Changeset 141901 in webkit


Ignore:
Timestamp:
Feb 5, 2013 10:36:33 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

TextAutosizing: adjust the maximum difference between cluster text width and its descendant
width.
https://bugs.webkit.org/show_bug.cgi?id=108411

Source/WebCore:

Currently, if a render object is more than 200 CSS units shorter than its parent cluster, it
becomes a separate autosizing cluster (see https://bugs.webkit.org/show_bug.cgi?id=105188).
This doesn't work well for layouts when narrow nodes are related, like nested comments:
deeper comments are all shorter than the parent cluster and become autosized differently. To
avoid that the difference that makes a shorter descendant a new autosizing cluster is
adjusted each time the width difference is not greater than 50 CSS units from the previous
one. This allows nested comments, for example, to remain a part of the parent cluster and be
autosized with the same multiplier.

Patch by Anton Vayvod <avayvod@chromium.org> on 2013-02-05
Reviewed by Kenneth Rohde Christiansen.

Tests:

fast/text-autosizing/nested-child.html

  • rendering/TextAutosizer.cpp:

(WebCore::TextAutosizingClusterInfo::TextAutosizingClusterInfo):

Added a new field to store the current maximum width difference for the cluster.

(WebCore::TextAutosizer::isAutosizingCluster):

Uses the new field to determine if the current node is a separate cluster,
updates the maximum allowed width difference between the cluster and its descendant.

(WebCore::TextAutosizer::processContainer):
(WebCore::TextAutosizer::clusterShouldBeAutosized):
(WebCore::TextAutosizer::measureDescendantTextWidth):

Non-const reference passed to the methods above.

  • rendering/TextAutosizer.h: updated method parameters.

LayoutTests:

Patch by Anton Vayvod <avayvod@chromium.org> on 2013-02-05
Reviewed by Kenneth Rohde Christiansen.

Tests that certain width difference doesn't make descendants separate clusters.

  • fast/text-autosizing/nested-child-expected.html: Added.
  • fast/text-autosizing/nested-child.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141893 r141901  
     12013-02-05  Anton Vayvod  <avayvod@chromium.org>
     2
     3        TextAutosizing: adjust the maximum difference between cluster text width and its descendant
     4        width.
     5        https://bugs.webkit.org/show_bug.cgi?id=108411
     6
     7        Reviewed by Kenneth Rohde Christiansen.
     8
     9        Tests that certain width difference doesn't make descendants separate clusters.
     10
     11        * fast/text-autosizing/nested-child-expected.html: Added.
     12        * fast/text-autosizing/nested-child.html: Added.
     13
    1142013-02-05  Ádám Kallai  <kadam@inf.u-szeged.hu>
    215
  • trunk/Source/WebCore/ChangeLog

    r141897 r141901  
     12013-02-05  Anton Vayvod  <avayvod@chromium.org>
     2
     3        TextAutosizing: adjust the maximum difference between cluster text width and its descendant
     4        width.
     5        https://bugs.webkit.org/show_bug.cgi?id=108411
     6
     7        Currently, if a render object is more than 200 CSS units shorter than its parent cluster, it
     8        becomes a separate autosizing cluster (see https://bugs.webkit.org/show_bug.cgi?id=105188).
     9        This doesn't work well for layouts when narrow nodes are related, like nested comments:
     10        deeper comments are all shorter than the parent cluster and become autosized differently. To
     11        avoid that the difference that makes a shorter descendant a new autosizing cluster is
     12        adjusted each time the width difference is not greater than 50 CSS units from the previous
     13        one. This allows nested comments, for example, to remain a part of the parent cluster and be
     14        autosized with the same multiplier.
     15       
     16        Reviewed by Kenneth Rohde Christiansen.
     17
     18        Tests:
     19                fast/text-autosizing/nested-child.html
     20
     21        * rendering/TextAutosizer.cpp:
     22        (WebCore::TextAutosizingClusterInfo::TextAutosizingClusterInfo):
     23
     24            Added a new field to store the current maximum width difference for the cluster.
     25
     26        (WebCore::TextAutosizer::isAutosizingCluster):
     27
     28            Uses the new field to determine if the current node is a separate cluster,
     29            updates the maximum allowed width difference between the cluster and its descendant.
     30
     31        (WebCore::TextAutosizer::processContainer):
     32        (WebCore::TextAutosizer::clusterShouldBeAutosized):
     33        (WebCore::TextAutosizer::measureDescendantTextWidth):
     34
     35            Non-const reference passed to the methods above.
     36
     37        * rendering/TextAutosizer.h: updated method parameters.
     38
    1392013-02-05  Tony Gentilcore  <tonyg@chromium.org>
    240
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r141489 r141901  
    5252        : root(root)
    5353        , blockContainingAllText(0)
     54        , maxAllowedDifferenceFromTextWidth(150)
    5455    {
    5556    }
     
    5758    RenderBlock* root;
    5859    const RenderBlock* blockContainingAllText;
     60
     61    // Upper limit on the difference between the width of the cluster's block containing all
     62    // text and that of a narrow child before the child becomes a separate cluster.
     63    float maxAllowedDifferenceFromTextWidth;
    5964};
    6065
     
    148153}
    149154
    150 void TextAutosizer::processContainer(float multiplier, RenderBlock* container, const TextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
     155void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
    151156{
    152157    ASSERT(isAutosizingContainer(container));
     
    231236}
    232237
    233 bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, const TextAutosizingClusterInfo* parentClusterInfo)
     238bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo)
    234239{
    235240    // "Autosizing clusters" are special autosizing containers within which we
     
    257262    ASSERT(isAutosizingContainer(renderer));
    258263
    259     // Upper limit on the difference between the width of the parent block containing all
    260     // text and that of a narrow child before the child becomes a cluster.
    261     const float maxWidthDifference = 200;
    262 
    263264    if (parentClusterInfo->blockContainingAllText) {
    264265        float contentWidth = renderer->contentLogicalWidth();
    265266        float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();
    266         if (contentWidth > clusterTextWidth || (clusterTextWidth - contentWidth) > maxWidthDifference)
     267        if (contentWidth > clusterTextWidth)
    267268            return true;
     269
     270        // The upper limit on how many pixels the difference between the renderer width
     271        // and its parent cluster width can exceed the current maximum difference by
     272        // before the object is considered to be a separate autosizing cluster.
     273        const float differenceFromMaxWidthDifference = 50;
     274
     275        float widthDifference = clusterTextWidth - contentWidth;
     276        if (widthDifference - parentClusterInfo->maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)
     277            return true;
     278        parentClusterInfo->maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo->maxAllowedDifferenceFromTextWidth);
    268279    }
    269280
     
    379390}
    380391
    381 bool TextAutosizer::clusterShouldBeAutosized(const TextAutosizingClusterInfo* clusterInfo, float blockWidth)
     392bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo* clusterInfo, float blockWidth)
    382393{
    383394    // Don't autosize clusters that contain less than 4 lines of text (in
     
    400411}
    401412
    402 void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, const TextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth)
     413void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth)
    403414{
    404415    bool skipLocalText = !containerShouldBeAutosized(container);
  • trunk/Source/WebCore/rendering/TextAutosizer.h

    r141489 r141901  
    6363
    6464    void processCluster(TextAutosizingClusterInfo*, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
    65     void processContainer(float multiplier, RenderBlock* container, const TextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
     65    void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
    6666
    6767    void setMultiplier(RenderObject*, float);
    6868
    6969    static bool isAutosizingContainer(const RenderObject*);
    70     static bool isAutosizingCluster(const RenderBlock*, const TextAutosizingClusterInfo* parentClusterInfo);
     70    static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo);
    7171    static bool isAutosizingCluster(const RenderObject*);
    7272
     
    7575    static bool containerIsRowOfLinks(const RenderObject* container);
    7676    static bool contentHeightIsConstrained(const RenderBlock* container);
    77     static bool clusterShouldBeAutosized(const TextAutosizingClusterInfo*, float blockWidth);
    78     static void measureDescendantTextWidth(const RenderBlock* container, const TextAutosizingClusterInfo*, float minTextWidth, float& textWidth);
     77    static bool clusterShouldBeAutosized(TextAutosizingClusterInfo*, float blockWidth);
     78    static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo*, float minTextWidth, float& textWidth);
    7979
    8080    // Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
Note: See TracChangeset for help on using the changeset viewer.