forked from WebKit/WebKit-http
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text Autosizing: Only take into account block width <= document layou…
…t width. https://bugs.webkit.org/show_bug.cgi?id=93862 Patch by John Mellor <johnme@chromium.org> on 2012-08-20 Reviewed by Kenneth Rohde Christiansen. Source/WebCore: Instead of calculating the textAutosizingMultiplier purely based on the width of each block, we now work out the maximum width of the block that could be displayed onscreen at any one time, and use that value. This avoids excessive text size multiplication (there's no point making text bigger than this, since you wouldn't be able to zoom out far enough to read it!). To determine the maximum onscreen block width, we take the minimum of the block width and the layoutWidth of the narrowest non-flattened ancestor frame. Flattened frames are ignored since they don't impose a hard limit on the maximum width that can be displayed, instead they can stretch to fit their contents. Note that on mobile the layoutWidth of the main frame is the fixed layout width aka viewport width. In practice this caps the maximum multiplier to a value that depends on the metrics of the device. For example on a Nexus S (480 x 800px and 1.5x devicePixelRatio) with a 980px default fixed layout width, this limits the multiplier to: 980 / (480/1.5) = 3.0625 Most pages won't have blocks that actually hit this cap, or they will only slightly exceed it (so their multiplier will only be slightly reduced). For example it's not uncommon for desktop pages to be slightly wider than 980px, but they would have to additionally have text that spans the full width of the page for this to affect them, and even then it would merely slightly decrease their multiplier). This will have more dramatic effects on the rare desktop pages which give a width=device-width (or similar) mobile viewport tag (on ports which support viewports). A follow-up patch will hopefully address this by wrapping the text in such excessively wide blocks to the layoutWidth. Tests: fast/text-autosizing/narrow-iframe-flattened.html fast/text-autosizing/narrow-iframe.html fast/text-autosizing/wide-block.html fast/text-autosizing/wide-iframe.html * page/FrameView.cpp: (WebCore::FrameView::isInChildFrameWithFrameFlattening): Made public and const, so can be used from TextAutosizer. * rendering/TextAutosizer.cpp: (WebCore::TextAutosizer::processSubtree): Computes the minimum layout width of the parent frames, as described above. (WebCore::TextAutosizer::processBlock): Limits used block width to this min layout width. LayoutTests: Added 4 tests: a block wider than the main frame, iframes both narrower than and wider than the main frame, both also containing wide blocks, and a narrow iframe expanded by frame flattening. I verified experimentally that narrow-iframe-flattened.html passes, by enabling frame flattening in Settings.cpp, but unfortunately it won't get run by any bots since the only platform which currently enables Text Autosizing (Chromium), doesn't enable frame flattening (or have the DRT methods required to test it). * fast/text-autosizing/font-scale-factor-expected.html: * fast/text-autosizing/font-scale-factor.html: * fast/text-autosizing/narrow-iframe-expected.html: Added. * fast/text-autosizing/narrow-iframe-flattened-expected.html: Added. * fast/text-autosizing/narrow-iframe-flattened.html: Added. * fast/text-autosizing/narrow-iframe.html: Added. * fast/text-autosizing/wide-block-expected.html: Added. * fast/text-autosizing/wide-block.html: Added. * fast/text-autosizing/wide-iframe-expected.html: Added. * fast/text-autosizing/wide-iframe.html: Added. * platform/chromium/TestExpectations: * platform/win/Skipped: * platform/wincairo/Skipped: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126058 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
341acfe
commit bb4668f
Showing
19 changed files
with
305 additions
and
8 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
body { | ||
width: 800px; | ||
margin: 0px; | ||
overflow: hidden; | ||
} | ||
</style> | ||
</head> | ||
|
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
19 changes: 19 additions & 0 deletions
19
LayoutTests/fast/text-autosizing/narrow-iframe-expected.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,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 50%; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px; font-size: 1.25rem"> | ||
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></body></html>'> | ||
|
||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
LayoutTests/fast/text-autosizing/narrow-iframe-flattened-expected.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,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 100%; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px; font-size: 2.5rem"> | ||
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></body></html>'> | ||
|
||
</body> | ||
</html> |
30 changes: 30 additions & 0 deletions
30
LayoutTests/fast/text-autosizing/narrow-iframe-flattened.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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
<script type="text/javascript"> | ||
if (window.internals) { | ||
window.internals.settings.setTextAutosizingEnabled(true); | ||
window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480); | ||
} else if (window.console && console.warn) { | ||
console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP."); | ||
} | ||
if (window.testRunner) | ||
testRunner.setFrameFlatteningEnabled(true); | ||
</script> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 50%; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px"> | ||
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></body></html>'> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
<script type="text/javascript"> | ||
if (window.internals) { | ||
window.internals.settings.setTextAutosizingEnabled(true); | ||
window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480); | ||
} else if (window.console && console.warn) { | ||
console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP."); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 50%; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px"> | ||
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></body></html>'> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<div style="width: 1600px; font-size: 2.5rem"> | ||
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> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
<script type="text/javascript"> | ||
if (window.internals) { | ||
window.internals.settings.setTextAutosizingEnabled(true); | ||
window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480); | ||
} else if (window.console && console.warn) { | ||
console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP."); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body> | ||
|
||
<div style="width: 1600px"> | ||
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> | ||
|
||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
LayoutTests/fast/text-autosizing/wide-iframe-expected.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,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 3200px; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px; font-size: 2.5rem"> | ||
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></body></html>'> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<meta name="viewport" content="width=800"> | ||
<style type="text/css"> | ||
body { width: 800px; margin: 0; overflow-y: hidden; } | ||
</style> | ||
|
||
<script type="text/javascript"> | ||
if (window.internals) { | ||
window.internals.settings.setTextAutosizingEnabled(true); | ||
window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480); | ||
} else if (window.console && console.warn) { | ||
console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing, and either use a mobile device with 320px device-width (like Nexus S or iPhone), or define HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP."); | ||
} | ||
</script> | ||
|
||
</head> | ||
<body> | ||
|
||
<iframe style="width: 3200px; height: 50%; border: 0" src='data:text/html, | ||
<html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px"> | ||
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></body></html>'> | ||
|
||
</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
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.