Changeset 142534 in webkit


Ignore:
Timestamp:
Feb 11, 2013 3:48:51 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Text Autosizing] Collect narrow descendants and process them separately. Refactoring for
a change to follow.
https://bugs.webkit.org/show_bug.cgi?id=109054

Preparational change to combine narrow descendants of the same autosizing cluster into
groups by the width difference between the descendant and the block containing all text of
the parent autosizing cluster. The groups will be 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 eventually want to be able to merge them back
together into one (or a few) descendant clusters.

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

No behavioral changes thus no new tests or test changes.

  • rendering/TextAutosizer.cpp:

(TextAutosizingClusterInfo): Vector of narrow descendants.
(WebCore::TextAutosizer::processCluster): Process narrow descendants separately.
(WebCore::TextAutosizer::processContainer):

Remember narrow descendants of the parent cluster for later processing.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142533 r142534  
     12013-02-11  Anton Vayvod  <avayvod@chromium.org>
     2
     3        [Text Autosizing] Collect narrow descendants and process them separately. Refactoring for
     4        a change to follow.
     5        https://bugs.webkit.org/show_bug.cgi?id=109054
     6
     7        Preparational change to combine narrow descendants of the same autosizing cluster into
     8        groups by the width difference between the descendant and the block containing all text of
     9        the parent autosizing cluster. The groups will be autosized with the same multiplier.
     10
     11        For example, on sites with a sidebar, sometimes the paragraphs next to the sidebar will have
     12        a large margin individually applied (via a CSS selector), causing them all to individually
     13        appear narrower than their enclosing blockContainingAllText. Rather than making each of
     14        these paragraphs into a separate cluster, we eventually want to be able to merge them back
     15        together into one (or a few) descendant clusters.
     16
     17        Reviewed by Julien Chaffraix.
     18
     19        No behavioral changes thus no new tests or test changes.
     20
     21        * rendering/TextAutosizer.cpp:
     22        (TextAutosizingClusterInfo): Vector of narrow descendants.
     23        (WebCore::TextAutosizer::processCluster): Process narrow descendants separately.
     24        (WebCore::TextAutosizer::processContainer):
     25
     26            Remember narrow descendants of the parent cluster for later processing.
     27
    1282013-02-11  Enrica Casucci  <enrica@apple.com>
    229
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r142367 r142534  
    3838#include <algorithm>
    3939#include <wtf/StdLibExtras.h>
     40#include <wtf/Vector.h>
    4041
    4142namespace WebCore {
     
    4849};
    4950
     51// Represents cluster related data. Instances should not persist between calls to processSubtree.
    5052struct TextAutosizingClusterInfo {
    5153    explicit TextAutosizingClusterInfo(RenderBlock* root)
     
    6264    // text and that of a narrow child before the child becomes a separate cluster.
    6365    float maxAllowedDifferenceFromTextWidth;
     66
     67    // Descendants of the cluster that are narrower than the block containing all text and must be
     68    // processed together.
     69    Vector<TextAutosizingClusterInfo> narrowDescendants;
    6470};
    6571
     
    151157
    152158    processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
     159
     160    Vector<TextAutosizingClusterInfo>& narrowDescendants = clusterInfo.narrowDescendants;
     161    for (size_t i = 0; i < narrowDescendants.size(); ++i) {
     162        TextAutosizingClusterInfo& descendantClusterInfo = narrowDescendants[i];
     163        processCluster(descendantClusterInfo, descendantClusterInfo.root, descendantClusterInfo.root, windowInfo);
     164    }
    153165}
    154166
     
    169181        } else if (isAutosizingContainer(descendant)) {
    170182            RenderBlock* descendantBlock = toRenderBlock(descendant);
    171             if (isAutosizingCluster(descendantBlock, clusterInfo)) {
    172                 TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
     183            TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
     184            if (isWiderDescendant(descendantBlock, clusterInfo) || isIndependentDescendant(descendantBlock))
    173185                processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
     186            else if (isNarrowDescendant(descendantBlock, clusterInfo)) {
     187                // Narrow descendants are processed together later to be able to apply the same multiplier
     188                // to each of them if necessary.
     189                clusterInfo.narrowDescendants.append(descendantClusterInfo);
    174190            } else
    175191                processContainer(multiplier, descendantBlock, clusterInfo, descendantBlock, windowInfo);
Note: See TracChangeset for help on using the changeset viewer.