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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayer.cpp

Issue 1315303009: Cleanup DeprecatedPaintLayer::physicalBoundingBox() and derivatives (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 if (respectOverflowClip == IgnoreOverflowClip) 1406 if (respectOverflowClip == IgnoreOverflowClip)
1407 paginationClipRectsContext.setIgnoreOverflowClip(); 1407 paginationClipRectsContext.setIgnoreOverflowClip();
1408 LayoutRect layerBoundsInFlowThread; 1408 LayoutRect layerBoundsInFlowThread;
1409 ClipRect backgroundRectInFlowThread; 1409 ClipRect backgroundRectInFlowThread;
1410 ClipRect foregroundRectInFlowThread; 1410 ClipRect foregroundRectInFlowThread;
1411 ClipRect outlineRectInFlowThread; 1411 ClipRect outlineRectInFlowThread;
1412 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread, backgroundRectInFlowThread, foregro undRectInFlowThread, 1412 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread, backgroundRectInFlowThread, foregro undRectInFlowThread,
1413 outlineRectInFlowThread, &offsetWithinPaginatedLayer); 1413 outlineRectInFlowThread, &offsetWithinPaginatedLayer);
1414 1414
1415 // Take our bounding box within the flow thread and clip it. 1415 // Take our bounding box within the flow thread and clip it.
1416 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(enclosingPaginationLayer(), &offsetWithinPaginatedLayer ); 1416 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(offsetWithinPaginatedLayer);
1417 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); 1417 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect());
1418 1418
1419 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.). 1419 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.).
1420 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(enclosingPaginati onLayer()->layoutObject()); 1420 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(enclosingPaginati onLayer()->layoutObject());
1421 LayoutPoint offsetOfPaginationLayerFromRoot; // Visual offset from the root layer to the nearest fragmentation context. 1421 LayoutPoint offsetOfPaginationLayerFromRoot; // Visual offset from the root layer to the nearest fragmentation context.
1422 bool rootLayerIsInsidePaginationLayer = rootLayer->enclosingPaginationLayer( ) == enclosingPaginationLayer(); 1422 bool rootLayerIsInsidePaginationLayer = rootLayer->enclosingPaginationLayer( ) == enclosingPaginationLayer();
1423 if (rootLayerIsInsidePaginationLayer) { 1423 if (rootLayerIsInsidePaginationLayer) {
1424 // The root layer is in the same fragmentation context as this layer, so we need to look 1424 // The root layer is in the same fragmentation context as this layer, so we need to look
1425 // inside it and subtract the offset between the fragmentation context a nd the root layer. 1425 // inside it and subtract the offset between the fragmentation context a nd the root layer.
1426 offsetOfPaginationLayerFromRoot = -rootLayer->visualOffsetFromAncestor(e nclosingPaginationLayer()); 1426 offsetOfPaginationLayerFromRoot = -rootLayer->visualOffsetFromAncestor(e nclosingPaginationLayer());
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 // FIXME: it would be more accurate to return !blockSelectionGapsBounds().is Empty(), but this is impossible 2023 // FIXME: it would be more accurate to return !blockSelectionGapsBounds().is Empty(), but this is impossible
2024 // at the moment because it causes invalid queries to layout-dependent code (crbug.com/372802). 2024 // at the moment because it causes invalid queries to layout-dependent code (crbug.com/372802).
2025 // ASSERT(layoutObject()->document().lifecycle().state() >= DocumentLifecycl e::LayoutClean); 2025 // ASSERT(layoutObject()->document().lifecycle().state() >= DocumentLifecycl e::LayoutClean);
2026 2026
2027 if (!layoutObject()->isLayoutBlock()) 2027 if (!layoutObject()->isLayoutBlock())
2028 return false; 2028 return false;
2029 2029
2030 return toLayoutBlock(layoutObject())->shouldPaintSelectionGaps(); 2030 return toLayoutBlock(layoutObject())->shouldPaintSelectionGaps();
2031 } 2031 }
2032 2032
2033 bool DeprecatedPaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, c onst LayoutRect& damageRect, const DeprecatedPaintLayer* rootLayer, const Layout Point* offsetFromRoot) const 2033 bool DeprecatedPaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, c onst LayoutRect& damageRect, const LayoutPoint& offsetFromRoot) const
2034 { 2034 {
2035 // Always examine the canvas and the root. 2035 // Always examine the canvas and the root.
2036 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView 2036 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView
2037 // paints the root's background. 2037 // paints the root's background.
2038 if (isRootLayer() || layoutObject()->isDocumentElement()) 2038 if (isRootLayer() || layoutObject()->isDocumentElement())
2039 return true; 2039 return true;
2040 2040
2041 // If we aren't an inline flow, and our layer bounds do intersect the damage rect, then we 2041 // If we aren't an inline flow, and our layer bounds do intersect the damage rect, then we
2042 // can go ahead and return true. 2042 // can go ahead and return true.
2043 LayoutView* view = layoutObject()->view(); 2043 LayoutView* view = layoutObject()->view();
2044 ASSERT(view); 2044 ASSERT(view);
2045 if (view && !layoutObject()->isLayoutInline()) { 2045 if (view && !layoutObject()->isLayoutInline()) {
2046 if (layerBounds.intersects(damageRect)) 2046 if (layerBounds.intersects(damageRect))
2047 return true; 2047 return true;
2048 } 2048 }
2049 2049
2050 // Otherwise we need to compute the bounding box of this single layer and se e if it intersects 2050 // Otherwise we need to compute the bounding box of this single layer and se e if it intersects
2051 // the damage rect. 2051 // the damage rect.
2052 return physicalBoundingBox(rootLayer, offsetFromRoot).intersects(damageRect) ; 2052 return physicalBoundingBox(offsetFromRoot).intersects(damageRect);
2053 } 2053 }
2054 2054
2055 LayoutRect DeprecatedPaintLayer::logicalBoundingBox() const 2055 LayoutRect DeprecatedPaintLayer::logicalBoundingBox() const
2056 { 2056 {
2057 // There are three special cases we need to consider. 2057 // There are three special cases we need to consider.
2058 // (1) Inline Flows. For inline flows we will create a bounding box that fu lly encompasses all of the lines occupied by the 2058 // (1) Inline Flows. For inline flows we will create a bounding box that fu lly encompasses all of the lines occupied by the
2059 // inline. In other words, if some <span> wraps to three lines, we'll creat e a bounding box that fully encloses the 2059 // inline. In other words, if some <span> wraps to three lines, we'll creat e a bounding box that fully encloses the
2060 // line boxes of all three lines (including overflow on those lines). 2060 // line boxes of all three lines (including overflow on those lines).
2061 // (2) Left/Top Overflow. The width/height of layers already includes right /bottom overflow. However, in the case of left/top 2061 // (2) Left/Top Overflow. The width/height of layers already includes right /bottom overflow. However, in the case of left/top
2062 // overflow, we have to create a bounding box that will extend to include th is overflow. 2062 // overflow, we have to create a bounding box that will extend to include th is overflow.
(...skipping 28 matching lines...) Expand all
2091 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox, Layou tObject* layoutObjects) 2091 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox, Layou tObject* layoutObjects)
2092 { 2092 {
2093 LayoutRect result = boundingBox; 2093 LayoutRect result = boundingBox;
2094 if (layoutObjects->isBox()) 2094 if (layoutObjects->isBox())
2095 toLayoutBox(layoutObjects)->flipForWritingMode(result); 2095 toLayoutBox(layoutObjects)->flipForWritingMode(result);
2096 else 2096 else
2097 layoutObjects->containingBlock()->flipForWritingMode(result); 2097 layoutObjects->containingBlock()->flipForWritingMode(result);
2098 return result; 2098 return result;
2099 } 2099 }
2100 2100
2101 LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint* offsetFromRoot) const 2101 LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const DeprecatedPaintLayer* ancestorLayer) const
2102 {
2103 LayoutPoint offsetFromRoot;
2104 convertToLayerCoords(ancestorLayer, offsetFromRoot);
2105 return physicalBoundingBox(offsetFromRoot);
2106 }
2107
2108 LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const LayoutPoint& offsetFr omRoot) const
2102 { 2109 {
2103 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject()); 2110 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject());
2104 if (offsetFromRoot) 2111 result.moveBy(offsetFromRoot);
2105 result.moveBy(*offsetFromRoot);
2106 else
2107 convertToLayerCoords(ancestorLayer, result);
2108 return result; 2112 return result;
2109 } 2113 }
2110 2114
2111 LayoutRect DeprecatedPaintLayer::fragmentsBoundingBox(const DeprecatedPaintLayer * ancestorLayer) const 2115 LayoutRect DeprecatedPaintLayer::fragmentsBoundingBox(const DeprecatedPaintLayer * ancestorLayer) const
2112 { 2116 {
2113 if (!enclosingPaginationLayer()) 2117 if (!enclosingPaginationLayer())
2114 return physicalBoundingBox(ancestorLayer); 2118 return physicalBoundingBox(ancestorLayer);
2115 2119
2116 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject()); 2120 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject());
2117 convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, resu lt); 2121 convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, resu lt);
(...skipping 24 matching lines...) Expand all
2142 // because those Layers don't paint into the graphics layer 2146 // because those Layers don't paint into the graphics layer
2143 // for this Layer. For example, the bounds of squashed Layers 2147 // for this Layer. For example, the bounds of squashed Layers
2144 // will be included in the computation of the appropriate squashing 2148 // will be included in the computation of the appropriate squashing
2145 // GraphicsLayer. 2149 // GraphicsLayer.
2146 if (node->layer()->compositingState() != NotComposited) 2150 if (node->layer()->compositingState() != NotComposited)
2147 continue; 2151 continue;
2148 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer)); 2152 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer));
2149 } 2153 }
2150 } 2154 }
2151 2155
2152 LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStacki ngChildren(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint& offsetF romRoot) const 2156 LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStacki ngChildren(const LayoutPoint& offsetFromRoot) const
2153 { 2157 {
2154 LayoutPoint origin; 2158 LayoutRect result = physicalBoundingBox(LayoutPoint());
2155 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin);
2156 2159
2157 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfN eeded(); 2160 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfN eeded();
2158 2161
2159 expandRectForReflectionAndStackingChildren(this, result); 2162 expandRectForReflectionAndStackingChildren(this, result);
2160 2163
2161 result.moveBy(offsetFromRoot); 2164 result.moveBy(offsetFromRoot);
2162 return result; 2165 return result;
2163 } 2166 }
2164 2167
2165 LayoutRect DeprecatedPaintLayer::boundingBoxForCompositing(const DeprecatedPaint Layer* ancestorLayer, CalculateBoundsOptions options) const 2168 LayoutRect DeprecatedPaintLayer::boundingBoxForCompositing(const DeprecatedPaint Layer* ancestorLayer, CalculateBoundsOptions options) const
(...skipping 14 matching lines...) Expand all
2180 2183
2181 // The layer created for the LayoutFlowThread is just a helper for painting and hit-testing, 2184 // The layer created for the LayoutFlowThread is just a helper for painting and hit-testing,
2182 // and should not contribute to the bounding box. The LayoutMultiColumnSets will contribute 2185 // and should not contribute to the bounding box. The LayoutMultiColumnSets will contribute
2183 // the correct size for the layout content of the multicol container. 2186 // the correct size for the layout content of the multicol container.
2184 if (layoutObject()->isLayoutFlowThread()) 2187 if (layoutObject()->isLayoutFlowThread())
2185 return LayoutRect(); 2188 return LayoutRect();
2186 2189
2187 LayoutRect result = clipper().localClipRect(); 2190 LayoutRect result = clipper().localClipRect();
2188 // TODO(chrishtr): avoid converting to IntRect and back. 2191 // TODO(chrishtr): avoid converting to IntRect and back.
2189 if (result == LayoutRect(LayoutRect::infiniteIntRect())) { 2192 if (result == LayoutRect(LayoutRect::infiniteIntRect())) {
2190 LayoutPoint origin; 2193 result = physicalBoundingBox(LayoutPoint());
2191 result = physicalBoundingBox(ancestorLayer, &origin);
2192 2194
2193 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList sIfNeeded(); 2195 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList sIfNeeded();
2194 2196
2195 // Reflections are implemented with Layers that hang off of the reflecte d layer. However, 2197 // Reflections are implemented with Layers that hang off of the reflecte d layer. However,
2196 // the reflection layer subtree does not include the subtree of the pare nt Layer, so 2198 // the reflection layer subtree does not include the subtree of the pare nt Layer, so
2197 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking 2199 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking
2198 // children of the parent, that need to be included in reflected composi ted bounds. 2200 // children of the parent, that need to be included in reflected composi ted bounds.
2199 // Fix this by including composited bounds of stacking children of the r eflected Layer. 2201 // Fix this by including composited bounds of stacking children of the r eflected Layer.
2200 if (hasCompositedDeprecatedPaintLayerMapping() && parent() && parent()-> reflectionInfo() && parent()->reflectionInfo()->reflectionLayer() == this) 2202 if (hasCompositedDeprecatedPaintLayerMapping() && parent() && parent()-> reflectionInfo() && parent()->reflectionInfo()->reflectionLayer() == this)
2201 expandRectForReflectionAndStackingChildren(parent(), result); 2203 expandRectForReflectionAndStackingChildren(parent(), result);
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 2742
2741 void showLayerTree(const blink::LayoutObject* layoutObject) 2743 void showLayerTree(const blink::LayoutObject* layoutObject)
2742 { 2744 {
2743 if (!layoutObject) { 2745 if (!layoutObject) {
2744 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2746 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2745 return; 2747 return;
2746 } 2748 }
2747 showLayerTree(layoutObject->enclosingLayer()); 2749 showLayerTree(layoutObject->enclosingLayer());
2748 } 2750 }
2749 #endif 2751 #endif
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayer.h ('k') | Source/core/paint/DeprecatedPaintLayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698