<!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>[189178] 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/189178">189178</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-08-31 11:40:24 -0700 (Mon, 31 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>iOS WebKit2 find-in-page doesn't support multi-line results, is often blank
https://bugs.webkit.org/show_bug.cgi?id=148599
&lt;rdar://problem/17914031&gt;

Reviewed by Beth Dakin.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::findString):
(WebKit::FindController::didFindString):
* WebProcess/WebPage/FindController.h:
Add didFindString() for FindControllerIOS.

* WebProcess/WebPage/ios/FindControllerIOS.mm:
(WebKit::FindIndicatorOverlayClientIOS::drawRect):
(WebKit::FindController::updateFindIndicator):
(WebKit::setCompositionSelectionChangeEnabledInAllFrames):
(WebKit::FindController::willFindString):
(WebKit::FindController::didFindString):
(WebKit::FindController::didFailToFindString):
(WebKit::FindController::didHideFindIndicator):
* WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h:
(WebKit::FindIndicatorOverlayClientIOS::FindIndicatorOverlayClientIOS):
Adopt TextIndicator and shrink-wrapping.

We'll re-create the indicator if the device/page scale factor change;
this is the only case in which a TextIndicator sticks around when
page scale changes -- we should come up with a better model!

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::getClippedVisibleTextRectangles):
(WebCore::FrameSelection::getTextRectangles):
* editing/FrameSelection.h:
* page/TextIndicator.cpp:
(WebCore::initializeIndicator):
* page/TextIndicator.h:
Make it possible to create a TextIndicator that isn't clipped to the visible rect,
because iOS find-in-page TextIndicators persist while scrolling the page,
and are already constrained to the document rect anyway.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectioncpp">trunk/Source/WebCore/editing/FrameSelection.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectionh">trunk/Source/WebCore/editing/FrameSelection.h</a></li>
<li><a href="#trunkSourceWebCorepageTextIndicatorcpp">trunk/Source/WebCore/page/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebCorepageTextIndicatorh">trunk/Source/WebCore/page/TextIndicator.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageFindControllercpp">trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageFindControllerh">trunk/Source/WebKit2/WebProcess/WebPage/FindController.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosFindControllerIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosFindIndicatorOverlayClientIOSh">trunk/Source/WebKit2/WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebCore/ChangeLog        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-08-31  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        iOS WebKit2 find-in-page doesn't support multi-line results, is often blank
+        https://bugs.webkit.org/show_bug.cgi?id=148599
+        &lt;rdar://problem/17914031&gt;
+
+        Reviewed by Beth Dakin.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::getClippedVisibleTextRectangles):
+        (WebCore::FrameSelection::getTextRectangles):
+        * editing/FrameSelection.h:
+        * page/TextIndicator.cpp:
+        (WebCore::initializeIndicator):
+        * page/TextIndicator.h:
+        Make it possible to create a TextIndicator that isn't clipped to the visible rect,
+        because iOS find-in-page TextIndicators persist while scrolling the page,
+        and are already constrained to the document rect anyway.
+
</ins><span class="cx"> 2015-08-31  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Freetype] FontCache::strengthOfFirstAlias leaks an FcPattern
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.cpp        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -2081,21 +2081,29 @@
</span><span class="cx">     if (!root)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    Vector&lt;FloatRect&gt; textRects;
+    getTextRectangles(textRects, textRectHeight);
+
+    FloatRect visibleContentRect = m_frame-&gt;view()-&gt;visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
+
+    for (const auto&amp; rect : textRects) {
+        FloatRect intersectionRect = intersection(rect, visibleContentRect);
+        if (!intersectionRect.isEmpty())
+            rectangles.append(intersectionRect);
+    }
+}
+
+void FrameSelection::getTextRectangles(Vector&lt;FloatRect&gt;&amp; rectangles, TextRectangleHeight textRectHeight) const
+{
</ins><span class="cx">     RefPtr&lt;Range&gt; range = toNormalizedRange();
</span><span class="cx">     if (!range)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    FloatRect visibleContentRect = m_frame-&gt;view()-&gt;visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
-
</del><span class="cx">     Vector&lt;FloatQuad&gt; quads;
</span><span class="cx">     range-&gt;absoluteTextQuads(quads, textRectHeight == TextRectangleHeight::SelectionHeight);
</span><span class="cx"> 
</span><del>-    size_t size = quads.size();
-    for (size_t i = 0; i &lt; size; ++i) {
-        FloatRect intersectionRect = intersection(quads[i].enclosingBoundingBox(), visibleContentRect);
-        if (!intersectionRect.isEmpty())
-            rectangles.append(intersectionRect);
-    }
</del><ins>+    for (const auto&amp; quad : quads)
+        rectangles.append(quad.enclosingBoundingBox());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Scans logically forward from &quot;start&quot;, including any child frames.
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.h (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.h        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebCore/editing/FrameSelection.h        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -262,6 +262,7 @@
</span><span class="cx"> 
</span><span class="cx">     enum class TextRectangleHeight { TextHeight, SelectionHeight };
</span><span class="cx">     WEBCORE_EXPORT void getClippedVisibleTextRectangles(Vector&lt;FloatRect&gt;&amp;, TextRectangleHeight = TextRectangleHeight::SelectionHeight) const;
</span><ins>+    WEBCORE_EXPORT void getTextRectangles(Vector&lt;FloatRect&gt;&amp;, TextRectangleHeight = TextRectangleHeight::SelectionHeight) const;
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT HTMLFormElement* currentForm() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageTextIndicatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/TextIndicator.cpp (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/TextIndicator.cpp        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebCore/page/TextIndicator.cpp        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -189,19 +189,27 @@
</span><span class="cx"> 
</span><span class="cx">     if ((data.options &amp; TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges) &amp;&amp; hasNonInlineOrReplacedElements(range))
</span><span class="cx">         data.options |= TextIndicatorOptionPaintAllContent;
</span><del>-    else
-        frame.selection().getClippedVisibleTextRectangles(textRects, textRectHeight);
</del><ins>+    else {
+        if (data.options &amp; TextIndicatorOptionDoNotClipToVisibleRect)
+            frame.selection().getTextRectangles(textRects, textRectHeight);
+        else
+            frame.selection().getClippedVisibleTextRectangles(textRects, textRectHeight);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (textRects.isEmpty()) {
</span><span class="cx">         RenderView* renderView = frame.contentRenderer();
</span><span class="cx">         if (!renderView)
</span><span class="cx">             return false;
</span><del>-        // Clip to the visible rect, just like getClippedVisibleTextRectangles does.
-        // FIXME: We really want to clip to the unobscured rect in both cases, I think.
-        // (this seems to work on Mac, but maybe not iOS?)
-        FloatRect visibleContentRect = frame.view()-&gt;visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
</del><span class="cx">         FloatRect boundingRect = range.absoluteBoundingRect();
</span><del>-        textRects.append(intersection(visibleContentRect, boundingRect));
</del><ins>+        if (data.options &amp; TextIndicatorOptionDoNotClipToVisibleRect)
+            textRects.append(boundingRect);
+        else {
+            // Clip to the visible rect, just like getClippedVisibleTextRectangles does.
+            // FIXME: We really want to clip to the unobscured rect in both cases, I think.
+            // (this seems to work on Mac, but maybe not iOS?)
+            FloatRect visibleContentRect = frame.view()-&gt;visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
+            textRects.append(intersection(visibleContentRect, boundingRect));
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     FloatRect textBoundingRectInRootViewCoordinates;
</span></span></pre></div>
<a id="trunkSourceWebCorepageTextIndicatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/TextIndicator.h (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/TextIndicator.h        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebCore/page/TextIndicator.h        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -84,6 +84,10 @@
</span><span class="cx">     // By default, TextIndicator removes any margin if the given Range matches the
</span><span class="cx">     // selection Range. If this option is set, maintain the margin in any case.
</span><span class="cx">     TextIndicatorOptionIncludeMarginIfRangeMatchesSelection = 1 &lt;&lt; 6,
</span><ins>+
+    // By default, TextIndicator clips the indicated rects to the visible content rect.
+    // If this option is set, do not clip the indicated rects.
+    TextIndicatorOptionDoNotClipToVisibleRect = 1 &lt;&lt; 7,
</ins><span class="cx"> };
</span><span class="cx"> typedef uint8_t TextIndicatorOptions;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebKit2/ChangeLog        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-08-31  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        iOS WebKit2 find-in-page doesn't support multi-line results, is often blank
+        https://bugs.webkit.org/show_bug.cgi?id=148599
+        &lt;rdar://problem/17914031&gt;
+
+        Reviewed by Beth Dakin.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::findString):
+        (WebKit::FindController::didFindString):
+        * WebProcess/WebPage/FindController.h:
+        Add didFindString() for FindControllerIOS.
+
+        * WebProcess/WebPage/ios/FindControllerIOS.mm:
+        (WebKit::FindIndicatorOverlayClientIOS::drawRect):
+        (WebKit::FindController::updateFindIndicator):
+        (WebKit::setCompositionSelectionChangeEnabledInAllFrames):
+        (WebKit::FindController::willFindString):
+        (WebKit::FindController::didFindString):
+        (WebKit::FindController::didFailToFindString):
+        (WebKit::FindController::didHideFindIndicator):
+        * WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h:
+        (WebKit::FindIndicatorOverlayClientIOS::FindIndicatorOverlayClientIOS):
+        Adopt TextIndicator and shrink-wrapping.
+
+        We'll re-create the indicator if the device/page scale factor change;
+        this is the only case in which a TextIndicator sticks around when
+        page scale changes -- we should come up with a better model!
+
</ins><span class="cx"> 2015-08-31  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Network Cache: Stale content after back navigation
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -234,11 +234,15 @@
</span><span class="cx">     else
</span><span class="cx">         found = m_webPage-&gt;corePage()-&gt;findString(string, coreOptions);
</span><span class="cx"> 
</span><del>-    if (found &amp;&amp; !foundStringStartsAfterSelection) {
-        if (options &amp; FindOptionsBackwards)
-            m_foundStringMatchIndex--;
-        else
-            m_foundStringMatchIndex++;
</del><ins>+    if (found) {
+        didFindString();
+
+        if (!foundStringStartsAfterSelection) {
+            if (options &amp; FindOptionsBackwards)
+                m_foundStringMatchIndex--;
+            else
+                m_foundStringMatchIndex++;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WebPage&gt; protectedWebPage = m_webPage;
</span><span class="lines">@@ -348,6 +352,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FindController::didFindString()
+{
+}
+
</ins><span class="cx"> void FindController::didFailToFindString()
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.h (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.h        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.h        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx">     void updateFindUIAfterPageScroll(bool found, const String&amp;, FindOptions, unsigned maxMatchCount);
</span><span class="cx"> 
</span><span class="cx">     void willFindString();
</span><ins>+    void didFindString();
</ins><span class="cx">     void didFailToFindString();
</span><span class="cx">     void didHideFindIndicator();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosFindControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -33,11 +33,15 @@
</span><span class="cx"> #import &quot;WebCoreArgumentCoders.h&quot;
</span><span class="cx"> #import &quot;WebPage.h&quot;
</span><span class="cx"> #import &quot;WebPageProxyMessages.h&quot;
</span><ins>+#import &lt;WebCore/FocusController.h&gt;
</ins><span class="cx"> #import &lt;WebCore/FrameView.h&gt;
</span><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/Page.h&gt;
</span><span class="cx"> #import &lt;WebCore/PageOverlayController.h&gt;
</span><ins>+#import &lt;WebCore/PathUtilities.h&gt;
+#import &lt;WebCore/Settings.h&gt;
+#import &lt;WebCore/TextIndicator.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -45,6 +49,8 @@
</span><span class="cx"> const int totalHorizontalMargin = 2;
</span><span class="cx"> const int totalVerticalMargin = 1;
</span><span class="cx"> 
</span><ins>+const TextIndicatorOptions findTextIndicatorOptions = TextIndicatorOptionTightlyFitContent | TextIndicatorOptionIncludeMarginIfRangeMatchesSelection | TextIndicatorOptionDoNotClipToVisibleRect;
+
</ins><span class="cx"> static Color highlightColor()
</span><span class="cx"> {
</span><span class="cx">     return Color(255, 228, 56, 255);
</span><span class="lines">@@ -54,44 +60,46 @@
</span><span class="cx"> 
</span><span class="cx"> void FindIndicatorOverlayClientIOS::drawRect(PageOverlay&amp; overlay, GraphicsContext&amp; context, const IntRect&amp; dirtyRect)
</span><span class="cx"> {
</span><del>-    // FIXME: Support multiple text rects.
</del><ins>+    float scaleFactor = m_frame.page()-&gt;deviceScaleFactor();
</ins><span class="cx"> 
</span><del>-    IntRect overlayFrame = overlay.frame();
-    IntRect overlayBounds = overlay.bounds();
</del><ins>+    if (m_frame.settings().delegatesPageScaling())
+        scaleFactor *= m_frame.page()-&gt;pageScaleFactor();
</ins><span class="cx"> 
</span><del>-    {
-        GraphicsContextStateSaver stateSaver(context);
-        Path clipPath;
-        clipPath.addRoundedRect(overlayBounds, FloatSize(cornerRadius, cornerRadius));
-        context.clip(clipPath);
-        context.setFillColor(highlightColor(), ColorSpaceDeviceRGB);
-        context.fillRect(overlayBounds);
-    }
</del><ins>+    // If the page scale changed, we need to paint a new TextIndicator.
+    if (m_textIndicator-&gt;contentImageScaleFactor() != scaleFactor)
+        m_textIndicator = TextIndicator::createWithSelectionInFrame(m_frame, findTextIndicatorOptions, TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
</ins><span class="cx"> 
</span><del>-    {
-        GraphicsContextStateSaver stateSaver(context);
-        context.translate(-overlayFrame.x(), -overlayFrame.y());
-        m_frame.view()-&gt;setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorForceBlackText | PaintBehaviorFlattenCompositingLayers);
-        m_frame.view()-&gt;paintContents(context, overlayFrame);
-        m_frame.view()-&gt;setPaintBehavior(PaintBehaviorNormal);
-    }
</del><ins>+    if (!m_textIndicator)
+        return;
+
+    Image* indicatorImage = m_textIndicator-&gt;contentImage();
+    if (!indicatorImage)
+        return;
+
+    Vector&lt;FloatRect&gt; textRectsInBoundingRectCoordinates = m_textIndicator-&gt;textRectsInBoundingRectCoordinates();
+    Vector&lt;Path&gt; paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);
+
+    context.setFillColor(highlightColor(), ColorSpaceDeviceRGB);
+    for (const auto&amp; path : paths)
+        context.fillPath(path);
+
+    context.drawImage(indicatorImage, ColorSpaceDeviceRGB, overlay.bounds());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool FindController::updateFindIndicator(Frame&amp; selectedFrame, bool isShowingOverlay, bool shouldAnimate)
</span><span class="cx"> {
</span><del>-    IntRect matchRect = enclosingIntRect(selectedFrame.selection().selectionBounds(false));
-    matchRect = selectedFrame.view()-&gt;contentsToRootView(matchRect);
-    matchRect.inflateX(totalHorizontalMargin);
-    matchRect.inflateY(totalVerticalMargin);
-
</del><span class="cx">     if (m_findIndicatorOverlay)
</span><span class="cx">         m_webPage-&gt;mainFrame()-&gt;pageOverlayController().uninstallPageOverlay(m_findIndicatorOverlay.get(), PageOverlay::FadeMode::DoNotFade);
</span><span class="cx"> 
</span><del>-    m_findIndicatorOverlayClient = std::make_unique&lt;FindIndicatorOverlayClientIOS&gt;(selectedFrame);
</del><ins>+    RefPtr&lt;TextIndicator&gt; textIndicator = TextIndicator::createWithSelectionInFrame(selectedFrame, findTextIndicatorOptions, TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
+    if (!textIndicator)
+        return false;
+
+    m_findIndicatorOverlayClient = std::make_unique&lt;FindIndicatorOverlayClientIOS&gt;(selectedFrame, textIndicator.get());
</ins><span class="cx">     m_findIndicatorOverlay = PageOverlay::create(*m_findIndicatorOverlayClient, PageOverlay::OverlayType::Document);
</span><span class="cx">     m_webPage-&gt;mainFrame()-&gt;pageOverlayController().installPageOverlay(m_findIndicatorOverlay, PageOverlay::FadeMode::DoNotFade);
</span><span class="cx"> 
</span><del>-    m_findIndicatorOverlay-&gt;setFrame(matchRect);
</del><ins>+    m_findIndicatorOverlay-&gt;setFrame(enclosingIntRect(textIndicator-&gt;textBoundingRectInRootViewCoordinates()));
</ins><span class="cx">     m_findIndicatorOverlay-&gt;setNeedsDisplay();
</span><span class="cx"> 
</span><span class="cx">     if (isShowingOverlay || shouldAnimate) {
</span><span class="lines">@@ -106,7 +114,6 @@
</span><span class="cx">         m_webPage-&gt;send(Messages::SmartMagnificationController::Magnify(startRect.center(), renderRect, visibleContentRect, m_webPage-&gt;minimumPageScaleFactor(), m_webPage-&gt;maximumPageScaleFactor()));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_findIndicatorRect = matchRect;
</del><span class="cx">     m_isShowingFindIndicator = true;
</span><span class="cx">     
</span><span class="cx">     return true;
</span><span class="lines">@@ -124,28 +131,38 @@
</span><span class="cx">     didHideFindIndicator();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void setCompositionSelectionChangeEnabledInAllFrames(WebPage&amp; page, bool enabled)
+{
+    for (Frame* coreFrame = page.mainFrame(); coreFrame; coreFrame = coreFrame-&gt;tree().traverseNext())
+        coreFrame-&gt;editor().setIgnoreCompositionSelectionChange(enabled);
+}
+
</ins><span class="cx"> void FindController::willFindString()
</span><span class="cx"> {
</span><del>-    for (Frame* coreFrame = m_webPage-&gt;mainFrame(); coreFrame; coreFrame = coreFrame-&gt;tree().traverseNext()) {
-        coreFrame-&gt;editor().setIgnoreCompositionSelectionChange(true);
-        coreFrame-&gt;selection().setUpdateAppearanceEnabled(true);
-    }
</del><ins>+    setCompositionSelectionChangeEnabledInAllFrames(*m_webPage, true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FindController::didFindString()
+{
+    // If the selection before we enabled appearance updates is equal to the
+    // range that we just found, setSelection will bail and fail to actually call
+    // updateAppearance, so the selection won't have been pushed to the render tree.
+    // Therefore, we need to force an update no matter what.
+
+    Frame&amp; frame = m_webPage-&gt;corePage()-&gt;focusController().focusedOrMainFrame();
+    frame.selection().setUpdateAppearanceEnabled(true);
+    frame.selection().updateAppearance();
+    frame.selection().setUpdateAppearanceEnabled(false);
+}
+
</ins><span class="cx"> void FindController::didFailToFindString()
</span><span class="cx"> {
</span><del>-    for (Frame* coreFrame = m_webPage-&gt;mainFrame(); coreFrame; coreFrame = coreFrame-&gt;tree().traverseNext()) {
-        coreFrame-&gt;selection().setUpdateAppearanceEnabled(false);
-        coreFrame-&gt;editor().setIgnoreCompositionSelectionChange(false);
-    }
</del><ins>+    setCompositionSelectionChangeEnabledInAllFrames(*m_webPage, false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FindController::didHideFindIndicator()
</span><span class="cx"> {
</span><del>-    for (Frame* coreFrame = m_webPage-&gt;mainFrame(); coreFrame; coreFrame = coreFrame-&gt;tree().traverseNext()) {
-        coreFrame-&gt;selection().setUpdateAppearanceEnabled(false);
-        coreFrame-&gt;editor().setIgnoreCompositionSelectionChange(false);
-    }
</del><ins>+    setCompositionSelectionChangeEnabledInAllFrames(*m_webPage, false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosFindIndicatorOverlayClientIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h (189177 => 189178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h        2015-08-31 18:31:04 UTC (rev 189177)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h        2015-08-31 18:40:24 UTC (rev 189178)
</span><span class="lines">@@ -30,12 +30,17 @@
</span><span class="cx"> #import &lt;WebCore/GraphicsContext.h&gt;
</span><span class="cx"> #import &lt;WebCore/PageOverlay.h&gt;
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+class TextIndicator;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class FindIndicatorOverlayClientIOS : public WebCore::PageOverlay::Client {
</span><span class="cx"> public:
</span><del>-    FindIndicatorOverlayClientIOS(WebCore::Frame&amp; frame)
</del><ins>+    FindIndicatorOverlayClientIOS(WebCore::Frame&amp; frame, WebCore::TextIndicator* textIndicator)
</ins><span class="cx">         : m_frame(frame)
</span><ins>+        , m_textIndicator(textIndicator)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -47,6 +52,7 @@
</span><span class="cx">     virtual bool mouseEvent(WebCore::PageOverlay&amp;, const WebCore::PlatformMouseEvent&amp;) override { return false; }
</span><span class="cx"> 
</span><span class="cx">     WebCore::Frame&amp; m_frame;
</span><ins>+    RefPtr&lt;WebCore::TextIndicator&gt; m_textIndicator;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>