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

Side by Side 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, 11 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 unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderFlexibleBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 LayoutSize offset = accumulateInFlowPositionOffsets(this); 233 LayoutSize offset = accumulateInFlowPositionOffsets(this);
234 234
235 RenderBlock* containingBlock = this->containingBlock(); 235 RenderBlock* containingBlock = this->containingBlock();
236 236
237 // Objects that shrink to avoid floats normally use available line width whe n computing containing block width. However 237 // Objects that shrink to avoid floats normally use available line width whe n computing containing block width. However
238 // in the case of relative positioning using percentages, we can't do this. The offset should always be resolved using the 238 // in the case of relative positioning using percentages, we can't do this. The offset should always be resolved using the
239 // available width of the containing block. Therefore we don't use containi ngBlockLogicalWidthForContent() here, but instead explicitly 239 // available width of the containing block. Therefore we don't use containi ngBlockLogicalWidthForContent() here, but instead explicitly
240 // call availableWidth on our containing block. 240 // call availableWidth on our containing block.
241 if (!style()->left().isAuto()) { 241 if (!style()->left().isAuto()) {
242 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig htDirection()) 242 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig htDirection())
243 offset.setWidth(-valueForLength(style()->right(), containingBlock->a vailableWidth(), view())); 243 offset.setWidth(-valueForLength(style()->right(), containingBlock->a vailableWidth()));
244 else 244 else
245 offset.expand(valueForLength(style()->left(), containingBlock->avail ableWidth(), view()), 0); 245 offset.expand(valueForLength(style()->left(), containingBlock->avail ableWidth()), 0);
246 } else if (!style()->right().isAuto()) { 246 } else if (!style()->right().isAuto()) {
247 offset.expand(-valueForLength(style()->right(), containingBlock->availab leWidth(), view()), 0); 247 offset.expand(-valueForLength(style()->right(), containingBlock->availab leWidth()), 0);
248 } 248 }
249 249
250 // If the containing block of a relatively positioned element does not 250 // If the containing block of a relatively positioned element does not
251 // specify a height, a percentage top or bottom offset should be resolved as 251 // specify a height, a percentage top or bottom offset should be resolved as
252 // auto. An exception to this is if the containing block has the WinIE quirk 252 // auto. An exception to this is if the containing block has the WinIE quirk
253 // where <html> and <body> assume the size of the viewport. In this case, 253 // where <html> and <body> assume the size of the viewport. In this case,
254 // calculate the percent offset based on this height. 254 // calculate the percent offset based on this height.
255 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. 255 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>.
256 if (!style()->top().isAuto() 256 if (!style()->top().isAuto()
257 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() 257 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
258 || !style()->top().isPercent() 258 || !style()->top().isPercent()
259 || containingBlock->stretchesToViewport())) 259 || containingBlock->stretchesToViewport()))
260 offset.expand(0, valueForLength(style()->top(), containingBlock->availab leHeight(), view())); 260 offset.expand(0, valueForLength(style()->top(), containingBlock->availab leHeight()));
261 261
262 else if (!style()->bottom().isAuto() 262 else if (!style()->bottom().isAuto()
263 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() 263 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
264 || !style()->bottom().isPercent() 264 || !style()->bottom().isPercent()
265 || containingBlock->stretchesToViewport())) 265 || containingBlock->stretchesToViewport()))
266 offset.expand(0, -valueForLength(style()->bottom(), containingBlock->ava ilableHeight(), view())); 266 offset.expand(0, -valueForLength(style()->bottom(), containingBlock->ava ilableHeight()));
267 267
268 return offset; 268 return offset;
269 } 269 }
270 270
271 LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const L ayoutPoint& startPoint) const 271 LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const L ayoutPoint& startPoint) const
272 { 272 {
273 // If the element is the HTML body element or doesn't have a parent 273 // If the element is the HTML body element or doesn't have a parent
274 // return 0 and stop this algorithm. 274 // return 0 and stop this algorithm.
275 if (isBody() || !parent()) 275 if (isBody() || !parent())
276 return LayoutPoint(); 276 return LayoutPoint();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& viewportRect) const 322 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& viewportRect) const
323 { 323 {
324 RenderBlock* containingBlock = this->containingBlock(); 324 RenderBlock* containingBlock = this->containingBlock();
325 325
326 LayoutRect containerContentRect = containingBlock->contentBoxRect(); 326 LayoutRect containerContentRect = containingBlock->contentBoxRect();
327 LayoutUnit maxWidth = containingBlock->availableLogicalWidth(); 327 LayoutUnit maxWidth = containingBlock->availableLogicalWidth();
328 328
329 // Sticky positioned element ignore any override logical width on the contai ning block (as they don't call 329 // Sticky positioned element ignore any override logical width on the contai ning block (as they don't call
330 // containingBlockLogicalWidthForContent). It's unclear whether this is tota lly fine. 330 // containingBlockLogicalWidthForContent). It's unclear whether this is tota lly fine.
331 LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWid th, view()), 331 LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWid th),
332 minimumValueForLength(style()->marginRight(), maxWidth, view()), 332 minimumValueForLength(style()->marginRight(), maxWidth),
333 minimumValueForLength(style()->marginBottom(), maxWidth, view()), 333 minimumValueForLength(style()->marginBottom(), maxWidth),
334 minimumValueForLength(style()->marginLeft(), maxWidth, view())); 334 minimumValueForLength(style()->marginLeft(), maxWidth));
335 335
336 // Compute the container-relative area within which the sticky element is al lowed to move. 336 // Compute the container-relative area within which the sticky element is al lowed to move.
337 containerContentRect.contract(minMargin); 337 containerContentRect.contract(minMargin);
338 // Map to the view to avoid including page scale factor. 338 // Map to the view to avoid including page scale factor.
339 constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainer Quad(FloatRect(containerContentRect), view()).boundingBox()); 339 constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainer Quad(FloatRect(containerContentRect), view()).boundingBox());
340 340
341 LayoutRect stickyBoxRect = frameRectForStickyPositioning(); 341 LayoutRect stickyBoxRect = frameRectForStickyPositioning();
342 LayoutRect flippedStickyBoxRect = stickyBoxRect; 342 LayoutRect flippedStickyBoxRect = stickyBoxRect;
343 containingBlock->flipForWritingMode(flippedStickyBoxRect); 343 containingBlock->flipForWritingMode(flippedStickyBoxRect);
344 LayoutPoint stickyLocation = flippedStickyBoxRect.location(); 344 LayoutPoint stickyLocation = flippedStickyBoxRect.location();
345 345
346 // FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms. 346 // FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms.
347 // Map to the view to avoid including page scale factor. 347 // Map to the view to avoid including page scale factor.
348 FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRec t(FloatPoint(), containingBlock->size()), view()).boundingBox(); 348 FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRec t(FloatPoint(), containingBlock->size()), view()).boundingBox();
349 349
350 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed. 350 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed.
351 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size()); 351 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size());
352 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect); 352 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
353 353
354 if (!style()->left().isAuto()) { 354 if (!style()->left().isAuto()) {
355 constraints.setLeftOffset(valueForLength(style()->left(), viewportRect.w idth(), view())); 355 constraints.setLeftOffset(valueForLength(style()->left(), viewportRect.w idth()));
356 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft); 356 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
357 } 357 }
358 358
359 if (!style()->right().isAuto()) { 359 if (!style()->right().isAuto()) {
360 constraints.setRightOffset(valueForLength(style()->right(), viewportRect .width(), view())); 360 constraints.setRightOffset(valueForLength(style()->right(), viewportRect .width()));
361 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight); 361 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
362 } 362 }
363 363
364 if (!style()->top().isAuto()) { 364 if (!style()->top().isAuto()) {
365 constraints.setTopOffset(valueForLength(style()->top(), viewportRect.hei ght(), view())); 365 constraints.setTopOffset(valueForLength(style()->top(), viewportRect.hei ght()));
366 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 366 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
367 } 367 }
368 368
369 if (!style()->bottom().isAuto()) { 369 if (!style()->bottom().isAuto()) {
370 constraints.setBottomOffset(valueForLength(style()->bottom(), viewportRe ct.height(), view())); 370 constraints.setBottomOffset(valueForLength(style()->bottom(), viewportRe ct.height()));
371 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom); 371 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
372 } 372 }
373 } 373 }
374 374
375 LayoutSize RenderBoxModelObject::stickyPositionOffset() const 375 LayoutSize RenderBoxModelObject::stickyPositionOffset() const
376 { 376 {
377 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibleCon tentRect(); 377 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibleCon tentRect();
378 378
379 StickyPositionViewportConstraints constraints; 379 StickyPositionViewportConstraints constraints;
380 computeStickyPositionConstraints(constraints, viewportRect); 380 computeStickyPositionConstraints(constraints, viewportRect);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 415
416 int RenderBoxModelObject::pixelSnappedOffsetHeight() const 416 int RenderBoxModelObject::pixelSnappedOffsetHeight() const
417 { 417 {
418 return snapSizeToPixel(offsetHeight(), offsetTop()); 418 return snapSizeToPixel(offsetHeight(), offsetTop());
419 } 419 }
420 420
421 LayoutUnit RenderBoxModelObject::computedCSSPadding(Length padding) const 421 LayoutUnit RenderBoxModelObject::computedCSSPadding(Length padding) const
422 { 422 {
423 LayoutUnit w = 0; 423 LayoutUnit w = 0;
424 RenderView* renderView = 0;
425 if (padding.isPercent()) 424 if (padding.isPercent())
426 w = containingBlockLogicalWidthForContent(); 425 w = containingBlockLogicalWidthForContent();
427 else if (padding.isViewportPercentage()) 426 return minimumValueForLength(padding, w);
428 renderView = view();
429 return minimumValueForLength(padding, w, renderView);
430 } 427 }
431 428
432 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht, 429 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& bor derRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeig ht,
433 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const 430 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
434 { 431 {
435 RenderView* renderView = view(); 432 RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogical LeftEdge, includeLogicalRightEdge);
436 RoundedRect border = style()->getRoundedBorderFor(borderRect, renderView, in cludeLogicalLeftEdge, includeLogicalRightEdge);
437 if (box && (box->nextLineBox() || box->prevLineBox())) { 433 if (box && (box->nextLineBox() || box->prevLineBox())) {
438 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), renderView, includeLogicalLeftEdge, includeL ogicalRightEdge); 434 RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0 , inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightE dge);
439 border.setRadii(segmentBorder.radii()); 435 border.setRadii(segmentBorder.radii());
440 } 436 }
441 437
442 return border; 438 return border;
443 } 439 }
444 440
445 void RenderBoxModelObject::clipRoundedInnerRect(GraphicsContext * context, const LayoutRect& rect, const RoundedRect& clipRect) 441 void RenderBoxModelObject::clipRoundedInnerRect(GraphicsContext * context, const LayoutRect& rect, const RoundedRect& clipRect)
446 { 442 {
447 if (clipRect.isRenderable()) 443 if (clipRect.isRenderable())
448 context->clipRoundedRect(clipRect); 444 context->clipRoundedRect(clipRect);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t ileSize.height().ceil() : tileSize.height().floor()); 869 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t ileSize.height().ceil() : tileSize.height().floor());
874 } 870 }
875 871
876 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const 872 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
877 { 873 {
878 StyleImage* image = fillLayer->image(); 874 StyleImage* image = fillLayer->image();
879 EFillSizeType type = fillLayer->size().type; 875 EFillSizeType type = fillLayer->size().type;
880 876
881 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi oningAreaSize, ScaleByEffectiveZoom); 877 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi oningAreaSize, ScaleByEffectiveZoom);
882 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal eFactor()); 878 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal eFactor());
883 RenderView* renderView = view();
884 switch (type) { 879 switch (type) {
885 case SizeLength: { 880 case SizeLength: {
886 LayoutSize tileSize = positioningAreaSize; 881 LayoutSize tileSize = positioningAreaSize;
887 882
888 Length layerWidth = fillLayer->size().size.width(); 883 Length layerWidth = fillLayer->size().size.width();
889 Length layerHeight = fillLayer->size().size.height(); 884 Length layerHeight = fillLayer->size().size.height();
890 885
891 if (layerWidth.isFixed()) 886 if (layerWidth.isFixed())
892 tileSize.setWidth(layerWidth.value()); 887 tileSize.setWidth(layerWidth.value());
893 else if (layerWidth.isPercent() || layerWidth.isViewportPercentage() ) 888 else if (layerWidth.isPercent())
894 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize .width(), renderView)); 889 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize .width()));
895 890
896 if (layerHeight.isFixed()) 891 if (layerHeight.isFixed())
897 tileSize.setHeight(layerHeight.value()); 892 tileSize.setHeight(layerHeight.value());
898 else if (layerHeight.isPercent() || layerHeight.isViewportPercentage ()) 893 else if (layerHeight.isPercent())
899 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi ze.height(), renderView)); 894 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi ze.height()));
900 895
901 applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize); 896 applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize);
902 897
903 // If one of the values is auto we have to use the appropriate 898 // If one of the values is auto we have to use the appropriate
904 // scale to maintain our aspect ratio. 899 // scale to maintain our aspect ratio.
905 if (layerWidth.isAuto() && !layerHeight.isAuto()) { 900 if (layerWidth.isAuto() && !layerHeight.isAuto()) {
906 if (imageIntrinsicSize.height()) 901 if (imageIntrinsicSize.height())
907 tileSize.setWidth(imageIntrinsicSize.width() * tileSize.heig ht() / imageIntrinsicSize.height()); 902 tileSize.setWidth(imageIntrinsicSize.width() * tileSize.heig ht() / imageIntrinsicSize.height());
908 } else if (!layerWidth.isAuto() && layerHeight.isAuto()) { 903 } else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
909 if (imageIntrinsicSize.width()) 904 if (imageIntrinsicSize.width())
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 positioningAreaSize = geometry.destRect().size(); 1052 positioningAreaSize = geometry.destRect().size();
1058 } 1053 }
1059 1054
1060 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this; 1055 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this;
1061 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ; 1056 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ;
1062 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi llTileSize, style()->effectiveZoom()); 1057 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi llTileSize, style()->effectiveZoom());
1063 geometry.setTileSize(fillTileSize); 1058 geometry.setTileSize(fillTileSize);
1064 1059
1065 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); 1060 EFillRepeat backgroundRepeatX = fillLayer->repeatX();
1066 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); 1061 EFillRepeat backgroundRepeatY = fillLayer->repeatY();
1067 RenderView* renderView = view();
1068 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width (); 1062 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width ();
1069 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght(); 1063 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght();
1070 1064
1071 LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(), availableWidth, renderView, true); 1065 LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(), availableWidth, true);
1072 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) { 1066 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) {
1073 long nrTiles = max(1l, lroundf((float)positioningAreaSize.width() / fill TileSize.width())); 1067 long nrTiles = max(1l, lroundf((float)positioningAreaSize.width() / fill TileSize.width()));
1074 1068
1075 if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != Rou ndFill) { 1069 if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != Rou ndFill) {
1076 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w idth() / (nrTiles * fillTileSize.width())); 1070 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w idth() / (nrTiles * fillTileSize.width()));
1077 } 1071 }
1078 1072
1079 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles); 1073 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles);
1080 geometry.setTileSize(fillTileSize); 1074 geometry.setTileSize(fillTileSize);
1081 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); 1075 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
1082 geometry.setSpaceSize(IntSize()); 1076 geometry.setSpaceSize(IntSize());
1083 } 1077 }
1084 1078
1085 LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(), availableHeight, renderView, true); 1079 LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(), availableHeight, true);
1086 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi llTileSize.height() > 0) { 1080 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi llTileSize.height() > 0) {
1087 long nrTiles = max(1l, lroundf((float)positioningAreaSize.height() / fil lTileSize.height())); 1081 long nrTiles = max(1l, lroundf((float)positioningAreaSize.height() / fil lTileSize.height()));
1088 1082
1089 if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != Roun dFill) { 1083 if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != Roun dFill) {
1090 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height())); 1084 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height()));
1091 } 1085 }
1092 1086
1093 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles); 1087 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles);
1094 geometry.setTileSize(fillTileSize); 1088 geometry.setTileSize(fillTileSize);
1095 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ; 1089 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ;
1096 geometry.setSpaceSize(IntSize()); 1090 geometry.setSpaceSize(IntSize());
1097 } 1091 }
1098 1092
1099 if (backgroundRepeatX == RepeatFill) { 1093 if (backgroundRepeatX == RepeatFill) {
1100 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); 1094 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
1101 geometry.setSpaceSize(IntSize()); 1095 geometry.setSpaceSize(IntSize());
1102 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) { 1096 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) {
1103 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi dth()); 1097 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi dth());
1104 int actualWidth = geometry.tileSize().width() + space; 1098 int actualWidth = geometry.tileSize().width() + space;
1105 1099
1106 if (space >= 0) { 1100 if (space >= 0) {
1107 computedXPosition = minimumValueForLength(Length(), availableWidth, renderView, true); 1101 computedXPosition = minimumValueForLength(Length(), availableWidth, true);
1108 geometry.setSpaceSize(IntSize(space, 0)); 1102 geometry.setSpaceSize(IntSize(space, 0));
1109 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP osition + left) % actualWidth : 0); 1103 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP osition + left) % actualWidth : 0);
1110 } else { 1104 } else {
1111 backgroundRepeatX = NoRepeatFill; 1105 backgroundRepeatX = NoRepeatFill;
1112 } 1106 }
1113 } 1107 }
1114 if (backgroundRepeatX == NoRepeatFill) { 1108 if (backgroundRepeatX == NoRepeatFill) {
1115 int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWid th - computedXPosition : computedXPosition; 1109 int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWid th - computedXPosition : computedXPosition;
1116 geometry.setNoRepeatX(left + xOffset); 1110 geometry.setNoRepeatX(left + xOffset);
1117 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height())); 1111 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height()));
1118 } 1112 }
1119 1113
1120 if (backgroundRepeatY == RepeatFill) { 1114 if (backgroundRepeatY == RepeatFill) {
1121 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ; 1115 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ;
1122 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); 1116 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0));
1123 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) { 1117 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) {
1124 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h eight()); 1118 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h eight());
1125 int actualHeight = geometry.tileSize().height() + space; 1119 int actualHeight = geometry.tileSize().height() + space;
1126 1120
1127 if (space >= 0) { 1121 if (space >= 0) {
1128 computedYPosition = minimumValueForLength(Length(), availableHeight, renderView, true); 1122 computedYPosition = minimumValueForLength(Length(), availableHeight, true);
1129 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space)); 1123 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space));
1130 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed YPosition + top) % actualHeight : 0); 1124 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed YPosition + top) % actualHeight : 0);
1131 } else { 1125 } else {
1132 backgroundRepeatY = NoRepeatFill; 1126 backgroundRepeatY = NoRepeatFill;
1133 } 1127 }
1134 } 1128 }
1135 if (backgroundRepeatY == NoRepeatFill) { 1129 if (backgroundRepeatY == NoRepeatFill) {
1136 int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHe ight - computedYPosition : computedYPosition; 1130 int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHe ight - computedYPosition : computedYPosition;
1137 geometry.setNoRepeatY(top + yOffset); 1131 geometry.setNoRepeatY(top + yOffset);
1138 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); 1132 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0));
1139 } 1133 }
1140 1134
1141 if (fixedAttachment) 1135 if (fixedAttachment)
1142 geometry.useFixedAttachment(snappedPaintRect.location()); 1136 geometry.useFixedAttachment(snappedPaintRect.location());
1143 1137
1144 geometry.clip(snappedPaintRect); 1138 geometry.clip(snappedPaintRect);
1145 geometry.setDestOrigin(geometry.destRect().location()); 1139 geometry.setDestOrigin(geometry.destRect().location());
1146 } 1140 }
1147 1141
1148 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent, RenderView* re nderView) 1142 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent)
1149 { 1143 {
1150 if (borderSlice.isNumber()) 1144 if (borderSlice.isNumber())
1151 return borderSlice.number() * borderSide; 1145 return borderSlice.number() * borderSide;
1152 if (borderSlice.length().isAuto()) 1146 if (borderSlice.length().isAuto())
1153 return imageSide; 1147 return imageSide;
1154 return valueForLength(borderSlice.length(), boxExtent, renderView); 1148 return valueForLength(borderSlice.length(), boxExtent);
1155 } 1149 }
1156 1150
1157 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style, 1151 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style,
1158 const NinePieceImage& ninePieceIm age, CompositeOperator op) 1152 const NinePieceImage& ninePieceIm age, CompositeOperator op)
1159 { 1153 {
1160 StyleImage* styleImage = ninePieceImage.image(); 1154 StyleImage* styleImage = ninePieceImage.image();
1161 if (!styleImage) 1155 if (!styleImage)
1162 return false; 1156 return false;
1163 1157
1164 if (!styleImage->isLoaded()) 1158 if (!styleImage->isLoaded())
1165 return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either. 1159 return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either.
1166 1160
1167 if (!styleImage->canRender(this, style->effectiveZoom())) 1161 if (!styleImage->canRender(this, style->effectiveZoom()))
1168 return false; 1162 return false;
1169 1163
1170 // FIXME: border-image is broken with full page zooming when tiling has to h appen, since the tiling function 1164 // FIXME: border-image is broken with full page zooming when tiling has to h appen, since the tiling function
1171 // doesn't have any understanding of the zoom that is in effect on the tile. 1165 // doesn't have any understanding of the zoom that is in effect on the tile.
1172 LayoutRect rectWithOutsets = rect; 1166 LayoutRect rectWithOutsets = rect;
1173 rectWithOutsets.expand(style->imageOutsets(ninePieceImage)); 1167 rectWithOutsets.expand(style->imageOutsets(ninePieceImage));
1174 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); 1168 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets);
1175 1169
1176 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag eRect.size(), DoNotScaleByEffectiveZoom); 1170 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag eRect.size(), DoNotScaleByEffectiveZoom);
1177 1171
1178 // If both values are ‘auto’ then the intrinsic width and/or height of the i mage should be used, if any. 1172 // If both values are ‘auto’ then the intrinsic width and/or height of the i mage should be used, if any.
1179 styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoo m()); 1173 styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoo m());
1180 1174
1181 int imageWidth = imageSize.width(); 1175 int imageWidth = imageSize.width();
1182 int imageHeight = imageSize.height(); 1176 int imageHeight = imageSize.height();
1183 RenderView* renderView = view();
1184 1177
1185 float imageScaleFactor = styleImage->imageScaleFactor(); 1178 float imageScaleFactor = styleImage->imageScaleFactor();
1186 int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlic es().top(), imageHeight, renderView)) * imageScaleFactor; 1179 int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlic es().top(), imageHeight)) * imageScaleFactor;
1187 int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSli ces().right(), imageWidth, renderView)) * imageScaleFactor; 1180 int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSli ces().right(), imageWidth)) * imageScaleFactor;
1188 int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageS lices().bottom(), imageHeight, renderView)) * imageScaleFactor; 1181 int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageS lices().bottom(), imageHeight)) * imageScaleFactor;
1189 int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlic es().left(), imageWidth, renderView)) * imageScaleFactor; 1182 int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlic es().left(), imageWidth)) * imageScaleFactor;
1190 1183
1191 ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); 1184 ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
1192 ENinePieceImageRule vRule = ninePieceImage.verticalRule(); 1185 ENinePieceImageRule vRule = ninePieceImage.verticalRule();
1193 1186
1194 int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), s tyle->borderTopWidth(), topSlice, borderImageRect.height(), renderView); 1187 int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), s tyle->borderTopWidth(), topSlice, borderImageRect.height());
1195 int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right( ), style->borderRightWidth(), rightSlice, borderImageRect.width(), renderView); 1188 int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right( ), style->borderRightWidth(), rightSlice, borderImageRect.width());
1196 int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().botto m(), style->borderBottomWidth(), bottomSlice, borderImageRect.height(), renderVi ew); 1189 int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().botto m(), style->borderBottomWidth(), bottomSlice, borderImageRect.height());
1197 int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width(), renderView); 1190 int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width());
1198 1191
1199 // Reduce the widths if they're too large. 1192 // Reduce the widths if they're too large.
1200 // The spec says: Given Lwidth as the width of the border image area, Lheigh t as its height, and Wside as the border image width 1193 // The spec says: Given Lwidth as the width of the border image area, Lheigh t as its height, and Wside as the border image width
1201 // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbo ttom)). If f < 1, then all W are reduced by 1194 // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbo ttom)). If f < 1, then all W are reduced by
1202 // multiplying them by f. 1195 // multiplying them by f.
1203 int borderSideWidth = max(1, leftWidth + rightWidth); 1196 int borderSideWidth = max(1, leftWidth + rightWidth);
1204 int borderSideHeight = max(1, topWidth + bottomWidth); 1197 int borderSideHeight = max(1, topWidth + bottomWidth);
1205 float borderSideScaleFactor = min((float)borderImageRect.width() / borderSid eWidth, (float)borderImageRect.height() / borderSideHeight); 1198 float borderSideScaleFactor = min((float)borderImageRect.width() / borderSid eWidth, (float)borderImageRect.height() / borderSideHeight);
1206 if (borderSideScaleFactor < 1) { 1199 if (borderSideScaleFactor < 1) {
1207 topWidth *= borderSideScaleFactor; 1200 topWidth *= borderSideScaleFactor;
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 GraphicsContext* graphicsContext = info.context; 1730 GraphicsContext* graphicsContext = info.context;
1738 // border-image is not affected by border-radius. 1731 // border-image is not affected by border-radius.
1739 if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage())) 1732 if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
1740 return; 1733 return;
1741 1734
1742 if (graphicsContext->paintingDisabled()) 1735 if (graphicsContext->paintingDisabled())
1743 return; 1736 return;
1744 1737
1745 BorderEdge edges[4]; 1738 BorderEdge edges[4];
1746 getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightE dge); 1739 getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightE dge);
1747 RoundedRect outerBorder = style->getRoundedBorderFor(rect, view(), includeLo gicalLeftEdge, includeLogicalRightEdge); 1740 RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLef tEdge, includeLogicalRightEdge);
1748 RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdj ustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLef tEdge, includeLogicalRightEdge); 1741 RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdj ustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLef tEdge, includeLogicalRightEdge);
1749 1742
1750 bool haveAlphaColor = false; 1743 bool haveAlphaColor = false;
1751 bool haveAllSolidEdges = true; 1744 bool haveAllSolidEdges = true;
1752 bool haveAllDoubleEdges = true; 1745 bool haveAllDoubleEdges = true;
1753 int numEdgesVisible = 4; 1746 int numEdgesVisible = 4;
1754 bool allEdgesShareColor = true; 1747 bool allEdgesShareColor = true;
1755 int firstVisibleEdge = -1; 1748 int firstVisibleEdge = -1;
1756 BorderEdgeFlags edgesToDraw = 0; 1749 BorderEdgeFlags edgesToDraw = 0;
1757 1750
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 } 2462 }
2470 2463
2471 void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec t& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogical LeftEdge, bool includeLogicalRightEdge) 2464 void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec t& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogical LeftEdge, bool includeLogicalRightEdge)
2472 { 2465 {
2473 // FIXME: Deal with border-image. Would be great to use border-image as a m ask. 2466 // FIXME: Deal with border-image. Would be great to use border-image as a m ask.
2474 GraphicsContext* context = info.context; 2467 GraphicsContext* context = info.context;
2475 if (context->paintingDisabled() || !s->boxShadow()) 2468 if (context->paintingDisabled() || !s->boxShadow())
2476 return; 2469 return;
2477 2470
2478 RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(pa intRect, includeLogicalLeftEdge, includeLogicalRightEdge) 2471 RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(pa intRect, includeLogicalLeftEdge, includeLogicalRightEdge)
2479 : s->getRoundedBorderFor(pain tRect, view(), includeLogicalLeftEdge, includeLogicalRightEdge); 2472 : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogic alRightEdge);
2480 2473
2481 bool hasBorderRadius = s->hasBorderRadius(); 2474 bool hasBorderRadius = s->hasBorderRadius();
2482 bool isHorizontal = s->isHorizontalWritingMode(); 2475 bool isHorizontal = s->isHorizontalWritingMode();
2483 bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundCol or).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() == 255; 2476 bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundCol or).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() == 255;
2484 2477
2485 GraphicsContextStateSaver stateSaver(*context, false); 2478 GraphicsContextStateSaver stateSaver(*context, false);
2486 2479
2487 const ShadowList* shadowList = s->boxShadow(); 2480 const ShadowList* shadowList = s->boxShadow();
2488 for (size_t i = shadowList->shadows().size(); i--; ) { 2481 for (size_t i = shadowList->shadows().size(); i--; ) {
2489 const ShadowData& shadow = shadowList->shadows()[i]; 2482 const ShadowData& shadow = shadowList->shadows()[i];
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2814 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2822 for (RenderObject* child = startChild; child && child != endChild; ) { 2815 for (RenderObject* child = startChild; child && child != endChild; ) {
2823 // Save our next sibling as moveChildTo will clear it. 2816 // Save our next sibling as moveChildTo will clear it.
2824 RenderObject* nextSibling = child->nextSibling(); 2817 RenderObject* nextSibling = child->nextSibling();
2825 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2818 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2826 child = nextSibling; 2819 child = nextSibling;
2827 } 2820 }
2828 } 2821 }
2829 2822
2830 } // namespace WebCore 2823 } // namespace WebCore
OLDNEW
« 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