Small region (~1px tall) where you get the selection button instead of the phone...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:48:36 +0000 (22:48 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:48:36 +0000 (22:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135852
<rdar://problem/17992795>

Reviewed by Enrica Casucci.

* WebProcess/WebPage/ServicesOverlayController.h:
* WebProcess/WebPage/mac/ServicesOverlayController.mm:
(WebKit::ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight):
(WebKit::ServicesOverlayController::determineActiveHighlight):
If our new active highlight is a selection highlight that is completely contained
by one of the phone number highlights, we'll make the phone number highlight active
even if it's not hovered. This fixes the case where the selection highlight
(a subset of a telephone number) is slightly taller than the telephone number
highlight, and can be hovered without hovering the phone number highlight

* WebCore.exp.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172501 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h
Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm

index 74d9ed3d657f77227ab04c7ce7872159af05a810..5eac550e894c22438732096a7c079c9d9760b3ab 100644 (file)
@@ -1,3 +1,13 @@
+2014-08-12  Tim Horton  <timothy_horton@apple.com>
+
+        Small region (~1px tall) where you get the selection button instead of the phone number overlay
+        https://bugs.webkit.org/show_bug.cgi?id=135852
+        <rdar://problem/17992795>
+
+        Reviewed by Enrica Casucci.
+
+        * WebCore.exp.in:
+
 2014-08-12  Alex Christensen  <achristensen@webkit.org>
 
         Generate header detection headers for CMake on Windows.
index 72d16ddded70df478f70091a195bd04814358c72..d98d8259fd7a47e48083d9d0f40fca8a1c897de7 100644 (file)
@@ -1896,6 +1896,7 @@ __ZNK7WebCore4Page27pageExtendedBackgroundColorEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore4Page9groupNameEv
 __ZNK7WebCore4Page9pageCountEv
+__ZNK7WebCore4Page9selectionEv
 __ZNK7WebCore4Page9sessionIDEv
 __ZNK7WebCore5Color10serializedEv
 __ZNK7WebCore5Color7getRGBAERdS1_S1_S1_
index 02d5cc4c3c280379de6a77bff582a275f2a550b9..be5586fdd64af22aaff34767264142578d621b93 100644 (file)
         * WebProcess/cocoa/WebProcessCocoa.mm:
         (WebKit::WebProcess::platformInitializeWebProcess):
 
+2014-08-12  Tim Horton  <timothy_horton@apple.com>
+
+        Small region (~1px tall) where you get the selection button instead of the phone number overlay
+        https://bugs.webkit.org/show_bug.cgi?id=135852
+        <rdar://problem/17992795>
+
+        Reviewed by Enrica Casucci.
+
+        * WebProcess/WebPage/ServicesOverlayController.h:
+        * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+        (WebKit::ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight):
+        (WebKit::ServicesOverlayController::determineActiveHighlight):
+        If our new active highlight is a selection highlight that is completely contained
+        by one of the phone number highlights, we'll make the phone number highlight active
+        even if it's not hovered. This fixes the case where the selection highlight
+        (a subset of a telephone number) is slightly taller than the telephone number
+        highlight, and can be hovered without hovering the phone number highlight.
+
 2014-08-12  Tim Horton  <timothy_horton@apple.com>
 
         REGRESSION (r172424): Extra menu header in combined telephone number menu when no phone paired
index 329d08f5935a1ec14a5578dc34bedbae17316f95..8643a3d40a237579b507378623a6323124fb5108 100644 (file)
@@ -117,6 +117,8 @@ private:
     void clearActiveHighlight();
     Highlight* activeHighlight() const { return m_activeHighlight.get(); }
 
+    Highlight* findTelephoneNumberHighlightContainingSelectionHighlight(Highlight&);
+
     bool hasRelevantSelectionServices();
 
     bool mouseIsOverHighlight(Highlight&, bool& mouseIsOverButton) const;
index 0523d18b902a6528b582e5972dd88351ee8f4244..b1028871eb879b2b880cbb00bb593ab01936488f 100644 (file)
@@ -576,6 +576,30 @@ bool ServicesOverlayController::highlightsAreEquivalent(const Highlight* a, cons
     return false;
 }
 
+ServicesOverlayController::Highlight* ServicesOverlayController::findTelephoneNumberHighlightContainingSelectionHighlight(Highlight& selectionHighlight)
+{
+    if (selectionHighlight.type() != Highlight::Type::Selection)
+        return nullptr;
+
+    const VisibleSelection& selection = m_webPage.corePage()->selection();
+    if (!selection.isRange())
+        return nullptr;
+
+    RefPtr<Range> activeSelectionRange = selection.toNormalizedRange();
+    if (!activeSelectionRange)
+        return nullptr;
+
+    for (auto& highlight : m_potentialHighlights) {
+        if (highlight->type() != Highlight::Type::TelephoneNumber)
+            continue;
+
+        if (highlight->range()->contains(*activeSelectionRange))
+            return highlight.get();
+    }
+
+    return nullptr;
+}
+
 void ServicesOverlayController::determineActiveHighlight(bool& mouseIsOverActiveHighlightButton)
 {
     mouseIsOverActiveHighlightButton = false;
@@ -603,6 +627,18 @@ void ServicesOverlayController::determineActiveHighlight(bool& mouseIsOverActive
         mouseIsOverActiveHighlightButton = mouseIsOverButton;
     }
 
+    // If our new active highlight is a selection highlight that is completely contained
+    // by one of the phone number highlights, we'll make the phone number highlight active even if it's not hovered.
+    if (newActiveHighlight && newActiveHighlight->type() == Highlight::Type::Selection) {
+        if (Highlight* containedTelephoneNumberHighlight = findTelephoneNumberHighlightContainingSelectionHighlight(*newActiveHighlight)) {
+            newActiveHighlight = containedTelephoneNumberHighlight;
+
+            // We will always initially choose the telephone number highlight over the selection highlight if the
+            // mouse is over the telephone number highlight's button, so we know that it's not hovered if we got here.
+            mouseIsOverActiveHighlightButton = false;
+        }
+    }
+
     if (!this->highlightsAreEquivalent(m_activeHighlight.get(), newActiveHighlight.get())) {
         // When transitioning to a new highlight, we might end up in determineActiveHighlight multiple times
         // before the new highlight actually becomes active. Keep track of the last next-but-not-yet-active