Title: [172528] trunk/Source/WebKit2
Revision
172528
Author
timothy_hor...@apple.com
Date
2014-08-13 12:03:56 -0700 (Wed, 13 Aug 2014)

Log Message

Avoid making new active service overlay highlights while the mouse is down
https://bugs.webkit.org/show_bug.cgi?id=135872
<rdar://problem/17982341>

Reviewed by Enrica Casucci.

* WebProcess/WebPage/ServicesOverlayController.h:
* WebProcess/WebPage/mac/ServicesOverlayController.mm:
(WebKit::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
(WebKit::ServicesOverlayController::mouseEvent):
If the mouse is pressed or it's been less than 200ms since the mouse went up,
don't allow the highlight to change. We apply the mouse-is-pressed rule to telephone
number highlights as well, unlike the rest of the hysteresis logic.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (172527 => 172528)


--- trunk/Source/WebKit2/ChangeLog	2014-08-13 19:00:53 UTC (rev 172527)
+++ trunk/Source/WebKit2/ChangeLog	2014-08-13 19:03:56 UTC (rev 172528)
@@ -1,3 +1,19 @@
+2014-08-13  Tim Horton  <timothy_hor...@apple.com>
+
+        Avoid making new active service overlay highlights while the mouse is down
+        https://bugs.webkit.org/show_bug.cgi?id=135872
+        <rdar://problem/17982341>
+
+        Reviewed by Enrica Casucci.
+
+        * WebProcess/WebPage/ServicesOverlayController.h:
+        * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+        (WebKit::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
+        (WebKit::ServicesOverlayController::mouseEvent):
+        If the mouse is pressed or it's been less than 200ms since the mouse went up,
+        don't allow the highlight to change. We apply the mouse-is-pressed rule to telephone
+        number highlights as well, unlike the rest of the hysteresis logic.
+
 2014-08-13  Timothy Hatcher  <timo...@apple.com>
 
         Web Inspector: Workaround a NSWindow change to the title bar.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h (172527 => 172528)


--- trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h	2014-08-13 19:00:53 UTC (rev 172527)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h	2014-08-13 19:03:56 UTC (rev 172528)
@@ -151,6 +151,7 @@
 
     std::chrono::steady_clock::time_point m_lastSelectionChangeTime;
     std::chrono::steady_clock::time_point m_nextActiveHighlightChangeTime;
+    std::chrono::steady_clock::time_point m_lastMouseUpTime;
 
     RefPtr<Highlight> m_currentMouseDownOnButtonHighlight;
     WebCore::IntPoint m_mousePosition;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm (172527 => 172528)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm	2014-08-13 19:00:53 UTC (rev 172527)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm	2014-08-13 19:03:56 UTC (rev 172528)
@@ -33,6 +33,7 @@
 #import "WebProcess.h"
 #import <QuartzCore/QuartzCore.h>
 #import <WebCore/Document.h>
+#import <WebCore/EventHandler.h>
 #import <WebCore/FloatQuad.h>
 #import <WebCore/FocusController.h>
 #import <WebCore/FrameView.h>
@@ -400,18 +401,25 @@
     if (!highlight)
         return std::chrono::milliseconds::zero();
 
+    auto minimumTimeUntilHighlightShouldBeShown = 200_ms;
+
+    bool mousePressed = false;
+    if (Frame* mainFrame = m_webPage.mainFrame())
+        mousePressed = mainFrame->eventHandler().mousePressed();
+
     // Highlight hysteresis is only for selection services, because telephone number highlights are already much more stable
-    // by virtue of being expanded to include the entire telephone number.
+    // by virtue of being expanded to include the entire telephone number. However, we will still avoid highlighting
+    // telephone numbers while the mouse is down.
     if (highlight->type() == Highlight::Type::TelephoneNumber)
-        return std::chrono::milliseconds::zero();
+        return mousePressed ? minimumTimeUntilHighlightShouldBeShown : 0_ms;
 
-    std::chrono::steady_clock::duration minimumTimeUntilHighlightShouldBeShown = 200_ms;
-
     auto now = std::chrono::steady_clock::now();
     auto timeSinceLastSelectionChange = now - m_lastSelectionChangeTime;
     auto timeSinceHighlightBecameActive = now - m_nextActiveHighlightChangeTime;
+    auto timeSinceLastMouseUp = mousePressed ? 0_ms : now - m_lastMouseUpTime;
 
-    return std::chrono::duration_cast<std::chrono::milliseconds>(std::max(minimumTimeUntilHighlightShouldBeShown - timeSinceLastSelectionChange, minimumTimeUntilHighlightShouldBeShown - timeSinceHighlightBecameActive));
+    auto remainingDelay = minimumTimeUntilHighlightShouldBeShown - std::min(std::min(timeSinceLastSelectionChange, timeSinceHighlightBecameActive), timeSinceLastMouseUp);
+    return std::chrono::duration_cast<std::chrono::milliseconds>(remainingDelay);
 }
 
 void ServicesOverlayController::determineActiveHighlightTimerFired(Timer<ServicesOverlayController>&)
@@ -688,6 +696,8 @@
         RefPtr<Highlight> mouseDownHighlight = m_currentMouseDownOnButtonHighlight;
         m_currentMouseDownOnButtonHighlight = nullptr;
 
+        m_lastMouseUpTime = std::chrono::steady_clock::now();
+
         if (mouseIsOverActiveHighlightButton && mouseDownHighlight) {
             handleClick(m_mousePosition, *mouseDownHighlight);
             return true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to