| 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; | 426 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; |
| 427 | 427 |
| 428 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in
cludeRightEdge); | 428 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in
cludeRightEdge); |
| 429 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() =
= LocalBackgroundAttachment; | 429 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() =
= LocalBackgroundAttachment; |
| 430 bool isBorderFill = bgLayer.clip() == BorderFillBox; | 430 bool isBorderFill = bgLayer.clip() == BorderFillBox; |
| 431 bool isDocumentElementRenderer = this->isDocumentElement(); | 431 bool isDocumentElementRenderer = this->isDocumentElement(); |
| 432 bool isBottomLayer = !bgLayer.next(); | 432 bool isBottomLayer = !bgLayer.next(); |
| 433 | 433 |
| 434 Color bgColor = color; | 434 Color bgColor = color; |
| 435 StyleImage* bgImage = bgLayer.image(); | 435 StyleImage* bgImage = bgLayer.image(); |
| 436 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(*this, style
()->effectiveZoom()); | 436 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(*this); |
| 437 | 437 |
| 438 bool colorVisible = bgColor.alpha(); | 438 bool colorVisible = bgColor.alpha(); |
| 439 | 439 |
| 440 // Fast path for drawing simple color backgrounds. | 440 // Fast path for drawing simple color backgrounds. |
| 441 if (!isDocumentElementRenderer && !clippedWithLocalScrolling && !shouldPaint
BackgroundImage && isBorderFill && isBottomLayer) { | 441 if (!isDocumentElementRenderer && !clippedWithLocalScrolling && !shouldPaint
BackgroundImage && isBorderFill && isBottomLayer) { |
| 442 if (!colorVisible) | 442 if (!colorVisible) |
| 443 return; | 443 return; |
| 444 | 444 |
| 445 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli
edToBackground(bleedAvoidance, box); | 445 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli
edToBackground(bleedAvoidance, box); |
| 446 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp
pliedToBackground); | 446 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp
pliedToBackground); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 650 |
| 651 // Only the first solution fits. | 651 // Only the first solution fits. |
| 652 return IntSize(solutionWidth, size.height()); | 652 return IntSize(solutionWidth, size.height()); |
| 653 } | 653 } |
| 654 | 654 |
| 655 // Only the second solution fits, assert that. | 655 // Only the second solution fits, assert that. |
| 656 ASSERT(solutionHeight <= size.height()); | 656 ASSERT(solutionHeight <= size.height()); |
| 657 return IntSize(size.width(), solutionHeight); | 657 return IntSize(size.width(), solutionHeight); |
| 658 } | 658 } |
| 659 | 659 |
| 660 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
e, const IntSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNo
t) const | 660 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* imag
e, const IntSize& positioningAreaSize) const |
| 661 { | 661 { |
| 662 // A generated image without a fixed size, will always return the container
size as intrinsic size. | 662 // A generated image without a fixed size, will always return the container
size as intrinsic size. |
| 663 if (image->isGeneratedImage() && image->usesImageContainerSize()) | 663 if (image->isGeneratedImage() && image->usesImageContainerSize()) |
| 664 return IntSize(positioningAreaSize.width(), positioningAreaSize.height()
); | 664 return IntSize(positioningAreaSize.width(), positioningAreaSize.height()
); |
| 665 | 665 |
| 666 Length intrinsicWidth; | 666 Length intrinsicWidth; |
| 667 Length intrinsicHeight; | 667 Length intrinsicHeight; |
| 668 FloatSize intrinsicRatio; | 668 FloatSize intrinsicRatio; |
| 669 image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, int
rinsicRatio); | 669 image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, int
rinsicRatio); |
| 670 | 670 |
| 671 ASSERT(!intrinsicWidth.isPercent()); | 671 ASSERT(!intrinsicWidth.isPercent()); |
| 672 ASSERT(!intrinsicHeight.isPercent()); | 672 ASSERT(!intrinsicHeight.isPercent()); |
| 673 | 673 |
| 674 IntSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value()); | 674 IntSize resolvedSize(intrinsicWidth.value(), intrinsicHeight.value()); |
| 675 IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height()
> 0 ? 1 : 0); | 675 IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height()
> 0 ? 1 : 0); |
| 676 if (shouldScaleOrNot == ScaleByEffectiveZoom) | |
| 677 resolvedSize.scale(style()->effectiveZoom()); | |
| 678 resolvedSize.clampToMinimumSize(minimumSize); | 676 resolvedSize.clampToMinimumSize(minimumSize); |
| 679 | 677 |
| 680 if (!resolvedSize.isEmpty()) | 678 if (!resolvedSize.isEmpty()) |
| 681 return resolvedSize; | 679 return resolvedSize; |
| 682 | 680 |
| 683 // If the image has one of either an intrinsic width or an intrinsic height: | 681 // If the image has one of either an intrinsic width or an intrinsic height: |
| 684 // * and an intrinsic aspect ratio, then the missing dimension is calculated
from the given dimension and the ratio. | 682 // * and an intrinsic aspect ratio, then the missing dimension is calculated
from the given dimension and the ratio. |
| 685 // * and no intrinsic aspect ratio, then the missing dimension is assumed to
be the size of the rectangle that | 683 // * and no intrinsic aspect ratio, then the missing dimension is assumed to
be the size of the rectangle that |
| 686 // establishes the coordinate system for the 'background-position' propert
y. | 684 // establishes the coordinate system for the 'background-position' propert
y. |
| 687 if (resolvedSize.width() > 0 || resolvedSize.height() > 0) | 685 if (resolvedSize.width() > 0 || resolvedSize.height() > 0) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 702 { | 700 { |
| 703 tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tile
Size.width().ceil() : tileSize.width().floor()); | 701 tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tile
Size.width().ceil() : tileSize.width().floor()); |
| 704 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t
ileSize.height().ceil() : tileSize.height().floor()); | 702 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t
ileSize.height().ceil() : tileSize.height().floor()); |
| 705 } | 703 } |
| 706 | 704 |
| 707 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer& fillLayer,
const IntSize& positioningAreaSize) const | 705 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer& fillLayer,
const IntSize& positioningAreaSize) const |
| 708 { | 706 { |
| 709 StyleImage* image = fillLayer.image(); | 707 StyleImage* image = fillLayer.image(); |
| 710 EFillSizeType type = fillLayer.size().type; | 708 EFillSizeType type = fillLayer.size().type; |
| 711 | 709 |
| 712 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi
oningAreaSize, ScaleByEffectiveZoom); | 710 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi
oningAreaSize); |
| 713 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal
eFactor()); | 711 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal
eFactor()); |
| 714 switch (type) { | 712 switch (type) { |
| 715 case SizeLength: { | 713 case SizeLength: { |
| 716 LayoutSize tileSize = positioningAreaSize; | 714 LayoutSize tileSize = positioningAreaSize; |
| 717 | 715 |
| 718 Length layerWidth = fillLayer.size().size.width(); | 716 Length layerWidth = fillLayer.size().size.width(); |
| 719 Length layerHeight = fillLayer.size().size.height(); | 717 Length layerHeight = fillLayer.size().size.height(); |
| 720 | 718 |
| 721 if (layerWidth.isFixed()) | 719 if (layerWidth.isFixed()) |
| 722 tileSize.setWidth(layerWidth.value()); | 720 tileSize.setWidth(layerWidth.value()); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l
ocalToAbsolute(FloatPoint())); | 884 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l
ocalToAbsolute(FloatPoint())); |
| 887 viewportRect.moveBy(-absoluteContainerOffset); | 885 viewportRect.moveBy(-absoluteContainerOffset); |
| 888 } | 886 } |
| 889 | 887 |
| 890 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); | 888 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); |
| 891 positioningAreaSize = geometry.destRect().size(); | 889 positioningAreaSize = geometry.destRect().size(); |
| 892 } | 890 } |
| 893 | 891 |
| 894 const RenderObject* clientForBackgroundImage = backgroundObject ? background
Object : this; | 892 const RenderObject* clientForBackgroundImage = backgroundObject ? background
Object : this; |
| 895 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; | 893 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; |
| 896 fillLayer.image()->setContainerSizeForRenderer(clientForBackgroundImage, fil
lTileSize, style()->effectiveZoom()); | 894 fillLayer.image()->setContainerSizeForRenderer(clientForBackgroundImage, fil
lTileSize); |
| 897 geometry.setTileSize(fillTileSize); | 895 geometry.setTileSize(fillTileSize); |
| 898 | 896 |
| 899 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); | 897 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); |
| 900 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); | 898 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); |
| 901 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); | 899 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); |
| 902 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); | 900 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); |
| 903 | 901 |
| 904 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); | 902 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); |
| 905 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { | 903 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { |
| 906 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() /
fillTileSize.width())); | 904 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() /
fillTileSize.width())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
const LayoutRect& rect, const RenderStyle* style, | 988 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
const LayoutRect& rect, const RenderStyle* style, |
| 991 const NinePieceImage& ninePieceIm
age, CompositeOperator op) | 989 const NinePieceImage& ninePieceIm
age, CompositeOperator op) |
| 992 { | 990 { |
| 993 StyleImage* styleImage = ninePieceImage.image(); | 991 StyleImage* styleImage = ninePieceImage.image(); |
| 994 if (!styleImage) | 992 if (!styleImage) |
| 995 return false; | 993 return false; |
| 996 | 994 |
| 997 if (!styleImage->isLoaded()) | 995 if (!styleImage->isLoaded()) |
| 998 return true; // Never paint a nine-piece image incrementally, but don't
paint the fallback borders either. | 996 return true; // Never paint a nine-piece image incrementally, but don't
paint the fallback borders either. |
| 999 | 997 |
| 1000 if (!styleImage->canRender(*this, style->effectiveZoom())) | 998 if (!styleImage->canRender(*this)) |
| 1001 return false; | 999 return false; |
| 1002 | 1000 |
| 1003 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function | 1001 // FIXME: border-image is broken with full page zooming when tiling has to h
appen, since the tiling function |
| 1004 // doesn't have any understanding of the zoom that is in effect on the tile. | 1002 // doesn't have any understanding of the zoom that is in effect on the tile. |
| 1005 LayoutRect rectWithOutsets = rect; | 1003 LayoutRect rectWithOutsets = rect; |
| 1006 rectWithOutsets.expand(style->imageOutsets(ninePieceImage)); | 1004 rectWithOutsets.expand(style->imageOutsets(ninePieceImage)); |
| 1007 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); | 1005 IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets); |
| 1008 | 1006 |
| 1009 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag
eRect.size(), DoNotScaleByEffectiveZoom); | 1007 IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImag
eRect.size()); |
| 1010 | 1008 |
| 1011 // If both values are ‘auto’ then the intrinsic width and/or height of the i
mage should be used, if any. | 1009 // If both values are ‘auto’ then the intrinsic width and/or height of the i
mage should be used, if any. |
| 1012 styleImage->setContainerSizeForRenderer(this, imageSize, style->effectiveZoo
m()); | 1010 styleImage->setContainerSizeForRenderer(this, imageSize); |
| 1013 | 1011 |
| 1014 int imageWidth = imageSize.width(); | 1012 int imageWidth = imageSize.width(); |
| 1015 int imageHeight = imageSize.height(); | 1013 int imageHeight = imageSize.height(); |
| 1016 | 1014 |
| 1017 float imageScaleFactor = styleImage->imageScaleFactor(); | 1015 float imageScaleFactor = styleImage->imageScaleFactor(); |
| 1018 int topSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.imag
eSlices().top(), imageHeight)) * imageScaleFactor; | 1016 int topSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.imag
eSlices().top(), imageHeight)) * imageScaleFactor; |
| 1019 int rightSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.ima
geSlices().right(), imageWidth)) * imageScaleFactor; | 1017 int rightSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.ima
geSlices().right(), imageWidth)) * imageScaleFactor; |
| 1020 int bottomSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.i
mageSlices().bottom(), imageHeight)) * imageScaleFactor; | 1018 int bottomSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.i
mageSlices().bottom(), imageHeight)) * imageScaleFactor; |
| 1021 int leftSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.imag
eSlices().left(), imageWidth)) * imageScaleFactor; | 1019 int leftSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.imag
eSlices().left(), imageWidth)) * imageScaleFactor; |
| 1022 | 1020 |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 2607 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
| 2610 for (RenderObject* child = startChild; child && child != endChild; ) { | 2608 for (RenderObject* child = startChild; child && child != endChild; ) { |
| 2611 // Save our next sibling as moveChildTo will clear it. | 2609 // Save our next sibling as moveChildTo will clear it. |
| 2612 RenderObject* nextSibling = child->nextSibling(); | 2610 RenderObject* nextSibling = child->nextSibling(); |
| 2613 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 2611 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
| 2614 child = nextSibling; | 2612 child = nextSibling; |
| 2615 } | 2613 } |
| 2616 } | 2614 } |
| 2617 | 2615 |
| 2618 } // namespace blink | 2616 } // namespace blink |
| OLD | NEW |