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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2692853016: Change PaintLayer::m_layoutObject to a reference. (Closed)
Patch Set: Added TODO Created 3 years, 10 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
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 PaintLayerRareData::PaintLayerRareData() 121 PaintLayerRareData::PaintLayerRareData()
122 : enclosingPaginationLayer(nullptr), 122 : enclosingPaginationLayer(nullptr),
123 potentialCompositingReasonsFromStyle(CompositingReasonNone), 123 potentialCompositingReasonsFromStyle(CompositingReasonNone),
124 compositingReasons(CompositingReasonNone), 124 compositingReasons(CompositingReasonNone),
125 squashingDisallowedReasons(SquashingDisallowedReasonsNone), 125 squashingDisallowedReasons(SquashingDisallowedReasonsNone),
126 groupedMapping(nullptr) {} 126 groupedMapping(nullptr) {}
127 127
128 PaintLayerRareData::~PaintLayerRareData() {} 128 PaintLayerRareData::~PaintLayerRareData() {}
129 129
130 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject) 130 PaintLayer::PaintLayer(LayoutBoxModelObject& layoutObject)
131 : m_hasSelfPaintingLayerDescendant(false), 131 : m_hasSelfPaintingLayerDescendant(false),
132 m_hasSelfPaintingLayerDescendantDirty(false), 132 m_hasSelfPaintingLayerDescendantDirty(false),
133 m_isRootLayer(layoutObject->isLayoutView()), 133 m_isRootLayer(layoutObject.isLayoutView()),
134 m_hasVisibleContent(false), 134 m_hasVisibleContent(false),
135 m_needsDescendantDependentFlagsUpdate(true), 135 m_needsDescendantDependentFlagsUpdate(true),
136 m_hasVisibleDescendant(false), 136 m_hasVisibleDescendant(false),
137 #if DCHECK_IS_ON() 137 #if DCHECK_IS_ON()
138 m_needsPositionUpdate(true), 138 m_needsPositionUpdate(true),
139 #endif 139 #endif
140 m_has3DTransformedDescendant(false), 140 m_has3DTransformedDescendant(false),
141 m_containsDirtyOverlayScrollbars(false), 141 m_containsDirtyOverlayScrollbars(false),
142 m_needsAncestorDependentCompositingInputsUpdate(true), 142 m_needsAncestorDependentCompositingInputsUpdate(true),
143 m_childNeedsCompositingInputsUpdate(true), 143 m_childNeedsCompositingInputsUpdate(true),
(...skipping 25 matching lines...) Expand all
169 m_ancestorOverflowLayer(nullptr) { 169 m_ancestorOverflowLayer(nullptr) {
170 updateStackingNode(); 170 updateStackingNode();
171 171
172 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 172 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
173 173
174 updateScrollableArea(); 174 updateScrollableArea();
175 } 175 }
176 176
177 PaintLayer::~PaintLayer() { 177 PaintLayer::~PaintLayer() {
178 if (m_rareData && m_rareData->resourceInfo) { 178 if (m_rareData && m_rareData->resourceInfo) {
179 const ComputedStyle& style = layoutObject()->styleRef(); 179 const ComputedStyle& style = layoutObject().styleRef();
180 if (style.hasFilter()) 180 if (style.hasFilter())
181 style.filter().removeClient(m_rareData->resourceInfo); 181 style.filter().removeClient(m_rareData->resourceInfo);
182 if (isReferenceClipPath(style.clipPath())) { 182 if (isReferenceClipPath(style.clipPath())) {
183 toReferenceClipPathOperation(style.clipPath()) 183 toReferenceClipPathOperation(style.clipPath())
184 ->removeClient(m_rareData->resourceInfo); 184 ->removeClient(m_rareData->resourceInfo);
185 } 185 }
186 m_rareData->resourceInfo->clearLayer(); 186 m_rareData->resourceInfo->clearLayer();
187 } 187 }
188 if (layoutObject()->frame() && layoutObject()->frame()->page()) { 188 if (layoutObject().frame() && layoutObject().frame()->page()) {
189 if (ScrollingCoordinator* scrollingCoordinator = 189 if (ScrollingCoordinator* scrollingCoordinator =
190 layoutObject()->frame()->page()->scrollingCoordinator()) 190 layoutObject().frame()->page()->scrollingCoordinator())
191 scrollingCoordinator->willDestroyLayer(this); 191 scrollingCoordinator->willDestroyLayer(this);
192 } 192 }
193 193
194 if (groupedMapping()) { 194 if (groupedMapping()) {
195 DisableCompositingQueryAsserts disabler; 195 DisableCompositingQueryAsserts disabler;
196 setGroupedMapping(0, InvalidateLayerAndRemoveFromMapping); 196 setGroupedMapping(0, InvalidateLayerAndRemoveFromMapping);
197 } 197 }
198 198
199 // Child layers will be deleted by their corresponding layout objects, so 199 // Child layers will be deleted by their corresponding layout objects, so
200 // we don't need to delete them ourselves. 200 // we don't need to delete them ourselves.
201 201
202 clearCompositedLayerMapping(true); 202 clearCompositedLayerMapping(true);
203 203
204 if (m_scrollableArea) 204 if (m_scrollableArea)
205 m_scrollableArea->dispose(); 205 m_scrollableArea->dispose();
206 } 206 }
207 207
208 String PaintLayer::debugName() const { 208 String PaintLayer::debugName() const {
209 return layoutObject()->debugName(); 209 return layoutObject().debugName();
210 } 210 }
211 211
212 LayoutRect PaintLayer::visualRect() const { 212 LayoutRect PaintLayer::visualRect() const {
213 return m_layoutObject->visualRect(); 213 return m_layoutObject.visualRect();
214 } 214 }
215 215
216 PaintLayerCompositor* PaintLayer::compositor() const { 216 PaintLayerCompositor* PaintLayer::compositor() const {
217 if (!layoutObject()->view()) 217 if (!layoutObject().view())
218 return 0; 218 return 0;
219 return layoutObject()->view()->compositor(); 219 return layoutObject().view()->compositor();
220 } 220 }
221 221
222 void PaintLayer::contentChanged(ContentChangeType changeType) { 222 void PaintLayer::contentChanged(ContentChangeType changeType) {
223 // updateLayerCompositingState will query compositingReasons for accelerated 223 // updateLayerCompositingState will query compositingReasons for accelerated
224 // overflow scrolling. This is tripped by 224 // overflow scrolling. This is tripped by
225 // LayoutTests/compositing/content-changed-chicken-egg.html 225 // LayoutTests/compositing/content-changed-chicken-egg.html
226 DisableCompositingQueryAsserts disabler; 226 DisableCompositingQueryAsserts disabler;
227 227
228 if (changeType == CanvasChanged) 228 if (changeType == CanvasChanged)
229 compositor()->setNeedsCompositingUpdate( 229 compositor()->setNeedsCompositingUpdate(
(...skipping 11 matching lines...) Expand all
241 compositedLayerMapping()->setNeedsGraphicsLayerUpdate( 241 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(
242 GraphicsLayerUpdateSubtree); 242 GraphicsLayerUpdateSubtree);
243 } 243 }
244 244
245 if (CompositedLayerMapping* compositedLayerMapping = 245 if (CompositedLayerMapping* compositedLayerMapping =
246 this->compositedLayerMapping()) 246 this->compositedLayerMapping())
247 compositedLayerMapping->contentChanged(changeType); 247 compositedLayerMapping->contentChanged(changeType);
248 } 248 }
249 249
250 bool PaintLayer::paintsWithFilters() const { 250 bool PaintLayer::paintsWithFilters() const {
251 if (!layoutObject()->hasFilterInducingProperty()) 251 if (!layoutObject().hasFilterInducingProperty())
252 return false; 252 return false;
253 253
254 // https://code.google.com/p/chromium/issues/detail?id=343759 254 // https://code.google.com/p/chromium/issues/detail?id=343759
255 DisableCompositingQueryAsserts disabler; 255 DisableCompositingQueryAsserts disabler;
256 return !compositedLayerMapping() || 256 return !compositedLayerMapping() ||
257 compositingState() != PaintsIntoOwnBacking; 257 compositingState() != PaintsIntoOwnBacking;
258 } 258 }
259 259
260 bool PaintLayer::paintsWithBackdropFilters() const { 260 bool PaintLayer::paintsWithBackdropFilters() const {
261 if (!layoutObject()->hasBackdropFilter()) 261 if (!layoutObject().hasBackdropFilter())
262 return false; 262 return false;
263 263
264 // https://code.google.com/p/chromium/issues/detail?id=343759 264 // https://code.google.com/p/chromium/issues/detail?id=343759
265 DisableCompositingQueryAsserts disabler; 265 DisableCompositingQueryAsserts disabler;
266 return !compositedLayerMapping() || 266 return !compositedLayerMapping() ||
267 compositingState() != PaintsIntoOwnBacking; 267 compositingState() != PaintsIntoOwnBacking;
268 } 268 }
269 269
270 LayoutSize PaintLayer::subpixelAccumulation() const { 270 LayoutSize PaintLayer::subpixelAccumulation() const {
271 return m_rareData ? m_rareData->subpixelAccumulation : LayoutSize(); 271 return m_rareData ? m_rareData->subpixelAccumulation : LayoutSize();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // ancestors further. 323 // ancestors further.
324 if (layer->isSelfPaintingLayer()) { 324 if (layer->isSelfPaintingLayer()) {
325 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty || 325 DCHECK(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty ||
326 parent()->m_hasSelfPaintingLayerDescendant); 326 parent()->m_hasSelfPaintingLayerDescendant);
327 break; 327 break;
328 } 328 }
329 } 329 }
330 } 330 }
331 331
332 bool PaintLayer::sticksToViewport() const { 332 bool PaintLayer::sticksToViewport() const {
333 if (layoutObject()->style()->position() != EPosition::kFixed && 333 if (layoutObject().style()->position() != EPosition::kFixed &&
334 layoutObject()->style()->position() != EPosition::kSticky) 334 layoutObject().style()->position() != EPosition::kSticky)
335 return false; 335 return false;
336 336
337 // TODO(pdr): This approach of calculating the nearest scroll node is O(n). 337 // TODO(pdr): This approach of calculating the nearest scroll node is O(n).
338 // An option for improving this is to cache the nearest scroll node in 338 // An option for improving this is to cache the nearest scroll node in
339 // the local border box properties. 339 // the local border box properties.
340 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 340 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
341 const auto* viewProperties = layoutObject()->view()->paintProperties(); 341 const auto* viewProperties = layoutObject().view()->paintProperties();
342 const ScrollPaintPropertyNode* ancestorTargetScrollNode; 342 const ScrollPaintPropertyNode* ancestorTargetScrollNode;
343 if (layoutObject()->style()->position() == EPosition::kFixed) { 343 if (layoutObject().style()->position() == EPosition::kFixed) {
344 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() 344 ancestorTargetScrollNode = viewProperties->localBorderBoxProperties()
345 ->transform() 345 ->transform()
346 ->findEnclosingScrollNode(); 346 ->findEnclosingScrollNode();
347 } else { 347 } else {
348 ancestorTargetScrollNode = viewProperties->contentsProperties() 348 ancestorTargetScrollNode = viewProperties->contentsProperties()
349 ->transform() 349 ->transform()
350 ->findEnclosingScrollNode(); 350 ->findEnclosingScrollNode();
351 } 351 }
352 352
353 const auto* properties = layoutObject()->paintProperties(); 353 const auto* properties = layoutObject().paintProperties();
354 const auto* transform = properties->localBorderBoxProperties()->transform(); 354 const auto* transform = properties->localBorderBoxProperties()->transform();
355 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; 355 return transform->findEnclosingScrollNode() == ancestorTargetScrollNode;
356 } 356 }
357 357
358 return (layoutObject()->style()->position() == EPosition::kFixed && 358 return (layoutObject().style()->position() == EPosition::kFixed &&
359 layoutObject()->containerForFixedPosition() == 359 layoutObject().containerForFixedPosition() ==
360 layoutObject()->view()) || 360 layoutObject().view()) ||
361 (layoutObject()->style()->position() == EPosition::kSticky && 361 (layoutObject().style()->position() == EPosition::kSticky &&
362 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root())); 362 (!ancestorScrollingLayer() || ancestorScrollingLayer() == root()));
363 } 363 }
364 364
365 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { 365 bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const {
366 if (sticksToViewport() != other->sticksToViewport()) 366 if (sticksToViewport() != other->sticksToViewport())
367 return true; 367 return true;
368 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); 368 return ancestorScrollingLayer() != other->ancestorScrollingLayer();
369 } 369 }
370 370
371 void PaintLayer::updateLayerPositionsAfterOverflowScroll() { 371 void PaintLayer::updateLayerPositionsAfterOverflowScroll() {
(...skipping 16 matching lines...) Expand all
388 } 388 }
389 389
390 void PaintLayer::updateTransform(const ComputedStyle* oldStyle, 390 void PaintLayer::updateTransform(const ComputedStyle* oldStyle,
391 const ComputedStyle& newStyle) { 391 const ComputedStyle& newStyle) {
392 if (oldStyle && newStyle.transformDataEquivalent(*oldStyle)) 392 if (oldStyle && newStyle.transformDataEquivalent(*oldStyle))
393 return; 393 return;
394 394
395 // hasTransform() on the layoutObject is also true when there is 395 // hasTransform() on the layoutObject is also true when there is
396 // transform-style: preserve-3d or perspective set, so check style too. 396 // transform-style: preserve-3d or perspective set, so check style too.
397 bool hasTransform = 397 bool hasTransform =
398 layoutObject()->hasTransformRelatedProperty() && newStyle.hasTransform(); 398 layoutObject().hasTransformRelatedProperty() && newStyle.hasTransform();
399 bool had3DTransform = has3DTransform(); 399 bool had3DTransform = has3DTransform();
400 400
401 bool hadTransform = transform(); 401 bool hadTransform = transform();
402 if (hasTransform != hadTransform) { 402 if (hasTransform != hadTransform) {
403 if (hasTransform) 403 if (hasTransform)
404 ensureRareData().transform = TransformationMatrix::create(); 404 ensureRareData().transform = TransformationMatrix::create();
405 else 405 else
406 m_rareData->transform.reset(); 406 m_rareData->transform.reset();
407 407
408 // PaintLayers with transforms act as clip rects roots, so clear the cached 408 // PaintLayers with transforms act as clip rects roots, so clear the cached
409 // clip rects here. 409 // clip rects here.
410 clipper(PaintLayer::DoNotUseGeometryMapper) 410 clipper(PaintLayer::DoNotUseGeometryMapper)
411 .clearClipRectsIncludingDescendants(); 411 .clearClipRectsIncludingDescendants();
412 } else if (hasTransform) { 412 } else if (hasTransform) {
413 clipper(PaintLayer::DoNotUseGeometryMapper) 413 clipper(PaintLayer::DoNotUseGeometryMapper)
414 .clearClipRectsIncludingDescendants(AbsoluteClipRects); 414 .clearClipRectsIncludingDescendants(AbsoluteClipRects);
415 } 415 }
416 416
417 updateTransformationMatrix(); 417 updateTransformationMatrix();
418 418
419 if (had3DTransform != has3DTransform()) 419 if (had3DTransform != has3DTransform())
420 markAncestorChainForDescendantDependentFlagsUpdate(); 420 markAncestorChainForDescendantDependentFlagsUpdate();
421 421
422 if (FrameView* frameView = layoutObject()->document().view()) 422 if (FrameView* frameView = layoutObject().document().view())
423 frameView->setNeedsUpdateWidgetGeometries(); 423 frameView->setNeedsUpdateWidgetGeometries();
424 } 424 }
425 425
426 static PaintLayer* enclosingLayerForContainingBlock(PaintLayer* layer) { 426 static PaintLayer* enclosingLayerForContainingBlock(PaintLayer* layer) {
427 if (LayoutObject* containingBlock = layer->layoutObject()->containingBlock()) 427 if (LayoutObject* containingBlock = layer->layoutObject().containingBlock())
428 return containingBlock->enclosingLayer(); 428 return containingBlock->enclosingLayer();
429 return 0; 429 return 0;
430 } 430 }
431 431
432 static const PaintLayer* enclosingLayerForContainingBlock( 432 static const PaintLayer* enclosingLayerForContainingBlock(
433 const PaintLayer* layer) { 433 const PaintLayer* layer) {
434 if (const LayoutObject* containingBlock = 434 if (const LayoutObject* containingBlock =
435 layer->layoutObject()->containingBlock()) 435 layer->layoutObject().containingBlock())
436 return containingBlock->enclosingLayer(); 436 return containingBlock->enclosingLayer();
437 return 0; 437 return 0;
438 } 438 }
439 439
440 PaintLayer* PaintLayer::renderingContextRoot() { 440 PaintLayer* PaintLayer::renderingContextRoot() {
441 PaintLayer* renderingContext = 0; 441 PaintLayer* renderingContext = 0;
442 442
443 if (shouldPreserve3D()) 443 if (shouldPreserve3D())
444 renderingContext = this; 444 renderingContext = this;
445 445
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 485
486 return *transform; 486 return *transform;
487 } 487 }
488 488
489 void PaintLayer::convertFromFlowThreadToVisualBoundingBoxInAncestor( 489 void PaintLayer::convertFromFlowThreadToVisualBoundingBoxInAncestor(
490 const PaintLayer* ancestorLayer, 490 const PaintLayer* ancestorLayer,
491 LayoutRect& rect) const { 491 LayoutRect& rect) const {
492 PaintLayer* paginationLayer = enclosingPaginationLayer(); 492 PaintLayer* paginationLayer = enclosingPaginationLayer();
493 DCHECK(paginationLayer); 493 DCHECK(paginationLayer);
494 LayoutFlowThread* flowThread = 494 LayoutFlowThread& flowThread =
495 toLayoutFlowThread(paginationLayer->layoutObject()); 495 toLayoutFlowThread(paginationLayer->layoutObject());
496 496
497 // First make the flow thread rectangle relative to the flow thread, not to 497 // First make the flow thread rectangle relative to the flow thread, not to
498 // |layer|. 498 // |layer|.
499 LayoutPoint offsetWithinPaginationLayer; 499 LayoutPoint offsetWithinPaginationLayer;
500 convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer); 500 convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer);
501 rect.moveBy(offsetWithinPaginationLayer); 501 rect.moveBy(offsetWithinPaginationLayer);
502 502
503 // Then make the rectangle visual, relative to the fragmentation context. 503 // Then make the rectangle visual, relative to the fragmentation context.
504 // Split our box up into the actual fragment boxes that layout in the 504 // Split our box up into the actual fragment boxes that layout in the
505 // columns/pages and unite those together to get our true bounding box. 505 // columns/pages and unite those together to get our true bounding box.
506 rect = flowThread->fragmentsBoundingBox(rect); 506 rect = flowThread.fragmentsBoundingBox(rect);
507 507
508 // Finally, make the visual rectangle relative to |ancestorLayer|. 508 // Finally, make the visual rectangle relative to |ancestorLayer|.
509 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) { 509 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) {
510 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); 510 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer));
511 return; 511 return;
512 } 512 }
513 // The ancestor layer is inside the same pagination layer as |layer|, so we 513 // The ancestor layer is inside the same pagination layer as |layer|, so we
514 // need to subtract the visual distance from the ancestor layer to the 514 // need to subtract the visual distance from the ancestor layer to the
515 // pagination layer. 515 // pagination layer.
516 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); 516 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer));
517 } 517 }
518 518
519 void PaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) { 519 void PaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) {
520 if (m_rareData) 520 if (m_rareData)
521 m_rareData->enclosingPaginationLayer = nullptr; 521 m_rareData->enclosingPaginationLayer = nullptr;
522 522
523 if (layoutObject()->isLayoutFlowThread()) 523 if (layoutObject().isLayoutFlowThread())
524 needsPaginationUpdate = true; 524 needsPaginationUpdate = true;
525 525
526 if (needsPaginationUpdate) { 526 if (needsPaginationUpdate) {
527 // Each paginated layer has to paint on its own. There is no recurring into 527 // Each paginated layer has to paint on its own. There is no recurring into
528 // child layers. Each layer has to be checked individually and genuinely 528 // child layers. Each layer has to be checked individually and genuinely
529 // know if it is going to have to split itself up when painting only its 529 // know if it is going to have to split itself up when painting only its
530 // contents (and not any other descendant layers). We track an 530 // contents (and not any other descendant layers). We track an
531 // enclosingPaginationLayer instead of using a simple bit, since we want to 531 // enclosingPaginationLayer instead of using a simple bit, since we want to
532 // be able to get back to that layer easily. 532 // be able to get back to that layer easily.
533 if (LayoutFlowThread* containingFlowThread = 533 if (LayoutFlowThread* containingFlowThread =
534 layoutObject()->flowThreadContainingBlock()) 534 layoutObject().flowThreadContainingBlock())
535 ensureRareData().enclosingPaginationLayer = containingFlowThread->layer(); 535 ensureRareData().enclosingPaginationLayer = containingFlowThread->layer();
536 } 536 }
537 537
538 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) 538 for (PaintLayer* child = firstChild(); child; child = child->nextSibling())
539 child->updatePaginationRecursive(needsPaginationUpdate); 539 child->updatePaginationRecursive(needsPaginationUpdate);
540 } 540 }
541 541
542 void PaintLayer::clearPaginationRecursive() { 542 void PaintLayer::clearPaginationRecursive() {
543 if (m_rareData) 543 if (m_rareData)
544 m_rareData->enclosingPaginationLayer = nullptr; 544 m_rareData->enclosingPaginationLayer = nullptr;
545 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) 545 for (PaintLayer* child = firstChild(); child; child = child->nextSibling())
546 child->clearPaginationRecursive(); 546 child->clearPaginationRecursive();
547 } 547 }
548 548
549 void PaintLayer::mapPointInPaintInvalidationContainerToBacking( 549 void PaintLayer::mapPointInPaintInvalidationContainerToBacking(
550 const LayoutBoxModelObject& paintInvalidationContainer, 550 const LayoutBoxModelObject& paintInvalidationContainer,
551 FloatPoint& point) { 551 FloatPoint& point) {
552 // TODO(chrishtr): this should be
553 // PaintLayer* transformedAncestorPaintLayer =
554 // paintInvalidationLayer->enclosingTransformedAncestor();
555 // if (!transformedAncestorPaintLayer)
556 // return;
552 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer(); 557 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer();
553 if (!paintInvalidationLayer->groupedMapping()) 558 if (!paintInvalidationLayer->groupedMapping())
554 return; 559 return;
555 560
556 LayoutBoxModelObject* transformedAncestor = 561 LayoutBoxModelObject& transformedAncestor =
557 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject(); 562 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject();
558 if (!transformedAncestor)
559 return;
560 563
561 // |paintInvalidationContainer| may have a local 2D transform on it, so take 564 // |paintInvalidationContainer| may have a local 2D transform on it, so take
562 // that into account when mapping into the space of the transformed ancestor. 565 // that into account when mapping into the space of the transformed ancestor.
563 point = paintInvalidationContainer.localToAncestorPoint(point, 566 point = paintInvalidationContainer.localToAncestorPoint(point,
564 transformedAncestor); 567 &transformedAncestor);
565 568
566 point.moveBy(-paintInvalidationLayer->groupedMapping() 569 point.moveBy(-paintInvalidationLayer->groupedMapping()
567 ->squashingOffsetFromTransformedAncestor()); 570 ->squashingOffsetFromTransformedAncestor());
568 } 571 }
569 572
570 void PaintLayer::mapRectInPaintInvalidationContainerToBacking( 573 void PaintLayer::mapRectInPaintInvalidationContainerToBacking(
571 const LayoutBoxModelObject& paintInvalidationContainer, 574 const LayoutBoxModelObject& paintInvalidationContainer,
572 LayoutRect& rect) { 575 LayoutRect& rect) {
576 // TODO(chrishtr): this should be
577 // PaintLayer* transformedAncestorPaintLayer =
578 // paintInvalidationLayer->enclosingTransformedAncestor();
579 // if (!transformedAncestorPaintLayer)
580 // return;
573 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer(); 581 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer();
574 if (!paintInvalidationLayer->groupedMapping()) 582 if (!paintInvalidationLayer->groupedMapping())
575 return; 583 return;
576 584
577 LayoutBoxModelObject* transformedAncestor = 585 LayoutBoxModelObject& transformedAncestor =
578 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject(); 586 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject();
579 if (!transformedAncestor)
580 return;
581 587
582 // |paintInvalidationContainer| may have a local 2D transform on it, so take 588 // |paintInvalidationContainer| may have a local 2D transform on it, so take
583 // that into account when mapping into the space of the transformed ancestor. 589 // that into account when mapping into the space of the transformed ancestor.
584 rect = 590 rect =
585 LayoutRect(paintInvalidationContainer 591 LayoutRect(paintInvalidationContainer
586 .localToAncestorQuad(FloatRect(rect), transformedAncestor) 592 .localToAncestorQuad(FloatRect(rect), &transformedAncestor)
587 .boundingBox()); 593 .boundingBox());
588 594
589 rect.moveBy(-paintInvalidationLayer->groupedMapping() 595 rect.moveBy(-paintInvalidationLayer->groupedMapping()
590 ->squashingOffsetFromTransformedAncestor()); 596 ->squashingOffsetFromTransformedAncestor());
591 } 597 }
592 598
593 void PaintLayer::mapRectToPaintInvalidationBacking( 599 void PaintLayer::mapRectToPaintInvalidationBacking(
594 const LayoutObject& layoutObject, 600 const LayoutObject& layoutObject,
595 const LayoutBoxModelObject& paintInvalidationContainer, 601 const LayoutBoxModelObject& paintInvalidationContainer,
596 LayoutRect& rect) { 602 LayoutRect& rect) {
(...skipping 25 matching lines...) Expand all
622 parent()->dirtyVisibleContentStatus(); 628 parent()->dirtyVisibleContentStatus();
623 } 629 }
624 630
625 void PaintLayer::markAncestorChainForDescendantDependentFlagsUpdate() { 631 void PaintLayer::markAncestorChainForDescendantDependentFlagsUpdate() {
626 for (PaintLayer* layer = this; layer; layer = layer->parent()) { 632 for (PaintLayer* layer = this; layer; layer = layer->parent()) {
627 if (layer->m_needsDescendantDependentFlagsUpdate) 633 if (layer->m_needsDescendantDependentFlagsUpdate)
628 break; 634 break;
629 layer->m_needsDescendantDependentFlagsUpdate = true; 635 layer->m_needsDescendantDependentFlagsUpdate = true;
630 636
631 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 637 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
632 layer->layoutObject()->setNeedsPaintPropertyUpdate(); 638 layer->layoutObject().setNeedsPaintPropertyUpdate();
633 } 639 }
634 } 640 }
635 641
636 // FIXME: this is quite brute-force. We could be more efficient if we were to 642 // FIXME: this is quite brute-force. We could be more efficient if we were to
637 // track state and update it as appropriate as changes are made in the layout 643 // track state and update it as appropriate as changes are made in the layout
638 // tree. 644 // tree.
639 void PaintLayer::updateScrollingStateAfterCompositingChange() { 645 void PaintLayer::updateScrollingStateAfterCompositingChange() {
640 TRACE_EVENT0("blink", 646 TRACE_EVENT0("blink",
641 "PaintLayer::updateScrollingStateAfterCompositingChange"); 647 "PaintLayer::updateScrollingStateAfterCompositingChange");
642 m_isAllScrollingContentComposited = true; 648 m_isAllScrollingContentComposited = true;
643 for (LayoutObject* r = layoutObject()->slowFirstChild(); r; 649 for (LayoutObject* r = layoutObject().slowFirstChild(); r;
644 r = r->nextSibling()) { 650 r = r->nextSibling()) {
645 if (!r->hasLayer()) { 651 if (!r->hasLayer()) {
646 m_isAllScrollingContentComposited = false; 652 m_isAllScrollingContentComposited = false;
647 return; 653 return;
648 } 654 }
649 } 655 }
650 656
651 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { 657 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) {
652 if (child->compositingState() == NotComposited) { 658 if (child->compositingState() == NotComposited) {
653 m_isAllScrollingContentComposited = false; 659 m_isAllScrollingContentComposited = false;
(...skipping 19 matching lines...) Expand all
673 for (PaintLayer* child = firstChild(); child; 679 for (PaintLayer* child = firstChild(); child;
674 child = child->nextSibling()) { 680 child = child->nextSibling()) {
675 child->updateDescendantDependentFlags(); 681 child->updateDescendantDependentFlags();
676 682
677 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) 683 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant)
678 m_hasVisibleDescendant = true; 684 m_hasVisibleDescendant = true;
679 685
680 m_hasNonIsolatedDescendantWithBlendMode |= 686 m_hasNonIsolatedDescendantWithBlendMode |=
681 (!child->stackingNode()->isStackingContext() && 687 (!child->stackingNode()->isStackingContext() &&
682 child->hasNonIsolatedDescendantWithBlendMode()) || 688 child->hasNonIsolatedDescendantWithBlendMode()) ||
683 child->layoutObject()->styleRef().hasBlendMode(); 689 child->layoutObject().styleRef().hasBlendMode();
684 690
685 m_hasDescendantWithClipPath |= child->hasDescendantWithClipPath() || 691 m_hasDescendantWithClipPath |= child->hasDescendantWithClipPath() ||
686 child->layoutObject()->hasClipPath(); 692 child->layoutObject().hasClipPath();
687 693
688 m_hasRootScrollerAsDescendant |= child->hasRootScrollerAsDescendant() || 694 m_hasRootScrollerAsDescendant |= child->hasRootScrollerAsDescendant() ||
689 (child == 695 (child ==
690 child->layoutObject() 696 child->layoutObject()
691 ->document() 697 .document()
692 .rootScrollerController() 698 .rootScrollerController()
693 .rootScrollerPaintLayer()); 699 .rootScrollerPaintLayer());
694 } 700 }
695 701
696 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 702 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
697 oldHasNonIsolatedDescendantWithBlendMode != 703 oldHasNonIsolatedDescendantWithBlendMode !=
698 static_cast<bool>(m_hasNonIsolatedDescendantWithBlendMode)) 704 static_cast<bool>(m_hasNonIsolatedDescendantWithBlendMode))
699 layoutObject()->setNeedsPaintPropertyUpdate(); 705 layoutObject().setNeedsPaintPropertyUpdate();
700 m_needsDescendantDependentFlagsUpdate = false; 706 m_needsDescendantDependentFlagsUpdate = false;
701 } 707 }
702 708
703 bool previouslyHasVisibleContent = m_hasVisibleContent; 709 bool previouslyHasVisibleContent = m_hasVisibleContent;
704 if (layoutObject()->style()->visibility() == EVisibility::kVisible) { 710 if (layoutObject().style()->visibility() == EVisibility::kVisible) {
705 m_hasVisibleContent = true; 711 m_hasVisibleContent = true;
706 } else { 712 } else {
707 // layer may be hidden but still have some visible content, check for this 713 // layer may be hidden but still have some visible content, check for this
708 m_hasVisibleContent = false; 714 m_hasVisibleContent = false;
709 LayoutObject* r = layoutObject()->slowFirstChild(); 715 LayoutObject* r = layoutObject().slowFirstChild();
710 while (r) { 716 while (r) {
711 if (r->style()->visibility() == EVisibility::kVisible && 717 if (r->style()->visibility() == EVisibility::kVisible &&
712 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 718 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
713 m_hasVisibleContent = true; 719 m_hasVisibleContent = true;
714 break; 720 break;
715 } 721 }
716 LayoutObject* layoutObjectFirstChild = r->slowFirstChild(); 722 LayoutObject* layoutObjectFirstChild = r->slowFirstChild();
717 if (layoutObjectFirstChild && 723 if (layoutObjectFirstChild &&
718 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 724 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
719 r = layoutObjectFirstChild; 725 r = layoutObjectFirstChild;
720 } else if (r->nextSibling()) { 726 } else if (r->nextSibling()) {
721 r = r->nextSibling(); 727 r = r->nextSibling();
722 } else { 728 } else {
723 do { 729 do {
724 r = r->parent(); 730 r = r->parent();
725 if (r == layoutObject()) 731 if (r == &layoutObject())
726 r = 0; 732 r = 0;
727 } while (r && !r->nextSibling()); 733 } while (r && !r->nextSibling());
728 if (r) 734 if (r)
729 r = r->nextSibling(); 735 r = r->nextSibling();
730 } 736 }
731 } 737 }
732 } 738 }
733 739
734 if (hasVisibleContent() != previouslyHasVisibleContent) { 740 if (hasVisibleContent() != previouslyHasVisibleContent) {
735 setNeedsCompositingInputsUpdateInternal(); 741 setNeedsCompositingInputsUpdateInternal();
736 // We need to tell m_layoutObject to recheck its rect because we 742 // We need to tell m_layoutObject to recheck its rect because we
737 // pretend that invisible LayoutObjects have 0x0 rects. Changing 743 // pretend that invisible LayoutObjects have 0x0 rects. Changing
738 // visibility therefore changes our rect and we need to visit 744 // visibility therefore changes our rect and we need to visit
739 // this LayoutObject during the invalidateTreeIfNeeded walk. 745 // this LayoutObject during the invalidateTreeIfNeeded walk.
740 m_layoutObject->setMayNeedPaintInvalidation(); 746 m_layoutObject.setMayNeedPaintInvalidation();
741 } 747 }
742 748
743 update3DTransformedDescendantStatus(); 749 update3DTransformedDescendantStatus();
744 } 750 }
745 751
746 void PaintLayer::update3DTransformedDescendantStatus() { 752 void PaintLayer::update3DTransformedDescendantStatus() {
747 m_has3DTransformedDescendant = false; 753 m_has3DTransformedDescendant = false;
748 754
749 m_stackingNode->updateZOrderLists(); 755 m_stackingNode->updateZOrderLists();
750 756
(...skipping 16 matching lines...) Expand all
767 m_has3DTransformedDescendant = true; 773 m_has3DTransformedDescendant = true;
768 break; 774 break;
769 } 775 }
770 } 776 }
771 } 777 }
772 778
773 void PaintLayer::updateLayerPosition() { 779 void PaintLayer::updateLayerPosition() {
774 LayoutPoint localPoint; 780 LayoutPoint localPoint;
775 781
776 bool didResize = false; 782 bool didResize = false;
777 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 783 if (layoutObject().isInline() && layoutObject().isLayoutInline()) {
778 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 784 LayoutInline& inlineFlow = toLayoutInline(layoutObject());
779 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox()); 785 IntRect lineBox = enclosingIntRect(inlineFlow.linesBoundingBox());
780 m_size = lineBox.size(); 786 m_size = lineBox.size();
781 } else if (LayoutBox* box = layoutBox()) { 787 } else if (LayoutBox* box = layoutBox()) {
782 IntSize newSize = pixelSnappedIntSize(box->size(), box->location()); 788 IntSize newSize = pixelSnappedIntSize(box->size(), box->location());
783 didResize = newSize != m_size; 789 didResize = newSize != m_size;
784 m_size = newSize; 790 m_size = newSize;
785 localPoint.moveBy(box->physicalLocation()); 791 localPoint.moveBy(box->physicalLocation());
786 } 792 }
787 793
788 if (!layoutObject()->isOutOfFlowPositioned() && 794 if (!layoutObject().isOutOfFlowPositioned() &&
789 !layoutObject()->isColumnSpanAll()) { 795 !layoutObject().isColumnSpanAll()) {
790 // We must adjust our position by walking up the layout tree looking for the 796 // We must adjust our position by walking up the layout tree looking for the
791 // nearest enclosing object with a layer. 797 // nearest enclosing object with a layer.
792 LayoutObject* curr = layoutObject()->container(); 798 LayoutObject* curr = layoutObject().container();
793 while (curr && !curr->hasLayer()) { 799 while (curr && !curr->hasLayer()) {
794 if (curr->isBox() && !curr->isTableRow()) { 800 if (curr->isBox() && !curr->isTableRow()) {
795 // Rows and cells share the same coordinate space (that of the section). 801 // Rows and cells share the same coordinate space (that of the section).
796 // Omit them when computing our xpos/ypos. 802 // Omit them when computing our xpos/ypos.
797 localPoint.moveBy(toLayoutBox(curr)->physicalLocation()); 803 localPoint.moveBy(toLayoutBox(curr)->physicalLocation());
798 } 804 }
799 curr = curr->container(); 805 curr = curr->container();
800 } 806 }
801 if (curr && curr->isTableRow()) { 807 if (curr && curr->isTableRow()) {
802 // Put ourselves into the row coordinate space. 808 // Put ourselves into the row coordinate space.
803 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation()); 809 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation());
804 } 810 }
805 } 811 }
806 812
807 if (PaintLayer* containingLayer = this->containingLayer()) { 813 if (PaintLayer* containingLayer = this->containingLayer()) {
808 if (containingLayer->layoutObject()->hasOverflowClip()) { 814 if (containingLayer->layoutObject().hasOverflowClip()) {
809 // Subtract our container's scroll offset. 815 // Subtract our container's scroll offset.
810 IntSize offset = containingLayer->layoutBox()->scrolledContentOffset(); 816 IntSize offset = containingLayer->layoutBox()->scrolledContentOffset();
811 localPoint -= offset; 817 localPoint -= offset;
812 } else if (layoutObject()->isAbsolutePositioned() && 818 } else if (layoutObject().isAbsolutePositioned() &&
813 containingLayer->layoutObject()->isInFlowPositioned() && 819 containingLayer->layoutObject().isInFlowPositioned() &&
814 containingLayer->layoutObject()->isLayoutInline()) { 820 containingLayer->layoutObject().isLayoutInline()) {
815 // Adjust offset for absolute under in-flow positioned inline. 821 // Adjust offset for absolute under in-flow positioned inline.
816 LayoutSize offset = 822 LayoutSize offset =
817 toLayoutInline(containingLayer->layoutObject()) 823 toLayoutInline(containingLayer->layoutObject())
818 ->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 824 .offsetForInFlowPositionedInline(toLayoutBox(layoutObject()));
819 localPoint += offset; 825 localPoint += offset;
820 } 826 }
821 } 827 }
822 828
823 if (layoutObject()->isInFlowPositioned()) { 829 if (layoutObject().isInFlowPositioned()) {
824 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); 830 LayoutSize newOffset = layoutObject().offsetForInFlowPosition();
825 if (m_rareData || !newOffset.isZero()) 831 if (m_rareData || !newOffset.isZero())
826 ensureRareData().offsetForInFlowPosition = newOffset; 832 ensureRareData().offsetForInFlowPosition = newOffset;
827 localPoint.move(newOffset); 833 localPoint.move(newOffset);
828 } else if (m_rareData) { 834 } else if (m_rareData) {
829 m_rareData->offsetForInFlowPosition = LayoutSize(); 835 m_rareData->offsetForInFlowPosition = LayoutSize();
830 } 836 }
831 837
832 m_location = localPoint; 838 m_location = localPoint;
833 839
834 if (m_scrollableArea && didResize) 840 if (m_scrollableArea && didResize)
835 m_scrollableArea->visibleSizeChanged(); 841 m_scrollableArea->visibleSizeChanged();
836 842
837 #if DCHECK_IS_ON() 843 #if DCHECK_IS_ON()
838 m_needsPositionUpdate = false; 844 m_needsPositionUpdate = false;
839 #endif 845 #endif
840 } 846 }
841 847
842 TransformationMatrix PaintLayer::perspectiveTransform() const { 848 TransformationMatrix PaintLayer::perspectiveTransform() const {
843 if (!layoutObject()->hasTransformRelatedProperty()) 849 if (!layoutObject().hasTransformRelatedProperty())
844 return TransformationMatrix(); 850 return TransformationMatrix();
845 851
846 const ComputedStyle& style = layoutObject()->styleRef(); 852 const ComputedStyle& style = layoutObject().styleRef();
847 if (!style.hasPerspective()) 853 if (!style.hasPerspective())
848 return TransformationMatrix(); 854 return TransformationMatrix();
849 855
850 TransformationMatrix t; 856 TransformationMatrix t;
851 t.applyPerspective(style.perspective()); 857 t.applyPerspective(style.perspective());
852 return t; 858 return t;
853 } 859 }
854 860
855 FloatPoint PaintLayer::perspectiveOrigin() const { 861 FloatPoint PaintLayer::perspectiveOrigin() const {
856 if (!layoutObject()->hasTransformRelatedProperty()) 862 if (!layoutObject().hasTransformRelatedProperty())
857 return FloatPoint(); 863 return FloatPoint();
858 864
859 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); 865 const LayoutRect borderBox = toLayoutBox(layoutObject()).borderBoxRect();
860 const ComputedStyle& style = layoutObject()->styleRef(); 866 const ComputedStyle& style = layoutObject().styleRef();
861 867
862 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), 868 return FloatPoint(floatValueForLength(style.perspectiveOriginX(),
863 borderBox.width().toFloat()), 869 borderBox.width().toFloat()),
864 floatValueForLength(style.perspectiveOriginY(), 870 floatValueForLength(style.perspectiveOriginY(),
865 borderBox.height().toFloat())); 871 borderBox.height().toFloat()));
866 } 872 }
867 873
868 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor, 874 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor,
869 bool* skippedAncestor) const { 875 bool* skippedAncestor) const {
870 // If we have specified an ancestor, surely the caller needs to know whether 876 // If we have specified an ancestor, surely the caller needs to know whether
871 // we skipped it. 877 // we skipped it.
872 DCHECK(!ancestor || skippedAncestor); 878 DCHECK(!ancestor || skippedAncestor);
873 if (skippedAncestor) 879 if (skippedAncestor)
874 *skippedAncestor = false; 880 *skippedAncestor = false;
875 881
876 LayoutObject* layoutObject = this->layoutObject(); 882 LayoutObject& layoutObject = this->layoutObject();
877 if (layoutObject->isColumnSpanAll() || 883 if (layoutObject.isColumnSpanAll() ||
878 layoutObject->isFloatingWithNonContainingBlockParent()) { 884 layoutObject.isFloatingWithNonContainingBlockParent()) {
879 Optional<LayoutObject::AncestorSkipInfo> skipInfo; 885 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
880 if (skippedAncestor) 886 if (skippedAncestor)
881 skipInfo.emplace(ancestor->layoutObject()); 887 skipInfo.emplace(&ancestor->layoutObject());
882 if (auto containingBlock = layoutObject->containingBlock( 888 if (auto containingBlock = layoutObject.containingBlock(
883 skippedAncestor ? &*skipInfo : nullptr)) { 889 skippedAncestor ? &*skipInfo : nullptr)) {
884 if (skippedAncestor && skipInfo->ancestorSkipped()) 890 if (skippedAncestor && skipInfo->ancestorSkipped())
885 *skippedAncestor = true; 891 *skippedAncestor = true;
886 return containingBlock->enclosingLayer(); 892 return containingBlock->enclosingLayer();
887 } 893 }
888 return nullptr; 894 return nullptr;
889 } 895 }
890 896
891 if (layoutObject->isOutOfFlowPositioned()) { 897 if (layoutObject.isOutOfFlowPositioned()) {
892 auto canContainThisLayer = 898 auto canContainThisLayer =
893 layoutObject->isFixedPositioned() 899 layoutObject.isFixedPositioned()
894 ? &LayoutObject::canContainFixedPositionObjects 900 ? &LayoutObject::canContainFixedPositionObjects
895 : &LayoutObject::canContainAbsolutePositionObjects; 901 : &LayoutObject::canContainAbsolutePositionObjects;
896 902
897 PaintLayer* curr = parent(); 903 PaintLayer* curr = parent();
898 while (curr && !(curr->layoutObject()->*canContainThisLayer)()) { 904 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) {
899 if (skippedAncestor && curr == ancestor) 905 if (skippedAncestor && curr == ancestor)
900 *skippedAncestor = true; 906 *skippedAncestor = true;
901 curr = curr->parent(); 907 curr = curr->parent();
902 } 908 }
903 return curr; 909 return curr;
904 } 910 }
905 911
906 return parent(); 912 return parent();
907 } 913 }
908 914
909 PaintLayer* PaintLayer::enclosingTransformedAncestor() const { 915 PaintLayer* PaintLayer::enclosingTransformedAncestor() const {
910 PaintLayer* curr = parent(); 916 PaintLayer* curr = parent();
911 while (curr && !curr->isRootLayer() && !curr->transform()) 917 while (curr && !curr->isRootLayer() && !curr->transform())
912 curr = curr->parent(); 918 curr = curr->parent();
913 919
914 return curr; 920 return curr;
915 } 921 }
916 922
917 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const { 923 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const {
918 TransformState transformState(TransformState::ApplyTransformDirection, 924 TransformState transformState(TransformState::ApplyTransformDirection,
919 FloatPoint()); 925 FloatPoint());
920 layoutObject()->mapLocalToAncestor( 926 layoutObject().mapLocalToAncestor(
921 transformAncestor() ? transformAncestor()->layoutObject() : nullptr, 927 transformAncestor() ? &transformAncestor()->layoutObject() : nullptr,
922 transformState, 0); 928 transformState, 0);
923 transformState.flatten(); 929 transformState.flatten();
924 return LayoutPoint(transformState.lastPlanarPoint()); 930 return LayoutPoint(transformState.lastPlanarPoint());
925 } 931 }
926 932
927 PaintLayer* PaintLayer::compositingContainer() const { 933 PaintLayer* PaintLayer::compositingContainer() const {
928 if (!stackingNode()->isStacked()) 934 if (!stackingNode()->isStacked())
929 return isSelfPaintingLayer() ? parent() : containingLayer(); 935 return isSelfPaintingLayer() ? parent() : containingLayer();
930 if (PaintLayerStackingNode* ancestorStackingNode = 936 if (PaintLayerStackingNode* ancestorStackingNode =
931 stackingNode()->ancestorStackingContextNode()) 937 stackingNode()->ancestorStackingContextNode())
(...skipping 29 matching lines...) Expand all
961 967
962 // Return the enclosingCompositedLayerForPaintInvalidation for the given Layer 968 // Return the enclosingCompositedLayerForPaintInvalidation for the given Layer
963 // including crossing frame boundaries. 969 // including crossing frame boundaries.
964 PaintLayer* 970 PaintLayer*
965 PaintLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const { 971 PaintLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const {
966 const PaintLayer* layer = this; 972 const PaintLayer* layer = this;
967 PaintLayer* compositedLayer = 0; 973 PaintLayer* compositedLayer = 0;
968 while (!compositedLayer) { 974 while (!compositedLayer) {
969 compositedLayer = layer->enclosingLayerForPaintInvalidation(); 975 compositedLayer = layer->enclosingLayerForPaintInvalidation();
970 if (!compositedLayer) { 976 if (!compositedLayer) {
971 CHECK(layer->layoutObject()->frame()); 977 CHECK(layer->layoutObject().frame());
972 LayoutItem owner = layer->layoutObject()->frame()->ownerLayoutItem(); 978 LayoutItem owner = layer->layoutObject().frame()->ownerLayoutItem();
973 if (owner.isNull()) 979 if (owner.isNull())
974 break; 980 break;
975 layer = owner.enclosingLayer(); 981 layer = owner.enclosingLayer();
976 } 982 }
977 } 983 }
978 return compositedLayer; 984 return compositedLayer;
979 } 985 }
980 986
981 PaintLayer* PaintLayer::enclosingLayerForPaintInvalidation() const { 987 PaintLayer* PaintLayer::enclosingLayerForPaintInvalidation() const {
982 DCHECK(isAllowedToQueryCompositingState()); 988 DCHECK(isAllowedToQueryCompositingState());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 void PaintLayer::didUpdateCompositingInputs() { 1033 void PaintLayer::didUpdateCompositingInputs() {
1028 DCHECK(!needsCompositingInputsUpdate()); 1034 DCHECK(!needsCompositingInputsUpdate());
1029 m_childNeedsCompositingInputsUpdate = false; 1035 m_childNeedsCompositingInputsUpdate = false;
1030 if (m_scrollableArea) 1036 if (m_scrollableArea)
1031 m_scrollableArea->updateNeedsCompositedScrolling(); 1037 m_scrollableArea->updateNeedsCompositedScrolling();
1032 } 1038 }
1033 1039
1034 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const { 1040 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const {
1035 if (m_hasNonIsolatedDescendantWithBlendMode) 1041 if (m_hasNonIsolatedDescendantWithBlendMode)
1036 return true; 1042 return true;
1037 if (layoutObject()->isSVGRoot()) 1043 if (layoutObject().isSVGRoot())
1038 return toLayoutSVGRoot(layoutObject())->hasNonIsolatedBlendingDescendants(); 1044 return toLayoutSVGRoot(layoutObject()).hasNonIsolatedBlendingDescendants();
1039 return false; 1045 return false;
1040 } 1046 }
1041 1047
1042 void PaintLayer::setCompositingReasons(CompositingReasons reasons, 1048 void PaintLayer::setCompositingReasons(CompositingReasons reasons,
1043 CompositingReasons mask) { 1049 CompositingReasons mask) {
1044 CompositingReasons oldReasons = 1050 CompositingReasons oldReasons =
1045 m_rareData ? m_rareData->compositingReasons : CompositingReasonNone; 1051 m_rareData ? m_rareData->compositingReasons : CompositingReasonNone;
1046 if ((oldReasons & mask) == (reasons & mask)) 1052 if ((oldReasons & mask) == (reasons & mask))
1047 return; 1053 return;
1048 CompositingReasons newReasons = (reasons & mask) | (oldReasons & ~mask); 1054 CompositingReasons newReasons = (reasons & mask) | (oldReasons & ~mask);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1102
1097 static void expandClipRectForDescendants( 1103 static void expandClipRectForDescendants(
1098 LayoutRect& clipRect, 1104 LayoutRect& clipRect,
1099 const PaintLayer* layer, 1105 const PaintLayer* layer,
1100 const PaintLayer* rootLayer, 1106 const PaintLayer* rootLayer,
1101 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior, 1107 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior,
1102 const LayoutSize& subPixelAccumulation, 1108 const LayoutSize& subPixelAccumulation,
1103 GlobalPaintFlags globalPaintFlags) { 1109 GlobalPaintFlags globalPaintFlags) {
1104 // If we have a mask, then the clip is limited to the border box area (and 1110 // If we have a mask, then the clip is limited to the border box area (and
1105 // there is no need to examine child layers). 1111 // there is no need to examine child layers).
1106 if (!layer->layoutObject()->hasMask()) { 1112 if (!layer->layoutObject().hasMask()) {
1107 // Note: we don't have to walk z-order lists since transparent elements 1113 // Note: we don't have to walk z-order lists since transparent elements
1108 // always establish a stacking container. This means we can just walk the 1114 // always establish a stacking container. This means we can just walk the
1109 // layer tree directly. 1115 // layer tree directly.
1110 for (PaintLayer* curr = layer->firstChild(); curr; 1116 for (PaintLayer* curr = layer->firstChild(); curr;
1111 curr = curr->nextSibling()) 1117 curr = curr->nextSibling())
1112 clipRect.unite(PaintLayer::transparencyClipBox( 1118 clipRect.unite(PaintLayer::transparencyClipBox(
1113 curr, rootLayer, transparencyBehavior, 1119 curr, rootLayer, transparencyBehavior,
1114 PaintLayer::DescendantsOfTransparencyClipBox, subPixelAccumulation, 1120 PaintLayer::DescendantsOfTransparencyClipBox, subPixelAccumulation,
1115 globalPaintFlags)); 1121 globalPaintFlags));
1116 } 1122 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 expandClipRectForDescendants(clipRect, layer, layer, transparencyBehavior, 1163 expandClipRectForDescendants(clipRect, layer, layer, transparencyBehavior,
1158 subPixelAccumulation, globalPaintFlags); 1164 subPixelAccumulation, globalPaintFlags);
1159 LayoutRect result = enclosingLayoutRect( 1165 LayoutRect result = enclosingLayoutRect(
1160 transform.mapRect(layer->mapRectForFilter(FloatRect(clipRect)))); 1166 transform.mapRect(layer->mapRectForFilter(FloatRect(clipRect))));
1161 if (!paginationLayer) 1167 if (!paginationLayer)
1162 return result; 1168 return result;
1163 1169
1164 // We have to break up the transformed extent across our columns. 1170 // We have to break up the transformed extent across our columns.
1165 // Split our box up into the actual fragment boxes that layout in the 1171 // Split our box up into the actual fragment boxes that layout in the
1166 // columns/pages and unite those together to get our true bounding box. 1172 // columns/pages and unite those together to get our true bounding box.
1167 LayoutFlowThread* enclosingFlowThread = 1173 LayoutFlowThread& enclosingFlowThread =
1168 toLayoutFlowThread(paginationLayer->layoutObject()); 1174 toLayoutFlowThread(paginationLayer->layoutObject());
1169 result = enclosingFlowThread->fragmentsBoundingBox(result); 1175 result = enclosingFlowThread.fragmentsBoundingBox(result);
1170 1176
1171 LayoutPoint rootLayerDelta; 1177 LayoutPoint rootLayerDelta;
1172 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta); 1178 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
1173 result.moveBy(rootLayerDelta); 1179 result.moveBy(rootLayerDelta);
1174 return result; 1180 return result;
1175 } 1181 }
1176 1182
1177 LayoutRect clipRect = layer->shouldFragmentCompositedBounds(rootLayer) 1183 LayoutRect clipRect = layer->shouldFragmentCompositedBounds(rootLayer)
1178 ? layer->fragmentsBoundingBox(rootLayer) 1184 ? layer->fragmentsBoundingBox(rootLayer)
1179 : layer->physicalBoundingBox(rootLayer); 1185 : layer->physicalBoundingBox(rootLayer);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 1236
1231 child->m_parent = this; 1237 child->m_parent = this;
1232 1238
1233 // The ancestor overflow layer is calculated during compositing inputs update 1239 // The ancestor overflow layer is calculated during compositing inputs update
1234 // and should not be set yet. 1240 // and should not be set yet.
1235 CHECK(!child->ancestorOverflowLayer()); 1241 CHECK(!child->ancestorOverflowLayer());
1236 1242
1237 setNeedsCompositingInputsUpdate(); 1243 setNeedsCompositingInputsUpdate();
1238 1244
1239 if (!child->stackingNode()->isStacked() && 1245 if (!child->stackingNode()->isStacked() &&
1240 !layoutObject()->documentBeingDestroyed()) 1246 !layoutObject().documentBeingDestroyed())
1241 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1247 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1242 1248
1243 if (child->stackingNode()->isStacked() || child->firstChild()) { 1249 if (child->stackingNode()->isStacked() || child->firstChild()) {
1244 // Dirty the z-order list in which we are contained. The 1250 // Dirty the z-order list in which we are contained. The
1245 // ancestorStackingContextNode() can be null in the case where we're 1251 // ancestorStackingContextNode() can be null in the case where we're
1246 // building up generated content layers. This is ok, since the lists will 1252 // building up generated content layers. This is ok, since the lists will
1247 // start off dirty in that case anyway. 1253 // start off dirty in that case anyway.
1248 child->stackingNode()->dirtyStackingContextZOrderLists(); 1254 child->stackingNode()->dirtyStackingContextZOrderLists();
1249 } 1255 }
1250 1256
(...skipping 13 matching lines...) Expand all
1264 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); 1270 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
1265 if (oldChild->nextSibling()) 1271 if (oldChild->nextSibling())
1266 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()); 1272 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
1267 1273
1268 if (m_first == oldChild) 1274 if (m_first == oldChild)
1269 m_first = oldChild->nextSibling(); 1275 m_first = oldChild->nextSibling();
1270 if (m_last == oldChild) 1276 if (m_last == oldChild)
1271 m_last = oldChild->previousSibling(); 1277 m_last = oldChild->previousSibling();
1272 1278
1273 if (!oldChild->stackingNode()->isStacked() && 1279 if (!oldChild->stackingNode()->isStacked() &&
1274 !layoutObject()->documentBeingDestroyed()) 1280 !layoutObject().documentBeingDestroyed())
1275 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1281 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1276 1282
1277 if (oldChild->stackingNode()->isStacked() || oldChild->firstChild()) { 1283 if (oldChild->stackingNode()->isStacked() || oldChild->firstChild()) {
1278 // Dirty the z-order list in which we are contained. When called via the 1284 // Dirty the z-order list in which we are contained. When called via the
1279 // reattachment process in removeOnlyThisLayer, the layer may already be 1285 // reattachment process in removeOnlyThisLayer, the layer may already be
1280 // disconnected from the main layer tree, so we need to null-check the 1286 // disconnected from the main layer tree, so we need to null-check the
1281 // |stackingContext| value. 1287 // |stackingContext| value.
1282 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); 1288 oldChild->stackingNode()->dirtyStackingContextZOrderLists();
1283 } 1289 }
1284 1290
1285 if (layoutObject()->style()->visibility() != EVisibility::kVisible) 1291 if (layoutObject().style()->visibility() != EVisibility::kVisible)
1286 dirtyVisibleContentStatus(); 1292 dirtyVisibleContentStatus();
1287 1293
1288 oldChild->setPreviousSibling(0); 1294 oldChild->setPreviousSibling(0);
1289 oldChild->setNextSibling(0); 1295 oldChild->setNextSibling(0);
1290 oldChild->m_parent = 0; 1296 oldChild->m_parent = 0;
1291 1297
1292 // Remove any ancestor overflow layers which descended into the removed child. 1298 // Remove any ancestor overflow layers which descended into the removed child.
1293 if (oldChild->ancestorOverflowLayer()) 1299 if (oldChild->ancestorOverflowLayer())
1294 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer()); 1300 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer());
1295 1301
(...skipping 16 matching lines...) Expand all
1312 1318
1313 bool didSetPaintInvalidation = false; 1319 bool didSetPaintInvalidation = false;
1314 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1320 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1315 DisableCompositingQueryAsserts 1321 DisableCompositingQueryAsserts
1316 disabler; // We need the current compositing status. 1322 disabler; // We need the current compositing status.
1317 if (isPaintInvalidationContainer()) { 1323 if (isPaintInvalidationContainer()) {
1318 // Our children will be reparented and contained by a new paint 1324 // Our children will be reparented and contained by a new paint
1319 // invalidation container, so need paint invalidation. CompositingUpdate 1325 // invalidation container, so need paint invalidation. CompositingUpdate
1320 // can't see this layer (which has been removed) so won't do this for us. 1326 // can't see this layer (which has been removed) so won't do this for us.
1321 DisablePaintInvalidationStateAsserts disabler; 1327 DisablePaintInvalidationStateAsserts disabler;
1322 ObjectPaintInvalidator(*layoutObject()) 1328 ObjectPaintInvalidator(layoutObject())
1323 .invalidatePaintIncludingNonCompositingDescendants(); 1329 .invalidatePaintIncludingNonCompositingDescendants();
1324 layoutObject() 1330 layoutObject()
1325 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants() ; 1331 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1326 didSetPaintInvalidation = true; 1332 didSetPaintInvalidation = true;
1327 } 1333 }
1328 } 1334 }
1329 1335
1330 if (!didSetPaintInvalidation && isSelfPaintingLayer()) { 1336 if (!didSetPaintInvalidation && isSelfPaintingLayer()) {
1331 if (PaintLayer* enclosingSelfPaintingLayer = 1337 if (PaintLayer* enclosingSelfPaintingLayer =
1332 m_parent->enclosingSelfPaintingLayer()) 1338 m_parent->enclosingSelfPaintingLayer())
1333 enclosingSelfPaintingLayer->mergeNeedsPaintPhaseFlagsFrom(*this); 1339 enclosingSelfPaintingLayer->mergeNeedsPaintPhaseFlagsFrom(*this);
1334 } 1340 }
1335 1341
1336 clipper(PaintLayer::DoNotUseGeometryMapper) 1342 clipper(PaintLayer::DoNotUseGeometryMapper)
1337 .clearClipRectsIncludingDescendants(); 1343 .clearClipRectsIncludingDescendants();
1338 1344
1339 PaintLayer* nextSib = nextSibling(); 1345 PaintLayer* nextSib = nextSibling();
1340 1346
1341 // Now walk our kids and reattach them to our parent. 1347 // Now walk our kids and reattach them to our parent.
1342 PaintLayer* current = m_first; 1348 PaintLayer* current = m_first;
1343 while (current) { 1349 while (current) {
1344 PaintLayer* next = current->nextSibling(); 1350 PaintLayer* next = current->nextSibling();
1345 removeChild(current); 1351 removeChild(current);
1346 m_parent->addChild(current, nextSib); 1352 m_parent->addChild(current, nextSib);
1347 1353
1348 // FIXME: We should call a specialized version of this function. 1354 // FIXME: We should call a specialized version of this function.
1349 current->updateLayerPositionsAfterLayout(); 1355 current->updateLayerPositionsAfterLayout();
1350 current = next; 1356 current = next;
1351 } 1357 }
1352 1358
1353 // Remove us from the parent. 1359 // Remove us from the parent.
1354 m_parent->removeChild(this); 1360 m_parent->removeChild(this);
1355 m_layoutObject->destroyLayer(); 1361 m_layoutObject.destroyLayer();
1356 } 1362 }
1357 1363
1358 void PaintLayer::insertOnlyThisLayerAfterStyleChange() { 1364 void PaintLayer::insertOnlyThisLayerAfterStyleChange() {
1359 if (!m_parent && layoutObject()->parent()) { 1365 if (!m_parent && layoutObject().parent()) {
1360 // We need to connect ourselves when our layoutObject() has a parent. 1366 // We need to connect ourselves when our layoutObject() has a parent.
1361 // Find our enclosingLayer and add ourselves. 1367 // Find our enclosingLayer and add ourselves.
1362 PaintLayer* parentLayer = layoutObject()->parent()->enclosingLayer(); 1368 PaintLayer* parentLayer = layoutObject().parent()->enclosingLayer();
1363 DCHECK(parentLayer); 1369 DCHECK(parentLayer);
1364 PaintLayer* beforeChild = 1370 PaintLayer* beforeChild =
1365 layoutObject()->parent()->findNextLayer(parentLayer, layoutObject()); 1371 layoutObject().parent()->findNextLayer(parentLayer, &layoutObject());
1366 parentLayer->addChild(this, beforeChild); 1372 parentLayer->addChild(this, beforeChild);
1367 } 1373 }
1368 1374
1369 // Remove all descendant layers from the hierarchy and add them to the new 1375 // Remove all descendant layers from the hierarchy and add them to the new
1370 // position. 1376 // position.
1371 for (LayoutObject* curr = layoutObject()->slowFirstChild(); curr; 1377 for (LayoutObject* curr = layoutObject().slowFirstChild(); curr;
1372 curr = curr->nextSibling()) 1378 curr = curr->nextSibling())
1373 curr->moveLayers(m_parent, this); 1379 curr->moveLayers(m_parent, this);
1374 1380
1375 // If the previous paint invalidation container is not a stacking context and 1381 // If the previous paint invalidation container is not a stacking context and
1376 // this object is stacked content, creating this layer may cause this object 1382 // this object is stacked content, creating this layer may cause this object
1377 // and its descendants to change paint invalidation container. 1383 // and its descendants to change paint invalidation container.
1378 bool didSetPaintInvalidation = false; 1384 bool didSetPaintInvalidation = false;
1379 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 1385 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
1380 !layoutObject()->isLayoutView() && layoutObject()->isRooted() && 1386 !layoutObject().isLayoutView() && layoutObject().isRooted() &&
1381 layoutObject()->styleRef().isStacked()) { 1387 layoutObject().styleRef().isStacked()) {
1382 const LayoutBoxModelObject& previousPaintInvalidationContainer = 1388 const LayoutBoxModelObject& previousPaintInvalidationContainer =
1383 layoutObject()->parent()->containerForPaintInvalidation(); 1389 layoutObject().parent()->containerForPaintInvalidation();
1384 if (!previousPaintInvalidationContainer.styleRef().isStackingContext()) { 1390 if (!previousPaintInvalidationContainer.styleRef().isStackingContext()) {
1385 ObjectPaintInvalidator(*layoutObject()) 1391 ObjectPaintInvalidator(layoutObject())
1386 .invalidatePaintIncludingNonSelfPaintingLayerDescendants( 1392 .invalidatePaintIncludingNonSelfPaintingLayerDescendants(
1387 previousPaintInvalidationContainer); 1393 previousPaintInvalidationContainer);
1388 // Set needsRepaint along the original compositingContainer chain. 1394 // Set needsRepaint along the original compositingContainer chain.
1389 layoutObject()->parent()->enclosingLayer()->setNeedsRepaint(); 1395 layoutObject().parent()->enclosingLayer()->setNeedsRepaint();
1390 didSetPaintInvalidation = true; 1396 didSetPaintInvalidation = true;
1391 } 1397 }
1392 } 1398 }
1393 1399
1394 if (!didSetPaintInvalidation && isSelfPaintingLayer() && m_parent) { 1400 if (!didSetPaintInvalidation && isSelfPaintingLayer() && m_parent) {
1395 if (PaintLayer* enclosingSelfPaintingLayer = 1401 if (PaintLayer* enclosingSelfPaintingLayer =
1396 m_parent->enclosingSelfPaintingLayer()) 1402 m_parent->enclosingSelfPaintingLayer())
1397 mergeNeedsPaintPhaseFlagsFrom(*enclosingSelfPaintingLayer); 1403 mergeNeedsPaintPhaseFlagsFrom(*enclosingSelfPaintingLayer);
1398 } 1404 }
1399 1405
1400 // Clear out all the clip rects. 1406 // Clear out all the clip rects.
1401 clipper(PaintLayer::DoNotUseGeometryMapper) 1407 clipper(PaintLayer::DoNotUseGeometryMapper)
1402 .clearClipRectsIncludingDescendants(); 1408 .clearClipRectsIncludingDescendants();
1403 } 1409 }
1404 1410
1405 // Returns the layer reached on the walk up towards the ancestor. 1411 // Returns the layer reached on the walk up towards the ancestor.
1406 static inline const PaintLayer* accumulateOffsetTowardsAncestor( 1412 static inline const PaintLayer* accumulateOffsetTowardsAncestor(
1407 const PaintLayer* layer, 1413 const PaintLayer* layer,
1408 const PaintLayer* ancestorLayer, 1414 const PaintLayer* ancestorLayer,
1409 LayoutPoint& location) { 1415 LayoutPoint& location) {
1410 DCHECK(ancestorLayer != layer); 1416 DCHECK(ancestorLayer != layer);
1411 1417
1412 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); 1418 const LayoutBoxModelObject& layoutObject = layer->layoutObject();
1413 1419
1414 if (layoutObject->isFixedPositioned() && 1420 if (layoutObject.isFixedPositioned() &&
1415 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) { 1421 (!ancestorLayer || ancestorLayer == layoutObject.view()->layer())) {
1416 // If the fixed layer's container is the root, just add in the offset of the 1422 // If the fixed layer's container is the root, just add in the offset of the
1417 // view. We can obtain this by calling localToAbsolute() on the LayoutView. 1423 // view. We can obtain this by calling localToAbsolute() on the LayoutView.
1418 FloatPoint absPos = layoutObject->localToAbsolute(); 1424 FloatPoint absPos = layoutObject.localToAbsolute();
1419 location += LayoutSize(absPos.x(), absPos.y()); 1425 location += LayoutSize(absPos.x(), absPos.y());
1420 return ancestorLayer; 1426 return ancestorLayer;
1421 } 1427 }
1422 1428
1423 bool foundAncestorFirst; 1429 bool foundAncestorFirst;
1424 PaintLayer* containingLayer = 1430 PaintLayer* containingLayer =
1425 layer->containingLayer(ancestorLayer, &foundAncestorFirst); 1431 layer->containingLayer(ancestorLayer, &foundAncestorFirst);
1426 1432
1427 if (foundAncestorFirst) { 1433 if (foundAncestorFirst) {
1428 // Found ancestorLayer before the containing layer, so compute offset of 1434 // Found ancestorLayer before the containing layer, so compute offset of
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 if (ancestorLayer == this) 1474 if (ancestorLayer == this)
1469 return offset; 1475 return offset;
1470 PaintLayer* paginationLayer = enclosingPaginationLayer(); 1476 PaintLayer* paginationLayer = enclosingPaginationLayer();
1471 if (paginationLayer == this) 1477 if (paginationLayer == this)
1472 paginationLayer = parent()->enclosingPaginationLayer(); 1478 paginationLayer = parent()->enclosingPaginationLayer();
1473 if (!paginationLayer) { 1479 if (!paginationLayer) {
1474 convertToLayerCoords(ancestorLayer, offset); 1480 convertToLayerCoords(ancestorLayer, offset);
1475 return offset; 1481 return offset;
1476 } 1482 }
1477 1483
1478 LayoutFlowThread* flowThread = 1484 LayoutFlowThread& flowThread =
1479 toLayoutFlowThread(paginationLayer->layoutObject()); 1485 toLayoutFlowThread(paginationLayer->layoutObject());
1480 convertToLayerCoords(paginationLayer, offset); 1486 convertToLayerCoords(paginationLayer, offset);
1481 offset = flowThread->flowThreadPointToVisualPoint(offset); 1487 offset = flowThread.flowThreadPointToVisualPoint(offset);
1482 if (ancestorLayer == paginationLayer) 1488 if (ancestorLayer == paginationLayer)
1483 return offset; 1489 return offset;
1484 1490
1485 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) { 1491 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) {
1486 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); 1492 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer));
1487 } else { 1493 } else {
1488 // The ancestor layer is also inside the pagination layer, so we need to 1494 // The ancestor layer is also inside the pagination layer, so we need to
1489 // subtract the visual distance from the ancestor layer to the pagination 1495 // subtract the visual distance from the ancestor layer to the pagination
1490 // layer. 1496 // layer.
1491 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); 1497 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer));
(...skipping 15 matching lines...) Expand all
1507 1513
1508 void PaintLayer::updateScrollableArea() { 1514 void PaintLayer::updateScrollableArea() {
1509 DCHECK(!m_scrollableArea); 1515 DCHECK(!m_scrollableArea);
1510 if (requiresScrollableArea()) 1516 if (requiresScrollableArea())
1511 m_scrollableArea = PaintLayerScrollableArea::create(*this); 1517 m_scrollableArea = PaintLayerScrollableArea::create(*this);
1512 } 1518 }
1513 1519
1514 bool PaintLayer::hasOverflowControls() const { 1520 bool PaintLayer::hasOverflowControls() const {
1515 return m_scrollableArea && (m_scrollableArea->hasScrollbar() || 1521 return m_scrollableArea && (m_scrollableArea->hasScrollbar() ||
1516 m_scrollableArea->scrollCorner() || 1522 m_scrollableArea->scrollCorner() ||
1517 layoutObject()->style()->resize() != RESIZE_NONE); 1523 layoutObject().style()->resize() != RESIZE_NONE);
1518 } 1524 }
1519 1525
1520 void PaintLayer::appendSingleFragmentIgnoringPagination( 1526 void PaintLayer::appendSingleFragmentIgnoringPagination(
1521 PaintLayerFragments& fragments, 1527 PaintLayerFragments& fragments,
1522 const PaintLayer* rootLayer, 1528 const PaintLayer* rootLayer,
1523 const LayoutRect& dirtyRect, 1529 const LayoutRect& dirtyRect,
1524 ClipRectsCacheSlot clipRectsCacheSlot, 1530 ClipRectsCacheSlot clipRectsCacheSlot,
1525 PaintLayer::GeometryMapperOption geometryMapperOption, 1531 PaintLayer::GeometryMapperOption geometryMapperOption,
1526 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior, 1532 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior,
1527 ShouldRespectOverflowClipType respectOverflowClip, 1533 ShouldRespectOverflowClipType respectOverflowClip,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 LayoutRect(LayoutRect::infiniteIntRect()), 1596 LayoutRect(LayoutRect::infiniteIntRect()),
1591 layerBoundsInFlowThread, backgroundRectInFlowThread, 1597 layerBoundsInFlowThread, backgroundRectInFlowThread,
1592 foregroundRectInFlowThread, &offsetWithinPaginatedLayer); 1598 foregroundRectInFlowThread, &offsetWithinPaginatedLayer);
1593 1599
1594 // Take our bounding box within the flow thread and clip it. 1600 // Take our bounding box within the flow thread and clip it.
1595 LayoutRect layerBoundingBoxInFlowThread = 1601 LayoutRect layerBoundingBoxInFlowThread =
1596 layerBoundingBox ? *layerBoundingBox 1602 layerBoundingBox ? *layerBoundingBox
1597 : physicalBoundingBox(offsetWithinPaginatedLayer); 1603 : physicalBoundingBox(offsetWithinPaginatedLayer);
1598 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); 1604 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect());
1599 1605
1600 LayoutFlowThread* enclosingFlowThread = 1606 LayoutFlowThread& enclosingFlowThread =
1601 toLayoutFlowThread(enclosingPaginationLayer()->layoutObject()); 1607 toLayoutFlowThread(enclosingPaginationLayer()->layoutObject());
1602 // Visual offset from the root layer to the nearest fragmentation context. 1608 // Visual offset from the root layer to the nearest fragmentation context.
1603 LayoutPoint offsetOfPaginationLayerFromRoot; 1609 LayoutPoint offsetOfPaginationLayerFromRoot;
1604 bool rootLayerIsInsidePaginationLayer = 1610 bool rootLayerIsInsidePaginationLayer =
1605 rootLayer->enclosingPaginationLayer() == enclosingPaginationLayer(); 1611 rootLayer->enclosingPaginationLayer() == enclosingPaginationLayer();
1606 if (rootLayerIsInsidePaginationLayer) { 1612 if (rootLayerIsInsidePaginationLayer) {
1607 // The root layer is in the same fragmentation context as this layer, so we 1613 // The root layer is in the same fragmentation context as this layer, so we
1608 // need to look inside it and subtract the offset between the fragmentation 1614 // need to look inside it and subtract the offset between the fragmentation
1609 // context and the root layer. 1615 // context and the root layer.
1610 offsetOfPaginationLayerFromRoot = 1616 offsetOfPaginationLayerFromRoot =
1611 -rootLayer->visualOffsetFromAncestor(enclosingPaginationLayer()); 1617 -rootLayer->visualOffsetFromAncestor(enclosingPaginationLayer());
1612 } else { 1618 } else {
1613 offsetOfPaginationLayerFromRoot = 1619 offsetOfPaginationLayerFromRoot =
1614 enclosingPaginationLayer()->visualOffsetFromAncestor(rootLayer); 1620 enclosingPaginationLayer()->visualOffsetFromAncestor(rootLayer);
1615 } 1621 }
1616 // Make the dirty rect relative to the fragmentation context (multicol 1622 // Make the dirty rect relative to the fragmentation context (multicol
1617 // container, etc.). 1623 // container, etc.).
1618 LayoutRect dirtyRectInMulticolContainer(dirtyRect); 1624 LayoutRect dirtyRectInMulticolContainer(dirtyRect);
1619 dirtyRectInMulticolContainer.move(enclosingFlowThread->physicalLocation() - 1625 dirtyRectInMulticolContainer.move(enclosingFlowThread.physicalLocation() -
1620 offsetOfPaginationLayerFromRoot); 1626 offsetOfPaginationLayerFromRoot);
1621 1627
1622 // Slice the layer into fragments. Each fragment needs to be processed (e.g. 1628 // Slice the layer into fragments. Each fragment needs to be processed (e.g.
1623 // painted) separately. We pass enough information to walk a minimal number of 1629 // painted) separately. We pass enough information to walk a minimal number of
1624 // fragments based on the pages/columns that intersect the actual dirtyRect as 1630 // fragments based on the pages/columns that intersect the actual dirtyRect as
1625 // well as the pages/columns that intersect our layer's bounding box. 1631 // well as the pages/columns that intersect our layer's bounding box.
1626 FragmentainerIterator iterator(*enclosingFlowThread, 1632 FragmentainerIterator iterator(enclosingFlowThread,
1627 layerBoundingBoxInFlowThread, 1633 layerBoundingBoxInFlowThread,
1628 dirtyRectInMulticolContainer); 1634 dirtyRectInMulticolContainer);
1629 if (iterator.atEnd()) 1635 if (iterator.atEnd())
1630 return; 1636 return;
1631 1637
1632 // Get the parent clip rects of the pagination layer, since we need to 1638 // Get the parent clip rects of the pagination layer, since we need to
1633 // intersect with that when painting column contents. 1639 // intersect with that when painting column contents.
1634 ClipRect ancestorClipRect = dirtyRect; 1640 ClipRect ancestorClipRect = dirtyRect;
1635 if (const PaintLayer* paginationParentLayer = 1641 if (const PaintLayer* paginationParentLayer =
1636 enclosingPaginationLayer()->parent()) { 1642 enclosingPaginationLayer()->parent()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 fragment.intersect(fragment.paginationClip); 1683 fragment.intersect(fragment.paginationClip);
1678 1684
1679 // TODO(mstensho): Don't add empty fragments. We've always done that in some 1685 // TODO(mstensho): Don't add empty fragments. We've always done that in some
1680 // cases, but there should be no reason to do so. Either filter them out 1686 // cases, but there should be no reason to do so. Either filter them out
1681 // here, or, even better: pass a better clip rectangle to the fragmentainer 1687 // here, or, even better: pass a better clip rectangle to the fragmentainer
1682 // iterator, so that we won't end up with empty fragments here. 1688 // iterator, so that we won't end up with empty fragments here.
1683 fragments.push_back(fragment); 1689 fragments.push_back(fragment);
1684 } 1690 }
1685 } 1691 }
1686 1692
1687 static inline LayoutRect frameVisibleRect(LayoutObject* layoutObject) { 1693 static inline LayoutRect frameVisibleRect(LayoutObject& layoutObject) {
1688 FrameView* frameView = layoutObject->document().view(); 1694 FrameView* frameView = layoutObject.document().view();
1689 if (!frameView) 1695 if (!frameView)
1690 return LayoutRect(); 1696 return LayoutRect();
1691 1697
1692 return LayoutRect(frameView->visibleContentRect()); 1698 return LayoutRect(frameView->visibleContentRect());
1693 } 1699 }
1694 1700
1695 bool PaintLayer::hitTest(HitTestResult& result) { 1701 bool PaintLayer::hitTest(HitTestResult& result) {
1696 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 1702 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
1697 1703
1698 // LayoutView should make sure to update layout before entering hit testing 1704 // LayoutView should make sure to update layout before entering hit testing
1699 DCHECK(!layoutObject()->frame()->view()->layoutPending()); 1705 DCHECK(!layoutObject().frame()->view()->layoutPending());
1700 DCHECK(!layoutObject()->document().layoutViewItem().needsLayout()); 1706 DCHECK(!layoutObject().document().layoutViewItem().needsLayout());
1701 1707
1702 const HitTestRequest& request = result.hitTestRequest(); 1708 const HitTestRequest& request = result.hitTestRequest();
1703 const HitTestLocation& hitTestLocation = result.hitTestLocation(); 1709 const HitTestLocation& hitTestLocation = result.hitTestLocation();
1704 1710
1705 // Start with frameVisibleRect to ensure we include the scrollbars. 1711 // Start with frameVisibleRect to ensure we include the scrollbars.
1706 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 1712 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
1707 if (request.ignoreClipping()) 1713 if (request.ignoreClipping())
1708 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 1714 hitTestArea.unite(LayoutRect(layoutObject().view()->documentRect()));
1709 1715
1710 PaintLayer* insideLayer = 1716 PaintLayer* insideLayer =
1711 hitTestLayer(this, 0, result, hitTestArea, hitTestLocation, false); 1717 hitTestLayer(this, 0, result, hitTestArea, hitTestLocation, false);
1712 if (!insideLayer && isRootLayer()) { 1718 if (!insideLayer && isRootLayer()) {
1713 IntRect hitRect = hitTestLocation.boundingBox(); 1719 IntRect hitRect = hitTestLocation.boundingBox();
1714 bool fallback = false; 1720 bool fallback = false;
1715 // If we didn't hit any layers but are still inside the document 1721 // If we didn't hit any layers but are still inside the document
1716 // bounds, then we should fallback to hitting the document. 1722 // bounds, then we should fallback to hitting the document.
1717 // For rect-based hit test, we do the fallback only when the hit-rect 1723 // For rect-based hit test, we do the fallback only when the hit-rect
1718 // is totally within the document bounds. 1724 // is totally within the document bounds.
1719 if (hitTestArea.contains(LayoutRect(hitRect))) { 1725 if (hitTestArea.contains(LayoutRect(hitRect))) {
1720 fallback = true; 1726 fallback = true;
1721 1727
1722 // Mouse dragging outside the main document should also be 1728 // Mouse dragging outside the main document should also be
1723 // delivered to the document. 1729 // delivered to the document.
1724 // TODO(miletus): Capture behavior inconsistent with iframes 1730 // TODO(miletus): Capture behavior inconsistent with iframes
1725 // crbug.com/522109. 1731 // crbug.com/522109.
1726 // TODO(majidvp): This should apply more consistently across different 1732 // TODO(majidvp): This should apply more consistently across different
1727 // event types and we should not use RequestType for it. Perhaps best for 1733 // event types and we should not use RequestType for it. Perhaps best for
1728 // it to be done at a higher level. See http://crbug.com/505825 1734 // it to be done at a higher level. See http://crbug.com/505825
1729 } else if ((request.active() || request.release()) && 1735 } else if ((request.active() || request.release()) &&
1730 !request.isChildFrameHitTest()) { 1736 !request.isChildFrameHitTest()) {
1731 fallback = true; 1737 fallback = true;
1732 } 1738 }
1733 if (fallback) { 1739 if (fallback) {
1734 layoutObject()->updateHitTestResult( 1740 layoutObject().updateHitTestResult(
1735 result, toLayoutView(layoutObject()) 1741 result, toLayoutView(layoutObject())
1736 ->flipForWritingMode(hitTestLocation.point())); 1742 .flipForWritingMode(hitTestLocation.point()));
1737 insideLayer = this; 1743 insideLayer = this;
1738 1744
1739 // Don't cache this result since it really wasn't a true hit. 1745 // Don't cache this result since it really wasn't a true hit.
1740 result.setCacheable(false); 1746 result.setCacheable(false);
1741 } 1747 }
1742 } 1748 }
1743 1749
1744 // Now determine if the result is inside an anchor - if the urlElement isn't 1750 // Now determine if the result is inside an anchor - if the urlElement isn't
1745 // already set. 1751 // already set.
1746 Node* node = result.innerNode(); 1752 Node* node = result.innerNode();
1747 if (node && !result.URLElement()) 1753 if (node && !result.URLElement())
1748 result.setURLElement(node->enclosingLinkEventParentOrSelf()); 1754 result.setURLElement(node->enclosingLinkEventParentOrSelf());
1749 1755
1750 // Now return whether we were inside this layer (this will always be true for 1756 // Now return whether we were inside this layer (this will always be true for
1751 // the root layer). 1757 // the root layer).
1752 return insideLayer; 1758 return insideLayer;
1753 } 1759 }
1754 1760
1755 Node* PaintLayer::enclosingNode() const { 1761 Node* PaintLayer::enclosingNode() const {
1756 for (LayoutObject* r = layoutObject(); r; r = r->parent()) { 1762 for (LayoutObject* r = &layoutObject(); r; r = r->parent()) {
1757 if (Node* e = r->node()) 1763 if (Node* e = r->node())
1758 return e; 1764 return e;
1759 } 1765 }
1760 ASSERT_NOT_REACHED(); 1766 ASSERT_NOT_REACHED();
1761 return 0; 1767 return 0;
1762 } 1768 }
1763 1769
1764 bool PaintLayer::isInTopLayer() const { 1770 bool PaintLayer::isInTopLayer() const {
1765 Node* node = layoutObject()->node(); 1771 Node* node = layoutObject().node();
1766 return node && node->isElementNode() && toElement(node)->isInTopLayer(); 1772 return node && node->isElementNode() && toElement(node)->isInTopLayer();
1767 } 1773 }
1768 1774
1769 // Compute the z-offset of the point in the transformState. 1775 // Compute the z-offset of the point in the transformState.
1770 // This is effectively projecting a ray normal to the plane of ancestor, finding 1776 // This is effectively projecting a ray normal to the plane of ancestor, finding
1771 // where that ray intersects target, and computing the z delta between those two 1777 // where that ray intersects target, and computing the z delta between those two
1772 // points. 1778 // points.
1773 static double computeZOffset(const HitTestingTransformState& transformState) { 1779 static double computeZOffset(const HitTestingTransformState& transformState) {
1774 // We got an affine transform, so no z-offset 1780 // We got an affine transform, so no z-offset
1775 if (transformState.m_accumulatedTransform.isAffine()) 1781 if (transformState.m_accumulatedTransform.isAffine())
(...skipping 26 matching lines...) Expand all
1802 // If this is the first time we need to make transform state, then base it 1808 // If this is the first time we need to make transform state, then base it
1803 // off of hitTestLocation, which is relative to rootLayer. 1809 // off of hitTestLocation, which is relative to rootLayer.
1804 transformState = HitTestingTransformState::create( 1810 transformState = HitTestingTransformState::create(
1805 hitTestLocation.transformedPoint(), hitTestLocation.transformedRect(), 1811 hitTestLocation.transformedPoint(), hitTestLocation.transformedRect(),
1806 FloatQuad(FloatRect(hitTestRect))); 1812 FloatQuad(FloatRect(hitTestRect)));
1807 convertToLayerCoords(rootLayer, offset); 1813 convertToLayerCoords(rootLayer, offset);
1808 } 1814 }
1809 offset.moveBy(translationOffset); 1815 offset.moveBy(translationOffset);
1810 1816
1811 LayoutObject* containerLayoutObject = 1817 LayoutObject* containerLayoutObject =
1812 containerLayer ? containerLayer->layoutObject() : 0; 1818 containerLayer ? &containerLayer->layoutObject() : 0;
1813 if (layoutObject()->shouldUseTransformFromContainer(containerLayoutObject)) { 1819 if (layoutObject().shouldUseTransformFromContainer(containerLayoutObject)) {
1814 TransformationMatrix containerTransform; 1820 TransformationMatrix containerTransform;
1815 layoutObject()->getTransformFromContainer( 1821 layoutObject().getTransformFromContainer(
1816 containerLayoutObject, toLayoutSize(offset), containerTransform); 1822 containerLayoutObject, toLayoutSize(offset), containerTransform);
1817 transformState->applyTransform( 1823 transformState->applyTransform(
1818 containerTransform, HitTestingTransformState::AccumulateTransform); 1824 containerTransform, HitTestingTransformState::AccumulateTransform);
1819 } else { 1825 } else {
1820 transformState->translate(offset.x().toInt(), offset.y().toInt(), 1826 transformState->translate(offset.x().toInt(), offset.y().toInt(),
1821 HitTestingTransformState::AccumulateTransform); 1827 HitTestingTransformState::AccumulateTransform);
1822 } 1828 }
1823 1829
1824 return transformState; 1830 return transformState;
1825 } 1831 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 // the containing flattening layer. 1872 // the containing flattening layer.
1867 PaintLayer* PaintLayer::hitTestLayer( 1873 PaintLayer* PaintLayer::hitTestLayer(
1868 PaintLayer* rootLayer, 1874 PaintLayer* rootLayer,
1869 PaintLayer* containerLayer, 1875 PaintLayer* containerLayer,
1870 HitTestResult& result, 1876 HitTestResult& result,
1871 const LayoutRect& hitTestRect, 1877 const LayoutRect& hitTestRect,
1872 const HitTestLocation& hitTestLocation, 1878 const HitTestLocation& hitTestLocation,
1873 bool appliedTransform, 1879 bool appliedTransform,
1874 const HitTestingTransformState* transformState, 1880 const HitTestingTransformState* transformState,
1875 double* zOffset) { 1881 double* zOffset) {
1876 DCHECK(layoutObject()->document().lifecycle().state() >= 1882 DCHECK(layoutObject().document().lifecycle().state() >=
1877 DocumentLifecycle::CompositingClean); 1883 DocumentLifecycle::CompositingClean);
1878 1884
1879 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 1885 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
1880 return nullptr; 1886 return nullptr;
1881 1887
1882 ClipRectsCacheSlot clipRectsCacheSlot = 1888 ClipRectsCacheSlot clipRectsCacheSlot =
1883 result.hitTestRequest().ignoreClipping() 1889 result.hitTestRequest().ignoreClipping()
1884 ? RootRelativeClipRectsIgnoringViewportClip 1890 ? RootRelativeClipRectsIgnoringViewportClip
1885 : RootRelativeClipRects; 1891 : RootRelativeClipRects;
1886 1892
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 } else if (transformState || m_has3DTransformedDescendant || preserves3D()) { 1927 } else if (transformState || m_has3DTransformedDescendant || preserves3D()) {
1922 // We need transform state for the first time, or to offset the container 1928 // We need transform state for the first time, or to offset the container
1923 // state, so create it here. 1929 // state, so create it here.
1924 localTransformState = 1930 localTransformState =
1925 createLocalTransformState(rootLayer, containerLayer, hitTestRect, 1931 createLocalTransformState(rootLayer, containerLayer, hitTestRect,
1926 hitTestLocation, transformState); 1932 hitTestLocation, transformState);
1927 } 1933 }
1928 1934
1929 // Check for hit test on backface if backface-visibility is 'hidden' 1935 // Check for hit test on backface if backface-visibility is 'hidden'
1930 if (localTransformState && 1936 if (localTransformState &&
1931 layoutObject()->style()->backfaceVisibility() == 1937 layoutObject().style()->backfaceVisibility() ==
1932 BackfaceVisibilityHidden) { 1938 BackfaceVisibilityHidden) {
1933 TransformationMatrix invertedMatrix = 1939 TransformationMatrix invertedMatrix =
1934 localTransformState->m_accumulatedTransform.inverse(); 1940 localTransformState->m_accumulatedTransform.inverse();
1935 // If the z-vector of the matrix is negative, the back is facing towards the 1941 // If the z-vector of the matrix is negative, the back is facing towards the
1936 // viewer. 1942 // viewer.
1937 if (invertedMatrix.m33() < 0) 1943 if (invertedMatrix.m33() < 0)
1938 return nullptr; 1944 return nullptr;
1939 } 1945 }
1940 1946
1941 RefPtr<HitTestingTransformState> unflattenedTransformState = 1947 RefPtr<HitTestingTransformState> unflattenedTransformState =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 PaintLayer::DoNotUseGeometryMapper, 2009 PaintLayer::DoNotUseGeometryMapper,
2004 ExcludeOverlayScrollbarSizeForHitTesting); 2010 ExcludeOverlayScrollbarSizeForHitTesting);
2005 else 2011 else
2006 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheSlot, 2012 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheSlot,
2007 PaintLayer::DoNotUseGeometryMapper, 2013 PaintLayer::DoNotUseGeometryMapper,
2008 ExcludeOverlayScrollbarSizeForHitTesting); 2014 ExcludeOverlayScrollbarSizeForHitTesting);
2009 2015
2010 if (m_scrollableArea && 2016 if (m_scrollableArea &&
2011 m_scrollableArea->hitTestResizerInFragments(layerFragments, 2017 m_scrollableArea->hitTestResizerInFragments(layerFragments,
2012 hitTestLocation)) { 2018 hitTestLocation)) {
2013 layoutObject()->updateHitTestResult(result, hitTestLocation.point()); 2019 layoutObject().updateHitTestResult(result, hitTestLocation.point());
2014 return this; 2020 return this;
2015 } 2021 }
2016 2022
2017 // Next we want to see if the mouse pos is inside the child LayoutObjects of 2023 // Next we want to see if the mouse pos is inside the child LayoutObjects of
2018 // the layer. Check every fragment in reverse order. 2024 // the layer. Check every fragment in reverse order.
2019 if (isSelfPaintingLayer()) { 2025 if (isSelfPaintingLayer()) {
2020 // Hit test with a temporary HitTestResult, because we only want to commit 2026 // Hit test with a temporary HitTestResult, because we only want to commit
2021 // to 'result' if we know we're frontmost. 2027 // to 'result' if we know we're frontmost.
2022 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); 2028 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
2023 bool insideFragmentForegroundRect = false; 2029 bool insideFragmentForegroundRect = false;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 newHitTestLocation, true, newTransformState.get(), 2205 newHitTestLocation, true, newTransformState.get(),
2200 zOffset); 2206 zOffset);
2201 } 2207 }
2202 2208
2203 bool PaintLayer::hitTestContents(HitTestResult& result, 2209 bool PaintLayer::hitTestContents(HitTestResult& result,
2204 const LayoutRect& layerBounds, 2210 const LayoutRect& layerBounds,
2205 const HitTestLocation& hitTestLocation, 2211 const HitTestLocation& hitTestLocation,
2206 HitTestFilter hitTestFilter) const { 2212 HitTestFilter hitTestFilter) const {
2207 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 2213 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
2208 2214
2209 if (!layoutObject()->hitTest( 2215 if (!layoutObject().hitTest(
2210 result, hitTestLocation, 2216 result, hitTestLocation,
2211 toLayoutPoint(layerBounds.location() - layoutBoxLocation()), 2217 toLayoutPoint(layerBounds.location() - layoutBoxLocation()),
2212 hitTestFilter)) { 2218 hitTestFilter)) {
2213 // It's wrong to set innerNode, but then claim that you didn't hit anything, 2219 // It's wrong to set innerNode, but then claim that you didn't hit anything,
2214 // unless it is a rect-based test. 2220 // unless it is a rect-based test.
2215 DCHECK(!result.innerNode() || (result.hitTestRequest().listBased() && 2221 DCHECK(!result.innerNode() || (result.hitTestRequest().listBased() &&
2216 result.listBasedTestResult().size())); 2222 result.listBasedTestResult().size()));
2217 return false; 2223 return false;
2218 } 2224 }
2219 2225
2220 if (!result.innerNode()) { 2226 if (!result.innerNode()) {
2221 // We hit something anonymous, and we didn't find a DOM node ancestor in 2227 // We hit something anonymous, and we didn't find a DOM node ancestor in
2222 // this layer. 2228 // this layer.
2223 2229
2224 if (layoutObject()->isLayoutFlowThread()) { 2230 if (layoutObject().isLayoutFlowThread()) {
2225 // For a flow thread it's safe to just say that we didn't hit anything. 2231 // For a flow thread it's safe to just say that we didn't hit anything.
2226 // That means that we'll continue as normally, and eventually hit a column 2232 // That means that we'll continue as normally, and eventually hit a column
2227 // set sibling instead. Column sets are also anonymous, but, unlike flow 2233 // set sibling instead. Column sets are also anonymous, but, unlike flow
2228 // threads, they don't establish layers, so we'll fall back and hit the 2234 // threads, they don't establish layers, so we'll fall back and hit the
2229 // multicol container parent (which should have a DOM node). 2235 // multicol container parent (which should have a DOM node).
2230 return false; 2236 return false;
2231 } 2237 }
2232 2238
2233 Node* e = enclosingNode(); 2239 Node* e = enclosingNode();
2234 // FIXME: should be a call to result.setNodeAndPosition. What we would 2240 // FIXME: should be a call to result.setNodeAndPosition. What we would
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 return resultLayer; 2293 return resultLayer;
2288 } 2294 }
2289 2295
2290 FloatRect PaintLayer::boxForFilterOrMask() const { 2296 FloatRect PaintLayer::boxForFilterOrMask() const {
2291 return FloatRect(physicalBoundingBoxIncludingStackingChildren( 2297 return FloatRect(physicalBoundingBoxIncludingStackingChildren(
2292 LayoutPoint(), PaintLayer::CalculateBoundsOptions:: 2298 LayoutPoint(), PaintLayer::CalculateBoundsOptions::
2293 IncludeTransformsAndCompositedChildLayers)); 2299 IncludeTransformsAndCompositedChildLayers));
2294 } 2300 }
2295 2301
2296 LayoutRect PaintLayer::boxForClipPath() const { 2302 LayoutRect PaintLayer::boxForClipPath() const {
2297 if (!layoutObject()->isBox()) { 2303 if (!layoutObject().isBox()) {
2298 SECURITY_DCHECK(layoutObject()->isLayoutInline()); 2304 SECURITY_DCHECK(layoutObject().isLayoutInline());
2299 const LayoutInline& layoutInline = toLayoutInline(*layoutObject()); 2305 const LayoutInline& layoutInline = toLayoutInline(layoutObject());
2300 // This somewhat convoluted computation matches what Gecko does. 2306 // This somewhat convoluted computation matches what Gecko does.
2301 // See crbug.com/641907. 2307 // See crbug.com/641907.
2302 LayoutRect inlineBBox = layoutInline.linesBoundingBox(); 2308 LayoutRect inlineBBox = layoutInline.linesBoundingBox();
2303 const InlineFlowBox* flowBox = layoutInline.firstLineBox(); 2309 const InlineFlowBox* flowBox = layoutInline.firstLineBox();
2304 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height() 2310 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height()
2305 : LayoutUnit(0)); 2311 : LayoutUnit(0));
2306 return inlineBBox; 2312 return inlineBBox;
2307 } 2313 }
2308 return toLayoutBox(layoutObject())->borderBoxRect(); 2314 return toLayoutBox(layoutObject()).borderBoxRect();
2309 } 2315 }
2310 2316
2311 bool PaintLayer::hitTestClippedOutByClipPath( 2317 bool PaintLayer::hitTestClippedOutByClipPath(
2312 PaintLayer* rootLayer, 2318 PaintLayer* rootLayer,
2313 const HitTestLocation& hitTestLocation) const { 2319 const HitTestLocation& hitTestLocation) const {
2314 if (!layoutObject()->hasClipPath()) 2320 if (!layoutObject().hasClipPath())
2315 return false; 2321 return false;
2316 DCHECK(isSelfPaintingLayer()); 2322 DCHECK(isSelfPaintingLayer());
2317 DCHECK(rootLayer); 2323 DCHECK(rootLayer);
2318 2324
2319 LayoutRect referenceBox(boxForClipPath()); 2325 LayoutRect referenceBox(boxForClipPath());
2320 if (enclosingPaginationLayer()) 2326 if (enclosingPaginationLayer())
2321 convertFromFlowThreadToVisualBoundingBoxInAncestor(rootLayer, referenceBox); 2327 convertFromFlowThreadToVisualBoundingBoxInAncestor(rootLayer, referenceBox);
2322 else 2328 else
2323 convertToLayerCoords(rootLayer, referenceBox); 2329 convertToLayerCoords(rootLayer, referenceBox);
2324 2330
2325 FloatPoint point(hitTestLocation.point()); 2331 FloatPoint point(hitTestLocation.point());
2326 2332
2327 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); 2333 ClipPathOperation* clipPathOperation = layoutObject().style()->clipPath();
2328 DCHECK(clipPathOperation); 2334 DCHECK(clipPathOperation);
2329 if (clipPathOperation->type() == ClipPathOperation::SHAPE) { 2335 if (clipPathOperation->type() == ClipPathOperation::SHAPE) {
2330 ShapeClipPathOperation* clipPath = 2336 ShapeClipPathOperation* clipPath =
2331 toShapeClipPathOperation(clipPathOperation); 2337 toShapeClipPathOperation(clipPathOperation);
2332 return !clipPath->path(FloatRect(referenceBox)).contains(point); 2338 return !clipPath->path(FloatRect(referenceBox)).contains(point);
2333 } 2339 }
2334 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); 2340 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE);
2335 Node* targetNode = layoutObject()->node(); 2341 Node* targetNode = layoutObject().node();
2336 if (!targetNode) 2342 if (!targetNode)
2337 return false; 2343 return false;
2338 const ReferenceClipPathOperation& referenceClipPathOperation = 2344 const ReferenceClipPathOperation& referenceClipPathOperation =
2339 toReferenceClipPathOperation(*clipPathOperation); 2345 toReferenceClipPathOperation(*clipPathOperation);
2340 SVGElement* element = 2346 SVGElement* element =
2341 referenceClipPathOperation.findElement(targetNode->treeScope()); 2347 referenceClipPathOperation.findElement(targetNode->treeScope());
2342 if (!isSVGClipPathElement(element) || !element->layoutObject()) 2348 if (!isSVGClipPathElement(element) || !element->layoutObject())
2343 return false; 2349 return false;
2344 LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper( 2350 LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper(
2345 toLayoutSVGResourceContainer(element->layoutObject())); 2351 toLayoutSVGResourceContainer(element->layoutObject()));
2346 // If the clipPath is using "userspace on use" units, then the origin of 2352 // If the clipPath is using "userspace on use" units, then the origin of
2347 // the coordinate system is the top-left of the reference box, so adjust 2353 // the coordinate system is the top-left of the reference box, so adjust
2348 // the point accordingly. 2354 // the point accordingly.
2349 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) 2355 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse)
2350 point.moveBy(-referenceBox.location()); 2356 point.moveBy(-referenceBox.location());
2351 return !clipper->hitTestClipContent(FloatRect(referenceBox), point); 2357 return !clipper->hitTestClipContent(FloatRect(referenceBox), point);
2352 } 2358 }
2353 2359
2354 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, 2360 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds,
2355 const LayoutRect& damageRect, 2361 const LayoutRect& damageRect,
2356 const LayoutPoint& offsetFromRoot) const { 2362 const LayoutPoint& offsetFromRoot) const {
2357 // Always examine the canvas and the root. 2363 // Always examine the canvas and the root.
2358 // FIXME: Could eliminate the isDocumentElement() check if we fix background 2364 // FIXME: Could eliminate the isDocumentElement() check if we fix background
2359 // painting so that the LayoutView paints the root's background. 2365 // painting so that the LayoutView paints the root's background.
2360 if (isRootLayer() || layoutObject()->isDocumentElement()) 2366 if (isRootLayer() || layoutObject().isDocumentElement())
2361 return true; 2367 return true;
2362 2368
2363 // If we aren't an inline flow, and our layer bounds do intersect the damage 2369 // If we aren't an inline flow, and our layer bounds do intersect the damage
2364 // rect, then we can go ahead and return true. 2370 // rect, then we can go ahead and return true.
2365 LayoutView* view = layoutObject()->view(); 2371 LayoutView* view = layoutObject().view();
2366 DCHECK(view); 2372 DCHECK(view);
2367 if (view && !layoutObject()->isLayoutInline()) { 2373 if (view && !layoutObject().isLayoutInline()) {
2368 if (layerBounds.intersects(damageRect)) 2374 if (layerBounds.intersects(damageRect))
2369 return true; 2375 return true;
2370 } 2376 }
2371 2377
2372 // Otherwise we need to compute the bounding box of this single layer and see 2378 // Otherwise we need to compute the bounding box of this single layer and see
2373 // if it intersects the damage rect. 2379 // if it intersects the damage rect.
2374 return physicalBoundingBox(offsetFromRoot).intersects(damageRect); 2380 return physicalBoundingBox(offsetFromRoot).intersects(damageRect);
2375 } 2381 }
2376 2382
2377 LayoutRect PaintLayer::logicalBoundingBox() const { 2383 LayoutRect PaintLayer::logicalBoundingBox() const {
2378 LayoutRect rect = layoutObject()->visualOverflowRect(); 2384 LayoutRect rect = layoutObject().visualOverflowRect();
2379 2385
2380 if (isRootLayer()) { 2386 if (isRootLayer()) {
2381 rect.unite( 2387 rect.unite(
2382 LayoutRect(rect.location(), layoutObject()->view()->viewRect().size())); 2388 LayoutRect(rect.location(), layoutObject().view()->viewRect().size()));
2383 } 2389 }
2384 2390
2385 return rect; 2391 return rect;
2386 } 2392 }
2387 2393
2388 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox, 2394 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox,
2389 LayoutObject* layoutObject) { 2395 LayoutObject& layoutObject) {
2390 LayoutRect result = boundingBox; 2396 LayoutRect result = boundingBox;
2391 if (layoutObject->isBox()) 2397 if (layoutObject.isBox())
2392 toLayoutBox(layoutObject)->flipForWritingMode(result); 2398 toLayoutBox(layoutObject).flipForWritingMode(result);
2393 else 2399 else
2394 layoutObject->containingBlock()->flipForWritingMode(result); 2400 layoutObject.containingBlock()->flipForWritingMode(result);
2395 return result; 2401 return result;
2396 } 2402 }
2397 2403
2398 LayoutRect PaintLayer::physicalBoundingBox( 2404 LayoutRect PaintLayer::physicalBoundingBox(
2399 const PaintLayer* ancestorLayer) const { 2405 const PaintLayer* ancestorLayer) const {
2400 LayoutPoint offsetFromRoot; 2406 LayoutPoint offsetFromRoot;
2401 convertToLayerCoords(ancestorLayer, offsetFromRoot); 2407 convertToLayerCoords(ancestorLayer, offsetFromRoot);
2402 return physicalBoundingBox(offsetFromRoot); 2408 return physicalBoundingBox(offsetFromRoot);
2403 } 2409 }
2404 2410
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 2499
2494 // FIXME: This could be improved to do a check like 2500 // FIXME: This could be improved to do a check like
2495 // hasVisibleNonCompositingDescendantLayers() (bug 92580). 2501 // hasVisibleNonCompositingDescendantLayers() (bug 92580).
2496 if (this != &compositedLayer && !hasVisibleContent() && 2502 if (this != &compositedLayer && !hasVisibleContent() &&
2497 !hasVisibleDescendant()) 2503 !hasVisibleDescendant())
2498 return LayoutRect(); 2504 return LayoutRect();
2499 2505
2500 // The root layer is the size of the document, plus any additional area due 2506 // The root layer is the size of the document, plus any additional area due
2501 // to layout viewport being different than initial containing block. 2507 // to layout viewport being different than initial containing block.
2502 if (isRootLayer()) { 2508 if (isRootLayer()) {
2503 IntRect documentRect = layoutObject()->view()->documentRect(); 2509 IntRect documentRect = layoutObject().view()->documentRect();
2504 2510
2505 if (FrameView* frameView = layoutObject()->document().view()) { 2511 if (FrameView* frameView = layoutObject().document().view()) {
2506 documentRect.unite(IntRect(IntPoint(), frameView->visibleContentSize())); 2512 documentRect.unite(IntRect(IntPoint(), frameView->visibleContentSize()));
2507 } 2513 }
2508 2514
2509 return LayoutRect(documentRect); 2515 return LayoutRect(documentRect);
2510 } 2516 }
2511 2517
2512 // The layer created for the LayoutFlowThread is just a helper for painting 2518 // The layer created for the LayoutFlowThread is just a helper for painting
2513 // and hit-testing, and should not contribute to the bounding box. The 2519 // and hit-testing, and should not contribute to the bounding box. The
2514 // LayoutMultiColumnSets will contribute the correct size for the layout 2520 // LayoutMultiColumnSets will contribute the correct size for the layout
2515 // content of the multicol container. 2521 // content of the multicol container.
2516 if (layoutObject()->isLayoutFlowThread()) 2522 if (layoutObject().isLayoutFlowThread())
2517 return LayoutRect(); 2523 return LayoutRect();
2518 2524
2519 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); 2525 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
2520 2526
2521 // If there is a clip applied by an ancestor to this PaintLayer but below or 2527 // If there is a clip applied by an ancestor to this PaintLayer but below or
2522 // equal to |ancestorLayer|, apply that clip. 2528 // equal to |ancestorLayer|, apply that clip.
2523 LayoutRect result = clipper(PaintLayer::DoNotUseGeometryMapper) 2529 LayoutRect result = clipper(PaintLayer::DoNotUseGeometryMapper)
2524 .localClipRect(compositedLayer); 2530 .localClipRect(compositedLayer);
2525 2531
2526 result.intersect(physicalBoundingBox(LayoutPoint())); 2532 result.intersect(physicalBoundingBox(LayoutPoint()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 if (!compositedLayerMapping()) 2572 if (!compositedLayerMapping())
2567 return NotComposited; 2573 return NotComposited;
2568 2574
2569 return PaintsIntoOwnBacking; 2575 return PaintsIntoOwnBacking;
2570 } 2576 }
2571 2577
2572 bool PaintLayer::isAllowedToQueryCompositingState() const { 2578 bool PaintLayer::isAllowedToQueryCompositingState() const {
2573 if (gCompositingQueryMode == CompositingQueriesAreAllowed || 2579 if (gCompositingQueryMode == CompositingQueriesAreAllowed ||
2574 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2580 RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2575 return true; 2581 return true;
2576 return layoutObject()->document().lifecycle().state() >= 2582 return layoutObject().document().lifecycle().state() >=
2577 DocumentLifecycle::InCompositingUpdate; 2583 DocumentLifecycle::InCompositingUpdate;
2578 } 2584 }
2579 2585
2580 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const { 2586 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const {
2581 DCHECK(isAllowedToQueryCompositingState()); 2587 DCHECK(isAllowedToQueryCompositingState());
2582 return m_rareData ? m_rareData->compositedLayerMapping.get() : nullptr; 2588 return m_rareData ? m_rareData->compositedLayerMapping.get() : nullptr;
2583 } 2589 }
2584 2590
2585 GraphicsLayer* PaintLayer::graphicsLayerBacking(const LayoutObject* obj) const { 2591 GraphicsLayer* PaintLayer::graphicsLayerBacking(const LayoutObject* obj) const {
2586 switch (compositingState()) { 2592 switch (compositingState()) {
2587 case NotComposited: 2593 case NotComposited:
2588 return nullptr; 2594 return nullptr;
2589 case PaintsIntoGroupedBacking: 2595 case PaintsIntoGroupedBacking:
2590 return groupedMapping()->squashingLayer(); 2596 return groupedMapping()->squashingLayer();
2591 default: 2597 default:
2592 return (obj != layoutObject() && 2598 return (obj != &layoutObject() &&
2593 compositedLayerMapping()->scrollingContentsLayer()) 2599 compositedLayerMapping()->scrollingContentsLayer())
2594 ? compositedLayerMapping()->scrollingContentsLayer() 2600 ? compositedLayerMapping()->scrollingContentsLayer()
2595 : compositedLayerMapping()->mainGraphicsLayer(); 2601 : compositedLayerMapping()->mainGraphicsLayer();
2596 } 2602 }
2597 } 2603 }
2598 2604
2599 BackgroundPaintLocation PaintLayer::backgroundPaintLocation( 2605 BackgroundPaintLocation PaintLayer::backgroundPaintLocation(
2600 uint32_t* reasons) const { 2606 uint32_t* reasons) const {
2601 BackgroundPaintLocation location; 2607 BackgroundPaintLocation location;
2602 if (!scrollsOverflow()) { 2608 if (!scrollsOverflow()) {
2603 location = BackgroundPaintInGraphicsLayer; 2609 location = BackgroundPaintInGraphicsLayer;
2604 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 2610 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2605 location = layoutObject()->backgroundPaintLocation(reasons); 2611 location = layoutObject().backgroundPaintLocation(reasons);
2606 } else { 2612 } else {
2607 location = isRootLayer() ? BackgroundPaintInGraphicsLayer 2613 location = isRootLayer() ? BackgroundPaintInGraphicsLayer
2608 : layoutObject()->backgroundPaintLocation(reasons); 2614 : layoutObject().backgroundPaintLocation(reasons);
2609 } 2615 }
2610 m_stackingNode->updateLayerListsIfNeeded(); 2616 m_stackingNode->updateLayerListsIfNeeded();
2611 if (m_stackingNode->hasNegativeZOrderList()) 2617 if (m_stackingNode->hasNegativeZOrderList())
2612 location = BackgroundPaintInGraphicsLayer; 2618 location = BackgroundPaintInGraphicsLayer;
2613 return location; 2619 return location;
2614 } 2620 }
2615 2621
2616 void PaintLayer::ensureCompositedLayerMapping() { 2622 void PaintLayer::ensureCompositedLayerMapping() {
2617 if (m_rareData && m_rareData->compositedLayerMapping) 2623 if (m_rareData && m_rareData->compositedLayerMapping)
2618 return; 2624 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 if (m_rareData || groupedMapping) 2667 if (m_rareData || groupedMapping)
2662 ensureRareData().groupedMapping = groupedMapping; 2668 ensureRareData().groupedMapping = groupedMapping;
2663 #if DCHECK_IS_ON() 2669 #if DCHECK_IS_ON()
2664 DCHECK(!groupedMapping || groupedMapping->verifyLayerInSquashingVector(this)); 2670 DCHECK(!groupedMapping || groupedMapping->verifyLayerInSquashingVector(this));
2665 #endif 2671 #endif
2666 if (options == InvalidateLayerAndRemoveFromMapping && groupedMapping) 2672 if (options == InvalidateLayerAndRemoveFromMapping && groupedMapping)
2667 groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree); 2673 groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree);
2668 } 2674 }
2669 2675
2670 bool PaintLayer::maskBlendingAppliedByCompositor() const { 2676 bool PaintLayer::maskBlendingAppliedByCompositor() const {
2671 DCHECK(m_layoutObject->hasMask()); 2677 DCHECK(m_layoutObject.hasMask());
2672 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2678 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2673 return true; 2679 return true;
2674 return m_rareData && m_rareData->compositedLayerMapping && 2680 return m_rareData && m_rareData->compositedLayerMapping &&
2675 m_rareData->compositedLayerMapping->hasMaskLayer(); 2681 m_rareData->compositedLayerMapping->hasMaskLayer();
2676 } 2682 }
2677 2683
2678 bool PaintLayer::hasCompositedClippingMask() const { 2684 bool PaintLayer::hasCompositedClippingMask() const {
2679 return m_rareData && m_rareData->compositedLayerMapping && 2685 return m_rareData && m_rareData->compositedLayerMapping &&
2680 m_rareData->compositedLayerMapping->hasChildClippingMaskLayer(); 2686 m_rareData->compositedLayerMapping->hasChildClippingMaskLayer();
2681 } 2687 }
2682 2688
2683 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const { 2689 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const {
2684 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { 2690 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) {
2685 return transform() && 2691 return transform() &&
2686 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || 2692 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) ||
2687 compositingState() != PaintsIntoOwnBacking); 2693 compositingState() != PaintsIntoOwnBacking);
2688 } 2694 }
2689 2695
2690 return (transform() || 2696 return (transform() ||
2691 layoutObject()->style()->position() == EPosition::kFixed) && 2697 layoutObject().style()->position() == EPosition::kFixed) &&
2692 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || 2698 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) ||
2693 compositingState() != PaintsIntoOwnBacking); 2699 compositingState() != PaintsIntoOwnBacking);
2694 } 2700 }
2695 2701
2696 bool PaintLayer::compositesWithTransform() const { 2702 bool PaintLayer::compositesWithTransform() const {
2697 return transformAncestor() || transform(); 2703 return transformAncestor() || transform();
2698 } 2704 }
2699 2705
2700 bool PaintLayer::compositesWithOpacity() const { 2706 bool PaintLayer::compositesWithOpacity() const {
2701 return opacityAncestor() || layoutObject()->style()->hasOpacity(); 2707 return opacityAncestor() || layoutObject().style()->hasOpacity();
2702 } 2708 }
2703 2709
2704 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect( 2710 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect(
2705 const LayoutRect& localRect) const { 2711 const LayoutRect& localRect) const {
2706 if (paintsWithTransparency(GlobalPaintNormalPhase)) 2712 if (paintsWithTransparency(GlobalPaintNormalPhase))
2707 return false; 2713 return false;
2708 2714
2709 // We can't use hasVisibleContent(), because that will be true if our 2715 // We can't use hasVisibleContent(), because that will be true if our
2710 // layoutObject is hidden, but some child is visible and that child doesn't 2716 // layoutObject is hidden, but some child is visible and that child doesn't
2711 // cover the entire rect. 2717 // cover the entire rect.
2712 if (layoutObject()->style()->visibility() != EVisibility::kVisible) 2718 if (layoutObject().style()->visibility() != EVisibility::kVisible)
2713 return false; 2719 return false;
2714 2720
2715 if (paintsWithFilters() && 2721 if (paintsWithFilters() &&
2716 layoutObject()->style()->filter().hasFilterThatAffectsOpacity()) 2722 layoutObject().style()->filter().hasFilterThatAffectsOpacity())
2717 return false; 2723 return false;
2718 2724
2719 // FIXME: Handle simple transforms. 2725 // FIXME: Handle simple transforms.
2720 if (transform() && compositingState() != PaintsIntoOwnBacking) 2726 if (transform() && compositingState() != PaintsIntoOwnBacking)
2721 return false; 2727 return false;
2722 2728
2723 if (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() && 2729 if (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() &&
2724 layoutObject()->style()->position() == EPosition::kFixed && 2730 layoutObject().style()->position() == EPosition::kFixed &&
2725 compositingState() != PaintsIntoOwnBacking) 2731 compositingState() != PaintsIntoOwnBacking)
2726 return false; 2732 return false;
2727 2733
2728 // This function should not be called when layer-lists are dirty. 2734 // This function should not be called when layer-lists are dirty.
2729 // TODO(schenney) This check never hits in layout tests or most platforms, but 2735 // TODO(schenney) This check never hits in layout tests or most platforms, but
2730 // does hit in PopupBlockerBrowserTest.AllowPopupThroughContentSetting on 2736 // does hit in PopupBlockerBrowserTest.AllowPopupThroughContentSetting on
2731 // Win 7 Test Builder. 2737 // Win 7 Test Builder.
2732 if (m_stackingNode->zOrderListsDirty()) 2738 if (m_stackingNode->zOrderListsDirty())
2733 return false; 2739 return false;
2734 2740
2735 // FIXME: We currently only check the immediate layoutObject, 2741 // FIXME: We currently only check the immediate layoutObject,
2736 // which will miss many cases where additional layout objects paint 2742 // which will miss many cases where additional layout objects paint
2737 // into this layer. 2743 // into this layer.
2738 if (layoutObject()->backgroundIsKnownToBeOpaqueInRect(localRect)) 2744 if (layoutObject().backgroundIsKnownToBeOpaqueInRect(localRect))
2739 return true; 2745 return true;
2740 2746
2741 // We can't consult child layers if we clip, since they might cover 2747 // We can't consult child layers if we clip, since they might cover
2742 // parts of the rect that are clipped out. 2748 // parts of the rect that are clipped out.
2743 if (layoutObject()->hasClipRelatedProperty()) 2749 if (layoutObject().hasClipRelatedProperty())
2744 return false; 2750 return false;
2745 2751
2746 // TODO(schenney): This could be improved by unioning the opaque regions of 2752 // TODO(schenney): This could be improved by unioning the opaque regions of
2747 // all the children. That would require a refactoring because currently 2753 // all the children. That would require a refactoring because currently
2748 // children just check they at least cover the given rect, but a unioning 2754 // children just check they at least cover the given rect, but a unioning
2749 // method would require children to compute and report their rects. 2755 // method would require children to compute and report their rects.
2750 return childBackgroundIsKnownToBeOpaqueInRect(localRect); 2756 return childBackgroundIsKnownToBeOpaqueInRect(localRect);
2751 } 2757 }
2752 2758
2753 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect( 2759 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect(
(...skipping 15 matching lines...) Expand all
2769 childLayer->convertToLayerCoords(this, childOffset); 2775 childLayer->convertToLayerCoords(this, childOffset);
2770 childLocalRect.moveBy(-childOffset); 2776 childLocalRect.moveBy(-childOffset);
2771 2777
2772 if (childLayer->backgroundIsKnownToBeOpaqueInRect(childLocalRect)) 2778 if (childLayer->backgroundIsKnownToBeOpaqueInRect(childLocalRect))
2773 return true; 2779 return true;
2774 } 2780 }
2775 return false; 2781 return false;
2776 } 2782 }
2777 2783
2778 bool PaintLayer::shouldBeSelfPaintingLayer() const { 2784 bool PaintLayer::shouldBeSelfPaintingLayer() const {
2779 if (layoutObject()->isLayoutPart() && 2785 if (layoutObject().isLayoutPart() &&
2780 toLayoutPart(layoutObject())->requiresAcceleratedCompositing()) 2786 toLayoutPart(layoutObject()).requiresAcceleratedCompositing())
2781 return true; 2787 return true;
2782 2788
2783 return layoutObject()->layerTypeRequired() == NormalPaintLayer || 2789 return layoutObject().layerTypeRequired() == NormalPaintLayer ||
2784 (m_scrollableArea && m_scrollableArea->hasOverlayScrollbars()) || 2790 (m_scrollableArea && m_scrollableArea->hasOverlayScrollbars()) ||
2785 needsCompositedScrolling(); 2791 needsCompositedScrolling();
2786 } 2792 }
2787 2793
2788 void PaintLayer::updateSelfPaintingLayer() { 2794 void PaintLayer::updateSelfPaintingLayer() {
2789 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 2795 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer();
2790 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) 2796 if (this->isSelfPaintingLayer() == isSelfPaintingLayer)
2791 return; 2797 return;
2792 2798
2793 m_isSelfPaintingLayer = isSelfPaintingLayer; 2799 m_isSelfPaintingLayer = isSelfPaintingLayer;
(...skipping 18 matching lines...) Expand all
2812 layer = layer->parent(); 2818 layer = layer->parent();
2813 return layer; 2819 return layer;
2814 } 2820 }
2815 2821
2816 bool PaintLayer::hasNonEmptyChildLayoutObjects() const { 2822 bool PaintLayer::hasNonEmptyChildLayoutObjects() const {
2817 // Some HTML can cause whitespace text nodes to have layoutObjects, like: 2823 // Some HTML can cause whitespace text nodes to have layoutObjects, like:
2818 // <div> 2824 // <div>
2819 // <img src=...> 2825 // <img src=...>
2820 // </div> 2826 // </div>
2821 // so test for 0x0 LayoutTexts here 2827 // so test for 0x0 LayoutTexts here
2822 for (LayoutObject* child = layoutObject()->slowFirstChild(); child; 2828 for (LayoutObject* child = layoutObject().slowFirstChild(); child;
2823 child = child->nextSibling()) { 2829 child = child->nextSibling()) {
2824 if (!child->hasLayer()) { 2830 if (!child->hasLayer()) {
2825 if (child->isLayoutInline() || !child->isBox()) 2831 if (child->isLayoutInline() || !child->isBox())
2826 return true; 2832 return true;
2827 2833
2828 if (toLayoutBox(child)->size().width() > 0 || 2834 if (toLayoutBox(child)->size().width() > 0 ||
2829 toLayoutBox(child)->size().height() > 0) 2835 toLayoutBox(child)->size().height() > 0)
2830 return true; 2836 return true;
2831 } 2837 }
2832 } 2838 }
2833 return false; 2839 return false;
2834 } 2840 }
2835 2841
2836 bool PaintLayer::hasBoxDecorationsOrBackground() const { 2842 bool PaintLayer::hasBoxDecorationsOrBackground() const {
2837 return layoutObject()->style()->hasBoxDecorations() || 2843 return layoutObject().style()->hasBoxDecorations() ||
2838 layoutObject()->style()->hasBackground(); 2844 layoutObject().style()->hasBackground();
2839 } 2845 }
2840 2846
2841 bool PaintLayer::hasVisibleBoxDecorations() const { 2847 bool PaintLayer::hasVisibleBoxDecorations() const {
2842 if (!hasVisibleContent()) 2848 if (!hasVisibleContent())
2843 return false; 2849 return false;
2844 2850
2845 return hasBoxDecorationsOrBackground() || hasOverflowControls(); 2851 return hasBoxDecorationsOrBackground() || hasOverflowControls();
2846 } 2852 }
2847 2853
2848 void PaintLayer::updateFilters(const ComputedStyle* oldStyle, 2854 void PaintLayer::updateFilters(const ComputedStyle* oldStyle,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 // the overlap map. 2915 // the overlap map.
2910 if (diff.transformChanged() && 2916 if (diff.transformChanged() &&
2911 (!m_rareData || 2917 (!m_rareData ||
2912 !(m_rareData->compositingReasons & CompositingReasonInlineTransform))) 2918 !(m_rareData->compositingReasons & CompositingReasonInlineTransform)))
2913 return false; 2919 return false;
2914 2920
2915 // We composite transparent Layers differently from non-transparent 2921 // We composite transparent Layers differently from non-transparent
2916 // Layers even when the non-transparent Layers are already a 2922 // Layers even when the non-transparent Layers are already a
2917 // stacking context. 2923 // stacking context.
2918 if (diff.opacityChanged() && 2924 if (diff.opacityChanged() &&
2919 m_layoutObject->style()->hasOpacity() != oldStyle->hasOpacity()) 2925 m_layoutObject.style()->hasOpacity() != oldStyle->hasOpacity())
2920 return false; 2926 return false;
2921 2927
2922 // Changes in pointer-events affect hit test visibility of the scrollable 2928 // Changes in pointer-events affect hit test visibility of the scrollable
2923 // area and its |m_scrollsOverflow| value which determines if the layer 2929 // area and its |m_scrollsOverflow| value which determines if the layer
2924 // requires composited scrolling or not. 2930 // requires composited scrolling or not.
2925 if (m_scrollableArea && 2931 if (m_scrollableArea &&
2926 m_layoutObject->style()->pointerEvents() != oldStyle->pointerEvents()) 2932 m_layoutObject.style()->pointerEvents() != oldStyle->pointerEvents())
2927 return false; 2933 return false;
2928 2934
2929 updateTransform(oldStyle, layoutObject()->styleRef()); 2935 updateTransform(oldStyle, layoutObject().styleRef());
2930 2936
2931 // FIXME: Consider introducing a smaller graphics layer update scope 2937 // FIXME: Consider introducing a smaller graphics layer update scope
2932 // that just handles transforms and opacity. GraphicsLayerUpdateLocal 2938 // that just handles transforms and opacity. GraphicsLayerUpdateLocal
2933 // will also program bounds, clips, and many other properties that could 2939 // will also program bounds, clips, and many other properties that could
2934 // not possibly have changed. 2940 // not possibly have changed.
2935 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate( 2941 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate(
2936 GraphicsLayerUpdateLocal); 2942 GraphicsLayerUpdateLocal);
2937 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange); 2943 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange);
2938 2944
2939 if (m_scrollableArea) 2945 if (m_scrollableArea)
2940 m_scrollableArea->updateAfterStyleChange(oldStyle); 2946 m_scrollableArea->updateAfterStyleChange(oldStyle);
2941 2947
2942 return true; 2948 return true;
2943 } 2949 }
2944 2950
2945 void PaintLayer::styleDidChange(StyleDifference diff, 2951 void PaintLayer::styleDidChange(StyleDifference diff,
2946 const ComputedStyle* oldStyle) { 2952 const ComputedStyle* oldStyle) {
2947 if (attemptDirectCompositingUpdate(diff, oldStyle)) 2953 if (attemptDirectCompositingUpdate(diff, oldStyle))
2948 return; 2954 return;
2949 2955
2950 m_stackingNode->styleDidChange(oldStyle); 2956 m_stackingNode->styleDidChange(oldStyle);
2951 2957
2952 if (m_scrollableArea) 2958 if (m_scrollableArea)
2953 m_scrollableArea->updateAfterStyleChange(oldStyle); 2959 m_scrollableArea->updateAfterStyleChange(oldStyle);
2954 2960
2955 // Overlay scrollbars can make this layer self-painting so we need 2961 // Overlay scrollbars can make this layer self-painting so we need
2956 // to recompute the bit once scrollbars have been updated. 2962 // to recompute the bit once scrollbars have been updated.
2957 updateSelfPaintingLayer(); 2963 updateSelfPaintingLayer();
2958 2964
2959 updateTransform(oldStyle, layoutObject()->styleRef()); 2965 updateTransform(oldStyle, layoutObject().styleRef());
2960 updateFilters(oldStyle, layoutObject()->styleRef()); 2966 updateFilters(oldStyle, layoutObject().styleRef());
2961 updateClipPath(oldStyle, layoutObject()->styleRef()); 2967 updateClipPath(oldStyle, layoutObject().styleRef());
2962 2968
2963 setNeedsCompositingInputsUpdate(); 2969 setNeedsCompositingInputsUpdate();
2964 layoutObject()->setNeedsPaintPropertyUpdate(); 2970 layoutObject().setNeedsPaintPropertyUpdate();
2965 } 2971 }
2966 2972
2967 PaintLayerClipper PaintLayer::clipper( 2973 PaintLayerClipper PaintLayer::clipper(
2968 GeometryMapperOption geometryMapperOption) const { 2974 GeometryMapperOption geometryMapperOption) const {
2969 GeometryMapper* geometryMapper = nullptr; 2975 GeometryMapper* geometryMapper = nullptr;
2970 if (geometryMapperOption == UseGeometryMapper) { 2976 if (geometryMapperOption == UseGeometryMapper) {
2971 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); 2977 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
2972 if (FrameView* frameView = m_layoutObject->document().view()) 2978 if (FrameView* frameView = m_layoutObject.document().view())
2973 geometryMapper = &frameView->geometryMapper(); 2979 geometryMapper = &frameView->geometryMapper();
2974 } 2980 }
2975 return PaintLayerClipper(*this, geometryMapper); 2981 return PaintLayerClipper(*this, geometryMapper);
2976 } 2982 }
2977 2983
2978 bool PaintLayer::scrollsOverflow() const { 2984 bool PaintLayer::scrollsOverflow() const {
2979 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) 2985 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea())
2980 return scrollableArea->scrollsOverflow(); 2986 return scrollableArea->scrollsOverflow();
2981 2987
2982 return false; 2988 return false;
2983 } 2989 }
2984 2990
2985 FilterOperations PaintLayer::addReflectionToFilterOperations( 2991 FilterOperations PaintLayer::addReflectionToFilterOperations(
2986 const ComputedStyle& style) const { 2992 const ComputedStyle& style) const {
2987 FilterOperations filterOperations = style.filter(); 2993 FilterOperations filterOperations = style.filter();
2988 if (layoutObject()->hasReflection() && layoutObject()->isBox()) { 2994 if (layoutObject().hasReflection() && layoutObject().isBox()) {
2989 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); 2995 BoxReflection reflection = boxReflectionForPaintLayer(*this, style);
2990 filterOperations.operations().push_back( 2996 filterOperations.operations().push_back(
2991 BoxReflectFilterOperation::create(reflection)); 2997 BoxReflectFilterOperation::create(reflection));
2992 } 2998 }
2993 return filterOperations; 2999 return filterOperations;
2994 } 3000 }
2995 3001
2996 CompositorFilterOperations 3002 CompositorFilterOperations
2997 PaintLayer::createCompositorFilterOperationsForFilter( 3003 PaintLayer::createCompositorFilterOperationsForFilter(
2998 const ComputedStyle& style) { 3004 const ComputedStyle& style) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 FilterEffect* PaintLayer::lastFilterEffect() const { 3053 FilterEffect* PaintLayer::lastFilterEffect() const {
3048 // TODO(chrishtr): ensure (and assert) that compositing is clean here. 3054 // TODO(chrishtr): ensure (and assert) that compositing is clean here.
3049 if (!paintsWithFilters()) 3055 if (!paintsWithFilters())
3050 return nullptr; 3056 return nullptr;
3051 PaintLayerResourceInfo* resourceInfo = this->resourceInfo(); 3057 PaintLayerResourceInfo* resourceInfo = this->resourceInfo();
3052 DCHECK(resourceInfo); 3058 DCHECK(resourceInfo);
3053 3059
3054 if (resourceInfo->lastEffect()) 3060 if (resourceInfo->lastEffect())
3055 return resourceInfo->lastEffect(); 3061 return resourceInfo->lastEffect();
3056 3062
3057 const ComputedStyle& style = layoutObject()->styleRef(); 3063 const ComputedStyle& style = layoutObject().styleRef();
3058 FloatRect zoomedReferenceBox; 3064 FloatRect zoomedReferenceBox;
3059 if (style.filter().hasReferenceFilter()) 3065 if (style.filter().hasReferenceFilter())
3060 zoomedReferenceBox = boxForFilterOrMask(); 3066 zoomedReferenceBox = boxForFilterOrMask();
3061 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox, 3067 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox,
3062 style.effectiveZoom()); 3068 style.effectiveZoom());
3063 resourceInfo->setLastEffect( 3069 resourceInfo->setLastEffect(
3064 builder.buildFilterEffect(addReflectionToFilterOperations(style))); 3070 builder.buildFilterEffect(addReflectionToFilterOperations(style)));
3065 return resourceInfo->lastEffect(); 3071 return resourceInfo->lastEffect();
3066 } 3072 }
3067 3073
3068 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const { 3074 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const {
3069 if (!hasFilterThatMovesPixels()) 3075 if (!hasFilterThatMovesPixels())
3070 return rect; 3076 return rect;
3071 3077
3072 // Ensure the filter-chain is refreshed wrt reference filters. 3078 // Ensure the filter-chain is refreshed wrt reference filters.
3073 // TODO(fs): Avoid having this side-effect inducing call. 3079 // TODO(fs): Avoid having this side-effect inducing call.
3074 lastFilterEffect(); 3080 lastFilterEffect();
3075 3081
3076 FilterOperations filterOperations = 3082 FilterOperations filterOperations =
3077 addReflectionToFilterOperations(layoutObject()->styleRef()); 3083 addReflectionToFilterOperations(layoutObject().styleRef());
3078 return filterOperations.mapRect(rect); 3084 return filterOperations.mapRect(rect);
3079 } 3085 }
3080 3086
3081 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const { 3087 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const {
3082 if (!hasFilterThatMovesPixels()) 3088 if (!hasFilterThatMovesPixels())
3083 return rect; 3089 return rect;
3084 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect))); 3090 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect)));
3085 } 3091 }
3086 3092
3087 bool PaintLayer::hasFilterThatMovesPixels() const { 3093 bool PaintLayer::hasFilterThatMovesPixels() const {
3088 if (!hasFilterInducingProperty()) 3094 if (!hasFilterInducingProperty())
3089 return false; 3095 return false;
3090 const ComputedStyle& style = layoutObject()->styleRef(); 3096 const ComputedStyle& style = layoutObject().styleRef();
3091 if (style.hasFilter() && style.filter().hasFilterThatMovesPixels()) 3097 if (style.hasFilter() && style.filter().hasFilterThatMovesPixels())
3092 return true; 3098 return true;
3093 if (style.hasBoxReflect()) 3099 if (style.hasBoxReflect())
3094 return true; 3100 return true;
3095 return false; 3101 return false;
3096 } 3102 }
3097 3103
3098 void PaintLayer::addLayerHitTestRects(LayerHitTestRects& rects) const { 3104 void PaintLayer::addLayerHitTestRects(LayerHitTestRects& rects) const {
3099 computeSelfHitTestRects(rects); 3105 computeSelfHitTestRects(rects);
3100 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) 3106 for (PaintLayer* child = firstChild(); child; child = child->nextSibling())
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 if (CompositedLayerMapping* groupedMapping = layer->groupedMapping()) { 3163 if (CompositedLayerMapping* groupedMapping = layer->groupedMapping()) {
3158 // TODO(wkorman): As we clean up the CompositedLayerMapping needsRepaint 3164 // TODO(wkorman): As we clean up the CompositedLayerMapping needsRepaint
3159 // logic to delegate to scrollbars, we may be able to remove the line 3165 // logic to delegate to scrollbars, we may be able to remove the line
3160 // below as well. 3166 // below as well.
3161 groupedMapping->owningLayer().setNeedsRepaint(); 3167 groupedMapping->owningLayer().setNeedsRepaint();
3162 return; 3168 return;
3163 } 3169 }
3164 3170
3165 PaintLayer* container = layer->compositingContainer(); 3171 PaintLayer* container = layer->compositingContainer();
3166 if (!container) { 3172 if (!container) {
3167 LayoutItem owner = layer->layoutObject()->frame()->ownerLayoutItem(); 3173 LayoutItem owner = layer->layoutObject().frame()->ownerLayoutItem();
3168 if (owner.isNull()) 3174 if (owner.isNull())
3169 break; 3175 break;
3170 container = owner.enclosingLayer(); 3176 container = owner.enclosingLayer();
3171 } 3177 }
3172 3178
3173 if (container->m_needsRepaint) 3179 if (container->m_needsRepaint)
3174 break; 3180 break;
3175 3181
3176 container->setNeedsRepaintInternal(); 3182 container->setNeedsRepaintInternal();
3177 layer = container; 3183 layer = container;
(...skipping 21 matching lines...) Expand all
3199 3205
3200 #ifndef NDEBUG 3206 #ifndef NDEBUG
3201 // FIXME: Rename? 3207 // FIXME: Rename?
3202 void showLayerTree(const blink::PaintLayer* layer) { 3208 void showLayerTree(const blink::PaintLayer* layer) {
3203 blink::DisableCompositingQueryAsserts disabler; 3209 blink::DisableCompositingQueryAsserts disabler;
3204 if (!layer) { 3210 if (!layer) {
3205 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3211 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3206 return; 3212 return;
3207 } 3213 }
3208 3214
3209 if (blink::LocalFrame* frame = layer->layoutObject()->frame()) { 3215 if (blink::LocalFrame* frame = layer->layoutObject().frame()) {
3210 WTF::String output = externalRepresentation( 3216 WTF::String output = externalRepresentation(
3211 frame, 3217 frame,
3212 blink::LayoutAsTextShowAllLayers | blink::LayoutAsTextShowLayerNesting | 3218 blink::LayoutAsTextShowAllLayers | blink::LayoutAsTextShowLayerNesting |
3213 blink::LayoutAsTextShowCompositedLayers | 3219 blink::LayoutAsTextShowCompositedLayers |
3214 blink::LayoutAsTextShowAddresses | 3220 blink::LayoutAsTextShowAddresses |
3215 blink::LayoutAsTextShowIDAndClass | 3221 blink::LayoutAsTextShowIDAndClass |
3216 blink::LayoutAsTextDontUpdateLayout | 3222 blink::LayoutAsTextDontUpdateLayout |
3217 blink::LayoutAsTextShowLayoutState, 3223 blink::LayoutAsTextShowLayoutState,
3218 layer); 3224 layer);
3219 LOG(INFO) << output.utf8().data(); 3225 LOG(INFO) << output.utf8().data();
3220 } 3226 }
3221 } 3227 }
3222 3228
3223 void showLayerTree(const blink::LayoutObject* layoutObject) { 3229 void showLayerTree(const blink::LayoutObject* layoutObject) {
3224 if (!layoutObject) { 3230 if (!layoutObject) {
3225 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3231 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3226 return; 3232 return;
3227 } 3233 }
3228 showLayerTree(layoutObject->enclosingLayer()); 3234 showLayerTree(layoutObject->enclosingLayer());
3229 } 3235 }
3230 #endif 3236 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698