Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rename browser zoom to page zoom Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderFlexibleBox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBoxModelObject.cpp
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index caef81861c47db979ac5417313a251fb3679192e..9113f1ab58ea6e7fc00a822c88bec84c9213e3f9 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -240,11 +240,11 @@ LayoutSize RenderBoxModelObject::relativePositionOffset() const
// call availableWidth on our containing block.
if (!style()->left().isAuto()) {
if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRightDirection())
- offset.setWidth(-valueForLength(style()->right(), containingBlock->availableWidth(), view()));
+ offset.setWidth(-valueForLength(style()->right(), containingBlock->availableWidth()));
else
- offset.expand(valueForLength(style()->left(), containingBlock->availableWidth(), view()), 0);
+ offset.expand(valueForLength(style()->left(), containingBlock->availableWidth()), 0);
} else if (!style()->right().isAuto()) {
- offset.expand(-valueForLength(style()->right(), containingBlock->availableWidth(), view()), 0);
+ offset.expand(-valueForLength(style()->right(), containingBlock->availableWidth()), 0);
}
// If the containing block of a relatively positioned element does not
@@ -257,13 +257,13 @@ LayoutSize RenderBoxModelObject::relativePositionOffset() const
&& (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
|| !style()->top().isPercent()
|| containingBlock->stretchesToViewport()))
- offset.expand(0, valueForLength(style()->top(), containingBlock->availableHeight(), view()));
+ offset.expand(0, valueForLength(style()->top(), containingBlock->availableHeight()));
else if (!style()->bottom().isAuto()
&& (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
|| !style()->bottom().isPercent()
|| containingBlock->stretchesToViewport()))
- offset.expand(0, -valueForLength(style()->bottom(), containingBlock->availableHeight(), view()));
+ offset.expand(0, -valueForLength(style()->bottom(), containingBlock->availableHeight()));
return offset;
}
@@ -328,10 +328,10 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
// Sticky positioned element ignore any override logical width on the containing block (as they don't call
// containingBlockLogicalWidthForContent). It's unclear whether this is totally fine.
- LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWidth, view()),
- minimumValueForLength(style()->marginRight(), maxWidth, view()),
- minimumValueForLength(style()->marginBottom(), maxWidth, view()),
- minimumValueForLength(style()->marginLeft(), maxWidth, view()));
+ LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWidth),
+ minimumValueForLength(style()->marginRight(), maxWidth),
+ minimumValueForLength(style()->marginBottom(), maxWidth),
+ minimumValueForLength(style()->marginLeft(), maxWidth));
// Compute the container-relative area within which the sticky element is allowed to move.
containerContentRect.contract(minMargin);
@@ -352,22 +352,22 @@ void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo
constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
if (!style()->left().isAuto()) {
- constraints.setLeftOffset(valueForLength(style()->left(), viewportRect.width(), view()));
+ constraints.setLeftOffset(valueForLength(style()->left(), viewportRect.width()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
}
if (!style()->right().isAuto()) {
- constraints.setRightOffset(valueForLength(style()->right(), viewportRect.width(), view()));
+ constraints.setRightOffset(valueForLength(style()->right(), viewportRect.width()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
}
if (!style()->top().isAuto()) {
- constraints.setTopOffset(valueForLength(style()->top(), viewportRect.height(), view()));
+ constraints.setTopOffset(valueForLength(style()->top(), viewportRect.height()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
}
if (!style()->bottom().isAuto()) {
- constraints.setBottomOffset(valueForLength(style()->bottom(), viewportRect.height(), view()));
+ constraints.setBottomOffset(valueForLength(style()->bottom(), viewportRect.height()));
constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
}
}
@@ -421,21 +421,17 @@ int RenderBoxModelObject::pixelSnappedOffsetHeight() const
LayoutUnit RenderBoxModelObject::computedCSSPadding(Length padding) const
{
LayoutUnit w = 0;
- RenderView* renderView = 0;
if (padding.isPercent())
w = containingBlockLogicalWidthForContent();
- else if (padding.isViewportPercentage())
- renderView = view();
- return minimumValueForLength(padding, w, renderView);
+ return minimumValueForLength(padding, w);
}
RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
- RenderView* renderView = view();
- RoundedRect border = style()->getRoundedBorderFor(borderRect, renderView, includeLogicalLeftEdge, includeLogicalRightEdge);
+ RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
if (box && (box->nextLineBox() || box->prevLineBox())) {
- RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0, inlineBoxWidth, inlineBoxHeight), renderView, includeLogicalLeftEdge, includeLogicalRightEdge);
+ RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0, inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightEdge);
border.setRadii(segmentBorder.radii());
}
@@ -880,7 +876,6 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScaleFactor());
- RenderView* renderView = view();
switch (type) {
case SizeLength: {
LayoutSize tileSize = positioningAreaSize;
@@ -890,13 +885,13 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
if (layerWidth.isFixed())
tileSize.setWidth(layerWidth.value());
- else if (layerWidth.isPercent() || layerWidth.isViewportPercentage())
- tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize.width(), renderView));
+ else if (layerWidth.isPercent())
+ tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize.width()));
if (layerHeight.isFixed())
tileSize.setHeight(layerHeight.value());
- else if (layerHeight.isPercent() || layerHeight.isViewportPercentage())
- tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height(), renderView));
+ else if (layerHeight.isPercent())
+ tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height()));
applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize);
@@ -1064,11 +1059,10 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
EFillRepeat backgroundRepeatX = fillLayer->repeatX();
EFillRepeat backgroundRepeatY = fillLayer->repeatY();
- RenderView* renderView = view();
int availableWidth = positioningAreaSize.width() - geometry.tileSize().width();
int availableHeight = positioningAreaSize.height() - geometry.tileSize().height();
- LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(), availableWidth, renderView, true);
+ LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(), availableWidth, true);
if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fillTileSize.width() > 0) {
long nrTiles = max(1l, lroundf((float)positioningAreaSize.width() / fillTileSize.width()));
@@ -1082,7 +1076,7 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
geometry.setSpaceSize(IntSize());
}
- LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(), availableHeight, renderView, true);
+ LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(), availableHeight, true);
if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fillTileSize.height() > 0) {
long nrTiles = max(1l, lroundf((float)positioningAreaSize.height() / fillTileSize.height()));
@@ -1104,7 +1098,7 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
int actualWidth = geometry.tileSize().width() + space;
if (space >= 0) {
- computedXPosition = minimumValueForLength(Length(), availableWidth, renderView, true);
+ computedXPosition = minimumValueForLength(Length(), availableWidth, true);
geometry.setSpaceSize(IntSize(space, 0));
geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0);
} else {
@@ -1125,7 +1119,7 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
int actualHeight = geometry.tileSize().height() + space;
if (space >= 0) {
- computedYPosition = minimumValueForLength(Length(), availableHeight, renderView, true);
+ computedYPosition = minimumValueForLength(Length(), availableHeight, true);
geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space));
geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computedYPosition + top) % actualHeight : 0);
} else {
@@ -1145,13 +1139,13 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
geometry.setDestOrigin(geometry.destRect().location());
}
-static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, LayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent, RenderView* renderView)
+static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, LayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent)
{
if (borderSlice.isNumber())
return borderSlice.number() * borderSide;
if (borderSlice.length().isAuto())
return imageSide;
- return valueForLength(borderSlice.length(), boxExtent, renderView);
+ return valueForLength(borderSlice.length(), boxExtent);
}
bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style,
@@ -1180,21 +1174,20 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
int imageWidth = imageSize.width();
int imageHeight = imageSize.height();
- RenderView* renderView = view();
float imageScaleFactor = styleImage->imageScaleFactor();
- int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight, renderView)) * imageScaleFactor;
- int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth, renderView)) * imageScaleFactor;
- int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight, renderView)) * imageScaleFactor;
- int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth, renderView)) * imageScaleFactor;
+ int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight)) * imageScaleFactor;
+ int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth)) * imageScaleFactor;
+ int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight)) * imageScaleFactor;
+ int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth)) * imageScaleFactor;
ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
ENinePieceImageRule vRule = ninePieceImage.verticalRule();
- int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height(), renderView);
- int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width(), renderView);
- int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height(), renderView);
- int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width(), renderView);
+ int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height());
+ int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width());
+ int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height());
+ int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width());
// Reduce the widths if they're too large.
// The spec says: Given Lwidth as the width of the border image area, Lheight as its height, and Wside as the border image width
@@ -1744,7 +1737,7 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect&
BorderEdge edges[4];
getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightEdge);
- RoundedRect outerBorder = style->getRoundedBorderFor(rect, view(), includeLogicalLeftEdge, includeLogicalRightEdge);
+ RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge);
bool haveAlphaColor = false;
@@ -2476,7 +2469,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
return;
RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge)
- : s->getRoundedBorderFor(paintRect, view(), includeLogicalLeftEdge, includeLogicalRightEdge);
+ : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge);
bool hasBorderRadius = s->hasBorderRadius();
bool isHorizontal = s->isHorizontalWritingMode();
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderFlexibleBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698