haikuwebkit/LayoutTests/fast/events/autoscroll-when-zoomed.html

102 lines
3.1 KiB
HTML
Raw Permalink Normal View History

REGRESSION (r209299): Selection is broken when you zoom in webpage using trackpad https://bugs.webkit.org/show_bug.cgi?id=166472 rdar://problem/29675551 Reviewed by Tim Horton. Source/WebCore: r209299 broke autoscroll in zoomed pages because it changed RenderLayer::scrollRectToVisible() to shrink viewRect by page scale. This is incorrect for all callers of scrollRectToVisible, since the "absoluteRect" passed in is actually in zoomed document coordinates for all the callers I tested. This code is also fixed to account for headers and footers. getRectToExpose() takes rectangles in "scroll view contents" coordinates (i.e. including header, and zoomed document), so doesn't need the separate visibleRectRelativeToDocument parameter. Tests: fast/events/autoscroll-main-document.html fast/events/autoscroll-when-zoomed.html fast/events/drag-select-when-zoomed-with-header.html fast/events/drag-select-when-zoomed.html fast/scrolling/scroll-to-anchor-zoomed-header.html * rendering/RenderLayer.cpp: (WebCore::RenderLayer::scrollRectToVisible): (WebCore::RenderLayer::getRectToExpose): * rendering/RenderLayer.h: Tools: These changes are necessary to allow the mouse to leave the WTR window while drag-scrolling, to test autoscroll. Previously, we were never calling -mouseDragged (which DRT does); we'd always go through mouseMoved, which hits an early return in WebViewImpl::mouseMoved() when the point is outside the view. * WebKitTestRunner/mac/EventSenderProxy.mm: (WTR::EventSenderProxy::mouseMoveTo): LayoutTests: Add some test coverage for autoscroll of the main document. I could only get this working in WebKitTestRunner, not DumpRenderTree. * TestExpectations: * fast/events/autoscroll-main-document-expected.txt: Added. * fast/events/autoscroll-main-document.html: Added. * fast/events/autoscroll-when-zoomed-expected.txt: Added. * fast/events/autoscroll-when-zoomed.html: Added. * fast/events/drag-select-when-zoomed-expected.txt: Added. * fast/events/drag-select-when-zoomed-with-header-expected.txt: Added. * fast/events/drag-select-when-zoomed-with-header.html: Added. * fast/events/drag-select-when-zoomed.html: Added. * fast/scrolling/scroll-to-anchor-zoomed-header-expected.txt: Added. * fast/scrolling/scroll-to-anchor-zoomed-header.html: Added. * fast/transforms/selection-bounds-in-transformed-view.html: Revert the target scroll position to what it was before r209299, and improve the failure output. * platform/ios-simulator/TestExpectations: * platform/mac-wk2/TestExpectations: Canonical link: https://commits.webkit.org/183751@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-25 23:57:40 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 1000px;
}
#container {
position: relative;
top: -10px;
left: 50px;
width: 400px;
outline: 1px solid black;
font-family: monospace;
}
</style>
<script src="../../resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;
const pageScale = 1.5;
const eventCount = 50;
var scrollCount = 0;
var start;
var end;
var firstRange;
function testComplete()
{
eventSender.mouseMoveTo(pageScale * end.x, 0);
eventSender.mouseUp();
firstRange = window.getSelection().getRangeAt(0);
shouldBe('firstRange.startOffset', '51');
shouldBe('firstRange.endOffset', '400');
finishJSTest();
}
function waitForScrolledToTop()
{
if (window.scrollY == 0) {
testComplete();
return;
}
window.setTimeout(waitForScrolledToTop, 2);
}
function doOneScroll()
{
if (++scrollCount == eventCount) {
waitForScrolledToTop();
return;
}
eventSender.mouseMoveTo(pageScale * end.x, pageScale * (end.y - scrollCount));
window.setTimeout(doOneScroll, 2);
}
function doTest()
{
if (!window.testRunner || !window.eventSender) {
debug('This test requires testRunner and eventSender');
return;
}
window.internals.setPageScaleFactor(pageScale, 0, 0);
var containerRect = document.getElementById('container').getBoundingClientRect();
var lineHeight = containerRect.height / 3;
window.scrollTo(0, containerRect.bottom - lineHeight);
containerRect = document.getElementById('container').getBoundingClientRect(); // Scrolling changed it.
Incorrect position when dragging jQuery Draggable elements with position fixed after pinch zoom https://bugs.webkit.org/show_bug.cgi?id=171113 Source/WebCore: rdar://problem/31746516 Reviewed by Tim Horton. Make getBoundingClientRect() and getClientRects() return rects which are relative to the layout viewport, rather than the visual viewport. This goes part of the way to fixing webkit.org/b/170981, which aims to make pinch-zoom invisible to web pages ("inert visual viewport"). It fixes issues on various sites like Facebook when zoomed. Factor coordinate conversion code into functions on FrameView, which now documents the various coordinate systems in a big comment. Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale() and Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale() are renamed and factored to use these helpers. There are two behavior changes here: 1. FrameView::documentToClientOffset() now uses the origin of the layout viewport in the "document to client" coordinate mapping. 2. The two document functions would apply the scale and offset in the wrong order. We need to first undo the effects of CSS zoom, page zoom and page scale, and then map from document to client coordinates. Tests: fast/visual-viewport/client-rects-relative-to-layout-viewport.html fast/zooming/client-rects-with-css-and-page-zoom.html * dom/Document.cpp: (WebCore::Document::convertAbsoluteToClientQuads): (WebCore::Document::convertAbsoluteToClientRect): (WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale): Deleted. (WebCore::Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale): Deleted. * dom/Document.h: * dom/Element.cpp: (WebCore::Element::getClientRects): (WebCore::Element::getBoundingClientRect): * dom/Range.cpp: (WebCore::Range::borderAndTextQuads): * page/FrameView.cpp: (WebCore::FrameView::absoluteToDocumentScaleFactor): (WebCore::FrameView::absoluteToDocumentRect): (WebCore::FrameView::absoluteToDocumentPoint): (WebCore::FrameView::documentToClientOffset): (WebCore::FrameView::documentToClientRect): (WebCore::FrameView::documentToClientPoint): * page/FrameView.h: * platform/ScrollableArea.h: #pragma once * platform/Scrollbar.h: #pragma once * platform/Widget.h: #pragma once LayoutTests: Reviewed by Tim Horton. Rebaseline tests which dumped the getBoundingClientRect for fixed elements; now that these are layout viewport-relative, getBoundingClientRect() for a fixed element is unchanging. New test that exercises getBoundingClientRect() and getClientRects() for fixed and absolute elements after zooming. * fast/events/autoscroll-when-zoomed.html: Adjust to account for behavior change. * fast/visual-viewport/client-rects-relative-to-layout-viewport-expected.txt: Added. * fast/visual-viewport/client-rects-relative-to-layout-viewport.html: Added. * fast/visual-viewport/zoomed-fixed-expected.txt: * fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: * fast/zooming/client-rect-in-fixed-zoomed-expected.txt: * fast/zooming/client-rect-in-fixed-zoomed.html: * fast/zooming/client-rects-with-css-and-page-zoom-expected.txt: Added. * fast/zooming/client-rects-with-css-and-page-zoom.html: Added. * platform/ios-wk2/fast/visual-viewport/client-rects-relative-to-layout-viewport-expected.txt: Added. * platform/ios/TestExpectations: Mark imported/w3c/web-platform-tests/cssom-view/elementFromPoint.html as failing; it will be fixed via webkit.org/b/172019 * platform/ios/fast/visual-viewport/zoomed-fixed-expected.txt: * platform/ios/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Canonical link: https://commits.webkit.org/188997@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216803 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-12 23:48:12 +00:00
start = { x: containerRect.left + 10, y: 2 * lineHeight / 3 };
REGRESSION (r209299): Selection is broken when you zoom in webpage using trackpad https://bugs.webkit.org/show_bug.cgi?id=166472 rdar://problem/29675551 Reviewed by Tim Horton. Source/WebCore: r209299 broke autoscroll in zoomed pages because it changed RenderLayer::scrollRectToVisible() to shrink viewRect by page scale. This is incorrect for all callers of scrollRectToVisible, since the "absoluteRect" passed in is actually in zoomed document coordinates for all the callers I tested. This code is also fixed to account for headers and footers. getRectToExpose() takes rectangles in "scroll view contents" coordinates (i.e. including header, and zoomed document), so doesn't need the separate visibleRectRelativeToDocument parameter. Tests: fast/events/autoscroll-main-document.html fast/events/autoscroll-when-zoomed.html fast/events/drag-select-when-zoomed-with-header.html fast/events/drag-select-when-zoomed.html fast/scrolling/scroll-to-anchor-zoomed-header.html * rendering/RenderLayer.cpp: (WebCore::RenderLayer::scrollRectToVisible): (WebCore::RenderLayer::getRectToExpose): * rendering/RenderLayer.h: Tools: These changes are necessary to allow the mouse to leave the WTR window while drag-scrolling, to test autoscroll. Previously, we were never calling -mouseDragged (which DRT does); we'd always go through mouseMoved, which hits an early return in WebViewImpl::mouseMoved() when the point is outside the view. * WebKitTestRunner/mac/EventSenderProxy.mm: (WTR::EventSenderProxy::mouseMoveTo): LayoutTests: Add some test coverage for autoscroll of the main document. I could only get this working in WebKitTestRunner, not DumpRenderTree. * TestExpectations: * fast/events/autoscroll-main-document-expected.txt: Added. * fast/events/autoscroll-main-document.html: Added. * fast/events/autoscroll-when-zoomed-expected.txt: Added. * fast/events/autoscroll-when-zoomed.html: Added. * fast/events/drag-select-when-zoomed-expected.txt: Added. * fast/events/drag-select-when-zoomed-with-header-expected.txt: Added. * fast/events/drag-select-when-zoomed-with-header.html: Added. * fast/events/drag-select-when-zoomed.html: Added. * fast/scrolling/scroll-to-anchor-zoomed-header-expected.txt: Added. * fast/scrolling/scroll-to-anchor-zoomed-header.html: Added. * fast/transforms/selection-bounds-in-transformed-view.html: Revert the target scroll position to what it was before r209299, and improve the failure output. * platform/ios-simulator/TestExpectations: * platform/mac-wk2/TestExpectations: Canonical link: https://commits.webkit.org/183751@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-25 23:57:40 +00:00
end = { x: containerRect.right - 10, y: 16 };
eventSender.mouseMoveTo(pageScale * start.x, pageScale * start.y);
eventSender.mouseDown();
doOneScroll();
}
window.addEventListener('load', doTest, false);
</script>
</head>
<body>
<div id="container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<p>This test ensures that drag-selecting works correctly in the main frame.</p>
<div id="console"></div>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>