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