cluster = cluster->containingBlock();
TextAutosizingClusterInfo clusterInfo(cluster);
- processCluster(&clusterInfo, container, layoutRoot, windowInfo);
+ processCluster(clusterInfo, container, layoutRoot, windowInfo);
return true;
}
-void TextAutosizer::processCluster(TextAutosizingClusterInfo* clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
+void TextAutosizer::processCluster(TextAutosizingClusterInfo& clusterInfo, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
{
// Many pages set a max-width on their content. So especially for the
// RenderView, instead of just taking the width of |cluster| we find
// the lowest common ancestor of the first and last descendant text node of
// the cluster (i.e. the deepest wrapper block that contains all the text),
// and use its width instead.
- clusterInfo->blockContainingAllText = findDeepestBlockContainingAllText(clusterInfo->root);
- float textWidth = clusterInfo->blockContainingAllText->contentLogicalWidth();
+ clusterInfo.blockContainingAllText = findDeepestBlockContainingAllText(clusterInfo.root);
+ float textWidth = clusterInfo.blockContainingAllText->contentLogicalWidth();
float multiplier = 1;
if (clusterShouldBeAutosized(clusterInfo, textWidth)) {
- int logicalWindowWidth = clusterInfo->root->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
- int logicalLayoutWidth = clusterInfo->root->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
+ int logicalWindowWidth = clusterInfo.root->isHorizontalWritingMode() ? windowInfo.windowSize.width() : windowInfo.windowSize.height();
+ int logicalLayoutWidth = clusterInfo.root->isHorizontalWritingMode() ? windowInfo.minLayoutSize.width() : windowInfo.minLayoutSize.height();
// Ignore box width in excess of the layout width, to avoid extreme multipliers.
float logicalClusterWidth = std::min<float>(textWidth, logicalLayoutWidth);
processContainer(multiplier, container, clusterInfo, subtreeRoot, windowInfo);
}
-void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
+void TextAutosizer::processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo& clusterInfo, RenderObject* subtreeRoot, const TextAutosizingWindowInfo& windowInfo)
{
ASSERT(isAutosizingContainer(container));
RenderBlock* descendantBlock = toRenderBlock(descendant);
if (isAutosizingCluster(descendantBlock, clusterInfo)) {
TextAutosizingClusterInfo descendantClusterInfo(descendantBlock);
- processCluster(&descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
+ processCluster(descendantClusterInfo, descendantBlock, descendantBlock, windowInfo);
} else
processContainer(multiplier, descendantBlock, clusterInfo, descendantBlock, windowInfo);
}
return true;
}
-bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isNarrowDescendant(const RenderBlock* renderer, TextAutosizingClusterInfo& parentClusterInfo)
{
ASSERT(isAutosizingContainer(renderer));
// less than 50px narrower than the current limit.
const float differenceFromMaxWidthDifference = 50;
float contentWidth = renderer->contentLogicalWidth();
- float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();
+ float clusterTextWidth = parentClusterInfo.blockContainingAllText->contentLogicalWidth();
float widthDifference = clusterTextWidth - contentWidth;
- if (widthDifference - parentClusterInfo->maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)
+ if (widthDifference - parentClusterInfo.maxAllowedDifferenceFromTextWidth > differenceFromMaxWidthDifference)
return true;
- parentClusterInfo->maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo->maxAllowedDifferenceFromTextWidth);
+ parentClusterInfo.maxAllowedDifferenceFromTextWidth = std::max(widthDifference, parentClusterInfo.maxAllowedDifferenceFromTextWidth);
return false;
}
-bool TextAutosizer::isWiderDescendant(const RenderBlock* renderer, const TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isWiderDescendant(const RenderBlock* renderer, const TextAutosizingClusterInfo& parentClusterInfo)
{
ASSERT(isAutosizingContainer(renderer));
// Autosizing containers that are wider than the |blockContainingAllText| of their enclosing
// cluster are treated the same way as autosizing clusters to be autosized separately.
float contentWidth = renderer->contentLogicalWidth();
- float clusterTextWidth = parentClusterInfo->blockContainingAllText->contentLogicalWidth();
+ float clusterTextWidth = parentClusterInfo.blockContainingAllText->contentLogicalWidth();
return contentWidth > clusterTextWidth;
}
// containers, and probably flexboxes...
}
-bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo* parentClusterInfo)
+bool TextAutosizer::isAutosizingCluster(const RenderBlock* renderer, TextAutosizingClusterInfo& parentClusterInfo)
{
ASSERT(isAutosizingContainer(renderer));
return false;
}
-bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo* clusterInfo, float blockWidth)
+bool TextAutosizer::clusterShouldBeAutosized(TextAutosizingClusterInfo& clusterInfo, float blockWidth)
{
// Don't autosize clusters that contain less than 4 lines of text (in
// practice less lines are required, since measureDescendantTextWidth
const float minLinesOfText = 4;
float minTextWidth = blockWidth * minLinesOfText;
float textWidth = 0;
- measureDescendantTextWidth(clusterInfo->blockContainingAllText, clusterInfo, minTextWidth, textWidth);
+ measureDescendantTextWidth(clusterInfo.blockContainingAllText, clusterInfo, minTextWidth, textWidth);
if (textWidth >= minTextWidth)
return true;
return false;
}
-void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo* clusterInfo, float minTextWidth, float& textWidth)
+void TextAutosizer::measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo& clusterInfo, float minTextWidth, float& textWidth)
{
bool skipLocalText = !containerShouldBeAutosized(container);
explicit TextAutosizer(Document*);
- void processCluster(TextAutosizingClusterInfo*, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
- void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo*, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
+ void processCluster(TextAutosizingClusterInfo&, RenderBlock* container, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
+ void processContainer(float multiplier, RenderBlock* container, TextAutosizingClusterInfo&, RenderObject* subtreeRoot, const TextAutosizingWindowInfo&);
void setMultiplier(RenderObject*, float);
static bool isAutosizingContainer(const RenderObject*);
- static bool isNarrowDescendant(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo);
- static bool isWiderDescendant(const RenderBlock*, const TextAutosizingClusterInfo* parentClusterInfo);
+ static bool isNarrowDescendant(const RenderBlock*, TextAutosizingClusterInfo& parentClusterInfo);
+ static bool isWiderDescendant(const RenderBlock*, const TextAutosizingClusterInfo& parentClusterInfo);
static bool isIndependentDescendant(const RenderBlock*);
- static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo* parentClusterInfo);
+ static bool isAutosizingCluster(const RenderBlock*, TextAutosizingClusterInfo& parentClusterInfo);
static bool containerShouldBeAutosized(const RenderBlock* container);
static bool containerContainsOneOfTags(const RenderBlock* cluster, const Vector<QualifiedName>& tags);
static bool containerIsRowOfLinks(const RenderObject* container);
static bool contentHeightIsConstrained(const RenderBlock* container);
- static bool clusterShouldBeAutosized(TextAutosizingClusterInfo*, float blockWidth);
- static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo*, float minTextWidth, float& textWidth);
+ static bool clusterShouldBeAutosized(TextAutosizingClusterInfo&, float blockWidth);
+ static void measureDescendantTextWidth(const RenderBlock* container, TextAutosizingClusterInfo&, float minTextWidth, float& textWidth);
// Use to traverse the tree of descendants, excluding descendants of containers (but returning the containers themselves).
static RenderObject* nextInPreOrderSkippingDescendantsOfContainers(const RenderObject*, const RenderObject* stayWithin);