OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t
ileSize.height().ceil() : tileSize.height().floor()); | 870 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t
ileSize.height().ceil() : tileSize.height().floor()); |
875 } | 871 } |
876 | 872 |
877 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
const IntSize& positioningAreaSize) const | 873 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
const IntSize& positioningAreaSize) const |
878 { | 874 { |
879 StyleImage* image = fillLayer->image(); | 875 StyleImage* image = fillLayer->image(); |
880 EFillSizeType type = fillLayer->size().type; | 876 EFillSizeType type = fillLayer->size().type; |
881 | 877 |
882 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi
oningAreaSize, ScaleByEffectiveZoom); | 878 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi
oningAreaSize, ScaleByEffectiveZoom); |
883 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal
eFactor()); | 879 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal
eFactor()); |
884 RenderView* renderView = view(); | |
885 switch (type) { | 880 switch (type) { |
886 case SizeLength: { | 881 case SizeLength: { |
887 LayoutSize tileSize = positioningAreaSize; | 882 LayoutSize tileSize = positioningAreaSize; |
888 | 883 |
889 Length layerWidth = fillLayer->size().size.width(); | 884 Length layerWidth = fillLayer->size().size.width(); |
890 Length layerHeight = fillLayer->size().size.height(); | 885 Length layerHeight = fillLayer->size().size.height(); |
891 | 886 |
892 if (layerWidth.isFixed()) | 887 if (layerWidth.isFixed()) |
893 tileSize.setWidth(layerWidth.value()); | 888 tileSize.setWidth(layerWidth.value()); |
894 else if (layerWidth.isPercent() || layerWidth.isViewportPercentage()
) | 889 else if (layerWidth.isPercent()) |
895 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize
.width(), renderView)); | 890 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize
.width())); |
896 | 891 |
897 if (layerHeight.isFixed()) | 892 if (layerHeight.isFixed()) |
898 tileSize.setHeight(layerHeight.value()); | 893 tileSize.setHeight(layerHeight.value()); |
899 else if (layerHeight.isPercent() || layerHeight.isViewportPercentage
()) | 894 else if (layerHeight.isPercent()) |
900 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi
ze.height(), renderView)); | 895 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi
ze.height())); |
901 | 896 |
902 applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize); | 897 applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize); |
903 | 898 |
904 // If one of the values is auto we have to use the appropriate | 899 // If one of the values is auto we have to use the appropriate |
905 // scale to maintain our aspect ratio. | 900 // scale to maintain our aspect ratio. |
906 if (layerWidth.isAuto() && !layerHeight.isAuto()) { | 901 if (layerWidth.isAuto() && !layerHeight.isAuto()) { |
907 if (imageIntrinsicSize.height()) | 902 if (imageIntrinsicSize.height()) |
908 tileSize.setWidth(imageIntrinsicSize.width() * tileSize.heig
ht() / imageIntrinsicSize.height()); | 903 tileSize.setWidth(imageIntrinsicSize.width() * tileSize.heig
ht() / imageIntrinsicSize.height()); |
909 } else if (!layerWidth.isAuto() && layerHeight.isAuto()) { | 904 } else if (!layerWidth.isAuto() && layerHeight.isAuto()) { |
910 if (imageIntrinsicSize.width()) | 905 if (imageIntrinsicSize.width()) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 positioningAreaSize = geometry.destRect().size(); | 1042 positioningAreaSize = geometry.destRect().size(); |
1048 } | 1043 } |
1049 | 1044 |
1050 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject
: this; | 1045 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject
: this; |
1051 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; | 1046 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; |
1052 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi
llTileSize, style()->effectiveZoom()); | 1047 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi
llTileSize, style()->effectiveZoom()); |
1053 geometry.setTileSize(fillTileSize); | 1048 geometry.setTileSize(fillTileSize); |
1054 | 1049 |
1055 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); | 1050 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); |
1056 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); | 1051 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); |
1057 RenderView* renderView = view(); | |
1058 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); | 1052 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); |
1059 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); | 1053 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); |
1060 | 1054 |
1061 LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(),
availableWidth, renderView, true); | 1055 LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(),
availableWidth, true); |
1062 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { | 1056 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { |
1063 long nrTiles = max(1l, lroundf((float)positioningAreaSize.width() / fill
TileSize.width())); | 1057 long nrTiles = max(1l, lroundf((float)positioningAreaSize.width() / fill
TileSize.width())); |
1064 | 1058 |
1065 if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != Rou
ndFill) { | 1059 if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != Rou
ndFill) { |
1066 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w
idth() / (nrTiles * fillTileSize.width())); | 1060 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w
idth() / (nrTiles * fillTileSize.width())); |
1067 } | 1061 } |
1068 | 1062 |
1069 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles); | 1063 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles); |
1070 geometry.setTileSize(fillTileSize); | 1064 geometry.setTileSize(fillTileSize); |
1071 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid
th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); | 1065 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid
th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); |
1072 geometry.setSpaceSize(IntSize()); | 1066 geometry.setSpaceSize(IntSize()); |
1073 } | 1067 } |
1074 | 1068 |
1075 LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(),
availableHeight, renderView, true); | 1069 LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(),
availableHeight, true); |
1076 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi
llTileSize.height() > 0) { | 1070 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi
llTileSize.height() > 0) { |
1077 long nrTiles = max(1l, lroundf((float)positioningAreaSize.height() / fil
lTileSize.height())); | 1071 long nrTiles = max(1l, lroundf((float)positioningAreaSize.height() / fil
lTileSize.height())); |
1078 | 1072 |
1079 if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != Roun
dFill) { | 1073 if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != Roun
dFill) { |
1080 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei
ght() / (nrTiles * fillTileSize.height())); | 1074 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei
ght() / (nrTiles * fillTileSize.height())); |
1081 } | 1075 } |
1082 | 1076 |
1083 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles); | 1077 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles); |
1084 geometry.setTileSize(fillTileSize); | 1078 geometry.setTileSize(fillTileSize); |
1085 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he
ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0)
; | 1079 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he
ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0)
; |
1086 geometry.setSpaceSize(IntSize()); | 1080 geometry.setSpaceSize(IntSize()); |
1087 } | 1081 } |
1088 | 1082 |
1089 if (backgroundRepeatX == RepeatFill) { | 1083 if (backgroundRepeatX == RepeatFill) { |
1090 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid
th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); | 1084 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid
th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); |
1091 geometry.setSpaceSize(IntSize()); | 1085 geometry.setSpaceSize(IntSize()); |
1092 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) { | 1086 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) { |
1093 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi
dth()); | 1087 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi
dth()); |
1094 int actualWidth = geometry.tileSize().width() + space; | 1088 int actualWidth = geometry.tileSize().width() + space; |
1095 | 1089 |
1096 if (space >= 0) { | 1090 if (space >= 0) { |
1097 computedXPosition = minimumValueForLength(Length(), availableWidth,
renderView, true); | 1091 computedXPosition = minimumValueForLength(Length(), availableWidth,
true); |
1098 geometry.setSpaceSize(IntSize(space, 0)); | 1092 geometry.setSpaceSize(IntSize(space, 0)); |
1099 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP
osition + left) % actualWidth : 0); | 1093 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP
osition + left) % actualWidth : 0); |
1100 } else { | 1094 } else { |
1101 backgroundRepeatX = NoRepeatFill; | 1095 backgroundRepeatX = NoRepeatFill; |
1102 } | 1096 } |
1103 } | 1097 } |
1104 if (backgroundRepeatX == NoRepeatFill) { | 1098 if (backgroundRepeatX == NoRepeatFill) { |
1105 int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWid
th - computedXPosition : computedXPosition; | 1099 int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWid
th - computedXPosition : computedXPosition; |
1106 geometry.setNoRepeatX(left + xOffset); | 1100 geometry.setNoRepeatX(left + xOffset); |
1107 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height())); | 1101 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height())); |
1108 } | 1102 } |
1109 | 1103 |
1110 if (backgroundRepeatY == RepeatFill) { | 1104 if (backgroundRepeatY == RepeatFill) { |
1111 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he
ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0)
; | 1105 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he
ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0)
; |
1112 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); | 1106 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); |
1113 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) { | 1107 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) { |
1114 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h
eight()); | 1108 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h
eight()); |
1115 int actualHeight = geometry.tileSize().height() + space; | 1109 int actualHeight = geometry.tileSize().height() + space; |
1116 | 1110 |
1117 if (space >= 0) { | 1111 if (space >= 0) { |
1118 computedYPosition = minimumValueForLength(Length(), availableHeight,
renderView, true); | 1112 computedYPosition = minimumValueForLength(Length(), availableHeight,
true); |
1119 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space)); | 1113 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space)); |
1120 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed
YPosition + top) % actualHeight : 0); | 1114 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed
YPosition + top) % actualHeight : 0); |
1121 } else { | 1115 } else { |
1122 backgroundRepeatY = NoRepeatFill; | 1116 backgroundRepeatY = NoRepeatFill; |
1123 } | 1117 } |
1124 } | 1118 } |
1125 if (backgroundRepeatY == NoRepeatFill) { | 1119 if (backgroundRepeatY == NoRepeatFill) { |
1126 int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHe
ight - computedYPosition : computedYPosition; | 1120 int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHe
ight - computedYPosition : computedYPosition; |
1127 geometry.setNoRepeatY(top + yOffset); | 1121 geometry.setNoRepeatY(top + yOffset); |
1128 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); | 1122 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); |
1129 } | 1123 } |
1130 | 1124 |
1131 if (fixedAttachment) | 1125 if (fixedAttachment) |
1132 geometry.useFixedAttachment(snappedPaintRect.location()); | 1126 geometry.useFixedAttachment(snappedPaintRect.location()); |
1133 | 1127 |
1134 geometry.clip(snappedPaintRect); | 1128 geometry.clip(snappedPaintRect); |
1135 geometry.setDestOrigin(geometry.destRect().location()); | 1129 geometry.setDestOrigin(geometry.destRect().location()); |
1136 } | 1130 } |
1137 | 1131 |
1138 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L
ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent, RenderView* re
nderView) | 1132 static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, L
ayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent) |
1139 { | 1133 { |
1140 if (borderSlice.isNumber()) | 1134 if (borderSlice.isNumber()) |
1141 return borderSlice.number() * borderSide; | 1135 return borderSlice.number() * borderSide; |
1142 if (borderSlice.length().isAuto()) | 1136 if (borderSlice.length().isAuto()) |
1143 return imageSide; | 1137 return imageSide; |
1144 return valueForLength(borderSlice.length(), boxExtent, renderView); | 1138 return valueForLength(borderSlice.length(), boxExtent); |
1145 } | 1139 } |
1146 | 1140 |
1147 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
const LayoutRect& rect, const RenderStyle* style, | 1141 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
const LayoutRect& rect, const RenderStyle* style, |
1148 const NinePieceImage& ninePieceIm
age, CompositeOperator op) | 1142 const NinePieceImage& ninePieceIm
age, CompositeOperator op) |
1149 { | 1143 { |
1150 StyleImage* styleImage = ninePieceImage.image(); | 1144 StyleImage* styleImage = ninePieceImage.image(); |
1151 if (!styleImage) | 1145 if (!styleImage) |
1152 return false; | 1146 return false; |
1153 | 1147 |
1154 if (!styleImage->isLoaded()) | 1148 if (!styleImage->isLoaded()) |
1155 return true; // Never paint a nine-piece image incrementally, but don't
paint the fallback borders either. | 1149 return true; // Never paint a nine-piece image incrementally, but don't
paint the fallback borders either. |
1156 | 1150 |
1157 if (!styleImage->canRender(this, style->effectiveZoom())) | 1151 if (!styleImage->canRender(this, style->effectiveZoom())) |
1158 return false; | 1152 return false; |
1159 | 1153 |
1160 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function | 1154 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function |
1161 // doesn't have any understanding of the zoom that is in effect on the tile. | 1155 // doesn't have any understanding of the zoom that is in effect on the tile. |
1162 LayoutRect rectWithOutsets = rect; | 1156 LayoutRect rectWithOutsets = rect; |
1163 rectWithOutsets.expand(style->imageOutsets(ninePieceImage)); | 1157 rectWithOutsets.expand(style->imageOutsets(ninePieceImage)); |
1164 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); | 1158 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); |
1165 | 1159 |
1166 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag
eRect.size(), DoNotScaleByEffectiveZoom); | 1160 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag
eRect.size(), DoNotScaleByEffectiveZoom); |
1167 | 1161 |
1168 // If both values are ‘auto’ then the intrinsic width and/or height of the i
mage should be used, if any. | 1162 // If both values are ‘auto’ then the intrinsic width and/or height of the i
mage should be used, if any. |
1169 styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoo
m()); | 1163 styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoo
m()); |
1170 | 1164 |
1171 int imageWidth = imageSize.width(); | 1165 int imageWidth = imageSize.width(); |
1172 int imageHeight = imageSize.height(); | 1166 int imageHeight = imageSize.height(); |
1173 RenderView* renderView = view(); | |
1174 | 1167 |
1175 float imageScaleFactor = styleImage->imageScaleFactor(); | 1168 float imageScaleFactor = styleImage->imageScaleFactor(); |
1176 int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlic
es().top(), imageHeight, renderView)) * imageScaleFactor; | 1169 int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlic
es().top(), imageHeight)) * imageScaleFactor; |
1177 int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSli
ces().right(), imageWidth, renderView)) * imageScaleFactor; | 1170 int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSli
ces().right(), imageWidth)) * imageScaleFactor; |
1178 int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageS
lices().bottom(), imageHeight, renderView)) * imageScaleFactor; | 1171 int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageS
lices().bottom(), imageHeight)) * imageScaleFactor; |
1179 int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlic
es().left(), imageWidth, renderView)) * imageScaleFactor; | 1172 int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlic
es().left(), imageWidth)) * imageScaleFactor; |
1180 | 1173 |
1181 ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); | 1174 ENinePieceImageRule hRule = ninePieceImage.horizontalRule(); |
1182 ENinePieceImageRule vRule = ninePieceImage.verticalRule(); | 1175 ENinePieceImageRule vRule = ninePieceImage.verticalRule(); |
1183 | 1176 |
1184 int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), s
tyle->borderTopWidth(), topSlice, borderImageRect.height(), renderView); | 1177 int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), s
tyle->borderTopWidth(), topSlice, borderImageRect.height()); |
1185 int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(
), style->borderRightWidth(), rightSlice, borderImageRect.width(), renderView); | 1178 int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(
), style->borderRightWidth(), rightSlice, borderImageRect.width()); |
1186 int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().botto
m(), style->borderBottomWidth(), bottomSlice, borderImageRect.height(), renderVi
ew); | 1179 int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().botto
m(), style->borderBottomWidth(), bottomSlice, borderImageRect.height()); |
1187 int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(),
style->borderLeftWidth(), leftSlice, borderImageRect.width(), renderView); | 1180 int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(),
style->borderLeftWidth(), leftSlice, borderImageRect.width()); |
1188 | 1181 |
1189 // Reduce the widths if they're too large. | 1182 // Reduce the widths if they're too large. |
1190 // 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 | 1183 // 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 |
1191 // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbo
ttom)). If f < 1, then all W are reduced by | 1184 // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbo
ttom)). If f < 1, then all W are reduced by |
1192 // multiplying them by f. | 1185 // multiplying them by f. |
1193 int borderSideWidth = max(1, leftWidth + rightWidth); | 1186 int borderSideWidth = max(1, leftWidth + rightWidth); |
1194 int borderSideHeight = max(1, topWidth + bottomWidth); | 1187 int borderSideHeight = max(1, topWidth + bottomWidth); |
1195 float borderSideScaleFactor = min((float)borderImageRect.width() / borderSid
eWidth, (float)borderImageRect.height() / borderSideHeight); | 1188 float borderSideScaleFactor = min((float)borderImageRect.width() / borderSid
eWidth, (float)borderImageRect.height() / borderSideHeight); |
1196 if (borderSideScaleFactor < 1) { | 1189 if (borderSideScaleFactor < 1) { |
1197 topWidth *= borderSideScaleFactor; | 1190 topWidth *= borderSideScaleFactor; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 GraphicsContext* graphicsContext = info.context; | 1720 GraphicsContext* graphicsContext = info.context; |
1728 // border-image is not affected by border-radius. | 1721 // border-image is not affected by border-radius. |
1729 if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage())) | 1722 if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage())) |
1730 return; | 1723 return; |
1731 | 1724 |
1732 if (graphicsContext->paintingDisabled()) | 1725 if (graphicsContext->paintingDisabled()) |
1733 return; | 1726 return; |
1734 | 1727 |
1735 BorderEdge edges[4]; | 1728 BorderEdge edges[4]; |
1736 getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightE
dge); | 1729 getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightE
dge); |
1737 RoundedRect outerBorder = style->getRoundedBorderFor(rect, view(), includeLo
gicalLeftEdge, includeLogicalRightEdge); | 1730 RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLef
tEdge, includeLogicalRightEdge); |
1738 RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdj
ustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLef
tEdge, includeLogicalRightEdge); | 1731 RoundedRect innerBorder = style->getRoundedInnerBorderFor(borderInnerRectAdj
ustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLef
tEdge, includeLogicalRightEdge); |
1739 | 1732 |
1740 bool haveAlphaColor = false; | 1733 bool haveAlphaColor = false; |
1741 bool haveAllSolidEdges = true; | 1734 bool haveAllSolidEdges = true; |
1742 bool haveAllDoubleEdges = true; | 1735 bool haveAllDoubleEdges = true; |
1743 int numEdgesVisible = 4; | 1736 int numEdgesVisible = 4; |
1744 bool allEdgesShareColor = true; | 1737 bool allEdgesShareColor = true; |
1745 int firstVisibleEdge = -1; | 1738 int firstVisibleEdge = -1; |
1746 BorderEdgeFlags edgesToDraw = 0; | 1739 BorderEdgeFlags edgesToDraw = 0; |
1747 | 1740 |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2459 } | 2452 } |
2460 | 2453 |
2461 void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
t& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogical
LeftEdge, bool includeLogicalRightEdge) | 2454 void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
t& paintRect, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogical
LeftEdge, bool includeLogicalRightEdge) |
2462 { | 2455 { |
2463 // FIXME: Deal with border-image. Would be great to use border-image as a m
ask. | 2456 // FIXME: Deal with border-image. Would be great to use border-image as a m
ask. |
2464 GraphicsContext* context = info.context; | 2457 GraphicsContext* context = info.context; |
2465 if (context->paintingDisabled() || !s->boxShadow()) | 2458 if (context->paintingDisabled() || !s->boxShadow()) |
2466 return; | 2459 return; |
2467 | 2460 |
2468 RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(pa
intRect, includeLogicalLeftEdge, includeLogicalRightEdge) | 2461 RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(pa
intRect, includeLogicalLeftEdge, includeLogicalRightEdge) |
2469 : s->getRoundedBorderFor(pain
tRect, view(), includeLogicalLeftEdge, includeLogicalRightEdge); | 2462 : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogic
alRightEdge); |
2470 | 2463 |
2471 bool hasBorderRadius = s->hasBorderRadius(); | 2464 bool hasBorderRadius = s->hasBorderRadius(); |
2472 bool isHorizontal = s->isHorizontalWritingMode(); | 2465 bool isHorizontal = s->isHorizontalWritingMode(); |
2473 bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundCol
or).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() ==
255; | 2466 bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundCol
or).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() ==
255; |
2474 | 2467 |
2475 GraphicsContextStateSaver stateSaver(*context, false); | 2468 GraphicsContextStateSaver stateSaver(*context, false); |
2476 | 2469 |
2477 const ShadowList* shadowList = s->boxShadow(); | 2470 const ShadowList* shadowList = s->boxShadow(); |
2478 for (size_t i = shadowList->shadows().size(); i--; ) { | 2471 for (size_t i = shadowList->shadows().size(); i--; ) { |
2479 const ShadowData& shadow = shadowList->shadows()[i]; | 2472 const ShadowData& shadow = shadowList->shadows()[i]; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2811 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 2804 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
2812 for (RenderObject* child = startChild; child && child != endChild; ) { | 2805 for (RenderObject* child = startChild; child && child != endChild; ) { |
2813 // Save our next sibling as moveChildTo will clear it. | 2806 // Save our next sibling as moveChildTo will clear it. |
2814 RenderObject* nextSibling = child->nextSibling(); | 2807 RenderObject* nextSibling = child->nextSibling(); |
2815 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 2808 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
2816 child = nextSibling; | 2809 child = nextSibling; |
2817 } | 2810 } |
2818 } | 2811 } |
2819 | 2812 |
2820 } // namespace WebCore | 2813 } // namespace WebCore |
OLD | NEW |