OLD | NEW |
---|---|
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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 } | 693 } |
694 | 694 |
695 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs | 695 // If we live in a 3d hierarchy, then the layer at the root of that hierarch y needs |
696 // the m_has3DTransformedDescendant set. | 696 // the m_has3DTransformedDescendant set. |
697 if (preserves3D()) | 697 if (preserves3D()) |
698 return has3DTransform() || m_has3DTransformedDescendant; | 698 return has3DTransform() || m_has3DTransformedDescendant; |
699 | 699 |
700 return has3DTransform(); | 700 return has3DTransform(); |
701 } | 701 } |
702 | 702 |
703 LayoutPoint DeprecatedPaintLayer::locationSansOverflowScroll() const | |
704 { | |
705 // Our m_location already has scroll offset baked-in. We have to revert it h ere. | |
706 IntSize scrollOffset; | |
707 if (DeprecatedPaintLayer* positionedParent = layoutObject()->isOutOfFlowPosi tioned() ? enclosingPositionedAncestor() : nullptr) { | |
708 if (positionedParent->layoutObject()->hasOverflowClip()) | |
709 scrollOffset = positionedParent->layoutBox()->scrolledContentOffset( ); | |
710 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { | |
711 scrollOffset = parent()->layoutBox()->scrolledContentOffset(); | |
712 } | |
713 return location() + LayoutSize(scrollOffset); | |
pdr.
2015/08/25 20:47:55
Shouldn't this be subtraction?
trchen
2015/08/26 07:39:04
A layer moves up (subtraction) when it scrolls, so
| |
714 } | |
715 | |
703 bool DeprecatedPaintLayer::updateLayerPosition() | 716 bool DeprecatedPaintLayer::updateLayerPosition() |
704 { | 717 { |
705 LayoutPoint localPoint; | 718 LayoutPoint localPoint; |
706 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. | 719 LayoutPoint inlineBoundingBoxOffset; // We don't put this into the Layer x/y for inlines, so we need to subtract it out when done. |
707 | 720 |
708 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { | 721 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { |
709 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); | 722 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); |
710 IntRect lineBox = inlineFlow->linesBoundingBox(); | 723 IntRect lineBox = inlineFlow->linesBoundingBox(); |
711 m_size = lineBox.size(); | 724 m_size = lineBox.size(); |
712 inlineBoundingBoxOffset = lineBox.location(); | 725 inlineBoundingBoxOffset = lineBox.location(); |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location) const | 1298 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutPoint& location) const |
1286 { | 1299 { |
1287 if (ancestorLayer == this) | 1300 if (ancestorLayer == this) |
1288 return; | 1301 return; |
1289 | 1302 |
1290 const DeprecatedPaintLayer* currLayer = this; | 1303 const DeprecatedPaintLayer* currLayer = this; |
1291 while (currLayer && currLayer != ancestorLayer) | 1304 while (currLayer && currLayer != ancestorLayer) |
1292 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation); | 1305 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation); |
1293 } | 1306 } |
1294 | 1307 |
1308 // TODO(trchen): Deduplicate. | |
1309 static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestorSansOve rflowScroll(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ances torLayer, LayoutPoint& location) | |
1310 { | |
1311 ASSERT(ancestorLayer != layer); | |
1312 | |
1313 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); | |
1314 EPosition position = layoutObject->style()->position(); | |
1315 | |
1316 if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutO bject->view()->layer())) { | |
1317 // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling | |
1318 // localToAbsolute() on the LayoutView. | |
1319 FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed) ; | |
1320 location += LayoutSize(absPos.x(), absPos.y()); | |
1321 return ancestorLayer; | |
1322 } | |
1323 | |
1324 DeprecatedPaintLayer* parentLayer; | |
1325 if (position == AbsolutePosition || position == FixedPosition) { | |
1326 bool foundAncestorFirst; | |
1327 parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAn cestorFirst); | |
1328 | |
1329 if (foundAncestorFirst) { | |
1330 // Found ancestorLayer before the container of the out-of-flow objec t, so compute offset | |
1331 // of both relative to the container and subtract. | |
1332 | |
1333 LayoutPoint thisCoords; | |
1334 layer->convertToLayerCoordsSansOverflowScroll(parentLayer, thisCoord s); | |
1335 | |
1336 LayoutPoint ancestorCoords; | |
1337 ancestorLayer->convertToLayerCoordsSansOverflowScroll(parentLayer, a ncestorCoords); | |
1338 | |
1339 location += (thisCoords - ancestorCoords); | |
1340 return ancestorLayer; | |
1341 } | |
1342 } else if (layoutObject->isColumnSpanAll()) { | |
1343 LayoutBlock* multicolContainer = layoutObject->containingBlock(); | |
1344 ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); | |
1345 parentLayer = multicolContainer->layer(); | |
1346 ASSERT(parentLayer); | |
1347 } else { | |
1348 parentLayer = layer->parent(); | |
1349 } | |
1350 | |
1351 if (!parentLayer) | |
1352 return nullptr; | |
1353 | |
1354 location += layer->locationSansOverflowScroll(); | |
1355 return parentLayer; | |
1356 } | |
1357 | |
1358 // TODO(trchen): Deduplicate. | |
1359 void DeprecatedPaintLayer::convertToLayerCoordsSansOverflowScroll(const Deprecat edPaintLayer* ancestorLayer, LayoutPoint& location) const | |
1360 { | |
1361 if (ancestorLayer == this) | |
1362 return; | |
1363 | |
1364 const DeprecatedPaintLayer* currLayer = this; | |
1365 while (currLayer && currLayer != ancestorLayer) | |
1366 currLayer = accumulateOffsetTowardsAncestorSansOverflowScroll(currLayer, ancestorLayer, location); | |
1367 } | |
1368 | |
1295 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutRect& rect) const | 1369 void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance storLayer, LayoutRect& rect) const |
1296 { | 1370 { |
1297 LayoutPoint delta; | 1371 LayoutPoint delta; |
1298 convertToLayerCoords(ancestorLayer, delta); | 1372 convertToLayerCoords(ancestorLayer, delta); |
1299 rect.moveBy(delta); | 1373 rect.moveBy(delta); |
1300 } | 1374 } |
1301 | 1375 |
1302 LayoutPoint DeprecatedPaintLayer::visualOffsetFromAncestor(const DeprecatedPaint Layer* ancestorLayer) const | 1376 LayoutPoint DeprecatedPaintLayer::visualOffsetFromAncestor(const DeprecatedPaint Layer* ancestorLayer) const |
1303 { | 1377 { |
1304 LayoutPoint offset; | 1378 LayoutPoint offset; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 if (respectOverflowClip == IgnoreOverflowClip) | 1472 if (respectOverflowClip == IgnoreOverflowClip) |
1399 paginationClipRectsContext.setIgnoreOverflowClip(); | 1473 paginationClipRectsContext.setIgnoreOverflowClip(); |
1400 LayoutRect layerBoundsInFlowThread; | 1474 LayoutRect layerBoundsInFlowThread; |
1401 ClipRect backgroundRectInFlowThread; | 1475 ClipRect backgroundRectInFlowThread; |
1402 ClipRect foregroundRectInFlowThread; | 1476 ClipRect foregroundRectInFlowThread; |
1403 ClipRect outlineRectInFlowThread; | 1477 ClipRect outlineRectInFlowThread; |
1404 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread, backgroundRectInFlowThread, foregro undRectInFlowThread, | 1478 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread, backgroundRectInFlowThread, foregro undRectInFlowThread, |
1405 outlineRectInFlowThread, &offsetWithinPaginatedLayer); | 1479 outlineRectInFlowThread, &offsetWithinPaginatedLayer); |
1406 | 1480 |
1407 // Take our bounding box within the flow thread and clip it. | 1481 // Take our bounding box within the flow thread and clip it. |
1408 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(enclosingPaginationLayer(), &offsetWithinPaginatedLayer ); | 1482 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(nullptr, &offsetWithinPaginatedLayer); |
1409 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); | 1483 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); |
1410 | 1484 |
1411 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.). | 1485 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.). |
1412 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(enclosingPaginati onLayer()->layoutObject()); | 1486 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(enclosingPaginati onLayer()->layoutObject()); |
1413 LayoutPoint offsetOfPaginationLayerFromRoot; // Visual offset from the root layer to the nearest fragmentation context. | 1487 LayoutPoint offsetOfPaginationLayerFromRoot; // Visual offset from the root layer to the nearest fragmentation context. |
1414 bool rootLayerIsInsidePaginationLayer = rootLayer->enclosingPaginationLayer( ) == enclosingPaginationLayer(); | 1488 bool rootLayerIsInsidePaginationLayer = rootLayer->enclosingPaginationLayer( ) == enclosingPaginationLayer(); |
1415 if (rootLayerIsInsidePaginationLayer) { | 1489 if (rootLayerIsInsidePaginationLayer) { |
1416 // The root layer is in the same fragmentation context as this layer, so we need to look | 1490 // The root layer is in the same fragmentation context as this layer, so we need to look |
1417 // inside it and subtract the offset between the fragmentation context a nd the root layer. | 1491 // inside it and subtract the offset between the fragmentation context a nd the root layer. |
1418 offsetOfPaginationLayerFromRoot = -rootLayer->visualOffsetFromAncestor(e nclosingPaginationLayer()); | 1492 offsetOfPaginationLayerFromRoot = -rootLayer->visualOffsetFromAncestor(e nclosingPaginationLayer()); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2007 // ASSERT(layoutObject()->document().lifecycle().state() >= DocumentLifecycl e::LayoutClean); | 2081 // ASSERT(layoutObject()->document().lifecycle().state() >= DocumentLifecycl e::LayoutClean); |
2008 | 2082 |
2009 if (!layoutObject()->isLayoutBlock()) | 2083 if (!layoutObject()->isLayoutBlock()) |
2010 return false; | 2084 return false; |
2011 | 2085 |
2012 return toLayoutBlock(layoutObject())->shouldPaintSelectionGaps(); | 2086 return toLayoutBlock(layoutObject())->shouldPaintSelectionGaps(); |
2013 } | 2087 } |
2014 | 2088 |
2015 bool DeprecatedPaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, c onst LayoutRect& damageRect, const DeprecatedPaintLayer* rootLayer, const Layout Point* offsetFromRoot) const | 2089 bool DeprecatedPaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, c onst LayoutRect& damageRect, const DeprecatedPaintLayer* rootLayer, const Layout Point* offsetFromRoot) const |
2016 { | 2090 { |
2091 ASSERT(!(rootLayer && offsetFromRoot)); | |
2017 // Always examine the canvas and the root. | 2092 // Always examine the canvas and the root. |
2018 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView | 2093 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView |
2019 // paints the root's background. | 2094 // paints the root's background. |
2020 if (isRootLayer() || layoutObject()->isDocumentElement()) | 2095 if (isRootLayer() || layoutObject()->isDocumentElement()) |
2021 return true; | 2096 return true; |
2022 | 2097 |
2023 // If we aren't an inline flow, and our layer bounds do intersect the damage rect, then we | 2098 // If we aren't an inline flow, and our layer bounds do intersect the damage rect, then we |
2024 // can go ahead and return true. | 2099 // can go ahead and return true. |
2025 LayoutView* view = layoutObject()->view(); | 2100 LayoutView* view = layoutObject()->view(); |
2026 ASSERT(view); | 2101 ASSERT(view); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2075 LayoutRect result = boundingBox; | 2150 LayoutRect result = boundingBox; |
2076 if (layoutObjects->isBox()) | 2151 if (layoutObjects->isBox()) |
2077 toLayoutBox(layoutObjects)->flipForWritingMode(result); | 2152 toLayoutBox(layoutObjects)->flipForWritingMode(result); |
2078 else | 2153 else |
2079 layoutObjects->containingBlock()->flipForWritingMode(result); | 2154 layoutObjects->containingBlock()->flipForWritingMode(result); |
2080 return result; | 2155 return result; |
2081 } | 2156 } |
2082 | 2157 |
2083 LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint* offsetFromRoot) const | 2158 LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint* offsetFromRoot) const |
2084 { | 2159 { |
2160 ASSERT(!(ancestorLayer && offsetFromRoot)); | |
2085 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject()); | 2161 LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutOb ject()); |
2086 if (offsetFromRoot) | 2162 if (offsetFromRoot) |
2087 result.moveBy(*offsetFromRoot); | 2163 result.moveBy(*offsetFromRoot); |
2088 else | 2164 else |
2089 convertToLayerCoords(ancestorLayer, result); | 2165 convertToLayerCoords(ancestorLayer, result); |
2090 return result; | 2166 return result; |
2091 } | 2167 } |
2092 | 2168 |
2093 LayoutRect DeprecatedPaintLayer::fragmentsBoundingBox(const DeprecatedPaintLayer * ancestorLayer) const | 2169 LayoutRect DeprecatedPaintLayer::fragmentsBoundingBox(const DeprecatedPaintLayer * ancestorLayer) const |
2094 { | 2170 { |
(...skipping 27 matching lines...) Expand all Loading... | |
2122 // because those Layers don't paint into the graphics layer | 2198 // because those Layers don't paint into the graphics layer |
2123 // for this Layer. For example, the bounds of squashed Layers | 2199 // for this Layer. For example, the bounds of squashed Layers |
2124 // will be included in the computation of the appropriate squashing | 2200 // will be included in the computation of the appropriate squashing |
2125 // GraphicsLayer. | 2201 // GraphicsLayer. |
2126 if (options != DeprecatedPaintLayer::ApplyBoundsChickenEggHacks && node- >layer()->compositingState() != NotComposited) | 2202 if (options != DeprecatedPaintLayer::ApplyBoundsChickenEggHacks && node- >layer()->compositingState() != NotComposited) |
2127 continue; | 2203 continue; |
2128 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer, opt ions)); | 2204 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer, opt ions)); |
2129 } | 2205 } |
2130 } | 2206 } |
2131 | 2207 |
2132 LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStacki ngChildren(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint& offsetF romRoot) const | 2208 LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStacki ngChildren(const LayoutPoint& offsetFromRoot) const |
2133 { | 2209 { |
2134 LayoutPoint origin; | 2210 LayoutPoint origin; |
2135 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | 2211 LayoutRect result = physicalBoundingBox(nullptr, &origin); |
2136 | 2212 |
2137 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfN eeded(); | 2213 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfN eeded(); |
2138 | 2214 |
2139 expandRectForReflectionAndStackingChildren(this, DoNotApplyBoundsChickenEggH acks, result); | 2215 expandRectForReflectionAndStackingChildren(this, DoNotApplyBoundsChickenEggH acks, result); |
2140 | 2216 |
2141 result.moveBy(offsetFromRoot); | 2217 result.moveBy(offsetFromRoot); |
2142 return result; | 2218 return result; |
2143 } | 2219 } |
2144 | 2220 |
2145 LayoutRect DeprecatedPaintLayer::boundingBoxForCompositing(const DeprecatedPaint Layer* ancestorLayer, CalculateBoundsOptions options) const | 2221 LayoutRect DeprecatedPaintLayer::boundingBoxForCompositing(const DeprecatedPaint Layer* ancestorLayer, CalculateBoundsOptions options) const |
(...skipping 14 matching lines...) Expand all Loading... | |
2160 | 2236 |
2161 // The layer created for the LayoutFlowThread is just a helper for painting and hit-testing, | 2237 // The layer created for the LayoutFlowThread is just a helper for painting and hit-testing, |
2162 // and should not contribute to the bounding box. The LayoutMultiColumnSets will contribute | 2238 // and should not contribute to the bounding box. The LayoutMultiColumnSets will contribute |
2163 // the correct size for the layout content of the multicol container. | 2239 // the correct size for the layout content of the multicol container. |
2164 if (layoutObject()->isLayoutFlowThread()) | 2240 if (layoutObject()->isLayoutFlowThread()) |
2165 return LayoutRect(); | 2241 return LayoutRect(); |
2166 | 2242 |
2167 LayoutRect result = clipper().localClipRect(); | 2243 LayoutRect result = clipper().localClipRect(); |
2168 if (result == LayoutRect::infiniteIntRect()) { | 2244 if (result == LayoutRect::infiniteIntRect()) { |
2169 LayoutPoint origin; | 2245 LayoutPoint origin; |
2170 result = physicalBoundingBox(ancestorLayer, &origin); | 2246 result = physicalBoundingBox(nullptr, &origin); |
2171 | 2247 |
2172 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList sIfNeeded(); | 2248 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList sIfNeeded(); |
2173 | 2249 |
2174 // Reflections are implemented with Layers that hang off of the reflecte d layer. However, | 2250 // Reflections are implemented with Layers that hang off of the reflecte d layer. However, |
2175 // the reflection layer subtree does not include the subtree of the pare nt Layer, so | 2251 // the reflection layer subtree does not include the subtree of the pare nt Layer, so |
2176 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking | 2252 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking |
2177 // children of the parent, that need to be included in reflected composi ted bounds. | 2253 // children of the parent, that need to be included in reflected composi ted bounds. |
2178 // Fix this by including composited bounds of stacking children of the r eflected Layer. | 2254 // Fix this by including composited bounds of stacking children of the r eflected Layer. |
2179 if (hasCompositedDeprecatedPaintLayerMapping() && parent() && parent()-> reflectionInfo() && parent()->reflectionInfo()->reflectionLayer() == this) | 2255 if (hasCompositedDeprecatedPaintLayerMapping() && parent() && parent()-> reflectionInfo() && parent()->reflectionInfo()->reflectionLayer() == this) |
2180 expandRectForReflectionAndStackingChildren(parent(), options, result ); | 2256 expandRectForReflectionAndStackingChildren(parent(), options, result ); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2671 | 2747 |
2672 void showLayerTree(const blink::LayoutObject* layoutObject) | 2748 void showLayerTree(const blink::LayoutObject* layoutObject) |
2673 { | 2749 { |
2674 if (!layoutObject) { | 2750 if (!layoutObject) { |
2675 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2751 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2676 return; | 2752 return; |
2677 } | 2753 } |
2678 showLayerTree(layoutObject->enclosingLayer()); | 2754 showLayerTree(layoutObject->enclosingLayer()); |
2679 } | 2755 } |
2680 #endif | 2756 #endif |
OLD | NEW |