Cleanup: Only need one bit (not two) to express flow thread state.

The InsideOutOfFlowThread / InsideInFlowThread distinction is a relic from the
CSS Regions days. Just telling whether we're a descendant of a flow thread or
not is enough.

R=dsinclair@chromium.org

Review URL: https://codereview.chromium.org/1124993002

git-svn-id: svn://svn.chromium.org/blink/trunk@194945 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp b/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp
index eb6543a..de0fe15 100644
--- a/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp
@@ -132,7 +132,7 @@
 
     // Make sure the LayoutObject already knows it is going to be added to a LayoutFlowThread before we set the style
     // for the first time. Otherwise code using inLayoutFlowThread() in the styleWillChange and styleDidChange will fail.
-    newLayoutObject->setFlowThreadState(parentLayoutObject->flowThreadState());
+    newLayoutObject->setIsInsideFlowThread(parentLayoutObject->isInsideFlowThread());
 
     LayoutObject* nextLayoutObject = this->nextLayoutObject();
     m_node->setLayoutObject(newLayoutObject);
@@ -163,7 +163,7 @@
 
     // Make sure the LayoutObject already knows it is going to be added to a LayoutFlowThread before we set the style
     // for the first time. Otherwise code using inLayoutFlowThread() in the styleWillChange and styleDidChange will fail.
-    newLayoutObject->setFlowThreadState(parentLayoutObject->flowThreadState());
+    newLayoutObject->setIsInsideFlowThread(parentLayoutObject->isInsideFlowThread());
 
     LayoutObject* nextLayoutObject = this->nextLayoutObject();
     m_node->setLayoutObject(newLayoutObject);
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index c6c13a2..700f7ac 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -596,7 +596,7 @@
         // generated content added yet.
         cloneBlock->setChildrenInline(cloneBlock->firstChild() ? cloneBlock->firstChild()->isInline() : childrenInline());
     }
-    cloneBlock->setFlowThreadState(flowThreadState());
+    cloneBlock->setIsInsideFlowThread(isInsideFlowThread());
     return cloneBlock;
 }
 
diff --git a/third_party/WebKit/Source/core/layout/LayoutFlowThread.cpp b/third_party/WebKit/Source/core/layout/LayoutFlowThread.cpp
index cb0391c..cc2f99e5 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFlowThread.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFlowThread.cpp
@@ -42,7 +42,6 @@
     , m_regionsHaveUniformLogicalHeight(true)
     , m_pageLogicalSizeChanged(false)
 {
-    setFlowThreadState(InsideOutOfFlowThread);
 }
 
 void LayoutFlowThread::removeRegionFromThread(LayoutMultiColumnSet* columnSet)
diff --git a/third_party/WebKit/Source/core/layout/LayoutInline.cpp b/third_party/WebKit/Source/core/layout/LayoutInline.cpp
index d1b173a..5bfdcae 100644
--- a/third_party/WebKit/Source/core/layout/LayoutInline.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutInline.cpp
@@ -360,7 +360,7 @@
 {
     LayoutInline* cloneInline = new LayoutInline(node());
     cloneInline->setStyle(mutableStyle());
-    cloneInline->setFlowThreadState(flowThreadState());
+    cloneInline->setIsInsideFlowThread(isInsideFlowThread());
     return cloneInline;
 }
 
diff --git a/third_party/WebKit/Source/core/layout/LayoutMultiColumnFlowThread.cpp b/third_party/WebKit/Source/core/layout/LayoutMultiColumnFlowThread.cpp
index 1db0643..f792bfb6 100644
--- a/third_party/WebKit/Source/core/layout/LayoutMultiColumnFlowThread.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutMultiColumnFlowThread.cpp
@@ -40,7 +40,7 @@
     , m_progressionIsInline(true)
     , m_isBeingEvacuated(false)
 {
-    setFlowThreadState(InsideInFlowThread);
+    setIsInsideFlowThread(true);
 }
 
 LayoutMultiColumnFlowThread::~LayoutMultiColumnFlowThread()
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index bfc7614..8e598ba 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -265,7 +265,7 @@
     return isHTMLLegendElement(node());
 }
 
-void LayoutObject::setFlowThreadStateIncludingDescendants(FlowThreadState state)
+void LayoutObject::setIsInsideFlowThreadIncludingDescendants(bool insideFlowThread)
 {
     LayoutObject* next;
     for (LayoutObject *object = this; object; object = next) {
@@ -275,8 +275,8 @@
             continue;
         }
         next = object->nextInPreOrder(this);
-        ASSERT(state != object->flowThreadState());
-        object->setFlowThreadState(state);
+        ASSERT(insideFlowThread != object->isInsideFlowThread());
+        object->setIsInsideFlowThread(insideFlowThread);
     }
 }
 
@@ -598,7 +598,7 @@
 
 LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const
 {
-    ASSERT(flowThreadState() != NotInsideFlowThread);
+    ASSERT(isInsideFlowThread());
 
     // See if we have the thread cached because we're in the middle of layout.
     if (LayoutState* layoutState = view()->layoutState()) {
@@ -2515,7 +2515,7 @@
 
 void LayoutObject::removeFromLayoutFlowThread()
 {
-    if (flowThreadState() == NotInsideFlowThread)
+    if (!isInsideFlowThread())
         return;
 
     // Sometimes we remove the element from the flow, but it's not destroyed at that time.
@@ -2542,7 +2542,7 @@
 
     if (layoutFlowThread && layoutFlowThread != this)
         layoutFlowThread->flowThreadDescendantWillBeRemoved(this);
-    setFlowThreadState(NotInsideFlowThread);
+    setIsInsideFlowThread(false);
     RELEASE_ASSERT(!spannerPlaceholder());
 }
 
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index 2927ce9..08fbdeb04 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -203,7 +203,7 @@
     // function follows the containing block chain.
     LayoutFlowThread* flowThreadContainingBlock() const
     {
-        if (flowThreadState() == NotInsideFlowThread)
+        if (!isInsideFlowThread())
             return 0;
         return locateFlowThreadContainingBlock();
     }
@@ -287,9 +287,9 @@
         // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread.
         // A LayoutFlowThread is always considered to be inside itself, so it never has to change its state
         // in response to parent changes.
-        FlowThreadState newState = parent ? parent->flowThreadState() : NotInsideFlowThread;
-        if (newState != flowThreadState() && !isLayoutFlowThread())
-            setFlowThreadStateIncludingDescendants(newState);
+        bool insideFlowThread = parent && parent->isInsideFlowThread();
+        if (insideFlowThread != isInsideFlowThread() && !isLayoutFlowThread())
+            setIsInsideFlowThreadIncludingDescendants(insideFlowThread);
     }
 
     //////////////////////////////////////////
@@ -430,16 +430,10 @@
             setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::LineBoxesChanged);
     }
 
-    enum FlowThreadState {
-        NotInsideFlowThread = 0,
-        InsideOutOfFlowThread = 1,
-        InsideInFlowThread = 2,
-    };
+    void setIsInsideFlowThreadIncludingDescendants(bool);
 
-    void setFlowThreadStateIncludingDescendants(FlowThreadState);
-
-    FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState(); }
-    void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadState(state); }
+    bool isInsideFlowThread() const { return m_bitfields.isInsideFlowThread(); }
+    void setIsInsideFlowThread(bool insideFlowThread) { m_bitfields.setIsInsideFlowThread(insideFlowThread); }
 
     // FIXME: Until all SVG layoutObjects can be subclasses of LayoutSVGModelObject we have
     // to add SVG layoutObject methods to LayoutObject with an ASSERT_NOT_REACHED() default implementation.
@@ -1314,13 +1308,13 @@
             , m_ancestorLineBoxDirty(false)
             , m_layoutDidGetCalledSinceLastFrame(false)
             , m_hasPendingResourceUpdate(false)
+            , m_isInsideFlowThread(false)
             , m_childrenInline(false)
             , m_hasColumns(false)
             , m_alwaysCreateLineBoxesForLayoutInline(false)
             , m_lastBoxDecorationBackgroundObscured(false)
             , m_positionedState(IsStaticallyPositioned)
             , m_selectionState(SelectionNone)
-            , m_flowThreadState(NotInsideFlowThread)
             , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
             , m_fullPaintInvalidationReason(PaintInvalidationNone)
         {
@@ -1362,6 +1356,8 @@
 
         ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate);
 
+        ADD_BOOLEAN_BITFIELD(isInsideFlowThread, IsInsideFlowThread);
+
         // from LayoutBlock
         ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
         ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
@@ -1375,7 +1371,6 @@
     private:
         unsigned m_positionedState : 2; // PositionedState
         unsigned m_selectionState : 3; // SelectionState
-        unsigned m_flowThreadState : 2; // FlowThreadState
         unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundState
         unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
 
@@ -1394,9 +1389,6 @@
         ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
         ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
 
-        ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_cast<FlowThreadState>(m_flowThreadState); }
-        ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
-
         ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState() const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgroundState); }
         ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgroundState s) { m_boxDecorationBackgroundState = s; }