[Cherry-pick][Text Autosizing] Process narrow descendants with the same multiplier...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 12:09:18 +0000 (12:09 +0000)
committerJaehun Lim <ljaehun.lim@samsung.com>
Thu, 4 Apr 2013 02:41:59 +0000 (11:41 +0900)
commit515e556f64f1a7932ebf31360c416a55e2f0d2de
tree81cb9ff45c61462de706ce604233382b5dda5db9
parentd6046f62215398a43536af685e491508b2f7bfcc
[Cherry-pick][Text Autosizing] Process narrow descendants with the same multiplier for the font size.

[Text Autosizing] Process narrow descendants with the same multiplier for the font size.
https://bugs.webkit.org/show_bug.cgi?id=109573

Source/WebCore:

Patch by Anton Vayvod <avayvod@chromium.org> on 2013-02-14
Reviewed by Julien Chaffraix.

Combine narrow descendants of the same autosizing cluster into a group that is autosized
with the same multiplier.

For example, on sites with a sidebar, sometimes the paragraphs next to the sidebar will have
a large margin individually applied (via a CSS selector), causing them all to individually
appear narrower than their enclosing blockContainingAllText. Rather than making each of
these paragraphs into a separate cluster, we want them all to share the same multiplier, as
if they were a single cluster.

Test: fast/text-autosizing/narrow-descendants-combined.html

* rendering/TextAutosizer.cpp:
(WebCore::TextAutosizer::processClusterInternal):

    Common implementation for processCluster() and processCompositeCluster that accepts the
    text width and whether the cluster should be autosized as parameters instead of
    calculating it inline.

(WebCore::TextAutosizer::processCluster):

    Calculates the text width for a single cluster and whether it should be autosized, then
    calls processClusterInternal() to apply the multiplier and process the cluster's
    descendants.

(WebCore::TextAutosizer::processCompositeCluster):

    Calculates the text width for a group of renderers and if the group should be autosized,
    then calls processClusterInternal() repeatedly with the same multiplier to apply it and
    process all the descendants of the group.

(WebCore::TextAutosizer::clusterShouldBeAutosized):

    Calls the multiple renderers version to avoid code duplication.

(WebCore::TextAutosizer::compositeClusterShouldBeAutosized):

    The multiple renderers version of clusterShouldBeAutosized.

* rendering/TextAutosizer.h:

    Updated method declarations.

LayoutTests:

Test to verify that all narrow descendants of a cluster are autosized with the same
multiplier.

Patch by Anton Vayvod <avayvod@chromium.org> on 2013-02-14
Reviewed by Julien Chaffraix.

* fast/text-autosizing/narrow-descendants-combined-expected.html: Added.
* fast/text-autosizing/narrow-descendants-combined.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142866 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:

LayoutTests/ChangeLog
Source/WebCore/ChangeLog
LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html [new file with mode: 0644]
LayoutTests/fast/text-autosizing/narrow-descendants-combined.html [new file with mode: 0644]
Source/WebCore/rendering/TextAutosizer.cpp
Source/WebCore/rendering/TextAutosizer.h