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

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

Issue 1577433003: Statistics of LayoutBox rare data reasons Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 3 years, 9 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. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2009 Google Inc. All rights reserved. 8 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #endif 94 #endif
95 95
96 namespace blink { 96 namespace blink {
97 97
98 namespace { 98 namespace {
99 99
100 static bool gModifyLayoutTreeStructureAnyState = false; 100 static bool gModifyLayoutTreeStructureAnyState = false;
101 101
102 } // namespace 102 } // namespace
103 103
104 int RareDataStat::s_reasonCounts[MaxReason] = {0};
105
106 int* rareDataReasonCounts() {
107 return RareDataStat::s_reasonCounts;
108 }
109
104 #if DCHECK_IS_ON() 110 #if DCHECK_IS_ON()
105 111
106 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope( 112 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(
107 LayoutObject& layoutObject) 113 LayoutObject& layoutObject)
108 : m_layoutObject(layoutObject), 114 : m_layoutObject(layoutObject),
109 m_preexistingForbidden(m_layoutObject.isSetNeedsLayoutForbidden()) { 115 m_preexistingForbidden(m_layoutObject.isSetNeedsLayoutForbidden()) {
110 m_layoutObject.setNeedsLayoutIsForbidden(true); 116 m_layoutObject.setNeedsLayoutIsForbidden(true);
111 } 117 }
112 118
113 LayoutObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() { 119 LayoutObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() {
114 m_layoutObject.setNeedsLayoutIsForbidden(m_preexistingForbidden); 120 m_layoutObject.setNeedsLayoutIsForbidden(m_preexistingForbidden);
115 } 121 }
116 #endif 122 #endif
117 123
118 struct SameSizeAsLayoutObject : DisplayItemClient { 124 struct SameSizeAsLayoutObject : DisplayItemClient {
119 virtual ~SameSizeAsLayoutObject() {} // Allocate vtable pointer. 125 virtual ~SameSizeAsLayoutObject() {} // Allocate vtable pointer.
120 void* pointers[5]; 126 void* pointers[5];
121 Member<void*> members[1]; 127 Member<void*> members[1];
122 #if DCHECK_IS_ON() 128 #if DCHECK_IS_ON()
123 unsigned m_debugBitfields : 2; 129 unsigned m_debugBitfields : 2;
124 #endif 130 #endif
125 unsigned m_bitfields; 131 unsigned m_bitfields;
126 unsigned m_bitfields2; 132 unsigned m_bitfields2;
127 LayoutRect m_visualRect; 133 LayoutRect m_visualRect;
128 LayoutPoint m_paintOffset; 134 LayoutPoint m_paintOffset;
129 std::unique_ptr<void*> m_paintProperties; 135 std::unique_ptr<void*> m_paintProperties;
130 }; 136 };
131 137
132 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), 138 // static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject),
133 "LayoutObject should stay small"); 139 // "LayoutObject should stay small");
134 140
135 bool LayoutObject::s_affectsParentBlock = false; 141 bool LayoutObject::s_affectsParentBlock = false;
136 142
137 void* LayoutObject::operator new(size_t sz) { 143 void* LayoutObject::operator new(size_t sz) {
138 ASSERT(isMainThread()); 144 ASSERT(isMainThread());
139 return PartitionAlloc(WTF::Partitions::layoutPartition(), sz, 145 return PartitionAlloc(WTF::Partitions::layoutPartition(), sz,
140 WTF_HEAP_PROFILER_TYPE_NAME(LayoutObject)); 146 WTF_HEAP_PROFILER_TYPE_NAME(LayoutObject));
141 } 147 }
142 148
143 void LayoutObject::operator delete(void* ptr) { 149 void LayoutObject::operator delete(void* ptr) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 m_previous(nullptr), 231 m_previous(nullptr),
226 m_next(nullptr), 232 m_next(nullptr),
227 #if DCHECK_IS_ON() 233 #if DCHECK_IS_ON()
228 m_hasAXObject(false), 234 m_hasAXObject(false),
229 m_setNeedsLayoutForbidden(false), 235 m_setNeedsLayoutForbidden(false),
230 #endif 236 #endif
231 m_bitfields(node) { 237 m_bitfields(node) {
232 InstanceCounters::incrementCounter(InstanceCounters::LayoutObjectCounter); 238 InstanceCounters::incrementCounter(InstanceCounters::LayoutObjectCounter);
233 if (m_node) 239 if (m_node)
234 frameView()->incrementLayoutObjectCount(); 240 frameView()->incrementLayoutObjectCount();
241
242 m_rareStat.addReason(ReasonLOAll);
235 } 243 }
236 244
237 LayoutObject::~LayoutObject() { 245 LayoutObject::~LayoutObject() {
238 #if DCHECK_IS_ON() 246 #if DCHECK_IS_ON()
239 DCHECK(!m_hasAXObject); 247 DCHECK(!m_hasAXObject);
240 #endif 248 #endif
241 InstanceCounters::decrementCounter(InstanceCounters::LayoutObjectCounter); 249 InstanceCounters::decrementCounter(InstanceCounters::LayoutObjectCounter);
242 } 250 }
243 251
244 bool LayoutObject::isDescendantOf(const LayoutObject* obj) const { 252 bool LayoutObject::isDescendantOf(const LayoutObject* obj) const {
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 ObjectPaintInvalidator paintInvalidator(*this); 1211 ObjectPaintInvalidator paintInvalidator(*this);
1204 context.oldVisualRect = visualRect(); 1212 context.oldVisualRect = visualRect();
1205 context.oldLocation = paintInvalidator.locationInBacking(); 1213 context.oldLocation = paintInvalidator.locationInBacking();
1206 LayoutRect newVisualRect = 1214 LayoutRect newVisualRect =
1207 paintInvalidationState.computeVisualRectInBacking(); 1215 paintInvalidationState.computeVisualRectInBacking();
1208 context.newLocation = 1216 context.newLocation =
1209 paintInvalidationState.computeLocationInBacking(newVisualRect.location()); 1217 paintInvalidationState.computeLocationInBacking(newVisualRect.location());
1210 1218
1211 setVisualRect(newVisualRect); 1219 setVisualRect(newVisualRect);
1212 paintInvalidator.setLocationInBacking(context.newLocation); 1220 paintInvalidator.setLocationInBacking(context.newLocation);
1221 if (!newVisualRect.isEmpty() &&
1222 newVisualRect.location() != context.newLocation) {
1223 m_rareStat.addReason(ReasonLocationOffsetObject);
1224 if (isBox())
1225 m_rareStat.addReason(ReasonLocationOffsetBox);
1226 if (isText())
1227 m_rareStat.addReason(ReasonLocationOffsetText);
1228 if (isLayoutInline())
1229 m_rareStat.addReason(ReasonLocationOffsetInline);
1230 if (isSVG())
1231 m_rareStat.addReason(ReasonLocationOffsetSVG);
1232 }
1213 1233
1214 if (!shouldCheckForPaintInvalidation() && 1234 if (!shouldCheckForPaintInvalidation() &&
1215 paintInvalidationState 1235 paintInvalidationState
1216 .forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) { 1236 .forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) {
1217 // We are done updating the visual rect. No other paint invalidation work 1237 // We are done updating the visual rect. No other paint invalidation work
1218 // to do for this object. 1238 // to do for this object.
1219 return PaintInvalidationNone; 1239 return PaintInvalidationNone;
1220 } 1240 }
1221 1241
1222 return invalidatePaintIfNeeded(context); 1242 return invalidatePaintIfNeeded(context);
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 const blink::LayoutObject* root = object1; 3665 const blink::LayoutObject* root = object1;
3646 while (root->parent()) 3666 while (root->parent())
3647 root = root->parent(); 3667 root = root->parent();
3648 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3668 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3649 } else { 3669 } else {
3650 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3670 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3651 } 3671 }
3652 } 3672 }
3653 3673
3654 #endif 3674 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698