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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp

Issue 2811023002: Move LayoutBoxModelObject's PaintLayer member to rare paint data (Closed)
Patch Set: Created 3 years, 8 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 } 229 }
230 return kBackgroundPaintInGraphicsLayer; 230 return kBackgroundPaintInGraphicsLayer;
231 } 231 }
232 return paint_location; 232 return paint_location;
233 } 233 }
234 234
235 LayoutBoxModelObject::~LayoutBoxModelObject() { 235 LayoutBoxModelObject::~LayoutBoxModelObject() {
236 // Our layer should have been destroyed and cleared by now 236 // Our layer should have been destroyed and cleared by now
237 DCHECK(!HasLayer()); 237 DCHECK(!HasLayer());
238 DCHECK(!layer_); 238 DCHECK(!Layer());
239 } 239 }
240 240
241 void LayoutBoxModelObject::WillBeDestroyed() { 241 void LayoutBoxModelObject::WillBeDestroyed() {
242 ImageQualityController::Remove(*this); 242 ImageQualityController::Remove(*this);
243 243
244 // A continuation of this LayoutObject should be destroyed at subclasses. 244 // A continuation of this LayoutObject should be destroyed at subclasses.
245 DCHECK(!Continuation()); 245 DCHECK(!Continuation());
246 246
247 if (IsPositioned()) { 247 if (IsPositioned()) {
248 // Don't use this->view() because the document's layoutView has been set to 248 // Don't use this->view() because the document's layoutView has been set to
249 // 0 during destruction. 249 // 0 during destruction.
250 if (LocalFrame* frame = this->GetFrame()) { 250 if (LocalFrame* frame = this->GetFrame()) {
251 if (FrameView* frame_view = frame->View()) { 251 if (FrameView* frame_view = frame->View()) {
252 if (Style()->HasViewportConstrainedPosition()) 252 if (Style()->HasViewportConstrainedPosition())
253 frame_view->RemoveViewportConstrainedObject(*this); 253 frame_view->RemoveViewportConstrainedObject(*this);
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 LayoutObject::WillBeDestroyed(); 258 LayoutObject::WillBeDestroyed();
259 259
260 DestroyLayer(); 260 if (HasLayer())
261 DestroyLayer();
261 } 262 }
262 263
263 void LayoutBoxModelObject::StyleWillChange(StyleDifference diff, 264 void LayoutBoxModelObject::StyleWillChange(StyleDifference diff,
264 const ComputedStyle& new_style) { 265 const ComputedStyle& new_style) {
265 // This object's layer may begin or cease to be a stacking context, in which 266 // This object's layer may begin or cease to be a stacking context, in which
266 // case the paint invalidation container of this object and descendants may 267 // case the paint invalidation container of this object and descendants may
267 // change. Thus we need to invalidate paint eagerly for all such children. 268 // change. Thus we need to invalidate paint eagerly for all such children.
268 // PaintLayerCompositor::paintInvalidationOnCompositingChange() doesn't work 269 // PaintLayerCompositor::paintInvalidationOnCompositingChange() doesn't work
269 // for the case because we can only see the new paintInvalidationContainer 270 // for the case because we can only see the new paintInvalidationContainer
270 // during compositing update. 271 // during compositing update.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ((old_style->OriginalDisplay() == EDisplay::kBlock) || 322 ((old_style->OriginalDisplay() == EDisplay::kBlock) ||
322 (old_style->OriginalDisplay() == EDisplay::kInlineBlock))) 323 (old_style->OriginalDisplay() == EDisplay::kInlineBlock)))
323 Parent()->SetNeedsLayout(LayoutInvalidationReason::kChildChanged, 324 Parent()->SetNeedsLayout(LayoutInvalidationReason::kChildChanged,
324 kMarkContainerChain); 325 kMarkContainerChain);
325 326
326 PaintLayerType type = LayerTypeRequired(); 327 PaintLayerType type = LayerTypeRequired();
327 if (type != kNoPaintLayer) { 328 if (type != kNoPaintLayer) {
328 if (!Layer() && LayerCreationAllowedForSubtree()) { 329 if (!Layer() && LayerCreationAllowedForSubtree()) {
329 if (was_floating_before_style_changed && IsFloating()) 330 if (was_floating_before_style_changed && IsFloating())
330 SetChildNeedsLayout(); 331 SetChildNeedsLayout();
331 CreateLayer(); 332 CreateLayer();
chrishtr 2017/04/11 21:52:34 Move 333 inside and call this CreateLayerAfterStyl
pdr. 2017/04/11 22:36:01 Done
333 Layer()->InsertOnlyThisLayerAfterStyleChange();
332 if (Parent() && !NeedsLayout()) { 334 if (Parent() && !NeedsLayout()) {
333 // FIXME: We should call a specialized version of this function. 335 // FIXME: We should call a specialized version of this function.
334 Layer()->UpdateLayerPositionsAfterLayout(); 336 Layer()->UpdateLayerPositionsAfterLayout();
335 } 337 }
336 } 338 }
337 } else if (Layer() && Layer()->Parent()) { 339 } else if (Layer() && Layer()->Parent()) {
338 PaintLayer* parent_layer = Layer()->Parent(); 340 PaintLayer* parent_layer = Layer()->Parent();
339 // Either a transform wasn't specified or the object doesn't support 341 // Either a transform wasn't specified or the object doesn't support
340 // transforms, so just null out the bit. 342 // transforms, so just null out the bit.
341 SetHasTransformRelatedProperty(false); 343 SetHasTransformRelatedProperty(false);
342 SetHasReflection(false); 344 SetHasReflection(false);
343 Layer()->UpdateFilters(old_style, StyleRef()); 345 Layer()->UpdateFilters(old_style, StyleRef());
344 Layer()->UpdateClipPath(old_style, StyleRef()); 346 Layer()->UpdateClipPath(old_style, StyleRef());
345 // Calls destroyLayer() which clears m_layer. 347 // Calls DestroyLayer() which clears the layer.
346 Layer()->RemoveOnlyThisLayerAfterStyleChange(); 348 Layer()->RemoveOnlyThisLayerAfterStyleChange();
347 if (was_floating_before_style_changed && IsFloating()) 349 if (was_floating_before_style_changed && IsFloating())
348 SetChildNeedsLayout(); 350 SetChildNeedsLayout();
349 if (had_transform_related_property) { 351 if (had_transform_related_property) {
350 SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( 352 SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
351 LayoutInvalidationReason::kStyleChange); 353 LayoutInvalidationReason::kStyleChange);
352 } 354 }
353 if (!NeedsLayout()) { 355 if (!NeedsLayout()) {
354 // FIXME: We should call a specialized version of this function. 356 // FIXME: We should call a specialized version of this function.
355 parent_layer->UpdateLayerPositionsAfterLayout(); 357 parent_layer->UpdateLayerPositionsAfterLayout();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // as if we have saved constraints for this layer they were saved in the 498 // as if we have saved constraints for this layer they were saved in the
497 // previous frame. 499 // previous frame.
498 DisableCompositingQueryAsserts disabler; 500 DisableCompositingQueryAsserts disabler;
499 if (const PaintLayer* ancestor_overflow_layer = 501 if (const PaintLayer* ancestor_overflow_layer =
500 enclosing->AncestorOverflowLayer()) 502 enclosing->AncestorOverflowLayer())
501 ancestor_overflow_layer->GetScrollableArea() 503 ancestor_overflow_layer->GetScrollableArea()
502 ->InvalidateAllStickyConstraints(); 504 ->InvalidateAllStickyConstraints();
503 } 505 }
504 506
505 void LayoutBoxModelObject::CreateLayer() { 507 void LayoutBoxModelObject::CreateLayer() {
506 DCHECK(!layer_); 508 DCHECK(!HasLayer() && !Layer());
507 layer_ = WTF::MakeUnique<PaintLayer>(*this); 509 EnsureRarePaintData().SetLayer(WTF::MakeUnique<PaintLayer>(*this));
508 SetHasLayer(true); 510 SetHasLayer(true);
509 layer_->InsertOnlyThisLayerAfterStyleChange();
510 } 511 }
511 512
512 void LayoutBoxModelObject::DestroyLayer() { 513 void LayoutBoxModelObject::DestroyLayer() {
514 DCHECK(HasLayer() && Layer());
513 SetHasLayer(false); 515 SetHasLayer(false);
514 layer_ = nullptr; 516 GetRarePaintData()->SetLayer(nullptr);
515 } 517 }
516 518
517 bool LayoutBoxModelObject::HasSelfPaintingLayer() const { 519 bool LayoutBoxModelObject::HasSelfPaintingLayer() const {
518 return layer_ && layer_->IsSelfPaintingLayer(); 520 return Layer() && Layer()->IsSelfPaintingLayer();
519 } 521 }
520 522
521 PaintLayerScrollableArea* LayoutBoxModelObject::GetScrollableArea() const { 523 PaintLayerScrollableArea* LayoutBoxModelObject::GetScrollableArea() const {
522 return layer_ ? layer_->GetScrollableArea() : 0; 524 return Layer() ? Layer()->GetScrollableArea() : nullptr;
523 } 525 }
524 526
525 void LayoutBoxModelObject::AddLayerHitTestRects( 527 void LayoutBoxModelObject::AddLayerHitTestRects(
526 LayerHitTestRects& rects, 528 LayerHitTestRects& rects,
527 const PaintLayer* current_layer, 529 const PaintLayer* current_layer,
528 const LayoutPoint& layer_offset, 530 const LayoutPoint& layer_offset,
529 const LayoutRect& container_rect) const { 531 const LayoutRect& container_rect) const {
530 if (HasLayer()) { 532 if (HasLayer()) {
531 if (IsLayoutView()) { 533 if (IsLayoutView()) {
532 // LayoutView is handled with a special fast-path, but it needs to know 534 // LayoutView is handled with a special fast-path, but it needs to know
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 if (root_element_style->HasBackground()) 1481 if (root_element_style->HasBackground())
1480 return false; 1482 return false;
1481 1483
1482 if (GetNode() != GetDocument().FirstBodyElement()) 1484 if (GetNode() != GetDocument().FirstBodyElement())
1483 return false; 1485 return false;
1484 1486
1485 return true; 1487 return true;
1486 } 1488 }
1487 1489
1488 } // namespace blink 1490 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698