-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only do partial layouts when possible.
This patch changes offsetWidth, offsetHeight, offsetLeft, and offsetTop to only layout a portion of the render tree, up to the target renderer. Partial layout leaves the root needing layout so a full layout must happen before painting. An example of the benefit of this patch is wikipedia where the following pattern is common: 1) page load 2) javascript calls offsetWidth, forcing a full layout 3) javascript injects style into the page, invalidating layout 4) a full layout is performed for painting With this patch, the offsetWidth call in #2 is significantly improved. Text autosizing currently removes most of the benefit of this patch, this will be addressed in a followup patch. Similarly, non-overlay scrollbars reduce the benefit from this patch. This is currently implemented behind the PartialLayout runtime enabled feature flag. BUG=283623 Review URL: https://chromiumcodereview.appspot.com/18601002 git-svn-id: svn://svn.chromium.org/blink/trunk@157252 bbb929c8-8fbe-4397-9dbb-9b2b20218538
- Loading branch information
1 parent
3e3ee45
commit 50887b8
Showing
52 changed files
with
482 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Test that partial layout works for offset{width, height, left, top} methods. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<link rel="stylesheet" href="../../resources/testharness.css"> | ||
<head> | ||
<style> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#measure { | ||
margin: 10px; | ||
padding: 10px; | ||
} | ||
|
||
#fixedsize { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="measure"><div id="fixedsize"></div></div> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
if (window.internals) | ||
window.internals.setUsesOverlayScrollbars(true); | ||
|
||
test(function() { | ||
var measure = document.getElementById('measure'); | ||
|
||
// Record partial layout values for offset*. | ||
var measureWidth = measure.offsetWidth; | ||
var measureHeight = measure.offsetHeight; | ||
var measureTop = measure.offsetTop; | ||
var measureLeft = measure.offsetLeft; | ||
|
||
// Invalidate measure and force a full layout. | ||
var child = measure.firstChild; | ||
measure.removeChild(child); | ||
document.body.clientHeight; | ||
measure.appendChild(child); | ||
var forceLayout = document.body.clientHeight; | ||
|
||
var childOffsetTop = child.offsetTop; | ||
|
||
assert_equals(measureWidth, document.body.offsetWidth - 20); | ||
assert_equals(measureHeight, measure.offsetHeight); | ||
assert_equals(measureTop, childOffsetTop - 10); | ||
assert_equals(measureLeft, measure.offsetLeft); | ||
}, 'Test that partial layout works for offset{width, height, left, top} methods.'); | ||
</script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
LayoutTests/fast/dom/partial-layout-non-overlay-scrollbars-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Test that partial layout works with non-overlay scrollbars. | ||
|
47 changes: 47 additions & 0 deletions
47
LayoutTests/fast/dom/partial-layout-non-overlay-scrollbars.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<link rel="stylesheet" href="../../resources/testharness.css"> | ||
<head> | ||
<style> | ||
::-webkit-scrollbar { | ||
-webkit-appearance: none; | ||
width: 8px; | ||
} | ||
|
||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#makespace { | ||
height: 5000px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="makespace"></div> | ||
<div id="measure"></div> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
if (window.internals) | ||
window.internals.setUsesOverlayScrollbars(true); // Note: We force non-overlay scrollbars with CSS. | ||
|
||
var test = async_test("Test that partial layout works with non-overlay scrollbars."); | ||
setTimeout(function() { | ||
test.step(function() { | ||
var measure = document.getElementById('measure'); | ||
var measureWidth = measure.offsetWidth; // Partial layout occurs here! | ||
|
||
assert_equals(measureWidth, document.body.offsetWidth); | ||
assert_equals(measureWidth, window.innerWidth - 8); | ||
}); | ||
|
||
test.done(); | ||
}, 0); | ||
</script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
LayoutTests/fast/dom/partial-layout-overlay-scrollbars-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Test that partial layout works with overlay scrollbars. | ||
|
42 changes: 42 additions & 0 deletions
42
LayoutTests/fast/dom/partial-layout-overlay-scrollbars.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<link rel="stylesheet" href="../../resources/testharness.css"> | ||
<head> | ||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#makespace { | ||
height: 5000px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="makespace"></div> | ||
<div id="measure"></div> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
if (window.internals) | ||
window.internals.setUsesOverlayScrollbars(true); | ||
|
||
var test = async_test("Test that partial layout works with overlay scrollbars."); | ||
setTimeout(function() { | ||
test.step(function() { | ||
var measure = document.getElementById('measure'); | ||
var measureWidth = measure.offsetWidth; // Partial layout occurs here! | ||
|
||
assert_equals(measureWidth, document.body.offsetWidth); | ||
assert_equals(measureWidth, window.innerWidth); | ||
}); | ||
|
||
test.done(); | ||
}, 0); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.