Commit cc802019 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Refactor visual viewport size methods

This CL does some cleanups around size-related methods in
VisualViewport. Changes here include:

 - Making VisibleRect methods allow including or excluding the scrollbar
   sizes. The default is now to exclude, matching the intuition of what
   the visible rect is as well as the convention set in ScrollableArea.
 - VisibleWidth, VisibleHeight are no longer overriden and use the
   correct convention regarding scrollbars.
 - Use VisibleRect in other methods rather than duplicating code
 - Added, clarified, and corrected comments in visual viewport
 - Updated tests (and converted to more modern style) to not use
   internals visual viewport methods where a web-visible API exists.
 - Explicitly use PageZoomFactor for zoom adjustment, rather than the
   misleadingly named AdjustScroll helper.

Change-Id: I4df38bbff78224cccf47f0ee86a573c8fe033c5d
Reviewed-on: https://chromium-review.googlesource.com/1082928Reviewed-by: default avatarJianpeng Chao <chaopeng@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565062}
parent c87477e1
This tests that a usually overflow: hidden viewport should be scrollable when scaled. Otherwise, you can't get to content you would have been able to get to had you not been zoomed it.
PASS internals.visualViewportScrollY() is 0
PASS internals.visualViewportScrollY() became 200
PASS successfullyParsed is true
TEST COMPLETE
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/gesture-util.js"></script>
<style> <style>
html, body { margin:0; overflow: hidden; } html, body { margin:0; overflow: hidden; }
</style> </style>
<script src="../../resources/js-test.js"></script>
<div> <div>
This tests that a usually overflow: hidden viewport should be scrollable when This tests that a usually overflow: hidden viewport should be scrollable when
...@@ -14,29 +17,32 @@ ...@@ -14,29 +17,32 @@
</div> </div>
<script> <script>
jsTestIsAsync = true; const MOUSE_INPUT = 2; // Gesture source type from synthetic_gesture_params.
async function runTest() {
(function() { promise_test( async () => {
if (!window.testRunner || !window.internals) { assert_true(typeof(window.internals) !== "undefined",
debug("This test only works in the test runner and requires window.internals."); "This test requires window.internals.");
return;
} // Force a layout.
document.body.offsetLeft;
// Force a layout.
document.body.offsetLeft; internals.setPageScaleFactor(2);
internals.setPageScaleFactor(2); await waitForCompositorCommit();
// Note that with ScrollTopLeftInterop enabled, document.scrollingElement is // Note that with ScrollTopLeftInterop enabled,
// null because document.body is potentially scrollable (with overflow:hidden // document.scrollingElement is null because document.body is
// the box can still be scrolled programmatically). // potentially scrollable (with overflow:hidden the box can still
shouldBe("internals.visualViewportScrollY()", "0"); // be scrolled programmatically).
assert_equals(window.visualViewport.pageTop, 0);
if (window.eventSender) {
eventSender.mouseMoveTo(100, 100); await smoothScroll(700, 100, 100, MOUSE_INPUT, 'down', 3000);
eventSender.mouseScrollBy(0, -10); await waitFor(() => { return window.visualViewport.pageTop >= 300; });
} assert_equals(window.visualViewport.pageTop,
300,
shouldBecomeEqual("internals.visualViewportScrollY()", "200", finishJSTest); "Visual viewport is scrolled fully to the bottom");
})(); },
"Viewport with overflow: hidden can still be panned when pinch-zoomed in.");
}
window.addEventListener("load", runTest);
</script> </script>
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
height: 10000px; height: 10000px;
width: 10000px; width: 10000px;
} }
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
</style> </style>
<body></body> <body></body>
...@@ -19,7 +23,7 @@ ...@@ -19,7 +23,7 @@
assert_array_equals([window.innerWidth, window.innerHeight], [800, 600], 'initial page size is valid'); assert_array_equals([window.innerWidth, window.innerHeight], [800, 600], 'initial page size is valid');
if (window.internals) { if (window.internals) {
internals.setPageScaleFactor(2); internals.setPageScaleFactor(2);
assert_array_equals([internals.visualViewportWidth(), internals.visualViewportHeight()], [400, 300], 'page is scaled'); assert_array_equals([window.visualViewport.width, window.visualViewport.height], [400, 300], 'page is scaled');
} }
history.scrollRestoration = 'manual'; history.scrollRestoration = 'manual';
...@@ -32,7 +36,7 @@ ...@@ -32,7 +36,7 @@
window.location = "../../../resources/back.html"; window.location = "../../../resources/back.html";
}, 0); }, 0);
} else { } else {
assert_array_equals([internals.visualViewportWidth(), internals.visualViewportHeight()], [400, 300], 'page scale is restored'); assert_array_equals([window.visualViewport.width, window.visualViewport.height], [400, 300], 'page scale is restored');
assert_array_equals([window.scrollX, window.scrollY], [0, 0], 'scroll position is not restored'); assert_array_equals([window.scrollX, window.scrollY], [0, 0], 'scroll position is not restored');
// clean up // clean up
window.name = ''; window.name = '';
......
Test that element.scrollIntoView() only scrolls the layout viewport when the intertVisualViewport is set.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS internals.visualViewportScrollX() is window.scrollX
PASS internals.visualViewportScrollY() is window.scrollY
PASS window.scrollX is 0
PASS window.scrollY is > 0
PASS internals.visualViewportScrollX() is window.scrollX
PASS internals.visualViewportScrollY() is window.scrollY
PASS window.scrollX is 0
PASS window.scrollY is > 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function runTest() {
test( () => {
assert_true(typeof(window.internals) !== 'undefined',
"This test requires window.internals");
internals.setPageScaleFactor(2.0);
const target = document.getElementById("box");
window.scrollTo(0, 0);
internals.setVisualViewportOffset(0, 0);
target.scrollIntoView();
assert_equals(window.visualViewport.pageLeft, window.scrollX);
assert_equals(window.visualViewport.pageTop, window.scrollY);
assert_equals(window.scrollX, 0);
assert_greater_than(window.scrollY, 0);
window.scrollTo(0, 0);
internals.setVisualViewportOffset(0, 0);
target.scrollIntoViewIfNeeded();
assert_equals(window.visualViewport.pageLeft, window.scrollX);
assert_equals(window.visualViewport.pageTop, window.scrollY);
assert_equals(window.scrollX, 0);
assert_greater_than(window.scrollY, 0);
}, "Test that element.scrollIntoView() scrolls only the layout viewport.");
}
onload = runTest;
</script>
<style> <style>
body { body {
height: 800px; height: 800px;
...@@ -13,46 +47,5 @@ ...@@ -13,46 +47,5 @@
position: absolute; position: absolute;
} }
</style> </style>
<script src="../../resources/js-test.js"></script>
<script>
if (window.testRunner && window.internals) {
window.jsTestIsAsync = true;
testRunner.dumpAsText();
testRunner.waitUntilDone();
setPrintTestResultsLazily();
}
description("Test that element.scrollIntoView() only scrolls the layout\
viewport when the intertVisualViewport is set.");
function runTest() {
if (!window.testRunner || !window.internals) {
testFailed("This test requires test runner and internals");
finishJSTest();
return;
}
internals.setPageScaleFactor(2.0);
var target = document.getElementById("box");
window.scrollTo(0, 0);
internals.setVisualViewportOffset(0, 0);
target.scrollIntoView();
shouldBe('internals.visualViewportScrollX()', 'window.scrollX');
shouldBe('internals.visualViewportScrollY()', 'window.scrollY');
shouldBe('window.scrollX', '0');
shouldBeGreaterThan('window.scrollY', '0');
window.scrollTo(0, 0);
internals.setVisualViewportOffset(0, 0);
target.scrollIntoViewIfNeeded();
shouldBe('internals.visualViewportScrollX()', 'window.scrollX');
shouldBe('internals.visualViewportScrollY()', 'window.scrollY');
shouldBe('window.scrollX', '0');
shouldBeGreaterThan('window.scrollY', '0');
finishJSTest();
}
onload = runTest;
</script>
<div id="box"></div> <div id="box"></div>
...@@ -115,7 +115,7 @@ promise_test(t => { ...@@ -115,7 +115,7 @@ promise_test(t => {
// downwards, the layout_viewport needs to scroll another 100 downwards to // downwards, the layout_viewport needs to scroll another 100 downwards to
// make the total offset as 700. // make the total offset as 700.
return set_and_scroll_and_snap(300, 250, 'down', 400, 300); return set_and_scroll_and_snap(300, 250, 'down', 400, 300);
}, "Snap scrolls both layout and visual viewports when visual viewport is" + }, "Snap scrolls both layout and visual viewports when visual viewport is " +
"scrollable but does not has enough room to reach the snap position."); "scrollable but does not has enough room to reach the snap position.");
</script> </script>
Test that scrolling editor commands while pinch-zoomed scrolls both viewports. To test manually, pinch zoom into the page and use the arrow keys, page up/down, home/end to scroll the page. You should be able to reach the end of the page bounds (i.e. scroll to see the divs at the bounds.)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
Testing Document Scrolling:
PASS window.scrollY is pageHeight - window.innerHeight
PASS window.scrollX is 0
PASS window.scrollY is 0
PASS window.scrollX is 0
Testing Page Scrolling:
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS internals.visualViewportScrollX() is 0
PASS internals.visualViewportScrollY() is 0
PASS internals.visualViewportScrollX() is 0
Testing Line Scrolling:
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS internals.visualViewportScrollX() is 0
PASS internals.visualViewportScrollY() is 0
PASS internals.visualViewportScrollX() is 0
Top of pageBottom of pageLeft of pageRight of pageMiddle of page
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/gesture-util.js"></script>
<script> <script>
var numScrolls; let numScrolls;
var pageHeight = 2000; const pageHeight = 2000;
var pageWidth = 2000; const pageWidth = 2000;
if (testRunner) if (testRunner)
testRunner.waitUntilDone(); testRunner.waitUntilDone();
const document_test = async_test("Document scrolling commands scroll visual viewport");
const page_test = async_test("Page scrolling commands scroll visual viewport");
const line_test = async_test("Line scrolling commands scroll visual viewport");
function reset() function reset()
{ {
window.scrollTo(0, 0); window.scrollTo(0, 0);
...@@ -16,77 +22,66 @@ ...@@ -16,77 +22,66 @@
// Test Document scroll separately so we ensure it scrolls all the way in one // Test Document scroll separately so we ensure it scrolls all the way in one
// shot. // shot.
function testDocumentScroll() { function testDocumentScroll(test) {
internals.executeCommand(document, 'ScrollToEndOfDocument', ''); test.step( () => {
shouldBe('window.scrollY', 'pageHeight - window.innerHeight'); internals.executeCommand(document, 'ScrollToEndOfDocument', '');
shouldBe('window.scrollX', '0'); assert_equals(window.scrollY, pageHeight - window.innerHeight);
assert_equals(window.visualViewport.pageTop, pageHeight - window.visualViewport.height);
internals.executeCommand(document, 'ScrollToBeginningOfDocument', ''); assert_equals(window.scrollX, 0);
shouldBe('window.scrollY', '0');
shouldBe('window.scrollX', '0'); internals.executeCommand(document, 'ScrollToBeginningOfDocument', '');
assert_equals(window.scrollY, 0);
assert_equals(window.visualViewport.pageTop, 0);
assert_equals(window.scrollX, 0);
test.done();
});
} }
function testScroll(forwardCmd, backwardCmd) { function testScroll(test, forwardCmd, backwardCmd) {
internals.executeCommand(document, forwardCmd, ''); test.step( () => {
internals.executeCommand(document, forwardCmd, '');
if (internals.visualViewportScrollY() === 0) { assert_greater_than(window.visualViewport.pageTop,
debug('FAIL: Command ' + forwardCmd + ' failed to scroll page at all.'); 0,
return; 'Command ' + forwardCmd + ' failed to scroll page at all.');
}
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY()); numScrolls = Math.ceil((pageHeight - window.visualViewport.height) / window.visualViewport.pageTop);
for(var i = 0; i < numScrolls - 1; ++i) { for(let i = 0; i < numScrolls - 1; ++i) {
internals.executeCommand(document, forwardCmd, ''); internals.executeCommand(document, forwardCmd, '');
} }
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()'); assert_equals(window.visualViewport.pageTop, pageHeight - window.visualViewport.height);
shouldBe('internals.visualViewportScrollX()', '0'); assert_equals(window.visualViewport.pageLeft, 0);
for(var i = 0; i < numScrolls; ++i) { for(let i = 0; i < numScrolls; ++i) {
internals.executeCommand(document, backwardCmd, ''); internals.executeCommand(document, backwardCmd, '');
} }
shouldBe('internals.visualViewportScrollY()', '0'); assert_equals(window.visualViewport.pageTop, 0);
shouldBe('internals.visualViewportScrollX()', '0'); assert_equals(window.visualViewport.pageLeft, 0);
test.done();
});
} }
function runTest() async function runTest()
{ {
description(
'Test that scrolling editor commands while pinch-zoomed scrolls ' +
'both viewports. To test manually, pinch zoom into the page and ' +
'use the arrow keys, page up/down, home/end to scroll the page. ' +
'You should be able to reach the end of the page bounds (i.e. ' +
'scroll to see the divs at the bounds.)');
if (window.internals) { if (window.internals) {
await waitForCompositorCommit();
internals.settings.setScrollAnimatorEnabled(false); internals.settings.setScrollAnimatorEnabled(false);
reset(); reset();
debug(''); testDocumentScroll(document_test);
debug('Testing Document Scrolling:');
testDocumentScroll();
reset(); reset();
debug(''); testScroll(page_test, 'ScrollPageForward', 'ScrollPageBackward');
debug('Testing Page Scrolling:');
testScroll('ScrollPageForward', 'ScrollPageBackward');
reset(); reset();
debug(''); testScroll(line_test, 'ScrollLineDown', 'ScrollLineUp');
debug('Testing Line Scrolling:');
testScroll('ScrollLineDown', 'ScrollLineUp');
if (testRunner)
testRunner.notifyDone();
} }
} }
// Run after rAF to ensure the viewports are registered which happens after a addEventListener('load', runTest);
// full lifecycle update (and rAF comes before lifecycle update so X2).
addEventListener('load', () => {
requestAnimationFrame(() => { requestAnimationFrame(runTest); } );
});
</script> </script>
<style> <style>
::-webkit-scrollbar { ::-webkit-scrollbar {
...@@ -138,8 +133,12 @@ ...@@ -138,8 +133,12 @@
left: 1800px; left: 1800px;
} }
</style> </style>
<p id="description" style="width: 800px"></p> <p id="description" style="width: 800px">
<p id="console" style="width: 800px"></p> Test that scrolling editor commands while pinch-zoomed scrolls both
viewports. To test manually, pinch zoom into the page and use the arrow keys,
page up/down, home/end to scroll the page. You should be able to reach the
end of the page bounds (i.e. scroll to see the divs at the bounds.
</p>
<div class="top">Top of page</div> <div class="top">Top of page</div>
<div class="bottom">Bottom of page</div> <div class="bottom">Bottom of page</div>
<div class="left">Left of page</div> <div class="left">Left of page</div>
......
Test that keyboard scrolling while the page is scaled scrolls both viewports. To test manually, pinch zoom into the page and use the arrow keys, page up/down, home/end to scroll the page. You should be able to reach the end of the page bounds (i.e. scroll to see the divs at the bounds.)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
Testing arrow keys:
PASS internals.visualViewportScrollY() is > 0
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS internals.visualViewportScrollY() is 0
PASS internals.visualViewportScrollX() is pageWidth - internals.visualViewportWidth()
PASS internals.visualViewportScrollX() is 0
Testing home and end keys:
PASS window.scrollY is pageHeight - window.innerHeight
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS window.scrollY is 0
PASS internals.visualViewportScrollY() is 0
Testing page up and page down keys:
PASS internals.visualViewportScrollY() is > 0
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS internals.visualViewportScrollY() is 0
Testing spacebar:
PASS internals.visualViewportScrollY() is > 0
PASS internals.visualViewportScrollY() is pageHeight - internals.visualViewportHeight()
PASS internals.visualViewportScrollY() is 0
Top of pageBottom of pageLeft of pageRight of pageMiddle of page
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script> <script>
var numScrolls; let numScrolls;
var pageHeight = 2000; const pageHeight = 2000;
var pageWidth = 2000; const pageWidth = 2000;
function reset() function reset()
{ {
...@@ -13,121 +14,145 @@ ...@@ -13,121 +14,145 @@
function testArrowKeys() function testArrowKeys()
{ {
// Test up and down. test(() => {
eventSender.keyDown('ArrowDown'); // Test up and down.
shouldBeGreaterThan('internals.visualViewportScrollY()', '0');
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY());
for(var i = 0; i < numScrolls - 1; ++i) {
eventSender.keyDown('ArrowDown'); eventSender.keyDown('ArrowDown');
} assert_greater_than(window.visualViewport.pageTop,
0,
"Arrow down scrolls visual viewport");
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()'); numScrolls = Math.ceil((pageHeight - window.visualViewport.height) / window.visualViewport.pageTop);
for(var i = 0; i < numScrolls; ++i) { for(let i = 0; i < numScrolls - 1; ++i) {
eventSender.keyDown('ArrowUp'); eventSender.keyDown('ArrowDown');
} }
assert_equals(window.visualViewport.pageTop,
pageHeight - window.visualViewport.height,
"Visual viewport should have fully scrolled to the page bottom");
shouldBe('internals.visualViewportScrollY()', '0'); for(let i = 0; i < numScrolls; ++i) {
eventSender.keyDown('ArrowUp');
}
// Now test left and right. assert_equals(window.visualViewport.pageTop,
0,
"Visual viewport should have fully scrolled to the page top");
reset(); // Now test left and right.
eventSender.keyDown('ArrowRight');
numScrolls = Math.ceil((pageWidth - internals.visualViewportWidth()) / internals.visualViewportScrollX());
for(var i = 0; i < numScrolls - 1; ++i) { reset();
eventSender.keyDown('ArrowRight'); eventSender.keyDown('ArrowRight');
} numScrolls = Math.ceil((pageWidth - window.visualViewport.width) / window.visualViewport.pageLeft);
shouldBe('internals.visualViewportScrollX()', 'pageWidth - internals.visualViewportWidth()'); for(let i = 0; i < numScrolls - 1; ++i) {
eventSender.keyDown('ArrowRight');
}
for(var i = 0; i < numScrolls; ++i) { assert_equals(window.visualViewport.pageLeft,
eventSender.keyDown('ArrowLeft'); pageWidth - window.visualViewport.width,
} "Visual viewport should have fully scrolled to page right");
for(let i = 0; i < numScrolls; ++i) {
eventSender.keyDown('ArrowLeft');
}
shouldBe('internals.visualViewportScrollX()', '0'); assert_equals(window.visualViewport.pageLeft,
0,
"Visual viewport should have fully scrolled to page left");
}, "Arrow key scrolling affects visual viewport");
} }
function testHomeEnd() function testHomeEnd()
{ {
eventSender.keyDown('End'); test( () => {
shouldBe('window.scrollY', 'pageHeight - window.innerHeight'); eventSender.keyDown('End');
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()'); assert_equals(window.scrollY,
eventSender.keyDown('Home'); pageHeight - window.innerHeight,
shouldBe('window.scrollY', '0'); "Layout viewport scrolled fully to page bottom");
shouldBe('internals.visualViewportScrollY()', '0'); assert_equals(window.visualViewport.pageTop,
pageHeight - window.visualViewport.height,
"Visual viewport scrolled fully to page bottom");
eventSender.keyDown('Home');
assert_equals(window.scrollY,
0,
"Layout viewport scrolled fully to page top");
assert_equals(window.visualViewport.pageTop,
0,
"Visual viewport scrolled fully to page top");
}, "Home and End keys affect visual viewport");
} }
function testPageUpDown() function testPageUpDown()
{ {
eventSender.keyDown('PageDown'); test( () => {
shouldBeGreaterThan('internals.visualViewportScrollY()', '0'); eventSender.keyDown('PageDown');
assert_greater_than(window.visualViewport.pageTop,
0,
"Page down scrolled visual viewport");
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY()); numScrolls = Math.ceil((pageHeight - window.visualViewport.height) / window.visualViewport.pageTop);
for(var i = 0; i < numScrolls - 1; ++i) { for(let i = 0; i < numScrolls - 1; ++i) {
eventSender.keyDown('PageDown'); eventSender.keyDown('PageDown');
} }
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()'); assert_equals(window.visualViewport.pageTop,
pageHeight - window.visualViewport.height,
"Visual viewport scrolled fully to page bottom");
for(var i = 0; i < numScrolls; ++i) { for(let i = 0; i < numScrolls; ++i) {
eventSender.keyDown('PageUp'); eventSender.keyDown('PageUp');
} }
shouldBe('internals.visualViewportScrollY()', '0'); assert_equals(window.visualViewport.pageTop,
0,
"Visual viewport scrolled fully to page top");
}, "Page up and down keys affect visual viewport");
} }
function testSpacebar() function testSpacebar()
{ {
eventSender.keyDown(' '); test( () => {
shouldBeGreaterThan('internals.visualViewportScrollY()', '0'); eventSender.keyDown(' ');
assert_greater_than(window.visualViewport.pageTop,
0,
"Space bar caused visual viewport to scroll");
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY()); numScrolls = Math.ceil((pageHeight - window.visualViewport.height) / window.visualViewport.pageTop);
for(var i = 0; i < numScrolls - 1; ++i) { for(let i = 0; i < numScrolls - 1; ++i) {
eventSender.keyDown(' '); eventSender.keyDown(' ');
} }
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()'); assert_equals(window.visualViewport.pageTop,
pageHeight - window.visualViewport.height,
"Visual viewport scrolled fully to page bottom");
for(var i = 0; i < numScrolls; ++i) { for(let i = 0; i < numScrolls; ++i) {
eventSender.keyDown(' ', 'shiftKey'); eventSender.keyDown(' ', 'shiftKey');
} }
shouldBe('internals.visualViewportScrollY()', '0'); assert_equals(window.visualViewport.pageTop,
0,
"Visual viewport scrolled fully to page top");
});
} }
function runTest() function runTest()
{ {
description(
'Test that keyboard scrolling while the page is scaled scrolls ' +
'both viewports. To test manually, pinch zoom into the page and ' +
'use the arrow keys, page up/down, home/end to scroll the page. ' +
'You should be able to reach the end of the page bounds (i.e. ' +
'scroll to see the divs at the bounds.)');
if (window.eventSender && window.internals) { if (window.eventSender && window.internals) {
internals.settings.setScrollAnimatorEnabled(false); internals.settings.setScrollAnimatorEnabled(false);
reset(); reset();
debug('Testing arrow keys:');
testArrowKeys(); testArrowKeys();
reset(); reset();
debug('');
debug('Testing home and end keys:');
testHomeEnd(); testHomeEnd();
reset(); reset();
debug('');
debug('Testing page up and page down keys:');
testPageUpDown(); testPageUpDown();
reset(); reset();
debug('');
debug('Testing spacebar:');
testSpacebar(); testSpacebar();
} }
} }
...@@ -184,8 +209,12 @@ ...@@ -184,8 +209,12 @@
left: 1800px; left: 1800px;
} }
</style> </style>
<p id="description" style="width: 800px"></p> <p id="description" style="width: 800px">
<p id="console" style="width: 800px"></p> Test that keyboard scrolling while the page is scaled scrolls both viewports.
To test manually, pinch zoom into the page and use the arrow keys, page
up/down, home/end to scroll the page. You should be able to reach the end of
the page bounds (i.e. scroll to see the divs at the bounds.
</p>
<div class="top">Top of page</div> <div class="top">Top of page</div>
<div class="bottom">Bottom of page</div> <div class="bottom">Bottom of page</div>
<div class="left">Left of page</div> <div class="left">Left of page</div>
......
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
<script src="../media-controls.js"></script> <script src="../media-controls.js"></script>
</head> </head>
<style> <style>
body { body {
overflow-x: hidden; overflow-x: hidden;
} }
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
</style> </style>
<body> <body>
<video controls width=400 style="transform:rotate(180deg)"></video> <video controls width=400 style="transform:rotate(180deg)"></video>
......
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
<script src="media-controls.js"></script> <script src="media-controls.js"></script>
</head> </head>
<style> <style>
body { body {
overflow-x: hidden; overflow-x: hidden;
} }
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
</style> </style>
<body> <body>
<video controls width=400></video> <video controls width=400></video>
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
internals.settings.setPreferCompositingToLCDTextEnabled( internals.settings.setPreferCompositingToLCDTextEnabled(
true); true);
document.execCommand("FindString", false, "target"); document.execCommand("FindString", false, "target");
assert_equals(internals.visualViewportScrollX(), 167); assert_equals(window.visualViewport.pageLeft, 167);
assert_equals(internals.visualViewportScrollY(), 2867); assert_equals(window.visualViewport.pageTop, 2867);
}, "Test scrolled into view with prefer compositing enabled"); }, "Test scrolled into view with prefer compositing enabled");
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
internals.settings.setPreferCompositingToLCDTextEnabled( internals.settings.setPreferCompositingToLCDTextEnabled(
false); false);
document.execCommand("FindString", false, "target"); document.execCommand("FindString", false, "target");
assert_equals(internals.visualViewportScrollX(), 167); assert_equals(window.visualViewport.pageLeft, 167);
assert_equals(internals.visualViewportScrollY(), 2867); assert_equals(window.visualViewport.pageTop, 2867);
}, "Test scrolled into view with prefer compositing disabled"); }, "Test scrolled into view with prefer compositing disabled");
} }
</script> </script>
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/input/event_handler.h" #include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/adjust_for_absolute_zoom.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h" #include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
...@@ -153,24 +152,27 @@ void VisualViewport::MainFrameDidChangeSize() { ...@@ -153,24 +152,27 @@ void VisualViewport::MainFrameDidChangeSize() {
ClampToBoundaries(); ClampToBoundaries();
} }
FloatSize VisualViewport::VisibleSize() const { FloatRect VisualViewport::VisibleRect(
FloatSize scaled_size(size_); IncludeScrollbarsInRect scrollbar_inclusion) const {
scaled_size.Expand(0, browser_controls_adjustment_); FloatSize visible_size(size_);
scaled_size.Scale(1 / scale_);
return scaled_size; if (scrollbar_inclusion == kExcludeScrollbars)
} visible_size = FloatSize(ExcludeScrollbars(size_));
FloatRect VisualViewport::VisibleRect() const { visible_size.Expand(0, browser_controls_adjustment_);
return FloatRect(FloatPoint(GetScrollOffset()), VisibleSize()); visible_size.Scale(1 / scale_);
return FloatRect(FloatPoint(GetScrollOffset()), visible_size);
} }
FloatRect VisualViewport::VisibleRectInDocument() const { FloatRect VisualViewport::VisibleRectInDocument(
IncludeScrollbarsInRect scrollbar_inclusion) const {
if (!MainFrame() || !MainFrame()->View()) if (!MainFrame() || !MainFrame()->View())
return FloatRect(); return FloatRect();
FloatPoint view_location = FloatPoint view_location =
FloatPoint(MainFrame()->View()->GetScrollableArea()->GetScrollOffset()); FloatPoint(MainFrame()->View()->GetScrollableArea()->GetScrollOffset());
return FloatRect(view_location, VisibleSize()); return FloatRect(view_location, VisibleRect(scrollbar_inclusion).Size());
} }
FloatPoint VisualViewport::ViewportCSSPixelsToRootFrame( FloatPoint VisualViewport::ViewportCSSPixelsToRootFrame(
...@@ -199,8 +201,7 @@ double VisualViewport::OffsetLeft() const { ...@@ -199,8 +201,7 @@ double VisualViewport::OffsetLeft() const {
UpdateStyleAndLayoutIgnorePendingStylesheets(); UpdateStyleAndLayoutIgnorePendingStylesheets();
return AdjustForAbsoluteZoom::AdjustScroll(VisibleRect().X(), return VisibleRect().X() / MainFrame()->PageZoomFactor();
MainFrame()->PageZoomFactor());
} }
double VisualViewport::OffsetTop() const { double VisualViewport::OffsetTop() const {
...@@ -209,8 +210,7 @@ double VisualViewport::OffsetTop() const { ...@@ -209,8 +210,7 @@ double VisualViewport::OffsetTop() const {
UpdateStyleAndLayoutIgnorePendingStylesheets(); UpdateStyleAndLayoutIgnorePendingStylesheets();
return AdjustForAbsoluteZoom::AdjustScroll(VisibleRect().Y(), return VisibleRect().Y() / MainFrame()->PageZoomFactor();
MainFrame()->PageZoomFactor());
} }
double VisualViewport::Width() const { double VisualViewport::Width() const {
...@@ -238,12 +238,8 @@ double VisualViewport::VisibleWidthCSSPx() const { ...@@ -238,12 +238,8 @@ double VisualViewport::VisibleWidthCSSPx() const {
return 0; return 0;
float zoom = MainFrame()->PageZoomFactor(); float zoom = MainFrame()->PageZoomFactor();
float width_css_px = float width_css_px = VisibleRect().Width() / zoom;
AdjustForAbsoluteZoom::AdjustScroll(VisibleSize().Width(), zoom); return width_css_px;
auto* scrollable_area = MainFrame()->View()->LayoutViewportScrollableArea();
float scrollbar_thickness_css_px =
scrollable_area->VerticalScrollbarWidth() / (zoom * scale_);
return width_css_px - scrollbar_thickness_css_px;
} }
double VisualViewport::VisibleHeightCSSPx() const { double VisualViewport::VisibleHeightCSSPx() const {
...@@ -251,12 +247,8 @@ double VisualViewport::VisibleHeightCSSPx() const { ...@@ -251,12 +247,8 @@ double VisualViewport::VisibleHeightCSSPx() const {
return 0; return 0;
float zoom = MainFrame()->PageZoomFactor(); float zoom = MainFrame()->PageZoomFactor();
float height_css_px = float height_css_px = VisibleRect().Height() / zoom;
AdjustForAbsoluteZoom::AdjustScroll(VisibleSize().Height(), zoom); return height_css_px;
auto* scrollable_area = MainFrame()->View()->LayoutViewportScrollableArea();
float scrollbar_thickness_css_px =
scrollable_area->HorizontalScrollbarHeight() / (zoom * scale_);
return height_css_px - scrollbar_thickness_css_px;
} }
bool VisualViewport::DidSetScaleOrLocation(float scale, bool VisualViewport::DidSetScaleOrLocation(float scale,
...@@ -604,7 +596,7 @@ IntPoint VisualViewport::ClampDocumentOffsetAtScale(const IntPoint& offset, ...@@ -604,7 +596,7 @@ IntPoint VisualViewport::ClampDocumentOffsetAtScale(const IntPoint& offset,
LocalFrameView* view = MainFrame()->View(); LocalFrameView* view = MainFrame()->View();
FloatSize scaled_size(size_); FloatSize scaled_size(ExcludeScrollbars(size_));
scaled_size.Scale(1 / scale); scaled_size.Scale(1 / scale);
IntSize visual_viewport_max = IntSize visual_viewport_max =
...@@ -661,28 +653,15 @@ bool VisualViewport::UserInputScrollable(ScrollbarOrientation) const { ...@@ -661,28 +653,15 @@ bool VisualViewport::UserInputScrollable(ScrollbarOrientation) const {
IntSize VisualViewport::ContentsSize() const { IntSize VisualViewport::ContentsSize() const {
LocalFrame* frame = MainFrame(); LocalFrame* frame = MainFrame();
if (!frame || !frame->View()) if (!frame || !frame->View())
return IntSize(); return IntSize();
// TODO(bokan): This should be the layout viewport rather than main
// LocalFrameView.
return frame->View()->VisibleContentRect(kIncludeScrollbars).Size(); return frame->View()->VisibleContentRect(kIncludeScrollbars).Size();
} }
IntRect VisualViewport::VisibleContentRect( IntRect VisualViewport::VisibleContentRect(
IncludeScrollbarsInRect scrollbar_inclusion) const { IncludeScrollbarsInRect scrollbar_inclusion) const {
// TODO(ymalik): We're losing precision here and below. visibleRect should return EnclosingIntRect(VisibleRect(scrollbar_inclusion));
// be replaced with visibleContentRect.
IntRect rect = EnclosingIntRect(VisibleRect());
if (scrollbar_inclusion == kExcludeScrollbars) {
RootFrameViewport* root_frame_viewport =
MainFrame()->View()->GetRootFrameViewport();
DCHECK(root_frame_viewport);
rect.Contract(root_frame_viewport->VerticalScrollbarWidth() / scale_,
root_frame_viewport->HorizontalScrollbarHeight() / scale_);
}
return rect;
} }
scoped_refptr<base::SingleThreadTaskRunner> VisualViewport::GetTimerTaskRunner() scoped_refptr<base::SingleThreadTaskRunner> VisualViewport::GetTimerTaskRunner()
...@@ -727,12 +706,28 @@ void VisualViewport::PaintContents(const GraphicsLayer*, ...@@ -727,12 +706,28 @@ void VisualViewport::PaintContents(const GraphicsLayer*,
GraphicsLayerPaintingPhase, GraphicsLayerPaintingPhase,
const IntRect&) const {} const IntRect&) const {}
RootFrameViewport* VisualViewport::GetRootFrameViewport() const {
if (!MainFrame() || !MainFrame()->View())
return nullptr;
return MainFrame()->View()->GetRootFrameViewport();
}
LocalFrame* VisualViewport::MainFrame() const { LocalFrame* VisualViewport::MainFrame() const {
return GetPage().MainFrame() && GetPage().MainFrame()->IsLocalFrame() return GetPage().MainFrame() && GetPage().MainFrame()->IsLocalFrame()
? GetPage().DeprecatedLocalMainFrame() ? GetPage().DeprecatedLocalMainFrame()
: nullptr; : nullptr;
} }
IntSize VisualViewport::ExcludeScrollbars(const IntSize& size) const {
IntSize excluded_size = size;
if (RootFrameViewport* root_frame_viewport = GetRootFrameViewport()) {
excluded_size.Expand(-root_frame_viewport->VerticalScrollbarWidth(),
-root_frame_viewport->HorizontalScrollbarHeight());
}
return excluded_size;
}
bool VisualViewport::ScheduleAnimation() { bool VisualViewport::ScheduleAnimation() {
GetPage().GetChromeClient().ScheduleAnimation(MainFrame()->View()); GetPage().GetChromeClient().ScheduleAnimation(MainFrame()->View());
return true; return true;
...@@ -879,16 +874,10 @@ CompositorAnimationTimeline* VisualViewport::GetCompositorAnimationTimeline() ...@@ -879,16 +874,10 @@ CompositorAnimationTimeline* VisualViewport::GetCompositorAnimationTimeline()
} }
void VisualViewport::NotifyRootFrameViewport() const { void VisualViewport::NotifyRootFrameViewport() const {
if (!MainFrame() || !MainFrame()->View()) if (!GetRootFrameViewport())
return;
RootFrameViewport* root_frame_viewport =
MainFrame()->View()->GetRootFrameViewport();
if (!root_frame_viewport)
return; return;
root_frame_viewport->DidUpdateVisualViewport(); GetRootFrameViewport()->DidUpdateVisualViewport();
} }
ScrollbarTheme& VisualViewport::GetPageScrollbarTheme() const { ScrollbarTheme& VisualViewport::GetPageScrollbarTheme() const {
......
...@@ -113,12 +113,21 @@ class CORE_EXPORT VisualViewport final ...@@ -113,12 +113,21 @@ class CORE_EXPORT VisualViewport final
// FIXME: This should be called moveBy // FIXME: This should be called moveBy
void Move(const ScrollOffset&); void Move(const ScrollOffset&);
// Sets the size of the inner viewport when unscaled in CSS pixels. // The size of the Blink viewport area. See size_ for precise
// definition.
void SetSize(const IntSize&); void SetSize(const IntSize&);
IntSize Size() const { return size_; } IntSize Size() const { return size_; }
// Gets the scaled size, i.e. the viewport in root view space. // The area of the layout viewport rect visible in the visual viewport,
FloatSize VisibleSize() const; // relative to the layout viewport's top-left corner. i.e. As the page scale
// is increased, this rect shrinks. Does not account for browser-zoom (ctrl
// +/- zooming).
FloatRect VisibleRect(IncludeScrollbarsInRect = kExcludeScrollbars) const;
// Similar to VisibleRect but this returns the rect relative to the main
// document's top-left corner.
FloatRect VisibleRectInDocument(
IncludeScrollbarsInRect = kExcludeScrollbars) const;
// Resets the viewport to initial state. // Resets the viewport to initial state.
void Reset(); void Reset();
...@@ -137,13 +146,6 @@ class CORE_EXPORT VisualViewport final ...@@ -137,13 +146,6 @@ class CORE_EXPORT VisualViewport final
// if page scale factor is left unchanged. // if page scale factor is left unchanged.
bool MagnifyScaleAroundAnchor(float magnify_delta, const FloatPoint& anchor); bool MagnifyScaleAroundAnchor(float magnify_delta, const FloatPoint& anchor);
// The portion of the unzoomed frame visible in the visual viewport,
// in partial CSS pixels. Relative to the main frame.
FloatRect VisibleRect() const;
// The viewport rect relative to the document origin, in partial CSS pixels.
FloatRect VisibleRectInDocument() const;
// Convert the given rect in the main LocalFrameView's coordinates into a rect // Convert the given rect in the main LocalFrameView's coordinates into a rect
// in the viewport. The given and returned rects are in CSS pixels, meaning // in the viewport. The given and returned rects are in CSS pixels, meaning
// scale isn't applied. // scale isn't applied.
...@@ -192,8 +194,9 @@ class CORE_EXPORT VisualViewport final ...@@ -192,8 +194,9 @@ class CORE_EXPORT VisualViewport final
IntSize MinimumScrollOffsetInt() const override; IntSize MinimumScrollOffsetInt() const override;
IntSize MaximumScrollOffsetInt() const override; IntSize MaximumScrollOffsetInt() const override;
ScrollOffset MaximumScrollOffset() const override; ScrollOffset MaximumScrollOffset() const override;
int VisibleHeight() const override { return VisibleRect().Height(); } // Note: Because scrollbars are conceptually owned by the LayoutView,
int VisibleWidth() const override { return VisibleRect().Width(); } // ContentsSize includes the main frame's scrollbars. This is necessary for
// correct cc Layer sizing.
IntSize ContentsSize() const override; IntSize ContentsSize() const override;
bool ScrollbarsCanBeActive() const override { return false; } bool ScrollbarsCanBeActive() const override { return false; }
IntRect ScrollableAreaBoundingBox() const override; IntRect ScrollableAreaBoundingBox() const override;
...@@ -270,6 +273,8 @@ class CORE_EXPORT VisualViewport final ...@@ -270,6 +273,8 @@ class CORE_EXPORT VisualViewport final
void NotifyRootFrameViewport() const; void NotifyRootFrameViewport() const;
RootFrameViewport* GetRootFrameViewport() const;
LocalFrame* MainFrame() const; LocalFrame* MainFrame() const;
Page& GetPage() const { Page& GetPage() const {
...@@ -277,6 +282,10 @@ class CORE_EXPORT VisualViewport final ...@@ -277,6 +282,10 @@ class CORE_EXPORT VisualViewport final
return *page_; return *page_;
} }
// Contracts the given size by the thickness of any visible scrollbars. Does
// not contract the size if the scrollbar is overlay.
IntSize ExcludeScrollbars(const IntSize&) const;
Member<Page> page_; Member<Page> page_;
std::unique_ptr<GraphicsLayer> root_transform_layer_; std::unique_ptr<GraphicsLayer> root_transform_layer_;
std::unique_ptr<GraphicsLayer> inner_viewport_container_layer_; std::unique_ptr<GraphicsLayer> inner_viewport_container_layer_;
...@@ -297,8 +306,24 @@ class CORE_EXPORT VisualViewport final ...@@ -297,8 +306,24 @@ class CORE_EXPORT VisualViewport final
// Offset of the visual viewport from the main frame's origin, in CSS pixels. // Offset of the visual viewport from the main frame's origin, in CSS pixels.
ScrollOffset offset_; ScrollOffset offset_;
float scale_; float scale_;
// The Blink viewport size. This is effectively the size of the rect Blink is
// rendering into and includes space consumed by scrollbars. While it will
// not include the URL bar height, Blink is only informed of changes to the
// URL bar once they're fully committed (all the way hidden or shown). While
// they're animating or being dragged, size_ will not reflect the changed
// visible content area. The transient URL bar-caused change to the visible
// content area is tracked in browser_controls_adjustment.
IntSize size_; IntSize size_;
// Blink is only resized as a result of showing/hiding the URL bar once
// they're fully committed (all the way hidden or shown). While they're
// animating or being dragged, browser_controls_adjustment_ tracks the amount
// they expand or shrink the visible content height.
float browser_controls_adjustment_; float browser_controls_adjustment_;
// The maximum page scale the user has zoomed to on the current page. Used
// only to report statistics about pinch-zoom usage.
float max_page_scale_; float max_page_scale_;
bool track_pinch_zoom_stats_for_page_; bool track_pinch_zoom_stats_for_page_;
UniqueObjectId unique_id_; UniqueObjectId unique_id_;
......
...@@ -1652,8 +1652,8 @@ TEST_P(VisualViewportTest, visualViewportIsInert) { ...@@ -1652,8 +1652,8 @@ TEST_P(VisualViewportTest, visualViewportIsInert) {
->GetVisualViewport(); ->GetVisualViewport();
visual_viewport.SetScale(2); visual_viewport.SetScale(2);
ASSERT_EQ(100, visual_viewport.VisibleSize().Width()); ASSERT_EQ(100, visual_viewport.VisibleRect().Width());
ASSERT_EQ(150, visual_viewport.VisibleSize().Height()); ASSERT_EQ(150, visual_viewport.VisibleRect().Height());
EXPECT_EQ(200, window->innerWidth()); EXPECT_EQ(200, window->innerWidth());
EXPECT_EQ(300, window->innerHeight()); EXPECT_EQ(300, window->innerHeight());
......
...@@ -1869,7 +1869,8 @@ WebInputEventResult EventHandler::ShowNonLocatedContextMenu( ...@@ -1869,7 +1869,8 @@ WebInputEventResult EventHandler::ShowNonLocatedContextMenu(
} else { } else {
location_in_root_frame = IntPoint( location_in_root_frame = IntPoint(
right_aligned right_aligned
? visual_viewport.VisibleRect().MaxX() - kContextMenuMargin ? visual_viewport.VisibleRect(kIncludeScrollbars).MaxX() -
kContextMenuMargin
: visual_viewport.GetScrollOffset().Width() + kContextMenuMargin, : visual_viewport.GetScrollOffset().Width() + kContextMenuMargin,
visual_viewport.GetScrollOffset().Height() + kContextMenuMargin); visual_viewport.GetScrollOffset().Height() + kContextMenuMargin);
} }
......
...@@ -1133,12 +1133,6 @@ Response InspectorPageAgent::getLayoutMetrics( ...@@ -1133,12 +1133,6 @@ Response InspectorPageAgent::getLayoutMetrics(
float page_zoom = main_frame->PageZoomFactor(); float page_zoom = main_frame->PageZoomFactor();
FloatRect visible_rect = visual_viewport.VisibleRect(); FloatRect visible_rect = visual_viewport.VisibleRect();
float scale = visual_viewport.Scale(); float scale = visual_viewport.Scale();
float scrollbar_width =
frame_view->LayoutViewportScrollableArea()->VerticalScrollbarWidth() /
scale;
float scrollbar_height =
frame_view->LayoutViewportScrollableArea()->HorizontalScrollbarHeight() /
scale;
IntSize content_size = frame_view->GetScrollableArea()->ContentsSize(); IntSize content_size = frame_view->GetScrollableArea()->ContentsSize();
*out_content_size = protocol::DOM::Rect::create() *out_content_size = protocol::DOM::Rect::create()
...@@ -1148,20 +1142,19 @@ Response InspectorPageAgent::getLayoutMetrics( ...@@ -1148,20 +1142,19 @@ Response InspectorPageAgent::getLayoutMetrics(
.setHeight(content_size.Height()) .setHeight(content_size.Height())
.build(); .build();
*out_visual_viewport = *out_visual_viewport = protocol::Page::VisualViewport::create()
protocol::Page::VisualViewport::create() .setOffsetX(AdjustForAbsoluteZoom::AdjustScroll(
.setOffsetX( visible_rect.X(), page_zoom))
AdjustForAbsoluteZoom::AdjustScroll(visible_rect.X(), page_zoom)) .setOffsetY(AdjustForAbsoluteZoom::AdjustScroll(
.setOffsetY( visible_rect.Y(), page_zoom))
AdjustForAbsoluteZoom::AdjustScroll(visible_rect.Y(), page_zoom)) .setPageX(AdjustForAbsoluteZoom::AdjustScroll(
.setPageX(AdjustForAbsoluteZoom::AdjustScroll(page_offset.Width(), page_offset.Width(), page_zoom))
page_zoom)) .setPageY(AdjustForAbsoluteZoom::AdjustScroll(
.setPageY(AdjustForAbsoluteZoom::AdjustScroll(page_offset.Height(), page_offset.Height(), page_zoom))
page_zoom)) .setClientWidth(visible_rect.Width())
.setClientWidth(visible_rect.Width() - scrollbar_width) .setClientHeight(visible_rect.Height())
.setClientHeight(visible_rect.Height() - scrollbar_height) .setScale(scale)
.setScale(scale) .build();
.build();
return Response::OK(); return Response::OK();
} }
......
...@@ -3307,38 +3307,6 @@ void Internals::setVisualViewportOffset(int x, int y) { ...@@ -3307,38 +3307,6 @@ void Internals::setVisualViewportOffset(int x, int y) {
GetFrame()->GetPage()->GetVisualViewport().SetLocation(FloatPoint(x, y)); GetFrame()->GetPage()->GetVisualViewport().SetLocation(FloatPoint(x, y));
} }
int Internals::visualViewportHeight() {
if (!GetFrame())
return 0;
return ExpandedIntSize(
GetFrame()->GetPage()->GetVisualViewport().VisibleRect().Size())
.Height();
}
int Internals::visualViewportWidth() {
if (!GetFrame())
return 0;
return ExpandedIntSize(
GetFrame()->GetPage()->GetVisualViewport().VisibleRect().Size())
.Width();
}
float Internals::visualViewportScrollX() {
if (!GetFrame())
return 0;
return GetFrame()->View()->GetScrollableArea()->GetScrollOffset().Width();
}
float Internals::visualViewportScrollY() {
if (!GetFrame())
return 0;
return GetFrame()->View()->GetScrollableArea()->GetScrollOffset().Height();
}
bool Internals::isUseCounted(Document* document, uint32_t feature) { bool Internals::isUseCounted(Document* document, uint32_t feature) {
if (feature >= static_cast<int32_t>(WebFeature::kNumberOfFeatures)) if (feature >= static_cast<int32_t>(WebFeature::kNumberOfFeatures))
return false; return false;
......
...@@ -521,11 +521,6 @@ class Internals final : public ScriptWrappable { ...@@ -521,11 +521,6 @@ class Internals final : public ScriptWrappable {
String selectedTextForClipboard(); String selectedTextForClipboard();
void setVisualViewportOffset(int x, int y); void setVisualViewportOffset(int x, int y);
int visualViewportHeight();
int visualViewportWidth();
// The scroll position of the visual viewport relative to the document origin.
float visualViewportScrollX();
float visualViewportScrollY();
// Return true if the given use counter exists for the given document. // Return true if the given use counter exists for the given document.
// |feature| must be one of the values from the WebFeature enum. // |feature| must be one of the values from the WebFeature enum.
......
...@@ -349,10 +349,6 @@ enum EffectiveConnectionType { ...@@ -349,10 +349,6 @@ enum EffectiveConnectionType {
DOMString selectedTextForClipboard(); DOMString selectedTextForClipboard();
void setVisualViewportOffset(long x, long y); void setVisualViewportOffset(long x, long y);
long visualViewportHeight();
long visualViewportWidth();
double visualViewportScrollX();
double visualViewportScrollY();
boolean magnifyScaleAroundAnchor(float offset, float x, float y); boolean magnifyScaleAroundAnchor(float offset, float x, float y);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment