[Text Autosizing] Process narrow descendants with the same multiplier for the font...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 12:09:18 +0000 (12:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2013 12:09:18 +0000 (12:09 +0000)
commit6b910fe564472aeab915929ee416d482bab0bbca
tree053be1afe159d090e2fe584be38598e6bea67526
parent427f493de353ed1a5353b134698012565efbd96c
[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: https://svn.webkit.org/repository/webkit/trunk@142866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/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/ChangeLog
Source/WebCore/rendering/TextAutosizer.cpp
Source/WebCore/rendering/TextAutosizer.h