<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170987] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170987">170987</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-07-10 17:49:02 -0700 (Thu, 10 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WK2] Move WKInspectorHighlightView to its own file
https://bugs.webkit.org/show_bug.cgi?id=134819

Reviewed by Joseph Pecoraro.

WKInspectorHighlightView brought a lot of path/quad-related code into WKContentView.mm,
so move it into its own file.

* UIProcess/WKInspectorHighlightView.h: Added.
* UIProcess/WKInspectorHighlightView.mm: Added.
(-[WKInspectorHighlightView dealloc]):
(-[WKInspectorHighlightView _removeAllLayers]):
(-[WKInspectorHighlightView _createLayers:]):
(findIntersectionOnLineBetweenPoints):
(quadIntersection):
(layerPathWithHole):
(layerPath):
(-[WKInspectorHighlightView _layoutForNodeHighlight:]):
(-[WKInspectorHighlightView _layoutForRectsHighlight:]):
(-[WKInspectorHighlightView update:]):
* UIProcess/ios/WKContentView.mm:
(-[WKInspectorHighlightView initWithFrame:]): Deleted.
(-[WKInspectorHighlightView dealloc]): Deleted.
(-[WKInspectorHighlightView _removeAllLayers]): Deleted.
(-[WKInspectorHighlightView _createLayers:]): Deleted.
(findIntersectionOnLineBetweenPoints): Deleted.
(quadIntersection): Deleted.
(layerPathWithHole): Deleted.
(layerPath): Deleted.
(-[WKInspectorHighlightView _layoutForNodeHighlight:]): Deleted.
(-[WKInspectorHighlightView _layoutForRectsHighlight:]): Deleted.
(-[WKInspectorHighlightView update:]): Deleted.
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewmm">trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessWKInspectorHighlightViewh">trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWKInspectorHighlightViewmm">trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170986 => 170987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-11 00:12:02 UTC (rev 170986)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-11 00:49:02 UTC (rev 170987)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2014-07-10  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] Move WKInspectorHighlightView to its own file
+        https://bugs.webkit.org/show_bug.cgi?id=134819
+
+        Reviewed by Joseph Pecoraro.
+        
+        WKInspectorHighlightView brought a lot of path/quad-related code into WKContentView.mm,
+        so move it into its own file.
+
+        * UIProcess/WKInspectorHighlightView.h: Added.
+        * UIProcess/WKInspectorHighlightView.mm: Added.
+        (-[WKInspectorHighlightView dealloc]):
+        (-[WKInspectorHighlightView _removeAllLayers]):
+        (-[WKInspectorHighlightView _createLayers:]):
+        (findIntersectionOnLineBetweenPoints):
+        (quadIntersection):
+        (layerPathWithHole):
+        (layerPath):
+        (-[WKInspectorHighlightView _layoutForNodeHighlight:]):
+        (-[WKInspectorHighlightView _layoutForRectsHighlight:]):
+        (-[WKInspectorHighlightView update:]):
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKInspectorHighlightView initWithFrame:]): Deleted.
+        (-[WKInspectorHighlightView dealloc]): Deleted.
+        (-[WKInspectorHighlightView _removeAllLayers]): Deleted.
+        (-[WKInspectorHighlightView _createLayers:]): Deleted.
+        (findIntersectionOnLineBetweenPoints): Deleted.
+        (quadIntersection): Deleted.
+        (layerPathWithHole): Deleted.
+        (layerPath): Deleted.
+        (-[WKInspectorHighlightView _layoutForNodeHighlight:]): Deleted.
+        (-[WKInspectorHighlightView _layoutForRectsHighlight:]): Deleted.
+        (-[WKInspectorHighlightView update:]): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-07-10  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r170935): WKWebView is always transparent until the first layer tree commit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWKInspectorHighlightViewh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.h (0 => 170987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.h        2014-07-11 00:49:02 UTC (rev 170987)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(IOS)
+
+#import &lt;UIKit/UIKit.h&gt;
+
+namespace WebCore {
+struct Highlight;
+}
+
+@interface WKInspectorHighlightView : UIView {
+    NSMutableArray *_layers; // CAShapeLayers.
+}
+- (void)update:(const WebCore::Highlight&amp;)highlight;
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWKInspectorHighlightViewmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.mm (0 => 170987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WKInspectorHighlightView.mm        2014-07-11 00:49:02 UTC (rev 170987)
</span><span class="lines">@@ -0,0 +1,268 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;WKInspectorHighlightView.h&quot;
+
+#if PLATFORM(IOS)
+
+#import &lt;WebCore/FloatQuad.h&gt;
+#import &lt;WebCore/GeometryUtilities.h&gt;
+#import &lt;WebCore/InspectorOverlay.h&gt;
+
+using namespace WebCore;
+
+@implementation WKInspectorHighlightView
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+    _layers = [[NSMutableArray alloc] init];
+    return self;
+}
+
+- (void)dealloc
+{
+    [self _removeAllLayers];
+    [_layers release];
+    [super dealloc];
+}
+
+- (void)_removeAllLayers
+{
+    for (CAShapeLayer *layer in _layers)
+        [layer removeFromSuperlayer];
+    [_layers removeAllObjects];
+}
+
+- (void)_createLayers:(NSUInteger)numLayers
+{
+    if ([_layers count] == numLayers)
+        return;
+
+    [self _removeAllLayers];
+
+    for (NSUInteger i = 0; i &lt; numLayers; ++i) {
+        CAShapeLayer *layer = [[CAShapeLayer alloc] init];
+        [_layers addObject:layer];
+        [self.layer addSublayer:layer];
+        [layer release];
+    }
+}
+
+static bool findIntersectionOnLineBetweenPoints(const FloatPoint&amp; p1, const FloatPoint&amp; p2, const FloatPoint&amp; d1, const FloatPoint&amp; d2, FloatPoint&amp; intersection) 
+{
+    // Do the lines intersect?
+    FloatPoint temporaryIntersectionPoint;
+    if (!findIntersection(p1, p2, d1, d2, temporaryIntersectionPoint))
+        return false;
+
+    // Is the intersection between the two points on the line?
+    if (p1.x() &gt;= p2.x()) {
+        if (temporaryIntersectionPoint.x() &gt; p1.x() || temporaryIntersectionPoint.x() &lt; p2.x())
+            return false;
+    } else {
+        if (temporaryIntersectionPoint.x() &gt; p2.x() || temporaryIntersectionPoint.x() &lt; p1.x())
+            return false;
+    }
+    if (p1.y() &gt;= p2.y()) {
+        if (temporaryIntersectionPoint.y() &gt; p1.y() || temporaryIntersectionPoint.y() &lt; p2.y())
+            return false;
+    } else {
+        if (temporaryIntersectionPoint.y() &gt; p2.y() || temporaryIntersectionPoint.y() &lt; p1.y())
+            return false;
+    }
+
+    intersection = temporaryIntersectionPoint;
+    return true;
+}
+
+// This quad intersection works because the two quads are known to be at the same
+// rotation and clockwise-ness.
+static FloatQuad quadIntersection(FloatQuad bounds, FloatQuad toClamp)
+{
+    // Resulting points.
+    FloatPoint p1, p2, p3, p4;
+    bool containsPoint1 = false;
+    bool containsPoint2 = false;
+    bool containsPoint3 = false;
+    bool containsPoint4 = false;
+    bool intersectForPoint1 = false;
+    bool intersectForPoint2 = false;
+    bool intersectForPoint3 = false;
+    bool intersectForPoint4 = false;
+
+    // Top / bottom vertical clamping.
+    if (bounds.containsPoint(toClamp.p1())) {
+        containsPoint1 = true;
+        p1 = toClamp.p1();
+    } else if (!(intersectForPoint1 = findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p2(), toClamp.p1(), toClamp.p4(), p1)))
+        p1 = toClamp.p1();
+
+    if (bounds.containsPoint(toClamp.p2())) {
+        containsPoint2 = true;
+        p2 = toClamp.p2();
+    } else if (!(intersectForPoint2 = findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p2(), toClamp.p2(), toClamp.p3(), p2)))
+        p2 = toClamp.p2();
+
+    if (bounds.containsPoint(toClamp.p3())) {
+        containsPoint3 = true;
+        p3 = toClamp.p3();
+    } else if (!(intersectForPoint3 = findIntersectionOnLineBetweenPoints(bounds.p4(), bounds.p3(), toClamp.p2(), toClamp.p3(), p3)))
+        p3 = toClamp.p3();
+
+    if (bounds.containsPoint(toClamp.p4())) {
+        containsPoint4 = true;
+        p4 = toClamp.p4();
+    } else if (!(intersectForPoint4 = findIntersectionOnLineBetweenPoints(bounds.p4(), bounds.p3(), toClamp.p1(), toClamp.p4(), p4)))
+        p4 = toClamp.p4();
+
+    // If only one of the points intersected on either the top or bottom line then we
+    // can clamp the other point on that line to the corner of the bounds.
+    if (!containsPoint1 &amp;&amp; intersectForPoint2 &amp;&amp; !intersectForPoint1) {
+        containsPoint1 = true;
+        p1 = bounds.p1();
+    } else if (!containsPoint2 &amp;&amp; intersectForPoint1 &amp;&amp; !intersectForPoint2) {
+        containsPoint2 = true;
+        p2 = bounds.p2();
+    }
+    if (!containsPoint4 &amp;&amp; intersectForPoint3 &amp;&amp; !intersectForPoint4) {
+        containsPoint4 = true;
+        p4 = bounds.p4();
+    } else if (!containsPoint3 &amp;&amp; intersectForPoint4 &amp;&amp; !intersectForPoint3) {
+        containsPoint3 = true;
+        p3 = bounds.p3();
+    }
+
+    // Now we only need to perform horizontal clamping for unadjusted points.
+    if (!containsPoint2 &amp;&amp; !intersectForPoint2)
+        findIntersectionOnLineBetweenPoints(bounds.p2(), bounds.p3(), p1, p2, p2);
+    if (!containsPoint3 &amp;&amp; !intersectForPoint3)
+        findIntersectionOnLineBetweenPoints(bounds.p2(), bounds.p3(), p4, p3, p3);
+    if (!containsPoint1 &amp;&amp; !intersectForPoint1)
+        findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p4(), p1, p2, p1);
+    if (!containsPoint4 &amp;&amp; !intersectForPoint4)
+        findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p4(), p4, p3, p4);
+
+    return FloatQuad(p1, p2, p3, p4);
+}
+
+static void layerPathWithHole(CAShapeLayer *layer, const FloatQuad&amp; outerQuad, const FloatQuad&amp; holeQuad)
+{
+    // Nothing to show.
+    if (outerQuad == holeQuad || holeQuad.containsQuad(outerQuad)) {
+        layer.path = NULL;
+        return;
+    }
+
+    // If there is a negative margin / padding then the outer box might not
+    // fully contain the hole box. In such cases we recalculate the hole to
+    // be the intersection of the two quads.
+    FloatQuad innerHole;
+    if (outerQuad.containsQuad(holeQuad))
+        innerHole = holeQuad;
+    else
+        innerHole = quadIntersection(outerQuad, holeQuad);
+
+    // Clockwise inside rect (hole), Counter-Clockwise outside rect (fill).
+    CGMutablePathRef path = CGPathCreateMutable();
+    CGPathMoveToPoint(path, 0, innerHole.p1().x(), innerHole.p1().y());
+    CGPathAddLineToPoint(path, 0, innerHole.p2().x(), innerHole.p2().y());
+    CGPathAddLineToPoint(path, 0, innerHole.p3().x(), innerHole.p3().y());
+    CGPathAddLineToPoint(path, 0, innerHole.p4().x(), innerHole.p4().y());
+    CGPathMoveToPoint(path, 0, outerQuad.p1().x(), outerQuad.p1().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p4().x(), outerQuad.p4().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p3().x(), outerQuad.p3().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p2().x(), outerQuad.p2().y());
+    layer.path = path;
+    CGPathRelease(path);
+}
+
+static void layerPath(CAShapeLayer *layer, const FloatQuad&amp; outerQuad)
+{
+    CGMutablePathRef path = CGPathCreateMutable();
+    CGPathMoveToPoint(path, 0, outerQuad.p1().x(), outerQuad.p1().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p4().x(), outerQuad.p4().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p3().x(), outerQuad.p3().y());
+    CGPathAddLineToPoint(path, 0, outerQuad.p2().x(), outerQuad.p2().y());
+    layer.path = path;
+    CGPathRelease(path);
+}
+
+- (void)_layoutForNodeHighlight:(const Highlight&amp;)highlight
+{
+    [self _createLayers:4];
+
+    CAShapeLayer *marginLayer = [_layers objectAtIndex:0];
+    CAShapeLayer *borderLayer = [_layers objectAtIndex:1];
+    CAShapeLayer *paddingLayer = [_layers objectAtIndex:2];
+    CAShapeLayer *contentLayer = [_layers objectAtIndex:3];
+
+    FloatQuad marginQuad = highlight.quads[0];
+    FloatQuad borderQuad = highlight.quads[1];
+    FloatQuad paddingQuad = highlight.quads[2];
+    FloatQuad contentQuad = highlight.quads[3];
+
+    marginLayer.fillColor = cachedCGColor(highlight.marginColor, ColorSpaceDeviceRGB);
+    borderLayer.fillColor = cachedCGColor(highlight.borderColor, ColorSpaceDeviceRGB);
+    paddingLayer.fillColor = cachedCGColor(highlight.paddingColor, ColorSpaceDeviceRGB);
+    contentLayer.fillColor = cachedCGColor(highlight.contentColor, ColorSpaceDeviceRGB);
+
+    layerPathWithHole(marginLayer, marginQuad, borderQuad);
+    layerPathWithHole(borderLayer, borderQuad, paddingQuad);
+    layerPathWithHole(paddingLayer, paddingQuad, contentQuad);
+    layerPath(contentLayer, contentQuad);
+}
+
+- (void)_layoutForRectsHighlight:(const Highlight&amp;)highlight
+{
+    NSUInteger numLayers = (NSUInteger)highlight.quads.size();
+    if (!numLayers) {
+        [self _removeAllLayers];
+        return;
+    }
+
+    [self _createLayers:numLayers];
+
+    CGColorRef contentColor = cachedCGColor(highlight.contentColor, ColorSpaceDeviceRGB);
+    for (NSUInteger i = 0; i &lt; numLayers; ++i) {
+        CAShapeLayer *layer = [_layers objectAtIndex:i];
+        layer.fillColor = contentColor;
+        layerPath(layer, highlight.quads[i]);
+    }
+}
+
+- (void)update:(const Highlight&amp;)highlight
+{
+    if (highlight.type == HighlightTypeNode)
+        [self _layoutForNodeHighlight:highlight];
+    else if (highlight.type == HighlightTypeRects)
+        [self _layoutForRectsHighlight:highlight];
+}
+
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (170986 => 170987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm        2014-07-11 00:12:02 UTC (rev 170986)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm        2014-07-11 00:49:02 UTC (rev 170987)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #import &quot;WKBrowsingContextControllerInternal.h&quot;
</span><span class="cx"> #import &quot;WKBrowsingContextGroupPrivate.h&quot;
</span><span class="cx"> #import &quot;WKGeolocationProviderIOS.h&quot;
</span><ins>+#import &quot;WKInspectorHighlightView.h&quot;
</ins><span class="cx"> #import &quot;WKPreferencesInternal.h&quot;
</span><span class="cx"> #import &quot;WKProcessGroupPrivate.h&quot;
</span><span class="cx"> #import &quot;WKProcessPoolInternal.h&quot;
</span><span class="lines">@@ -50,7 +51,6 @@
</span><span class="cx"> #import &lt;UIKit/UIWindow_Private.h&gt;
</span><span class="cx"> #import &lt;WebCore/FloatQuad.h&gt;
</span><span class="cx"> #import &lt;WebCore/FrameView.h&gt;
</span><del>-#import &lt;WebCore/GeometryUtilities.h&gt;
</del><span class="cx"> #import &lt;WebCore/InspectorOverlay.h&gt;
</span><span class="cx"> #import &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #import &lt;wtf/CurrentTime.h&gt;
</span><span class="lines">@@ -173,245 +173,6 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-
-@interface WKInspectorHighlightView : UIView {
-    NSMutableArray *_layers; // CAShapeLayers.
-}
-- (void)update:(const WebCore::Highlight&amp;)highlight;
-@end
-
-@implementation WKInspectorHighlightView
-
-- (instancetype)initWithFrame:(CGRect)frame
-{
-    if (!(self = [super initWithFrame:frame]))
-        return nil;
-    _layers = [[NSMutableArray alloc] init];
-    return self;
-}
-
-- (void)dealloc
-{
-    [self _removeAllLayers];
-    [_layers release];
-    [super dealloc];
-}
-
-- (void)_removeAllLayers
-{
-    for (CAShapeLayer *layer in _layers)
-        [layer removeFromSuperlayer];
-    [_layers removeAllObjects];
-}
-
-- (void)_createLayers:(NSUInteger)numLayers
-{
-    if ([_layers count] == numLayers)
-        return;
-
-    [self _removeAllLayers];
-
-    for (NSUInteger i = 0; i &lt; numLayers; ++i) {
-        CAShapeLayer *layer = [[CAShapeLayer alloc] init];
-        [_layers addObject:layer];
-        [self.layer addSublayer:layer];
-        [layer release];
-    }
-}
-
-static bool findIntersectionOnLineBetweenPoints(const FloatPoint&amp; p1, const FloatPoint&amp; p2, const FloatPoint&amp; d1, const FloatPoint&amp; d2, FloatPoint&amp; intersection) 
-{
-    // Do the lines intersect?
-    FloatPoint temporaryIntersectionPoint;
-    if (!findIntersection(p1, p2, d1, d2, temporaryIntersectionPoint))
-        return false;
-
-    // Is the intersection between the two points on the line?
-    if (p1.x() &gt;= p2.x()) {
-        if (temporaryIntersectionPoint.x() &gt; p1.x() || temporaryIntersectionPoint.x() &lt; p2.x())
-            return false;
-    } else {
-        if (temporaryIntersectionPoint.x() &gt; p2.x() || temporaryIntersectionPoint.x() &lt; p1.x())
-            return false;
-    }
-    if (p1.y() &gt;= p2.y()) {
-        if (temporaryIntersectionPoint.y() &gt; p1.y() || temporaryIntersectionPoint.y() &lt; p2.y())
-            return false;
-    } else {
-        if (temporaryIntersectionPoint.y() &gt; p2.y() || temporaryIntersectionPoint.y() &lt; p1.y())
-            return false;
-    }
-
-    intersection = temporaryIntersectionPoint;
-    return true;
-}
-
-// This quad intersection works because the two quads are known to be at the same
-// rotation and clockwise-ness.
-static FloatQuad quadIntersection(FloatQuad bounds, FloatQuad toClamp)
-{
-    // Resulting points.
-    FloatPoint p1, p2, p3, p4;
-    bool containsPoint1 = false;
-    bool containsPoint2 = false;
-    bool containsPoint3 = false;
-    bool containsPoint4 = false;
-    bool intersectForPoint1 = false;
-    bool intersectForPoint2 = false;
-    bool intersectForPoint3 = false;
-    bool intersectForPoint4 = false;
-
-    // Top / bottom vertical clamping.
-    if (bounds.containsPoint(toClamp.p1())) {
-        containsPoint1 = true;
-        p1 = toClamp.p1();
-    } else if (!(intersectForPoint1 = findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p2(), toClamp.p1(), toClamp.p4(), p1)))
-        p1 = toClamp.p1();
-
-    if (bounds.containsPoint(toClamp.p2())) {
-        containsPoint2 = true;
-        p2 = toClamp.p2();
-    } else if (!(intersectForPoint2 = findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p2(), toClamp.p2(), toClamp.p3(), p2)))
-        p2 = toClamp.p2();
-
-    if (bounds.containsPoint(toClamp.p3())) {
-        containsPoint3 = true;
-        p3 = toClamp.p3();
-    } else if (!(intersectForPoint3 = findIntersectionOnLineBetweenPoints(bounds.p4(), bounds.p3(), toClamp.p2(), toClamp.p3(), p3)))
-        p3 = toClamp.p3();
-
-    if (bounds.containsPoint(toClamp.p4())) {
-        containsPoint4 = true;
-        p4 = toClamp.p4();
-    } else if (!(intersectForPoint4 = findIntersectionOnLineBetweenPoints(bounds.p4(), bounds.p3(), toClamp.p1(), toClamp.p4(), p4)))
-        p4 = toClamp.p4();
-
-    // If only one of the points intersected on either the top or bottom line then we
-    // can clamp the other point on that line to the corner of the bounds.
-    if (!containsPoint1 &amp;&amp; intersectForPoint2 &amp;&amp; !intersectForPoint1) {
-        containsPoint1 = true;
-        p1 = bounds.p1();
-    } else if (!containsPoint2 &amp;&amp; intersectForPoint1 &amp;&amp; !intersectForPoint2) {
-        containsPoint2 = true;
-        p2 = bounds.p2();
-    }
-    if (!containsPoint4 &amp;&amp; intersectForPoint3 &amp;&amp; !intersectForPoint4) {
-        containsPoint4 = true;
-        p4 = bounds.p4();
-    } else if (!containsPoint3 &amp;&amp; intersectForPoint4 &amp;&amp; !intersectForPoint3) {
-        containsPoint3 = true;
-        p3 = bounds.p3();
-    }
-
-    // Now we only need to perform horizontal clamping for unadjusted points.
-    if (!containsPoint2 &amp;&amp; !intersectForPoint2)
-        findIntersectionOnLineBetweenPoints(bounds.p2(), bounds.p3(), p1, p2, p2);
-    if (!containsPoint3 &amp;&amp; !intersectForPoint3)
-        findIntersectionOnLineBetweenPoints(bounds.p2(), bounds.p3(), p4, p3, p3);
-    if (!containsPoint1 &amp;&amp; !intersectForPoint1)
-        findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p4(), p1, p2, p1);
-    if (!containsPoint4 &amp;&amp; !intersectForPoint4)
-        findIntersectionOnLineBetweenPoints(bounds.p1(), bounds.p4(), p4, p3, p4);
-
-    return FloatQuad(p1, p2, p3, p4);
-}
-
-static void layerPathWithHole(CAShapeLayer *layer, const FloatQuad&amp; outerQuad, const FloatQuad&amp; holeQuad)
-{
-    // Nothing to show.
-    if (outerQuad == holeQuad || holeQuad.containsQuad(outerQuad)) {
-        layer.path = NULL;
-        return;
-    }
-
-    // If there is a negative margin / padding then the outer box might not
-    // fully contain the hole box. In such cases we recalculate the hole to
-    // be the intersection of the two quads.
-    FloatQuad innerHole;
-    if (outerQuad.containsQuad(holeQuad))
-        innerHole = holeQuad;
-    else
-        innerHole = quadIntersection(outerQuad, holeQuad);
-
-    // Clockwise inside rect (hole), Counter-Clockwise outside rect (fill).
-    CGMutablePathRef path = CGPathCreateMutable();
-    CGPathMoveToPoint(path, 0, innerHole.p1().x(), innerHole.p1().y());
-    CGPathAddLineToPoint(path, 0, innerHole.p2().x(), innerHole.p2().y());
-    CGPathAddLineToPoint(path, 0, innerHole.p3().x(), innerHole.p3().y());
-    CGPathAddLineToPoint(path, 0, innerHole.p4().x(), innerHole.p4().y());
-    CGPathMoveToPoint(path, 0, outerQuad.p1().x(), outerQuad.p1().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p4().x(), outerQuad.p4().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p3().x(), outerQuad.p3().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p2().x(), outerQuad.p2().y());
-    layer.path = path;
-    CGPathRelease(path);
-}
-
-static void layerPath(CAShapeLayer *layer, const FloatQuad&amp; outerQuad)
-{
-    CGMutablePathRef path = CGPathCreateMutable();
-    CGPathMoveToPoint(path, 0, outerQuad.p1().x(), outerQuad.p1().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p4().x(), outerQuad.p4().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p3().x(), outerQuad.p3().y());
-    CGPathAddLineToPoint(path, 0, outerQuad.p2().x(), outerQuad.p2().y());
-    layer.path = path;
-    CGPathRelease(path);
-}
-
-- (void)_layoutForNodeHighlight:(const Highlight&amp;)highlight
-{
-    [self _createLayers:4];
-
-    CAShapeLayer *marginLayer = [_layers objectAtIndex:0];
-    CAShapeLayer *borderLayer = [_layers objectAtIndex:1];
-    CAShapeLayer *paddingLayer = [_layers objectAtIndex:2];
-    CAShapeLayer *contentLayer = [_layers objectAtIndex:3];
-
-    FloatQuad marginQuad = highlight.quads[0];
-    FloatQuad borderQuad = highlight.quads[1];
-    FloatQuad paddingQuad = highlight.quads[2];
-    FloatQuad contentQuad = highlight.quads[3];
-
-    marginLayer.fillColor = cachedCGColor(highlight.marginColor, ColorSpaceDeviceRGB);
-    borderLayer.fillColor = cachedCGColor(highlight.borderColor, ColorSpaceDeviceRGB);
-    paddingLayer.fillColor = cachedCGColor(highlight.paddingColor, ColorSpaceDeviceRGB);
-    contentLayer.fillColor = cachedCGColor(highlight.contentColor, ColorSpaceDeviceRGB);
-
-    layerPathWithHole(marginLayer, marginQuad, borderQuad);
-    layerPathWithHole(borderLayer, borderQuad, paddingQuad);
-    layerPathWithHole(paddingLayer, paddingQuad, contentQuad);
-    layerPath(contentLayer, contentQuad);
-}
-
-- (void)_layoutForRectsHighlight:(const Highlight&amp;)highlight
-{
-    NSUInteger numLayers = (NSUInteger)highlight.quads.size();
-    if (!numLayers) {
-        [self _removeAllLayers];
-        return;
-    }
-
-    [self _createLayers:numLayers];
-
-    CGColorRef contentColor = cachedCGColor(highlight.contentColor, ColorSpaceDeviceRGB);
-    for (NSUInteger i = 0; i &lt; numLayers; ++i) {
-        CAShapeLayer *layer = [_layers objectAtIndex:i];
-        layer.fillColor = contentColor;
-        layerPath(layer, highlight.quads[i]);
-    }
-}
-
-- (void)update:(const Highlight&amp;)highlight
-{
-    if (highlight.type == HighlightTypeNode)
-        [self _layoutForNodeHighlight:highlight];
-    else if (highlight.type == HighlightTypeRects)
-        [self _layoutForRectsHighlight:highlight];
-}
-
-@end
-
-
</del><span class="cx"> @implementation WKContentView {
</span><span class="cx">     std::unique_ptr&lt;PageClientImpl&gt; _pageClient;
</span><span class="cx">     RetainPtr&lt;WKBrowsingContextController&gt; _browsingContextController;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (170986 => 170987)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-07-11 00:12:02 UTC (rev 170986)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-07-11 00:49:02 UTC (rev 170987)
</span><span class="lines">@@ -69,6 +69,8 @@
</span><span class="cx">                 0F0C365E18C110A500F607D7 /* LayerRepresentation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F0C365D18C110A500F607D7 /* LayerRepresentation.mm */; };
</span><span class="cx">                 0F174AA3142A4CB70039250F /* APIGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F174AA2142A4CB60039250F /* APIGeometry.h */; };
</span><span class="cx">                 0F174AA7142AAC610039250F /* WKGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F174AA6142AAC610039250F /* WKGeometry.cpp */; };
</span><ins>+                0F3C725B196F604E00AEDD0C /* WKInspectorHighlightView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */; };
+                0F3C725C196F605200AEDD0C /* WKInspectorHighlightView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */; };
</ins><span class="cx">                 0F594790187B3B3A00437857 /* RemoteScrollingCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F59478D187B3B3A00437857 /* RemoteScrollingCoordinator.h */; };
</span><span class="cx">                 0F594792187B3B3A00437857 /* RemoteScrollingCoordinator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F59478F187B3B3A00437857 /* RemoteScrollingCoordinator.mm */; };
</span><span class="cx">                 0F59479A187B3B6000437857 /* RemoteScrollingCoordinatorProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F594794187B3B6000437857 /* RemoteScrollingCoordinatorProxy.cpp */; };
</span><span class="lines">@@ -1992,6 +1994,8 @@
</span><span class="cx">                 0F0C365D18C110A500F607D7 /* LayerRepresentation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LayerRepresentation.mm; path = ios/LayerRepresentation.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F174AA2142A4CB60039250F /* APIGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIGeometry.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F174AA6142AAC610039250F /* WKGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKGeometry.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorHighlightView.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKInspectorHighlightView.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0F59478D187B3B3A00437857 /* RemoteScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteScrollingCoordinator.h; path = Scrolling/RemoteScrollingCoordinator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F59478E187B3B3A00437857 /* RemoteScrollingCoordinator.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = RemoteScrollingCoordinator.messages.in; path = Scrolling/RemoteScrollingCoordinator.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F59478F187B3B3A00437857 /* RemoteScrollingCoordinator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RemoteScrollingCoordinator.mm; path = Scrolling/RemoteScrollingCoordinator.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4828,6 +4832,8 @@
</span><span class="cx">                                 0FCB4E3F18BBE044000FCFC9 /* WKGeolocationProviderIOS.h */,
</span><span class="cx">                                 0FCB4E4018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm */,
</span><span class="cx">                                 0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */,
</span><ins>+                                0F3C7259196F5F6800AEDD0C /* WKInspectorHighlightView.h */,
+                                0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */,
</ins><span class="cx">                                 A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */,
</span><span class="cx">                                 A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */,
</span><span class="cx">                                 0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */,
</span><span class="lines">@@ -7217,6 +7223,7 @@
</span><span class="cx">                                 513A164D1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h in Headers */,
</span><span class="cx">                                 379A873C18BBFF0700588AF2 /* _WKElementActionInternal.h in Headers */,
</span><span class="cx">                                 51DD9F2916367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h in Headers */,
</span><ins>+                                0F3C725B196F604E00AEDD0C /* WKInspectorHighlightView.h in Headers */,
</ins><span class="cx">                                 5179556A162876F300FA43B6 /* NetworkProcess.h in Headers */,
</span><span class="cx">                                 517CF0E4163A486C00C2950E /* NetworkProcessConnectionMessages.h in Headers */,
</span><span class="cx">                                 51795571162877D200FA43B6 /* NetworkProcessCreationParameters.h in Headers */,
</span><span class="lines">@@ -9016,6 +9023,7 @@
</span><span class="cx">                                 515E772B184008B90007203F /* DatabaseProcessCreationParameters.cpp in Sources */,
</span><span class="cx">                                 1A6420E412DCE2FF00CAAE2C /* ShareableBitmap.cpp in Sources */,
</span><span class="cx">                                 C01A260112662F2100C9ED55 /* ShareableBitmapCG.cpp in Sources */,
</span><ins>+                                0F3C725C196F605200AEDD0C /* WKInspectorHighlightView.mm in Sources */,
</ins><span class="cx">                                 1F7506AF1859162800EC0FF7 /* WKWebProcessPlugInNodeHandle.mm in Sources */,
</span><span class="cx">                                 51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
</span><span class="cx">                                 1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>