<!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>[185778] trunk/Source/WebCore</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/185778">185778</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-06-19 16:40:32 -0700 (Fri, 19 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Selection services cannot be invoked when force click is enabled
https://bugs.webkit.org/show_bug.cgi?id=146166
&lt;rdar://problem/21468362&gt;

Reviewed by Darin Adler.

* page/mac/ServicesOverlayController.h:
Turn Highlight::Type into something we can use for dirty flags.

* page/mac/ServicesOverlayController.mm:
(WebCore::ServicesOverlayController::Highlight::createForSelection):
(WebCore::ServicesOverlayController::Highlight::createForTelephoneNumber):
(WebCore::ServicesOverlayController::ServicesOverlayController):
(WebCore::ServicesOverlayController::selectionRectsDidChange):
(WebCore::ServicesOverlayController::selectedTelephoneNumberRangesChanged):
(WebCore::ServicesOverlayController::invalidateHighlightsOfType):
(WebCore::ServicesOverlayController::buildPotentialHighlightsIfNeeded):
(WebCore::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
(WebCore::ServicesOverlayController::buildPhoneNumberHighlights):
(WebCore::ServicesOverlayController::buildSelectionHighlight):
(WebCore::ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight):
(WebCore::ServicesOverlayController::determineActiveHighlight):
(WebCore::ServicesOverlayController::didScrollFrame):
(WebCore::ServicesOverlayController::handleClick):
Coalesce highlight rebuilding so that things (like TextIndicator creation)
that change the selection and then reset it immediately don't cause us
to lose the active highlight.

This also means that if the selection changes multiple times in a runloop
(easily possible from script), we won't waste a lot of time rebuilding highlights.

(WebCore::ServicesOverlayController::didRebuildPotentialHighlights):
Merged into buildPotentialHighlightsIfNeeded.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagemacServicesOverlayControllerh">trunk/Source/WebCore/page/mac/ServicesOverlayController.h</a></li>
<li><a href="#trunkSourceWebCorepagemacServicesOverlayControllermm">trunk/Source/WebCore/page/mac/ServicesOverlayController.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185777 => 185778)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-19 23:35:53 UTC (rev 185777)
+++ trunk/Source/WebCore/ChangeLog        2015-06-19 23:40:32 UTC (rev 185778)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2015-06-19  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Selection services cannot be invoked when force click is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=146166
+        &lt;rdar://problem/21468362&gt;
+
+        Reviewed by Darin Adler.
+
+        * page/mac/ServicesOverlayController.h:
+        Turn Highlight::Type into something we can use for dirty flags.
+
+        * page/mac/ServicesOverlayController.mm:
+        (WebCore::ServicesOverlayController::Highlight::createForSelection):
+        (WebCore::ServicesOverlayController::Highlight::createForTelephoneNumber):
+        (WebCore::ServicesOverlayController::ServicesOverlayController):
+        (WebCore::ServicesOverlayController::selectionRectsDidChange):
+        (WebCore::ServicesOverlayController::selectedTelephoneNumberRangesChanged):
+        (WebCore::ServicesOverlayController::invalidateHighlightsOfType):
+        (WebCore::ServicesOverlayController::buildPotentialHighlightsIfNeeded):
+        (WebCore::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
+        (WebCore::ServicesOverlayController::buildPhoneNumberHighlights):
+        (WebCore::ServicesOverlayController::buildSelectionHighlight):
+        (WebCore::ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight):
+        (WebCore::ServicesOverlayController::determineActiveHighlight):
+        (WebCore::ServicesOverlayController::didScrollFrame):
+        (WebCore::ServicesOverlayController::handleClick):
+        Coalesce highlight rebuilding so that things (like TextIndicator creation)
+        that change the selection and then reset it immediately don't cause us
+        to lose the active highlight.
+
+        This also means that if the selection changes multiple times in a runloop
+        (easily possible from script), we won't waste a lot of time rebuilding highlights.
+
+        (WebCore::ServicesOverlayController::didRebuildPotentialHighlights):
+        Merged into buildPotentialHighlightsIfNeeded.
+
</ins><span class="cx"> 2015-06-19  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: TimelineAgent needs to handle nested runloops
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacServicesOverlayControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/ServicesOverlayController.h (185777 => 185778)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/ServicesOverlayController.h        2015-06-19 23:35:53 UTC (rev 185777)
+++ trunk/Source/WebCore/page/mac/ServicesOverlayController.h        2015-06-19 23:40:32 UTC (rev 185778)
</span><span class="lines">@@ -67,10 +67,11 @@
</span><span class="cx">         Range* range() const { return m_range.get(); }
</span><span class="cx">         GraphicsLayer* layer() const { return m_graphicsLayer.get(); }
</span><span class="cx"> 
</span><del>-        enum class Type {
-            TelephoneNumber,
-            Selection
</del><ins>+        enum {
+            TelephoneNumberType = 1 &lt;&lt; 0,
+            SelectionType = 1 &lt;&lt; 1,
</ins><span class="cx">         };
</span><ins>+        typedef uint8_t Type;
</ins><span class="cx">         Type type() const { return m_type; }
</span><span class="cx"> 
</span><span class="cx">         void fadeIn();
</span><span class="lines">@@ -108,11 +109,13 @@
</span><span class="cx"> 
</span><span class="cx">     void drawHighlight(Highlight&amp;, GraphicsContext&amp;);
</span><span class="cx"> 
</span><ins>+    void invalidateHighlightsOfType(Highlight::Type);
+    void buildPotentialHighlightsIfNeeded();
+
</ins><span class="cx">     void replaceHighlightsOfTypePreservingEquivalentHighlights(HashSet&lt;RefPtr&lt;Highlight&gt;&gt;&amp;, Highlight::Type);
</span><span class="cx">     void removeAllPotentialHighlightsOfType(Highlight::Type);
</span><span class="cx">     void buildPhoneNumberHighlights();
</span><span class="cx">     void buildSelectionHighlight();
</span><del>-    void didRebuildPotentialHighlights();
</del><span class="cx"> 
</span><span class="cx">     void determineActiveHighlight(bool&amp; mouseIsOverButton);
</span><span class="cx">     void clearActiveHighlight();
</span><span class="lines">@@ -137,7 +140,7 @@
</span><span class="cx">     MainFrame&amp; mainFrame() const { return m_mainFrame; }
</span><span class="cx"> 
</span><span class="cx">     MainFrame&amp; m_mainFrame;
</span><del>-    PageOverlay* m_servicesOverlay;
</del><ins>+    PageOverlay* m_servicesOverlay { nullptr };
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Highlight&gt; m_activeHighlight;
</span><span class="cx">     RefPtr&lt;Highlight&gt; m_nextActiveHighlight;
</span><span class="lines">@@ -148,8 +151,10 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: These should move onto Highlight.
</span><span class="cx">     Vector&lt;LayoutRect&gt; m_currentSelectionRects;
</span><del>-    bool m_isTextOnly;
</del><ins>+    bool m_isTextOnly { false };
</ins><span class="cx"> 
</span><ins>+    Highlight::Type m_dirtyHighlightTypes { 0 };
+
</ins><span class="cx">     std::chrono::steady_clock::time_point m_lastSelectionChangeTime;
</span><span class="cx">     std::chrono::steady_clock::time_point m_nextActiveHighlightChangeTime;
</span><span class="cx">     std::chrono::steady_clock::time_point m_lastMouseUpTime;
</span><span class="lines">@@ -158,6 +163,7 @@
</span><span class="cx">     IntPoint m_mousePosition;
</span><span class="cx"> 
</span><span class="cx">     Timer m_determineActiveHighlightTimer;
</span><ins>+    Timer m_buildHighlightsTimer;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacServicesOverlayControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/ServicesOverlayController.mm (185777 => 185778)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/ServicesOverlayController.mm        2015-06-19 23:35:53 UTC (rev 185777)
+++ trunk/Source/WebCore/page/mac/ServicesOverlayController.mm        2015-06-19 23:40:32 UTC (rev 185778)
</span><span class="lines">@@ -57,12 +57,12 @@
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;ServicesOverlayController::Highlight&gt; ServicesOverlayController::Highlight::createForSelection(ServicesOverlayController&amp; controller, RetainPtr&lt;DDHighlightRef&gt; ddHighlight, PassRefPtr&lt;Range&gt; range)
</span><span class="cx"> {
</span><del>-    return adoptRef(*new Highlight(controller, Type::Selection, ddHighlight, range));
</del><ins>+    return adoptRef(*new Highlight(controller, Highlight::SelectionType, ddHighlight, range));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;ServicesOverlayController::Highlight&gt; ServicesOverlayController::Highlight::createForTelephoneNumber(ServicesOverlayController&amp; controller, RetainPtr&lt;DDHighlightRef&gt; ddHighlight, PassRefPtr&lt;Range&gt; range)
</span><span class="cx"> {
</span><del>-    return adoptRef(*new Highlight(controller, Type::TelephoneNumber, ddHighlight, range));
</del><ins>+    return adoptRef(*new Highlight(controller, Highlight::TelephoneNumberType, ddHighlight, range));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ServicesOverlayController::Highlight::Highlight(ServicesOverlayController&amp; controller, Type type, RetainPtr&lt;DDHighlightRef&gt; ddHighlight, PassRefPtr&lt;WebCore::Range&gt; range)
</span><span class="lines">@@ -204,9 +204,8 @@
</span><span class="cx"> 
</span><span class="cx"> ServicesOverlayController::ServicesOverlayController(MainFrame&amp; mainFrame)
</span><span class="cx">     : m_mainFrame(mainFrame)
</span><del>-    , m_servicesOverlay(nullptr)
-    , m_isTextOnly(false)
</del><span class="cx">     , m_determineActiveHighlightTimer(*this, &amp;ServicesOverlayController::determineActiveHighlightTimerFired)
</span><ins>+    , m_buildHighlightsTimer(*this, &amp;ServicesOverlayController::buildPotentialHighlightsIfNeeded)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -379,8 +378,7 @@
</span><span class="cx">     m_currentSelectionRects.reverse();
</span><span class="cx"> 
</span><span class="cx">     LOG(Services, &quot;ServicesOverlayController - Selection rects changed - Now have %lu\n&quot;, rects.size());
</span><del>-
-    buildSelectionHighlight();
</del><ins>+    invalidateHighlightsOfType(Highlight::SelectionType);
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(rects);
</span><span class="cx">     UNUSED_PARAM(gapRects);
</span><span class="lines">@@ -392,10 +390,47 @@
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt; 1090
</span><span class="cx">     LOG(Services, &quot;ServicesOverlayController - Telephone number ranges changed\n&quot;);
</span><del>-    buildPhoneNumberHighlights();
</del><ins>+    invalidateHighlightsOfType(Highlight::TelephoneNumberType);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ServicesOverlayController::invalidateHighlightsOfType(Highlight::Type type)
+{
+    if (!m_mainFrame.settings().serviceControlsEnabled())
+        return;
+
+    m_dirtyHighlightTypes |= type;
+    m_buildHighlightsTimer.startOneShot(0);
+}
+
+void ServicesOverlayController::buildPotentialHighlightsIfNeeded()
+{
+    if (!m_dirtyHighlightTypes)
+        return;
+
+    if (m_dirtyHighlightTypes &amp; Highlight::TelephoneNumberType)
+        buildPhoneNumberHighlights();
+
+    if (m_dirtyHighlightTypes &amp; Highlight::SelectionType)
+        buildSelectionHighlight();
+
+    m_dirtyHighlightTypes = 0;
+
+    if (m_potentialHighlights.isEmpty()) {
+        if (m_servicesOverlay)
+            m_mainFrame.pageOverlayController().uninstallPageOverlay(m_servicesOverlay, PageOverlay::FadeMode::DoNotFade);
+        return;
+    }
+
+    if (telephoneNumberRangesForFocusedFrame().isEmpty() &amp;&amp; !hasRelevantSelectionServices())
+        return;
+
+    createOverlayIfNeeded();
+
+    bool mouseIsOverButton;
+    determineActiveHighlight(mouseIsOverButton);
+}
+
</ins><span class="cx"> bool ServicesOverlayController::mouseIsOverHighlight(Highlight&amp; highlight, bool&amp; mouseIsOverButton) const
</span><span class="cx"> {
</span><span class="cx">     Boolean onButton;
</span><span class="lines">@@ -419,7 +454,7 @@
</span><span class="cx">     // Highlight hysteresis is only for selection services, because telephone number highlights are already much more stable
</span><span class="cx">     // by virtue of being expanded to include the entire telephone number. However, we will still avoid highlighting
</span><span class="cx">     // telephone numbers while the mouse is down.
</span><del>-    if (highlight-&gt;type() == Highlight::Type::TelephoneNumber)
</del><ins>+    if (highlight-&gt;type() == Highlight::TelephoneNumberType)
</ins><span class="cx">         return mousePressed ? minimumTimeUntilHighlightShouldBeShown : 0_ms;
</span><span class="cx"> 
</span><span class="cx">     auto now = std::chrono::steady_clock::now();
</span><span class="lines">@@ -465,16 +500,12 @@
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::buildPhoneNumberHighlights()
</span><span class="cx"> {
</span><del>-    if (!m_mainFrame.settings().serviceControlsEnabled())
-        return;
-
</del><span class="cx">     Vector&lt;RefPtr&lt;Range&gt;&gt; phoneNumberRanges;
</span><span class="cx">     for (Frame* frame = &amp;m_mainFrame; frame; frame = frame-&gt;tree().traverseNext())
</span><span class="cx">         phoneNumberRanges.appendVector(frame-&gt;editor().detectedTelephoneNumberRanges());
</span><span class="cx"> 
</span><span class="cx">     if (phoneNumberRanges.isEmpty()) {
</span><del>-        removeAllPotentialHighlightsOfType(Highlight::Type::TelephoneNumber);
-        didRebuildPotentialHighlights();
</del><ins>+        removeAllPotentialHighlightsOfType(Highlight::TelephoneNumberType);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -505,19 +536,13 @@
</span><span class="cx">         newPotentialHighlights.add(Highlight::createForTelephoneNumber(*this, ddHighlight, range));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    replaceHighlightsOfTypePreservingEquivalentHighlights(newPotentialHighlights, Highlight::Type::TelephoneNumber);
-
-    didRebuildPotentialHighlights();
</del><ins>+    replaceHighlightsOfTypePreservingEquivalentHighlights(newPotentialHighlights, Highlight::TelephoneNumberType);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::buildSelectionHighlight()
</span><span class="cx"> {
</span><del>-    if (!m_mainFrame.settings().serviceControlsEnabled())
-        return;
-
</del><span class="cx">     if (m_currentSelectionRects.isEmpty()) {
</span><del>-        removeAllPotentialHighlightsOfType(Highlight::Type::Selection);
-        didRebuildPotentialHighlights();
</del><ins>+        removeAllPotentialHighlightsOfType(Highlight::SelectionType);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -555,9 +580,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    replaceHighlightsOfTypePreservingEquivalentHighlights(newPotentialHighlights, Highlight::Type::Selection);
-
-    didRebuildPotentialHighlights();
</del><ins>+    replaceHighlightsOfTypePreservingEquivalentHighlights(newPotentialHighlights, Highlight::SelectionType);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::replaceHighlightsOfTypePreservingEquivalentHighlights(HashSet&lt;RefPtr&lt;Highlight&gt;&gt;&amp; newPotentialHighlights, Highlight::Type type)
</span><span class="lines">@@ -595,23 +618,6 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ServicesOverlayController::didRebuildPotentialHighlights()
-{
-    if (m_potentialHighlights.isEmpty()) {
-        if (m_servicesOverlay)
-            m_mainFrame.pageOverlayController().uninstallPageOverlay(m_servicesOverlay, PageOverlay::FadeMode::DoNotFade);
-        return;
-    }
-
-    if (telephoneNumberRangesForFocusedFrame().isEmpty() &amp;&amp; !hasRelevantSelectionServices())
-        return;
-
-    createOverlayIfNeeded();
-
-    bool mouseIsOverButton;
-    determineActiveHighlight(mouseIsOverButton);
-}
-
</del><span class="cx"> void ServicesOverlayController::createOverlayIfNeeded()
</span><span class="cx"> {
</span><span class="cx">     if (m_servicesOverlay)
</span><span class="lines">@@ -650,7 +656,7 @@
</span><span class="cx"> 
</span><span class="cx"> ServicesOverlayController::Highlight* ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight(Highlight&amp; selectionHighlight)
</span><span class="cx"> {
</span><del>-    if (selectionHighlight.type() != Highlight::Type::Selection)
</del><ins>+    if (selectionHighlight.type() != Highlight::SelectionType)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     Page* page = m_mainFrame.page();
</span><span class="lines">@@ -666,7 +672,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; highlight : m_potentialHighlights) {
</span><del>-        if (highlight-&gt;type() != Highlight::Type::TelephoneNumber)
</del><ins>+        if (highlight-&gt;type() != Highlight::TelephoneNumberType)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         if (highlight-&gt;range()-&gt;contains(*activeSelectionRange))
</span><span class="lines">@@ -678,15 +684,17 @@
</span><span class="cx"> 
</span><span class="cx"> void ServicesOverlayController::determineActiveHighlight(bool&amp; mouseIsOverActiveHighlightButton)
</span><span class="cx"> {
</span><ins>+    buildPotentialHighlightsIfNeeded();
+
</ins><span class="cx">     mouseIsOverActiveHighlightButton = false;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Highlight&gt; newActiveHighlight;
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; highlight : m_potentialHighlights) {
</span><del>-        if (highlight-&gt;type() == Highlight::Type::Selection) {
</del><ins>+        if (highlight-&gt;type() == Highlight::SelectionType) {
</ins><span class="cx">             // If we've already found a new active highlight, and it's
</span><span class="cx">             // a telephone number highlight, prefer that over this selection highlight.
</span><del>-            if (newActiveHighlight &amp;&amp; newActiveHighlight-&gt;type() == Highlight::Type::TelephoneNumber)
</del><ins>+            if (newActiveHighlight &amp;&amp; newActiveHighlight-&gt;type() == Highlight::TelephoneNumberType)
</ins><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             // If this highlight has no compatible services, it can't be active.
</span><span class="lines">@@ -705,7 +713,7 @@
</span><span class="cx"> 
</span><span class="cx">     // If our new active highlight is a selection highlight that is completely contained
</span><span class="cx">     // by one of the phone number highlights, we'll make the phone number highlight active even if it's not hovered.
</span><del>-    if (newActiveHighlight &amp;&amp; newActiveHighlight-&gt;type() == Highlight::Type::Selection) {
</del><ins>+    if (newActiveHighlight &amp;&amp; newActiveHighlight-&gt;type() == Highlight::SelectionType) {
</ins><span class="cx">         if (Highlight* containedTelephoneNumberHighlight = findTelephoneNumberHighlightContainingSelectionHighlight(*newActiveHighlight)) {
</span><span class="cx">             newActiveHighlight = containedTelephoneNumberHighlight;
</span><span class="cx"> 
</span><span class="lines">@@ -801,8 +809,9 @@
</span><span class="cx">     if (frame.isMainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    buildPhoneNumberHighlights();
-    buildSelectionHighlight();
</del><ins>+    invalidateHighlightsOfType(Highlight::TelephoneNumberType);
+    invalidateHighlightsOfType(Highlight::SelectionType);
+    buildPotentialHighlightsIfNeeded();
</ins><span class="cx"> 
</span><span class="cx">     bool mouseIsOverActiveHighlightButton;
</span><span class="cx">     determineActiveHighlight(mouseIsOverActiveHighlightButton);
</span><span class="lines">@@ -820,7 +829,7 @@
</span><span class="cx"> 
</span><span class="cx">     IntPoint windowPoint = frameView-&gt;contentsToWindow(clickPoint);
</span><span class="cx"> 
</span><del>-    if (highlight.type() == Highlight::Type::Selection) {
</del><ins>+    if (highlight.type() == Highlight::SelectionType) {
</ins><span class="cx">         auto telephoneNumberRanges = telephoneNumberRangesForFocusedFrame();
</span><span class="cx">         Vector&lt;String&gt; selectedTelephoneNumbers;
</span><span class="cx">         selectedTelephoneNumbers.reserveCapacity(telephoneNumberRanges.size());
</span><span class="lines">@@ -828,7 +837,7 @@
</span><span class="cx">             selectedTelephoneNumbers.append(range-&gt;text());
</span><span class="cx"> 
</span><span class="cx">         page-&gt;chrome().client().handleSelectionServiceClick(page-&gt;focusController().focusedOrMainFrame().selection(), selectedTelephoneNumbers, windowPoint);
</span><del>-    } else if (highlight.type() == Highlight::Type::TelephoneNumber)
</del><ins>+    } else if (highlight.type() == Highlight::TelephoneNumberType)
</ins><span class="cx">         page-&gt;chrome().client().handleTelephoneNumberClick(highlight.range()-&gt;text(), windowPoint);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>