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

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

Issue 2513893002: Make ifdefs consistent in WebKit/Source/core/ (Closed)
Patch Set: Limited fix to /core/ only. Created 4 years 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 14 matching lines...) Expand all
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 * 26 *
27 */ 27 */
28 28
29 #include "core/layout/LayoutObject.h" 29 #include "core/layout/LayoutObject.h"
30 30
31 #include "core/animation/ElementAnimations.h" 31 #include "core/animation/ElementAnimations.h"
32 #include "core/css/resolver/StyleResolver.h" 32 #include "core/css/resolver/StyleResolver.h"
33 #include "core/dom/AXObjectCache.h" 33 #include "core/dom/AXObjectCache.h"
34 #include "core/dom/ElementTraversal.h" 34 #include "core/dom/ElementTraversal.h"
35 #include "core/dom/Node.h"
35 #include "core/dom/StyleChangeReason.h" 36 #include "core/dom/StyleChangeReason.h"
36 #include "core/dom/StyleEngine.h" 37 #include "core/dom/StyleEngine.h"
37 #include "core/dom/shadow/ShadowRoot.h" 38 #include "core/dom/shadow/ShadowRoot.h"
38 #include "core/editing/EditingUtilities.h" 39 #include "core/editing/EditingUtilities.h"
39 #include "core/editing/FrameSelection.h" 40 #include "core/editing/FrameSelection.h"
40 #include "core/editing/TextAffinity.h" 41 #include "core/editing/TextAffinity.h"
41 #include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h" 42 #include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h"
42 #include "core/frame/EventHandlerRegistry.h" 43 #include "core/frame/EventHandlerRegistry.h"
43 #include "core/frame/FrameView.h" 44 #include "core/frame/FrameView.h"
44 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 static bool gModifyLayoutTreeStructureAnyState = false; 98 static bool gModifyLayoutTreeStructureAnyState = false;
98 99
99 } // namespace 100 } // namespace
100 101
101 const LayoutUnit& caretWidth() { 102 const LayoutUnit& caretWidth() {
102 static LayoutUnit gCaretWidth(1); 103 static LayoutUnit gCaretWidth(1);
103 return gCaretWidth; 104 return gCaretWidth;
104 } 105 }
105 106
106 #if ENABLE(ASSERT) 107 #if DCHECK_IS_ON()
107 108
108 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope( 109 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(
109 LayoutObject& layoutObject) 110 LayoutObject& layoutObject)
110 : m_layoutObject(layoutObject), 111 : m_layoutObject(layoutObject),
111 m_preexistingForbidden(m_layoutObject.isSetNeedsLayoutForbidden()) { 112 m_preexistingForbidden(m_layoutObject.isSetNeedsLayoutForbidden()) {
112 m_layoutObject.setNeedsLayoutIsForbidden(true); 113 m_layoutObject.setNeedsLayoutIsForbidden(true);
113 } 114 }
114 115
115 LayoutObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() { 116 LayoutObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() {
116 m_layoutObject.setNeedsLayoutIsForbidden(m_preexistingForbidden); 117 m_layoutObject.setNeedsLayoutIsForbidden(m_preexistingForbidden);
117 } 118 }
118 #endif 119 #endif
119 120
120 struct SameSizeAsLayoutObject : DisplayItemClient { 121 struct SameSizeAsLayoutObject : DisplayItemClient {
121 virtual ~SameSizeAsLayoutObject() {} // Allocate vtable pointer. 122 virtual ~SameSizeAsLayoutObject() {} // Allocate vtable pointer.
122 void* pointers[5]; 123 void* pointers[5];
123 Member<void*> members[1]; 124 Member<void*> members[1];
124 #if ENABLE(ASSERT) 125 #if DCHECK_IS_ON()
125 unsigned m_debugBitfields : 2; 126 unsigned m_debugBitfields : 2;
126 #endif 127 #endif
127 unsigned m_bitfields; 128 unsigned m_bitfields;
128 unsigned m_bitfields2; 129 unsigned m_bitfields2;
129 LayoutRect m_visualRect; 130 LayoutRect m_visualRect;
130 LayoutPoint m_paintOffset; 131 LayoutPoint m_paintOffset;
131 std::unique_ptr<void*> m_paintProperties; 132 std::unique_ptr<void*> m_paintProperties;
132 }; 133 };
133 134
134 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), 135 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ASSERT_NOT_REACHED(); 219 ASSERT_NOT_REACHED();
219 return nullptr; 220 return nullptr;
220 } 221 }
221 222
222 LayoutObject::LayoutObject(Node* node) 223 LayoutObject::LayoutObject(Node* node)
223 : m_style(nullptr), 224 : m_style(nullptr),
224 m_node(node), 225 m_node(node),
225 m_parent(nullptr), 226 m_parent(nullptr),
226 m_previous(nullptr), 227 m_previous(nullptr),
227 m_next(nullptr), 228 m_next(nullptr),
228 #if ENABLE(ASSERT) 229 #if DCHECK_IS_ON()
229 m_hasAXObject(false), 230 m_hasAXObject(false),
230 m_setNeedsLayoutForbidden(false), 231 m_setNeedsLayoutForbidden(false),
231 #endif 232 #endif
232 m_bitfields(node) { 233 m_bitfields(node) {
233 InstanceCounters::incrementCounter(InstanceCounters::LayoutObjectCounter); 234 InstanceCounters::incrementCounter(InstanceCounters::LayoutObjectCounter);
234 if (m_node) 235 if (m_node)
235 frameView()->incrementLayoutObjectCount(); 236 frameView()->incrementLayoutObjectCount();
236 } 237 }
237 238
238 LayoutObject::~LayoutObject() { 239 LayoutObject::~LayoutObject() {
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 last = object; 790 last = object;
790 if (scheduleRelayout && objectIsRelayoutBoundary(last)) 791 if (scheduleRelayout && objectIsRelayoutBoundary(last))
791 break; 792 break;
792 object = container; 793 object = container;
793 } 794 }
794 795
795 if (scheduleRelayout) 796 if (scheduleRelayout)
796 last->scheduleRelayout(); 797 last->scheduleRelayout();
797 } 798 }
798 799
799 #if ENABLE(ASSERT) 800 #if DCHECK_IS_ON()
800 void LayoutObject::checkBlockPositionedObjectsNeedLayout() { 801 void LayoutObject::checkBlockPositionedObjectsNeedLayout() {
801 ASSERT(!needsLayout()); 802 ASSERT(!needsLayout());
802 803
803 if (isLayoutBlock()) 804 if (isLayoutBlock())
804 toLayoutBlock(this)->checkPositionedObjectsNeedLayout(); 805 toLayoutBlock(this)->checkPositionedObjectsNeedLayout();
805 } 806 }
806 #endif 807 #endif
807 808
808 void LayoutObject::setPreferredLogicalWidthsDirty(MarkingBehavior markParents) { 809 void LayoutObject::setPreferredLogicalWidthsDirty(MarkingBehavior markParents) {
809 m_bitfields.setPreferredLogicalWidthsDirty(true); 810 m_bitfields.setPreferredLogicalWidthsDirty(true);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 return false; 1299 return false;
1299 } 1300 }
1300 return parent->mapToVisualRectInAncestorSpace(ancestor, rect, 1301 return parent->mapToVisualRectInAncestorSpace(ancestor, rect,
1301 visualRectFlags); 1302 visualRectFlags);
1302 } 1303 }
1303 return true; 1304 return true;
1304 } 1305 }
1305 1306
1306 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*, MarkingBehavior) {} 1307 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*, MarkingBehavior) {}
1307 1308
1308 #ifndef NDEBUG 1309 #if DCHECK_IS_ON()
1309
1310 void LayoutObject::showTreeForThis() const { 1310 void LayoutObject::showTreeForThis() const {
1311 if (node()) 1311 if (node())
1312 ::showTree(node()); 1312 ::showTree(node());
1313 } 1313 }
1314 1314
1315 void LayoutObject::showLayoutTreeForThis() const { 1315 void LayoutObject::showLayoutTreeForThis() const {
1316 showLayoutTree(this, 0); 1316 showLayoutTree(this, 0);
1317 } 1317 }
1318 1318
1319 void LayoutObject::showLineTreeForThis() const { 1319 void LayoutObject::showLineTreeForThis() const {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 stringBuilder.append(' '); 1366 stringBuilder.append(' ');
1367 1367
1368 showLayoutObject(stringBuilder); 1368 showLayoutObject(stringBuilder);
1369 1369
1370 for (const LayoutObject* child = slowFirstChild(); child; 1370 for (const LayoutObject* child = slowFirstChild(); child;
1371 child = child->nextSibling()) 1371 child = child->nextSibling())
1372 child->showLayoutTreeAndMark(markedObject1, markedLabel1, markedObject2, 1372 child->showLayoutTreeAndMark(markedObject1, markedLabel1, markedObject2,
1373 markedLabel2, depth + 1); 1373 markedLabel2, depth + 1);
1374 } 1374 }
1375 1375
1376 #endif // NDEBUG 1376 #endif // DCHECK_IS_ON
1377 1377
1378 bool LayoutObject::isSelectable() const { 1378 bool LayoutObject::isSelectable() const {
1379 return !isInert() && 1379 return !isInert() &&
1380 !(style()->userSelect() == SELECT_NONE && 1380 !(style()->userSelect() == SELECT_NONE &&
1381 style()->userModify() == READ_ONLY); 1381 style()->userModify() == READ_ONLY);
1382 } 1382 }
1383 1383
1384 Color LayoutObject::selectionBackgroundColor() const { 1384 Color LayoutObject::selectionBackgroundColor() const {
1385 if (!isSelectable()) 1385 if (!isSelectable())
1386 return Color::transparent; 1386 return Color::transparent;
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() { 3369 void LayoutObject::setMayNeedPaintInvalidationAnimatedBackgroundImage() {
3370 if (mayNeedPaintInvalidationAnimatedBackgroundImage()) 3370 if (mayNeedPaintInvalidationAnimatedBackgroundImage())
3371 return; 3371 return;
3372 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true); 3372 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(true);
3373 setMayNeedPaintInvalidation(); 3373 setMayNeedPaintInvalidation();
3374 } 3374 }
3375 3375
3376 void LayoutObject::clearPaintInvalidationFlags() { 3376 void LayoutObject::clearPaintInvalidationFlags() {
3377 // paintInvalidationStateIsDirty should be kept in sync with the 3377 // paintInvalidationStateIsDirty should be kept in sync with the
3378 // booleans that are cleared below. 3378 // booleans that are cleared below.
3379 ASSERT(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || 3379 #if DCHECK_IS_ON()
3380 DCHECK(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() ||
3380 paintInvalidationStateIsDirty()); 3381 paintInvalidationStateIsDirty());
3382 #endif
3381 clearShouldDoFullPaintInvalidation(); 3383 clearShouldDoFullPaintInvalidation();
3382 m_bitfields.setChildShouldCheckForPaintInvalidation(false); 3384 m_bitfields.setChildShouldCheckForPaintInvalidation(false);
3383 m_bitfields.setMayNeedPaintInvalidation(false); 3385 m_bitfields.setMayNeedPaintInvalidation(false);
3384 m_bitfields.setMayNeedPaintInvalidationSubtree(false); 3386 m_bitfields.setMayNeedPaintInvalidationSubtree(false);
3385 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false); 3387 m_bitfields.setMayNeedPaintInvalidationAnimatedBackgroundImage(false);
3386 m_bitfields.setShouldInvalidateSelection(false); 3388 m_bitfields.setShouldInvalidateSelection(false);
3387 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false); 3389 m_bitfields.setBackgroundChangedSinceLastPaintInvalidation(false);
3388 } 3390 }
3389 3391
3390 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) { 3392 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3440 LayoutRect rect; 3442 LayoutRect rect;
3441 LayoutBlock* block = containingBlock(); 3443 LayoutBlock* block = containingBlock();
3442 if (block) 3444 if (block)
3443 block->adjustChildDebugRect(rect); 3445 block->adjustChildDebugRect(rect);
3444 3446
3445 return rect; 3447 return rect;
3446 } 3448 }
3447 3449
3448 } // namespace blink 3450 } // namespace blink
3449 3451
3450 #ifndef NDEBUG 3452 #if DCHECK_IS_ON()
3451 3453
3452 void showTree(const blink::LayoutObject* object) { 3454 void showTree(const blink::LayoutObject* object) {
3453 if (object) 3455 if (object)
3454 object->showTreeForThis(); 3456 object->showTreeForThis();
3455 else 3457 else
3456 WTFLogAlways("%s", "Cannot showTree. Root is (nil)"); 3458 WTFLogAlways("%s", "Cannot showTree. Root is (nil)");
3457 } 3459 }
3458 3460
3459 void showLineTree(const blink::LayoutObject* object) { 3461 void showLineTree(const blink::LayoutObject* object) {
3460 if (object) 3462 if (object)
(...skipping 12 matching lines...) Expand all
3473 const blink::LayoutObject* root = object1; 3475 const blink::LayoutObject* root = object1;
3474 while (root->parent()) 3476 while (root->parent())
3475 root = root->parent(); 3477 root = root->parent();
3476 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3478 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3477 } else { 3479 } else {
3478 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3480 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3479 } 3481 }
3480 } 3482 }
3481 3483
3482 #endif 3484 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698