Content inside frames and scrollbars in overflow areas hit-tests incorrectly when
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 23:23:20 +0000 (23:23 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Apr 2013 23:23:20 +0000 (23:23 +0000)
the WKView has a header
https://bugs.webkit.org/show_bug.cgi?id=114769

Reviewed by Simon Fraser.

Source/WebCore:

convertToRenderer() and convertFromRenderer() need to factor in the headerHeight,
much like all of the conversion functions on ScrollView.
* page/FrameView.cpp:
(WebCore::FrameView::convertFromRenderer):
(WebCore::FrameView::convertToRenderer):

The scrollPosition equivalent of the existing scrollOffsetRelativeToDocument()
function.
* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollPositionRelativeToDocument):
* platform/ScrollView.h:
(ScrollView):

LayoutTests:

* platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame.html: Added.
* platform/mac-wk2/tiled-drawing/resources/iframe-to-hit-test.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/tiled-drawing/resources/iframe-to-hit-test.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h

index 2466aa6..0d0564f 100644 (file)
@@ -1,3 +1,15 @@
+2013-04-17  Beth Dakin  <bdakin@apple.com>
+
+        Content inside frames and scrollbars in overflow areas hit-tests incorrectly when 
+        the WKView has a header
+        https://bugs.webkit.org/show_bug.cgi?id=114769
+
+        Reviewed by Simon Fraser.
+
+        * platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame-expected.txt: Added.
+        * platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame.html: Added.
+        * platform/mac-wk2/tiled-drawing/resources/iframe-to-hit-test.html: Added.
+
 2013-04-17  Jessie Berlin  <jberlin@apple.com>
 
         Unskip some tests for wk2 where the underlying cause of them being skipped has since been
diff --git a/LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame-expected.txt b/LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame-expected.txt
new file mode 100644 (file)
index 0000000..ac137d2
--- /dev/null
@@ -0,0 +1,2 @@
+
+Pass!
diff --git a/LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame.html b/LayoutTests/platform/mac-wk2/tiled-drawing/header-and-footer-hit-testing-in-frame.html
new file mode 100644 (file)
index 0000000..c871d59
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script>
+    function runTest() {
+        if (!window.eventSender)
+            return;
+        if (window.internals)
+            window.internals.setHeaderHeight(document, 100);
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        eventSender.mouseMoveTo(20, 120);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+</script>
+</head>
+<body onload="runTest()">
+    <iframe src="resources/iframe-to-hit-test.html" scrolling="no" frameborder="no" height="300" width="600"></iframe>
+    <div id="result">This test needs to be run through WebKitTestRunner.</div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac-wk2/tiled-drawing/resources/iframe-to-hit-test.html b/LayoutTests/platform/mac-wk2/tiled-drawing/resources/iframe-to-hit-test.html
new file mode 100644 (file)
index 0000000..a450daa
--- /dev/null
@@ -0,0 +1,20 @@
+<html>
+<head>
+<style>
+    #target {
+        background-color:purple;
+        width:25px;
+        height:25px;
+    }
+</style>
+<script>
+    function clicked() {
+        var result = parent.document.getElementById("result");
+        result.innerHTML = "Pass!";
+    }
+</script>
+</head>
+<body>
+    <div id="target" onclick="clicked()"></div>
+</body>
+</html>
index c24ffa7..6461a7d 100644 (file)
@@ -1,3 +1,24 @@
+2013-04-17  Beth Dakin  <bdakin@apple.com>
+
+        Content inside frames and scrollbars in overflow areas hit-tests incorrectly when 
+        the WKView has a header
+        https://bugs.webkit.org/show_bug.cgi?id=114769
+
+        Reviewed by Simon Fraser.
+
+        convertToRenderer() and convertFromRenderer() need to factor in the headerHeight, 
+        much like all of the conversion functions on ScrollView. 
+        * page/FrameView.cpp:
+        (WebCore::FrameView::convertFromRenderer):
+        (WebCore::FrameView::convertToRenderer):
+
+        The scrollPosition equivalent of the existing scrollOffsetRelativeToDocument() 
+        function. 
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::scrollPositionRelativeToDocument):
+        * platform/ScrollView.h:
+        (ScrollView):
+
 2013-04-17  Andreas Kling  <akling@apple.com>
 
         Remove FragmentScriptingPermission.h include from Element.h.
index 9c078c6..727c906 100644 (file)
@@ -3803,7 +3803,7 @@ IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRe
 
     // Convert from page ("absolute") to FrameView coordinates.
     if (!delegatesScrolling())
-        rect.moveBy(-scrollPosition());
+        rect.moveBy(-scrollPosition() + IntPoint(0, headerHeight()));
 
     return rect;
 }
@@ -3814,7 +3814,7 @@ IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect
     
     // Convert from FrameView coords into page ("absolute") coordinates.
     if (!delegatesScrolling())
-        rect.moveBy(scrollPosition());
+        rect.moveBy(scrollPositionRelativeToDocument());
 
     // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
     // move the rect for now.
@@ -3828,7 +3828,7 @@ IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntP
 
     // Convert from page ("absolute") to FrameView coordinates.
     if (!delegatesScrolling())
-        point.moveBy(-scrollPosition());
+        point.moveBy(-scrollPosition() + IntPoint(0, headerHeight()));
     return point;
 }
 
@@ -3838,7 +3838,7 @@ IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoi
 
     // Convert from FrameView coords into page ("absolute") coordinates.
     if (!delegatesScrolling())
-        point += IntSize(scrollX(), scrollY());
+        point = point + scrollPositionRelativeToDocument();
 
     return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms));
 }
index fd8c782..dbc3ce9 100644 (file)
@@ -341,6 +341,12 @@ IntSize ScrollView::scrollOffsetRelativeToDocument() const
     return IntSize(scrollOffset.width(), scrollOffset.height() - headerHeight());
 }
 
+IntPoint ScrollView::scrollPositionRelativeToDocument() const
+{
+    IntPoint scrollPosition = this->scrollPosition();
+    return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight());
+}
+
 int ScrollView::scrollSize(ScrollbarOrientation orientation) const
 {
     // If no scrollbars are present, it does not indicate content is not be scrollable.
index a2d8c55..b65ea6d 100644 (file)
@@ -190,6 +190,7 @@ public:
     // anchors (0,0) at the top of the Document, which will be beneath any headers, so it is relative
     // to contentsSize().
     IntSize scrollOffsetRelativeToDocument() const;
+    IntPoint scrollPositionRelativeToDocument() const;
 
     virtual IntSize overhangAmount() const OVERRIDE;