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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 102123013: Fix painting of fixed background images in composited layers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added missing DOCTYPEs Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderImage.cpp » ('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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 689 }
690 } else if (bgColor.alpha()) { 690 } else if (bgColor.alpha()) {
691 context->fillRect(backgroundRect, bgColor, context->compositeOpe ration()); 691 context->fillRect(backgroundRect, bgColor, context->compositeOpe ration());
692 } 692 }
693 } 693 }
694 } 694 }
695 695
696 // no progressive loading of the background image 696 // no progressive loading of the background image
697 if (shouldPaintBackgroundImage) { 697 if (shouldPaintBackgroundImage) {
698 BackgroundImageGeometry geometry; 698 BackgroundImageGeometry geometry;
699 calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect, geometry, b ackgroundObject); 699 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc rolledPaintRect, geometry, backgroundObject);
700 geometry.clip(paintInfo.rect); 700 geometry.clip(paintInfo.rect);
701 if (!geometry.destRect().isEmpty()) { 701 if (!geometry.destRect().isEmpty()) {
702 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer- >composite() : op; 702 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer- >composite() : op;
703 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this; 703 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this;
704 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize()); 704 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize());
705 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), bgLayer, geometry.tileSize()); 705 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), bgLayer, geometry.tileSize());
706 if (bgLayer->maskSourceType() == MaskLuminance) 706 if (bgLayer->maskSourceType() == MaskLuminance)
707 context->setColorFilter(ColorFilterLuminanceToAlpha); 707 context->setColorFilter(ColorFilterLuminanceToAlpha);
708 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality(); 708 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality();
709 context->setImageInterpolationQuality(interpolationQuality); 709 context->setImageInterpolationQuality(interpolationQuality);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 { 957 {
958 int numberOfTiles = areaSize / tileSize; 958 int numberOfTiles = areaSize / tileSize;
959 int space = -1; 959 int space = -1;
960 960
961 if (numberOfTiles > 1) 961 if (numberOfTiles > 1)
962 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf Tiles - 1)); 962 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf Tiles - 1));
963 963
964 return space; 964 return space;
965 } 965 }
966 966
967 void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil lLayer, const LayoutRect& paintRect, 967 void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod elObject* paintContainer, const FillLayer* fillLayer, const LayoutRect& paintRec t,
968 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) 968 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) const
969 { 969 {
970 LayoutUnit left = 0; 970 LayoutUnit left = 0;
971 LayoutUnit top = 0; 971 LayoutUnit top = 0;
972 IntSize positioningAreaSize; 972 IntSize positioningAreaSize;
973 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); 973 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect);
974 974
975 // Determine the background positioning area and set destRect to the backgro und painting area. 975 // Determine the background positioning area and set destRect to the backgro und painting area.
976 // destRect will be adjusted later if the background is non-repeating. 976 // destRect will be adjusted later if the background is non-repeating.
977 // FIXME: transforms spec says that fixed backgrounds behave like scroll ins ide transforms.
977 bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment; 978 bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment;
978 979
979 #if ENABLE(FAST_MOBILE_SCROLLING) 980 #if ENABLE(FAST_MOBILE_SCROLLING)
980 if (view()->frameView() && view()->frameView()->shouldAttemptToScrollUsingFa stPath()) { 981 if (view()->frameView() && view()->frameView()->shouldAttemptToScrollUsingFa stPath()) {
981 // As a side effect of an optimization to blit on scroll, we do not hono r the CSS 982 // As a side effect of an optimization to blit on scroll, we do not hono r the CSS
982 // property "background-attachment: fixed" because it may result in rend ering 983 // property "background-attachment: fixed" because it may result in rend ering
983 // artifacts. Note, these artifacts only appear if we are blitting on sc roll of 984 // artifacts. Note, these artifacts only appear if we are blitting on sc roll of
984 // a page that has fixed background images. 985 // a page that has fixed background images.
985 fixedAttachment = false; 986 fixedAttachment = false;
986 } 987 }
(...skipping 21 matching lines...) Expand all
1008 // The background of the box generated by the root element covers the en tire canvas including 1009 // The background of the box generated by the root element covers the en tire canvas including
1009 // its margins. Since those were added in already, we have to factor the m out when computing 1010 // its margins. Since those were added in already, we have to factor the m out when computing
1010 // the background positioning area. 1011 // the background positioning area.
1011 if (isRoot()) { 1012 if (isRoot()) {
1012 positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size() - LayoutSize(left + right, top + bottom), toRenderBox(this)->location()); 1013 positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size() - LayoutSize(left + right, top + bottom), toRenderBox(this)->location());
1013 left += marginLeft(); 1014 left += marginLeft();
1014 top += marginTop(); 1015 top += marginTop();
1015 } else 1016 } else
1016 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location()); 1017 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location());
1017 } else { 1018 } else {
1019 geometry.setHasNonLocalGeometry();
1020
1018 IntRect viewportRect = pixelSnappedIntRect(viewRect()); 1021 IntRect viewportRect = pixelSnappedIntRect(viewRect());
1019 if (fixedBackgroundPaintsInLocalCoordinates()) 1022 if (fixedBackgroundPaintsInLocalCoordinates())
1020 viewportRect.setLocation(IntPoint()); 1023 viewportRect.setLocation(IntPoint());
1021 else if (FrameView* frameView = view()->frameView()) 1024 else if (FrameView* frameView = view()->frameView())
1022 viewportRect.setLocation(IntPoint(frameView->scrollOffsetForFixedPos ition())); 1025 viewportRect.setLocation(IntPoint(frameView->scrollOffsetForFixedPos ition()));
1023 1026
1027 if (paintContainer) {
1028 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint()));
1029 viewportRect.moveBy(-absoluteContainerOffset);
1030 }
1031
1024 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); 1032 geometry.setDestRect(pixelSnappedIntRect(viewportRect));
1025 positioningAreaSize = geometry.destRect().size(); 1033 positioningAreaSize = geometry.destRect().size();
1026 } 1034 }
1027 1035
1028 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this; 1036 const RenderObject* clientForBackgroundImage = backgroundObject ? background Object : this;
1029 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ; 1037 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ;
1030 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi llTileSize, style()->effectiveZoom()); 1038 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi llTileSize, style()->effectiveZoom());
1031 geometry.setTileSize(fillTileSize); 1039 geometry.setTileSize(fillTileSize);
1032 1040
1033 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); 1041 EFillRepeat backgroundRepeatX = fillLayer->repeatX();
1034 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); 1042 EFillRepeat backgroundRepeatY = fillLayer->repeatY();
1035 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width (); 1043 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width ();
1036 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght(); 1044 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght();
1037 1045
1038 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer->xPosi tion(), availableWidth); 1046 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer->xPosi tion(), availableWidth);
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2817 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2810 for (RenderObject* child = startChild; child && child != endChild; ) { 2818 for (RenderObject* child = startChild; child && child != endChild; ) {
2811 // Save our next sibling as moveChildTo will clear it. 2819 // Save our next sibling as moveChildTo will clear it.
2812 RenderObject* nextSibling = child->nextSibling(); 2820 RenderObject* nextSibling = child->nextSibling();
2813 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2821 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2814 child = nextSibling; 2822 child = nextSibling;
2815 } 2823 }
2816 } 2824 }
2817 2825
2818 } // namespace WebCore 2826 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698