Bug 981116: Convert nsFlexContainerFrame boolean member-var into frame state bit. r=heycam

This commit is contained in:
Daniel Holbert 2014-03-07 15:58:38 -08:00
parent a72e872bab
commit cded82fd98
4 changed files with 18 additions and 7 deletions

View File

@ -1457,7 +1457,8 @@ nsFlexContainerFrame::SanityCheckAnonymousFlexItems() const
"but it isn't");
if (child->StyleContext()->GetPseudo() ==
nsCSSAnonBoxes::anonymousFlexItem) {
MOZ_ASSERT(!prevChildWasAnonFlexItem || mChildrenHaveBeenReordered,
MOZ_ASSERT(!prevChildWasAnonFlexItem ||
HasAnyStateBits(NS_STATE_FLEX_CHILDREN_REORDERED),
"two anon flex items in a row (shouldn't happen, unless our "
"children have been reordered with the 'order' property)");
@ -2740,9 +2741,11 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
// operations need to use a fancier LEQ function that also takes DOM order
// into account, so that we can honor the spec's requirement that frames w/
// equal "order" values are laid out in DOM order.
if (!mChildrenHaveBeenReordered) {
mChildrenHaveBeenReordered =
SortChildrenIfNeeded<IsOrderLEQ>();
if (!HasAnyStateBits(NS_STATE_FLEX_CHILDREN_REORDERED)) {
if (SortChildrenIfNeeded<IsOrderLEQ>()) {
AddStateBits(NS_STATE_FLEX_CHILDREN_REORDERED);
}
} else {
SortChildrenIfNeeded<IsOrderLEQWithDOMFallback>();
}

View File

@ -20,6 +20,7 @@ typedef nsContainerFrame nsFlexContainerFrameSuper;
template <class T> class nsTArray;
class nsFlexContainerFrame : public nsFlexContainerFrameSuper {
public:
NS_DECL_FRAMEARENA_HELPERS
NS_DECL_QUERYFRAME_TARGET(nsFlexContainerFrame)
NS_DECL_QUERYFRAME
@ -28,7 +29,6 @@ class nsFlexContainerFrame : public nsFlexContainerFrameSuper {
friend nsIFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
public:
// Forward-decls of helper classes
class FlexItem;
class FlexLine;
@ -60,8 +60,7 @@ public:
protected:
// Protected constructor & destructor
nsFlexContainerFrame(nsStyleContext* aContext) :
nsFlexContainerFrameSuper(aContext),
mChildrenHaveBeenReordered(false)
nsFlexContainerFrameSuper(aContext)
{}
virtual ~nsFlexContainerFrame();

View File

@ -10,6 +10,7 @@
#include "nsBlockFrame.h"
#include "nsBoxFrame.h"
#include "nsBulletFrame.h"
#include "nsFlexContainerFrame.h"
#include "nsGfxScrollFrame.h"
#include "nsIFrame.h"
#include "nsISVGChildFrame.h"

View File

@ -284,6 +284,14 @@ FRAME_STATE_BIT(Box, 60, NS_FRAME_MOUSE_THROUGH_ALWAYS)
FRAME_STATE_BIT(Box, 61, NS_FRAME_MOUSE_THROUGH_NEVER)
// == Frame state bits that apply to flex container frames ====================
FRAME_STATE_GROUP(FlexContainer, nsFlexContainerFrame)
// Set for a flex container whose children have been reordered due to 'order'.
// (Means that we have to be more thorough about checking them for sortedness.)
FRAME_STATE_BIT(FlexContainer, 20, NS_STATE_FLEX_CHILDREN_REORDERED)
// == Frame state bits that apply to SVG frames ===============================
FRAME_STATE_GROUP(SVG, nsISVGChildFrame)