<!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>[172553] branches/safari-600.1-branch/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/172553">172553</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2014-08-13 20:38:54 -0700 (Wed, 13 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/172383">r172383</a>. <rdar://problem/17971057></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001branchSourceWebCoreChangeLog">branches/safari-600.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001branchSourceWebCoreeditingEditorcpp">branches/safari-600.1-branch/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#branchessafari6001branchSourceWebCoreeditingEditorh">branches/safari-600.1-branch/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#branchessafari6001branchSourceWebCorepageEditorClienth">branches/safari-600.1-branch/Source/WebCore/page/EditorClient.h</a></li>
<li><a href="#branchessafari6001branchSourceWebKit2ChangeLog">branches/safari-600.1-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6001branchSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp">branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp</a></li>
<li><a href="#branchessafari6001branchSourceWebKit2WebProcessWebCoreSupportWebEditorClienth">branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#branchessafari6001branchSourceWebKit2WebProcessWebPageServicesOverlayControllerh">branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h</a></li>
<li><a href="#branchessafari6001branchSourceWebKit2WebProcessWebPagemacServicesOverlayControllermm">branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/ChangeLog (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/ChangeLog        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebCore/ChangeLog        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-08-13 Lucas Forschler <lforschler@apple.com>
+
+ Merge r172383
+
+ 2014-08-10 Tim Horton <timothy_horton@apple.com>
+
+ Yelp phone number highlights often disappear
+ https://bugs.webkit.org/show_bug.cgi?id=135789
+ <rdar://problem/17971057>
+
+ Reviewed by Brady Eidson.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::scanSelectionForTelephoneNumbers):
+ (WebCore::Editor::clearDataDetectedTelephoneNumbers): Deleted.
+ * editing/Editor.h:
+ (WebCore::Editor::detectedTelephoneNumberRanges):
+ * page/EditorClient.h:
+ (WebCore::EditorClient::selectedTelephoneNumberRangesChanged):
+ Cache and expose detected telephone number ranges on Editor.
+ Change selectedTelephoneNumberRangesChanged to take no arguments; it's
+ just a notification now.
+
</ins><span class="cx"> 2014-08-12 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r172471
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/editing/Editor.cpp (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/editing/Editor.cpp        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebCore/editing/Editor.cpp        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -3362,11 +3362,13 @@
</span><span class="cx"> if (!shouldDetectTelephoneNumbers() || !client())
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ m_detectedTelephoneNumberRanges.clear();
+
</ins><span class="cx"> Vector<RefPtr<Range>> markedRanges;
</span><span class="cx">
</span><span class="cx"> FrameSelection& frameSelection = m_frame.selection();
</span><span class="cx"> if (!frameSelection.isRange()) {
</span><del>- client()->selectedTelephoneNumberRangesChanged(markedRanges);
</del><ins>+ client()->selectedTelephoneNumberRangesChanged();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> RefPtr<Range> selectedRange = frameSelection.toNormalizedRange();
</span><span class="lines">@@ -3394,20 +3396,19 @@
</span><span class="cx"> RefPtr<Range> extendedRange = extendedSelection.toNormalizedRange();
</span><span class="cx">
</span><span class="cx"> if (!extendedRange) {
</span><del>- client()->selectedTelephoneNumberRangesChanged(markedRanges);
</del><ins>+ client()->selectedTelephoneNumberRangesChanged();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> scanRangeForTelephoneNumbers(*extendedRange, extendedRange->text(), markedRanges);
</span><span class="cx">
</span><span class="cx"> // Only consider ranges with a detected telephone number if they overlap with the actual selection range.
</span><del>- Vector<RefPtr<Range>> markedRangesIntersectingSelection;
</del><span class="cx"> for (auto& range : markedRanges) {
</span><span class="cx"> if (rangesOverlap(range.get(), selectedRange.get()))
</span><del>- markedRangesIntersectingSelection.append(range);
</del><ins>+ m_detectedTelephoneNumberRanges.append(range);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- client()->selectedTelephoneNumberRangesChanged(markedRangesIntersectingSelection);
</del><ins>+ client()->selectedTelephoneNumberRangesChanged();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Editor::scanRangeForTelephoneNumbers(Range& range, const StringView& stringView, Vector<RefPtr<Range>>& markedRanges)
</span><span class="lines">@@ -3448,13 +3449,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Editor::clearDataDetectedTelephoneNumbers()
-{
- document().markers().removeMarkers(DocumentMarker::TelephoneNumber);
-
- // FIXME: Do other UI cleanup here once we have other UI.
-}
-
</del><span class="cx"> #endif // ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> void Editor::updateEditorUINowIfScheduled()
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/editing/Editor.h (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/editing/Editor.h        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebCore/editing/Editor.h        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -450,6 +450,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
</span><span class="cx"> void scanSelectionForTelephoneNumbers();
</span><ins>+ const Vector<RefPtr<Range>>& detectedTelephoneNumberRanges() const { return m_detectedTelephoneNumberRanges; }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -521,9 +522,9 @@
</span><span class="cx"> bool shouldDetectTelephoneNumbers();
</span><span class="cx"> void scanSelectionForTelephoneNumbers(Timer<Editor>&);
</span><span class="cx"> void scanRangeForTelephoneNumbers(Range&, const StringView&, Vector<RefPtr<Range>>& markedRanges);
</span><del>- void clearDataDetectedTelephoneNumbers();
</del><span class="cx">
</span><span class="cx"> Timer<Editor> m_telephoneNumberDetectionUpdateTimer;
</span><ins>+ Vector<RefPtr<Range>> m_detectedTelephoneNumberRanges;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebCorepageEditorClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebCore/page/EditorClient.h (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebCore/page/EditorClient.h        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebCore/page/EditorClient.h        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx"> virtual void setInputMethodState(bool enabled) = 0;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
</span><del>- virtual void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<Range>>&) { }
</del><ins>+ virtual void selectedTelephoneNumberRangesChanged() { }
</ins><span class="cx"> virtual void selectionRectsDidChange(const Vector<LayoutRect>&, const Vector<GapRects>&, bool) { }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebKit2/ChangeLog (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebKit2/ChangeLog        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebKit2/ChangeLog        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2014-08-13 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r172383
+
+ 2014-08-10 Tim Horton <timothy_horton@apple.com>
+
+ Yelp phone number highlights often disappear
+ https://bugs.webkit.org/show_bug.cgi?id=135789
+ <rdar://problem/17971057>
+
+ Reviewed by Brady Eidson.
+
+ Since selectedTelephoneNumberRangesChanged doesn't provide an associated
+ Frame, an incoming selectedTelephoneNumberRangesChanged from a subframe
+ would overwrite ServicesOverlayController's cached (and potentially active)
+ telephone number highlights.
+
+ This happens a lot on Yelp, because they have many subframes which are
+ doing layout on a regular basis.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::selectedTelephoneNumberRangesChanged):
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ Adjust to the new (lack of) arguments.
+
+ * WebProcess/WebPage/ServicesOverlayController.h:
+ * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+ (WebKit::ServicesOverlayController::selectedTelephoneNumberRangesChanged):
+ Adjust logging; we can revisit it later.
+
+ (WebKit::ServicesOverlayController::buildPhoneNumberHighlights):
+ When building phone number highlights, walk the Frame tree and retrieve
+ them from all of the Editors.
+
+ (WebKit::ServicesOverlayController::didRebuildPotentialHighlights):
+ (WebKit::ServicesOverlayController::telephoneNumberRangesForFocusedFrame):
+ (WebKit::ServicesOverlayController::determineActiveHighlight):
+ (WebKit::ServicesOverlayController::handleClick):
+ Retrieve the detected telephone number ranges from the focused frame
+ when combining telephone numbers with selection services.
+ This ensures that we don't show combined phone number highlights from other frames.
+
+2014-08-13 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r172382
</span><span class="cx">
</span><span class="cx"> 2014-08-10 Tim Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebKit2WebProcessWebCoreSupportWebEditorClientcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -532,10 +532,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
</span><del>-void WebEditorClient::selectedTelephoneNumberRangesChanged(const Vector<RefPtr<Range>>& ranges)
</del><ins>+void WebEditorClient::selectedTelephoneNumberRangesChanged()
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>- m_page->servicesOverlayController().selectedTelephoneNumberRangesChanged(ranges);
</del><ins>+ m_page->servicesOverlayController().selectedTelephoneNumberRangesChanged();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> void WebEditorClient::selectionRectsDidChange(const Vector<LayoutRect>& rects, const Vector<GapRects>& gapRects, bool isTextOnly)
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebKit2WebProcessWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx"> virtual bool supportsGlobalSelection() override;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(TELEPHONE_NUMBER_DETECTION) || ENABLE(SERVICE_CONTROLS)
</span><del>- virtual void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<WebCore::Range>>&) override;
</del><ins>+ virtual void selectedTelephoneNumberRangesChanged() override;
</ins><span class="cx"> virtual void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&, bool isTextOnly) override;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebKit2WebProcessWebPageServicesOverlayControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
</span><span class="cx">
</span><span class="cx"> #include "PageOverlay.h"
</span><ins>+#include "WebFrame.h"
</ins><span class="cx"> #include <WebCore/Range.h>
</span><span class="cx"> #include <WebCore/Timer.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -50,7 +51,7 @@
</span><span class="cx"> ServicesOverlayController(WebPage&);
</span><span class="cx"> ~ServicesOverlayController();
</span><span class="cx">
</span><del>- void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<WebCore::Range>>&);
</del><ins>+ void selectedTelephoneNumberRangesChanged();
</ins><span class="cx"> void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&, bool isTextOnly);
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -112,13 +113,14 @@
</span><span class="cx">
</span><span class="cx"> static bool highlightsAreEquivalent(const Highlight* a, const Highlight* b);
</span><span class="cx">
</span><ins>+ Vector<RefPtr<WebCore::Range>> telephoneNumberRangesForFocusedFrame();
+
</ins><span class="cx"> WebPage& m_webPage;
</span><span class="cx"> PageOverlay* m_servicesOverlay;
</span><span class="cx">
</span><span class="cx"> RefPtr<Highlight> m_activeHighlight;
</span><span class="cx"> HashSet<RefPtr<Highlight>> m_potentialHighlights;
</span><span class="cx">
</span><del>- Vector<RefPtr<WebCore::Range>> m_currentTelephoneNumberRanges;
</del><span class="cx"> Vector<WebCore::LayoutRect> m_currentSelectionRects;
</span><span class="cx"> bool m_isTextOnly;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6001branchSourceWebKit2WebProcessWebPagemacServicesOverlayControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm (172552 => 172553)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm        2014-08-14 03:19:02 UTC (rev 172552)
+++ branches/safari-600.1-branch/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm        2014-08-14 03:38:54 UTC (rev 172553)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #import "WebProcess.h"
</span><span class="cx"> #import <WebCore/Document.h>
</span><span class="cx"> #import <WebCore/FloatQuad.h>
</span><ins>+#import <WebCore/FocusController.h>
</ins><span class="cx"> #import <WebCore/FrameView.h>
</span><span class="cx"> #import <WebCore/GapRects.h>
</span><span class="cx"> #import <WebCore/GraphicsContext.h>
</span><span class="lines">@@ -224,12 +225,10 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ServicesOverlayController::selectedTelephoneNumberRangesChanged(const Vector<RefPtr<Range>>& ranges)
</del><ins>+void ServicesOverlayController::selectedTelephoneNumberRangesChanged()
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
</span><del>- LOG(Services, "ServicesOverlayController - Telephone number ranges changed - Had %lu, now have %lu\n", m_currentTelephoneNumberRanges.size(), ranges.size());
- m_currentTelephoneNumberRanges = ranges;
-
</del><ins>+ LOG(Services, "ServicesOverlayController - Telephone number ranges changed\n");
</ins><span class="cx"> buildPhoneNumberHighlights();
</span><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(ranges);
</span><span class="lines">@@ -323,25 +322,30 @@
</span><span class="cx"> {
</span><span class="cx"> removeAllPotentialHighlightsOfType(Highlight::Type::TelephoneNumber);
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < m_currentTelephoneNumberRanges.size(); ++i) {
- // FIXME: This will choke if the range wraps around the edge of the view.
- // What should we do in that case?
- IntRect rect = textQuadsToBoundingRectForRange(*m_currentTelephoneNumberRanges[i]);
</del><ins>+ Frame* mainFrame = m_webPage.mainFrame();
+ FrameView& mainFrameView = *mainFrame->view();
</ins><span class="cx">
</span><del>- // Convert to the main document's coordinate space.
- // FIXME: It's a little crazy to call contentsToWindow and then windowToContents in order to get the right coordinate space.
- // We should consider adding conversion functions to ScrollView for contentsToDocument(). Right now, contentsToRootView() is
- // not equivalent to what we need when you have a topContentInset or a header banner.
- FrameView* viewForRange = m_currentTelephoneNumberRanges[i]->ownerDocument().view();
- if (!viewForRange)
- continue;
- FrameView& mainFrameView = *m_webPage.corePage()->mainFrame().view();
- rect.setLocation(mainFrameView.windowToContents(viewForRange->contentsToWindow(rect.location())));
</del><ins>+ for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext()) {
+ auto& ranges = frame->editor().detectedTelephoneNumberRanges();
+ for (auto& range : ranges) {
+ // FIXME: This will choke if the range wraps around the edge of the view.
+ // What should we do in that case?
+ IntRect rect = textQuadsToBoundingRectForRange(*range);
</ins><span class="cx">
</span><del>- CGRect cgRect = rect;
- RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, mainFrameView.visibleContentRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
</del><ins>+ // Convert to the main document's coordinate space.
+ // FIXME: It's a little crazy to call contentsToWindow and then windowToContents in order to get the right coordinate space.
+ // We should consider adding conversion functions to ScrollView for contentsToDocument(). Right now, contentsToRootView() is
+ // not equivalent to what we need when you have a topContentInset or a header banner.
+ FrameView* viewForRange = range->ownerDocument().view();
+ if (!viewForRange)
+ continue;
+ rect.setLocation(mainFrameView.windowToContents(viewForRange->contentsToWindow(rect.location())));
</ins><span class="cx">
</span><del>- m_potentialHighlights.add(Highlight::createForTelephoneNumber(ddHighlight, m_currentTelephoneNumberRanges[i]));
</del><ins>+ CGRect cgRect = rect;
+ RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, mainFrameView.visibleContentRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
+
+ m_potentialHighlights.add(Highlight::createForTelephoneNumber(ddHighlight, range));
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> didRebuildPotentialHighlights();
</span><span class="lines">@@ -380,7 +384,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (m_currentTelephoneNumberRanges.isEmpty() && !hasRelevantSelectionServices())
</del><ins>+ if (telephoneNumberRangesForFocusedFrame().isEmpty() && !hasRelevantSelectionServices())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> createOverlayIfNeeded();
</span><span class="lines">@@ -399,6 +403,15 @@
</span><span class="cx"> m_servicesOverlay->setNeedsDisplay();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Vector<RefPtr<Range>> ServicesOverlayController::telephoneNumberRangesForFocusedFrame()
+{
+ Page* page = m_webPage.corePage();
+ if (!page)
+ return Vector<RefPtr<Range>>();
+
+ return page->focusController().focusedOrMainFrame().editor().detectedTelephoneNumberRanges();
+}
+
</ins><span class="cx"> bool ServicesOverlayController::highlightsAreEquivalent(const Highlight* a, const Highlight* b)
</span><span class="cx"> {
</span><span class="cx"> if (a == b)
</span><span class="lines">@@ -427,7 +440,7 @@
</span><span class="cx"> continue;
</span><span class="cx">
</span><span class="cx"> // If this highlight has no compatible services, it can't be active, unless we have telephone number highlights to show in the combined menu.
</span><del>- if (m_currentTelephoneNumberRanges.isEmpty() && !hasRelevantSelectionServices())
</del><ins>+ if (telephoneNumberRangesForFocusedFrame().isEmpty() && !hasRelevantSelectionServices())
</ins><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -505,9 +518,10 @@
</span><span class="cx"> IntPoint windowPoint = frameView->contentsToWindow(clickPoint);
</span><span class="cx">
</span><span class="cx"> if (highlight.type() == Highlight::Type::Selection) {
</span><ins>+ auto telephoneNumberRanges = telephoneNumberRangesForFocusedFrame();
</ins><span class="cx"> Vector<String> selectedTelephoneNumbers;
</span><del>- selectedTelephoneNumbers.reserveCapacity(m_currentTelephoneNumberRanges.size());
- for (auto& range : m_currentTelephoneNumberRanges)
</del><ins>+ selectedTelephoneNumbers.reserveCapacity(telephoneNumberRanges.size());
+ for (auto& range : telephoneNumberRanges)
</ins><span class="cx"> selectedTelephoneNumbers.append(range->text());
</span><span class="cx">
</span><span class="cx"> m_webPage.handleSelectionServiceClick(m_webPage.corePage()->mainFrame().selection(), selectedTelephoneNumbers, windowPoint);
</span></span></pre>
</div>
</div>
</body>
</html>