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

Side by Side Diff: Source/core/layout/LayoutObject.h

Issue 1124993002: Cleanup: Only need one bit (not two) to express flow thread state. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutMultiColumnFlowThread.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 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) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Convenience function for getting to the nearest enclosing box of a Layout Object. 196 // Convenience function for getting to the nearest enclosing box of a Layout Object.
197 LayoutBox* enclosingBox() const; 197 LayoutBox* enclosingBox() const;
198 LayoutBoxModelObject* enclosingBoxModelObject() const; 198 LayoutBoxModelObject* enclosingBoxModelObject() const;
199 199
200 LayoutBox* enclosingScrollableBox() const; 200 LayoutBox* enclosingScrollableBox() const;
201 201
202 // Function to return our enclosing flow thread if we are contained inside o ne. This 202 // Function to return our enclosing flow thread if we are contained inside o ne. This
203 // function follows the containing block chain. 203 // function follows the containing block chain.
204 LayoutFlowThread* flowThreadContainingBlock() const 204 LayoutFlowThread* flowThreadContainingBlock() const
205 { 205 {
206 if (flowThreadState() == NotInsideFlowThread) 206 if (!isInsideFlowThread())
207 return 0; 207 return 0;
208 return locateFlowThreadContainingBlock(); 208 return locateFlowThreadContainingBlock();
209 } 209 }
210 210
211 #if ENABLE(ASSERT) 211 #if ENABLE(ASSERT)
212 void setHasAXObject(bool flag) { m_hasAXObject = flag; } 212 void setHasAXObject(bool flag) { m_hasAXObject = flag; }
213 bool hasAXObject() const { return m_hasAXObject; } 213 bool hasAXObject() const { return m_hasAXObject; }
214 214
215 // Helper class forbidding calls to setNeedsLayout() during its lifetime. 215 // Helper class forbidding calls to setNeedsLayout() during its lifetime.
216 class SetLayoutNeededForbiddenScope { 216 class SetLayoutNeededForbiddenScope {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Helper functions. Dangerous to use! 280 // Helper functions. Dangerous to use!
281 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 281 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
282 void setNextSibling(LayoutObject* next) { m_next = next; } 282 void setNextSibling(LayoutObject* next) { m_next = next; }
283 void setParent(LayoutObject* parent) 283 void setParent(LayoutObject* parent)
284 { 284 {
285 m_parent = parent; 285 m_parent = parent;
286 286
287 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread. 287 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread.
288 // A LayoutFlowThread is always considered to be inside itself, so it ne ver has to change its state 288 // A LayoutFlowThread is always considered to be inside itself, so it ne ver has to change its state
289 // in response to parent changes. 289 // in response to parent changes.
290 FlowThreadState newState = parent ? parent->flowThreadState() : NotInsid eFlowThread; 290 bool insideFlowThread = parent && parent->isInsideFlowThread();
291 if (newState != flowThreadState() && !isLayoutFlowThread()) 291 if (insideFlowThread != isInsideFlowThread() && !isLayoutFlowThread())
292 setFlowThreadStateIncludingDescendants(newState); 292 setIsInsideFlowThreadIncludingDescendants(insideFlowThread);
293 } 293 }
294 294
295 ////////////////////////////////////////// 295 //////////////////////////////////////////
296 private: 296 private:
297 #if ENABLE(ASSERT) 297 #if ENABLE(ASSERT)
298 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; } 298 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
299 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag ; } 299 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag ; }
300 #endif 300 #endif
301 301
302 void addAbsoluteRectForLayer(IntRect& result); 302 void addAbsoluteRectForLayer(IntRect& result);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 424
425 bool ancestorLineBoxDirty() const { return m_bitfields.ancestorLineBoxDirty( ); } 425 bool ancestorLineBoxDirty() const { return m_bitfields.ancestorLineBoxDirty( ); }
426 void setAncestorLineBoxDirty(bool value = true) 426 void setAncestorLineBoxDirty(bool value = true)
427 { 427 {
428 m_bitfields.setAncestorLineBoxDirty(value); 428 m_bitfields.setAncestorLineBoxDirty(value);
429 if (value) 429 if (value)
430 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Lin eBoxesChanged); 430 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Lin eBoxesChanged);
431 } 431 }
432 432
433 enum FlowThreadState { 433 void setIsInsideFlowThreadIncludingDescendants(bool);
434 NotInsideFlowThread = 0,
435 InsideOutOfFlowThread = 1,
436 InsideInFlowThread = 2,
437 };
438 434
439 void setFlowThreadStateIncludingDescendants(FlowThreadState); 435 bool isInsideFlowThread() const { return m_bitfields.isInsideFlowThread(); }
440 436 void setIsInsideFlowThread(bool insideFlowThread) { m_bitfields.setIsInsideF lowThread(insideFlowThread); }
441 FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState (); }
442 void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadSt ate(state); }
443 437
444 // FIXME: Until all SVG layoutObjects can be subclasses of LayoutSVGModelObj ect we have 438 // FIXME: Until all SVG layoutObjects can be subclasses of LayoutSVGModelObj ect we have
445 // to add SVG layoutObject methods to LayoutObject with an ASSERT_NOT_REACHE D() default implementation. 439 // to add SVG layoutObject methods to LayoutObject with an ASSERT_NOT_REACHE D() default implementation.
446 bool isSVG() const { return isOfType(LayoutObjectSVG); } 440 bool isSVG() const { return isOfType(LayoutObjectSVG); }
447 bool isSVGRoot() const { return isOfType(LayoutObjectSVGRoot); } 441 bool isSVGRoot() const { return isOfType(LayoutObjectSVGRoot); }
448 bool isSVGContainer() const { return isOfType(LayoutObjectSVGContainer); } 442 bool isSVGContainer() const { return isOfType(LayoutObjectSVGContainer); }
449 bool isSVGTransformableContainer() const { return isOfType(LayoutObjectSVGTr ansformableContainer); } 443 bool isSVGTransformableContainer() const { return isOfType(LayoutObjectSVGTr ansformableContainer); }
450 bool isSVGViewportContainer() const { return isOfType(LayoutObjectSVGViewpor tContainer); } 444 bool isSVGViewportContainer() const { return isOfType(LayoutObjectSVGViewpor tContainer); }
451 bool isSVGGradientStop() const { return isOfType(LayoutObjectSVGGradientStop ); } 445 bool isSVGGradientStop() const { return isOfType(LayoutObjectSVGGradientStop ); }
452 bool isSVGHiddenContainer() const { return isOfType(LayoutObjectSVGHiddenCon tainer); } 446 bool isSVGHiddenContainer() const { return isOfType(LayoutObjectSVGHiddenCon tainer); }
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 , m_isDragging(false) 1294 , m_isDragging(false)
1301 , m_hasLayer(false) 1295 , m_hasLayer(false)
1302 , m_hasOverflowClip(false) 1296 , m_hasOverflowClip(false)
1303 , m_hasTransformRelatedProperty(false) 1297 , m_hasTransformRelatedProperty(false)
1304 , m_hasReflection(false) 1298 , m_hasReflection(false)
1305 , m_hasCounterNodeMap(false) 1299 , m_hasCounterNodeMap(false)
1306 , m_everHadLayout(false) 1300 , m_everHadLayout(false)
1307 , m_ancestorLineBoxDirty(false) 1301 , m_ancestorLineBoxDirty(false)
1308 , m_layoutDidGetCalledSinceLastFrame(false) 1302 , m_layoutDidGetCalledSinceLastFrame(false)
1309 , m_hasPendingResourceUpdate(false) 1303 , m_hasPendingResourceUpdate(false)
1304 , m_isInsideFlowThread(false)
1310 , m_childrenInline(false) 1305 , m_childrenInline(false)
1311 , m_hasColumns(false) 1306 , m_hasColumns(false)
1312 , m_alwaysCreateLineBoxesForLayoutInline(false) 1307 , m_alwaysCreateLineBoxesForLayoutInline(false)
1313 , m_lastBoxDecorationBackgroundObscured(false) 1308 , m_lastBoxDecorationBackgroundObscured(false)
1314 , m_positionedState(IsStaticallyPositioned) 1309 , m_positionedState(IsStaticallyPositioned)
1315 , m_selectionState(SelectionNone) 1310 , m_selectionState(SelectionNone)
1316 , m_flowThreadState(NotInsideFlowThread)
1317 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) 1311 , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
1318 , m_fullPaintInvalidationReason(PaintInvalidationNone) 1312 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1319 { 1313 {
1320 } 1314 }
1321 1315
1322 // 32 bits have been used in the first word, and 14 in the second. 1316 // 32 bits have been used in the first word, and 14 in the second.
mstensho (USE GERRIT) 2015/05/05 19:09:09 Note: I counted the bits over and over again, and
1323 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); 1317 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1324 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); 1318 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint);
1325 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; 1319 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ;
1326 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); 1320 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n);
1327 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); 1321 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren);
1328 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout); 1322 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout);
1329 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); 1323 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
1330 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); 1324 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
1331 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout); 1325 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout);
1332 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty); 1326 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty);
(...skipping 15 matching lines...) Expand all
1348 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection); 1342 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1349 1343
1350 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap); 1344 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
1351 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout); 1345 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1352 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty); 1346 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty);
1353 1347
1354 ADD_BOOLEAN_BITFIELD(layoutDidGetCalledSinceLastFrame, LayoutDidGetCalle dSinceLastFrame); 1348 ADD_BOOLEAN_BITFIELD(layoutDidGetCalledSinceLastFrame, LayoutDidGetCalle dSinceLastFrame);
1355 1349
1356 ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate) ; 1350 ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate) ;
1357 1351
1352 ADD_BOOLEAN_BITFIELD(isInsideFlowThread, IsInsideFlowThread);
1353
1358 // from LayoutBlock 1354 // from LayoutBlock
1359 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline); 1355 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1360 ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns); 1356 ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
1361 1357
1362 // from LayoutInline 1358 // from LayoutInline
1363 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForLayoutInline, AlwaysCreateL ineBoxesForLayoutInline); 1359 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForLayoutInline, AlwaysCreateL ineBoxesForLayoutInline);
1364 1360
1365 // For slimming-paint. 1361 // For slimming-paint.
1366 ADD_BOOLEAN_BITFIELD(lastBoxDecorationBackgroundObscured, LastBoxDecorat ionBackgroundObscured); 1362 ADD_BOOLEAN_BITFIELD(lastBoxDecorationBackgroundObscured, LastBoxDecorat ionBackgroundObscured);
1367 1363
1368 private: 1364 private:
1369 unsigned m_positionedState : 2; // PositionedState 1365 unsigned m_positionedState : 2; // PositionedState
1370 unsigned m_selectionState : 3; // SelectionState 1366 unsigned m_selectionState : 3; // SelectionState
1371 unsigned m_flowThreadState : 2; // FlowThreadState
1372 unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundS tate 1367 unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundS tate
1373 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason 1368 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
1374 1369
1375 public: 1370 public:
1376 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; } 1371 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; }
1377 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; } 1372 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; }
1378 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; } 1373 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; }
1379 1374
1380 void setPositionedState(int positionState) 1375 void setPositionedState(int positionState)
1381 { 1376 {
1382 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit. 1377 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit.
1383 m_positionedState = static_cast<PositionedState>(positionState & 0x3 ); 1378 m_positionedState = static_cast<PositionedState>(positionState & 0x3 );
1384 } 1379 }
1385 void clearPositionedState() { m_positionedState = StaticPosition; } 1380 void clearPositionedState() { m_positionedState = StaticPosition; }
1386 1381
1387 ALWAYS_INLINE SelectionState selectionState() const { return static_cast <SelectionState>(m_selectionState); } 1382 ALWAYS_INLINE SelectionState selectionState() const { return static_cast <SelectionState>(m_selectionState); }
1388 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; } 1383 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; }
1389 1384
1390 ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_ca st<FlowThreadState>(m_flowThreadState); }
1391 ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
1392
1393 ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState( ) const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgr oundState); } 1385 ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState( ) const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgr oundState); }
1394 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou ndState s) { m_boxDecorationBackgroundState = s; } 1386 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou ndState s) { m_boxDecorationBackgroundState = s; }
1395 1387
1396 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); } 1388 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); }
1397 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; } 1389 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; }
1398 }; 1390 };
1399 1391
1400 #undef ADD_BOOLEAN_BITFIELD 1392 #undef ADD_BOOLEAN_BITFIELD
1401 1393
1402 LayoutObjectBitfields m_bitfields; 1394 LayoutObjectBitfields m_bitfields;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 void showTree(const blink::LayoutObject*); 1641 void showTree(const blink::LayoutObject*);
1650 void showLineTree(const blink::LayoutObject*); 1642 void showLineTree(const blink::LayoutObject*);
1651 void showLayoutTree(const blink::LayoutObject* object1); 1643 void showLayoutTree(const blink::LayoutObject* object1);
1652 // We don't make object2 an optional parameter so that showLayoutTree 1644 // We don't make object2 an optional parameter so that showLayoutTree
1653 // can be called from gdb easily. 1645 // can be called from gdb easily.
1654 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 1646 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
1655 1647
1656 #endif 1648 #endif
1657 1649
1658 #endif // LayoutObject_h 1650 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutMultiColumnFlowThread.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698