12012-11-29 Anton Vayvod <avayvod@chromium.org>
2
3 Text Autosizing: text nodes wider than their ancestor clusters should be autosized as separate clusters
4 https://bugs.webkit.org/show_bug.cgi?id=103627
5
6 Reviewed by NOBODY (OOPS!).
7
8 isAutosizingCluster() is checking for the width of the container being greater than the width of its
9 descendant cluster (more precisely, its text nodes least common ancestor). This ancestor RenderBlock is
10 passed throughout tree traversal methods.
11 Algorithm that searches for text nodes least common ancestor had to be modified to avoid circular dependency
12 between finding LCA and determining if container is a cluster. After initial LCA is found, we check if any of
13 text leafs' parent nodes are clusters due to the new definition and if so, we find new text leafs and new LCA.
14 This is repeated until there are no clusters in paths from LCA to the first and last text leafs.
15
16 The change fixes several cases covered by existing tests.
17
18 * rendering/TextAutosizer.cpp:
19 (WebCore::TextAutosizer::processSubtree): passes found root cluster to processCluster as initial stayWithin value.
20 (WebCore::TextAutosizer::processCluster): stayWithin parameter (for assertion only), passes found block containing all text into processContainer.
21 (WebCore::TextAutosizer::processContainer): stayWithin parameter passed into processCluster and isAutosizingCluster.
22 (WebCore::TextAutosizer::isAutosizingCluster): considers a block that is wider than its parent, containing all text nodes within the parent cluster, to be a cluster itself.
23 (WebCore::TextAutosizer::clusterShouldBeAutosized): passes new parameter to measureDescendantTextWidth.
24 (WebCore::TextAutosizer::measureDescendantTextWidth): uses stayWithin parameter to pass to isAutosizingCluster.
25 (WebCore::TextAutosizer::findDeepestBlockContainingAllText): reimplemented to incrementally filter out clusters that are wider than the currently found block.
26 (WebCore::TextAutosizer::findClosestCluster): find the first cluster in a collection of RenderObjects starting from the given position.
27 (WebCore::TextAutosizer::findFirstTextLeafNotInCluster): finds text leaf that doesn't belong to any cluster, starts searching from the first child of the last node in the path.
28 (WebCore::TextAutosizer::findNextTextLeafNotInCluster): finds text leaf that doesn't belong to any cluster, starts searching from the next sibling of the last node in the path.
29 (WebCore::TextAutosizer::firstChildNotCluster): finds the first child of RenderObject that is not a cluster.
30 (WebCore::TextAutosizer::nextSiblingNotCluster): finds the next sibling of RenderObject that is not a cluster.
31 (WebCore::TextAutosizer::isObjectAutosizingCluster): convenience method reducing code duplication.
32 (WebCore::TextAutosizer::objectFirstChild): convenience method reducing code duplication.
33 (WebCore::TextAutosizer::objectNextSibling): convenience method reducing code duplication.
34 * rendering/TextAutosizer.h:
35 (TextAutosizer): type for a collection of const RenderObject*, new method definitions.
36