Changeset 129195 in webkit


Ignore:
Timestamp:
Sep 20, 2012 11:20:57 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Text Autosizing: Cluster text at flow roots, for consistency and to avoid autosizing headers/footers.
https://bugs.webkit.org/show_bug.cgi?id=97025

Patch by John Mellor <johnme@chromium.org> on 2012-09-20
Reviewed by Julien Chaffraix.

Source/WebCore:

This patch has 3 main changes:

  1. All text within a "cluster" (roughly equivalent to a CSS flow root / block formatting context) must have a uniform textAutosizingMultiplier, except for subtrees which are themselves clusters. This improves the consistency of the final output, since sibling blocks are now more likely to have the same multiplier (hence grow in proportion).
  1. Clusters must contain a minimum amount of text in order to be autosized (4 lines of text, assuming each char is 1em wide, so about 2 lines of text in practice). This is to reduce the likelihood of autosizing things like headers and footers, which can be quite visually distracting. The rationale is that if a cluster contains very few lines of text then it's ok to have to zoom in and pan from side to side to read each line, since if there are very few lines of text you'll only need to pan across once or twice.
  1. To avoid adding a 3rd tree traversal, processSubtree/processBox were refactored such that all of Text Autosizing now happens as a single tree traversal (hence halving the number of tree traversals done).

Tests: fast/text-autosizing/cluster-narrow-in-wide.html

fast/text-autosizing/cluster-wide-in-narrow.html
fast/text-autosizing/clusters-insufficient-text.html
fast/text-autosizing/clusters-insufficient-width.html
fast/text-autosizing/clusters-sufficient-text-except-in-root.html
fast/text-autosizing/clusters-sufficient-width.html

  • rendering/TextAutosizer.cpp:

(TextAutosizingWindowInfo):

Added this struct to bundle together the various sizes that
processSubtree needs to pass to every recursive call to
processCluster and processContainer.

(WebCore::TextAutosizer::processSubtree):

  • Bundle windowSize and minLayoutSize together as a single struct, TextAutosizingWindowInfo, rather than passing them separately.
  • Walk up the tree to find the current cluster and container, rather than (incorrectly) assuming that the layoutRoot is always a container.
  • Call processCluster instead of traversing the tree.

(WebCore::TextAutosizer::processCluster):

Calculates the multiplier based on the width of the cluster (moved
the calculation here from processBox, since now the multiplier is
fixed per cluster), and delegates to processContainer for the actual
tree traversal (since clusters are also containers).

(WebCore::contentHeightIsConstrained):

Changed parameter to RenderBlock.

(WebCore::TextAutosizer::processContainer):

This now takes care of the whole tree traversal, recursively calling
processCluster/processContainer when it encounters such an object,
and setMultiplier on RenderText objects (as processBox used to).
Also added a check that the RenderText's multiplier is not already
equal to the target multiplier (to save needlessly setting it).

(WebCore::TextAutosizer::isContainer):

  • Changed to be a positive (is) instead of negative (isNot) check.
  • Require objects to be RenderBlocks so it's easier to find them using containingBlock, and there don't seem to be many interesting RenderBoxes that aren't RenderBlocks.

(WebCore::TextAutosizer::isAutosizingCluster):

A container that is also a flow root / block formatting context
(approximately), hence demarcates an independent region of the page,
within which we want consistent autosizing.

(WebCore::TextAutosizer::clusterShouldBeAutosized):

Uses measureDescendantTextWidth and to check whether the cluster
contains enough text to be worth autosizing.

(WebCore::TextAutosizer::measureDescendantTextWidth):

Recursively traverse the cluster, skipping constrained height
containers as processContainer does, to measure how much autosizable
text it contains. Early out as soon as the minimum text width is
reached.

(WebCore::TextAutosizer::nextInPreOrderSkippingDescendantsOfContainers):

Replaces nextInPreOrderMatchingFilter. The filter is now fixed to
isContainer (we no longer need an isAutosizingCluster filter, since
I consolidated the tree traversal), and filtered objects are
actually returned (so they can in turn be recursively traversed),
it's just their descendants that get skipped.

  • rendering/TextAutosizer.h:

(TextAutosizer):

  • Deleted RenderObjectFilterFunctor, since the filter of nextInPreOrderSkippingDescendantsOfContainers is now fixed.

LayoutTests:

Added 6 tests (cluster*.html). Updated various other tests to have
enough text so that they continue to pass, or that if they fail, it's
for the reason that was being tested, not just because clustering
decided they had insufficient text.

  • fast/text-autosizing/cluster-narrow-in-wide-expected.html: Added.
  • fast/text-autosizing/cluster-narrow-in-wide.html: Copied from LayoutTests/fast/text-autosizing/em-margin-border-padding.html.
  • fast/text-autosizing/cluster-wide-in-narrow-expected.html: Added.
  • fast/text-autosizing/cluster-wide-in-narrow.html: Added.
  • fast/text-autosizing/clusters-insufficient-text-expected.html: Added.
  • fast/text-autosizing/clusters-insufficient-text.html: Added.
  • fast/text-autosizing/clusters-insufficient-width-expected.html: Added.
  • fast/text-autosizing/clusters-insufficient-width.html: Added.
  • fast/text-autosizing/clusters-sufficient-text-except-in-root-expected.html: Added.
  • fast/text-autosizing/clusters-sufficient-text-except-in-root.html: Added.
  • fast/text-autosizing/clusters-sufficient-width-expected.html: Added.
  • fast/text-autosizing/clusters-sufficient-width.html: Added.
  • fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html:
  • fast/text-autosizing/constrained-and-overflow-auto-ancestor.html:
  • fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html:
  • fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html:
  • fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html:
  • fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html:
  • fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html:
  • fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html:
  • fast/text-autosizing/constrained-height-ancestor-expected.html:
  • fast/text-autosizing/constrained-height-ancestor.html:
  • fast/text-autosizing/constrained-maxheight-ancestor-expected.html:
  • fast/text-autosizing/constrained-maxheight-ancestor.html:
  • fast/text-autosizing/constrained-maxheight-expected.html:
  • fast/text-autosizing/constrained-maxheight.html:
  • fast/text-autosizing/constrained-percent-maxheight-expected.html:
  • fast/text-autosizing/constrained-percent-maxheight.html:
  • fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html:
  • fast/text-autosizing/constrained-percent-of-viewport-maxheight.html:
  • fast/text-autosizing/constrained-then-overflow-ancestors-expected.html:
  • fast/text-autosizing/constrained-then-overflow-ancestors.html:
  • fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html:
  • fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html:
  • fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html:
  • fast/text-autosizing/constrained-then-position-absolute-ancestors.html:
  • fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html:
  • fast/text-autosizing/constrained-then-position-fixed-ancestors.html:
  • fast/text-autosizing/constrained-within-overflow-ancestor-expected.html:
  • fast/text-autosizing/constrained-within-overflow-ancestor.html:
  • fast/text-autosizing/em-margin-border-padding-expected.html:
  • fast/text-autosizing/em-margin-border-padding.html:
  • fast/text-autosizing/narrow-child-expected.html:
  • fast/text-autosizing/narrow-child.html:
  • fast/text-autosizing/wide-child-expected.html:
  • fast/text-autosizing/wide-child.html:
  • fast/text-autosizing/wide-iframe-expected.html:
  • fast/text-autosizing/wide-iframe.html:
Location:
trunk
Files:
11 added
42 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r129194 r129195  
     12012-09-20  John Mellor  <johnme@chromium.org>
     2
     3        Text Autosizing: Cluster text at flow roots, for consistency and to avoid autosizing headers/footers.
     4        https://bugs.webkit.org/show_bug.cgi?id=97025
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Added 6 tests (cluster*.html). Updated various other tests to have
     9        enough text so that they continue to pass, or that if they fail, it's
     10        for the reason that was being tested, not just because clustering
     11        decided they had insufficient text.
     12
     13        * fast/text-autosizing/cluster-narrow-in-wide-expected.html: Added.
     14        * fast/text-autosizing/cluster-narrow-in-wide.html: Copied from LayoutTests/fast/text-autosizing/em-margin-border-padding.html.
     15        * fast/text-autosizing/cluster-wide-in-narrow-expected.html: Added.
     16        * fast/text-autosizing/cluster-wide-in-narrow.html: Added.
     17        * fast/text-autosizing/clusters-insufficient-text-expected.html: Added.
     18        * fast/text-autosizing/clusters-insufficient-text.html: Added.
     19        * fast/text-autosizing/clusters-insufficient-width-expected.html: Added.
     20        * fast/text-autosizing/clusters-insufficient-width.html: Added.
     21        * fast/text-autosizing/clusters-sufficient-text-except-in-root-expected.html: Added.
     22        * fast/text-autosizing/clusters-sufficient-text-except-in-root.html: Added.
     23        * fast/text-autosizing/clusters-sufficient-width-expected.html: Added.
     24        * fast/text-autosizing/clusters-sufficient-width.html: Added.
     25        * fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html:
     26        * fast/text-autosizing/constrained-and-overflow-auto-ancestor.html:
     27        * fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html:
     28        * fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html:
     29        * fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html:
     30        * fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html:
     31        * fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html:
     32        * fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html:
     33        * fast/text-autosizing/constrained-height-ancestor-expected.html:
     34        * fast/text-autosizing/constrained-height-ancestor.html:
     35        * fast/text-autosizing/constrained-maxheight-ancestor-expected.html:
     36        * fast/text-autosizing/constrained-maxheight-ancestor.html:
     37        * fast/text-autosizing/constrained-maxheight-expected.html:
     38        * fast/text-autosizing/constrained-maxheight.html:
     39        * fast/text-autosizing/constrained-percent-maxheight-expected.html:
     40        * fast/text-autosizing/constrained-percent-maxheight.html:
     41        * fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html:
     42        * fast/text-autosizing/constrained-percent-of-viewport-maxheight.html:
     43        * fast/text-autosizing/constrained-then-overflow-ancestors-expected.html:
     44        * fast/text-autosizing/constrained-then-overflow-ancestors.html:
     45        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html:
     46        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html:
     47        * fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html:
     48        * fast/text-autosizing/constrained-then-position-absolute-ancestors.html:
     49        * fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html:
     50        * fast/text-autosizing/constrained-then-position-fixed-ancestors.html:
     51        * fast/text-autosizing/constrained-within-overflow-ancestor-expected.html:
     52        * fast/text-autosizing/constrained-within-overflow-ancestor.html:
     53        * fast/text-autosizing/em-margin-border-padding-expected.html:
     54        * fast/text-autosizing/em-margin-border-padding.html:
     55        * fast/text-autosizing/narrow-child-expected.html:
     56        * fast/text-autosizing/narrow-child.html:
     57        * fast/text-autosizing/wide-child-expected.html:
     58        * fast/text-autosizing/wide-child.html:
     59        * fast/text-autosizing/wide-iframe-expected.html:
     60        * fast/text-autosizing/wide-iframe.html:
     61
    1622012-09-20  Yury Semikhatsky  <yurys@chromium.org>
    263
  • trunk/LayoutTests/fast/text-autosizing/cluster-narrow-in-wide.html

    r129194 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
    10 <script type="text/javascript">
     11<script>
    1112if (window.internals) {
    1213    window.internals.settings.setTextAutosizingEnabled(true);
     
    2021<body>
    2122
    22 <p style="margin: 1em; border: 1em solid blue; padding: 1em">
     23<div style="width: 400px; float: left">
     24    This text should be autosized to just 20px computed font size (16 * 400/320), since the float:left causes this to be a new cluster, and it is only 400px wide.
     25</div>
     26
     27<div style="width: 320px">
     28    This text should be autosized to 40px computed font-size (16 * 800/320), since despite its width:320px it is part of the 800px wide root cluster.
     29</div>
     30
     31<div>
     32    This text should similarly be autosized to 40px.<br>
    2333    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.
    24 </p>
     34</div>
    2535
    2636</body>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
     
    1515    <div>
    1616        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:auto means the available height is unconstrained (despite the grandparent also having a max-height).
     17            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:auto means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-auto-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div>
    2525        <div>
    26             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:auto means the available height is unconstrained (despite the grandparent also having a max-height).
     26            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:auto means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1515    <div>
    1616        <div>
    17             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height (the grandparent's overflow-y:hidden doesn't prevent this, as hidden doesn't extend the available content height).
     17            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height (the grandparent's overflow-y:hidden doesn't prevent this, as hidden doesn't extend the available content height).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div>
    2525        <div>
    26             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height (the grandparent's overflow-y:hidden doesn't prevent this, as hidden doesn't extend the available content height).
     26            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height (the grandparent's overflow-y:hidden doesn't prevent this, as hidden doesn't extend the available content height).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
     
    1515    <div>
    1616        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:-webkit-paged-x means the available height is unconstrained (despite the grandparent also having a max-height).
     17            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:-webkit-paged-x means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div>
    2525        <div>
    26             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:-webkit-paged-x means the available height is unconstrained (despite the grandparent also having a max-height).
     26            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:-webkit-paged-x means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99::-webkit-scrollbar {
    1010    /* Keeps the text size multiplier a round number. */
     
    1919    <div>
    2020        <div style="font-size: 2.5rem">
    21             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:scroll means the available height is unconstrained (despite the grandparent also having a max-height).
     21            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:scroll means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     22            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.
    2223        </div>
    2324    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99::-webkit-scrollbar {
    1010    /* Keeps the text size multiplier a round number. */
     
    1313</style>
    1414
    15 <script type="text/javascript">
     15<script>
    1616if (window.internals) {
    1717    window.internals.settings.setTextAutosizingEnabled(true);
     
    2828    <div>
    2929        <div>
    30             This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:scroll means the available height is unconstrained (despite the grandparent also having a max-height).
     30            This text should be autosized to 40px computed font-size, since the grandparent's overflow-y:scroll means the available height is unconstrained (despite the grandparent also having a max-height).<br>
     31            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.
    3132        </div>
    3233    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-height-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1515    <div>
    1616        <div>
    17             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's height.
     17            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's height.<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-height-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div>
    2525        <div>
    26             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's height.
     26            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's height.<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-height-body-expected.html

    r128927 r129195  
    1313
    1414<div style="font-size: 2.5rem">
    15     This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).
     15    This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).<br>
     16        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.
    1617</div>
    1718
  • trunk/LayoutTests/fast/text-autosizing/constrained-height-body.html

    r128927 r129195  
    2222
    2323<div>
    24         This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).
     24        This text should be autosized to 40px computed font-size, since the constrained height on the html and body elements gets ignored (a hack to fix some sites that appear to set this accidentally).<br>
     25        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.
    2526</div>
    2627
  • trunk/LayoutTests/fast/text-autosizing/constrained-maxheight-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1515    <div>
    1616        <div>
    17             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height.
     17            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height.<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-maxheight-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div>
    2525        <div>
    26             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height.
     26            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the grandparent's max-height.<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-maxheight-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1313
    1414<div style="max-height: 500px">
    15     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height.
     15    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height.<br>
     16    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.
    1617</div>
    1718
  • trunk/LayoutTests/fast/text-autosizing/constrained-maxheight.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2222
    2323<div style="max-height: 500px">
    24     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height.
     24    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height.<br>
     25    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.
    2526</div>
    2627
  • trunk/LayoutTests/fast/text-autosizing/constrained-percent-maxheight-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1313
    1414<div style="max-height: 100%">
    15     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a percentage).
     15    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a percentage).<br>
     16    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.
    1617</div>
    1718
  • trunk/LayoutTests/fast/text-autosizing/constrained-percent-maxheight.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2222
    2323<div style="max-height: 100%">
    24     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a percentage).
     24    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a percentage).<br>
     25    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.
    2526</div>
    2627
  • trunk/LayoutTests/fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1313
    1414<div style="max-height: 100vh">
    15     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a viewport percentage).
     15    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a viewport percentage).<br>
     16    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.
    1617</div>
    1718
  • trunk/LayoutTests/fast/text-autosizing/constrained-percent-of-viewport-maxheight.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2222
    2323<div style="max-height: 100vh">
    24     This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a viewport percentage).
     24    This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the block's max-height (provided as a viewport percentage).<br>
     25    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.
    2526</div>
    2627
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors-expected.html

    r128927 r129195  
    1515    <div style="float: left">
    1616        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).
     17            This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-float-ancestors.html

    r128927 r129195  
    2424    <div style="float: left">
    2525        <div>
    26             This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).
     26            This text should be autosized to 40px computed font-size, since the parent is float:left so the height is considered to be unconstrained (ancestors of the parent are ignored).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-ancestors-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
     
    1515    <div style="overflow-y: auto">
    1616        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the parent's overflow-y:auto means the available height is unconstrained (despite the grandparent having a max-height).
     17            This text should be autosized to 40px computed font-size, since the parent's overflow-y:auto means the available height is unconstrained (despite the grandparent having a max-height).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-overflow-ancestors.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    8 body { width: 800px; margin: 0; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div style="overflow-y: auto">
    2525        <div>
    26             This text should be autosized to 40px computed font-size, since the parent's overflow-y:auto means the available height is unconstrained (despite the grandparent having a max-height).
     26            This text should be autosized to 40px computed font-size, since the parent's overflow-y:auto means the available height is unconstrained (despite the grandparent having a max-height).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html

    r128927 r129195  
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     9::-webkit-scrollbar {
     10    /* Keeps the text size multiplier a round number. */
     11    width: 0px;
     12}
    913</style>
    1014
     
    1519    <div style="position: absolute">
    1620        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).
     21            This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).<br>
     22            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.
    1823        </div>
    1924    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-position-absolute-ancestors.html

    r128927 r129195  
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     9::-webkit-scrollbar {
     10    /* Keeps the text size multiplier a round number. */
     11    width: 0px;
     12}
    913</style>
    1014
     
    2428    <div style="position: absolute">
    2529        <div>
    26             This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).
     30            This text should be autosized to 40px computed font-size, since the parent is position:absolute so the height is considered to be unconstrained (ancestors of the parent are ignored, even if they have position:relative).<br>
     31            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.
    2732        </div>
    2833    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html

    r128927 r129195  
    1515    <div style="position: fixed">
    1616        <div style="font-size: 2.5rem">
    17             This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).
     17            This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-then-position-fixed-ancestors.html

    r128927 r129195  
    2424    <div style="position: fixed">
    2525        <div>
    26             This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).
     26            This text should be autosized to 40px computed font-size, since the parent is position:fixed so the height is considered to be unconstrained (ancestors of the parent are ignored).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-within-overflow-ancestor-expected.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
     
    1515    <div style="max-height: 500px">
    1616        <div>
    17             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the parent's max-height (the grandparent's overflow-y:auto doesn't prevent this).
     17            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the parent's max-height (the grandparent's overflow-y:auto doesn't prevent this).<br>
     18            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.
    1819        </div>
    1920    </div>
  • trunk/LayoutTests/fast/text-autosizing/constrained-within-overflow-ancestor.html

    r128317 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
     6<style>
    77html { font-size: 16px; }
    88body { width: 800px; margin: 0; }
    99</style>
    1010
    11 <script type="text/javascript">
     11<script>
    1212if (window.internals) {
    1313    window.internals.settings.setTextAutosizingEnabled(true);
     
    2424    <div style="max-height: 500px">
    2525        <div>
    26             This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the parent's max-height (the grandparent's overflow-y:auto doesn't prevent this).
     26            This text should not be autosized (its computed font-size should remain 16px), as autosizing usually causes text to wrap onto more lines, which might cause it to overflow the parent's max-height (the grandparent's overflow-y:auto doesn't prevent this).<br>
     27            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.
    2728        </div>
    2829    </div>
  • trunk/LayoutTests/fast/text-autosizing/em-margin-border-padding-expected.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
     
    1112<body>
    1213
    13 <!-- Note that em margins, borders and padding do not get scaled in proportion
    14      to the font size. While unusual, this probably looks more consistent. -->
    15 <p style="font-size: 2.375rem; margin: 1rem; border: 1rem solid blue; padding: 1rem">
    16     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.
     14<p style="font-size: 2.5rem; margin: 1rem; border: 1rem solid blue; padding: 1rem">
     15    This text should get autosized to 40px computed font size, but the 1em margins, borders and padding should remain just 16px. While debatable, this generally looks more consistent than having them be scaled.<br>
     16    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.
    1717</p>
    1818
  • trunk/LayoutTests/fast/text-autosizing/em-margin-border-padding.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
    10 <script type="text/javascript">
     11<script>
    1112if (window.internals) {
    1213    window.internals.settings.setTextAutosizingEnabled(true);
     
    2122
    2223<p style="margin: 1em; border: 1em solid blue; padding: 1em">
    23     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.
     24    This text should get autosized to 40px computed font size, but the 1em margins, borders and padding should remain just 16px. While debatable, this generally looks more consistent than having them be scaled.<br>
     25    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.
    2426</p>
    2527
  • trunk/LayoutTests/fast/text-autosizing/narrow-child-expected.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
     
    1213
    1314<div style="font-size: 2.5rem">
    14     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    15     <div style="width: 320px; font-size: 1rem">
     15    This text should all be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
     16    <div style="width: 320px">
    1617        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    1718    </div>
  • trunk/LayoutTests/fast/text-autosizing/narrow-child.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
    10 <script type="text/javascript">
     11<script>
    1112if (window.internals) {
    1213    window.internals.settings.setTextAutosizingEnabled(true);
     
    2122
    2223<div>
    23     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     24    This text should all be autosized to 40px computed font-size, since although this has a narrow child block, the cluster will still be wide and need autosizing.
    2425    <div style="width: 320px">
    2526        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  • trunk/LayoutTests/fast/text-autosizing/wide-child-expected.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
     
    1112<body>
    1213
    13 <div style="width: 320px">
    14     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    15     <div style="width: 800px; font-size: 2.5rem">
     14<div style="width: 320px; font-size: 2.5rem">
     15    This text should all be autosized to 40px computed font-size, since although this block is narrow, it has a wide child block, so the cluster will be wide and need autosizing.
     16    <div style="width: 800px">
    1617        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    1718    </div>
  • trunk/LayoutTests/fast/text-autosizing/wide-child.html

    r125925 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; }
     6<style>
     7html { font-size: 16px; }
     8body { width: 800px; margin: 0; overflow-y: hidden; }
    89</style>
    910
    10 <script type="text/javascript">
     11<script>
    1112if (window.internals) {
    1213    window.internals.settings.setTextAutosizingEnabled(true);
     
    2122
    2223<div style="width: 320px">
    23     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
     24    This text should all be autosized to 40px computed font-size, since although this block is narrow, it has a wide child block, so the cluster will be wide and need autosizing.
    2425    <div style="width: 800px">
    2526        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
  • trunk/LayoutTests/fast/text-autosizing/wide-iframe-expected.html

    r126058 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; overflow-y: hidden; }
     6<style>
     7body { width: 800px; margin: 0; }
    88</style>
    99
     
    1212
    1313<iframe style="width: 3200px; height: 50%; border: 0" src='data:text/html,
    14 <html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px; font-size: 2.5rem">
    15 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.
     14<html style="font-size: 16px"><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px; font-size: 2.5rem">
     15This text should be autosized to just 40px computed font size, i.e. scaled up by 2.5x, since although this block is 1600px wide and is in a 3200px wide iframe, the top level frame is only 800px wide, and min(1600, 3200, 800) / 320 = 2.5.<br>
     16Lorem 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. 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.
    1617</div></body></html>'>
    1718
  • trunk/LayoutTests/fast/text-autosizing/wide-iframe.html

    r126058 r129195  
    44
    55<meta name="viewport" content="width=800">
    6 <style type="text/css">
    7 body { width: 800px; margin: 0; overflow-y: hidden; }
     6<style>
     7body { width: 800px; margin: 0; }
    88</style>
    99
    10 <script type="text/javascript">
     10<script>
    1111if (window.internals) {
    1212    window.internals.settings.setTextAutosizingEnabled(true);
     
    2121
    2222<iframe style="width: 3200px; height: 50%; border: 0" src='data:text/html,
    23 <html><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px">
    24 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.
     23<html style="font-size: 16px"><body style="margin: 0; overflow-y: hidden"><div style="width: 1600px">
     24This text should be autosized to just 40px computed font size, i.e. scaled up by 2.5x, since although this block is 1600px wide and is in a 3200px wide iframe, the top level frame is only 800px wide, and min(1600, 3200, 800) / 320 = 2.5.<br>
     25Lorem 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. 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.
    2526</div></body></html>'>
    2627
  • trunk/Source/WebCore/ChangeLog

    r129191 r129195  
     12012-09-20  John Mellor  <johnme@chromium.org>
     2
     3        Text Autosizing: Cluster text at flow roots, for consistency and to avoid autosizing headers/footers.
     4        https://bugs.webkit.org/show_bug.cgi?id=97025
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        This patch has 3 main changes:
     9
     10        1. All text within a "cluster" (roughly equivalent to a CSS flow root /
     11           block formatting context) must have a uniform textAutosizingMultiplier,
     12           except for subtrees which are themselves clusters. This improves the
     13           consistency of the final output, since sibling blocks are now more
     14           likely to have the same multiplier (hence grow in proportion).
     15
     16        2. Clusters must contain a minimum amount of text in order to be
     17           autosized (4 lines of text, assuming each char is 1em wide, so about
     18           2 lines of text in practice). This is to reduce the likelihood of
     19           autosizing things like headers and footers, which can be quite
     20           visually distracting. The rationale is that if a cluster contains
     21           very few lines of text then it's ok to have to zoom in and pan from
     22           side to side to read each line, since if there are very few lines of
     23           text you'll only need to pan across once or twice.
     24
     25        3. To avoid adding a 3rd tree traversal, processSubtree/processBox were
     26           refactored such that all of Text Autosizing now happens as a single
     27           tree traversal (hence halving the number of tree traversals done).
     28
     29        Tests: fast/text-autosizing/cluster-narrow-in-wide.html
     30               fast/text-autosizing/cluster-wide-in-narrow.html
     31               fast/text-autosizing/clusters-insufficient-text.html
     32               fast/text-autosizing/clusters-insufficient-width.html
     33               fast/text-autosizing/clusters-sufficient-text-except-in-root.html
     34               fast/text-autosizing/clusters-sufficient-width.html
     35
     36        * rendering/TextAutosizer.cpp:
     37        (TextAutosizingWindowInfo):
     38
     39            Added this struct to bundle together the various sizes that
     40            processSubtree needs to pass to every recursive call to
     41            processCluster and processContainer.
     42
     43        (WebCore::TextAutosizer::processSubtree):
     44
     45            - Bundle windowSize and minLayoutSize together as a single struct,
     46              TextAutosizingWindowInfo, rather than passing them separately.
     47            - Walk up the tree to find the current cluster and container, rather
     48              than (incorrectly) assuming that the layoutRoot is always a
     49              container.
     50            - Call processCluster instead of traversing the tree.
     51
     52        (WebCore::TextAutosizer::processCluster):
     53
     54            Calculates the multiplier based on the width of the cluster (moved
     55            the calculation here from processBox, since now the multiplier is
     56            fixed per cluster), and delegates to processContainer for the actual
     57            tree traversal (since clusters are also containers).
     58
     59        (WebCore::contentHeightIsConstrained):
     60
     61            Changed parameter to RenderBlock.
     62
     63        (WebCore::TextAutosizer::processContainer):
     64
     65            This now takes care of the whole tree traversal, recursively calling
     66            processCluster/processContainer when it encounters such an object,
     67            and setMultiplier on RenderText objects (as processBox used to).
     68            Also added a check that the RenderText's multiplier is not already
     69            equal to the target multiplier (to save needlessly setting it).
     70
     71        (WebCore::TextAutosizer::isContainer):
     72
     73            - Changed to be a positive (is) instead of negative (isNot) check.
     74            - Require objects to be RenderBlocks so it's easier to find them
     75              using containingBlock, and there don't seem to be many interesting
     76              RenderBoxes that aren't RenderBlocks.
     77
     78        (WebCore::TextAutosizer::isAutosizingCluster):
     79
     80            A container that is also a flow root / block formatting context
     81            (approximately), hence demarcates an independent region of the page,
     82            within which we want consistent autosizing.
     83
     84        (WebCore::TextAutosizer::clusterShouldBeAutosized):
     85
     86            Uses measureDescendantTextWidth and to check whether the cluster
     87            contains enough text to be worth autosizing.
     88
     89        (WebCore::TextAutosizer::measureDescendantTextWidth):
     90
     91            Recursively traverse the cluster, skipping constrained height
     92            containers as processContainer does, to measure how much autosizable
     93            text it contains. Early out as soon as the minimum text width is
     94            reached.
     95
     96        (WebCore::TextAutosizer::nextInPreOrderSkippingDescendantsOfContainers):
     97
     98            Replaces nextInPreOrderMatchingFilter. The filter is now fixed to
     99            isContainer (we no longer need an isAutosizingCluster filter, since
     100            I consolidated the tree traversal), and filtered objects are
     101            actually returned (so they can in turn be recursively traversed),
     102            it's just their descendants that get skipped.
     103
     104        * rendering/TextAutosizer.h:
     105        (TextAutosizer):
     106
     107            - Deleted RenderObjectFilterFunctor, since the filter of
     108              nextInPreOrderSkippingDescendantsOfContainers is now fixed.
     109
    11102012-09-20  Yoshifumi Inoue  <yosin@chromium.org>
    2111
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r128927 r129195  
    3636namespace WebCore {
    3737
     38struct TextAutosizingWindowInfo {
     39    IntSize windowSize;
     40    IntSize minLayoutSize;
     41};
     42
    3843TextAutosizer::TextAutosizer(Document* document)
    3944    : m_document(document)
     
    5459    Frame* mainFrame = m_document->page()->mainFrame();
    5560
     61    TextAutosizingWindowInfo windowInfo;
     62
    5663    // Window area, in logical (density-independent) pixels.
    57     IntSize windowSize = m_document->settings()->textAutosizingWindowSizeOverride();
    58     if (windowSize.isEmpty()) {
     64    windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOverride();
     65    if (windowInfo.windowSize.isEmpty()) {
    5966        bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(mainFrame);
    60         windowSize = mainFrame->view()->visibleContentRect(includeScrollbars).size(); // FIXME: Check that this is always in logical (density-independent) pixels (see wkbug.com/87440).
     67        windowInfo.windowSize = mainFrame->view()->visibleContentRect(includeScrollbars).size(); // FIXME: Check that this is always in logical (density-independent) pixels (see wkbug.com/87440).
    6168    }
    6269
    6370    // Largest area of block that can be visible at once (assuming the main
    6471    // frame doesn't get scaled to less than overview scale), in CSS pixels.
    65     IntSize minLayoutSize = mainFrame->view()->layoutSize();
     72    windowInfo.minLayoutSize = mainFrame->view()->layoutSize();
    6673    for (Frame* frame = m_document->frame(); frame; frame = frame->tree()->parent()) {
    6774        if (!frame->view()->isInChildFrameWithFrameFlattening())
    68             minLayoutSize = minLayoutSize.shrunkTo(frame->view()->layoutSize());
    69     }
    70 
    71     for (RenderObject* descendant = layoutRoot->nextInPreOrder(layoutRoot); descendant; descendant = descendant->nextInPreOrder(layoutRoot)) {
    72         if (isNotAnAutosizingContainer(descendant))
    73             continue;
    74         processBox(toRenderBox(descendant), windowSize, minLayoutSize);
    75     }
    76 
     75            windowInfo.minLayoutSize = windowInfo.minLayoutSize.shrunkTo(frame->view()->layoutSize());
     76    }
     77
     78    // The layoutRoot could be neither a container nor a cluster, so walk up the tree till we find each of these.
     79    RenderBlock* container = layoutRoot->isRenderBlock() ? toRenderBlock(layoutRoot) : layoutRoot->containingBlock();
     80    while (container && !isAutosizingContainer(container))
     81        container = container->containingBlock();
     82
     83    RenderBlock* cluster = container;
     84    while (cluster && (!isAutosizingContainer(cluster) || !isAutosizingCluster(cluster)))
     85        cluster = cluster->containingBlock();
     86
     87    processCluster(cluster, container, layoutRoot, windowInfo);
    7788    return true;
    7889}
    7990
    80 static bool contentHeightIsConstrained(const RenderBox* box)
     91void TextAutosizer::processCluster(RenderBlock* cluster, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
     92{
     93    ASSERT(isAutosizingCluster(cluster));
     94
     95    // FIXME: Many pages set a max-width on their content. So especially for the RenderView,
     96    // instead of just taking the width of |cluster| we should find the lowest common ancestor of
     97    // the first and last descendant text node of the cluster (i.e. the deepest wrapper block that
     98    // contains all the text), and use its width instead.
     99    RenderBlock* lowestCommonAncestor = cluster;
     100    float commonAncestorWidth = lowestCommonAncestor->contentLogicalWidth();
     101
     102    float multiplier = 1;
     103    if (clusterShouldBeAutosized(lowestCommonAncestor, commonAncestorWidth)) {
     104        int logicalWindowWidth = cluster->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
     105        int logicalLayoutWidth = cluster->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
     106        // Ignore box width in excess of the layout width, to avoid extreme multipliers.
     107        float logicalClusterWidth = std::min<float>(commonAncestorWidth, logicalLayoutWidth);
     108
     109        multiplier = logicalClusterWidth / logicalWindowWidth;
     110        multiplier *= m_document->settings()->textAutosizingFontScaleFactor();
     111        multiplier = std::max(1.0f, multiplier);
     112    }
     113
     114    processContainer(multiplier, container, subtreeRoot, windowInfo);
     115}
     116
     117static bool contentHeightIsConstrained(const RenderBlock* container)
    81118{
    82119    // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.
    83120    // FIXME: This code needs to take into account vertical writing modes.
    84121    // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
    85     for (const RenderBox* container = box; container; container = container->containingBlock()) {
     122    for (; container; container = container->containingBlock()) {
    86123        RenderStyle* style = container->style();
    87124        if (style->overflowY() >= OSCROLL)
     
    98135}
    99136
    100 void TextAutosizer::processBox(RenderBox* box, const IntSize& windowSize, const IntSize& layoutSize)
    101 {
    102     if (contentHeightIsConstrained(box))
    103         return;
    104 
    105     int logicalWindowWidth = box->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
    106     int logicalLayoutWidth = box->isHorizontalWritingMode() ? layoutSize.width() : layoutSize.height();
    107     // Ignore box width in excess of the layout width, to avoid extreme multipliers.
    108     float logicalBoxWidth = std::min<float>(box->logicalWidth(), logicalLayoutWidth);
    109 
    110     float multiplier = logicalBoxWidth / logicalWindowWidth;
    111     multiplier *= m_document->settings()->textAutosizingFontScaleFactor();
    112 
    113     if (multiplier < 1)
    114         return;
    115     RenderObject* descendant = nextInPreOrderMatchingFilter(box, box, isNotAnAutosizingContainer);
     137void TextAutosizer::processContainer(float multiplier, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
     138{
     139    ASSERT(isAutosizingContainer(container));
     140
     141    float localMultiplier = contentHeightIsConstrained(container) ? 1 : multiplier;
     142
     143    RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(subtreeRoot, subtreeRoot);
    116144    while (descendant) {
    117145        if (descendant->isText()) {
    118             setMultiplier(descendant, multiplier);
    119             setMultiplier(descendant->parent(), multiplier); // Parent does line spacing.
     146            if (localMultiplier != descendant->style()->textAutosizingMultiplier()) {
     147                setMultiplier(descendant, localMultiplier);
     148                setMultiplier(descendant->parent(), localMultiplier); // Parent does line spacing.
     149            }
    120150            // FIXME: Increase list marker size proportionately.
     151        } else if (isAutosizingContainer(descendant)) {
     152            RenderBlock* descendantBlock = toRenderBlock(descendant);
     153            if (isAutosizingCluster(descendantBlock))
     154                processCluster(descendantBlock, descendantBlock, descendantBlock, windowInfo);
     155            else
     156                processContainer(multiplier, descendantBlock, descendantBlock, windowInfo);
    121157        }
    122         descendant = nextInPreOrderMatchingFilter(descendant, box, isNotAnAutosizingContainer);
     158        descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, subtreeRoot);
    123159    }
    124160}
     
    159195}
    160196
    161 bool TextAutosizer::isNotAnAutosizingContainer(const RenderObject* renderer)
    162 {
    163     // "Autosizing containers" are the smallest unit for which we can enable/disable
    164     // Text Autosizing. A uniform text size multiplier is enforced within them.
    165     // - Must be RenderBoxes since they need a well-defined logicalWidth().
     197bool TextAutosizer::isAutosizingContainer(const RenderObject* renderer)
     198{
     199    // "Autosizing containers" are the smallest unit for which we can
     200    // enable/disable Text Autosizing.
    166201    // - Must not be inline, as different multipliers on one line looks terrible.
    167202    // - Must not be list items, as items in the same list should look consistent.
    168     return !renderer->isBox() || renderer->isInline() || renderer->isListItem();
    169 }
    170 
    171 RenderObject* TextAutosizer::nextInPreOrderMatchingFilter(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilterFunctor filter)
    172 {
    173     for (RenderObject* child = current->firstChild(); child; child = child->nextSibling())
    174         if (filter(child))
     203    return renderer->isRenderBlock() && !renderer->isInline() && !renderer->isListItem();
     204}
     205
     206bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer)
     207{
     208    // "Autosizing clusters" are special autosizing containers within which we
     209    // want to enforce a uniform text size multiplier, in the hopes of making
     210    // the major sections of the page look internally consistent.
     211    // All their descendents (including other autosizing containers) must share
     212    // the same multiplier, except for subtrees which are themselves clusters,
     213    // and some of their descendent containers might not be autosized at all
     214    // (for example if their height is constrained).
     215    // Additionally, clusterShouldBeAutosized requires each cluster to contain a
     216    // minimum amount of text, without which it won't be autosized.
     217    //
     218    // Clusters are chosen using very similar criteria to CSS flow roots, aka
     219    // block formatting contexts (http://w3.org/TR/css3-box/#flow-root), since
     220    // flow roots correspond to box containers that behave somewhat
     221    // independently from their parent (for example they don't overlap floats).
     222    // The definition of a flow flow root also conveniently includes most of the
     223    // ways that a box and its children can have significantly different width
     224    // from the box's parent (we want to avoid having significantly different
     225    // width blocks within a cluster, since the narrower blocks would end up
     226    // larger than would otherwise be necessary).
     227    ASSERT(isAutosizingContainer(renderer));
     228
     229    return renderer->isRenderView()
     230        || renderer->isFloating()
     231        || renderer->isOutOfFlowPositioned()
     232        || renderer->isTableCell()
     233        || renderer->isTableCaption()
     234        || renderer->isFlexibleBoxIncludingDeprecated()
     235        || renderer->hasColumns()
     236        || renderer->style()->overflowX() != OVISIBLE
     237        || renderer->style()->overflowY() != OVISIBLE
     238        || renderer->containingBlock()->isHorizontalWritingMode() != renderer->isHorizontalWritingMode();
     239    // FIXME: Tables need special handling to multiply all their columns by
     240    // the same amount even if they're different widths; so do hasColumns()
     241    // renderers, and probably flexboxes...
     242}
     243
     244bool TextAutosizer::clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth)
     245{
     246    // Don't autosize clusters that contain less than 4 lines of text (in
     247    // practice less lines are required, since measureDescendantTextWidth
     248    // assumes that characters are 1em wide, but most characters are narrower
     249    // than that, so we're overestimating their contribution to the linecount).
     250    //
     251    // This is to reduce the likelihood of autosizing things like headers and
     252    // footers, which can be quite visually distracting. The rationale is that
     253    // if a cluster contains very few lines of text then it's ok to have to zoom
     254    // in and pan from side to side to read each line, since if there are very
     255    // few lines of text you'll only need to pan across once or twice.
     256    const float minLinesOfText = 4;
     257    float minTextWidth = commonAncestorWidth * minLinesOfText;
     258    float textWidth = 0;
     259    measureDescendantTextWidth(lowestCommonAncestor, minTextWidth, textWidth);
     260    if (textWidth >= minTextWidth)
     261        return true;
     262    return false;
     263}
     264
     265void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth)
     266{
     267    bool skipLocalText = contentHeightIsConstrained(container);
     268
     269    RenderObject* descendant = nextInPreOrderSkippingDescendantsOfContainers(container, container);
     270    while (descendant) {
     271        if (!skipLocalText && descendant->isText()) {
     272            textWidth += toRenderText(descendant)->renderedTextLength() * descendant->style()->specifiedFontSize();
     273        } else if (isAutosizingContainer(descendant)) {
     274            RenderBlock* descendantBlock = toRenderBlock(descendant);
     275            if (!isAutosizingCluster(descendantBlock))
     276                measureDescendantTextWidth(descendantBlock, minTextWidth, textWidth);
     277        }
     278        if (textWidth >= minTextWidth)
     279            return;
     280        descendant = nextInPreOrderSkippingDescendantsOfContainers(descendant, container);
     281    }
     282}
     283
     284RenderObject* TextAutosizer::nextInPreOrderSkippingDescendantsOfContainers(const RenderObject* current, const RenderObject* stayWithin)
     285{
     286    if (current == stayWithin || !isAutosizingContainer(current))
     287        for (RenderObject* child = current->firstChild(); child; child = child->nextSibling())
    175288            return child;
    176289
     
    179292            return 0;
    180293        for (RenderObject* sibling = ancestor->nextSibling(); sibling; sibling = sibling->nextSibling())
    181             if (filter(sibling))
    182                 return sibling;
     294            return sibling;
    183295    }
    184296
  • trunk/Source/WebCore/rendering/TextAutosizer.h

    r126816 r129195  
    3737
    3838class Document;
    39 class RenderBox;
     39class RenderBlock;
    4040class RenderObject;
    4141class RenderStyle;
    4242class RenderText;
     43struct TextAutosizingWindowInfo;
    4344
    4445class TextAutosizer {
     
    5758    explicit TextAutosizer(Document*);
    5859
    59     void processBox(RenderBox*, const IntSize& windowSize, const IntSize& layoutSize);
     60    void processCluster(RenderBlock* cluster, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
     61    void processContainer(float multiplier, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
     62
    6063    void setMultiplier(RenderObject*, float);
    6164
    62     static bool isNotAnAutosizingContainer(const RenderObject*);
     65    static bool isAutosizingContainer(const RenderObject*);
     66    static bool isAutosizingCluster(const RenderBlock*);
    6367
    64     typedef bool (*RenderObjectFilterFunctor)(const RenderObject*);
    65     // Use to traverse the tree of descendants, excluding any subtrees within that whose root doesn't pass the filter.
    66     static RenderObject* nextInPreOrderMatchingFilter(RenderObject* current, const RenderObject* stayWithin, RenderObjectFilterFunctor);
     68    static bool clusterShouldBeAutosized(const RenderBlock* lowestCommonAncestor, float commonAncestorWidth);
     69    static void measureDescendantTextWidth(const RenderBlock* container, float minTextWidth, float& textWidth);
     70
     71    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
     72    static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const RenderObject* current, const RenderObject* stayWithin);
    6773
    6874    Document* m_document;
Note: See TracChangeset for help on using the changeset viewer.