| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // a self-painting descendant in this case, there is no need to dirty our | 321 // a self-painting descendant in this case, there is no need to dirty our |
| 322 // ancestors further. | 322 // ancestors further. |
| 323 if (layer->isSelfPaintingLayer()) { | 323 if (layer->isSelfPaintingLayer()) { |
| 324 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || | 324 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || |
| 325 parent()->m_hasSelfPaintingLayerDescendant); | 325 parent()->m_hasSelfPaintingLayerDescendant); |
| 326 break; | 326 break; |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 static const ScrollPaintPropertyNode* nearestScrollNode( |
| 332 const TransformPaintPropertyNode* transform) { |
| 333 if (const auto* scrollNode = transform->scrollNode()) |
| 334 return scrollNode; |
| 335 for (const auto* ancestor = transform->parent(); ancestor; |
| 336 ancestor = ancestor->parent()) { |
| 337 if (const auto* scrollNode = ancestor->scrollNode()) |
| 338 return scrollNode; |
| 339 } |
| 340 // The root transform node references the root scroll node so a scroll node |
| 341 // should always exist. |
| 342 NOTREACHED(); |
| 343 return nullptr; |
| 344 } |
| 345 |
| 331 bool PaintLayer::sticksToViewport() const { | 346 bool PaintLayer::sticksToViewport() const { |
| 332 if (layoutObject()->style()->position() != FixedPosition && | 347 if (layoutObject()->style()->position() != FixedPosition && |
| 333 layoutObject()->style()->position() != StickyPosition) | 348 layoutObject()->style()->position() != StickyPosition) |
| 334 return false; | 349 return false; |
| 335 | 350 |
| 351 // TODO(pdr): This approach of calculating the nearest scroll node is O(n). |
| 352 // An option for improving this is to cache the nearest scroll node in |
| 353 // the local border box properties. |
| 336 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 354 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 337 const ScrollPaintPropertyNode* ancestorTargetScrollNode; | 355 const ScrollPaintPropertyNode* ancestorTargetScrollNode; |
| 338 if (layoutObject()->style()->position() == FixedPosition) { | 356 if (layoutObject()->style()->position() == FixedPosition) { |
| 339 ancestorTargetScrollNode = layoutObject() | 357 ancestorTargetScrollNode = |
| 340 ->view() | 358 nearestScrollNode(layoutObject() |
| 341 ->paintProperties() | 359 ->view() |
| 342 ->localBorderBoxProperties() | 360 ->paintProperties() |
| 343 ->scroll(); | 361 ->localBorderBoxProperties() |
| 362 ->transform()); |
| 344 } else { | 363 } else { |
| 345 ancestorTargetScrollNode = layoutObject() | 364 ancestorTargetScrollNode = nearestScrollNode(layoutObject() |
| 346 ->view() | 365 ->view() |
| 347 ->paintProperties() | 366 ->paintProperties() |
| 348 ->contentsProperties() | 367 ->contentsProperties() |
| 349 ->scroll(); | 368 ->transform()); |
| 350 } | 369 } |
| 351 | 370 |
| 352 return layoutObject() | 371 return nearestScrollNode(layoutObject() |
| 353 ->paintProperties() | 372 ->paintProperties() |
| 354 ->localBorderBoxProperties() | 373 ->localBorderBoxProperties() |
| 355 ->scroll() == ancestorTargetScrollNode; | 374 ->transform()) == ancestorTargetScrollNode; |
| 356 } | 375 } |
| 357 | 376 |
| 358 return (layoutObject()->style()->position() == FixedPosition && | 377 return (layoutObject()->style()->position() == FixedPosition && |
| 359 layoutObject()->containerForFixedPosition() == | 378 layoutObject()->containerForFixedPosition() == |
| 360 layoutObject()->view()) || | 379 layoutObject()->view()) || |
| 361 (layoutObject()->style()->position() == StickyPosition && | 380 (layoutObject()->style()->position() == StickyPosition && |
| 362 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root())); | 381 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root())); |
| 363 } | 382 } |
| 364 | 383 |
| 365 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { | 384 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { |
| (...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3193 } | 3212 } |
| 3194 | 3213 |
| 3195 void showLayerTree(const blink::LayoutObject* layoutObject) { | 3214 void showLayerTree(const blink::LayoutObject* layoutObject) { |
| 3196 if (!layoutObject) { | 3215 if (!layoutObject) { |
| 3197 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; | 3216 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; |
| 3198 return; | 3217 return; |
| 3199 } | 3218 } |
| 3200 showLayerTree(layoutObject->enclosingLayer()); | 3219 showLayerTree(layoutObject->enclosingLayer()); |
| 3201 } | 3220 } |
| 3202 #endif | 3221 #endif |
| OLD | NEW |