|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
2. 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.
3. 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:
git-svn-id: svn://svn.chromium.org/blink/trunk@129195 bbb929c8-8fbe-4397-9dbb-9b2b20218538
|
|
https://bugs.webkit.org/show_bug.cgi?id=96143
Patch by John Mellor <johnme@chromium.org> on 2012-09-12
Reviewed by Julien Chaffraix.
Source/WebCore:
Autosizing text within constained height elements usually goes badly,
as the autosized text will wrap onto more lines, hence it will become
taller and often overflow its container, breaking the page's layout.
This patch disables autosizing for blocks with a fixed height ancestor
(or which are fixed height themselves), unless the lowest such ancestor
(or one of the ancestors in between it and the text block) has
overflow-y:auto/scroll, in which case the height isn't really fixed.
Tests: fast/text-autosizing/constrained-and-overflow-auto-ancestor.html
fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html
fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html
fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html
fast/text-autosizing/constrained-height-ancestor.html
fast/text-autosizing/constrained-maxheight-ancestor.html
fast/text-autosizing/constrained-maxheight.html
fast/text-autosizing/constrained-percent-maxheight.html
fast/text-autosizing/constrained-percent-of-viewport-maxheight.html
fast/text-autosizing/constrained-then-overflow-ancestors.html
fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html
fast/text-autosizing/constrained-then-position-absolute-ancestors.html
fast/text-autosizing/constrained-then-position-fixed-ancestors.html
fast/text-autosizing/constrained-within-overflow-ancestor.html
* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::processBox):
Skips boxes for which contentHeightIsConstrained returns true.
(WebCore::TextAutosizer::contentHeightIsConstrained):
Walks up the render tree until it finds either a constrained height
or overflow-y:auto/scroll ancestor.
LayoutTests:
Added tests with various kinds, orders and nestings of constrained
height, overflow-y and positioned elements.
* fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-and-overflow-auto-ancestor.html: Added.
* fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html: Added.
* fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html: Added.
* fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html: Added.
* fast/text-autosizing/constrained-height-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-height-ancestor.html: Added.
* fast/text-autosizing/constrained-maxheight-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-maxheight-ancestor.html: Added.
* fast/text-autosizing/constrained-maxheight-expected.html: Added.
* fast/text-autosizing/constrained-maxheight.html: Added.
* fast/text-autosizing/constrained-percent-maxheight-expected.html: Added.
* fast/text-autosizing/constrained-percent-maxheight.html: Added.
* fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html: Added.
* fast/text-autosizing/constrained-percent-of-viewport-maxheight.html: Added.
* fast/text-autosizing/constrained-then-overflow-ancestors-expected.html: Added.
* fast/text-autosizing/constrained-then-overflow-ancestors.html: Added.
* fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html: Added.
* fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html: Added.
* fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html: Added.
* fast/text-autosizing/constrained-then-position-absolute-ancestors.html: Added.
* fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html: Added.
* fast/text-autosizing/constrained-then-position-fixed-ancestors.html: Added.
* fast/text-autosizing/constrained-within-overflow-ancestor-expected.html: Added.
* fast/text-autosizing/constrained-within-overflow-ancestor.html: Added.
git-svn-id: svn://svn.chromium.org/blink/trunk@128317 bbb929c8-8fbe-4397-9dbb-9b2b20218538
|