<!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>[175484] 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/175484">175484</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-11-03 12:08:22 -0800 (Mon, 03 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use FrameSnapshotting functions in FindController::getFindIndicatorBitmap
https://bugs.webkit.org/show_bug.cgi?id=138300
&lt;rdar://problem/18855863&gt;

Reviewed by Simon Fraser.

Share more code by using WebCore's FrameSnapshotting::snapshotSelection
in FindController instead of copying it into FindController wholesale.

* WebProcess/WebPage/FindController.cpp:
(WebKit::getFindIndicatorBitmap):
Make getFindIndicatorBitmap static, rename it from getFindIndicatorBitmapAndRect,
and drop the rect argument because only one caller wanted it, and we no longer need
to compute it (this happens in WebCore now).

Use snapshotSelection; all of the removed paint behaviors get added by
code in or underneath snapshotSelection now.

Draw the snapshot into our ShareableBitmap; we could avoid this in a future patch
by refactoring the FrameSnapshotting functions to take GraphicsContexts.

(WebKit::FindController::getImageForFindMatch):
(WebKit::FindController::updateFindIndicator):
Adopt the new getFindIndicatorBitmap.

* WebProcess/WebPage/FindController.h:
Remove getFindIndicatorBitmap(AndRect), which is now static.

* WebCore.exp.in:
* page/FrameSnapshotting.cpp:
(WebCore::snapshotSelection):
Move knowledge that selectionBounds can be empty down to WebCore.</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="#trunkSourceWebCorepageFrameSnapshottingcpp">trunk/Source/WebCore/page/FrameSnapshotting.cpp</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebCore/ChangeLog        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-11-03  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Use FrameSnapshotting functions in FindController::getFindIndicatorBitmap
+        https://bugs.webkit.org/show_bug.cgi?id=138300
+        &lt;rdar://problem/18855863&gt;
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.exp.in:
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotSelection):
+        Move knowledge that selectionBounds can be empty down to WebCore.
+
</ins><span class="cx"> 2014-11-03  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Show Selector's Specificity
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -176,6 +176,7 @@
</span><span class="cx"> __ZN7WebCore11HistoryItemC1ERKNS_3URLERKN3WTF6StringES7_S7_
</span><span class="cx"> __ZN7WebCore11HistoryItemC1Ev
</span><span class="cx"> __ZN7WebCore11HistoryItemD1Ev
</span><ins>+__ZN7WebCore11ImageBufferD1Ev
</ins><span class="cx"> __ZN7WebCore11JSDOMWindow6s_infoE
</span><span class="cx"> __ZN7WebCore11MemoryCache11setDisabledEb
</span><span class="cx"> __ZN7WebCore11MemoryCache13getStatisticsEv
</span><span class="lines">@@ -521,6 +522,7 @@
</span><span class="cx"> __ZN7WebCore15GraphicsContext11clearShadowEv
</span><span class="cx"> __ZN7WebCore15GraphicsContext12setFillColorERKNS_5ColorENS_10ColorSpaceE
</span><span class="cx"> __ZN7WebCore15GraphicsContext14setStrokeColorERKNS_5ColorENS_10ColorSpaceE
</span><ins>+__ZN7WebCore15GraphicsContext15drawImageBufferEPNS_11ImageBufferENS_10ColorSpaceERKNS_10FloatPointERKNS_20ImagePaintingOptionsE
</ins><span class="cx"> __ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_NS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
</span><span class="cx"> __ZN7WebCore15GraphicsContext15setFillGradientEN3WTF7PassRefINS_8GradientEEE
</span><span class="cx"> __ZN7WebCore15GraphicsContext18setShouldAntialiasEb
</span><span class="lines">@@ -779,6 +781,7 @@
</span><span class="cx"> __ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
</span><span class="cx"> __ZN7WebCore17sRGBColorSpaceRefEv
</span><span class="cx"> __ZN7WebCore17setCookiesFromDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_RKN3WTF6StringE
</span><ins>+__ZN7WebCore17snapshotSelectionERNS_5FrameEj
</ins><span class="cx"> __ZN7WebCore17userVisibleStringEP5NSURL
</span><span class="cx"> __ZN7WebCore18DOMWindowExtensionC1EPNS_5FrameERNS_15DOMWrapperWorldE
</span><span class="cx"> __ZN7WebCore18PlatformCALayerMac18setGeometryFlippedEb
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameSnapshottingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameSnapshotting.cpp        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -102,11 +102,19 @@
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;ImageBuffer&gt; snapshotSelection(Frame&amp; frame, SnapshotOptions options)
</span><span class="cx"> {
</span><del>-    if (!frame.selection().isRange())
</del><ins>+    auto&amp; selection = frame.selection();
+
+    if (!selection.isRange())
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    FloatRect selectionBounds = selection.selectionBounds();
+
+    // It is possible for the selection bounds to be empty; see https://bugs.webkit.org/show_bug.cgi?id=56645.
+    if (selectionBounds.isEmpty())
+        return nullptr;
+
</ins><span class="cx">     options |= SnapshotOptionsPaintSelectionOnly;
</span><del>-    return snapshotFrameRect(frame, enclosingIntRect(frame.selection().selectionBounds()), options);
</del><ins>+    return snapshotFrameRect(frame, enclosingIntRect(selectionBounds), options);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;ImageBuffer&gt; snapshotNode(Frame&amp; frame, Node&amp; node)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebKit2/ChangeLog        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2014-11-03  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Use FrameSnapshotting functions in FindController::getFindIndicatorBitmap
+        https://bugs.webkit.org/show_bug.cgi?id=138300
+        &lt;rdar://problem/18855863&gt;
+
+        Reviewed by Simon Fraser.
+
+        Share more code by using WebCore's FrameSnapshotting::snapshotSelection
+        in FindController instead of copying it into FindController wholesale.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::getFindIndicatorBitmap):
+        Make getFindIndicatorBitmap static, rename it from getFindIndicatorBitmapAndRect,
+        and drop the rect argument because only one caller wanted it, and we no longer need
+        to compute it (this happens in WebCore now).
+
+        Use snapshotSelection; all of the removed paint behaviors get added by
+        code in or underneath snapshotSelection now.
+
+        Draw the snapshot into our ShareableBitmap; we could avoid this in a future patch
+        by refactoring the FrameSnapshotting functions to take GraphicsContexts.
+
+        (WebKit::FindController::getImageForFindMatch):
+        (WebKit::FindController::updateFindIndicator):
+        Adopt the new getFindIndicatorBitmap.
+
+        * WebProcess/WebPage/FindController.h:
+        Remove getFindIndicatorBitmap(AndRect), which is now static.
+
</ins><span class="cx"> 2014-11-03  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         URTBF after r175476 to make GTK and EFL build happy.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -36,8 +36,10 @@
</span><span class="cx"> #include &lt;WebCore/DocumentMarkerController.h&gt;
</span><span class="cx"> #include &lt;WebCore/FloatQuad.h&gt;
</span><span class="cx"> #include &lt;WebCore/FocusController.h&gt;
</span><ins>+#include &lt;WebCore/FrameSnapshotting.h&gt;
</ins><span class="cx"> #include &lt;WebCore/FrameView.h&gt;
</span><span class="cx"> #include &lt;WebCore/GraphicsContext.h&gt;
</span><ins>+#include &lt;WebCore/ImageBuffer.h&gt;
</ins><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><span class="cx"> #include &lt;WebCore/PageOverlayController.h&gt;
</span><span class="lines">@@ -257,39 +259,23 @@
</span><span class="cx">     m_webPage-&gt;send(Messages::WebPageProxy::DidFindStringMatches(string, matchRects, indexForSelection));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool FindController::getFindIndicatorBitmapAndRect(Frame&amp; frame, ShareableBitmap::Handle&amp; handle, IntRect&amp; selectionRect)
</del><ins>+static bool getFindIndicatorBitmap(Frame&amp; frame, ShareableBitmap::Handle&amp; handle)
</ins><span class="cx"> {
</span><del>-    selectionRect = enclosingIntRect(frame.selection().selectionBounds());
-
-    // Selection rect can be empty for matches that are currently obscured from view.
-    if (selectionRect.isEmpty())
</del><ins>+    std::unique_ptr&lt;ImageBuffer&gt; snapshot = snapshotSelection(frame, WebCore::SnapshotOptionsForceBlackText);
+    if (!snapshot)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    IntSize backingStoreSize = selectionRect.size();
-    float deviceScaleFactor = m_webPage-&gt;corePage()-&gt;deviceScaleFactor();
-    backingStoreSize.scale(deviceScaleFactor);
-
-    // Create a backing store and paint the find indicator text into it.
-    RefPtr&lt;ShareableBitmap&gt; findIndicatorTextBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
</del><ins>+    RefPtr&lt;ShareableBitmap&gt; findIndicatorTextBackingStore = ShareableBitmap::createShareable(snapshot-&gt;internalSize(), ShareableBitmap::SupportsAlpha);
</ins><span class="cx">     if (!findIndicatorTextBackingStore)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // FIXME: We should consider using subpixel antialiasing for the snapshot
</span><span class="cx">     // if we're compositing this image onto a solid color (the modern find indicator style).
</span><span class="cx">     auto graphicsContext = findIndicatorTextBackingStore-&gt;createGraphicsContext();
</span><ins>+    float deviceScaleFactor = frame.page()-&gt;deviceScaleFactor();
</ins><span class="cx">     graphicsContext-&gt;scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
</span><ins>+    graphicsContext-&gt;drawImageBuffer(snapshot.get(), ColorSpaceDeviceRGB, FloatPoint());
</ins><span class="cx"> 
</span><del>-    IntRect paintRect = selectionRect;
-    paintRect.move(frame.view()-&gt;frameRect().x(), frame.view()-&gt;frameRect().y());
-    paintRect.move(-frame.view()-&gt;scrollOffset());
-
-    graphicsContext-&gt;translate(-paintRect.x(), -paintRect.y());
-    frame.view()-&gt;setPaintBehavior(PaintBehaviorSelectionOnly | PaintBehaviorForceBlackText | PaintBehaviorFlattenCompositingLayers);
-    frame.document()-&gt;updateLayout();
-
-    frame.view()-&gt;paint(graphicsContext.get(), paintRect);
-    frame.view()-&gt;setPaintBehavior(PaintBehaviorNormal);
-
</del><span class="cx">     if (!findIndicatorTextBackingStore-&gt;createHandle(handle))
</span><span class="cx">         return false;
</span><span class="cx">     return true;
</span><span class="lines">@@ -306,9 +292,8 @@
</span><span class="cx">     VisibleSelection oldSelection = frame-&gt;selection().selection();
</span><span class="cx">     frame-&gt;selection().setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
</span><span class="cx"> 
</span><del>-    IntRect selectionRect;
</del><span class="cx">     ShareableBitmap::Handle handle;
</span><del>-    getFindIndicatorBitmapAndRect(*frame, handle, selectionRect);
</del><ins>+    getFindIndicatorBitmap(*frame, handle);
</ins><span class="cx"> 
</span><span class="cx">     frame-&gt;selection().setSelection(oldSelection);
</span><span class="cx"> 
</span><span class="lines">@@ -347,9 +332,9 @@
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> bool FindController::updateFindIndicator(Frame&amp; selectedFrame, bool isShowingOverlay, bool shouldAnimate)
</span><span class="cx"> {
</span><del>-    IntRect selectionRect;
</del><ins>+    IntRect selectionRect = enclosingIntRect(selectedFrame.selection().selectionBounds());
</ins><span class="cx">     ShareableBitmap::Handle handle;
</span><del>-    if (!getFindIndicatorBitmapAndRect(selectedFrame, handle, selectionRect))
</del><ins>+    if (!getFindIndicatorBitmap(selectedFrame, handle))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // We want the selection rect in window coordinates.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.h (175483 => 175484)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.h        2014-11-03 20:03:57 UTC (rev 175483)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.h        2014-11-03 20:08:22 UTC (rev 175484)
</span><span class="lines">@@ -77,7 +77,6 @@
</span><span class="cx">     virtual void drawRect(WebCore::PageOverlay&amp;, WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRect);
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;WebCore::IntRect&gt; rectsForTextMatches();
</span><del>-    bool getFindIndicatorBitmapAndRect(WebCore::Frame&amp;, ShareableBitmap::Handle&amp;, WebCore::IntRect&amp; selectionRect);
</del><span class="cx">     bool updateFindIndicator(WebCore::Frame&amp; selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
</span><span class="cx"> 
</span><span class="cx">     void updateFindUIAfterPageScroll(bool found, const String&amp;, FindOptions, unsigned maxMatchCount);
</span></span></pre>
</div>
</div>

</body>
</html>