Changeset 143318 in webkit
- Timestamp:
- Feb 19, 2013 4:45:26 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r143315 r143318 1 2013-02-19 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 Kenneth Rohde Christiansen. 11 12 * fast/text-autosizing/narrow-descendants-combined-expected.html: 13 * fast/text-autosizing/narrow-descendants-combined.html: 14 1 15 2013-02-19 Takashi Toyoshima <toyoshim@chromium.org> 2 16 -
trunk/LayoutTests/fast/text-autosizing/narrow-descendants-combined-expected.html
r142866 r143318 13 13 14 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 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. 20 </div> 21 <div style="width: 560px; font-size: 1.75rem"> 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. 17 24 </div> 18 25 <div style="width: 400px"> 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. 20 </div> 21 <div style="width: 240px"> 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 28 </div> 24 29 </div> -
trunk/LayoutTests/fast/text-autosizing/narrow-descendants-combined.html
r142866 r143318 22 22 23 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 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. 29 </div> 30 <div style="width: 560px"> 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. 26 33 </div> 27 34 <div style="width: 400px"> 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. 29 </div> 30 <div style="width: 240px"> 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 37 </div> 33 38 </div> -
trunk/Source/WebCore/ChangeLog
r143317 r143318 1 2013-02-19 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 Kenneth Rohde Christiansen. 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 34 2013-02-18 Ilya Tikhonovsky <loislo@chromium.org> 2 35 -
trunk/Source/WebCore/rendering/TextAutosizer.cpp
r143295 r143318 150 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 … … 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 599 } // namespace WebCore 560 600 -
trunk/Source/WebCore/rendering/TextAutosizer.h
r142866 r143318 92 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 99 Document* m_document; 95 100 };
Note: See TracChangeset
for help on using the changeset viewer.