<!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
<rdar://problem/17914031>
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 <timothy_horton@apple.com>
+
+ iOS WebKit2 find-in-page doesn't support multi-line results, is often blank
+ https://bugs.webkit.org/show_bug.cgi?id=148599
+ <rdar://problem/17914031>
+
+ 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 <mcatanzaro@igalia.com>
</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<FloatRect> textRects;
+ getTextRectangles(textRects, textRectHeight);
+
+ FloatRect visibleContentRect = m_frame->view()->visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
+
+ for (const auto& rect : textRects) {
+ FloatRect intersectionRect = intersection(rect, visibleContentRect);
+ if (!intersectionRect.isEmpty())
+ rectangles.append(intersectionRect);
+ }
+}
+
+void FrameSelection::getTextRectangles(Vector<FloatRect>& rectangles, TextRectangleHeight textRectHeight) const
+{
</ins><span class="cx"> RefPtr<Range> range = toNormalizedRange();
</span><span class="cx"> if (!range)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- FloatRect visibleContentRect = m_frame->view()->visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
-
</del><span class="cx"> Vector<FloatQuad> quads;
</span><span class="cx"> range->absoluteTextQuads(quads, textRectHeight == TextRectangleHeight::SelectionHeight);
</span><span class="cx">
</span><del>- size_t size = quads.size();
- for (size_t i = 0; i < size; ++i) {
- FloatRect intersectionRect = intersection(quads[i].enclosingBoundingBox(), visibleContentRect);
- if (!intersectionRect.isEmpty())
- rectangles.append(intersectionRect);
- }
</del><ins>+ for (const auto& quad : quads)
+ rectangles.append(quad.enclosingBoundingBox());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Scans logically forward from "start", 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<FloatRect>&, TextRectangleHeight = TextRectangleHeight::SelectionHeight) const;
</span><ins>+ WEBCORE_EXPORT void getTextRectangles(Vector<FloatRect>&, 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 & TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges) && hasNonInlineOrReplacedElements(range))
</span><span class="cx"> data.options |= TextIndicatorOptionPaintAllContent;
</span><del>- else
- frame.selection().getClippedVisibleTextRectangles(textRects, textRectHeight);
</del><ins>+ else {
+ if (data.options & 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()->visibleContentRect(ScrollableArea::LegacyIOSDocumentVisibleRect);
</del><span class="cx"> FloatRect boundingRect = range.absoluteBoundingRect();
</span><del>- textRects.append(intersection(visibleContentRect, boundingRect));
</del><ins>+ if (data.options & 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()->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 << 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 << 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 <timothy_horton@apple.com>
+
+ iOS WebKit2 find-in-page doesn't support multi-line results, is often blank
+ https://bugs.webkit.org/show_bug.cgi?id=148599
+ <rdar://problem/17914031>
+
+ 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 <antti@apple.com>
</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->corePage()->findString(string, coreOptions);
</span><span class="cx">
</span><del>- if (found && !foundStringStartsAfterSelection) {
- if (options & FindOptionsBackwards)
- m_foundStringMatchIndex--;
- else
- m_foundStringMatchIndex++;
</del><ins>+ if (found) {
+ didFindString();
+
+ if (!foundStringStartsAfterSelection) {
+ if (options & FindOptionsBackwards)
+ m_foundStringMatchIndex--;
+ else
+ m_foundStringMatchIndex++;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<WebPage> 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&, 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 "WebCoreArgumentCoders.h"
</span><span class="cx"> #import "WebPage.h"
</span><span class="cx"> #import "WebPageProxyMessages.h"
</span><ins>+#import <WebCore/FocusController.h>
</ins><span class="cx"> #import <WebCore/FrameView.h>
</span><span class="cx"> #import <WebCore/GraphicsContext.h>
</span><span class="cx"> #import <WebCore/MainFrame.h>
</span><span class="cx"> #import <WebCore/Page.h>
</span><span class="cx"> #import <WebCore/PageOverlayController.h>
</span><ins>+#import <WebCore/PathUtilities.h>
+#import <WebCore/Settings.h>
+#import <WebCore/TextIndicator.h>
</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& overlay, GraphicsContext& context, const IntRect& dirtyRect)
</span><span class="cx"> {
</span><del>- // FIXME: Support multiple text rects.
</del><ins>+ float scaleFactor = m_frame.page()->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()->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->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()->setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorForceBlackText | PaintBehaviorFlattenCompositingLayers);
- m_frame.view()->paintContents(context, overlayFrame);
- m_frame.view()->setPaintBehavior(PaintBehaviorNormal);
- }
</del><ins>+ if (!m_textIndicator)
+ return;
+
+ Image* indicatorImage = m_textIndicator->contentImage();
+ if (!indicatorImage)
+ return;
+
+ Vector<FloatRect> textRectsInBoundingRectCoordinates = m_textIndicator->textRectsInBoundingRectCoordinates();
+ Vector<Path> paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);
+
+ context.setFillColor(highlightColor(), ColorSpaceDeviceRGB);
+ for (const auto& 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& selectedFrame, bool isShowingOverlay, bool shouldAnimate)
</span><span class="cx"> {
</span><del>- IntRect matchRect = enclosingIntRect(selectedFrame.selection().selectionBounds(false));
- matchRect = selectedFrame.view()->contentsToRootView(matchRect);
- matchRect.inflateX(totalHorizontalMargin);
- matchRect.inflateY(totalVerticalMargin);
-
</del><span class="cx"> if (m_findIndicatorOverlay)
</span><span class="cx"> m_webPage->mainFrame()->pageOverlayController().uninstallPageOverlay(m_findIndicatorOverlay.get(), PageOverlay::FadeMode::DoNotFade);
</span><span class="cx">
</span><del>- m_findIndicatorOverlayClient = std::make_unique<FindIndicatorOverlayClientIOS>(selectedFrame);
</del><ins>+ RefPtr<TextIndicator> textIndicator = TextIndicator::createWithSelectionInFrame(selectedFrame, findTextIndicatorOptions, TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
+ if (!textIndicator)
+ return false;
+
+ m_findIndicatorOverlayClient = std::make_unique<FindIndicatorOverlayClientIOS>(selectedFrame, textIndicator.get());
</ins><span class="cx"> m_findIndicatorOverlay = PageOverlay::create(*m_findIndicatorOverlayClient, PageOverlay::OverlayType::Document);
</span><span class="cx"> m_webPage->mainFrame()->pageOverlayController().installPageOverlay(m_findIndicatorOverlay, PageOverlay::FadeMode::DoNotFade);
</span><span class="cx">
</span><del>- m_findIndicatorOverlay->setFrame(matchRect);
</del><ins>+ m_findIndicatorOverlay->setFrame(enclosingIntRect(textIndicator->textBoundingRectInRootViewCoordinates()));
</ins><span class="cx"> m_findIndicatorOverlay->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->send(Messages::SmartMagnificationController::Magnify(startRect.center(), renderRect, visibleContentRect, m_webPage->minimumPageScaleFactor(), m_webPage->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& page, bool enabled)
+{
+ for (Frame* coreFrame = page.mainFrame(); coreFrame; coreFrame = coreFrame->tree().traverseNext())
+ coreFrame->editor().setIgnoreCompositionSelectionChange(enabled);
+}
+
</ins><span class="cx"> void FindController::willFindString()
</span><span class="cx"> {
</span><del>- for (Frame* coreFrame = m_webPage->mainFrame(); coreFrame; coreFrame = coreFrame->tree().traverseNext()) {
- coreFrame->editor().setIgnoreCompositionSelectionChange(true);
- coreFrame->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& frame = m_webPage->corePage()->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->mainFrame(); coreFrame; coreFrame = coreFrame->tree().traverseNext()) {
- coreFrame->selection().setUpdateAppearanceEnabled(false);
- coreFrame->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->mainFrame(); coreFrame; coreFrame = coreFrame->tree().traverseNext()) {
- coreFrame->selection().setUpdateAppearanceEnabled(false);
- coreFrame->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 <WebCore/GraphicsContext.h>
</span><span class="cx"> #import <WebCore/PageOverlay.h>
</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& frame)
</del><ins>+ FindIndicatorOverlayClientIOS(WebCore::Frame& 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&, const WebCore::PlatformMouseEvent&) override { return false; }
</span><span class="cx">
</span><span class="cx"> WebCore::Frame& m_frame;
</span><ins>+ RefPtr<WebCore::TextIndicator> m_textIndicator;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>
</body>
</html>