<!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>[170624] trunk/Source/WebKit2</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>[WK2] Add a flatter find-in-page current match indicator style
https://bugs.webkit.org/show_bug.cgi?id=134434
&lt;rdar://problem/16225673&gt;

Reviewed by Simon Fraser.

* UIProcess/FindIndicator.cpp:
(WebKit::findIndicatorsForTextRectsOverlap):
(WebKit::FindIndicator::frameRect):
(WebKit::flatHighlightColor):
(WebKit::flatRimShadowColor):
(WebKit::flatDropShadowColor):
(WebKit::FindIndicator::draw):
Add a flatter find indicator, with a bigger shadow.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindUIAfterPageScroll):
(WebKit::FindController::getFindIndicatorBitmapAndRect):
(WebKit::FindController::hideFindIndicator):
(WebKit::FindController::drawRect):
Don't paint a shadow behind the secondary matches if we're using the new style.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessFindIndicatorcpp">trunk/Source/WebKit2/UIProcess/FindIndicator.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageFindControllercpp">trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170623 => 170624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-01 00:45:50 UTC (rev 170623)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-01 00:50:07 UTC (rev 170624)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-06-30  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [WK2] Add a flatter find-in-page current match indicator style
+        https://bugs.webkit.org/show_bug.cgi?id=134434
+        &lt;rdar://problem/16225673&gt;
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/FindIndicator.cpp:
+        (WebKit::findIndicatorsForTextRectsOverlap):
+        (WebKit::FindIndicator::frameRect):
+        (WebKit::flatHighlightColor):
+        (WebKit::flatRimShadowColor):
+        (WebKit::flatDropShadowColor):
+        (WebKit::FindIndicator::draw):
+        Add a flatter find indicator, with a bigger shadow.
+
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindUIAfterPageScroll):
+        (WebKit::FindController::getFindIndicatorBitmapAndRect):
+        (WebKit::FindController::hideFindIndicator):
+        (WebKit::FindController::drawRect):
+        Don't paint a shadow behind the secondary matches if we're using the new style.
+
</ins><span class="cx"> 2014-06-30  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS][WK2] Improve double-tap-to-scroll on image documents
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessFindIndicatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/FindIndicator.cpp (170623 => 170624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/FindIndicator.cpp        2014-07-01 00:45:50 UTC (rev 170623)
+++ trunk/Source/WebKit2/UIProcess/FindIndicator.cpp        2014-07-01 00:50:07 UTC (rev 170624)
</span><span class="lines">@@ -33,8 +33,15 @@
</span><span class="cx"> #include &lt;WebCore/IntRect.h&gt;
</span><span class="cx"> #include &lt;WebCore/Path.h&gt;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101000
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 1
+#else
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 0
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><ins>+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
</ins><span class="cx"> static const float cornerRadius = 3.0;
</span><span class="cx"> 
</span><span class="cx"> static const float shadowOffsetX = 0.0;
</span><span class="lines">@@ -75,6 +82,14 @@
</span><span class="cx"> static const int gradientLightGreen = 239;
</span><span class="cx"> static const int gradientLightBlue = 0;
</span><span class="cx"> static const int gradientLightAlpha = 255;
</span><ins>+#else
+const float flatStyleHorizontalBorder = 2;
+const float flatStyleVerticalBorder = 1;
+const float flatShadowOffsetX = 0;
+const float flatShadowOffsetY = 5;
+const float flatShadowBlurRadius = 25;
+const float flatRimShadowBlurRadius = 2;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -88,6 +103,26 @@
</span><span class="cx">     return adoptRef(new FindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImage.release()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static FloatRect inflateRect(const FloatRect&amp; rect, float inflateX, float inflateY)
+{
+    FloatRect inflatedRect = rect;
+    inflatedRect.inflateX(inflateX);
+    inflatedRect.inflateY(inflateY);
+    return inflatedRect;
+}
+
+static FloatRect outsetIndicatorRectIncludingShadow(const FloatRect rect)
+{
+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
+    FloatRect outsetRect = rect;
+    outsetRect.move(-leftBorderThickness, -topBorderThickness);
+    outsetRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
+    return outsetRect;
+#else
+    return inflateRect(rect, flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder);
+#endif
+}
+
</ins><span class="cx"> static bool findIndicatorsForTextRectsOverlap(const Vector&lt;FloatRect&gt;&amp; textRects)
</span><span class="cx"> {
</span><span class="cx">     size_t count = textRects.size();
</span><span class="lines">@@ -98,9 +133,7 @@
</span><span class="cx">     indicatorRects.reserveInitialCapacity(count);
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = 0; i &lt; count; ++i) {
</span><del>-        FloatRect indicatorRect = textRects[i];
-        indicatorRect.move(-leftBorderThickness, -topBorderThickness);
-        indicatorRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
</del><ins>+        FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
</ins><span class="cx"> 
</span><span class="cx">         for (size_t j = indicatorRects.size(); j; ) {
</span><span class="cx">             --j;
</span><span class="lines">@@ -130,38 +163,28 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static FloatRect inflateRect(const FloatRect&amp; rect, float inflateX, float inflateY)
-{
-    FloatRect inflatedRect = rect;
-    inflatedRect.inflateX(inflateX);
-    inflatedRect.inflateY(inflateY);
-    
-    return inflatedRect;
-}
-
</del><span class="cx"> FloatRect FindIndicator::frameRect() const
</span><span class="cx"> {
</span><del>-    return FloatRect(m_selectionRectInWindowCoordinates.x() - leftBorderThickness, m_selectionRectInWindowCoordinates.y() - topBorderThickness,
-                     m_selectionRectInWindowCoordinates.width() + rightBorderThickness + leftBorderThickness,
-                     m_selectionRectInWindowCoordinates.height() + topBorderThickness + bottomBorderThickness);
</del><ins>+    return outsetIndicatorRectIncludingShadow(m_selectionRectInWindowCoordinates);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Color lightBorderColor()
</del><ins>+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
+static inline Color lightBorderColor()
</ins><span class="cx"> {
</span><span class="cx">     return Color(lightBorderRed, lightBorderGreen, lightBorderBlue, lightBorderAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Color shadowColor()
</del><ins>+static inline Color shadowColor()
</ins><span class="cx"> {
</span><span class="cx">     return Color(shadowRed, shadowGreen, shadowBlue, shadowAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Color gradientLightColor()
</del><ins>+static inline Color gradientLightColor()
</ins><span class="cx"> {
</span><span class="cx">     return Color(gradientLightRed, gradientLightGreen, gradientLightBlue, gradientLightAlpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Color gradientDarkColor()
</del><ins>+static inline Color gradientDarkColor()
</ins><span class="cx"> {
</span><span class="cx">     return Color(gradientDarkRed, gradientDarkGreen, gradientDarkBlue, gradientDarkAlpha);
</span><span class="cx"> }
</span><span class="lines">@@ -173,9 +196,26 @@
</span><span class="cx"> 
</span><span class="cx">     return path;
</span><span class="cx"> }
</span><ins>+#else
+static inline Color flatHighlightColor()
+{
+    return Color(255, 255, 0, 255);
+}
+
+static inline Color flatRimShadowColor()
+{
+    return Color(0, 0, 0, 38);
+}
+
+static inline Color flatDropShadowColor()
+{
+    return Color(0, 0, 0, 51);
+}
+#endif
</ins><span class="cx">     
</span><span class="cx"> void FindIndicator::draw(GraphicsContext&amp; graphicsContext, const IntRect&amp; /*dirtyRect*/)
</span><span class="cx"> {
</span><ins>+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
</ins><span class="cx">     for (size_t i = 0; i &lt; m_textRectsInSelectionRectCoordinates.size(); ++i) {
</span><span class="cx">         FloatRect textRect = m_textRectsInSelectionRectCoordinates[i];
</span><span class="cx">         textRect.move(leftBorderThickness, topBorderThickness);
</span><span class="lines">@@ -208,6 +248,30 @@
</span><span class="cx">             m_contentImage-&gt;paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+#else
+    for (auto&amp; textRect : m_textRectsInSelectionRectCoordinates) {
+        FloatRect blurRect = textRect;
+        blurRect.move(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder);
+        FloatRect outerPathRect = inflateRect(blurRect, flatStyleHorizontalBorder, flatStyleVerticalBorder);
+
+        {
+            GraphicsContextStateSaver stateSaver(graphicsContext);
+            graphicsContext.setShadow(FloatSize(), flatRimShadowBlurRadius, flatRimShadowColor(), ColorSpaceSRGB);
+            graphicsContext.setFillColor(flatHighlightColor(), ColorSpaceSRGB);
+            graphicsContext.fillRect(outerPathRect);
+            graphicsContext.setShadow(FloatSize(flatShadowOffsetX, flatShadowOffsetY), flatShadowBlurRadius, flatDropShadowColor(), ColorSpaceSRGB);
+            graphicsContext.fillRect(outerPathRect);
+        }
+
+        {
+            GraphicsContextStateSaver stateSaver(graphicsContext);
+            graphicsContext.translate(FloatSize(flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder));
+
+            IntRect contentImageRect = enclosingIntRect(textRect);
+            m_contentImage-&gt;paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
+        }
+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (170623 => 170624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-07-01 00:45:50 UTC (rev 170623)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-07-01 00:50:07 UTC (rev 170624)
</span><span class="lines">@@ -44,6 +44,12 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101000
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 1
+#else
+#define ENABLE_LEGACY_FIND_INDICATOR_STYLE 0
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> static WebCore::FindOptions core(FindOptions options)
</span><span class="lines">@@ -266,6 +272,8 @@
</span><span class="cx">     if (!findIndicatorTextBackingStore)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    // FIXME: We should consider using subpixel antialiasing for the snapshot
+    // if we're compositing this image onto a solid color (the modern find indicator style).
</ins><span class="cx">     auto graphicsContext = findIndicatorTextBackingStore-&gt;createGraphicsContext();
</span><span class="cx">     graphicsContext-&gt;scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
</span><span class="cx"> 
</span><span class="lines">@@ -448,18 +456,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
</ins><span class="cx"> static const float shadowOffsetX = 0.0;
</span><span class="cx"> static const float shadowOffsetY = 1.0;
</span><span class="cx"> static const float shadowBlurRadius = 2.0;
</span><ins>+#endif
</ins><span class="cx"> 
</span><del>-static const float overlayBackgroundRed = 0.1;
-static const float overlayBackgroundGreen = 0.1;
-static const float overlayBackgroundBlue = 0.1;
-static const float overlayBackgroundAlpha = 0.25;
-
</del><span class="cx"> void FindController::drawRect(PageOverlay*, GraphicsContext&amp; graphicsContext, const IntRect&amp; dirtyRect)
</span><span class="cx"> {
</span><del>-    Color overlayBackgroundColor(overlayBackgroundRed, overlayBackgroundGreen, overlayBackgroundBlue, overlayBackgroundAlpha);
</del><ins>+    Color overlayBackgroundColor(0.1f, 0.1f, 0.1f, 0.25f);
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;IntRect&gt; rects = rectsForTextMatches();
</span><span class="cx"> 
</span><span class="lines">@@ -469,20 +474,22 @@
</span><span class="cx">     {
</span><span class="cx">         GraphicsContextStateSaver stateSaver(graphicsContext);
</span><span class="cx"> 
</span><ins>+#if ENABLE(LEGACY_FIND_INDICATOR_STYLE)
</ins><span class="cx">         graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, Color::black, ColorSpaceSRGB);
</span><ins>+#endif
</ins><span class="cx">         graphicsContext.setFillColor(Color::white, ColorSpaceSRGB);
</span><span class="cx"> 
</span><span class="cx">         // Draw white frames around the holes.
</span><del>-        for (size_t i = 0; i &lt; rects.size(); ++i) {
-            IntRect whiteFrameRect = rects[i];
</del><ins>+        for (auto&amp; rect : rects) {
+            IntRect whiteFrameRect = rect;
</ins><span class="cx">             whiteFrameRect.inflate(1);
</span><span class="cx">             graphicsContext.fillRect(whiteFrameRect);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Clear out the holes.
</span><del>-    for (size_t i = 0; i &lt; rects.size(); ++i)
-        graphicsContext.clearRect(rects[i]);
</del><ins>+    for (auto&amp; rect : rects)
+        graphicsContext.clearRect(rect);
</ins><span class="cx"> 
</span><span class="cx">     if (!m_isShowingFindIndicator)
</span><span class="cx">         return;
</span></span></pre>
</div>
</div>

</body>
</html>