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

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

Issue 2692853016: Change PaintLayer::m_layoutObject to a reference. (Closed)
Patch Set: restore inadvertantly removed null check 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 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer(); 552 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer();
553 if (!paintInvalidationLayer->groupedMapping()) 553 if (!paintInvalidationLayer->groupedMapping())
554 return; 554 return;
555 555
556 LayoutBoxModelObject* transformedAncestor = 556 LayoutBoxModelObject& transformedAncestor =
557 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject(); 557 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject();
chrishtr 2017/02/17 17:23:07 This looks like a bug in the old code. I think it'
chrishtr 2017/02/17 17:24:07 Make that: PaintLayer* transformedAncestorPaintL
szager1 2017/02/17 18:06:26 How about putting this in a separate patch? I don
558 if (!transformedAncestor)
559 return;
560 558
561 // |paintInvalidationContainer| may have a local 2D transform on it, so take 559 // |paintInvalidationContainer| may have a local 2D transform on it, so take
562 // that into account when mapping into the space of the transformed ancestor. 560 // that into account when mapping into the space of the transformed ancestor.
563 point = paintInvalidationContainer.localToAncestorPoint(point, 561 point = paintInvalidationContainer.localToAncestorPoint(point,
564 transformedAncestor); 562 &transformedAncestor);
565 563
566 point.moveBy(-paintInvalidationLayer->groupedMapping() 564 point.moveBy(-paintInvalidationLayer->groupedMapping()
567 ->squashingOffsetFromTransformedAncestor()); 565 ->squashingOffsetFromTransformedAncestor());
568 } 566 }
569 567
570 void PaintLayer::mapRectInPaintInvalidationContainerToBacking( 568 void PaintLayer::mapRectInPaintInvalidationContainerToBacking(
571 const LayoutBoxModelObject& paintInvalidationContainer, 569 const LayoutBoxModelObject& paintInvalidationContainer,
572 LayoutRect& rect) { 570 LayoutRect& rect) {
573 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer(); 571 PaintLayer* paintInvalidationLayer = paintInvalidationContainer.layer();
574 if (!paintInvalidationLayer->groupedMapping()) 572 if (!paintInvalidationLayer->groupedMapping())
575 return; 573 return;
576 574
577 LayoutBoxModelObject* transformedAncestor = 575 LayoutBoxModelObject& transformedAncestor =
578 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject(); 576 paintInvalidationLayer->enclosingTransformedAncestor()->layoutObject();
579 if (!transformedAncestor)
chrishtr 2017/02/17 17:23:07 ditto
580 return;
581 577
582 // |paintInvalidationContainer| may have a local 2D transform on it, so take 578 // |paintInvalidationContainer| may have a local 2D transform on it, so take
583 // that into account when mapping into the space of the transformed ancestor. 579 // that into account when mapping into the space of the transformed ancestor.
584 rect = 580 rect =
585 LayoutRect(paintInvalidationContainer 581 LayoutRect(paintInvalidationContainer
586 .localToAncestorQuad(FloatRect(rect), transformedAncestor) 582 .localToAncestorQuad(FloatRect(rect), &transformedAncestor)
587 .boundingBox()); 583 .boundingBox());
588 584
589 rect.moveBy(-paintInvalidationLayer->groupedMapping() 585 rect.moveBy(-paintInvalidationLayer->groupedMapping()
590 ->squashingOffsetFromTransformedAncestor()); 586 ->squashingOffsetFromTransformedAncestor());
591 } 587 }
592 588
593 void PaintLayer::mapRectToPaintInvalidationBacking( 589 void PaintLayer::mapRectToPaintInvalidationBacking(
594 const LayoutObject& layoutObject, 590 const LayoutObject& layoutObject,
595 const LayoutBoxModelObject& paintInvalidationContainer, 591 const LayoutBoxModelObject& paintInvalidationContainer,
596 LayoutRect& rect) { 592 LayoutRect& rect) {
(...skipping 25 matching lines...) Expand all
622 parent()->dirtyVisibleContentStatus(); 618 parent()->dirtyVisibleContentStatus();
623 } 619 }
624 620
625 void PaintLayer::markAncestorChainForDescendantDependentFlagsUpdate() { 621 void PaintLayer::markAncestorChainForDescendantDependentFlagsUpdate() {
626 for (PaintLayer* layer = this; layer; layer = layer->parent()) { 622 for (PaintLayer* layer = this; layer; layer = layer->parent()) {
627 if (layer->m_needsDescendantDependentFlagsUpdate) 623 if (layer->m_needsDescendantDependentFlagsUpdate)
628 break; 624 break;
629 layer->m_needsDescendantDependentFlagsUpdate = true; 625 layer->m_needsDescendantDependentFlagsUpdate = true;
630 626
631 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 627 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
632 layer->layoutObject()->setNeedsPaintPropertyUpdate(); 628 layer->layoutObject().setNeedsPaintPropertyUpdate();
633 } 629 }
634 } 630 }
635 631
636 // FIXME: this is quite brute-force. We could be more efficient if we were to 632 // 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 633 // track state and update it as appropriate as changes are made in the layout
638 // tree. 634 // tree.
639 void PaintLayer::updateScrollingStateAfterCompositingChange() { 635 void PaintLayer::updateScrollingStateAfterCompositingChange() {
640 TRACE_EVENT0("blink", 636 TRACE_EVENT0("blink",
641 "PaintLayer::updateScrollingStateAfterCompositingChange"); 637 "PaintLayer::updateScrollingStateAfterCompositingChange");
642 m_isAllScrollingContentComposited = true; 638 m_isAllScrollingContentComposited = true;
643 for (LayoutObject* r = layoutObject()->slowFirstChild(); r; 639 for (LayoutObject* r = layoutObject().slowFirstChild(); r;
644 r = r->nextSibling()) { 640 r = r->nextSibling()) {
645 if (!r->hasLayer()) { 641 if (!r->hasLayer()) {
646 m_isAllScrollingContentComposited = false; 642 m_isAllScrollingContentComposited = false;
647 return; 643 return;
648 } 644 }
649 } 645 }
650 646
651 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { 647 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) {
652 if (child->compositingState() == NotComposited) { 648 if (child->compositingState() == NotComposited) {
653 m_isAllScrollingContentComposited = false; 649 m_isAllScrollingContentComposited = false;
(...skipping 19 matching lines...) Expand all
673 for (PaintLayer* child = firstChild(); child; 669 for (PaintLayer* child = firstChild(); child;
674 child = child->nextSibling()) { 670 child = child->nextSibling()) {
675 child->updateDescendantDependentFlags(); 671 child->updateDescendantDependentFlags();
676 672
677 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant) 673 if (child->m_hasVisibleContent || child->m_hasVisibleDescendant)
678 m_hasVisibleDescendant = true; 674 m_hasVisibleDescendant = true;
679 675
680 m_hasNonIsolatedDescendantWithBlendMode |= 676 m_hasNonIsolatedDescendantWithBlendMode |=
681 (!child->stackingNode()->isStackingContext() && 677 (!child->stackingNode()->isStackingContext() &&
682 child->hasNonIsolatedDescendantWithBlendMode()) || 678 child->hasNonIsolatedDescendantWithBlendMode()) ||
683 child->layoutObject()->styleRef().hasBlendMode(); 679 child->layoutObject().styleRef().hasBlendMode();
684 680
685 m_hasDescendantWithClipPath |= child->hasDescendantWithClipPath() || 681 m_hasDescendantWithClipPath |= child->hasDescendantWithClipPath() ||
686 child->layoutObject()->hasClipPath(); 682 child->layoutObject().hasClipPath();
687 683
688 m_hasRootScrollerAsDescendant |= child->hasRootScrollerAsDescendant() || 684 m_hasRootScrollerAsDescendant |= child->hasRootScrollerAsDescendant() ||
689 (child == 685 (child ==
690 child->layoutObject() 686 child->layoutObject()
691 ->document() 687 .document()
692 .rootScrollerController() 688 .rootScrollerController()
693 .rootScrollerPaintLayer()); 689 .rootScrollerPaintLayer());
694 } 690 }
695 691
696 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 692 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
697 oldHasNonIsolatedDescendantWithBlendMode != 693 oldHasNonIsolatedDescendantWithBlendMode !=
698 static_cast<bool>(m_hasNonIsolatedDescendantWithBlendMode)) 694 static_cast<bool>(m_hasNonIsolatedDescendantWithBlendMode))
699 layoutObject()->setNeedsPaintPropertyUpdate(); 695 layoutObject().setNeedsPaintPropertyUpdate();
700 m_needsDescendantDependentFlagsUpdate = false; 696 m_needsDescendantDependentFlagsUpdate = false;
701 } 697 }
702 698
703 bool previouslyHasVisibleContent = m_hasVisibleContent; 699 bool previouslyHasVisibleContent = m_hasVisibleContent;
704 if (layoutObject()->style()->visibility() == EVisibility::kVisible) { 700 if (layoutObject().style()->visibility() == EVisibility::kVisible) {
705 m_hasVisibleContent = true; 701 m_hasVisibleContent = true;
706 } else { 702 } else {
707 // layer may be hidden but still have some visible content, check for this 703 // layer may be hidden but still have some visible content, check for this
708 m_hasVisibleContent = false; 704 m_hasVisibleContent = false;
709 LayoutObject* r = layoutObject()->slowFirstChild(); 705 LayoutObject* r = layoutObject().slowFirstChild();
710 while (r) { 706 while (r) {
711 if (r->style()->visibility() == EVisibility::kVisible && 707 if (r->style()->visibility() == EVisibility::kVisible &&
712 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 708 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
713 m_hasVisibleContent = true; 709 m_hasVisibleContent = true;
714 break; 710 break;
715 } 711 }
716 LayoutObject* layoutObjectFirstChild = r->slowFirstChild(); 712 LayoutObject* layoutObjectFirstChild = r->slowFirstChild();
717 if (layoutObjectFirstChild && 713 if (layoutObjectFirstChild &&
718 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) { 714 (!r->hasLayer() || !r->enclosingLayer()->isSelfPaintingLayer())) {
719 r = layoutObjectFirstChild; 715 r = layoutObjectFirstChild;
720 } else if (r->nextSibling()) { 716 } else if (r->nextSibling()) {
721 r = r->nextSibling(); 717 r = r->nextSibling();
722 } else { 718 } else {
723 do { 719 do {
724 r = r->parent(); 720 r = r->parent();
725 if (r == layoutObject()) 721 if (r == &layoutObject())
726 r = 0; 722 r = 0;
727 } while (r && !r->nextSibling()); 723 } while (r && !r->nextSibling());
728 if (r) 724 if (r)
729 r = r->nextSibling(); 725 r = r->nextSibling();
730 } 726 }
731 } 727 }
732 } 728 }
733 729
734 if (hasVisibleContent() != previouslyHasVisibleContent) { 730 if (hasVisibleContent() != previouslyHasVisibleContent) {
735 setNeedsCompositingInputsUpdateInternal(); 731 setNeedsCompositingInputsUpdateInternal();
736 // We need to tell m_layoutObject to recheck its rect because we 732 // We need to tell m_layoutObject to recheck its rect because we
737 // pretend that invisible LayoutObjects have 0x0 rects. Changing 733 // pretend that invisible LayoutObjects have 0x0 rects. Changing
738 // visibility therefore changes our rect and we need to visit 734 // visibility therefore changes our rect and we need to visit
739 // this LayoutObject during the invalidateTreeIfNeeded walk. 735 // this LayoutObject during the invalidateTreeIfNeeded walk.
740 m_layoutObject->setMayNeedPaintInvalidation(); 736 m_layoutObject.setMayNeedPaintInvalidation();
741 } 737 }
742 738
743 update3DTransformedDescendantStatus(); 739 update3DTransformedDescendantStatus();
744 } 740 }
745 741
746 void PaintLayer::update3DTransformedDescendantStatus() { 742 void PaintLayer::update3DTransformedDescendantStatus() {
747 m_has3DTransformedDescendant = false; 743 m_has3DTransformedDescendant = false;
748 744
749 m_stackingNode->updateZOrderLists(); 745 m_stackingNode->updateZOrderLists();
750 746
(...skipping 16 matching lines...) Expand all
767 m_has3DTransformedDescendant = true; 763 m_has3DTransformedDescendant = true;
768 break; 764 break;
769 } 765 }
770 } 766 }
771 } 767 }
772 768
773 void PaintLayer::updateLayerPosition() { 769 void PaintLayer::updateLayerPosition() {
774 LayoutPoint localPoint; 770 LayoutPoint localPoint;
775 771
776 bool didResize = false; 772 bool didResize = false;
777 if (layoutObject()->isInline() && layoutObject()->isLayoutInline()) { 773 if (layoutObject().isInline() && layoutObject().isLayoutInline()) {
778 LayoutInline* inlineFlow = toLayoutInline(layoutObject()); 774 LayoutInline& inlineFlow = toLayoutInline(layoutObject());
779 IntRect lineBox = enclosingIntRect(inlineFlow->linesBoundingBox()); 775 IntRect lineBox = enclosingIntRect(inlineFlow.linesBoundingBox());
780 m_size = lineBox.size(); 776 m_size = lineBox.size();
781 } else if (LayoutBox* box = layoutBox()) { 777 } else if (LayoutBox* box = layoutBox()) {
782 IntSize newSize = pixelSnappedIntSize(box->size(), box->location()); 778 IntSize newSize = pixelSnappedIntSize(box->size(), box->location());
783 didResize = newSize != m_size; 779 didResize = newSize != m_size;
784 m_size = newSize; 780 m_size = newSize;
785 localPoint.moveBy(box->physicalLocation()); 781 localPoint.moveBy(box->physicalLocation());
786 } 782 }
787 783
788 if (!layoutObject()->isOutOfFlowPositioned() && 784 if (!layoutObject().isOutOfFlowPositioned() &&
789 !layoutObject()->isColumnSpanAll()) { 785 !layoutObject().isColumnSpanAll()) {
790 // We must adjust our position by walking up the layout tree looking for the 786 // We must adjust our position by walking up the layout tree looking for the
791 // nearest enclosing object with a layer. 787 // nearest enclosing object with a layer.
792 LayoutObject* curr = layoutObject()->container(); 788 LayoutObject* curr = layoutObject().container();
793 while (curr && !curr->hasLayer()) { 789 while (curr && !curr->hasLayer()) {
794 if (curr->isBox() && !curr->isTableRow()) { 790 if (curr->isBox() && !curr->isTableRow()) {
795 // Rows and cells share the same coordinate space (that of the section). 791 // Rows and cells share the same coordinate space (that of the section).
796 // Omit them when computing our xpos/ypos. 792 // Omit them when computing our xpos/ypos.
797 localPoint.moveBy(toLayoutBox(curr)->physicalLocation()); 793 localPoint.moveBy(toLayoutBox(curr)->physicalLocation());
798 } 794 }
799 curr = curr->container(); 795 curr = curr->container();
800 } 796 }
801 if (curr && curr->isTableRow()) { 797 if (curr && curr->isTableRow()) {
802 // Put ourselves into the row coordinate space. 798 // Put ourselves into the row coordinate space.
803 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation()); 799 localPoint.moveBy(-toLayoutBox(curr)->physicalLocation());
804 } 800 }
805 } 801 }
806 802
807 if (PaintLayer* containingLayer = this->containingLayer()) { 803 if (PaintLayer* containingLayer = this->containingLayer()) {
808 if (containingLayer->layoutObject()->hasOverflowClip()) { 804 if (containingLayer->layoutObject().hasOverflowClip()) {
809 // Subtract our container's scroll offset. 805 // Subtract our container's scroll offset.
810 IntSize offset = containingLayer->layoutBox()->scrolledContentOffset(); 806 IntSize offset = containingLayer->layoutBox()->scrolledContentOffset();
811 localPoint -= offset; 807 localPoint -= offset;
812 } else if (layoutObject()->isAbsolutePositioned() && 808 } else if (layoutObject().isAbsolutePositioned() &&
813 containingLayer->layoutObject()->isInFlowPositioned() && 809 containingLayer->layoutObject().isInFlowPositioned() &&
814 containingLayer->layoutObject()->isLayoutInline()) { 810 containingLayer->layoutObject().isLayoutInline()) {
815 // Adjust offset for absolute under in-flow positioned inline. 811 // Adjust offset for absolute under in-flow positioned inline.
816 LayoutSize offset = 812 LayoutSize offset =
817 toLayoutInline(containingLayer->layoutObject()) 813 toLayoutInline(containingLayer->layoutObject())
818 ->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); 814 .offsetForInFlowPositionedInline(toLayoutBox(layoutObject()));
819 localPoint += offset; 815 localPoint += offset;
820 } 816 }
821 } 817 }
822 818
823 if (layoutObject()->isInFlowPositioned()) { 819 if (layoutObject().isInFlowPositioned()) {
824 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); 820 LayoutSize newOffset = layoutObject().offsetForInFlowPosition();
825 if (m_rareData || !newOffset.isZero()) 821 if (m_rareData || !newOffset.isZero())
826 ensureRareData().offsetForInFlowPosition = newOffset; 822 ensureRareData().offsetForInFlowPosition = newOffset;
827 localPoint.move(newOffset); 823 localPoint.move(newOffset);
828 } else if (m_rareData) { 824 } else if (m_rareData) {
829 m_rareData->offsetForInFlowPosition = LayoutSize(); 825 m_rareData->offsetForInFlowPosition = LayoutSize();
830 } 826 }
831 827
832 m_location = localPoint; 828 m_location = localPoint;
833 829
834 if (m_scrollableArea && didResize) 830 if (m_scrollableArea && didResize)
835 m_scrollableArea->visibleSizeChanged(); 831 m_scrollableArea->visibleSizeChanged();
836 832
837 #if DCHECK_IS_ON() 833 #if DCHECK_IS_ON()
838 m_needsPositionUpdate = false; 834 m_needsPositionUpdate = false;
839 #endif 835 #endif
840 } 836 }
841 837
842 TransformationMatrix PaintLayer::perspectiveTransform() const { 838 TransformationMatrix PaintLayer::perspectiveTransform() const {
843 if (!layoutObject()->hasTransformRelatedProperty()) 839 if (!layoutObject().hasTransformRelatedProperty())
844 return TransformationMatrix(); 840 return TransformationMatrix();
845 841
846 const ComputedStyle& style = layoutObject()->styleRef(); 842 const ComputedStyle& style = layoutObject().styleRef();
847 if (!style.hasPerspective()) 843 if (!style.hasPerspective())
848 return TransformationMatrix(); 844 return TransformationMatrix();
849 845
850 TransformationMatrix t; 846 TransformationMatrix t;
851 t.applyPerspective(style.perspective()); 847 t.applyPerspective(style.perspective());
852 return t; 848 return t;
853 } 849 }
854 850
855 FloatPoint PaintLayer::perspectiveOrigin() const { 851 FloatPoint PaintLayer::perspectiveOrigin() const {
856 if (!layoutObject()->hasTransformRelatedProperty()) 852 if (!layoutObject().hasTransformRelatedProperty())
857 return FloatPoint(); 853 return FloatPoint();
858 854
859 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); 855 const LayoutRect borderBox = toLayoutBox(layoutObject()).borderBoxRect();
860 const ComputedStyle& style = layoutObject()->styleRef(); 856 const ComputedStyle& style = layoutObject().styleRef();
861 857
862 return FloatPoint(floatValueForLength(style.perspectiveOriginX(), 858 return FloatPoint(floatValueForLength(style.perspectiveOriginX(),
863 borderBox.width().toFloat()), 859 borderBox.width().toFloat()),
864 floatValueForLength(style.perspectiveOriginY(), 860 floatValueForLength(style.perspectiveOriginY(),
865 borderBox.height().toFloat())); 861 borderBox.height().toFloat()));
866 } 862 }
867 863
868 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor, 864 PaintLayer* PaintLayer::containingLayer(const PaintLayer* ancestor,
869 bool* skippedAncestor) const { 865 bool* skippedAncestor) const {
870 // If we have specified an ancestor, surely the caller needs to know whether 866 // If we have specified an ancestor, surely the caller needs to know whether
871 // we skipped it. 867 // we skipped it.
872 DCHECK(!ancestor || skippedAncestor); 868 DCHECK(!ancestor || skippedAncestor);
873 if (skippedAncestor) 869 if (skippedAncestor)
874 *skippedAncestor = false; 870 *skippedAncestor = false;
875 871
876 LayoutObject* layoutObject = this->layoutObject(); 872 LayoutObject& layoutObject = this->layoutObject();
877 if (layoutObject->isColumnSpanAll() || 873 if (layoutObject.isColumnSpanAll() ||
878 layoutObject->isFloatingWithNonContainingBlockParent()) { 874 layoutObject.isFloatingWithNonContainingBlockParent()) {
879 Optional<LayoutObject::AncestorSkipInfo> skipInfo; 875 Optional<LayoutObject::AncestorSkipInfo> skipInfo;
880 if (skippedAncestor) 876 if (skippedAncestor)
881 skipInfo.emplace(ancestor->layoutObject()); 877 skipInfo.emplace(&ancestor->layoutObject());
882 if (auto containingBlock = layoutObject->containingBlock( 878 if (auto containingBlock = layoutObject.containingBlock(
883 skippedAncestor ? &*skipInfo : nullptr)) { 879 skippedAncestor ? &*skipInfo : nullptr)) {
884 if (skippedAncestor && skipInfo->ancestorSkipped()) 880 if (skippedAncestor && skipInfo->ancestorSkipped())
885 *skippedAncestor = true; 881 *skippedAncestor = true;
886 return containingBlock->enclosingLayer(); 882 return containingBlock->enclosingLayer();
887 } 883 }
888 return nullptr; 884 return nullptr;
889 } 885 }
890 886
891 if (layoutObject->isOutOfFlowPositioned()) { 887 if (layoutObject.isOutOfFlowPositioned()) {
892 auto canContainThisLayer = 888 auto canContainThisLayer =
893 layoutObject->isFixedPositioned() 889 layoutObject.isFixedPositioned()
894 ? &LayoutObject::canContainFixedPositionObjects 890 ? &LayoutObject::canContainFixedPositionObjects
895 : &LayoutObject::canContainAbsolutePositionObjects; 891 : &LayoutObject::canContainAbsolutePositionObjects;
896 892
897 PaintLayer* curr = parent(); 893 PaintLayer* curr = parent();
898 while (curr && !(curr->layoutObject()->*canContainThisLayer)()) { 894 while (curr && !((&curr->layoutObject())->*canContainThisLayer)()) {
899 if (skippedAncestor && curr == ancestor) 895 if (skippedAncestor && curr == ancestor)
900 *skippedAncestor = true; 896 *skippedAncestor = true;
901 curr = curr->parent(); 897 curr = curr->parent();
902 } 898 }
903 return curr; 899 return curr;
904 } 900 }
905 901
906 return parent(); 902 return parent();
907 } 903 }
908 904
909 PaintLayer* PaintLayer::enclosingTransformedAncestor() const { 905 PaintLayer* PaintLayer::enclosingTransformedAncestor() const {
910 PaintLayer* curr = parent(); 906 PaintLayer* curr = parent();
911 while (curr && !curr->isRootLayer() && !curr->transform()) 907 while (curr && !curr->isRootLayer() && !curr->transform())
912 curr = curr->parent(); 908 curr = curr->parent();
913 909
914 return curr; 910 return curr;
915 } 911 }
916 912
917 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const { 913 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const {
918 TransformState transformState(TransformState::ApplyTransformDirection, 914 TransformState transformState(TransformState::ApplyTransformDirection,
919 FloatPoint()); 915 FloatPoint());
920 layoutObject()->mapLocalToAncestor( 916 layoutObject().mapLocalToAncestor(
921 transformAncestor() ? transformAncestor()->layoutObject() : nullptr, 917 transformAncestor() ? &transformAncestor()->layoutObject() : nullptr,
922 transformState, 0); 918 transformState, 0);
923 transformState.flatten(); 919 transformState.flatten();
924 return LayoutPoint(transformState.lastPlanarPoint()); 920 return LayoutPoint(transformState.lastPlanarPoint());
925 } 921 }
926 922
927 PaintLayer* PaintLayer::compositingContainer() const { 923 PaintLayer* PaintLayer::compositingContainer() const {
928 if (!stackingNode()->isStacked()) 924 if (!stackingNode()->isStacked())
929 return isSelfPaintingLayer() ? parent() : containingLayer(); 925 return isSelfPaintingLayer() ? parent() : containingLayer();
930 if (PaintLayerStackingNode* ancestorStackingNode = 926 if (PaintLayerStackingNode* ancestorStackingNode =
931 stackingNode()->ancestorStackingContextNode()) 927 stackingNode()->ancestorStackingContextNode())
(...skipping 29 matching lines...) Expand all
961 957
962 // Return the enclosingCompositedLayerForPaintInvalidation for the given Layer 958 // Return the enclosingCompositedLayerForPaintInvalidation for the given Layer
963 // including crossing frame boundaries. 959 // including crossing frame boundaries.
964 PaintLayer* 960 PaintLayer*
965 PaintLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const { 961 PaintLayer::enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const {
966 const PaintLayer* layer = this; 962 const PaintLayer* layer = this;
967 PaintLayer* compositedLayer = 0; 963 PaintLayer* compositedLayer = 0;
968 while (!compositedLayer) { 964 while (!compositedLayer) {
969 compositedLayer = layer->enclosingLayerForPaintInvalidation(); 965 compositedLayer = layer->enclosingLayerForPaintInvalidation();
970 if (!compositedLayer) { 966 if (!compositedLayer) {
971 CHECK(layer->layoutObject()->frame()); 967 CHECK(layer->layoutObject().frame());
972 LayoutItem owner = layer->layoutObject()->frame()->ownerLayoutItem(); 968 LayoutItem owner = layer->layoutObject().frame()->ownerLayoutItem();
973 if (owner.isNull()) 969 if (owner.isNull())
974 break; 970 break;
975 layer = owner.enclosingLayer(); 971 layer = owner.enclosingLayer();
976 } 972 }
977 } 973 }
978 return compositedLayer; 974 return compositedLayer;
979 } 975 }
980 976
981 PaintLayer* PaintLayer::enclosingLayerForPaintInvalidation() const { 977 PaintLayer* PaintLayer::enclosingLayerForPaintInvalidation() const {
982 DCHECK(isAllowedToQueryCompositingState()); 978 DCHECK(isAllowedToQueryCompositingState());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 void PaintLayer::didUpdateCompositingInputs() { 1023 void PaintLayer::didUpdateCompositingInputs() {
1028 DCHECK(!needsCompositingInputsUpdate()); 1024 DCHECK(!needsCompositingInputsUpdate());
1029 m_childNeedsCompositingInputsUpdate = false; 1025 m_childNeedsCompositingInputsUpdate = false;
1030 if (m_scrollableArea) 1026 if (m_scrollableArea)
1031 m_scrollableArea->updateNeedsCompositedScrolling(); 1027 m_scrollableArea->updateNeedsCompositedScrolling();
1032 } 1028 }
1033 1029
1034 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const { 1030 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const {
1035 if (m_hasNonIsolatedDescendantWithBlendMode) 1031 if (m_hasNonIsolatedDescendantWithBlendMode)
1036 return true; 1032 return true;
1037 if (layoutObject()->isSVGRoot()) 1033 if (layoutObject().isSVGRoot())
1038 return toLayoutSVGRoot(layoutObject())->hasNonIsolatedBlendingDescendants(); 1034 return toLayoutSVGRoot(layoutObject()).hasNonIsolatedBlendingDescendants();
1039 return false; 1035 return false;
1040 } 1036 }
1041 1037
1042 void PaintLayer::setCompositingReasons(CompositingReasons reasons, 1038 void PaintLayer::setCompositingReasons(CompositingReasons reasons,
1043 CompositingReasons mask) { 1039 CompositingReasons mask) {
1044 CompositingReasons oldReasons = 1040 CompositingReasons oldReasons =
1045 m_rareData ? m_rareData->compositingReasons : CompositingReasonNone; 1041 m_rareData ? m_rareData->compositingReasons : CompositingReasonNone;
1046 if ((oldReasons & mask) == (reasons & mask)) 1042 if ((oldReasons & mask) == (reasons & mask))
1047 return; 1043 return;
1048 CompositingReasons newReasons = (reasons & mask) | (oldReasons & ~mask); 1044 CompositingReasons newReasons = (reasons & mask) | (oldReasons & ~mask);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1092
1097 static void expandClipRectForDescendants( 1093 static void expandClipRectForDescendants(
1098 LayoutRect& clipRect, 1094 LayoutRect& clipRect,
1099 const PaintLayer* layer, 1095 const PaintLayer* layer,
1100 const PaintLayer* rootLayer, 1096 const PaintLayer* rootLayer,
1101 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior, 1097 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior,
1102 const LayoutSize& subPixelAccumulation, 1098 const LayoutSize& subPixelAccumulation,
1103 GlobalPaintFlags globalPaintFlags) { 1099 GlobalPaintFlags globalPaintFlags) {
1104 // If we have a mask, then the clip is limited to the border box area (and 1100 // 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). 1101 // there is no need to examine child layers).
1106 if (!layer->layoutObject()->hasMask()) { 1102 if (!layer->layoutObject().hasMask()) {
1107 // Note: we don't have to walk z-order lists since transparent elements 1103 // 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 1104 // always establish a stacking container. This means we can just walk the
1109 // layer tree directly. 1105 // layer tree directly.
1110 for (PaintLayer* curr = layer->firstChild(); curr; 1106 for (PaintLayer* curr = layer->firstChild(); curr;
1111 curr = curr->nextSibling()) 1107 curr = curr->nextSibling())
1112 clipRect.unite(PaintLayer::transparencyClipBox( 1108 clipRect.unite(PaintLayer::transparencyClipBox(
1113 curr, rootLayer, transparencyBehavior, 1109 curr, rootLayer, transparencyBehavior,
1114 PaintLayer::DescendantsOfTransparencyClipBox, subPixelAccumulation, 1110 PaintLayer::DescendantsOfTransparencyClipBox, subPixelAccumulation,
1115 globalPaintFlags)); 1111 globalPaintFlags));
1116 } 1112 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 expandClipRectForDescendants(clipRect, layer, layer, transparencyBehavior, 1153 expandClipRectForDescendants(clipRect, layer, layer, transparencyBehavior,
1158 subPixelAccumulation, globalPaintFlags); 1154 subPixelAccumulation, globalPaintFlags);
1159 LayoutRect result = enclosingLayoutRect( 1155 LayoutRect result = enclosingLayoutRect(
1160 transform.mapRect(layer->mapRectForFilter(FloatRect(clipRect)))); 1156 transform.mapRect(layer->mapRectForFilter(FloatRect(clipRect))));
1161 if (!paginationLayer) 1157 if (!paginationLayer)
1162 return result; 1158 return result;
1163 1159
1164 // We have to break up the transformed extent across our columns. 1160 // 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 1161 // 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. 1162 // columns/pages and unite those together to get our true bounding box.
1167 LayoutFlowThread* enclosingFlowThread = 1163 LayoutFlowThread& enclosingFlowThread =
1168 toLayoutFlowThread(paginationLayer->layoutObject()); 1164 toLayoutFlowThread(paginationLayer->layoutObject());
1169 result = enclosingFlowThread->fragmentsBoundingBox(result); 1165 result = enclosingFlowThread.fragmentsBoundingBox(result);
1170 1166
1171 LayoutPoint rootLayerDelta; 1167 LayoutPoint rootLayerDelta;
1172 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta); 1168 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
1173 result.moveBy(rootLayerDelta); 1169 result.moveBy(rootLayerDelta);
1174 return result; 1170 return result;
1175 } 1171 }
1176 1172
1177 LayoutRect clipRect = layer->shouldFragmentCompositedBounds(rootLayer) 1173 LayoutRect clipRect = layer->shouldFragmentCompositedBounds(rootLayer)
1178 ? layer->fragmentsBoundingBox(rootLayer) 1174 ? layer->fragmentsBoundingBox(rootLayer)
1179 : layer->physicalBoundingBox(rootLayer); 1175 : layer->physicalBoundingBox(rootLayer);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 1226
1231 child->m_parent = this; 1227 child->m_parent = this;
1232 1228
1233 // The ancestor overflow layer is calculated during compositing inputs update 1229 // The ancestor overflow layer is calculated during compositing inputs update
1234 // and should not be set yet. 1230 // and should not be set yet.
1235 CHECK(!child->ancestorOverflowLayer()); 1231 CHECK(!child->ancestorOverflowLayer());
1236 1232
1237 setNeedsCompositingInputsUpdate(); 1233 setNeedsCompositingInputsUpdate();
1238 1234
1239 if (!child->stackingNode()->isStacked() && 1235 if (!child->stackingNode()->isStacked() &&
1240 !layoutObject()->documentBeingDestroyed()) 1236 !layoutObject().documentBeingDestroyed())
1241 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1237 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1242 1238
1243 if (child->stackingNode()->isStacked() || child->firstChild()) { 1239 if (child->stackingNode()->isStacked() || child->firstChild()) {
1244 // Dirty the z-order list in which we are contained. The 1240 // Dirty the z-order list in which we are contained. The
1245 // ancestorStackingContextNode() can be null in the case where we're 1241 // ancestorStackingContextNode() can be null in the case where we're
1246 // building up generated content layers. This is ok, since the lists will 1242 // building up generated content layers. This is ok, since the lists will
1247 // start off dirty in that case anyway. 1243 // start off dirty in that case anyway.
1248 child->stackingNode()->dirtyStackingContextZOrderLists(); 1244 child->stackingNode()->dirtyStackingContextZOrderLists();
1249 } 1245 }
1250 1246
(...skipping 13 matching lines...) Expand all
1264 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); 1260 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
1265 if (oldChild->nextSibling()) 1261 if (oldChild->nextSibling())
1266 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling()); 1262 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
1267 1263
1268 if (m_first == oldChild) 1264 if (m_first == oldChild)
1269 m_first = oldChild->nextSibling(); 1265 m_first = oldChild->nextSibling();
1270 if (m_last == oldChild) 1266 if (m_last == oldChild)
1271 m_last = oldChild->previousSibling(); 1267 m_last = oldChild->previousSibling();
1272 1268
1273 if (!oldChild->stackingNode()->isStacked() && 1269 if (!oldChild->stackingNode()->isStacked() &&
1274 !layoutObject()->documentBeingDestroyed()) 1270 !layoutObject().documentBeingDestroyed())
1275 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 1271 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
1276 1272
1277 if (oldChild->stackingNode()->isStacked() || oldChild->firstChild()) { 1273 if (oldChild->stackingNode()->isStacked() || oldChild->firstChild()) {
1278 // Dirty the z-order list in which we are contained. When called via the 1274 // Dirty the z-order list in which we are contained. When called via the
1279 // reattachment process in removeOnlyThisLayer, the layer may already be 1275 // reattachment process in removeOnlyThisLayer, the layer may already be
1280 // disconnected from the main layer tree, so we need to null-check the 1276 // disconnected from the main layer tree, so we need to null-check the
1281 // |stackingContext| value. 1277 // |stackingContext| value.
1282 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); 1278 oldChild->stackingNode()->dirtyStackingContextZOrderLists();
1283 } 1279 }
1284 1280
1285 if (layoutObject()->style()->visibility() != EVisibility::kVisible) 1281 if (layoutObject().style()->visibility() != EVisibility::kVisible)
1286 dirtyVisibleContentStatus(); 1282 dirtyVisibleContentStatus();
1287 1283
1288 oldChild->setPreviousSibling(0); 1284 oldChild->setPreviousSibling(0);
1289 oldChild->setNextSibling(0); 1285 oldChild->setNextSibling(0);
1290 oldChild->m_parent = 0; 1286 oldChild->m_parent = 0;
1291 1287
1292 // Remove any ancestor overflow layers which descended into the removed child. 1288 // Remove any ancestor overflow layers which descended into the removed child.
1293 if (oldChild->ancestorOverflowLayer()) 1289 if (oldChild->ancestorOverflowLayer())
1294 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer()); 1290 oldChild->removeAncestorOverflowLayer(oldChild->ancestorOverflowLayer());
1295 1291
(...skipping 16 matching lines...) Expand all
1312 1308
1313 bool didSetPaintInvalidation = false; 1309 bool didSetPaintInvalidation = false;
1314 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1310 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1315 DisableCompositingQueryAsserts 1311 DisableCompositingQueryAsserts
1316 disabler; // We need the current compositing status. 1312 disabler; // We need the current compositing status.
1317 if (isPaintInvalidationContainer()) { 1313 if (isPaintInvalidationContainer()) {
1318 // Our children will be reparented and contained by a new paint 1314 // Our children will be reparented and contained by a new paint
1319 // invalidation container, so need paint invalidation. CompositingUpdate 1315 // invalidation container, so need paint invalidation. CompositingUpdate
1320 // can't see this layer (which has been removed) so won't do this for us. 1316 // can't see this layer (which has been removed) so won't do this for us.
1321 DisablePaintInvalidationStateAsserts disabler; 1317 DisablePaintInvalidationStateAsserts disabler;
1322 ObjectPaintInvalidator(*layoutObject()) 1318 ObjectPaintInvalidator(layoutObject())
1323 .invalidatePaintIncludingNonCompositingDescendants(); 1319 .invalidatePaintIncludingNonCompositingDescendants();
1324 layoutObject() 1320 layoutObject()
1325 ->setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants() ; 1321 .setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1326 didSetPaintInvalidation = true; 1322 didSetPaintInvalidation = true;
1327 } 1323 }
1328 } 1324 }
1329 1325
1330 if (!didSetPaintInvalidation && isSelfPaintingLayer()) { 1326 if (!didSetPaintInvalidation && isSelfPaintingLayer()) {
1331 if (PaintLayer* enclosingSelfPaintingLayer = 1327 if (PaintLayer* enclosingSelfPaintingLayer =
1332 m_parent->enclosingSelfPaintingLayer()) 1328 m_parent->enclosingSelfPaintingLayer())
1333 enclosingSelfPaintingLayer->mergeNeedsPaintPhaseFlagsFrom(*this); 1329 enclosingSelfPaintingLayer->mergeNeedsPaintPhaseFlagsFrom(*this);
1334 } 1330 }
1335 1331
1336 clipper(PaintLayer::DoNotUseGeometryMapper) 1332 clipper(PaintLayer::DoNotUseGeometryMapper)
1337 .clearClipRectsIncludingDescendants(); 1333 .clearClipRectsIncludingDescendants();
1338 1334
1339 PaintLayer* nextSib = nextSibling(); 1335 PaintLayer* nextSib = nextSibling();
1340 1336
1341 // Now walk our kids and reattach them to our parent. 1337 // Now walk our kids and reattach them to our parent.
1342 PaintLayer* current = m_first; 1338 PaintLayer* current = m_first;
1343 while (current) { 1339 while (current) {
1344 PaintLayer* next = current->nextSibling(); 1340 PaintLayer* next = current->nextSibling();
1345 removeChild(current); 1341 removeChild(current);
1346 m_parent->addChild(current, nextSib); 1342 m_parent->addChild(current, nextSib);
1347 1343
1348 // FIXME: We should call a specialized version of this function. 1344 // FIXME: We should call a specialized version of this function.
1349 current->updateLayerPositionsAfterLayout(); 1345 current->updateLayerPositionsAfterLayout();
1350 current = next; 1346 current = next;
1351 } 1347 }
1352 1348
1353 // Remove us from the parent. 1349 // Remove us from the parent.
1354 m_parent->removeChild(this); 1350 m_parent->removeChild(this);
1355 m_layoutObject->destroyLayer(); 1351 m_layoutObject.destroyLayer();
1356 } 1352 }
1357 1353
1358 void PaintLayer::insertOnlyThisLayerAfterStyleChange() { 1354 void PaintLayer::insertOnlyThisLayerAfterStyleChange() {
1359 if (!m_parent && layoutObject()->parent()) { 1355 if (!m_parent && layoutObject().parent()) {
1360 // We need to connect ourselves when our layoutObject() has a parent. 1356 // We need to connect ourselves when our layoutObject() has a parent.
1361 // Find our enclosingLayer and add ourselves. 1357 // Find our enclosingLayer and add ourselves.
1362 PaintLayer* parentLayer = layoutObject()->parent()->enclosingLayer(); 1358 PaintLayer* parentLayer = layoutObject().parent()->enclosingLayer();
1363 DCHECK(parentLayer); 1359 DCHECK(parentLayer);
1364 PaintLayer* beforeChild = 1360 PaintLayer* beforeChild =
1365 layoutObject()->parent()->findNextLayer(parentLayer, layoutObject()); 1361 layoutObject().parent()->findNextLayer(parentLayer, &layoutObject());
1366 parentLayer->addChild(this, beforeChild); 1362 parentLayer->addChild(this, beforeChild);
1367 } 1363 }
1368 1364
1369 // Remove all descendant layers from the hierarchy and add them to the new 1365 // Remove all descendant layers from the hierarchy and add them to the new
1370 // position. 1366 // position.
1371 for (LayoutObject* curr = layoutObject()->slowFirstChild(); curr; 1367 for (LayoutObject* curr = layoutObject().slowFirstChild(); curr;
1372 curr = curr->nextSibling()) 1368 curr = curr->nextSibling())
1373 curr->moveLayers(m_parent, this); 1369 curr->moveLayers(m_parent, this);
1374 1370
1375 // If the previous paint invalidation container is not a stacking context and 1371 // 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 1372 // this object is stacked content, creating this layer may cause this object
1377 // and its descendants to change paint invalidation container. 1373 // and its descendants to change paint invalidation container.
1378 bool didSetPaintInvalidation = false; 1374 bool didSetPaintInvalidation = false;
1379 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 1375 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
1380 !layoutObject()->isLayoutView() && layoutObject()->isRooted() && 1376 !layoutObject().isLayoutView() && layoutObject().isRooted() &&
1381 layoutObject()->styleRef().isStacked()) { 1377 layoutObject().styleRef().isStacked()) {
1382 const LayoutBoxModelObject& previousPaintInvalidationContainer = 1378 const LayoutBoxModelObject& previousPaintInvalidationContainer =
1383 layoutObject()->parent()->containerForPaintInvalidation(); 1379 layoutObject().parent()->containerForPaintInvalidation();
1384 if (!previousPaintInvalidationContainer.styleRef().isStackingContext()) { 1380 if (!previousPaintInvalidationContainer.styleRef().isStackingContext()) {
1385 ObjectPaintInvalidator(*layoutObject()) 1381 ObjectPaintInvalidator(layoutObject())
1386 .invalidatePaintIncludingNonSelfPaintingLayerDescendants( 1382 .invalidatePaintIncludingNonSelfPaintingLayerDescendants(
1387 previousPaintInvalidationContainer); 1383 previousPaintInvalidationContainer);
1388 // Set needsRepaint along the original compositingContainer chain. 1384 // Set needsRepaint along the original compositingContainer chain.
1389 layoutObject()->parent()->enclosingLayer()->setNeedsRepaint(); 1385 layoutObject().parent()->enclosingLayer()->setNeedsRepaint();
1390 didSetPaintInvalidation = true; 1386 didSetPaintInvalidation = true;
1391 } 1387 }
1392 } 1388 }
1393 1389
1394 if (!didSetPaintInvalidation && isSelfPaintingLayer() && m_parent) { 1390 if (!didSetPaintInvalidation && isSelfPaintingLayer() && m_parent) {
1395 if (PaintLayer* enclosingSelfPaintingLayer = 1391 if (PaintLayer* enclosingSelfPaintingLayer =
1396 m_parent->enclosingSelfPaintingLayer()) 1392 m_parent->enclosingSelfPaintingLayer())
1397 mergeNeedsPaintPhaseFlagsFrom(*enclosingSelfPaintingLayer); 1393 mergeNeedsPaintPhaseFlagsFrom(*enclosingSelfPaintingLayer);
1398 } 1394 }
1399 1395
1400 // Clear out all the clip rects. 1396 // Clear out all the clip rects.
1401 clipper(PaintLayer::DoNotUseGeometryMapper) 1397 clipper(PaintLayer::DoNotUseGeometryMapper)
1402 .clearClipRectsIncludingDescendants(); 1398 .clearClipRectsIncludingDescendants();
1403 } 1399 }
1404 1400
1405 // Returns the layer reached on the walk up towards the ancestor. 1401 // Returns the layer reached on the walk up towards the ancestor.
1406 static inline const PaintLayer* accumulateOffsetTowardsAncestor( 1402 static inline const PaintLayer* accumulateOffsetTowardsAncestor(
1407 const PaintLayer* layer, 1403 const PaintLayer* layer,
1408 const PaintLayer* ancestorLayer, 1404 const PaintLayer* ancestorLayer,
1409 LayoutPoint& location) { 1405 LayoutPoint& location) {
1410 DCHECK(ancestorLayer != layer); 1406 DCHECK(ancestorLayer != layer);
1411 1407
1412 const LayoutBoxModelObject* layoutObject = layer->layoutObject(); 1408 const LayoutBoxModelObject& layoutObject = layer->layoutObject();
1413 1409
1414 if (layoutObject->isFixedPositioned() && 1410 if (layoutObject.isFixedPositioned() &&
1415 (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) { 1411 (!ancestorLayer || ancestorLayer == layoutObject.view()->layer())) {
1416 // If the fixed layer's container is the root, just add in the offset of the 1412 // 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. 1413 // view. We can obtain this by calling localToAbsolute() on the LayoutView.
1418 FloatPoint absPos = layoutObject->localToAbsolute(); 1414 FloatPoint absPos = layoutObject.localToAbsolute();
1419 location += LayoutSize(absPos.x(), absPos.y()); 1415 location += LayoutSize(absPos.x(), absPos.y());
1420 return ancestorLayer; 1416 return ancestorLayer;
1421 } 1417 }
1422 1418
1423 bool foundAncestorFirst; 1419 bool foundAncestorFirst;
1424 PaintLayer* containingLayer = 1420 PaintLayer* containingLayer =
1425 layer->containingLayer(ancestorLayer, &foundAncestorFirst); 1421 layer->containingLayer(ancestorLayer, &foundAncestorFirst);
1426 1422
1427 if (foundAncestorFirst) { 1423 if (foundAncestorFirst) {
1428 // Found ancestorLayer before the containing layer, so compute offset of 1424 // 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) 1464 if (ancestorLayer == this)
1469 return offset; 1465 return offset;
1470 PaintLayer* paginationLayer = enclosingPaginationLayer(); 1466 PaintLayer* paginationLayer = enclosingPaginationLayer();
1471 if (paginationLayer == this) 1467 if (paginationLayer == this)
1472 paginationLayer = parent()->enclosingPaginationLayer(); 1468 paginationLayer = parent()->enclosingPaginationLayer();
1473 if (!paginationLayer) { 1469 if (!paginationLayer) {
1474 convertToLayerCoords(ancestorLayer, offset); 1470 convertToLayerCoords(ancestorLayer, offset);
1475 return offset; 1471 return offset;
1476 } 1472 }
1477 1473
1478 LayoutFlowThread* flowThread = 1474 LayoutFlowThread& flowThread =
1479 toLayoutFlowThread(paginationLayer->layoutObject()); 1475 toLayoutFlowThread(paginationLayer->layoutObject());
1480 convertToLayerCoords(paginationLayer, offset); 1476 convertToLayerCoords(paginationLayer, offset);
1481 offset = flowThread->flowThreadPointToVisualPoint(offset); 1477 offset = flowThread.flowThreadPointToVisualPoint(offset);
1482 if (ancestorLayer == paginationLayer) 1478 if (ancestorLayer == paginationLayer)
1483 return offset; 1479 return offset;
1484 1480
1485 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) { 1481 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) {
1486 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); 1482 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer));
1487 } else { 1483 } else {
1488 // The ancestor layer is also inside the pagination layer, so we need to 1484 // 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 1485 // subtract the visual distance from the ancestor layer to the pagination
1490 // layer. 1486 // layer.
1491 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); 1487 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer));
(...skipping 15 matching lines...) Expand all
1507 1503
1508 void PaintLayer::updateScrollableArea() { 1504 void PaintLayer::updateScrollableArea() {
1509 DCHECK(!m_scrollableArea); 1505 DCHECK(!m_scrollableArea);
1510 if (requiresScrollableArea()) 1506 if (requiresScrollableArea())
1511 m_scrollableArea = PaintLayerScrollableArea::create(*this); 1507 m_scrollableArea = PaintLayerScrollableArea::create(*this);
1512 } 1508 }
1513 1509
1514 bool PaintLayer::hasOverflowControls() const { 1510 bool PaintLayer::hasOverflowControls() const {
1515 return m_scrollableArea && (m_scrollableArea->hasScrollbar() || 1511 return m_scrollableArea && (m_scrollableArea->hasScrollbar() ||
1516 m_scrollableArea->scrollCorner() || 1512 m_scrollableArea->scrollCorner() ||
1517 layoutObject()->style()->resize() != RESIZE_NONE); 1513 layoutObject().style()->resize() != RESIZE_NONE);
1518 } 1514 }
1519 1515
1520 void PaintLayer::appendSingleFragmentIgnoringPagination( 1516 void PaintLayer::appendSingleFragmentIgnoringPagination(
1521 PaintLayerFragments& fragments, 1517 PaintLayerFragments& fragments,
1522 const PaintLayer* rootLayer, 1518 const PaintLayer* rootLayer,
1523 const LayoutRect& dirtyRect, 1519 const LayoutRect& dirtyRect,
1524 ClipRectsCacheSlot clipRectsCacheSlot, 1520 ClipRectsCacheSlot clipRectsCacheSlot,
1525 PaintLayer::GeometryMapperOption geometryMapperOption, 1521 PaintLayer::GeometryMapperOption geometryMapperOption,
1526 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior, 1522 OverlayScrollbarClipBehavior overlayScrollbarClipBehavior,
1527 ShouldRespectOverflowClipType respectOverflowClip, 1523 ShouldRespectOverflowClipType respectOverflowClip,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 LayoutRect(LayoutRect::infiniteIntRect()), 1586 LayoutRect(LayoutRect::infiniteIntRect()),
1591 layerBoundsInFlowThread, backgroundRectInFlowThread, 1587 layerBoundsInFlowThread, backgroundRectInFlowThread,
1592 foregroundRectInFlowThread, &offsetWithinPaginatedLayer); 1588 foregroundRectInFlowThread, &offsetWithinPaginatedLayer);
1593 1589
1594 // Take our bounding box within the flow thread and clip it. 1590 // Take our bounding box within the flow thread and clip it.
1595 LayoutRect layerBoundingBoxInFlowThread = 1591 LayoutRect layerBoundingBoxInFlowThread =
1596 layerBoundingBox ? *layerBoundingBox 1592 layerBoundingBox ? *layerBoundingBox
1597 : physicalBoundingBox(offsetWithinPaginatedLayer); 1593 : physicalBoundingBox(offsetWithinPaginatedLayer);
1598 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); 1594 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect());
1599 1595
1600 LayoutFlowThread* enclosingFlowThread = 1596 LayoutFlowThread& enclosingFlowThread =
1601 toLayoutFlowThread(enclosingPaginationLayer()->layoutObject()); 1597 toLayoutFlowThread(enclosingPaginationLayer()->layoutObject());
1602 // Visual offset from the root layer to the nearest fragmentation context. 1598 // Visual offset from the root layer to the nearest fragmentation context.
1603 LayoutPoint offsetOfPaginationLayerFromRoot; 1599 LayoutPoint offsetOfPaginationLayerFromRoot;
1604 bool rootLayerIsInsidePaginationLayer = 1600 bool rootLayerIsInsidePaginationLayer =
1605 rootLayer->enclosingPaginationLayer() == enclosingPaginationLayer(); 1601 rootLayer->enclosingPaginationLayer() == enclosingPaginationLayer();
1606 if (rootLayerIsInsidePaginationLayer) { 1602 if (rootLayerIsInsidePaginationLayer) {
1607 // The root layer is in the same fragmentation context as this layer, so we 1603 // 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 1604 // need to look inside it and subtract the offset between the fragmentation
1609 // context and the root layer. 1605 // context and the root layer.
1610 offsetOfPaginationLayerFromRoot = 1606 offsetOfPaginationLayerFromRoot =
1611 -rootLayer->visualOffsetFromAncestor(enclosingPaginationLayer()); 1607 -rootLayer->visualOffsetFromAncestor(enclosingPaginationLayer());
1612 } else { 1608 } else {
1613 offsetOfPaginationLayerFromRoot = 1609 offsetOfPaginationLayerFromRoot =
1614 enclosingPaginationLayer()->visualOffsetFromAncestor(rootLayer); 1610 enclosingPaginationLayer()->visualOffsetFromAncestor(rootLayer);
1615 } 1611 }
1616 // Make the dirty rect relative to the fragmentation context (multicol 1612 // Make the dirty rect relative to the fragmentation context (multicol
1617 // container, etc.). 1613 // container, etc.).
1618 LayoutRect dirtyRectInMulticolContainer(dirtyRect); 1614 LayoutRect dirtyRectInMulticolContainer(dirtyRect);
1619 dirtyRectInMulticolContainer.move(enclosingFlowThread->physicalLocation() - 1615 dirtyRectInMulticolContainer.move(enclosingFlowThread.physicalLocation() -
1620 offsetOfPaginationLayerFromRoot); 1616 offsetOfPaginationLayerFromRoot);
1621 1617
1622 // Slice the layer into fragments. Each fragment needs to be processed (e.g. 1618 // 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 1619 // 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 1620 // 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. 1621 // well as the pages/columns that intersect our layer's bounding box.
1626 FragmentainerIterator iterator(*enclosingFlowThread, 1622 FragmentainerIterator iterator(enclosingFlowThread,
1627 layerBoundingBoxInFlowThread, 1623 layerBoundingBoxInFlowThread,
1628 dirtyRectInMulticolContainer); 1624 dirtyRectInMulticolContainer);
1629 if (iterator.atEnd()) 1625 if (iterator.atEnd())
1630 return; 1626 return;
1631 1627
1632 // Get the parent clip rects of the pagination layer, since we need to 1628 // Get the parent clip rects of the pagination layer, since we need to
1633 // intersect with that when painting column contents. 1629 // intersect with that when painting column contents.
1634 ClipRect ancestorClipRect = dirtyRect; 1630 ClipRect ancestorClipRect = dirtyRect;
1635 if (const PaintLayer* paginationParentLayer = 1631 if (const PaintLayer* paginationParentLayer =
1636 enclosingPaginationLayer()->parent()) { 1632 enclosingPaginationLayer()->parent()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 fragment.intersect(fragment.paginationClip); 1673 fragment.intersect(fragment.paginationClip);
1678 1674
1679 // TODO(mstensho): Don't add empty fragments. We've always done that in some 1675 // 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 1676 // 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 1677 // 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. 1678 // iterator, so that we won't end up with empty fragments here.
1683 fragments.push_back(fragment); 1679 fragments.push_back(fragment);
1684 } 1680 }
1685 } 1681 }
1686 1682
1687 static inline LayoutRect frameVisibleRect(LayoutObject* layoutObject) { 1683 static inline LayoutRect frameVisibleRect(LayoutObject& layoutObject) {
1688 FrameView* frameView = layoutObject->document().view(); 1684 FrameView* frameView = layoutObject.document().view();
1689 if (!frameView) 1685 if (!frameView)
1690 return LayoutRect(); 1686 return LayoutRect();
1691 1687
1692 return LayoutRect(frameView->visibleContentRect()); 1688 return LayoutRect(frameView->visibleContentRect());
1693 } 1689 }
1694 1690
1695 bool PaintLayer::hitTest(HitTestResult& result) { 1691 bool PaintLayer::hitTest(HitTestResult& result) {
1696 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 1692 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
1697 1693
1698 // LayoutView should make sure to update layout before entering hit testing 1694 // LayoutView should make sure to update layout before entering hit testing
1699 DCHECK(!layoutObject()->frame()->view()->layoutPending()); 1695 DCHECK(!layoutObject().frame()->view()->layoutPending());
1700 DCHECK(!layoutObject()->document().layoutViewItem().needsLayout()); 1696 DCHECK(!layoutObject().document().layoutViewItem().needsLayout());
1701 1697
1702 const HitTestRequest& request = result.hitTestRequest(); 1698 const HitTestRequest& request = result.hitTestRequest();
1703 const HitTestLocation& hitTestLocation = result.hitTestLocation(); 1699 const HitTestLocation& hitTestLocation = result.hitTestLocation();
1704 1700
1705 // Start with frameVisibleRect to ensure we include the scrollbars. 1701 // Start with frameVisibleRect to ensure we include the scrollbars.
1706 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 1702 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
1707 if (request.ignoreClipping()) 1703 if (request.ignoreClipping())
1708 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 1704 hitTestArea.unite(LayoutRect(layoutObject().view()->documentRect()));
1709 1705
1710 PaintLayer* insideLayer = 1706 PaintLayer* insideLayer =
1711 hitTestLayer(this, 0, result, hitTestArea, hitTestLocation, false); 1707 hitTestLayer(this, 0, result, hitTestArea, hitTestLocation, false);
1712 if (!insideLayer && isRootLayer()) { 1708 if (!insideLayer && isRootLayer()) {
1713 IntRect hitRect = hitTestLocation.boundingBox(); 1709 IntRect hitRect = hitTestLocation.boundingBox();
1714 bool fallback = false; 1710 bool fallback = false;
1715 // If we didn't hit any layers but are still inside the document 1711 // If we didn't hit any layers but are still inside the document
1716 // bounds, then we should fallback to hitting the document. 1712 // bounds, then we should fallback to hitting the document.
1717 // For rect-based hit test, we do the fallback only when the hit-rect 1713 // For rect-based hit test, we do the fallback only when the hit-rect
1718 // is totally within the document bounds. 1714 // is totally within the document bounds.
1719 if (hitTestArea.contains(LayoutRect(hitRect))) { 1715 if (hitTestArea.contains(LayoutRect(hitRect))) {
1720 fallback = true; 1716 fallback = true;
1721 1717
1722 // Mouse dragging outside the main document should also be 1718 // Mouse dragging outside the main document should also be
1723 // delivered to the document. 1719 // delivered to the document.
1724 // TODO(miletus): Capture behavior inconsistent with iframes 1720 // TODO(miletus): Capture behavior inconsistent with iframes
1725 // crbug.com/522109. 1721 // crbug.com/522109.
1726 // TODO(majidvp): This should apply more consistently across different 1722 // TODO(majidvp): This should apply more consistently across different
1727 // event types and we should not use RequestType for it. Perhaps best for 1723 // 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 1724 // it to be done at a higher level. See http://crbug.com/505825
1729 } else if ((request.active() || request.release()) && 1725 } else if ((request.active() || request.release()) &&
1730 !request.isChildFrameHitTest()) { 1726 !request.isChildFrameHitTest()) {
1731 fallback = true; 1727 fallback = true;
1732 } 1728 }
1733 if (fallback) { 1729 if (fallback) {
1734 layoutObject()->updateHitTestResult( 1730 layoutObject().updateHitTestResult(
1735 result, toLayoutView(layoutObject()) 1731 result, toLayoutView(layoutObject())
1736 ->flipForWritingMode(hitTestLocation.point())); 1732 .flipForWritingMode(hitTestLocation.point()));
1737 insideLayer = this; 1733 insideLayer = this;
1738 1734
1739 // Don't cache this result since it really wasn't a true hit. 1735 // Don't cache this result since it really wasn't a true hit.
1740 result.setCacheable(false); 1736 result.setCacheable(false);
1741 } 1737 }
1742 } 1738 }
1743 1739
1744 // Now determine if the result is inside an anchor - if the urlElement isn't 1740 // Now determine if the result is inside an anchor - if the urlElement isn't
1745 // already set. 1741 // already set.
1746 Node* node = result.innerNode(); 1742 Node* node = result.innerNode();
1747 if (node && !result.URLElement()) 1743 if (node && !result.URLElement())
1748 result.setURLElement(node->enclosingLinkEventParentOrSelf()); 1744 result.setURLElement(node->enclosingLinkEventParentOrSelf());
1749 1745
1750 // Now return whether we were inside this layer (this will always be true for 1746 // Now return whether we were inside this layer (this will always be true for
1751 // the root layer). 1747 // the root layer).
1752 return insideLayer; 1748 return insideLayer;
1753 } 1749 }
1754 1750
1755 Node* PaintLayer::enclosingNode() const { 1751 Node* PaintLayer::enclosingNode() const {
1756 for (LayoutObject* r = layoutObject(); r; r = r->parent()) { 1752 for (LayoutObject* r = &layoutObject(); r; r = r->parent()) {
1757 if (Node* e = r->node()) 1753 if (Node* e = r->node())
1758 return e; 1754 return e;
1759 } 1755 }
1760 ASSERT_NOT_REACHED(); 1756 ASSERT_NOT_REACHED();
1761 return 0; 1757 return 0;
1762 } 1758 }
1763 1759
1764 bool PaintLayer::isInTopLayer() const { 1760 bool PaintLayer::isInTopLayer() const {
1765 Node* node = layoutObject()->node(); 1761 Node* node = layoutObject().node();
1766 return node && node->isElementNode() && toElement(node)->isInTopLayer(); 1762 return node && node->isElementNode() && toElement(node)->isInTopLayer();
1767 } 1763 }
1768 1764
1769 // Compute the z-offset of the point in the transformState. 1765 // Compute the z-offset of the point in the transformState.
1770 // This is effectively projecting a ray normal to the plane of ancestor, finding 1766 // 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 1767 // where that ray intersects target, and computing the z delta between those two
1772 // points. 1768 // points.
1773 static double computeZOffset(const HitTestingTransformState& transformState) { 1769 static double computeZOffset(const HitTestingTransformState& transformState) {
1774 // We got an affine transform, so no z-offset 1770 // We got an affine transform, so no z-offset
1775 if (transformState.m_accumulatedTransform.isAffine()) 1771 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 1798 // If this is the first time we need to make transform state, then base it
1803 // off of hitTestLocation, which is relative to rootLayer. 1799 // off of hitTestLocation, which is relative to rootLayer.
1804 transformState = HitTestingTransformState::create( 1800 transformState = HitTestingTransformState::create(
1805 hitTestLocation.transformedPoint(), hitTestLocation.transformedRect(), 1801 hitTestLocation.transformedPoint(), hitTestLocation.transformedRect(),
1806 FloatQuad(FloatRect(hitTestRect))); 1802 FloatQuad(FloatRect(hitTestRect)));
1807 convertToLayerCoords(rootLayer, offset); 1803 convertToLayerCoords(rootLayer, offset);
1808 } 1804 }
1809 offset.moveBy(translationOffset); 1805 offset.moveBy(translationOffset);
1810 1806
1811 LayoutObject* containerLayoutObject = 1807 LayoutObject* containerLayoutObject =
1812 containerLayer ? containerLayer->layoutObject() : 0; 1808 containerLayer ? &containerLayer->layoutObject() : 0;
1813 if (layoutObject()->shouldUseTransformFromContainer(containerLayoutObject)) { 1809 if (layoutObject().shouldUseTransformFromContainer(containerLayoutObject)) {
1814 TransformationMatrix containerTransform; 1810 TransformationMatrix containerTransform;
1815 layoutObject()->getTransformFromContainer( 1811 layoutObject().getTransformFromContainer(
1816 containerLayoutObject, toLayoutSize(offset), containerTransform); 1812 containerLayoutObject, toLayoutSize(offset), containerTransform);
1817 transformState->applyTransform( 1813 transformState->applyTransform(
1818 containerTransform, HitTestingTransformState::AccumulateTransform); 1814 containerTransform, HitTestingTransformState::AccumulateTransform);
1819 } else { 1815 } else {
1820 transformState->translate(offset.x().toInt(), offset.y().toInt(), 1816 transformState->translate(offset.x().toInt(), offset.y().toInt(),
1821 HitTestingTransformState::AccumulateTransform); 1817 HitTestingTransformState::AccumulateTransform);
1822 } 1818 }
1823 1819
1824 return transformState; 1820 return transformState;
1825 } 1821 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 // the containing flattening layer. 1862 // the containing flattening layer.
1867 PaintLayer* PaintLayer::hitTestLayer( 1863 PaintLayer* PaintLayer::hitTestLayer(
1868 PaintLayer* rootLayer, 1864 PaintLayer* rootLayer,
1869 PaintLayer* containerLayer, 1865 PaintLayer* containerLayer,
1870 HitTestResult& result, 1866 HitTestResult& result,
1871 const LayoutRect& hitTestRect, 1867 const LayoutRect& hitTestRect,
1872 const HitTestLocation& hitTestLocation, 1868 const HitTestLocation& hitTestLocation,
1873 bool appliedTransform, 1869 bool appliedTransform,
1874 const HitTestingTransformState* transformState, 1870 const HitTestingTransformState* transformState,
1875 double* zOffset) { 1871 double* zOffset) {
1876 DCHECK(layoutObject()->document().lifecycle().state() >= 1872 DCHECK(layoutObject().document().lifecycle().state() >=
1877 DocumentLifecycle::CompositingClean); 1873 DocumentLifecycle::CompositingClean);
1878 1874
1879 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 1875 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
1880 return nullptr; 1876 return nullptr;
1881 1877
1882 ClipRectsCacheSlot clipRectsCacheSlot = 1878 ClipRectsCacheSlot clipRectsCacheSlot =
1883 result.hitTestRequest().ignoreClipping() 1879 result.hitTestRequest().ignoreClipping()
1884 ? RootRelativeClipRectsIgnoringViewportClip 1880 ? RootRelativeClipRectsIgnoringViewportClip
1885 : RootRelativeClipRects; 1881 : RootRelativeClipRects;
1886 1882
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 } else if (transformState || m_has3DTransformedDescendant || preserves3D()) { 1917 } else if (transformState || m_has3DTransformedDescendant || preserves3D()) {
1922 // We need transform state for the first time, or to offset the container 1918 // We need transform state for the first time, or to offset the container
1923 // state, so create it here. 1919 // state, so create it here.
1924 localTransformState = 1920 localTransformState =
1925 createLocalTransformState(rootLayer, containerLayer, hitTestRect, 1921 createLocalTransformState(rootLayer, containerLayer, hitTestRect,
1926 hitTestLocation, transformState); 1922 hitTestLocation, transformState);
1927 } 1923 }
1928 1924
1929 // Check for hit test on backface if backface-visibility is 'hidden' 1925 // Check for hit test on backface if backface-visibility is 'hidden'
1930 if (localTransformState && 1926 if (localTransformState &&
1931 layoutObject()->style()->backfaceVisibility() == 1927 layoutObject().style()->backfaceVisibility() ==
1932 BackfaceVisibilityHidden) { 1928 BackfaceVisibilityHidden) {
1933 TransformationMatrix invertedMatrix = 1929 TransformationMatrix invertedMatrix =
1934 localTransformState->m_accumulatedTransform.inverse(); 1930 localTransformState->m_accumulatedTransform.inverse();
1935 // If the z-vector of the matrix is negative, the back is facing towards the 1931 // If the z-vector of the matrix is negative, the back is facing towards the
1936 // viewer. 1932 // viewer.
1937 if (invertedMatrix.m33() < 0) 1933 if (invertedMatrix.m33() < 0)
1938 return nullptr; 1934 return nullptr;
1939 } 1935 }
1940 1936
1941 RefPtr<HitTestingTransformState> unflattenedTransformState = 1937 RefPtr<HitTestingTransformState> unflattenedTransformState =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 PaintLayer::DoNotUseGeometryMapper, 1999 PaintLayer::DoNotUseGeometryMapper,
2004 ExcludeOverlayScrollbarSizeForHitTesting); 2000 ExcludeOverlayScrollbarSizeForHitTesting);
2005 else 2001 else
2006 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheSlot, 2002 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheSlot,
2007 PaintLayer::DoNotUseGeometryMapper, 2003 PaintLayer::DoNotUseGeometryMapper,
2008 ExcludeOverlayScrollbarSizeForHitTesting); 2004 ExcludeOverlayScrollbarSizeForHitTesting);
2009 2005
2010 if (m_scrollableArea && 2006 if (m_scrollableArea &&
2011 m_scrollableArea->hitTestResizerInFragments(layerFragments, 2007 m_scrollableArea->hitTestResizerInFragments(layerFragments,
2012 hitTestLocation)) { 2008 hitTestLocation)) {
2013 layoutObject()->updateHitTestResult(result, hitTestLocation.point()); 2009 layoutObject().updateHitTestResult(result, hitTestLocation.point());
2014 return this; 2010 return this;
2015 } 2011 }
2016 2012
2017 // Next we want to see if the mouse pos is inside the child LayoutObjects of 2013 // Next we want to see if the mouse pos is inside the child LayoutObjects of
2018 // the layer. Check every fragment in reverse order. 2014 // the layer. Check every fragment in reverse order.
2019 if (isSelfPaintingLayer()) { 2015 if (isSelfPaintingLayer()) {
2020 // Hit test with a temporary HitTestResult, because we only want to commit 2016 // Hit test with a temporary HitTestResult, because we only want to commit
2021 // to 'result' if we know we're frontmost. 2017 // to 'result' if we know we're frontmost.
2022 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation()); 2018 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
2023 bool insideFragmentForegroundRect = false; 2019 bool insideFragmentForegroundRect = false;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 newHitTestLocation, true, newTransformState.get(), 2195 newHitTestLocation, true, newTransformState.get(),
2200 zOffset); 2196 zOffset);
2201 } 2197 }
2202 2198
2203 bool PaintLayer::hitTestContents(HitTestResult& result, 2199 bool PaintLayer::hitTestContents(HitTestResult& result,
2204 const LayoutRect& layerBounds, 2200 const LayoutRect& layerBounds,
2205 const HitTestLocation& hitTestLocation, 2201 const HitTestLocation& hitTestLocation,
2206 HitTestFilter hitTestFilter) const { 2202 HitTestFilter hitTestFilter) const {
2207 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 2203 DCHECK(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
2208 2204
2209 if (!layoutObject()->hitTest( 2205 if (!layoutObject().hitTest(
2210 result, hitTestLocation, 2206 result, hitTestLocation,
2211 toLayoutPoint(layerBounds.location() - layoutBoxLocation()), 2207 toLayoutPoint(layerBounds.location() - layoutBoxLocation()),
2212 hitTestFilter)) { 2208 hitTestFilter)) {
2213 // It's wrong to set innerNode, but then claim that you didn't hit anything, 2209 // It's wrong to set innerNode, but then claim that you didn't hit anything,
2214 // unless it is a rect-based test. 2210 // unless it is a rect-based test.
2215 DCHECK(!result.innerNode() || (result.hitTestRequest().listBased() && 2211 DCHECK(!result.innerNode() || (result.hitTestRequest().listBased() &&
2216 result.listBasedTestResult().size())); 2212 result.listBasedTestResult().size()));
2217 return false; 2213 return false;
2218 } 2214 }
2219 2215
2220 if (!result.innerNode()) { 2216 if (!result.innerNode()) {
2221 // We hit something anonymous, and we didn't find a DOM node ancestor in 2217 // We hit something anonymous, and we didn't find a DOM node ancestor in
2222 // this layer. 2218 // this layer.
2223 2219
2224 if (layoutObject()->isLayoutFlowThread()) { 2220 if (layoutObject().isLayoutFlowThread()) {
2225 // For a flow thread it's safe to just say that we didn't hit anything. 2221 // 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 2222 // 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 2223 // 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 2224 // threads, they don't establish layers, so we'll fall back and hit the
2229 // multicol container parent (which should have a DOM node). 2225 // multicol container parent (which should have a DOM node).
2230 return false; 2226 return false;
2231 } 2227 }
2232 2228
2233 Node* e = enclosingNode(); 2229 Node* e = enclosingNode();
2234 // FIXME: should be a call to result.setNodeAndPosition. What we would 2230 // 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; 2283 return resultLayer;
2288 } 2284 }
2289 2285
2290 FloatRect PaintLayer::boxForFilterOrMask() const { 2286 FloatRect PaintLayer::boxForFilterOrMask() const {
2291 return FloatRect(physicalBoundingBoxIncludingStackingChildren( 2287 return FloatRect(physicalBoundingBoxIncludingStackingChildren(
2292 LayoutPoint(), PaintLayer::CalculateBoundsOptions:: 2288 LayoutPoint(), PaintLayer::CalculateBoundsOptions::
2293 IncludeTransformsAndCompositedChildLayers)); 2289 IncludeTransformsAndCompositedChildLayers));
2294 } 2290 }
2295 2291
2296 LayoutRect PaintLayer::boxForClipPath() const { 2292 LayoutRect PaintLayer::boxForClipPath() const {
2297 if (!layoutObject()->isBox()) { 2293 if (!layoutObject().isBox()) {
2298 SECURITY_DCHECK(layoutObject()->isLayoutInline()); 2294 SECURITY_DCHECK(layoutObject().isLayoutInline());
2299 const LayoutInline& layoutInline = toLayoutInline(*layoutObject()); 2295 const LayoutInline& layoutInline = toLayoutInline(layoutObject());
2300 // This somewhat convoluted computation matches what Gecko does. 2296 // This somewhat convoluted computation matches what Gecko does.
2301 // See crbug.com/641907. 2297 // See crbug.com/641907.
2302 LayoutRect inlineBBox = layoutInline.linesBoundingBox(); 2298 LayoutRect inlineBBox = layoutInline.linesBoundingBox();
2303 const InlineFlowBox* flowBox = layoutInline.firstLineBox(); 2299 const InlineFlowBox* flowBox = layoutInline.firstLineBox();
2304 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height() 2300 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height()
2305 : LayoutUnit(0)); 2301 : LayoutUnit(0));
2306 return inlineBBox; 2302 return inlineBBox;
2307 } 2303 }
2308 return toLayoutBox(layoutObject())->borderBoxRect(); 2304 return toLayoutBox(layoutObject()).borderBoxRect();
2309 } 2305 }
2310 2306
2311 bool PaintLayer::hitTestClippedOutByClipPath( 2307 bool PaintLayer::hitTestClippedOutByClipPath(
2312 PaintLayer* rootLayer, 2308 PaintLayer* rootLayer,
2313 const HitTestLocation& hitTestLocation) const { 2309 const HitTestLocation& hitTestLocation) const {
2314 if (!layoutObject()->hasClipPath()) 2310 if (!layoutObject().hasClipPath())
2315 return false; 2311 return false;
2316 DCHECK(isSelfPaintingLayer()); 2312 DCHECK(isSelfPaintingLayer());
2317 DCHECK(rootLayer); 2313 DCHECK(rootLayer);
2318 2314
2319 LayoutRect referenceBox(boxForClipPath()); 2315 LayoutRect referenceBox(boxForClipPath());
2320 if (enclosingPaginationLayer()) 2316 if (enclosingPaginationLayer())
2321 convertFromFlowThreadToVisualBoundingBoxInAncestor(rootLayer, referenceBox); 2317 convertFromFlowThreadToVisualBoundingBoxInAncestor(rootLayer, referenceBox);
2322 else 2318 else
2323 convertToLayerCoords(rootLayer, referenceBox); 2319 convertToLayerCoords(rootLayer, referenceBox);
2324 2320
2325 FloatPoint point(hitTestLocation.point()); 2321 FloatPoint point(hitTestLocation.point());
2326 2322
2327 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); 2323 ClipPathOperation* clipPathOperation = layoutObject().style()->clipPath();
2328 DCHECK(clipPathOperation); 2324 DCHECK(clipPathOperation);
2329 if (clipPathOperation->type() == ClipPathOperation::SHAPE) { 2325 if (clipPathOperation->type() == ClipPathOperation::SHAPE) {
2330 ShapeClipPathOperation* clipPath = 2326 ShapeClipPathOperation* clipPath =
2331 toShapeClipPathOperation(clipPathOperation); 2327 toShapeClipPathOperation(clipPathOperation);
2332 return !clipPath->path(FloatRect(referenceBox)).contains(point); 2328 return !clipPath->path(FloatRect(referenceBox)).contains(point);
2333 } 2329 }
2334 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); 2330 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE);
2335 Node* targetNode = layoutObject()->node(); 2331 Node* targetNode = layoutObject().node();
2336 if (!targetNode) 2332 if (!targetNode)
2337 return false; 2333 return false;
2338 const ReferenceClipPathOperation& referenceClipPathOperation = 2334 const ReferenceClipPathOperation& referenceClipPathOperation =
2339 toReferenceClipPathOperation(*clipPathOperation); 2335 toReferenceClipPathOperation(*clipPathOperation);
2340 SVGElement* element = 2336 SVGElement* element =
2341 referenceClipPathOperation.findElement(targetNode->treeScope()); 2337 referenceClipPathOperation.findElement(targetNode->treeScope());
2342 if (!isSVGClipPathElement(element) || !element->layoutObject()) 2338 if (!isSVGClipPathElement(element) || !element->layoutObject())
2343 return false; 2339 return false;
2344 LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper( 2340 LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper(
2345 toLayoutSVGResourceContainer(element->layoutObject())); 2341 toLayoutSVGResourceContainer(element->layoutObject()));
2346 // If the clipPath is using "userspace on use" units, then the origin of 2342 // 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 2343 // the coordinate system is the top-left of the reference box, so adjust
2348 // the point accordingly. 2344 // the point accordingly.
2349 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) 2345 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse)
2350 point.moveBy(-referenceBox.location()); 2346 point.moveBy(-referenceBox.location());
2351 return !clipper->hitTestClipContent(FloatRect(referenceBox), point); 2347 return !clipper->hitTestClipContent(FloatRect(referenceBox), point);
2352 } 2348 }
2353 2349
2354 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, 2350 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds,
2355 const LayoutRect& damageRect, 2351 const LayoutRect& damageRect,
2356 const LayoutPoint& offsetFromRoot) const { 2352 const LayoutPoint& offsetFromRoot) const {
2357 // Always examine the canvas and the root. 2353 // Always examine the canvas and the root.
2358 // FIXME: Could eliminate the isDocumentElement() check if we fix background 2354 // FIXME: Could eliminate the isDocumentElement() check if we fix background
2359 // painting so that the LayoutView paints the root's background. 2355 // painting so that the LayoutView paints the root's background.
2360 if (isRootLayer() || layoutObject()->isDocumentElement()) 2356 if (isRootLayer() || layoutObject().isDocumentElement())
2361 return true; 2357 return true;
2362 2358
2363 // If we aren't an inline flow, and our layer bounds do intersect the damage 2359 // 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. 2360 // rect, then we can go ahead and return true.
2365 LayoutView* view = layoutObject()->view(); 2361 LayoutView* view = layoutObject().view();
2366 DCHECK(view); 2362 DCHECK(view);
2367 if (view && !layoutObject()->isLayoutInline()) { 2363 if (view && !layoutObject().isLayoutInline()) {
2368 if (layerBounds.intersects(damageRect)) 2364 if (layerBounds.intersects(damageRect))
2369 return true; 2365 return true;
2370 } 2366 }
2371 2367
2372 // Otherwise we need to compute the bounding box of this single layer and see 2368 // Otherwise we need to compute the bounding box of this single layer and see
2373 // if it intersects the damage rect. 2369 // if it intersects the damage rect.
2374 return physicalBoundingBox(offsetFromRoot).intersects(damageRect); 2370 return physicalBoundingBox(offsetFromRoot).intersects(damageRect);
2375 } 2371 }
2376 2372
2377 LayoutRect PaintLayer::logicalBoundingBox() const { 2373 LayoutRect PaintLayer::logicalBoundingBox() const {
2378 LayoutRect rect = layoutObject()->visualOverflowRect(); 2374 LayoutRect rect = layoutObject().visualOverflowRect();
2379 2375
2380 if (isRootLayer()) { 2376 if (isRootLayer()) {
2381 rect.unite( 2377 rect.unite(
2382 LayoutRect(rect.location(), layoutObject()->view()->viewRect().size())); 2378 LayoutRect(rect.location(), layoutObject().view()->viewRect().size()));
2383 } 2379 }
2384 2380
2385 return rect; 2381 return rect;
2386 } 2382 }
2387 2383
2388 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox, 2384 static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox,
2389 LayoutObject* layoutObject) { 2385 LayoutObject& layoutObject) {
2390 LayoutRect result = boundingBox; 2386 LayoutRect result = boundingBox;
2391 if (layoutObject->isBox()) 2387 if (layoutObject.isBox())
2392 toLayoutBox(layoutObject)->flipForWritingMode(result); 2388 toLayoutBox(layoutObject).flipForWritingMode(result);
2393 else 2389 else
2394 layoutObject->containingBlock()->flipForWritingMode(result); 2390 layoutObject.containingBlock()->flipForWritingMode(result);
2395 return result; 2391 return result;
2396 } 2392 }
2397 2393
2398 LayoutRect PaintLayer::physicalBoundingBox( 2394 LayoutRect PaintLayer::physicalBoundingBox(
2399 const PaintLayer* ancestorLayer) const { 2395 const PaintLayer* ancestorLayer) const {
2400 LayoutPoint offsetFromRoot; 2396 LayoutPoint offsetFromRoot;
2401 convertToLayerCoords(ancestorLayer, offsetFromRoot); 2397 convertToLayerCoords(ancestorLayer, offsetFromRoot);
2402 return physicalBoundingBox(offsetFromRoot); 2398 return physicalBoundingBox(offsetFromRoot);
2403 } 2399 }
2404 2400
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 2489
2494 // FIXME: This could be improved to do a check like 2490 // FIXME: This could be improved to do a check like
2495 // hasVisibleNonCompositingDescendantLayers() (bug 92580). 2491 // hasVisibleNonCompositingDescendantLayers() (bug 92580).
2496 if (this != &compositedLayer && !hasVisibleContent() && 2492 if (this != &compositedLayer && !hasVisibleContent() &&
2497 !hasVisibleDescendant()) 2493 !hasVisibleDescendant())
2498 return LayoutRect(); 2494 return LayoutRect();
2499 2495
2500 // The root layer is the size of the document, plus any additional area due 2496 // The root layer is the size of the document, plus any additional area due
2501 // to layout viewport being different than initial containing block. 2497 // to layout viewport being different than initial containing block.
2502 if (isRootLayer()) { 2498 if (isRootLayer()) {
2503 IntRect documentRect = layoutObject()->view()->documentRect(); 2499 IntRect documentRect = layoutObject().view()->documentRect();
2504 2500
2505 if (FrameView* frameView = layoutObject()->document().view()) { 2501 if (FrameView* frameView = layoutObject().document().view()) {
2506 documentRect.unite(IntRect(IntPoint(), frameView->visibleContentSize())); 2502 documentRect.unite(IntRect(IntPoint(), frameView->visibleContentSize()));
2507 } 2503 }
2508 2504
2509 return LayoutRect(documentRect); 2505 return LayoutRect(documentRect);
2510 } 2506 }
2511 2507
2512 // The layer created for the LayoutFlowThread is just a helper for painting 2508 // 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 2509 // and hit-testing, and should not contribute to the bounding box. The
2514 // LayoutMultiColumnSets will contribute the correct size for the layout 2510 // LayoutMultiColumnSets will contribute the correct size for the layout
2515 // content of the multicol container. 2511 // content of the multicol container.
2516 if (layoutObject()->isLayoutFlowThread()) 2512 if (layoutObject().isLayoutFlowThread())
2517 return LayoutRect(); 2513 return LayoutRect();
2518 2514
2519 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); 2515 const_cast<PaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
2520 2516
2521 // If there is a clip applied by an ancestor to this PaintLayer but below or 2517 // If there is a clip applied by an ancestor to this PaintLayer but below or
2522 // equal to |ancestorLayer|, apply that clip. 2518 // equal to |ancestorLayer|, apply that clip.
2523 LayoutRect result = clipper(PaintLayer::DoNotUseGeometryMapper) 2519 LayoutRect result = clipper(PaintLayer::DoNotUseGeometryMapper)
2524 .localClipRect(compositedLayer); 2520 .localClipRect(compositedLayer);
2525 2521
2526 result.intersect(physicalBoundingBox(LayoutPoint())); 2522 result.intersect(physicalBoundingBox(LayoutPoint()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 if (!compositedLayerMapping()) 2562 if (!compositedLayerMapping())
2567 return NotComposited; 2563 return NotComposited;
2568 2564
2569 return PaintsIntoOwnBacking; 2565 return PaintsIntoOwnBacking;
2570 } 2566 }
2571 2567
2572 bool PaintLayer::isAllowedToQueryCompositingState() const { 2568 bool PaintLayer::isAllowedToQueryCompositingState() const {
2573 if (gCompositingQueryMode == CompositingQueriesAreAllowed || 2569 if (gCompositingQueryMode == CompositingQueriesAreAllowed ||
2574 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2570 RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2575 return true; 2571 return true;
2576 return layoutObject()->document().lifecycle().state() >= 2572 return layoutObject().document().lifecycle().state() >=
2577 DocumentLifecycle::InCompositingUpdate; 2573 DocumentLifecycle::InCompositingUpdate;
2578 } 2574 }
2579 2575
2580 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const { 2576 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const {
2581 DCHECK(isAllowedToQueryCompositingState()); 2577 DCHECK(isAllowedToQueryCompositingState());
2582 return m_rareData ? m_rareData->compositedLayerMapping.get() : nullptr; 2578 return m_rareData ? m_rareData->compositedLayerMapping.get() : nullptr;
2583 } 2579 }
2584 2580
2585 GraphicsLayer* PaintLayer::graphicsLayerBacking(const LayoutObject* obj) const { 2581 GraphicsLayer* PaintLayer::graphicsLayerBacking(const LayoutObject* obj) const {
2586 switch (compositingState()) { 2582 switch (compositingState()) {
2587 case NotComposited: 2583 case NotComposited:
2588 return nullptr; 2584 return nullptr;
2589 case PaintsIntoGroupedBacking: 2585 case PaintsIntoGroupedBacking:
2590 return groupedMapping()->squashingLayer(); 2586 return groupedMapping()->squashingLayer();
2591 default: 2587 default:
2592 return (obj != layoutObject() && 2588 return (obj != &layoutObject() &&
2593 compositedLayerMapping()->scrollingContentsLayer()) 2589 compositedLayerMapping()->scrollingContentsLayer())
2594 ? compositedLayerMapping()->scrollingContentsLayer() 2590 ? compositedLayerMapping()->scrollingContentsLayer()
2595 : compositedLayerMapping()->mainGraphicsLayer(); 2591 : compositedLayerMapping()->mainGraphicsLayer();
2596 } 2592 }
2597 } 2593 }
2598 2594
2599 BackgroundPaintLocation PaintLayer::backgroundPaintLocation( 2595 BackgroundPaintLocation PaintLayer::backgroundPaintLocation(
2600 uint32_t* reasons) const { 2596 uint32_t* reasons) const {
2601 BackgroundPaintLocation location; 2597 BackgroundPaintLocation location;
2602 if (!scrollsOverflow()) { 2598 if (!scrollsOverflow()) {
2603 location = BackgroundPaintInGraphicsLayer; 2599 location = BackgroundPaintInGraphicsLayer;
2604 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 2600 } else if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
2605 location = layoutObject()->backgroundPaintLocation(reasons); 2601 location = layoutObject().backgroundPaintLocation(reasons);
2606 } else { 2602 } else {
2607 location = isRootLayer() ? BackgroundPaintInGraphicsLayer 2603 location = isRootLayer() ? BackgroundPaintInGraphicsLayer
2608 : layoutObject()->backgroundPaintLocation(reasons); 2604 : layoutObject().backgroundPaintLocation(reasons);
2609 } 2605 }
2610 m_stackingNode->updateLayerListsIfNeeded(); 2606 m_stackingNode->updateLayerListsIfNeeded();
2611 if (m_stackingNode->hasNegativeZOrderList()) 2607 if (m_stackingNode->hasNegativeZOrderList())
2612 location = BackgroundPaintInGraphicsLayer; 2608 location = BackgroundPaintInGraphicsLayer;
2613 return location; 2609 return location;
2614 } 2610 }
2615 2611
2616 void PaintLayer::ensureCompositedLayerMapping() { 2612 void PaintLayer::ensureCompositedLayerMapping() {
2617 if (m_rareData && m_rareData->compositedLayerMapping) 2613 if (m_rareData && m_rareData->compositedLayerMapping)
2618 return; 2614 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 if (m_rareData || groupedMapping) 2657 if (m_rareData || groupedMapping)
2662 ensureRareData().groupedMapping = groupedMapping; 2658 ensureRareData().groupedMapping = groupedMapping;
2663 #if DCHECK_IS_ON() 2659 #if DCHECK_IS_ON()
2664 DCHECK(!groupedMapping || groupedMapping->verifyLayerInSquashingVector(this)); 2660 DCHECK(!groupedMapping || groupedMapping->verifyLayerInSquashingVector(this));
2665 #endif 2661 #endif
2666 if (options == InvalidateLayerAndRemoveFromMapping && groupedMapping) 2662 if (options == InvalidateLayerAndRemoveFromMapping && groupedMapping)
2667 groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree); 2663 groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree);
2668 } 2664 }
2669 2665
2670 bool PaintLayer::maskBlendingAppliedByCompositor() const { 2666 bool PaintLayer::maskBlendingAppliedByCompositor() const {
2671 DCHECK(m_layoutObject->hasMask()); 2667 DCHECK(m_layoutObject.hasMask());
2672 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 2668 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2673 return true; 2669 return true;
2674 return m_rareData && m_rareData->compositedLayerMapping && 2670 return m_rareData && m_rareData->compositedLayerMapping &&
2675 m_rareData->compositedLayerMapping->hasMaskLayer(); 2671 m_rareData->compositedLayerMapping->hasMaskLayer();
2676 } 2672 }
2677 2673
2678 bool PaintLayer::hasCompositedClippingMask() const { 2674 bool PaintLayer::hasCompositedClippingMask() const {
2679 return m_rareData && m_rareData->compositedLayerMapping && 2675 return m_rareData && m_rareData->compositedLayerMapping &&
2680 m_rareData->compositedLayerMapping->hasChildClippingMaskLayer(); 2676 m_rareData->compositedLayerMapping->hasChildClippingMaskLayer();
2681 } 2677 }
2682 2678
2683 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const { 2679 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const {
2684 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { 2680 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) {
2685 return transform() && 2681 return transform() &&
2686 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || 2682 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) ||
2687 compositingState() != PaintsIntoOwnBacking); 2683 compositingState() != PaintsIntoOwnBacking);
2688 } 2684 }
2689 2685
2690 return (transform() || 2686 return (transform() ||
2691 layoutObject()->style()->position() == EPosition::kFixed) && 2687 layoutObject().style()->position() == EPosition::kFixed) &&
2692 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || 2688 ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) ||
2693 compositingState() != PaintsIntoOwnBacking); 2689 compositingState() != PaintsIntoOwnBacking);
2694 } 2690 }
2695 2691
2696 bool PaintLayer::compositesWithTransform() const { 2692 bool PaintLayer::compositesWithTransform() const {
2697 return transformAncestor() || transform(); 2693 return transformAncestor() || transform();
2698 } 2694 }
2699 2695
2700 bool PaintLayer::compositesWithOpacity() const { 2696 bool PaintLayer::compositesWithOpacity() const {
2701 return opacityAncestor() || layoutObject()->style()->hasOpacity(); 2697 return opacityAncestor() || layoutObject().style()->hasOpacity();
2702 } 2698 }
2703 2699
2704 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect( 2700 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect(
2705 const LayoutRect& localRect) const { 2701 const LayoutRect& localRect) const {
2706 if (paintsWithTransparency(GlobalPaintNormalPhase)) 2702 if (paintsWithTransparency(GlobalPaintNormalPhase))
2707 return false; 2703 return false;
2708 2704
2709 // We can't use hasVisibleContent(), because that will be true if our 2705 // 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 2706 // layoutObject is hidden, but some child is visible and that child doesn't
2711 // cover the entire rect. 2707 // cover the entire rect.
2712 if (layoutObject()->style()->visibility() != EVisibility::kVisible) 2708 if (layoutObject().style()->visibility() != EVisibility::kVisible)
2713 return false; 2709 return false;
2714 2710
2715 if (paintsWithFilters() && 2711 if (paintsWithFilters() &&
2716 layoutObject()->style()->filter().hasFilterThatAffectsOpacity()) 2712 layoutObject().style()->filter().hasFilterThatAffectsOpacity())
2717 return false; 2713 return false;
2718 2714
2719 // FIXME: Handle simple transforms. 2715 // FIXME: Handle simple transforms.
2720 if (transform() && compositingState() != PaintsIntoOwnBacking) 2716 if (transform() && compositingState() != PaintsIntoOwnBacking)
2721 return false; 2717 return false;
2722 2718
2723 if (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() && 2719 if (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() &&
2724 layoutObject()->style()->position() == EPosition::kFixed && 2720 layoutObject().style()->position() == EPosition::kFixed &&
2725 compositingState() != PaintsIntoOwnBacking) 2721 compositingState() != PaintsIntoOwnBacking)
2726 return false; 2722 return false;
2727 2723
2728 // This function should not be called when layer-lists are dirty. 2724 // 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 2725 // TODO(schenney) This check never hits in layout tests or most platforms, but
2730 // does hit in PopupBlockerBrowserTest.AllowPopupThroughContentSetting on 2726 // does hit in PopupBlockerBrowserTest.AllowPopupThroughContentSetting on
2731 // Win 7 Test Builder. 2727 // Win 7 Test Builder.
2732 if (m_stackingNode->zOrderListsDirty()) 2728 if (m_stackingNode->zOrderListsDirty())
2733 return false; 2729 return false;
2734 2730
2735 // FIXME: We currently only check the immediate layoutObject, 2731 // FIXME: We currently only check the immediate layoutObject,
2736 // which will miss many cases where additional layout objects paint 2732 // which will miss many cases where additional layout objects paint
2737 // into this layer. 2733 // into this layer.
2738 if (layoutObject()->backgroundIsKnownToBeOpaqueInRect(localRect)) 2734 if (layoutObject().backgroundIsKnownToBeOpaqueInRect(localRect))
2739 return true; 2735 return true;
2740 2736
2741 // We can't consult child layers if we clip, since they might cover 2737 // We can't consult child layers if we clip, since they might cover
2742 // parts of the rect that are clipped out. 2738 // parts of the rect that are clipped out.
2743 if (layoutObject()->hasClipRelatedProperty()) 2739 if (layoutObject().hasClipRelatedProperty())
2744 return false; 2740 return false;
2745 2741
2746 // TODO(schenney): This could be improved by unioning the opaque regions of 2742 // TODO(schenney): This could be improved by unioning the opaque regions of
2747 // all the children. That would require a refactoring because currently 2743 // all the children. That would require a refactoring because currently
2748 // children just check they at least cover the given rect, but a unioning 2744 // children just check they at least cover the given rect, but a unioning
2749 // method would require children to compute and report their rects. 2745 // method would require children to compute and report their rects.
2750 return childBackgroundIsKnownToBeOpaqueInRect(localRect); 2746 return childBackgroundIsKnownToBeOpaqueInRect(localRect);
2751 } 2747 }
2752 2748
2753 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect( 2749 bool PaintLayer::childBackgroundIsKnownToBeOpaqueInRect(
(...skipping 15 matching lines...) Expand all
2769 childLayer->convertToLayerCoords(this, childOffset); 2765 childLayer->convertToLayerCoords(this, childOffset);
2770 childLocalRect.moveBy(-childOffset); 2766 childLocalRect.moveBy(-childOffset);
2771 2767
2772 if (childLayer->backgroundIsKnownToBeOpaqueInRect(childLocalRect)) 2768 if (childLayer->backgroundIsKnownToBeOpaqueInRect(childLocalRect))
2773 return true; 2769 return true;
2774 } 2770 }
2775 return false; 2771 return false;
2776 } 2772 }
2777 2773
2778 bool PaintLayer::shouldBeSelfPaintingLayer() const { 2774 bool PaintLayer::shouldBeSelfPaintingLayer() const {
2779 if (layoutObject()->isLayoutPart() && 2775 if (layoutObject().isLayoutPart() &&
2780 toLayoutPart(layoutObject())->requiresAcceleratedCompositing()) 2776 toLayoutPart(layoutObject()).requiresAcceleratedCompositing())
2781 return true; 2777 return true;
2782 2778
2783 return layoutObject()->layerTypeRequired() == NormalPaintLayer || 2779 return layoutObject().layerTypeRequired() == NormalPaintLayer ||
2784 (m_scrollableArea && m_scrollableArea->hasOverlayScrollbars()) || 2780 (m_scrollableArea && m_scrollableArea->hasOverlayScrollbars()) ||
2785 needsCompositedScrolling(); 2781 needsCompositedScrolling();
2786 } 2782 }
2787 2783
2788 void PaintLayer::updateSelfPaintingLayer() { 2784 void PaintLayer::updateSelfPaintingLayer() {
2789 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 2785 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer();
2790 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) 2786 if (this->isSelfPaintingLayer() == isSelfPaintingLayer)
2791 return; 2787 return;
2792 2788
2793 m_isSelfPaintingLayer = isSelfPaintingLayer; 2789 m_isSelfPaintingLayer = isSelfPaintingLayer;
(...skipping 18 matching lines...) Expand all
2812 layer = layer->parent(); 2808 layer = layer->parent();
2813 return layer; 2809 return layer;
2814 } 2810 }
2815 2811
2816 bool PaintLayer::hasNonEmptyChildLayoutObjects() const { 2812 bool PaintLayer::hasNonEmptyChildLayoutObjects() const {
2817 // Some HTML can cause whitespace text nodes to have layoutObjects, like: 2813 // Some HTML can cause whitespace text nodes to have layoutObjects, like:
2818 // <div> 2814 // <div>
2819 // <img src=...> 2815 // <img src=...>
2820 // </div> 2816 // </div>
2821 // so test for 0x0 LayoutTexts here 2817 // so test for 0x0 LayoutTexts here
2822 for (LayoutObject* child = layoutObject()->slowFirstChild(); child; 2818 for (LayoutObject* child = layoutObject().slowFirstChild(); child;
2823 child = child->nextSibling()) { 2819 child = child->nextSibling()) {
2824 if (!child->hasLayer()) { 2820 if (!child->hasLayer()) {
2825 if (child->isLayoutInline() || !child->isBox()) 2821 if (child->isLayoutInline() || !child->isBox())
2826 return true; 2822 return true;
2827 2823
2828 if (toLayoutBox(child)->size().width() > 0 || 2824 if (toLayoutBox(child)->size().width() > 0 ||
2829 toLayoutBox(child)->size().height() > 0) 2825 toLayoutBox(child)->size().height() > 0)
2830 return true; 2826 return true;
2831 } 2827 }
2832 } 2828 }
2833 return false; 2829 return false;
2834 } 2830 }
2835 2831
2836 bool PaintLayer::hasBoxDecorationsOrBackground() const { 2832 bool PaintLayer::hasBoxDecorationsOrBackground() const {
2837 return layoutObject()->style()->hasBoxDecorations() || 2833 return layoutObject().style()->hasBoxDecorations() ||
2838 layoutObject()->style()->hasBackground(); 2834 layoutObject().style()->hasBackground();
2839 } 2835 }
2840 2836
2841 bool PaintLayer::hasVisibleBoxDecorations() const { 2837 bool PaintLayer::hasVisibleBoxDecorations() const {
2842 if (!hasVisibleContent()) 2838 if (!hasVisibleContent())
2843 return false; 2839 return false;
2844 2840
2845 return hasBoxDecorationsOrBackground() || hasOverflowControls(); 2841 return hasBoxDecorationsOrBackground() || hasOverflowControls();
2846 } 2842 }
2847 2843
2848 void PaintLayer::updateFilters(const ComputedStyle* oldStyle, 2844 void PaintLayer::updateFilters(const ComputedStyle* oldStyle,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 // the overlap map. 2905 // the overlap map.
2910 if (diff.transformChanged() && 2906 if (diff.transformChanged() &&
2911 (!m_rareData || 2907 (!m_rareData ||
2912 !(m_rareData->compositingReasons & CompositingReasonInlineTransform))) 2908 !(m_rareData->compositingReasons & CompositingReasonInlineTransform)))
2913 return false; 2909 return false;
2914 2910
2915 // We composite transparent Layers differently from non-transparent 2911 // We composite transparent Layers differently from non-transparent
2916 // Layers even when the non-transparent Layers are already a 2912 // Layers even when the non-transparent Layers are already a
2917 // stacking context. 2913 // stacking context.
2918 if (diff.opacityChanged() && 2914 if (diff.opacityChanged() &&
2919 m_layoutObject->style()->hasOpacity() != oldStyle->hasOpacity()) 2915 m_layoutObject.style()->hasOpacity() != oldStyle->hasOpacity())
2920 return false; 2916 return false;
2921 2917
2922 // Changes in pointer-events affect hit test visibility of the scrollable 2918 // Changes in pointer-events affect hit test visibility of the scrollable
2923 // area and its |m_scrollsOverflow| value which determines if the layer 2919 // area and its |m_scrollsOverflow| value which determines if the layer
2924 // requires composited scrolling or not. 2920 // requires composited scrolling or not.
2925 if (m_scrollableArea && 2921 if (m_scrollableArea &&
2926 m_layoutObject->style()->pointerEvents() != oldStyle->pointerEvents()) 2922 m_layoutObject.style()->pointerEvents() != oldStyle->pointerEvents())
2927 return false; 2923 return false;
2928 2924
2929 updateTransform(oldStyle, layoutObject()->styleRef()); 2925 updateTransform(oldStyle, layoutObject().styleRef());
2930 2926
2931 // FIXME: Consider introducing a smaller graphics layer update scope 2927 // FIXME: Consider introducing a smaller graphics layer update scope
2932 // that just handles transforms and opacity. GraphicsLayerUpdateLocal 2928 // that just handles transforms and opacity. GraphicsLayerUpdateLocal
2933 // will also program bounds, clips, and many other properties that could 2929 // will also program bounds, clips, and many other properties that could
2934 // not possibly have changed. 2930 // not possibly have changed.
2935 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate( 2931 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate(
2936 GraphicsLayerUpdateLocal); 2932 GraphicsLayerUpdateLocal);
2937 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange); 2933 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange);
2938 2934
2939 if (m_scrollableArea) 2935 if (m_scrollableArea)
2940 m_scrollableArea->updateAfterStyleChange(oldStyle); 2936 m_scrollableArea->updateAfterStyleChange(oldStyle);
2941 2937
2942 return true; 2938 return true;
2943 } 2939 }
2944 2940
2945 void PaintLayer::styleDidChange(StyleDifference diff, 2941 void PaintLayer::styleDidChange(StyleDifference diff,
2946 const ComputedStyle* oldStyle) { 2942 const ComputedStyle* oldStyle) {
2947 if (attemptDirectCompositingUpdate(diff, oldStyle)) 2943 if (attemptDirectCompositingUpdate(diff, oldStyle))
2948 return; 2944 return;
2949 2945
2950 m_stackingNode->styleDidChange(oldStyle); 2946 m_stackingNode->styleDidChange(oldStyle);
2951 2947
2952 if (m_scrollableArea) 2948 if (m_scrollableArea)
2953 m_scrollableArea->updateAfterStyleChange(oldStyle); 2949 m_scrollableArea->updateAfterStyleChange(oldStyle);
2954 2950
2955 // Overlay scrollbars can make this layer self-painting so we need 2951 // Overlay scrollbars can make this layer self-painting so we need
2956 // to recompute the bit once scrollbars have been updated. 2952 // to recompute the bit once scrollbars have been updated.
2957 updateSelfPaintingLayer(); 2953 updateSelfPaintingLayer();
2958 2954
2959 updateTransform(oldStyle, layoutObject()->styleRef()); 2955 updateTransform(oldStyle, layoutObject().styleRef());
2960 updateFilters(oldStyle, layoutObject()->styleRef()); 2956 updateFilters(oldStyle, layoutObject().styleRef());
2961 updateClipPath(oldStyle, layoutObject()->styleRef()); 2957 updateClipPath(oldStyle, layoutObject().styleRef());
2962 2958
2963 setNeedsCompositingInputsUpdate(); 2959 setNeedsCompositingInputsUpdate();
2964 layoutObject()->setNeedsPaintPropertyUpdate(); 2960 layoutObject().setNeedsPaintPropertyUpdate();
2965 } 2961 }
2966 2962
2967 PaintLayerClipper PaintLayer::clipper( 2963 PaintLayerClipper PaintLayer::clipper(
2968 GeometryMapperOption geometryMapperOption) const { 2964 GeometryMapperOption geometryMapperOption) const {
2969 GeometryMapper* geometryMapper = nullptr; 2965 GeometryMapper* geometryMapper = nullptr;
2970 if (geometryMapperOption == UseGeometryMapper) { 2966 if (geometryMapperOption == UseGeometryMapper) {
2971 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); 2967 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
2972 if (FrameView* frameView = m_layoutObject->document().view()) 2968 if (FrameView* frameView = m_layoutObject.document().view())
2973 geometryMapper = &frameView->geometryMapper(); 2969 geometryMapper = &frameView->geometryMapper();
2974 } 2970 }
2975 return PaintLayerClipper(*this, geometryMapper); 2971 return PaintLayerClipper(*this, geometryMapper);
2976 } 2972 }
2977 2973
2978 bool PaintLayer::scrollsOverflow() const { 2974 bool PaintLayer::scrollsOverflow() const {
2979 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) 2975 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea())
2980 return scrollableArea->scrollsOverflow(); 2976 return scrollableArea->scrollsOverflow();
2981 2977
2982 return false; 2978 return false;
2983 } 2979 }
2984 2980
2985 FilterOperations PaintLayer::addReflectionToFilterOperations( 2981 FilterOperations PaintLayer::addReflectionToFilterOperations(
2986 const ComputedStyle& style) const { 2982 const ComputedStyle& style) const {
2987 FilterOperations filterOperations = style.filter(); 2983 FilterOperations filterOperations = style.filter();
2988 if (layoutObject()->hasReflection() && layoutObject()->isBox()) { 2984 if (layoutObject().hasReflection() && layoutObject().isBox()) {
2989 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); 2985 BoxReflection reflection = boxReflectionForPaintLayer(*this, style);
2990 filterOperations.operations().push_back( 2986 filterOperations.operations().push_back(
2991 BoxReflectFilterOperation::create(reflection)); 2987 BoxReflectFilterOperation::create(reflection));
2992 } 2988 }
2993 return filterOperations; 2989 return filterOperations;
2994 } 2990 }
2995 2991
2996 CompositorFilterOperations 2992 CompositorFilterOperations
2997 PaintLayer::createCompositorFilterOperationsForFilter( 2993 PaintLayer::createCompositorFilterOperationsForFilter(
2998 const ComputedStyle& style) { 2994 const ComputedStyle& style) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 FilterEffect* PaintLayer::lastFilterEffect() const { 3043 FilterEffect* PaintLayer::lastFilterEffect() const {
3048 // TODO(chrishtr): ensure (and assert) that compositing is clean here. 3044 // TODO(chrishtr): ensure (and assert) that compositing is clean here.
3049 if (!paintsWithFilters()) 3045 if (!paintsWithFilters())
3050 return nullptr; 3046 return nullptr;
3051 PaintLayerResourceInfo* resourceInfo = this->resourceInfo(); 3047 PaintLayerResourceInfo* resourceInfo = this->resourceInfo();
3052 DCHECK(resourceInfo); 3048 DCHECK(resourceInfo);
3053 3049
3054 if (resourceInfo->lastEffect()) 3050 if (resourceInfo->lastEffect())
3055 return resourceInfo->lastEffect(); 3051 return resourceInfo->lastEffect();
3056 3052
3057 const ComputedStyle& style = layoutObject()->styleRef(); 3053 const ComputedStyle& style = layoutObject().styleRef();
3058 FloatRect zoomedReferenceBox; 3054 FloatRect zoomedReferenceBox;
3059 if (style.filter().hasReferenceFilter()) 3055 if (style.filter().hasReferenceFilter())
3060 zoomedReferenceBox = boxForFilterOrMask(); 3056 zoomedReferenceBox = boxForFilterOrMask();
3061 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox, 3057 FilterEffectBuilder builder(enclosingNode(), zoomedReferenceBox,
3062 style.effectiveZoom()); 3058 style.effectiveZoom());
3063 resourceInfo->setLastEffect( 3059 resourceInfo->setLastEffect(
3064 builder.buildFilterEffect(addReflectionToFilterOperations(style))); 3060 builder.buildFilterEffect(addReflectionToFilterOperations(style)));
3065 return resourceInfo->lastEffect(); 3061 return resourceInfo->lastEffect();
3066 } 3062 }
3067 3063
3068 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const { 3064 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const {
3069 if (!hasFilterThatMovesPixels()) 3065 if (!hasFilterThatMovesPixels())
3070 return rect; 3066 return rect;
3071 3067
3072 // Ensure the filter-chain is refreshed wrt reference filters. 3068 // Ensure the filter-chain is refreshed wrt reference filters.
3073 // TODO(fs): Avoid having this side-effect inducing call. 3069 // TODO(fs): Avoid having this side-effect inducing call.
3074 lastFilterEffect(); 3070 lastFilterEffect();
3075 3071
3076 FilterOperations filterOperations = 3072 FilterOperations filterOperations =
3077 addReflectionToFilterOperations(layoutObject()->styleRef()); 3073 addReflectionToFilterOperations(layoutObject().styleRef());
3078 return filterOperations.mapRect(rect); 3074 return filterOperations.mapRect(rect);
3079 } 3075 }
3080 3076
3081 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const { 3077 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const {
3082 if (!hasFilterThatMovesPixels()) 3078 if (!hasFilterThatMovesPixels())
3083 return rect; 3079 return rect;
3084 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect))); 3080 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect)));
3085 } 3081 }
3086 3082
3087 bool PaintLayer::hasFilterThatMovesPixels() const { 3083 bool PaintLayer::hasFilterThatMovesPixels() const {
3088 if (!hasFilterInducingProperty()) 3084 if (!hasFilterInducingProperty())
3089 return false; 3085 return false;
3090 const ComputedStyle& style = layoutObject()->styleRef(); 3086 const ComputedStyle& style = layoutObject().styleRef();
3091 if (style.hasFilter() && style.filter().hasFilterThatMovesPixels()) 3087 if (style.hasFilter() && style.filter().hasFilterThatMovesPixels())
3092 return true; 3088 return true;
3093 if (style.hasBoxReflect()) 3089 if (style.hasBoxReflect())
3094 return true; 3090 return true;
3095 return false; 3091 return false;
3096 } 3092 }
3097 3093
3098 void PaintLayer::addLayerHitTestRects(LayerHitTestRects& rects) const { 3094 void PaintLayer::addLayerHitTestRects(LayerHitTestRects& rects) const {
3099 computeSelfHitTestRects(rects); 3095 computeSelfHitTestRects(rects);
3100 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) 3096 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()) { 3153 if (CompositedLayerMapping* groupedMapping = layer->groupedMapping()) {
3158 // TODO(wkorman): As we clean up the CompositedLayerMapping needsRepaint 3154 // TODO(wkorman): As we clean up the CompositedLayerMapping needsRepaint
3159 // logic to delegate to scrollbars, we may be able to remove the line 3155 // logic to delegate to scrollbars, we may be able to remove the line
3160 // below as well. 3156 // below as well.
3161 groupedMapping->owningLayer().setNeedsRepaint(); 3157 groupedMapping->owningLayer().setNeedsRepaint();
3162 return; 3158 return;
3163 } 3159 }
3164 3160
3165 PaintLayer* container = layer->compositingContainer(); 3161 PaintLayer* container = layer->compositingContainer();
3166 if (!container) { 3162 if (!container) {
3167 LayoutItem owner = layer->layoutObject()->frame()->ownerLayoutItem(); 3163 LayoutItem owner = layer->layoutObject().frame()->ownerLayoutItem();
3168 if (owner.isNull()) 3164 if (owner.isNull())
3169 break; 3165 break;
3170 container = owner.enclosingLayer(); 3166 container = owner.enclosingLayer();
3171 } 3167 }
3172 3168
3173 if (container->m_needsRepaint) 3169 if (container->m_needsRepaint)
3174 break; 3170 break;
3175 3171
3176 container->setNeedsRepaintInternal(); 3172 container->setNeedsRepaintInternal();
3177 layer = container; 3173 layer = container;
(...skipping 21 matching lines...) Expand all
3199 3195
3200 #ifndef NDEBUG 3196 #ifndef NDEBUG
3201 // FIXME: Rename? 3197 // FIXME: Rename?
3202 void showLayerTree(const blink::PaintLayer* layer) { 3198 void showLayerTree(const blink::PaintLayer* layer) {
3203 blink::DisableCompositingQueryAsserts disabler; 3199 blink::DisableCompositingQueryAsserts disabler;
3204 if (!layer) { 3200 if (!layer) {
3205 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3201 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3206 return; 3202 return;
3207 } 3203 }
3208 3204
3209 if (blink::LocalFrame* frame = layer->layoutObject()->frame()) { 3205 if (blink::LocalFrame* frame = layer->layoutObject().frame()) {
3210 WTF::String output = externalRepresentation( 3206 WTF::String output = externalRepresentation(
3211 frame, 3207 frame,
3212 blink::LayoutAsTextShowAllLayers | blink::LayoutAsTextShowLayerNesting | 3208 blink::LayoutAsTextShowAllLayers | blink::LayoutAsTextShowLayerNesting |
3213 blink::LayoutAsTextShowCompositedLayers | 3209 blink::LayoutAsTextShowCompositedLayers |
3214 blink::LayoutAsTextShowAddresses | 3210 blink::LayoutAsTextShowAddresses |
3215 blink::LayoutAsTextShowIDAndClass | 3211 blink::LayoutAsTextShowIDAndClass |
3216 blink::LayoutAsTextDontUpdateLayout | 3212 blink::LayoutAsTextDontUpdateLayout |
3217 blink::LayoutAsTextShowLayoutState, 3213 blink::LayoutAsTextShowLayoutState,
3218 layer); 3214 layer);
3219 LOG(INFO) << output.utf8().data(); 3215 LOG(INFO) << output.utf8().data();
3220 } 3216 }
3221 } 3217 }
3222 3218
3223 void showLayerTree(const blink::LayoutObject* layoutObject) { 3219 void showLayerTree(const blink::LayoutObject* layoutObject) {
3224 if (!layoutObject) { 3220 if (!layoutObject) {
3225 LOG(INFO) << "Cannot showLayerTree. Root is (nil)"; 3221 LOG(INFO) << "Cannot showLayerTree. Root is (nil)";
3226 return; 3222 return;
3227 } 3223 }
3228 showLayerTree(layoutObject->enclosingLayer()); 3224 showLayerTree(layoutObject->enclosingLayer());
3229 } 3225 }
3230 #endif 3226 #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