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

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

Issue 102123013: Fix painting of fixed background images in composited layers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixes per review comments Created 6 years, 9 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
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, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 paintRootBoxFillLayers(paintInfo); 1236 paintRootBoxFillLayers(paintInfo);
1237 return; 1237 return;
1238 } 1238 }
1239 if (isBody() && skipBodyBackground(this)) 1239 if (isBody() && skipBodyBackground(this))
1240 return; 1240 return;
1241 if (backgroundIsKnownToBeObscured()) 1241 if (backgroundIsKnownToBeObscured())
1242 return; 1242 return;
1243 paintFillLayers(paintInfo, resolveColor(CSSPropertyBackgroundColor), style() ->backgroundLayers(), paintRect, bleedAvoidance); 1243 paintFillLayers(paintInfo, resolveColor(CSSPropertyBackgroundColor), style() ->backgroundLayers(), paintRect, bleedAvoidance);
1244 } 1244 }
1245 1245
1246 LayoutRect RenderBox::backgroundPaintedExtent() const 1246 bool RenderBox::getBackgroundPaintedExtent(LayoutRect& paintedExtent) const
1247 { 1247 {
1248 ASSERT(hasBackground()); 1248 ASSERT(hasBackground());
1249 LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect()); 1249 LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect());
1250 1250
1251 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); 1251 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
1252 if (backgroundColor.alpha()) 1252
1253 return backgroundRect; 1253 if (backgroundColor.alpha()) {
1254 if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->ne xt()) 1254 paintedExtent = backgroundRect;
1255 return backgroundRect; 1255 return true;
1256 }
1257
1258 if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->ne xt()) {
1259 paintedExtent = backgroundRect;
1260 return true;
1261 }
1262
1256 BackgroundImageGeometry geometry; 1263 BackgroundImageGeometry geometry;
1257 const_cast<RenderBox*>(this)->calculateBackgroundImageGeometry(style()->back groundLayers(), backgroundRect, geometry); 1264 calculateBackgroundImageGeometry(0, style()->backgroundLayers(), backgroundR ect, geometry);
1258 return geometry.destRect(); 1265 if (geometry.hasNonLocalGeometry())
1266 return false;
1267 paintedExtent = geometry.destRect();
1268 return true;
1259 } 1269 }
1260 1270
1261 bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst 1271 bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst
1262 { 1272 {
1263 if (isBody() && skipBodyBackground(this)) 1273 if (isBody() && skipBodyBackground(this))
1264 return false; 1274 return false;
1265 1275
1266 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); 1276 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
1267 if (backgroundColor.hasAlpha()) 1277 if (backgroundColor.hasAlpha())
1268 return false; 1278 return false;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 // Test to see if the children trivially obscure the background. 1368 // Test to see if the children trivially obscure the background.
1359 // FIXME: This test can be much more comprehensive. 1369 // FIXME: This test can be much more comprehensive.
1360 if (!hasBackground()) 1370 if (!hasBackground())
1361 return false; 1371 return false;
1362 // Table and root background painting is special. 1372 // Table and root background painting is special.
1363 if (isTable() || isRoot()) 1373 if (isTable() || isRoot())
1364 return false; 1374 return false;
1365 // FIXME: box-shadow is painted while background painting. 1375 // FIXME: box-shadow is painted while background painting.
1366 if (style()->boxShadow()) 1376 if (style()->boxShadow())
1367 return false; 1377 return false;
1368 LayoutRect backgroundRect = backgroundPaintedExtent(); 1378 LayoutRect backgroundRect;
1379 if (!getBackgroundPaintedExtent(backgroundRect))
1380 return false;
1369 return foregroundIsKnownToBeOpaqueInRect(backgroundRect, backgroundObscurati onTestMaxDepth); 1381 return foregroundIsKnownToBeOpaqueInRect(backgroundRect, backgroundObscurati onTestMaxDepth);
1370 } 1382 }
1371 1383
1372 bool RenderBox::backgroundHasOpaqueTopLayer() const 1384 bool RenderBox::backgroundHasOpaqueTopLayer() const
1373 { 1385 {
1374 const FillLayer* fillLayer = style()->backgroundLayers(); 1386 const FillLayer* fillLayer = style()->backgroundLayers();
1375 if (!fillLayer || fillLayer->clip() != BorderFillBox) 1387 if (!fillLayer || fillLayer->clip() != BorderFillBox)
1376 return false; 1388 return false;
1377 1389
1378 // Clipped with local scrolling 1390 // Clipped with local scrolling
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 // Apply outsets to the border box. 1474 // Apply outsets to the border box.
1463 borderImageRect.expand(style()->maskBoxImageOutsets()); 1475 borderImageRect.expand(style()->maskBoxImageOutsets());
1464 return borderImageRect; 1476 return borderImageRect;
1465 } 1477 }
1466 1478
1467 LayoutRect result; 1479 LayoutRect result;
1468 LayoutRect borderBox = borderBoxRect(); 1480 LayoutRect borderBox = borderBoxRect();
1469 for (const FillLayer* maskLayer = style()->maskLayers(); maskLayer; maskLaye r = maskLayer->next()) { 1481 for (const FillLayer* maskLayer = style()->maskLayers(); maskLayer; maskLaye r = maskLayer->next()) {
1470 if (maskLayer->image()) { 1482 if (maskLayer->image()) {
1471 BackgroundImageGeometry geometry; 1483 BackgroundImageGeometry geometry;
1472 calculateBackgroundImageGeometry(maskLayer, borderBox, geometry); 1484 // Masks should never have fixed attachment, so it's OK for paintCon tainer to be null.
1485 calculateBackgroundImageGeometry(0, maskLayer, borderBox, geometry);
1473 result.unite(geometry.destRect()); 1486 result.unite(geometry.destRect());
1474 } 1487 }
1475 } 1488 }
1476 return result; 1489 return result;
1477 } 1490 }
1478 1491
1479 void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, cons t FillLayer* fillLayer, const LayoutRect& rect, 1492 void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, cons t FillLayer* fillLayer, const LayoutRect& rect,
1480 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject) 1493 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject)
1481 { 1494 {
1482 Vector<const FillLayer*, 8> layers; 1495 Vector<const FillLayer*, 8> layers;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 layer()->contentChanged(MaskImageChanged); 1571 layer()->contentChanged(MaskImageChanged);
1559 } 1572 }
1560 1573
1561 bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer * layers, bool drawingBackground) 1574 bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer * layers, bool drawingBackground)
1562 { 1575 {
1563 LayoutRect rendererRect; 1576 LayoutRect rendererRect;
1564 RenderBox* layerRenderer = 0; 1577 RenderBox* layerRenderer = 0;
1565 1578
1566 for (const FillLayer* curLayer = layers; curLayer; curLayer = curLayer->next ()) { 1579 for (const FillLayer* curLayer = layers; curLayer; curLayer = curLayer->next ()) {
1567 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(this, style()->effectiveZoom())) { 1580 if (curLayer->image() && image == curLayer->image()->data() && curLayer- >image()->canRender(this, style()->effectiveZoom())) {
1568 // Now that we know this image is being used, compute the renderer a nd the rect 1581 // Now that we know this image is being used, compute the renderer a nd the rect if we haven't already.
1569 // if we haven't already
1570 if (!layerRenderer) { 1582 if (!layerRenderer) {
1571 bool drawingRootBackground = drawingBackground && (isRoot() || ( isBody() && !document().documentElement()->renderer()->hasBackground())); 1583 bool drawingRootBackground = drawingBackground && (isRoot() || ( isBody() && !document().documentElement()->renderer()->hasBackground()));
1572 if (drawingRootBackground) { 1584 if (drawingRootBackground) {
1573 layerRenderer = view(); 1585 layerRenderer = view();
1574 1586
1575 LayoutUnit rw; 1587 LayoutUnit rw;
1576 LayoutUnit rh; 1588 LayoutUnit rh;
1577 1589
1578 if (FrameView* frameView = toRenderView(layerRenderer)->fram eView()) { 1590 if (FrameView* frameView = toRenderView(layerRenderer)->fram eView()) {
1579 rw = frameView->contentsWidth(); 1591 rw = frameView->contentsWidth();
1580 rh = frameView->contentsHeight(); 1592 rh = frameView->contentsHeight();
1581 } else { 1593 } else {
1582 rw = layerRenderer->width(); 1594 rw = layerRenderer->width();
1583 rh = layerRenderer->height(); 1595 rh = layerRenderer->height();
1584 } 1596 }
1585 rendererRect = LayoutRect(-layerRenderer->marginLeft(), 1597 rendererRect = LayoutRect(-layerRenderer->marginLeft(),
1586 -layerRenderer->marginTop(), 1598 -layerRenderer->marginTop(),
1587 max(layerRenderer->width() + layerRenderer->marginWidth( ) + layerRenderer->borderLeft() + layerRenderer->borderRight(), rw), 1599 max(layerRenderer->width() + layerRenderer->marginWidth( ) + layerRenderer->borderLeft() + layerRenderer->borderRight(), rw),
1588 max(layerRenderer->height() + layerRenderer->marginHeigh t() + layerRenderer->borderTop() + layerRenderer->borderBottom(), rh)); 1600 max(layerRenderer->height() + layerRenderer->marginHeigh t() + layerRenderer->borderTop() + layerRenderer->borderBottom(), rh));
1589 } else { 1601 } else {
1590 layerRenderer = this; 1602 layerRenderer = this;
1591 rendererRect = borderBoxRect(); 1603 rendererRect = borderBoxRect();
1592 } 1604 }
1593 } 1605 }
1594 1606
1595 BackgroundImageGeometry geometry; 1607 BackgroundImageGeometry geometry;
1596 layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRe ct, geometry); 1608 layerRenderer->calculateBackgroundImageGeometry(0, curLayer, rendere rRect, geometry);
1609 if (geometry.hasNonLocalGeometry()) {
1610 // Rather than incur the costs of computing the paintContainer f or renderers with fixed backgrounds
1611 // in order to get the right destRect, just repaint the entire r enderer.
1612 layerRenderer->repaint();
1613 return true;
1614 }
1615
1597 layerRenderer->repaintRectangle(geometry.destRect()); 1616 layerRenderer->repaintRectangle(geometry.destRect());
1598 if (geometry.destRect() == rendererRect) 1617 if (geometry.destRect() == rendererRect)
1599 return true; 1618 return true;
1600 } 1619 }
1601 } 1620 }
1602 return false; 1621 return false;
1603 } 1622 }
1604 1623
1605 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset, ContentsClipBehavior contentsClipBehavior) 1624 bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumu latedOffset, ContentsClipBehavior contentsClipBehavior)
1606 { 1625 {
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
4661 return 0; 4680 return 0;
4662 4681
4663 if (!layoutState && !flowThreadContainingBlock()) 4682 if (!layoutState && !flowThreadContainingBlock())
4664 return 0; 4683 return 0;
4665 4684
4666 RenderBlock* containerBlock = containingBlock(); 4685 RenderBlock* containerBlock = containingBlock();
4667 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); 4686 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
4668 } 4687 }
4669 4688
4670 } // namespace WebCore 4689 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698