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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 723 } |
724 } else if (bgColor.alpha()) { | 724 } else if (bgColor.alpha()) { |
725 context->fillRect(backgroundRect, bgColor, context->compositeOpe
ration()); | 725 context->fillRect(backgroundRect, bgColor, context->compositeOpe
ration()); |
726 } | 726 } |
727 } | 727 } |
728 } | 728 } |
729 | 729 |
730 // no progressive loading of the background image | 730 // no progressive loading of the background image |
731 if (shouldPaintBackgroundImage) { | 731 if (shouldPaintBackgroundImage) { |
732 BackgroundImageGeometry geometry; | 732 BackgroundImageGeometry geometry; |
733 calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect, geometry, b
ackgroundObject); | 733 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc
rolledPaintRect, geometry, backgroundObject); |
734 geometry.clip(paintInfo.rect); | 734 geometry.clip(paintInfo.rect); |
735 if (!geometry.destRect().isEmpty()) { | 735 if (!geometry.destRect().isEmpty()) { |
736 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer-
>composite() : op; | 736 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer-
>composite() : op; |
737 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou
ndObject : this; | 737 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou
ndObject : this; |
738 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome
try.tileSize()); | 738 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome
try.tileSize()); |
739 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.g
et(), bgLayer, geometry.tileSize()); | 739 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.g
et(), bgLayer, geometry.tileSize()); |
740 if (bgLayer->maskSourceType() == MaskLuminance) | 740 if (bgLayer->maskSourceType() == MaskLuminance) |
741 context->setColorFilter(ColorFilterLuminanceToAlpha); | 741 context->setColorFilter(ColorFilterLuminanceToAlpha); |
742 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r
elativePhase(), geometry.tileSize(), | 742 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r
elativePhase(), geometry.tileSize(), |
743 compositeOp, useLowQualityScaling, bgLayer->blendMode(), geometr
y.spaceSize()); | 743 compositeOp, useLowQualityScaling, bgLayer->blendMode(), geometr
y.spaceSize()); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 { | 989 { |
990 int numberOfTiles = areaSize / tileSize; | 990 int numberOfTiles = areaSize / tileSize; |
991 int space = -1; | 991 int space = -1; |
992 | 992 |
993 if (numberOfTiles > 1) | 993 if (numberOfTiles > 1) |
994 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf
Tiles - 1)); | 994 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf
Tiles - 1)); |
995 | 995 |
996 return space; | 996 return space; |
997 } | 997 } |
998 | 998 |
999 void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
lLayer, const LayoutRect& paintRect, | 999 void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod
elObject* paintContainer, const FillLayer* fillLayer, const LayoutRect& paintRec
t, |
1000 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) | 1000 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) const |
1001 { | 1001 { |
1002 LayoutUnit left = 0; | 1002 LayoutUnit left = 0; |
1003 LayoutUnit top = 0; | 1003 LayoutUnit top = 0; |
1004 IntSize positioningAreaSize; | 1004 IntSize positioningAreaSize; |
1005 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); | 1005 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); |
1006 | 1006 |
1007 // Determine the background positioning area and set destRect to the backgro
und painting area. | 1007 // Determine the background positioning area and set destRect to the backgro
und painting area. |
1008 // destRect will be adjusted later if the background is non-repeating. | 1008 // destRect will be adjusted later if the background is non-repeating. |
| 1009 // FIXME: transforms spec says that fixed backgrounds behave like scroll ins
ide transforms. |
1009 bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment; | 1010 bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment; |
1010 | 1011 |
1011 #if ENABLE(FAST_MOBILE_SCROLLING) | 1012 #if ENABLE(FAST_MOBILE_SCROLLING) |
1012 if (view()->frameView() && view()->frameView()->canBlitOnScroll()) { | 1013 if (view()->frameView() && view()->frameView()->canBlitOnScroll()) { |
1013 // As a side effect of an optimization to blit on scroll, we do not hono
r the CSS | 1014 // As a side effect of an optimization to blit on scroll, we do not hono
r the CSS |
1014 // property "background-attachment: fixed" because it may result in rend
ering | 1015 // property "background-attachment: fixed" because it may result in rend
ering |
1015 // artifacts. Note, these artifacts only appear if we are blitting on sc
roll of | 1016 // artifacts. Note, these artifacts only appear if we are blitting on sc
roll of |
1016 // a page that has fixed background images. | 1017 // a page that has fixed background images. |
1017 fixedAttachment = false; | 1018 fixedAttachment = false; |
1018 } | 1019 } |
(...skipping 21 matching lines...) Expand all Loading... |
1040 // The background of the box generated by the root element covers the en
tire canvas including | 1041 // The background of the box generated by the root element covers the en
tire canvas including |
1041 // its margins. Since those were added in already, we have to factor the
m out when computing | 1042 // its margins. Since those were added in already, we have to factor the
m out when computing |
1042 // the background positioning area. | 1043 // the background positioning area. |
1043 if (isRoot()) { | 1044 if (isRoot()) { |
1044 positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size()
- LayoutSize(left + right, top + bottom), toRenderBox(this)->location()); | 1045 positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size()
- LayoutSize(left + right, top + bottom), toRenderBox(this)->location()); |
1045 left += marginLeft(); | 1046 left += marginLeft(); |
1046 top += marginTop(); | 1047 top += marginTop(); |
1047 } else | 1048 } else |
1048 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS
ize(left + right, top + bottom), paintRect.location()); | 1049 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS
ize(left + right, top + bottom), paintRect.location()); |
1049 } else { | 1050 } else { |
| 1051 geometry.setHasNonLocalGeometry(); |
| 1052 |
1050 IntRect viewportRect = pixelSnappedIntRect(viewRect()); | 1053 IntRect viewportRect = pixelSnappedIntRect(viewRect()); |
1051 if (fixedBackgroundPaintsInLocalCoordinates()) | 1054 if (fixedBackgroundPaintsInLocalCoordinates()) |
1052 viewportRect.setLocation(IntPoint()); | 1055 viewportRect.setLocation(IntPoint()); |
1053 else if (FrameView* frameView = view()->frameView()) | 1056 else if (FrameView* frameView = view()->frameView()) |
1054 viewportRect.setLocation(IntPoint(frameView->scrollOffsetForFixedPos
ition())); | 1057 viewportRect.setLocation(IntPoint(frameView->scrollOffsetForFixedPos
ition())); |
1055 | 1058 |
| 1059 if (paintContainer) { |
| 1060 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l
ocalToAbsolute(FloatPoint())); |
| 1061 viewportRect.moveBy(-absoluteContainerOffset); |
| 1062 } |
| 1063 |
1056 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); | 1064 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); |
1057 positioningAreaSize = geometry.destRect().size(); | 1065 positioningAreaSize = geometry.destRect().size(); |
1058 } | 1066 } |
1059 | 1067 |
1060 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject
: this; | 1068 const RenderObject* clientForBackgroundImage = backgroundObject ? background
Object : this; |
1061 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; | 1069 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize)
; |
1062 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi
llTileSize, style()->effectiveZoom()); | 1070 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi
llTileSize, style()->effectiveZoom()); |
1063 geometry.setTileSize(fillTileSize); | 1071 geometry.setTileSize(fillTileSize); |
1064 | 1072 |
1065 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); | 1073 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); |
1066 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); | 1074 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); |
1067 RenderView* renderView = view(); | 1075 RenderView* renderView = view(); |
1068 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); | 1076 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width
(); |
1069 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); | 1077 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei
ght(); |
1070 | 1078 |
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 2829 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
2822 for (RenderObject* child = startChild; child && child != endChild; ) { | 2830 for (RenderObject* child = startChild; child && child != endChild; ) { |
2823 // Save our next sibling as moveChildTo will clear it. | 2831 // Save our next sibling as moveChildTo will clear it. |
2824 RenderObject* nextSibling = child->nextSibling(); | 2832 RenderObject* nextSibling = child->nextSibling(); |
2825 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 2833 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
2826 child = nextSibling; | 2834 child = nextSibling; |
2827 } | 2835 } |
2828 } | 2836 } |
2829 | 2837 |
2830 } // namespace WebCore | 2838 } // namespace WebCore |
OLD | NEW |