+2014-08-13 Tim Horton <timothy_horton@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 <timothy@apple.com>
Web Inspector: Workaround a NSWindow change to the title bar.
#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>
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();
-
- std::chrono::steady_clock::duration minimumTimeUntilHighlightShouldBeShown = 200_ms;
+ return mousePressed ? minimumTimeUntilHighlightShouldBeShown : 0_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>&)
RefPtr<Highlight> mouseDownHighlight = m_currentMouseDownOnButtonHighlight;
m_currentMouseDownOnButtonHighlight = nullptr;
+ m_lastMouseUpTime = std::chrono::steady_clock::now();
+
if (mouseIsOverActiveHighlightButton && mouseDownHighlight) {
handleClick(m_mousePosition, *mouseDownHighlight);
return true;