The bounds on InteractionInformationAtPosition should be more precise
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2015 21:40:01 +0000 (21:40 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jun 2015 21:40:01 +0000 (21:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146468
-and corresponding-
rdar://problem/20739834

Reviewed by Enrica Casucci and Simon Fraser.

Source/WebCore:

Export absoluteContentQuad().
* rendering/RenderBox.h:

Source/WebKit2:

For links, get the TextQuads from the Range, and for images, look at the
absoluteContentQuad(). All other items can continue to use absoluteBoundingBox.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index b8270b3..67d2752 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-30  Beth Dakin  <bdakin@apple.com>
+
+        The bounds on InteractionInformationAtPosition should be more precise
+        https://bugs.webkit.org/show_bug.cgi?id=146468
+        -and corresponding-
+        rdar://problem/20739834
+
+        Reviewed by Enrica Casucci and Simon Fraser.
+
+        Export absoluteContentQuad().
+        * rendering/RenderBox.h:
+
 2015-06-30  Zalan Bujtas  <zalan@apple.com>
 
         Addressing post-review comments in r185756.
index e8f3e18..5d47e47 100644 (file)
@@ -167,7 +167,7 @@ public:
     // The content box in absolute coords. Ignores transforms.
     IntRect absoluteContentBox() const;
     // The content box converted to absolute coords (taking transforms into account).
-    FloatQuad absoluteContentQuad() const;
+    WEBCORE_EXPORT FloatQuad absoluteContentQuad() const;
 
     // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect
     // does include the intrinsic padding in the content box as this is what some callers expect (like getComputedStyle).
index c25d652..52cfe6b 100644 (file)
@@ -1,3 +1,17 @@
+2015-06-30  Beth Dakin  <bdakin@apple.com>
+
+        The bounds on InteractionInformationAtPosition should be more precise
+        https://bugs.webkit.org/show_bug.cgi?id=146468
+        -and corresponding-
+        rdar://problem/20739834
+
+        Reviewed by Enrica Casucci and Simon Fraser.
+
+        For links, get the TextQuads from the Range, and for images, look at the 
+        absoluteContentQuad(). All other items can continue to use absoluteBoundingBox.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
 2015-06-30  Anders Carlsson  <andersca@apple.com>
 
         Disable Spintracer when getting the list of plug-ins
index 0e352c7..8343714 100644 (file)
@@ -2160,9 +2160,23 @@ void WebPage::getPositionInformation(const IntPoint& point, InteractionInformati
             info.title = element->fastGetAttribute(HTMLNames::titleAttr).string();
             if (linkElement && info.title.isEmpty())
                 info.title = element->innerText();
-            if (element->renderer()) {
-                info.bounds = element->renderer()->absoluteBoundingBoxRect(true);
+            if (element->renderer())
                 info.touchCalloutEnabled = element->renderer()->style().touchCalloutEnabled();
+
+            if (element == linkElement) {
+                RefPtr<Range> linkRange = rangeOfContents(*linkElement);
+                Vector<FloatQuad> quads;
+                linkRange->textQuads(quads);
+                FloatRect linkBoundingBox;
+                for (const auto& quad : quads)
+                    linkBoundingBox.unite(quad.enclosingBoundingBox());
+                info.bounds = IntRect(linkBoundingBox);
+            } else if (RenderElement* renderer = element->renderer()) {
+                if (renderer->isRenderImage()) {
+                    auto& renderImage = downcast<RenderImage>(*renderer);
+                    info.bounds = renderImage.absoluteContentQuad().enclosingBoundingBox();
+                } else
+                    info.bounds = renderer->absoluteBoundingBoxRect();
             }
         }
     }