|
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 |
bool greaterClusterInfoRootWidth(const TextAutosizingClusterInfo& first, const TextAutosizingClusterInfo& second) |
| 565 |
{ |
| 566 |
return first.root->contentLogicalWidth() > second.root->contentLogicalWidth(); |
| 567 |
} |
| 568 |
|
| 569 |
} // namespace |
| 570 |
|
| 571 |
void TextAutosizer::getNarrowDescendantsGroupedByWidth(const TextAutosizingClusterInfo& parentClusterInfo, Vector<Vector<TextAutosizingClusterInfo> >& groups) |
| 572 |
{ |
| 573 |
ASSERT(parentClusterInfo.blockContainingAllText); |
| 574 |
ASSERT(groups.isEmpty()); |
| 575 |
|
| 576 |
Vector<TextAutosizingClusterInfo> clusterInfos(parentClusterInfo.narrowDescendants); |
| 577 |
if (clusterInfos.isEmpty()) |
| 578 |
return; |
| 579 |
|
| 580 |
std::sort(clusterInfos.begin(), clusterInfos.end(), &greaterClusterInfoRootWidth); |
| 581 |
groups.grow(1); |
| 582 |
|
| 583 |
// If the width difference between two consecutive elements of |clusterInfos| is greater than |
| 584 |
// this value, the next element should start a new group. |
| 585 |
const float maxWidthDifferenceWithinGroup = 100; |
| 586 |
for (size_t i = 0; i < clusterInfos.size(); ++i) { |
| 587 |
groups.last().append(clusterInfos[i]); |
| 588 |
|
| 589 |
if (i + 1 < clusterInfos.size()) { |
| 590 |
float currentWidth = clusterInfos[i].root->contentLogicalWidth(); |
| 591 |
float nextWidth = clusterInfos[i + 1].root->contentLogicalWidth(); |
| 592 |
if (currentWidth - nextWidth > maxWidthDifferenceWithinGroup) |
| 593 |
groups.grow(groups.size() + 1); |
| 594 |
} |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 559 |
} // namespace WebCore |
598 |
} // namespace WebCore |
| 560 |
|
599 |
|
| 561 |
#endif // ENABLE(TEXT_AUTOSIZING) |
600 |
#endif // ENABLE(TEXT_AUTOSIZING) |