Services overlay dropdown is often in the wrong place with zoomed pages or horizontal...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2014 16:19:37 +0000 (16:19 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2014 16:19:37 +0000 (16:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135755
<rdar://problem/17907752>

Reviewed by Brady Eidson.

* WebProcess/WebPage/mac/ServicesOverlayController.mm:
(WebKit::ServicesOverlayController::establishHoveredTelephoneHighlight):
(WebKit::ServicesOverlayController::maybeCreateSelectionHighlight):
DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection adjusts the
location of the button based on the visible rect, trying to keep the button visible.

We're handing it the wrong visible rect, though, not taking scrolling into account.

This leads to pages that scroll horizontally showing the button on the left
even if there's space for it on the right, or sometimes not showing it at all.

Instead, provide the actual main FrameView visible rect; the same coordinate
space that the highlight rects are provided in.

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm

index 92f00cb5c38b79bb4cd5d64f729d7d12f1808884..465bbd573ba8496002beaccf48b601b20eae72c7 100644 (file)
@@ -1,3 +1,25 @@
+2014-08-08  Timothy Horton  <timothy_horton@apple.com>
+
+        Services overlay dropdown is often in the wrong place with zoomed pages or horizontal scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=135755
+        <rdar://problem/17907752>
+
+        Reviewed by Brady Eidson.
+
+        * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+        (WebKit::ServicesOverlayController::establishHoveredTelephoneHighlight):
+        (WebKit::ServicesOverlayController::maybeCreateSelectionHighlight):
+        DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection adjusts the
+        location of the button based on the visible rect, trying to keep the button visible.
+
+        We're handing it the wrong visible rect, though, not taking scrolling into account.
+
+        This leads to pages that scroll horizontally showing the button on the left
+        even if there's space for it on the right, or sometimes not showing it at all.
+
+        Instead, provide the actual main FrameView visible rect; the same coordinate
+        space that the highlight rects are provided in.
+
 2014-08-08  Timothy Horton  <timothy_horton@apple.com>
 
         Additional items added to selection services menus are misaligned
 2014-08-08  Timothy Horton  <timothy_horton@apple.com>
 
         Additional items added to selection services menus are misaligned
index 79b2372e44d0f5bdc13291cde908502081ce5f00..1abcc383f7335b04fe77320f107acdefbe8fcdac 100644 (file)
@@ -431,7 +431,7 @@ void ServicesOverlayController::establishHoveredTelephoneHighlight(bool& mouseIs
             rect.setLocation(mainFrameView.windowToContents(viewForRange->contentsToWindow(rect.location())));
 
             CGRect cgRect = rect;
             rect.setLocation(mainFrameView.windowToContents(viewForRange->contentsToWindow(rect.location())));
 
             CGRect cgRect = rect;
-            m_telephoneNumberHighlights[i] = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, viewForRange->boundsRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
+            m_telephoneNumberHighlights[i] = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, &cgRect, 1, mainFrameView.visibleContentRect(), DDHighlightOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
         }
 
         if (!mouseIsOverHighlight(m_telephoneNumberHighlights[i].get(), mouseIsOverButton))
         }
 
         if (!mouseIsOverHighlight(m_telephoneNumberHighlights[i].get(), mouseIsOverButton))
@@ -460,8 +460,8 @@ void ServicesOverlayController::maybeCreateSelectionHighlight()
         cgRects.append((CGRect)pixelSnappedIntRect(rect));
 
     if (!cgRects.isEmpty()) {
         cgRects.append((CGRect)pixelSnappedIntRect(rect));
 
     if (!cgRects.isEmpty()) {
-        CGRect bounds = m_webPage->corePage()->mainFrame().view()->boundsRect();
-        m_selectionHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.begin(), cgRects.size(), bounds, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
+        CGRect visibleRect = m_webPage->corePage()->mainFrame().view()->visibleContentRect();
+        m_selectionHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.begin(), cgRects.size(), visibleRect, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));
 
         m_servicesOverlay->setNeedsDisplay();
     }
 
         m_servicesOverlay->setNeedsDisplay();
     }