<!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>[170758] trunk/Source</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/170758">170758</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-07-03 10:56:38 -0700 (Thu, 03 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Selection rects sent to ServicesOverlayController are wrong.
&lt;rdar://problem/16727796&gt; and https://bugs.webkit.org/show_bug.cgi?id=134568

Reviewed by Darin Adler (and Tim Horton and Ryosuke Niwa).

Source/WebCore:
* WebCore.exp.in:

Update the gatherer to keep GapRects separate from LayoutRects:
* editing/SelectionRectGatherer.cpp:
(WebCore::SelectionRectGatherer::addRects):
(WebCore::SelectionRectGatherer::Notifier::~Notifier):
(WebCore::SelectionRectGatherer::clearAndCreateNotifier):
* editing/SelectionRectGatherer.h:

* page/EditorClient.h:
(WebCore::EditorClient::selectionRectsDidChange): Updated to take LayoutRects and GapRects separately.

Change RenderSelectionInfo to also hang on to the individual rects that formed the final bounding rect:
* rendering/RenderSelectionInfo.h:
(WebCore::RenderSelectionInfo::RenderSelectionInfo): If the RenderObject is a RenderText, then call
  collectSelectionRectsForLineBoxes instead of selectionRectForRepaint.
(WebCore::RenderSelectionInfo::rects):

* rendering/RenderText.cpp:
(WebCore::RenderText::collectSelectionRectsForLineBoxes): Added
(WebCore::RenderText::selectionRectForRepaint):
* rendering/RenderText.h:

* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::collectSelectionRectsForRange): Added
* rendering/RenderTextLineBoxes.h:

* rendering/RenderView.cpp:
(WebCore::RenderView::setSubtreeSelection): Add the list of rects to the gatherer instead of just
  the bounding rect.

Source/WebKit2:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::selectionRectsDidChange): Also pass the GapRects to the ServicesOverlayController.
* WebProcess/WebCoreSupport/WebEditorClient.h:

* WebProcess/WebPage/ServicesOverlayController.h:
* WebProcess/WebPage/mac/ServicesOverlayController.mm:
(WebKit::expandForGap):
(WebKit::compactRectsWithGapRects): Combine 3+ rects down to exactly 3 rects, then expand them based on GapRects.
(WebKit::ServicesOverlayController::selectionRectsDidChange): Call compactRectsWithGapRects, then reverse the list.
(WebKit::ServicesOverlayController::drawSelectionHighlight): Tell data detectors to flip this.
(WebKit::ServicesOverlayController::drawTelephoneNumberHighlight): Tell data detectors to flip this.
(WebKit::ServicesOverlayController::drawCurrentHighlight): No need to flip this anymore.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreeditingSelectionRectGatherercpp">trunk/Source/WebCore/editing/SelectionRectGatherer.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingSelectionRectGathererh">trunk/Source/WebCore/editing/SelectionRectGatherer.h</a></li>
<li><a href="#trunkSourceWebCorepageEditorClienth">trunk/Source/WebCore/page/EditorClient.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderSelectionInfoh">trunk/Source/WebCore/rendering/RenderSelectionInfo.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextcpp">trunk/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTexth">trunk/Source/WebCore/rendering/RenderText.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextLineBoxescpp">trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextLineBoxesh">trunk/Source/WebCore/rendering/RenderTextLineBoxes.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageServicesOverlayControllerh">trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacServicesOverlayControllermm">trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/ChangeLog        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -19,6 +19,44 @@
</span><span class="cx"> 
</span><span class="cx"> 2014-07-03  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Selection rects sent to ServicesOverlayController are wrong.
+        &lt;rdar://problem/16727796&gt; and https://bugs.webkit.org/show_bug.cgi?id=134568
+
+        Reviewed by Darin Adler (and Tim Horton and Ryosuke Niwa).
+
+        * WebCore.exp.in:
+
+        Update the gatherer to keep GapRects separate from LayoutRects:
+        * editing/SelectionRectGatherer.cpp:
+        (WebCore::SelectionRectGatherer::addRects):
+        (WebCore::SelectionRectGatherer::Notifier::~Notifier):
+        (WebCore::SelectionRectGatherer::clearAndCreateNotifier):
+        * editing/SelectionRectGatherer.h:
+
+        * page/EditorClient.h:
+        (WebCore::EditorClient::selectionRectsDidChange): Updated to take LayoutRects and GapRects separately.
+
+        Change RenderSelectionInfo to also hang on to the individual rects that formed the final bounding rect:
+        * rendering/RenderSelectionInfo.h:
+        (WebCore::RenderSelectionInfo::RenderSelectionInfo): If the RenderObject is a RenderText, then call
+          collectSelectionRectsForLineBoxes instead of selectionRectForRepaint.
+        (WebCore::RenderSelectionInfo::rects):
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::collectSelectionRectsForLineBoxes): Added
+        (WebCore::RenderText::selectionRectForRepaint):
+        * rendering/RenderText.h:
+
+        * rendering/RenderTextLineBoxes.cpp:
+        (WebCore::RenderTextLineBoxes::collectSelectionRectsForRange): Added
+        * rendering/RenderTextLineBoxes.h:
+
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::setSubtreeSelection): Add the list of rects to the gatherer instead of just 
+          the bounding rect.
+
+2014-07-03  Brady Eidson  &lt;beidson@apple.com&gt;
+
</ins><span class="cx">         Possible crash in IconDatabase in WebCore::IconDatabase::dispatchDidRemoveAllIconsOnMainThread
</span><span class="cx">         &lt;rdar://problem/17437687&gt; and https://bugs.webkit.org/show_bug.cgi?id=134517
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -78,6 +78,7 @@
</span><span class="cx"> __ZN7WebCore10FontGlyphs15releaseFontDataEv
</span><span class="cx"> __ZN7WebCore10JSDocument6s_infoE
</span><span class="cx"> __ZN7WebCore10LayoutRect5scaleEf
</span><ins>+__ZN7WebCore10LayoutRect5uniteERKS0_
</ins><span class="cx"> __ZN7WebCore10LayoutRectC1ERKNS_9FloatRectE
</span><span class="cx"> __ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringENS1_10PassRefPtrINS_9DOMWindowEEERKNS_18PlatformMouseEventEiNS5_INS_4NodeEEE
</span><span class="cx"> __ZN7WebCore10Pasteboard14writePlainTextERKN3WTF6StringENS0_18SmartReplaceOptionE
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSelectionRectGatherercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SelectionRectGatherer.cpp (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SelectionRectGatherer.cpp        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/editing/SelectionRectGatherer.cpp        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -48,12 +48,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SelectionRectGatherer::addRects(const GapRects&amp; rects)
</span><span class="cx"> {
</span><del>-    if (!rects.left().isEmpty())
-        m_rects.append(rects.left());
-    if (!rects.right().isEmpty())
-        m_rects.append(rects.right());
-    if (!rects.center().isEmpty())
-        m_rects.append(rects.center());
</del><ins>+    m_gapRects.append(rects);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SelectionRectGatherer::Notifier::Notifier(SelectionRectGatherer&amp; gatherer)
</span><span class="lines">@@ -64,12 +59,13 @@
</span><span class="cx"> SelectionRectGatherer::Notifier::~Notifier()
</span><span class="cx"> {
</span><span class="cx">     if (EditorClient* client = m_gatherer.m_renderView.view().frame().editor().client())
</span><del>-        client-&gt;selectionRectsDidChange(m_gatherer.m_rects);
</del><ins>+        client-&gt;selectionRectsDidChange(m_gatherer.m_rects, m_gatherer.m_gapRects);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;SelectionRectGatherer::Notifier&gt; SelectionRectGatherer::clearAndCreateNotifier()
</span><span class="cx"> {
</span><span class="cx">     m_rects.clear();
</span><ins>+    m_gapRects.clear();
</ins><span class="cx"> 
</span><span class="cx">     return std::make_unique&lt;Notifier&gt;(*this);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSelectionRectGathererh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SelectionRectGatherer.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SelectionRectGatherer.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/editing/SelectionRectGatherer.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> private:
</span><span class="cx">     RenderView&amp; m_renderView;
</span><span class="cx">     Vector&lt;LayoutRect&gt; m_rects;
</span><ins>+    Vector&lt;GapRects&gt; m_gapRects;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EditorClient.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EditorClient.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/page/EditorClient.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx"> class VisibleSelection;
</span><span class="cx"> class VisiblePosition;
</span><span class="cx"> 
</span><ins>+struct GapRects;
</ins><span class="cx"> struct GrammarDetail;
</span><span class="cx"> 
</span><span class="cx"> class EditorClient {
</span><span class="lines">@@ -181,7 +182,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
</span><span class="cx">     virtual void selectedTelephoneNumberRangesChanged(const Vector&lt;RefPtr&lt;Range&gt;&gt;&amp;) { }
</span><del>-    virtual void selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp;) { }
</del><ins>+    virtual void selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp;, const Vector&lt;GapRects&gt;&amp;) { }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Support for global selections, used on platforms like the X Window System that treat
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderSelectionInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderSelectionInfo.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderSelectionInfo.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderSelectionInfo.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;IntRect.h&quot;
</span><span class="cx"> #include &quot;RenderBox.h&quot;
</span><ins>+#include &quot;RenderText.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -62,8 +63,14 @@
</span><span class="cx"> public:
</span><span class="cx">     RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent)
</span><span class="cx">         : RenderSelectionInfoBase(o)
</span><del>-        , m_rect(o-&gt;canUpdateSelectionOnRootLineBoxes() ? o-&gt;selectionRectForRepaint(m_repaintContainer, clipToVisibleContent) : LayoutRect())
</del><span class="cx">     {
</span><ins>+        ASSERT(o);
+        if (o-&gt;canUpdateSelectionOnRootLineBoxes()) {
+            if (o-&gt;isText())
+                m_rect = toRenderText(*o).collectSelectionRectsForLineBoxes(m_repaintContainer, clipToVisibleContent, m_rects);
+            else
+                m_rect = o-&gt;selectionRectForRepaint(m_repaintContainer, clipToVisibleContent);
+        }
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     void repaint()
</span><span class="lines">@@ -71,9 +78,11 @@
</span><span class="cx">         m_object-&gt;repaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rect));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    const Vector&lt;LayoutRect&gt;&amp; rects() const { return m_rects; }
</ins><span class="cx">     LayoutRect rect() const { return m_rect; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    Vector&lt;LayoutRect&gt; m_rects;
</ins><span class="cx">     LayoutRect m_rect; // relative to repaint container
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.cpp (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.cpp        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderText.cpp        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -1237,7 +1237,7 @@
</span><span class="cx">     return rendererToRepaint-&gt;clippedOverflowRectForRepaint(repaintContainer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-LayoutRect RenderText::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
</del><ins>+LayoutRect RenderText::collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector&lt;LayoutRect&gt;* rects)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!needsLayout());
</span><span class="cx">     ASSERT(!simpleLineLayout());
</span><span class="lines">@@ -1266,16 +1266,35 @@
</span><span class="cx">     if (startPos == endPos)
</span><span class="cx">         return IntRect();
</span><span class="cx"> 
</span><del>-    LayoutRect rect = m_lineBoxes.selectionRectForRange(startPos, endPos);
</del><ins>+    LayoutRect resultRect;
+    if (!rects)
+        resultRect = m_lineBoxes.selectionRectForRange(startPos, endPos);
+    else {
+        m_lineBoxes.collectSelectionRectsForRange(startPos, endPos, *rects);
+        for (auto&amp; rect : *rects) {
+            resultRect.unite(rect);
+            rect = localToContainerQuad(FloatRect(rect), repaintContainer).enclosingBoundingBox();
+        }
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (clipToVisibleContent)
</span><del>-        computeRectForRepaint(repaintContainer, rect);
</del><ins>+        computeRectForRepaint(repaintContainer, resultRect);
</ins><span class="cx">     else
</span><del>-        rect = localToContainerQuad(FloatRect(rect), repaintContainer).enclosingBoundingBox();
</del><ins>+        resultRect = localToContainerQuad(FloatRect(resultRect), repaintContainer).enclosingBoundingBox();
</ins><span class="cx"> 
</span><del>-    return rect;
</del><ins>+    return resultRect;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LayoutRect RenderText::collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector&lt;LayoutRect&gt;&amp; rects)
+{
+    return collectSelectionRectsForLineBoxes(repaintContainer, clipToVisibleContent, &amp;rects);
+}
+
+LayoutRect RenderText::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
+{
+    return collectSelectionRectsForLineBoxes(repaintContainer, clipToVisibleContent, nullptr);
+}
+
</ins><span class="cx"> int RenderText::caretMinOffset() const
</span><span class="cx"> {
</span><span class="cx">     if (auto layout = simpleLineLayout())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderText.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -109,6 +109,8 @@
</span><span class="cx">     virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override;
</span><span class="cx">     virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override;
</span><span class="cx"> 
</span><ins>+    LayoutRect collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector&lt;LayoutRect&gt;&amp; rects);
+
</ins><span class="cx">     LayoutUnit marginLeft() const { return minimumValueForLength(style().marginLeft(), 0); }
</span><span class="cx">     LayoutUnit marginRight() const { return minimumValueForLength(style().marginRight(), 0); }
</span><span class="cx"> 
</span><span class="lines">@@ -184,6 +186,8 @@
</span><span class="cx"> 
</span><span class="cx">     void secureText(UChar mask);
</span><span class="cx"> 
</span><ins>+    LayoutRect collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector&lt;LayoutRect&gt;*);
+
</ins><span class="cx">     void node() const = delete;
</span><span class="cx"> 
</span><span class="cx">     // We put the bitfield first to minimize padding on 64-bit.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextLineBoxescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -495,6 +495,17 @@
</span><span class="cx">     return rect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderTextLineBoxes::collectSelectionRectsForRange(unsigned start, unsigned end, Vector&lt;LayoutRect&gt;&amp; rects)
+{
+    for (auto box = m_first; box; box = box-&gt;nextTextBox()) {
+        LayoutRect rect;
+        rect.unite(box-&gt;localSelectionRect(start, end));
+        rect.unite(ellipsisRectForBox(*box, start, end));
+        if (!rect.size().isEmpty())
+            rects.append(rect);
+    }
+}
+
</ins><span class="cx"> Vector&lt;IntRect&gt; RenderTextLineBoxes::absoluteRects(const LayoutPoint&amp; accumulatedOffset) const
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;IntRect&gt; rects;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextLineBoxesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> 
</span><span class="cx">     void setSelectionState(RenderText&amp;, RenderObject::SelectionState);
</span><span class="cx">     LayoutRect selectionRectForRange(unsigned start, unsigned end);
</span><ins>+    void collectSelectionRectsForRange(unsigned start, unsigned end, Vector&lt;LayoutRect&gt;&amp; rects);
</ins><span class="cx"> 
</span><span class="cx">     IntRect boundingBox(const RenderText&amp;) const;
</span><span class="cx">     IntPoint firstRunLocation() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -992,7 +992,8 @@
</span><span class="cx">             std::unique_ptr&lt;RenderSelectionInfo&gt; selectionInfo = std::make_unique&lt;RenderSelectionInfo&gt;(o, true);
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><del>-            m_selectionRectGatherer.addRect(selectionInfo-&gt;rect());
</del><ins>+            for (auto&amp; rect : selectionInfo-&gt;rects())
+                m_selectionRectGatherer.addRect(rect);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">             newSelectedObjects.set(o, std::move(selectionInfo));
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -44,6 +44,26 @@
</span><span class="cx"> 
</span><span class="cx"> 2014-07-03  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Selection rects sent to ServicesOverlayController are wrong.
+        &lt;rdar://problem/16727796&gt; and https://bugs.webkit.org/show_bug.cgi?id=134568
+
+        Reviewed by Darin Adler (and Tim Horton and Ryosuke Niwa).
+
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::selectionRectsDidChange): Also pass the GapRects to the ServicesOverlayController.
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+
+        * WebProcess/WebPage/ServicesOverlayController.h:
+        * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+        (WebKit::expandForGap):
+        (WebKit::compactRectsWithGapRects): Combine 3+ rects down to exactly 3 rects, then expand them based on GapRects.
+        (WebKit::ServicesOverlayController::selectionRectsDidChange): Call compactRectsWithGapRects, then reverse the list.
+        (WebKit::ServicesOverlayController::drawSelectionHighlight): Tell data detectors to flip this.
+        (WebKit::ServicesOverlayController::drawTelephoneNumberHighlight): Tell data detectors to flip this.
+        (WebKit::ServicesOverlayController::drawCurrentHighlight): No need to flip this anymore.
+
+2014-07-03  Brady Eidson  &lt;beidson@apple.com&gt;
+
</ins><span class="cx">         Possible crash in IconDatabase in WebCore::IconDatabase::dispatchDidRemoveAllIconsOnMainThread
</span><span class="cx">         &lt;rdar://problem/17437687&gt; and https://bugs.webkit.org/show_bug.cgi?id=134517
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -531,11 +531,11 @@
</span><span class="cx">     m_page-&gt;servicesOverlayController().selectedTelephoneNumberRangesChanged(ranges);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><del>-void WebEditorClient::selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp; rects)
</del><ins>+void WebEditorClient::selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp; rects, const Vector&lt;GapRects&gt;&amp; gapRects)
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     if (m_page-&gt;serviceControlsEnabled())
</span><del>-        m_page-&gt;servicesOverlayController().selectionRectsDidChange(rects);
</del><ins>+        m_page-&gt;servicesOverlayController().selectionRectsDidChange(rects, gapRects);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(SERVICE_CONTROLS) &amp;&amp; ENABLE(TELEPHONE_NUMBER_DETECTION)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION) || ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     virtual void selectedTelephoneNumberRangesChanged(const Vector&lt;RefPtr&lt;WebCore::Range&gt;&gt;&amp;) override;
</span><del>-    virtual void selectionRectsDidChange(const Vector&lt;WebCore::LayoutRect&gt;&amp;) override;
</del><ins>+    virtual void selectionRectsDidChange(const Vector&lt;WebCore::LayoutRect&gt;&amp;, const Vector&lt;WebCore::GapRects&gt;&amp;) override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     WebPage* m_page;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageServicesOverlayControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class LayoutRect;
</span><span class="cx"> class Range;
</span><ins>+
+struct GapRects;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -48,7 +50,7 @@
</span><span class="cx">     ~ServicesOverlayController();
</span><span class="cx"> 
</span><span class="cx">     void selectedTelephoneNumberRangesChanged(const Vector&lt;RefPtr&lt;WebCore::Range&gt;&gt;&amp;);
</span><del>-    void selectionRectsDidChange(const Vector&lt;WebCore::LayoutRect&gt;&amp;);
</del><ins>+    void selectionRectsDidChange(const Vector&lt;WebCore::LayoutRect&gt;&amp;, const Vector&lt;WebCore::GapRects&gt;&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void createOverlayIfNeeded();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacServicesOverlayControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm (170757 => 170758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm        2014-07-03 17:13:02 UTC (rev 170757)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm        2014-07-03 17:56:38 UTC (rev 170758)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #import &lt;WebCore/Document.h&gt;
</span><span class="cx"> #import &lt;WebCore/FloatQuad.h&gt;
</span><span class="cx"> #import &lt;WebCore/FrameView.h&gt;
</span><ins>+#import &lt;WebCore/GapRects.h&gt;
</ins><span class="cx"> #import &lt;WebCore/GraphicsContext.h&gt;
</span><span class="cx"> #import &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><span class="lines">@@ -49,10 +50,10 @@
</span><span class="cx"> 
</span><span class="cx"> typedef NSUInteger DDHighlightStyle;
</span><span class="cx"> static const DDHighlightStyle DDHighlightNoOutlineWithArrow = (1 &lt;&lt; 16);
</span><ins>+static const DDHighlightStyle DDHighlightOutlineWithArrow = (1 &lt;&lt; 16) | 1;
</ins><span class="cx"> 
</span><span class="cx"> SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectors)
</span><del>-SOFT_LINK(DataDetectors, DDHighlightCreateWithRectsInVisibleRect, DDHighlightRef, (CFAllocatorRef allocator, CGRect * rects, CFIndex count, CGRect globalVisibleRect, Boolean withArrow), (allocator, rects, count, globalVisibleRect, withArrow))
-SOFT_LINK(DataDetectors, DDHighlightCreateWithRectsInVisibleRectWithStyle, DDHighlightRef, (CFAllocatorRef allocator, CGRect * rects, CFIndex count, CGRect globalVisibleRect, DDHighlightStyle style, Boolean withArrow), (allocator, rects, count, globalVisibleRect, style, withArrow))
</del><ins>+SOFT_LINK(DataDetectors, DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection, DDHighlightRef, (CFAllocatorRef allocator, CGRect* rects, CFIndex count, CGRect globalVisibleRect, DDHighlightStyle style, Boolean withArrow, NSWritingDirection writingDirection, Boolean endsWithEOL, Boolean flipped), (allocator, rects, count, globalVisibleRect, style, withArrow, writingDirection, endsWithEOL, flipped))
</ins><span class="cx"> SOFT_LINK(DataDetectors, DDHighlightGetLayerWithContext, CGLayerRef, (DDHighlightRef highlight, CGContextRef context), (highlight, context))
</span><span class="cx"> SOFT_LINK(DataDetectors, DDHighlightGetBoundingRect, CGRect, (DDHighlightRef highlight), (highlight))
</span><span class="cx"> SOFT_LINK(DataDetectors, DDHighlightPointIsOnHighlight, Boolean, (DDHighlightRef highlight, CGPoint point, Boolean* onButton), (highlight, point, onButton))
</span><span class="lines">@@ -128,12 +129,105 @@
</span><span class="cx">     m_servicesOverlay-&gt;setNeedsDisplay();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ServicesOverlayController::selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp; rects)
</del><ins>+static const uint8_t AlignmentNone = 0;
+static const uint8_t AlignmentLeft = 1 &lt;&lt; 0;
+static const uint8_t AlignmentRight = 1 &lt;&lt; 1;
+
+static void expandForGap(Vector&lt;LayoutRect&gt;&amp; rects, uint8_t* alignments, const GapRects&amp; gap)
</ins><span class="cx"> {
</span><ins>+    if (!gap.left().isEmpty()) {
+        LayoutUnit leftEdge = gap.left().x();
+        for (unsigned i = 0; i &lt; 3; ++i) {
+            if (alignments[i] &amp; AlignmentLeft)
+                rects[i].shiftXEdgeTo(leftEdge);
+        }
+    }
+
+    if (!gap.right().isEmpty()) {
+        LayoutUnit rightEdge = gap.right().maxX();
+        for (unsigned i = 0; i &lt; 3; ++i) {
+            if (alignments[i] &amp; AlignmentRight)
+                rects[i].shiftMaxXEdgeTo(rightEdge);
+        }
+    }
+}
+
+static void compactRectsWithGapRects(Vector&lt;LayoutRect&gt;&amp; rects, const Vector&lt;GapRects&gt;&amp; gapRects)
+{
+    if (rects.isEmpty())
+        return;
+
+    // All of the middle rects - everything but the first and last - can be unioned together.
+    if (rects.size() &gt; 3) {
+        LayoutRect united;
+        for (unsigned i = 1; i &lt; rects.size() - 1; ++i)
+            united.unite(rects[i]);
+
+        rects[1] = united;
+        rects[2] = rects.last();
+        rects.shrink(3);
+    }
+
+    // FIXME: The following alignments are correct for LTR text.
+    // We should also account for RTL.
+    uint8_t alignments[3];
+    if (rects.size() == 1) {
+        alignments[0] = AlignmentLeft | AlignmentRight;
+        alignments[1] = AlignmentNone;
+        alignments[2] = AlignmentNone;
+    } else if (rects.size() == 2) {
+        alignments[0] = AlignmentRight;
+        alignments[1] = AlignmentLeft;
+        alignments[2] = AlignmentNone;
+    } else {
+        alignments[0] = AlignmentRight;
+        alignments[1] = AlignmentLeft | AlignmentRight;
+        alignments[2] = AlignmentLeft;
+    }
+
+    // Account for each GapRects by extending the edge of certain LayoutRects to meet the gap.
+    for (auto&amp; gap : gapRects)
+        expandForGap(rects, alignments, gap);
+
+    // If we have 3 rects we might need one final GapRects to align the edges.
+    if (rects.size() == 3) {
+        LayoutRect left;
+        LayoutRect right;
+        for (unsigned i = 0; i &lt; 3; ++i) {
+            if (alignments[i] &amp; AlignmentLeft) {
+                if (left.isEmpty())
+                    left = rects[i];
+                else if (rects[i].x() &lt; left.x())
+                    left = rects[i];
+            }
+            if (alignments[i] &amp; AlignmentRight) {
+                if (right.isEmpty())
+                    right = rects[i];
+                else if ((rects[i].x() + rects[i].width()) &gt; (right.x() + right.width()))
+                    right = rects[i];
+            }
+        }
+
+        if (!left.isEmpty() || !right.isEmpty()) {
+            GapRects gap;
+            gap.uniteLeft(left);
+            gap.uniteRight(right);
+            expandForGap(rects, alignments, gap);
+        }
+    }
+}
+
+void ServicesOverlayController::selectionRectsDidChange(const Vector&lt;LayoutRect&gt;&amp; rects, const Vector&lt;GapRects&gt;&amp; gapRects)
+{
</ins><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1090
</span><span class="cx">     m_currentHighlightIsDirty = true;
</span><span class="cx">     m_currentSelectionRects = rects;
</span><span class="cx"> 
</span><ins>+    compactRectsWithGapRects(m_currentSelectionRects, gapRects);
+
+    // DataDetectors needs these reversed in order to place the arrow in the right location.
+    m_currentSelectionRects.reverse();
+
</ins><span class="cx">     createOverlayIfNeeded();
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(rects);
</span><span class="lines">@@ -205,12 +299,13 @@
</span><span class="cx"> 
</span><span class="cx">         if (!cgRects.isEmpty()) {
</span><span class="cx">             CGRect bounds = m_webPage-&gt;corePage()-&gt;mainFrame().view()-&gt;boundsRect();
</span><del>-            m_currentHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyle(nullptr, cgRects.begin(), cgRects.size(), bounds, DDHighlightNoOutlineWithArrow, true));
</del><ins>+            m_currentHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.begin(), cgRects.size(), bounds, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
</ins><span class="cx">             m_currentHighlightIsDirty = false;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    drawCurrentHighlight(graphicsContext);
</del><ins>+    if (m_currentHighlight)
+        drawCurrentHighlight(graphicsContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::drawTelephoneNumberHighlight(WebCore::GraphicsContext&amp; graphicsContext, const WebCore::IntRect&amp; dirtyRect)
</span><span class="lines">@@ -241,15 +336,18 @@
</span><span class="cx">     if (!m_currentHighlight || m_currentHighlightIsDirty) {
</span><span class="cx">         CGRect cgRect = (CGRect)rect;
</span><span class="cx"> 
</span><del>-        m_currentHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRect(nullptr, &amp;cgRect, 1, viewForRange-&gt;boundsRect(), true));
</del><ins>+        m_currentHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &amp;cgRect, 1, viewForRange-&gt;boundsRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
</ins><span class="cx">         m_currentHighlightIsDirty = false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    drawCurrentHighlight(graphicsContext);
</del><ins>+    if (m_currentHighlight)
+        drawCurrentHighlight(graphicsContext);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::drawCurrentHighlight(WebCore::GraphicsContext&amp; graphicsContext)
</span><span class="cx"> {
</span><ins>+    ASSERT(m_currentHighlight);
+
</ins><span class="cx">     Boolean onButton;
</span><span class="cx">     m_mouseIsOverHighlight = DDHighlightPointIsOnHighlight(m_currentHighlight.get(), (CGPoint)m_mousePosition, &amp;onButton);
</span><span class="cx"> 
</span><span class="lines">@@ -265,9 +363,7 @@
</span><span class="cx">     GraphicsContextStateSaver stateSaver(graphicsContext);
</span><span class="cx"> 
</span><span class="cx">     graphicsContext.translate(toFloatSize(highlightBoundingRect.origin));
</span><del>-    graphicsContext.scale(FloatSize(1, -1));
-    graphicsContext.translate(FloatSize(0, -highlightBoundingRect.size.height));
-    
</del><ins>+
</ins><span class="cx">     CGRect highlightDrawRect = highlightBoundingRect;
</span><span class="cx">     highlightDrawRect.origin.x = 0;
</span><span class="cx">     highlightDrawRect.origin.y = 0;
</span></span></pre>
</div>
</div>

</body>
</html>