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

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

Issue 1407543003: Preliminary paint property walk implementation for SPv2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address the feedback Created 5 years, 2 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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "core/layout/LayoutScrollbarPart.h" 67 #include "core/layout/LayoutScrollbarPart.h"
68 #include "core/layout/LayoutTableCaption.h" 68 #include "core/layout/LayoutTableCaption.h"
69 #include "core/layout/LayoutTableCell.h" 69 #include "core/layout/LayoutTableCell.h"
70 #include "core/layout/LayoutTableCol.h" 70 #include "core/layout/LayoutTableCol.h"
71 #include "core/layout/LayoutTableRow.h" 71 #include "core/layout/LayoutTableRow.h"
72 #include "core/layout/LayoutTheme.h" 72 #include "core/layout/LayoutTheme.h"
73 #include "core/layout/LayoutView.h" 73 #include "core/layout/LayoutView.h"
74 #include "core/layout/compositing/PaintLayerCompositor.h" 74 #include "core/layout/compositing/PaintLayerCompositor.h"
75 #include "core/page/AutoscrollController.h" 75 #include "core/page/AutoscrollController.h"
76 #include "core/page/Page.h" 76 #include "core/page/Page.h"
77 #include "core/paint/ObjectPaintProperties.h"
77 #include "core/paint/ObjectPainter.h" 78 #include "core/paint/ObjectPainter.h"
78 #include "core/paint/PaintInfo.h" 79 #include "core/paint/PaintInfo.h"
79 #include "core/paint/PaintLayer.h" 80 #include "core/paint/PaintLayer.h"
80 #include "core/style/ContentData.h" 81 #include "core/style/ContentData.h"
81 #include "core/style/ShadowList.h" 82 #include "core/style/ShadowList.h"
82 #include "platform/HostWindow.h" 83 #include "platform/HostWindow.h"
83 #include "platform/JSONValues.h" 84 #include "platform/JSONValues.h"
84 #include "platform/RuntimeEnabledFeatures.h" 85 #include "platform/RuntimeEnabledFeatures.h"
85 #include "platform/TraceEvent.h" 86 #include "platform/TraceEvent.h"
86 #include "platform/TracedValue.h" 87 #include "platform/TracedValue.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 LayoutPoint position; // Stores the previous position from the paint invalid ation container. 142 LayoutPoint position; // Stores the previous position from the paint invalid ation container.
142 }; 143 };
143 144
144 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), "LayoutObj ect should stay small"); 145 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), "LayoutObj ect should stay small");
145 146
146 bool LayoutObject::s_affectsParentBlock = false; 147 bool LayoutObject::s_affectsParentBlock = false;
147 148
148 typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap; 149 typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap;
149 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = nullptr; 150 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = nullptr;
150 151
152 // The pointer to paint properties is implemented as a global hash map temporari ly,
153 // to avoid memory regression during the transition towards SPv2.
154 typedef HashMap<const LayoutObject*, OwnPtr<ObjectPaintProperties>> ObjectPaintP ropertiesMap;
155 static ObjectPaintPropertiesMap& objectPaintPropertiesMap()
156 {
157 DEFINE_STATIC_LOCAL(ObjectPaintPropertiesMap,
158 staticObjectPaintPropertiesMap, ());
pdr. 2015/10/21 21:02:45 Oops, I think this fell off the line before it.
trchen 2015/10/21 22:21:14 Done.
159 return staticObjectPaintPropertiesMap;
160 }
161
151 void* LayoutObject::operator new(size_t sz) 162 void* LayoutObject::operator new(size_t sz)
152 { 163 {
153 ASSERT(isMainThread()); 164 ASSERT(isMainThread());
154 return partitionAlloc(WTF::Partitions::layoutPartition(), sz); 165 return partitionAlloc(WTF::Partitions::layoutPartition(), sz);
155 } 166 }
156 167
157 void LayoutObject::operator delete(void* ptr) 168 void LayoutObject::operator delete(void* ptr)
158 { 169 {
159 ASSERT(isMainThread()); 170 ASSERT(isMainThread());
160 partitionFree(ptr); 171 partitionFree(ptr);
(...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg istry(); 2517 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg istry();
2507 if (registry.eventHandlerTargets(EventHandlerRegistry::TouchEvent)->cont ains(node())) 2518 if (registry.eventHandlerTargets(EventHandlerRegistry::TouchEvent)->cont ains(node()))
2508 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE vent); 2519 registry.didRemoveEventHandler(*node(), EventHandlerRegistry::TouchE vent);
2509 } 2520 }
2510 2521
2511 setAncestorLineBoxDirty(false); 2522 setAncestorLineBoxDirty(false);
2512 2523
2513 if (selectionPaintInvalidationMap) 2524 if (selectionPaintInvalidationMap)
2514 selectionPaintInvalidationMap->remove(this); 2525 selectionPaintInvalidationMap->remove(this);
2515 2526
2527 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
2528 clearObjectPaintProperties();
2529
2516 clearLayoutRootIfNeeded(); 2530 clearLayoutRootIfNeeded();
2517 2531
2518 if (m_style) { 2532 if (m_style) {
2519 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b gLayer = bgLayer->next()) { 2533 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b gLayer = bgLayer->next()) {
2520 if (StyleImage* backgroundImage = bgLayer->image()) 2534 if (StyleImage* backgroundImage = bgLayer->image())
2521 backgroundImage->removeClient(this); 2535 backgroundImage->removeClient(this);
2522 } 2536 }
2523 2537
2524 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas kLayer = maskLayer->next()) { 2538 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas kLayer = maskLayer->next()) {
2525 if (StyleImage* maskImage = maskLayer->image()) 2539 if (StyleImage* maskImage = maskLayer->image())
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 ASSERT(frameView()); 3465 ASSERT(frameView());
3452 if (m_bitfields.isBackgroundAttachmentFixedObject() == isBackgroundAttachmen tFixedObject) 3466 if (m_bitfields.isBackgroundAttachmentFixedObject() == isBackgroundAttachmen tFixedObject)
3453 return; 3467 return;
3454 m_bitfields.setIsBackgroundAttachmentFixedObject(isBackgroundAttachmentFixed Object); 3468 m_bitfields.setIsBackgroundAttachmentFixedObject(isBackgroundAttachmentFixed Object);
3455 if (isBackgroundAttachmentFixedObject) 3469 if (isBackgroundAttachmentFixedObject)
3456 frameView()->addBackgroundAttachmentFixedObject(this); 3470 frameView()->addBackgroundAttachmentFixedObject(this);
3457 else 3471 else
3458 frameView()->removeBackgroundAttachmentFixedObject(this); 3472 frameView()->removeBackgroundAttachmentFixedObject(this);
3459 } 3473 }
3460 3474
3475 ObjectPaintProperties* LayoutObject::objectPaintProperties() const
3476 {
3477 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
3478 return objectPaintPropertiesMap().get(this);
3479 }
3480
3481 ObjectPaintProperties& LayoutObject::ensureObjectPaintProperties()
3482 {
3483 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
3484 if (ObjectPaintProperties* properties = objectPaintProperties())
3485 return *properties;
3486 return *objectPaintPropertiesMap().set(this, ObjectPaintProperties::create() ).storedValue->value.get();
3487 }
3488
3489 void LayoutObject::clearObjectPaintProperties()
3490 {
3491 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
3492 objectPaintPropertiesMap().remove(this);
3493 }
3494
3461 } // namespace blink 3495 } // namespace blink
3462 3496
3463 #ifndef NDEBUG 3497 #ifndef NDEBUG
3464 3498
3465 void showTree(const blink::LayoutObject* object) 3499 void showTree(const blink::LayoutObject* object)
3466 { 3500 {
3467 if (object) 3501 if (object)
3468 object->showTreeForThis(); 3502 object->showTreeForThis();
3469 else 3503 else
3470 fprintf(stderr, "Cannot showTree. Root is (nil)\n"); 3504 fprintf(stderr, "Cannot showTree. Root is (nil)\n");
(...skipping 18 matching lines...) Expand all
3489 const blink::LayoutObject* root = object1; 3523 const blink::LayoutObject* root = object1;
3490 while (root->parent()) 3524 while (root->parent())
3491 root = root->parent(); 3525 root = root->parent();
3492 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3526 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3493 } else { 3527 } else {
3494 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3528 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3495 } 3529 }
3496 } 3530 }
3497 3531
3498 #endif 3532 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698