| Differences between
and this patch
- a/Source/WebCore/ChangeLog +33 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-02-14  Anton Vayvod  <avayvod@chromium.org>
2
3
        [Text Autosizing] Combine narrow descendants of a cluster into groups that should be autosized with the same multiplier.
4
        https://bugs.webkit.org/show_bug.cgi?id=109825
5
6
        Enhancement of the approach introduced in https://bugs.webkit.org/show_bug.cgi?id=109573.
7
        Instead of using the same text size multiplier for all narrow descendants of any autosizing
8
        cluster, group the descendants by how much narrower they are than the cluster's
9
        |blockContainingAllText| and process each group separately with a different multiplier for
10
        each one.
11
        For example, we want nested comments on the page to be autosized as a group but separately
12
        from a sidebar on the same page.
13
14
        Reviewed by NOBODY (OOPS!).
15
16
        Updated the existing test to verify the patch.
17
18
        * rendering/TextAutosizer.cpp:
19
        (WebCore::TextAutosizer::processClusterInternal):
20
21
            Splits the narrow descendants of the autosizing cluster into groups before processing
22
            each group individually.
23
24
        (WebCore::TextAutosizer::getNarrowDescendantsGroupedByWidth):
25
26
            Sorts the narrow descendants of the given cluster into groups, combining them by the
27
            difference between their content widths. If sorted by width, two consecutive nodes
28
            belong to the same group if their width difference is no greater than 100 CSS units.
29
30
        * rendering/TextAutosizer.h:
31
32
            New method definitions.
33
1
2013-02-17  Csaba Osztrogonác  <ossy@webkit.org>
34
2013-02-17  Csaba Osztrogonác  <ossy@webkit.org>
2
35
3
        [Qt] Unreviewed buildfix for !USE(LIBXML) builds after r143112.
36
        [Qt] Unreviewed buildfix for !USE(LIBXML) builds after r143112.
- a/Source/WebCore/rendering/TextAutosizer.cpp -1 / +41 lines
Lines 149-155 void TextAutosizer::processClusterInternal(TextAutosizingClusterInfo& clusterInf a/Source/WebCore/rendering/TextAutosizer.cpp_sec1
149
149
150
    processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
150
    processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
151
151
152
    processCompositeCluster(clusterInfo.narrowDescendants, windowInfo);
152
    Vector<Vector<TextAutosizingClusterInfo> > narrowDescendantsGroups;
153
    getNarrowDescendantsGroupedByWidth(clusterInfo, narrowDescendantsGroups);
154
    for (size_t i = 0; i < narrowDescendantsGroups.size(); ++i)
155
        processCompositeCluster(narrowDescendantsGroups[i], windowInfo);
153
}
156
}
154
157
155
void TextAutosizer::processCluster(TextAutosizingClusterInfo& clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
158
void TextAutosizer::processCluster(TextAutosizingClusterInfo& clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
Lines 556-561 const RenderObject* TextAutosizer::findFirstTextLeafNotInCluster(const RenderObj a/Source/WebCore/rendering/TextAutosizer.cpp_sec2
556
    return 0;
559
    return 0;
557
}
560
}
558
561
562
namespace {
563
564
// Compares the width of the specified cluster's roots in descending order.
565
bool clusterWiderThanComparisonFn(const TextAutosizingClusterInfo& first, const TextAutosizingClusterInfo& second)
566
{
567
    return first.root->contentLogicalWidth() > second.root->contentLogicalWidth();
568
}
569
570
} // namespace
571
572
void TextAutosizer::getNarrowDescendantsGroupedByWidth(const TextAutosizingClusterInfo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >& groups)
573
{
574
    ASSERT(parentClusterInfo.blockContainingAllText);
575
    ASSERT(groups.isEmpty());
576
577
    Vector<TextAutosizingClusterInfo> clusterInfos(parentClusterInfo.narrowDescendants);
578
    if (clusterInfos.isEmpty())
579
        return;
580
581
    std::sort(clusterInfos.begin(), clusterInfos.end(), &clusterWiderThanComparisonFn);
582
    groups.grow(1);
583
584
    // If the width difference between two consecutive elements of |clusterInfos| is greater than
585
    // this empirically determined value, the next element should start a new group.
586
    const float maxWidthDifferenceWithinGroup = 100;
587
    for (size_t i = 0; i < clusterInfos.size(); ++i) {
588
        groups.last().append(clusterInfos[i]);
589
590
        if (i + 1 < clusterInfos.size()) {
591
            float currentWidth = clusterInfos[i].root->contentLogicalWidth();
592
            float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth();
593
            if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup)
594
                groups.grow(groups.size() + 1);
595
        }
596
    }
597
}
598
559
} // namespace WebCore
599
} // namespace WebCore
560
600
561
#endif // ENABLE(TEXT_AUTOSIZING)
601
#endif // ENABLE(TEXT_AUTOSIZING)
- a/Source/WebCore/rendering/TextAutosizer.h +5 lines
Lines 91-96 private: a/Source/WebCore/rendering/TextAutosizer.h_sec1
91
    // belong to any cluster.
91
    // belong to any cluster.
92
    static const RenderObject* findFirstTextLeafNotInCluster(const RenderObject*, size_t& depth, TraversalDirection);
92
    static const RenderObject* findFirstTextLeafNotInCluster(const RenderObject*, size_t& depth, TraversalDirection);
93
93
94
    // Returns groups of narrow descendants of a given autosizing cluster. The groups are combined
95
    // by the difference between the width of the descendant and the width of the parent cluster's
96
    // |blockContainingAllText|.
97
    static void getNarrowDescendantsGroupedByWidth(const TextAutosizingClusterInfo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >&);
98
94
    Document* m_document;
99
    Document* m_document;
95
};
100
};
96
101
- a/LayoutTests/ChangeLog +14 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2013-02-14  Anton Vayvod  <avayvod@chromium.org>
2
3
        [Text Autosizing] Combine narrow descendants of a cluster into groups that should be autosized with the same multiplier.
4
        https://bugs.webkit.org/show_bug.cgi?id=109825
5
6
        Verify that narrow descendants are grouped and autosized separately according to the
7
        difference between the descendant's width and the width of its enclosing cluster's
8
        |blockContainingAllText|.
9
10
        Reviewed by NOBODY (OOPS!).
11
12
        * fast/text-autosizing/narrow-descendants-combined-expected.html:
13
        * fast/text-autosizing/narrow-descendants-combined.html:
14
1
2013-02-17  Christophe Dumez  <ch.dumez@sisa.samsung.com>
15
2013-02-17  Christophe Dumez  <ch.dumez@sisa.samsung.com>
2
16
3
        Unreviewed EFL gardening.
17
        Unreviewed EFL gardening.
- a/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html -5 / +10 lines
Lines 12-25 body { width: 800px; margin: 0; overflow-y: hidden; } a/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html_sec1
12
<body>
12
<body>
13
13
14
<div style="font-size: 1.25rem">
14
<div style="font-size: 1.25rem">
15
    <div style="width: 240px">
16
        This text should be autosized to 20px computed font-size as it is combined with the next and the last narrow siblings and the maximum width is 400px.
17
    </div>
15
    <div style="width: 320px">
18
    <div style="width: 320px">
16
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
19
        This text should be autosized to 20px computed font-size as it is combined with the first and the last narrow siblings and the maximum width is 400px.
17
    </div>
20
    </div>
18
    <div style="width: 400px">
21
    <div style="width: 560px; font-size: 1.75rem">
19
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
22
        This text should be autosized to 28px computed font-size as it is combined into a separate group from its two siblings since it's significantly wider.<br>
23
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
20
    </div>
24
    </div>
21
    <div style="width: 240px">
25
    <div style="width: 400px">
22
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
26
        This text should be autosized to 20px computed font-size as it is combined with the first and the second narrow siblings and the maximum width is 400px.<br>
27
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
23
    </div>
28
    </div>
24
</div>
29
</div>
25
30
- a/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html -5 / +10 lines
Lines 21-34 if (window.internals) { a/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html_sec1
21
<body>
21
<body>
22
22
23
<div>
23
<div>
24
    <div style="width: 240px">
25
        This text should be autosized to 20px computed font-size as it is combined with the next and the last narrow siblings and the maximum width is 400px.
26
    </div>
24
    <div style="width: 320px">
27
    <div style="width: 320px">
25
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
28
        This text should be autosized to 20px computed font-size as it is combined with the first and the last narrow siblings and the maximum width is 400px.
26
    </div>
29
    </div>
27
    <div style="width: 400px">
30
    <div style="width: 560px">
28
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
31
        This text should be autosized to 28px computed font-size as it is combined into a separate group from its two siblings since it's significantly wider.<br>
32
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
29
    </div>
33
    </div>
30
    <div style="width: 240px">
34
    <div style="width: 400px">
31
        This text should be autosized to 20px computed font-size as it is combined with its narrow siblings and the maximum width is 400px.
35
        This text should be autosized to 20px computed font-size as it is combined with the first and the second narrow siblings and the maximum width is 400px.<br>
36
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
32
    </div>
37
    </div>
33
</div>
38
</div>
34
39

Return to Bug 109825