<!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>[175564] 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/175564">175564</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-11-04 11:42:37 -0800 (Tue, 04 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement yellow highlight over data detected items
https://bugs.webkit.org/show_bug.cgi?id=138340
<rdar://problem/18840102>
Reviewed by Anders Carlsson.
* Shared/TextIndicator.cpp: Renamed from Source/WebKit2/UIProcess/TextIndicator.cpp.
* Shared/TextIndicator.h: Renamed from Source/WebKit2/UIProcess/TextIndicator.h.
Move TextIndicator to Shared.
Move all of the members to a Data struct.
Implement encode/decode for TextIndicator::Data, so it can be passed as
the argument to SetTextIndicator, and also as a field on ActionMenuHitTestResult.
Add 'createWithSelectionInFrame', which builds a TextIndicator
from the selection in the given frame.
* Shared/mac/ActionMenuHitTestResult.h:
* Shared/mac/ActionMenuHitTestResult.mm:
(WebKit::ActionMenuHitTestResult::encode):
(WebKit::ActionMenuHitTestResult::decode):
Rename actionBoundingBox to detectedDataBoundingBox.
Store/encode/decode detectedDataTextIndicator.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setTextIndicator):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
Create a TextIndicator from the TextIndicator::Data.
Add an explicit ClearTextIndicator message instead of sending empty Data.
* UIProcess/mac/WKActionMenuController.h:
* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController prepareForMenu:withEvent:]):
If the text indicator is up when preparing for a new menu invocation, hide it.
(-[WKActionMenuController willOpenMenu:withEvent:]):
Show the text indicator when the menu opens, for data detected items.
(-[WKActionMenuController didCloseMenu:withEvent:]):
Hide the text indicator when the menu closes, unless we only had one item.
Then, we'll hide it in the DDActionContext completionHandler block.
(-[WKActionMenuController _showTextIndicator]):
(-[WKActionMenuController _hideTextIndicator]):
Added. Show and hide the text indicator based on the TextIndicator
data included in the action menu hit test result.
(-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
Hide the text indicator when the data detector popover completes.
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::getImageForFindMatch):
Make use of the newly-moved createSelectionSnapshot.
(WebKit::FindController::updateFindIndicator):
Make use of TextIndicator::createWithSelectionInFrame, which allows
us to share this code for building a TextIndicator with other callers.
(WebKit::FindController::hideFindIndicator):
(WebKit::getFindIndicatorBitmap): Deleted.
Move getFindIndicatorBitmap to WebFrame::createSelectionSnapshot.
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createSelectionSnapshot):
Moved from FindController's getFindIndicatorBitmap.
Now returns a ShareableBitmap instead of going ahead and making a Handle.
* WebProcess/WebPage/WebFrame.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::scanForDataDetectedItems):
(WebKit::textIndicatorForRange):
Temporarily change the selection to the given range, then use
TextIndicator::indicatorWithSelectionInFrame to acquire a TextIndicator,
then reset the selection.
(WebKit::WebPage::performActionMenuHitTestAtLocation):
Create a TextIndicator from the data detected range.
* platform/spi/mac/DataDetectorsSPI.h:
Add completionHandler SPI.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformspimacDataDetectorsSPIh">trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h</a></li>
<li><a href="#trunkSourceWebKit2CMakeListstxt">trunk/Source/WebKit2/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacActionMenuHitTestResulth">trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacActionMenuHitTestResultmm">trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKActionMenuControllerh">trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKActionMenuControllermm">trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageFindControllercpp">trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebFramecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebFrameh">trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2SharedTextIndicatorcpp">trunk/Source/WebKit2/Shared/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedTextIndicatorh">trunk/Source/WebKit2/Shared/TextIndicator.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessTextIndicatorcpp">trunk/Source/WebKit2/UIProcess/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessTextIndicatorh">trunk/Source/WebKit2/UIProcess/TextIndicator.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebCore/ChangeLog        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-11-04 Tim Horton <timothy_horton@apple.com>
+
+ Implement yellow highlight over data detected items
+ https://bugs.webkit.org/show_bug.cgi?id=138340
+ <rdar://problem/18840102>
+
+ Reviewed by Anders Carlsson.
+
+ * platform/spi/mac/DataDetectorsSPI.h:
+ Add completionHandler SPI.
+
</ins><span class="cx"> 2014-11-04 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Eliminate ResourceBuffer and use SharedBuffer directly instead
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspimacDataDetectorsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx"> @property NSRect highlightFrame;
</span><span class="cx"> @property (retain) NSArray *allResults;
</span><span class="cx"> @property (retain) __attribute__((NSObject)) DDResultRef mainResult;
</span><ins>+@property (copy) void (^completionHandler)(void);
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2CMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/CMakeLists.txt (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/CMakeLists.txt        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/CMakeLists.txt        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -206,6 +206,7 @@
</span><span class="cx"> Shared/ShareableBitmap.cpp
</span><span class="cx"> Shared/ShareableResource.cpp
</span><span class="cx"> Shared/StatisticsData.cpp
</span><ins>+ Shared/TextIndicator.cpp
</ins><span class="cx"> Shared/UpdateInfo.cpp
</span><span class="cx"> Shared/UserData.cpp
</span><span class="cx"> Shared/VisitedLinkTable.cpp
</span><span class="lines">@@ -299,7 +300,6 @@
</span><span class="cx"> UIProcess/ResponsivenessTimer.cpp
</span><span class="cx"> UIProcess/StatisticsRequest.cpp
</span><span class="cx"> UIProcess/TextCheckerCompletion.cpp
</span><del>- UIProcess/TextIndicator.cpp
</del><span class="cx"> UIProcess/VisitedLinkProvider.cpp
</span><span class="cx"> UIProcess/WebApplicationCacheManagerProxy.cpp
</span><span class="cx"> UIProcess/WebBackForwardList.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/ChangeLog        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -1,3 +1,84 @@
</span><ins>+2014-11-04 Tim Horton <timothy_horton@apple.com>
+
+ Implement yellow highlight over data detected items
+ https://bugs.webkit.org/show_bug.cgi?id=138340
+ <rdar://problem/18840102>
+
+ Reviewed by Anders Carlsson.
+
+ * Shared/TextIndicator.cpp: Renamed from Source/WebKit2/UIProcess/TextIndicator.cpp.
+ * Shared/TextIndicator.h: Renamed from Source/WebKit2/UIProcess/TextIndicator.h.
+ Move TextIndicator to Shared.
+ Move all of the members to a Data struct.
+ Implement encode/decode for TextIndicator::Data, so it can be passed as
+ the argument to SetTextIndicator, and also as a field on ActionMenuHitTestResult.
+ Add 'createWithSelectionInFrame', which builds a TextIndicator
+ from the selection in the given frame.
+
+ * Shared/mac/ActionMenuHitTestResult.h:
+ * Shared/mac/ActionMenuHitTestResult.mm:
+ (WebKit::ActionMenuHitTestResult::encode):
+ (WebKit::ActionMenuHitTestResult::decode):
+ Rename actionBoundingBox to detectedDataBoundingBox.
+ Store/encode/decode detectedDataTextIndicator.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setTextIndicator):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ Create a TextIndicator from the TextIndicator::Data.
+ Add an explicit ClearTextIndicator message instead of sending empty Data.
+
+ * UIProcess/mac/WKActionMenuController.h:
+ * UIProcess/mac/WKActionMenuController.mm:
+ (-[WKActionMenuController prepareForMenu:withEvent:]):
+ If the text indicator is up when preparing for a new menu invocation, hide it.
+
+ (-[WKActionMenuController willOpenMenu:withEvent:]):
+ Show the text indicator when the menu opens, for data detected items.
+
+ (-[WKActionMenuController didCloseMenu:withEvent:]):
+ Hide the text indicator when the menu closes, unless we only had one item.
+ Then, we'll hide it in the DDActionContext completionHandler block.
+
+ (-[WKActionMenuController _showTextIndicator]):
+ (-[WKActionMenuController _hideTextIndicator]):
+ Added. Show and hide the text indicator based on the TextIndicator
+ data included in the action menu hit test result.
+
+ (-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
+ Hide the text indicator when the data detector popover completes.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::FindController::getImageForFindMatch):
+ Make use of the newly-moved createSelectionSnapshot.
+
+ (WebKit::FindController::updateFindIndicator):
+ Make use of TextIndicator::createWithSelectionInFrame, which allows
+ us to share this code for building a TextIndicator with other callers.
+
+ (WebKit::FindController::hideFindIndicator):
+
+ (WebKit::getFindIndicatorBitmap): Deleted.
+ Move getFindIndicatorBitmap to WebFrame::createSelectionSnapshot.
+
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::createSelectionSnapshot):
+ Moved from FindController's getFindIndicatorBitmap.
+ Now returns a ShareableBitmap instead of going ahead and making a Handle.
+
+ * WebProcess/WebPage/WebFrame.h:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::scanForDataDetectedItems):
+ (WebKit::textIndicatorForRange):
+ Temporarily change the selection to the given range, then use
+ TextIndicator::indicatorWithSelectionInFrame to acquire a TextIndicator,
+ then reset the selection.
+
+ (WebKit::WebPage::performActionMenuHitTestAtLocation):
+ Create a TextIndicator from the data detected range.
+
</ins><span class="cx"> 2014-11-04 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix the iOS build after r175549.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedTextIndicatorcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/TextIndicator.cpp (0 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/TextIndicator.cpp         (rev 0)
+++ trunk/Source/WebKit2/Shared/TextIndicator.cpp        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -0,0 +1,350 @@
</span><ins>+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TextIndicator.h"
+
+#include "ArgumentCodersCF.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include "ShareableBitmap.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebFrame.h"
+#include "WebPage.h"
+#include <WebCore/Frame.h>
+#include <WebCore/FrameSelection.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/GeometryUtilities.h>
+#include <WebCore/Gradient.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/Path.h>
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#define ENABLE_LEGACY_TEXT_INDICATOR_STYLE 1
+#else
+#define ENABLE_LEGACY_TEXT_INDICATOR_STYLE 0
+#endif
+
+using namespace WebCore;
+
+#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
+static const float cornerRadius = 3.0;
+
+static const float shadowOffsetX = 0.0;
+static const float shadowOffsetY = 1.0;
+static const float shadowBlurRadius = 3.0;
+
+static const int shadowRed = 0;
+static const int shadowGreen = 0;
+static const int shadowBlue = 0;
+static const int shadowAlpha = 204;
+
+static const float lightBorderThickness = 1.0;
+static const float horizontalPaddingInsideLightBorder = 3.0;
+static const float verticalPaddingInsideLightBorder = 1.0;
+
+static const float horizontalBorderInsideShadow = lightBorderThickness + horizontalPaddingInsideLightBorder;
+static const float verticalBorderInsideShadow = lightBorderThickness + verticalPaddingInsideLightBorder;
+
+static const float leftBorderThickness = horizontalBorderInsideShadow + shadowOffsetX + shadowBlurRadius / 2.0;
+static const float topBorderThickness = verticalBorderInsideShadow - shadowOffsetY + shadowBlurRadius / 2.0;
+static const float rightBorderThickness = horizontalBorderInsideShadow - shadowOffsetX + shadowBlurRadius / 2.0;
+static const float bottomBorderThickness = verticalBorderInsideShadow + shadowOffsetY + shadowBlurRadius / 2.0;
+
+static const float horizontalOutsetToCenterOfLightBorder = horizontalBorderInsideShadow - lightBorderThickness / 2.0;
+static const float verticalOutsetToCenterOfLightBorder = verticalBorderInsideShadow - lightBorderThickness / 2.0;
+
+static const int lightBorderRed = 245;
+static const int lightBorderGreen = 230;
+static const int lightBorderBlue = 0;
+static const int lightBorderAlpha = 255;
+
+static const int gradientDarkRed = 237;
+static const int gradientDarkGreen = 204;
+static const int gradientDarkBlue = 0;
+static const int gradientDarkAlpha = 255;
+
+static const int gradientLightRed = 242;
+static const int gradientLightGreen = 239;
+static const int gradientLightBlue = 0;
+static const int gradientLightAlpha = 255;
+#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
+
+namespace WebKit {
+
+static FloatRect inflateRect(const FloatRect& 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_TEXT_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
+}
+
+static bool textIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
+{
+ size_t count = textRects.size();
+ if (count <= 1)
+ return false;
+
+ Vector<FloatRect> indicatorRects;
+ indicatorRects.reserveInitialCapacity(count);
+
+ for (size_t i = 0; i < count; ++i) {
+ FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
+
+ for (size_t j = indicatorRects.size(); j; ) {
+ --j;
+ if (indicatorRect.intersects(indicatorRects[j]))
+ return true;
+ }
+
+ indicatorRects.uncheckedAppend(indicatorRect);
+ }
+
+ return false;
+}
+
+PassRefPtr<TextIndicator> TextIndicator::create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage)
+{
+ TextIndicator::Data data;
+ data.selectionRectInWindowCoordinates = selectionRectInWindowCoordinates;
+ data.textRectsInSelectionRectCoordinates = textRectsInSelectionRectCoordinates;
+ data.contentImageScaleFactor = contentImageScaleFactor;
+ data.contentImage = contentImage;
+
+ return TextIndicator::create(data);
+}
+
+PassRefPtr<TextIndicator> TextIndicator::create(const TextIndicator::Data& data)
+{
+ return adoptRef(new TextIndicator(data));
+}
+
+PassRefPtr<TextIndicator> TextIndicator::createWithSelectionInFrame(WebFrame& frame)
+{
+ Frame& coreFrame = *frame.coreFrame();
+ IntRect selectionRect = enclosingIntRect(coreFrame.selection().selectionBounds());
+ RefPtr<ShareableBitmap> indicatorBitmap = frame.createSelectionSnapshot();
+ if (!indicatorBitmap)
+ return nullptr;
+
+ // We want the selection rect in window coordinates.
+ IntRect selectionRectInWindowCoordinates = coreFrame.view()->contentsToWindow(selectionRect);
+
+ Vector<FloatRect> textRects;
+ coreFrame.selection().getClippedVisibleTextRectangles(textRects);
+
+ // We want the text rects in selection rect coordinates.
+ Vector<FloatRect> textRectsInSelectionRectCoordinates;
+
+ for (const FloatRect& textRect : textRects) {
+ IntRect textRectInSelectionRectCoordinates = coreFrame.view()->contentsToWindow(enclosingIntRect(textRect));
+ textRectInSelectionRectCoordinates.move(-selectionRectInWindowCoordinates.x(), -selectionRectInWindowCoordinates.y());
+ textRectsInSelectionRectCoordinates.append(textRectInSelectionRectCoordinates);
+ }
+
+ return TextIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, frame.page()->deviceScaleFactor(), indicatorBitmap);
+}
+
+TextIndicator::TextIndicator(const TextIndicator::Data& data)
+ : m_data(data)
+{
+ ASSERT(m_data.contentImageScaleFactor != 1 || m_data.contentImage->size() == enclosingIntRect(m_data.selectionRectInWindowCoordinates).size());
+
+ if (textIndicatorsForTextRectsOverlap(m_data.textRectsInSelectionRectCoordinates)) {
+ m_data.textRectsInSelectionRectCoordinates[0] = unionRect(m_data.textRectsInSelectionRectCoordinates);
+ m_data.textRectsInSelectionRectCoordinates.shrink(1);
+ }
+}
+
+TextIndicator::~TextIndicator()
+{
+}
+
+FloatRect TextIndicator::frameRect() const
+{
+ return outsetIndicatorRectIncludingShadow(m_data.selectionRectInWindowCoordinates);
+}
+
+#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
+static inline Color lightBorderColor()
+{
+ return Color(lightBorderRed, lightBorderGreen, lightBorderBlue, lightBorderAlpha);
+}
+
+static inline Color shadowColor()
+{
+ return Color(shadowRed, shadowGreen, shadowBlue, shadowAlpha);
+}
+
+static inline Color gradientLightColor()
+{
+ return Color(gradientLightRed, gradientLightGreen, gradientLightBlue, gradientLightAlpha);
+}
+
+static inline Color gradientDarkColor()
+{
+ return Color(gradientDarkRed, gradientDarkGreen, gradientDarkBlue, gradientDarkAlpha);
+}
+
+static Path pathWithRoundedRect(const FloatRect& pathRect, float radius)
+{
+ Path path;
+ path.addRoundedRect(pathRect, FloatSize(radius, radius));
+
+ return path;
+}
+#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
+
+void TextIndicator::draw(GraphicsContext& graphicsContext, const IntRect& /*dirtyRect*/)
+{
+#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
+ for (size_t i = 0; i < m_data.textRectsInSelectionRectCoordinates.size(); ++i) {
+ FloatRect textRect = m_data.textRectsInSelectionRectCoordinates[i];
+ textRect.move(leftBorderThickness, topBorderThickness);
+
+ FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
+ FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
+ graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
+ graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
+ }
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
+ RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.maxY()));
+ gradient->addColorStop(0, gradientLightColor());
+ gradient->addColorStop(1, gradientDarkColor());
+ graphicsContext.setFillGradient(gradient.releaseNonNull());
+ graphicsContext.fillRect(outerPathRect);
+ }
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness)));
+
+ IntRect contentImageRect = enclosingIntRect(m_data.textRectsInSelectionRectCoordinates[i]);
+ m_data.contentImage->paint(graphicsContext, m_data.contentImageScaleFactor, contentImageRect.location(), contentImageRect);
+ }
+ }
+#else
+ for (auto& textRect : m_data.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_data.contentImage->paint(graphicsContext, m_data.contentImageScaleFactor, contentImageRect.location(), contentImageRect);
+ }
+ }
+#endif
+}
+
+void TextIndicator::Data::encode(IPC::ArgumentEncoder& encoder) const
+{
+ encoder << selectionRectInWindowCoordinates;
+ encoder << textRectsInSelectionRectCoordinates;
+ encoder << contentImageScaleFactor;
+
+ ShareableBitmap::Handle contentImageHandle;
+ if (contentImage)
+ contentImage->createHandle(contentImageHandle, SharedMemory::ReadOnly);
+ encoder << contentImageHandle;
+}
+
+bool TextIndicator::Data::decode(IPC::ArgumentDecoder& decoder, TextIndicator::Data& textIndicatorData)
+{
+ if (!decoder.decode(textIndicatorData.selectionRectInWindowCoordinates))
+ return false;
+
+ if (!decoder.decode(textIndicatorData.textRectsInSelectionRectCoordinates))
+ return false;
+
+ if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
+ return false;
+
+ ShareableBitmap::Handle contentImageHandle;
+ if (!decoder.decode(contentImageHandle))
+ return false;
+
+ if (!contentImageHandle.isNull())
+ textIndicatorData.contentImage = ShareableBitmap::create(contentImageHandle, SharedMemory::ReadOnly);
+
+ return true;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedTextIndicatorh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/TextIndicator.h (0 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/TextIndicator.h         (rev 0)
+++ trunk/Source/WebKit2/Shared/TextIndicator.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TextIndicator_h
+#define TextIndicator_h
+
+#include "ShareableBitmap.h"
+#include <WebCore/FloatRect.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class GraphicsContext;
+}
+
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class WebFrame;
+
+class TextIndicator : public RefCounted<TextIndicator> {
+public:
+ struct Data {
+ WebCore::FloatRect selectionRectInWindowCoordinates;
+ Vector<WebCore::FloatRect> textRectsInSelectionRectCoordinates;
+ float contentImageScaleFactor;
+ RefPtr<ShareableBitmap> contentImage;
+
+ void encode(IPC::ArgumentEncoder&) const;
+ static bool decode(IPC::ArgumentDecoder&, Data&);
+ };
+
+ static PassRefPtr<TextIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionCoordinates, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage);
+ static PassRefPtr<TextIndicator> create(const TextIndicator::Data&);
+ static PassRefPtr<TextIndicator> createWithSelectionInFrame(WebFrame&);
+
+ ~TextIndicator();
+
+ WebCore::FloatRect selectionRectInWindowCoordinates() const { return m_data.selectionRectInWindowCoordinates; }
+ WebCore::FloatRect frameRect() const;
+ ShareableBitmap* contentImage() const { return m_data.contentImage.get(); }
+ Data data() const { return m_data; }
+
+ void draw(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
+
+private:
+ TextIndicator(const TextIndicator::Data&);
+
+ Data m_data;
+};
+
+} // namespace WebKit
+
+#endif // TextIndicator_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedmacActionMenuHitTestResulth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define ActionMenuHitTestResult_h
</span><span class="cx">
</span><span class="cx"> #include "ShareableBitmap.h"
</span><ins>+#include "TextIndicator.h"
</ins><span class="cx"> #include "WebHitTestResult.h"
</span><span class="cx"> #include <WebCore/FloatRect.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -51,7 +52,8 @@
</span><span class="cx"> RefPtr<ShareableBitmap> image;
</span><span class="cx">
</span><span class="cx"> RetainPtr<DDActionContext> actionContext;
</span><del>- WebCore::FloatRect actionBoundingBox;
</del><ins>+ WebCore::FloatRect detectedDataBoundingBox;
+ RefPtr<TextIndicator> detectedDataTextIndicator;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacActionMenuHitTestResultmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #import "ArgumentCodersCF.h"
</span><span class="cx"> #import "ArgumentDecoder.h"
</span><span class="cx"> #import "ArgumentEncoder.h"
</span><ins>+#import "TextIndicator.h"
</ins><span class="cx"> #import "WebCoreArgumentCoders.h"
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx">
</span><span class="lines">@@ -58,9 +59,14 @@
</span><span class="cx"> [archiver finishEncoding];
</span><span class="cx">
</span><span class="cx"> IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get()));
</span><ins>+
+ encoder << detectedDataBoundingBox;
+
+ bool hasTextIndicator = detectedDataTextIndicator;
+ encoder << hasTextIndicator;
+ if (hasTextIndicator)
+ encoder << detectedDataTextIndicator->data();
</ins><span class="cx"> }
</span><del>-
- encoder << actionBoundingBox;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ActionMenuHitTestResult::decode(IPC::ArgumentDecoder& decoder, ActionMenuHitTestResult& actionMenuHitTestResult)
</span><span class="lines">@@ -100,11 +106,23 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> [unarchiver finishDecoding];
</span><ins>+
+ if (!decoder.decode(actionMenuHitTestResult.detectedDataBoundingBox))
+ return false;
+
+ bool hasTextIndicator;
+ if (!decoder.decode(hasTextIndicator))
+ return false;
+
+ if (hasTextIndicator) {
+ TextIndicator::Data indicatorData;
+ if (!decoder.decode(indicatorData))
+ return false;
+
+ actionMenuHitTestResult.detectedDataTextIndicator = TextIndicator::create(indicatorData);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (!decoder.decode(actionMenuHitTestResult.actionBoundingBox))
- return false;
-
</del><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessTextIndicatorcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/TextIndicator.cpp (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/TextIndicator.cpp        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/TextIndicator.cpp        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -1,277 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextIndicator.h"
-
-#include "ShareableBitmap.h"
-#include <WebCore/GeometryUtilities.h>
-#include <WebCore/Gradient.h>
-#include <WebCore/GraphicsContext.h>
-#include <WebCore/IntRect.h>
-#include <WebCore/Path.h>
-
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
-#define ENABLE_LEGACY_TEXT_INDICATOR_STYLE 1
-#else
-#define ENABLE_LEGACY_TEXT_INDICATOR_STYLE 0
-#endif
-
-using namespace WebCore;
-
-#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
-static const float cornerRadius = 3.0;
-
-static const float shadowOffsetX = 0.0;
-static const float shadowOffsetY = 1.0;
-static const float shadowBlurRadius = 3.0;
-
-static const int shadowRed = 0;
-static const int shadowGreen = 0;
-static const int shadowBlue = 0;
-static const int shadowAlpha = 204;
-
-static const float lightBorderThickness = 1.0;
-static const float horizontalPaddingInsideLightBorder = 3.0;
-static const float verticalPaddingInsideLightBorder = 1.0;
-
-static const float horizontalBorderInsideShadow = lightBorderThickness + horizontalPaddingInsideLightBorder;
-static const float verticalBorderInsideShadow = lightBorderThickness + verticalPaddingInsideLightBorder;
-
-static const float leftBorderThickness = horizontalBorderInsideShadow + shadowOffsetX + shadowBlurRadius / 2.0;
-static const float topBorderThickness = verticalBorderInsideShadow - shadowOffsetY + shadowBlurRadius / 2.0;
-static const float rightBorderThickness = horizontalBorderInsideShadow - shadowOffsetX + shadowBlurRadius / 2.0;
-static const float bottomBorderThickness = verticalBorderInsideShadow + shadowOffsetY + shadowBlurRadius / 2.0;
-
-static const float horizontalOutsetToCenterOfLightBorder = horizontalBorderInsideShadow - lightBorderThickness / 2.0;
-static const float verticalOutsetToCenterOfLightBorder = verticalBorderInsideShadow - lightBorderThickness / 2.0;
-
-static const int lightBorderRed = 245;
-static const int lightBorderGreen = 230;
-static const int lightBorderBlue = 0;
-static const int lightBorderAlpha = 255;
-
-static const int gradientDarkRed = 237;
-static const int gradientDarkGreen = 204;
-static const int gradientDarkBlue = 0;
-static const int gradientDarkAlpha = 255;
-
-static const int gradientLightRed = 242;
-static const int gradientLightGreen = 239;
-static const int gradientLightBlue = 0;
-static const int gradientLightAlpha = 255;
-#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
-
-namespace WebKit {
-
-PassRefPtr<TextIndicator> TextIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle)
-{
- RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(contentImageHandle);
- if (!contentImage)
- return 0;
- ASSERT(contentImageScaleFactor != 1 || contentImage->size() == enclosingIntRect(selectionRectInWindowCoordinates).size());
-
- return adoptRef(new TextIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImage.release()));
-}
-
-static FloatRect inflateRect(const FloatRect& 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_TEXT_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
-}
-
-static bool textIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
-{
- size_t count = textRects.size();
- if (count <= 1)
- return false;
-
- Vector<FloatRect> indicatorRects;
- indicatorRects.reserveInitialCapacity(count);
-
- for (size_t i = 0; i < count; ++i) {
- FloatRect indicatorRect = outsetIndicatorRectIncludingShadow(textRects[i]);
-
- for (size_t j = indicatorRects.size(); j; ) {
- --j;
- if (indicatorRect.intersects(indicatorRects[j]))
- return true;
- }
-
- indicatorRects.uncheckedAppend(indicatorRect);
- }
-
- return false;
-}
-
-TextIndicator::TextIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage)
- : m_selectionRectInWindowCoordinates(selectionRectInWindowCoordinates)
- , m_textRectsInSelectionRectCoordinates(textRectsInSelectionRectCoordinates)
- , m_contentImageScaleFactor(contentImageScaleFactor)
- , m_contentImage(contentImage)
-{
- if (textIndicatorsForTextRectsOverlap(m_textRectsInSelectionRectCoordinates)) {
- m_textRectsInSelectionRectCoordinates[0] = unionRect(m_textRectsInSelectionRectCoordinates);
- m_textRectsInSelectionRectCoordinates.shrink(1);
- }
-}
-
-TextIndicator::~TextIndicator()
-{
-}
-
-FloatRect TextIndicator::frameRect() const
-{
- return outsetIndicatorRectIncludingShadow(m_selectionRectInWindowCoordinates);
-}
-
-#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
-static inline Color lightBorderColor()
-{
- return Color(lightBorderRed, lightBorderGreen, lightBorderBlue, lightBorderAlpha);
-}
-
-static inline Color shadowColor()
-{
- return Color(shadowRed, shadowGreen, shadowBlue, shadowAlpha);
-}
-
-static inline Color gradientLightColor()
-{
- return Color(gradientLightRed, gradientLightGreen, gradientLightBlue, gradientLightAlpha);
-}
-
-static inline Color gradientDarkColor()
-{
- return Color(gradientDarkRed, gradientDarkGreen, gradientDarkBlue, gradientDarkAlpha);
-}
-
-static Path pathWithRoundedRect(const FloatRect& pathRect, float radius)
-{
- Path path;
- path.addRoundedRect(pathRect, FloatSize(radius, radius));
-
- return path;
-}
-#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
-
-void TextIndicator::draw(GraphicsContext& graphicsContext, const IntRect& /*dirtyRect*/)
-{
-#if ENABLE(LEGACY_TEXT_INDICATOR_STYLE)
- for (size_t i = 0; i < m_textRectsInSelectionRectCoordinates.size(); ++i) {
- FloatRect textRect = m_textRectsInSelectionRectCoordinates[i];
- textRect.move(leftBorderThickness, topBorderThickness);
-
- FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
- FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
-
- {
- GraphicsContextStateSaver stateSaver(graphicsContext);
- graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
- graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
- graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
- }
-
- {
- GraphicsContextStateSaver stateSaver(graphicsContext);
- graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
- RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.maxY()));
- gradient->addColorStop(0, gradientLightColor());
- gradient->addColorStop(1, gradientDarkColor());
- graphicsContext.setFillGradient(gradient.releaseNonNull());
- graphicsContext.fillRect(outerPathRect);
- }
-
- {
- GraphicsContextStateSaver stateSaver(graphicsContext);
- graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness)));
-
- IntRect contentImageRect = enclosingIntRect(m_textRectsInSelectionRectCoordinates[i]);
- m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
- }
- }
-#else
- for (auto& 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->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
- }
- }
-#endif
-}
-
-} // namespace WebKit
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessTextIndicatorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/UIProcess/TextIndicator.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/TextIndicator.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/TextIndicator.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -1,64 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextIndicator_h
-#define TextIndicator_h
-
-#include "ShareableBitmap.h"
-#include <WebCore/FloatRect.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-class GraphicsContext;
-}
-
-namespace WebKit {
-
-class TextIndicator : public RefCounted<TextIndicator> {
-public:
- static PassRefPtr<TextIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle);
- ~TextIndicator();
-
- WebCore::FloatRect selectionRectInWindowCoordinates() const { return m_selectionRectInWindowCoordinates; }
- WebCore::FloatRect frameRect() const;
-
- ShareableBitmap* contentImage() const { return m_contentImage.get(); }
-
- void draw(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
-
-private:
- TextIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage);
-
- WebCore::FloatRect m_selectionRectInWindowCoordinates;
- Vector<WebCore::FloatRect> m_textRectsInSelectionRectCoordinates;
- float m_contentImageScaleFactor;
- RefPtr<ShareableBitmap> m_contentImage;
-};
-
-} // namespace WebKit
-
-#endif // TextIndicator_h
</del></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -3625,12 +3625,16 @@
</span><span class="cx"> m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebPageProxy::setTextIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
</del><ins>+void WebPageProxy::setTextIndicator(const TextIndicator::Data& indicatorData, bool fadeOut, bool animate)
</ins><span class="cx"> {
</span><del>- RefPtr<TextIndicator> textIndicator = TextIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
- m_pageClient.setTextIndicator(textIndicator.release(), fadeOut, animate);
</del><ins>+ m_pageClient.setTextIndicator(TextIndicator::create(indicatorData), fadeOut, animate);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::clearTextIndicator(bool fadeOut, bool animate)
+{
+ m_pageClient.setTextIndicator(nullptr, fadeOut, animate);
+}
+
</ins><span class="cx"> void WebPageProxy::didFindString(const String& string, uint32_t matchCount, int32_t matchIndex)
</span><span class="cx"> {
</span><span class="cx"> m_findClient->didFindString(this, string, matchCount, matchIndex);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx"> class RemoteLayerTreeTransaction;
</span><span class="cx"> class RemoteScrollingCoordinatorProxy;
</span><span class="cx"> class StringPairVector;
</span><ins>+class TextIndicator;
</ins><span class="cx"> class ViewSnapshot;
</span><span class="cx"> class VisitedLinkProvider;
</span><span class="cx"> class WebBackForwardList;
</span><span class="lines">@@ -661,7 +662,8 @@
</span><span class="cx"> void hideFindUI();
</span><span class="cx"> void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
</span><span class="cx"> void didCountStringMatches(const String&, uint32_t matchCount);
</span><del>- void setTextIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate);
</del><ins>+ void setTextIndicator(const TextIndicator::Data&, bool fadeOut, bool animate);
+ void clearTextIndicator(bool fadeOut, bool animate);
</ins><span class="cx"> void didFindString(const String&, uint32_t matchCount, int32_t matchIndex);
</span><span class="cx"> void didFailToFindString(const String&);
</span><span class="cx"> void didFindStringMatches(const String&, const Vector<Vector<WebCore::IntRect>>& matchRects, int32_t firstIndexAfterSelection);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -228,7 +228,8 @@
</span><span class="cx">
</span><span class="cx"> # Find messages
</span><span class="cx"> DidCountStringMatches(String string, uint32_t matchCount)
</span><del>- SetTextIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut, bool animate)
</del><ins>+ SetTextIndicator(WebKit::TextIndicator::Data indicator, bool fadeOut, bool animate)
+ ClearTextIndicator(bool fadeOut, bool animate)
</ins><span class="cx"> DidFindString(String string, uint32_t matchCount, int32_t matchIndex)
</span><span class="cx"> DidFailToFindString(String string)
</span><span class="cx"> DidFindStringMatches(String string, Vector<Vector<WebCore::IntRect>> matches, int32_t firstIndexAfterSelection)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKActionMenuControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -56,6 +56,8 @@
</span><span class="cx"> RefPtr<API::Object> _userData;
</span><span class="cx"> _WKActionMenuType _type;
</span><span class="cx"> RetainPtr<NSSharingServicePicker> _sharingServicePicker;
</span><ins>+
+ BOOL _isShowingTextIndicator;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (instancetype)initWithPage:(WebKit::WebPageProxy&)page view:(WKView *)wkView;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span><span class="cx">
</span><ins>+#import "TextIndicator.h"
</ins><span class="cx"> #import "WKNSURLExtras.h"
</span><span class="cx"> #import "WKViewInternal.h"
</span><span class="cx"> #import "WebContext.h"
</span><span class="lines">@@ -71,6 +72,8 @@
</span><span class="cx"> @interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate>
</span><span class="cx"> - (void)_updateActionMenuItemsForStage:(MenuUpdateStage)stage;
</span><span class="cx"> - (BOOL)_canAddImageToPhotos;
</span><ins>+- (void)_showTextIndicator;
+- (void)_hideTextIndicator;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @interface WKView (WKDeprecatedSPI)
</span><span class="lines">@@ -97,6 +100,7 @@
</span><span class="cx"> {
</span><span class="cx"> _page = nullptr;
</span><span class="cx"> _wkView = nullptr;
</span><ins>+ _hitTestResult = ActionMenuHitTestResult();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
</span><span class="lines">@@ -108,6 +112,8 @@
</span><span class="cx">
</span><span class="cx"> _state = ActionMenuState::Pending;
</span><span class="cx"> [self _updateActionMenuItemsForStage:MenuUpdateStage::PrepareForMenu];
</span><ins>+
+ [self _hideTextIndicator];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)isMenuForTextContent
</span><span class="lines">@@ -120,6 +126,9 @@
</span><span class="cx"> if (menu != _wkView.actionMenu)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ if (_type == kWKActionMenuDataDetectedItem)
+ [self _showTextIndicator];
+
</ins><span class="cx"> if (![self isMenuForTextContent])
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -134,6 +143,9 @@
</span><span class="cx"> {
</span><span class="cx"> if (menu != _wkView.actionMenu)
</span><span class="cx"> return;
</span><ins>+
+ if (_type == kWKActionMenuDataDetectedItem && menu.numberOfItems > 1)
+ [self _hideTextIndicator];
</ins><span class="cx">
</span><span class="cx"> _state = ActionMenuState::None;
</span><span class="cx"> _hitTestResult = ActionMenuHitTestResult();
</span><span class="lines">@@ -149,6 +161,28 @@
</span><span class="cx"> _userData = userData;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark Text Indicator
+
+- (void)_showTextIndicator
+{
+ if (_isShowingTextIndicator)
+ return;
+
+ if (_hitTestResult.detectedDataTextIndicator) {
+ _page->setTextIndicator(_hitTestResult.detectedDataTextIndicator->data(), false, true);
+ _isShowingTextIndicator = YES;
+ }
+}
+
+- (void)_hideTextIndicator
+{
+ if (!_isShowingTextIndicator)
+ return;
+
+ _page->clearTextIndicator(false, true);
+ _isShowingTextIndicator = NO;
+}
+
</ins><span class="cx"> #pragma mark Link actions
</span><span class="cx">
</span><span class="cx"> - (NSArray *)_defaultMenuItemsForLink
</span><span class="lines">@@ -321,8 +355,12 @@
</span><span class="cx"> if (!actionContext)
</span><span class="cx"> return @[ ];
</span><span class="cx">
</span><ins>+ actionContext.completionHandler = ^() {
+ [self _hideTextIndicator];
+ };
+
</ins><span class="cx"> WKSetDDActionContextIsForActionMenu(actionContext);
</span><del>- actionContext.highlightFrame = [_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.actionBoundingBox toView:nil]];
</del><ins>+ actionContext.highlightFrame = [_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.detectedDataBoundingBox toView:nil]];
</ins><span class="cx"> return [[getDDActionsManagerClass() sharedManager] menuItemsForResult:[_hitTestResult.actionContext mainResult] actionContext:actionContext];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -4458,6 +4458,8 @@
</span><span class="cx">                                 5272B2881406985D0096A5D0 /* StatisticsData.cpp */,
</span><span class="cx">                                 5272B2891406985D0096A5D0 /* StatisticsData.h */,
</span><span class="cx">                                 1A5E4DA312D3BD3D0099A2BB /* TextCheckerState.h */,
</span><ins>+                                1A910070126675C4001842F5 /* TextIndicator.cpp */,
+                                1A91006F126675C3001842F5 /* TextIndicator.h */,
</ins><span class="cx">                                 1A64245D12DE29A100CAAE2C /* UpdateInfo.cpp */,
</span><span class="cx">                                 1A64245C12DE29A100CAAE2C /* UpdateInfo.h */,
</span><span class="cx">                                 1AC1336518565B5700F3EC05 /* UserData.cpp */,
</span><span class="lines">@@ -5778,10 +5780,8 @@
</span><span class="cx">                                 BC2652121182608100243E12 /* DrawingAreaProxy.cpp */,
</span><span class="cx">                                 BC2652131182608100243E12 /* DrawingAreaProxy.h */,
</span><span class="cx">                                 1A6422FC12DD08FE00CAAE2C /* DrawingAreaProxy.messages.in */,
</span><del>-                                1A910070126675C4001842F5 /* TextIndicator.cpp */,
</del><span class="cx">                                 1AE00D5E1831792100087DD7 /* FrameLoadState.cpp */,
</span><span class="cx">                                 1AE00D5F1831792100087DD7 /* FrameLoadState.h */,
</span><del>-                                1A91006F126675C3001842F5 /* TextIndicator.h */,
</del><span class="cx">                                 BC17753E118BABF0007D9E9A /* GenericCallback.h */,
</span><span class="cx">                                 BC06F44912DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.cpp */,
</span><span class="cx">                                 BC06F44812DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.h */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "DrawingArea.h"
</span><span class="cx"> #include "PluginView.h"
</span><span class="cx"> #include "ShareableBitmap.h"
</span><ins>+#include "TextIndicator.h"
</ins><span class="cx"> #include "WKPage.h"
</span><span class="cx"> #include "WebCoreArgumentCoders.h"
</span><span class="cx"> #include "WebPage.h"
</span><span class="lines">@@ -36,10 +37,8 @@
</span><span class="cx"> #include <WebCore/DocumentMarkerController.h>
</span><span class="cx"> #include <WebCore/FloatQuad.h>
</span><span class="cx"> #include <WebCore/FocusController.h>
</span><del>-#include <WebCore/FrameSnapshotting.h>
</del><span class="cx"> #include <WebCore/FrameView.h>
</span><span class="cx"> #include <WebCore/GraphicsContext.h>
</span><del>-#include <WebCore/ImageBuffer.h>
</del><span class="cx"> #include <WebCore/MainFrame.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="cx"> #include <WebCore/PageOverlayController.h>
</span><span class="lines">@@ -259,28 +258,6 @@
</span><span class="cx"> m_webPage->send(Messages::WebPageProxy::DidFindStringMatches(string, matchRects, indexForSelection));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static bool getFindIndicatorBitmap(Frame& frame, ShareableBitmap::Handle& handle)
-{
- std::unique_ptr<ImageBuffer> snapshot = snapshotSelection(frame, WebCore::SnapshotOptionsForceBlackText);
- if (!snapshot)
- return false;
-
- RefPtr<ShareableBitmap> findIndicatorTextBackingStore = ShareableBitmap::createShareable(snapshot->internalSize(), ShareableBitmap::SupportsAlpha);
- if (!findIndicatorTextBackingStore)
- return false;
-
- // 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).
- auto graphicsContext = findIndicatorTextBackingStore->createGraphicsContext();
- float deviceScaleFactor = frame.page()->deviceScaleFactor();
- graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
- graphicsContext->drawImageBuffer(snapshot.get(), ColorSpaceDeviceRGB, FloatPoint());
-
- if (!findIndicatorTextBackingStore->createHandle(handle))
- return false;
- return true;
-}
-
</del><span class="cx"> void FindController::getImageForFindMatch(uint32_t matchIndex)
</span><span class="cx"> {
</span><span class="cx"> if (matchIndex >= m_findMatches.size())
</span><span class="lines">@@ -292,11 +269,16 @@
</span><span class="cx"> VisibleSelection oldSelection = frame->selection().selection();
</span><span class="cx"> frame->selection().setSelection(VisibleSelection(m_findMatches[matchIndex].get()));
</span><span class="cx">
</span><del>- ShareableBitmap::Handle handle;
- getFindIndicatorBitmap(*frame, handle);
</del><ins>+ RefPtr<ShareableBitmap> selectionSnapshot = WebFrame::fromCoreFrame(*frame)->createSelectionSnapshot();
</ins><span class="cx">
</span><span class="cx"> frame->selection().setSelection(oldSelection);
</span><span class="cx">
</span><ins>+ if (!selectionSnapshot)
+ return;
+
+ ShareableBitmap::Handle handle;
+ selectionSnapshot->createHandle(handle);
+
</ins><span class="cx"> if (handle.isNull())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -332,29 +314,12 @@
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> bool FindController::updateFindIndicator(Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate)
</span><span class="cx"> {
</span><del>- IntRect selectionRect = enclosingIntRect(selectedFrame.selection().selectionBounds());
- ShareableBitmap::Handle handle;
- if (!getFindIndicatorBitmap(selectedFrame, handle))
</del><ins>+ RefPtr<TextIndicator> indicator = TextIndicator::createWithSelectionInFrame(*WebFrame::fromCoreFrame(selectedFrame));
+ if (!indicator)
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- // We want the selection rect in window coordinates.
- IntRect selectionRectInWindowCoordinates = selectedFrame.view()->contentsToWindow(selectionRect);
-
- Vector<FloatRect> textRects;
- selectedFrame.selection().getClippedVisibleTextRectangles(textRects);
-
- // We want the text rects in selection rect coordinates.
- Vector<FloatRect> textRectsInSelectionRectCoordinates;
-
- for (size_t i = 0; i < textRects.size(); ++i) {
- IntRect textRectInSelectionRectCoordinates = selectedFrame.view()->contentsToWindow(enclosingIntRect(textRects[i]));
- textRectInSelectionRectCoordinates.move(-selectionRectInWindowCoordinates.x(), -selectionRectInWindowCoordinates.y());
-
- textRectsInSelectionRectCoordinates.append(textRectInSelectionRectCoordinates);
- }
-
- m_webPage->send(Messages::WebPageProxy::SetTextIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->corePage()->deviceScaleFactor(), handle, !isShowingOverlay, shouldAnimate));
- m_findIndicatorRect = selectionRectInWindowCoordinates;
</del><ins>+ m_findIndicatorRect = enclosingIntRect(indicator->selectionRectInWindowCoordinates());
+ m_webPage->send(Messages::WebPageProxy::SetTextIndicator(indicator->data(), !isShowingOverlay, shouldAnimate));
</ins><span class="cx"> m_isShowingFindIndicator = true;
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="lines">@@ -365,8 +330,7 @@
</span><span class="cx"> if (!m_isShowingFindIndicator)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- ShareableBitmap::Handle handle;
- m_webPage->send(Messages::WebPageProxy::SetTextIndicator(FloatRect(), Vector<FloatRect>(), m_webPage->corePage()->deviceScaleFactor(), handle, false, true));
</del><ins>+ m_webPage->send(Messages::WebPageProxy::ClearTextIndicator(false, true));
</ins><span class="cx"> m_isShowingFindIndicator = false;
</span><span class="cx"> m_foundStringMatchIndex = -1;
</span><span class="cx"> didHideFindIndicator();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -50,12 +50,14 @@
</span><span class="cx"> #include <WebCore/DocumentLoader.h>
</span><span class="cx"> #include <WebCore/EventHandler.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><ins>+#include <WebCore/FrameSnapshotting.h>
</ins><span class="cx"> #include <WebCore/FrameView.h>
</span><span class="cx"> #include <WebCore/HTMLFormElement.h>
</span><span class="cx"> #include <WebCore/HTMLFrameOwnerElement.h>
</span><span class="cx"> #include <WebCore/HTMLInputElement.h>
</span><span class="cx"> #include <WebCore/HTMLNames.h>
</span><span class="cx"> #include <WebCore/HTMLTextAreaElement.h>
</span><ins>+#include <WebCore/ImageBuffer.h>
</ins><span class="cx"> #include <WebCore/JSCSSStyleDeclaration.h>
</span><span class="cx"> #include <WebCore/JSElement.h>
</span><span class="cx"> #include <WebCore/JSRange.h>
</span><span class="lines">@@ -780,5 +782,25 @@
</span><span class="cx"> return archive->rawDataRepresentation();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+
+PassRefPtr<ShareableBitmap> WebFrame::createSelectionSnapshot()
+{
+ std::unique_ptr<ImageBuffer> snapshot = snapshotSelection(*coreFrame(), WebCore::SnapshotOptionsForceBlackText);
+ if (!snapshot)
+ return nullptr;
+
+ RefPtr<ShareableBitmap> sharedSnapshot = ShareableBitmap::createShareable(snapshot->internalSize(), ShareableBitmap::SupportsAlpha);
+ if (!sharedSnapshot)
+ return nullptr;
+
+ // FIXME: We should consider providing a way to use subpixel antialiasing for the snapshot
+ // if we're compositing this image onto a solid color (e.g. the modern find indicator style).
+ auto graphicsContext = sharedSnapshot->createGraphicsContext();
+ float deviceScaleFactor = coreFrame()->page()->deviceScaleFactor();
+ graphicsContext->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
+ graphicsContext->drawImageBuffer(snapshot.get(), ColorSpaceDeviceRGB, FloatPoint());
+
+ return sharedSnapshot.release();
+}
</ins><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebFrameh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define WebFrame_h
</span><span class="cx">
</span><span class="cx"> #include "APIObject.h"
</span><ins>+#include "ShareableBitmap.h"
</ins><span class="cx"> #include "WKBase.h"
</span><span class="cx"> #include "WebFrameLoaderClient.h"
</span><span class="cx"> #include <JavaScriptCore/JSBase.h>
</span><span class="lines">@@ -149,6 +150,8 @@
</span><span class="cx"> RetainPtr<CFDataRef> webArchiveData(FrameFilterFunction, void* context);
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ PassRefPtr<ShareableBitmap> createSelectionSnapshot();
+
</ins><span class="cx"> private:
</span><span class="cx"> static PassRefPtr<WebFrame> create(std::unique_ptr<WebFrameLoaderClient>);
</span><span class="cx"> WebFrame(std::unique_ptr<WebFrameLoaderClient>);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175563 => 175564)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-04 19:39:17 UTC (rev 175563)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-04 19:42:37 UTC (rev 175564)
</span><span class="lines">@@ -1077,7 +1077,7 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static RetainPtr<DDActionContext> scanForDataDetectedItems(const HitTestResult& hitTestResult, FloatRect& actionBoundingBox)
</del><ins>+static RetainPtr<DDActionContext> scanForDataDetectedItems(const HitTestResult& hitTestResult, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
</ins><span class="cx"> {
</span><span class="cx"> Node* node = hitTestResult.innerNonSharedNode();
</span><span class="cx"> if (!node)
</span><span class="lines">@@ -1128,11 +1128,33 @@
</span><span class="cx"> Vector<FloatQuad> quads;
</span><span class="cx"> mainResultRange->textQuads(quads);
</span><span class="cx"> if (!quads.isEmpty())
</span><del>- actionBoundingBox = mainResultRange->ownerDocument().view()->contentsToWindow(quads[0].enclosingBoundingBox());
</del><ins>+ detectedDataBoundingBox = mainResultRange->ownerDocument().view()->contentsToWindow(quads[0].enclosingBoundingBox());
</ins><span class="cx">
</span><ins>+ detectedDataRange = mainResultRange;
+
</ins><span class="cx"> return actionContext;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static PassRefPtr<TextIndicator> textIndicatorForRange(Range* range)
+{
+ if (!range)
+ return nullptr;
+
+ Frame* frame = range->startContainer()->document().frame();
+
+ if (!frame)
+ return nullptr;
+
+ VisibleSelection oldSelection = frame->selection().selection();
+ frame->selection().setSelection(range);
+
+ RefPtr<TextIndicator> indicator = TextIndicator::createWithSelectionInFrame(*WebFrame::fromCoreFrame(*frame));
+
+ frame->selection().setSelection(oldSelection);
+
+ return indicator.release();
+}
+
</ins><span class="cx"> void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInViewCooordinates)
</span><span class="cx"> {
</span><span class="cx"> layoutIfNeeded();
</span><span class="lines">@@ -1166,9 +1188,13 @@
</span><span class="cx">
</span><span class="cx"> // FIXME: Avoid scanning if we will just throw away the result (e.g. we're over a link).
</span><span class="cx"> if (hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode()) {
</span><del>- FloatRect actionBoundingBox;
- actionMenuResult.actionContext = scanForDataDetectedItems(hitTestResult, actionBoundingBox);
- actionMenuResult.actionBoundingBox = actionBoundingBox;
</del><ins>+ FloatRect detectedDataBoundingBox;
+ RefPtr<Range> detectedDataRange;
+ actionMenuResult.actionContext = scanForDataDetectedItems(hitTestResult, detectedDataBoundingBox, detectedDataRange);
+ if (actionMenuResult.actionContext) {
+ actionMenuResult.detectedDataBoundingBox = detectedDataBoundingBox;
+ actionMenuResult.detectedDataTextIndicator = textIndicatorForRange(detectedDataRange.get());
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<API::Object> userData;
</span></span></pre>
</div>
</div>
</body>
</html>