Bug 1340723 part 1. Add an nsIFrame function that can be called from the stylo restyle manager to update style contexts on anonymous boxes associated with that frame, and a frame state bit that can be used to optimize out the virtual calls. r?emilio
MozReview-Commit-ID: 2niUdJPSXKa
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -10247,16 +10247,26 @@ IsFrameScrolledOutOfView(nsIFrame *aFram
}
bool
nsIFrame::IsScrolledOutOfView()
{
return IsFrameScrolledOutOfView(this);
}
+/* virtual */
+void
+nsIFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet,
+ nsStyleChangeList& aChangeList,
+ nsChangeHint aHintForThisFrame)
+{
+ MOZ_ASSERT(!(GetStateBits() & NS_FRAME_OWNS_ANON_BOXES));
+ MOZ_ASSERT(false, "Why did this get called?");
+}
+
nsIFrame::CaretPosition::CaretPosition()
: mContentOffset(0)
{
}
nsIFrame::CaretPosition::~CaretPosition()
{
}
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -261,16 +261,20 @@ FRAME_STATE_BIT(Generic, 52, NS_FRAME_HA
// Frame is not displayed directly due to it being, or being under, an SVG
// <defs> element or an SVG resource element (<mask>, <pattern>, etc.)
FRAME_STATE_BIT(Generic, 53, NS_FRAME_IS_NONDISPLAY)
// Frame has a LayerActivityProperty property
FRAME_STATE_BIT(Generic, 54, NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY)
+// Frame owns anonymous boxes whose style contexts it will need to update during
+// a stylo tree traversal.
+FRAME_STATE_BIT(Generic, 55, NS_FRAME_OWNS_ANON_BOXES)
+
// Set for all descendants of MathML sub/supscript elements (other than the
// base frame) to indicate that the SSTY font feature should be used.
FRAME_STATE_BIT(Generic, 58, NS_FRAME_MATHML_SCRIPT_DESCENDANT)
// This state bit is set on frames within token MathML elements if the
// token represents an <mi> tag whose inner HTML consists of a single
// non-whitespace character to allow special rendering behaviour.
FRAME_STATE_BIT(Generic, 59, NS_FRAME_IS_IN_SINGLE_CHAR_MI)
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -34,16 +34,17 @@
#include "mozilla/ReflowOutput.h"
#include "nsITheme.h"
#include "nsLayoutUtils.h"
#include "nsQueryFrame.h"
#include "nsStringGlue.h"
#include "nsStyleContext.h"
#include "nsStyleStruct.h"
#include "Visibility.h"
+#include "nsChangeHint.h"
#ifdef ACCESSIBILITY
#include "mozilla/a11y/AccTypes.h"
#endif
/**
* New rules of reflow:
* 1. you get a WillReflow() followed by a Reflow() followed by a DidReflow() in order
@@ -76,30 +77,32 @@ class nsDisplayListSet;
class nsDisplayList;
class gfxSkipChars;
class gfxSkipCharsIterator;
class gfxContext;
class nsLineList_iterator;
class nsAbsoluteContainingBlock;
class nsIContent;
class nsContainerFrame;
+class nsStyleChangeList;
struct nsPeekOffsetStruct;
struct nsPoint;
struct nsRect;
struct nsSize;
struct nsMargin;
struct CharacterDataChangeInfo;
namespace mozilla {
enum class CSSPseudoElementType : uint8_t;
class EventStates;
struct ReflowInput;
class ReflowOutput;
+class ServoStyleSet;
namespace layers {
class Layer;
} // namespace layers
namespace gfx {
class Matrix;
} // namespace gfx
@@ -3041,16 +3044,45 @@ public:
* or nullptr if the style context is for display:contents content.
* @return The style context that should be the parent of this frame's
* style context. Null is permitted, and means that this frame's
* style context should be the root of the style context tree.
*/
virtual nsStyleContext* GetParentStyleContext(nsIFrame** aProviderFrame) const = 0;
/**
+ * Called by ServoRestyleManager to update the style contexts of anonymous
+ * boxes directly associtated with this frame. The passed-in ServoStyleSet
+ * can be used to create new style contexts as needed.
+ *
+ * This function will be called after this frame's style context has already
+ * been updated. This function will only be called on frames which have the
+ * NS_FRAME_OWNS_ANON_BOXES bit set.
+ *
+ * The nsStyleChangeList can be used to append additional changes. It's
+ * guaranteed to already have a change in it for this frame and this frame's
+ * content and a change hint of aHintForThisFrame.
+ */
+ void UpdateStyleOfOwnedAnonBoxes(mozilla::ServoStyleSet& aStyleSet,
+ nsStyleChangeList& aChangeList,
+ nsChangeHint aHintForThisFrame) {
+ if (GetStateBits() & NS_FRAME_OWNS_ANON_BOXES) {
+ DoUpdateStyleOfOwnedAnonBoxes(aStyleSet, aChangeList, aHintForThisFrame);
+ }
+ }
+
+ /**
+ * Hook subclasses can override to actually implement updating of style of
+ * owned anon boxes.
+ */
+ virtual void DoUpdateStyleOfOwnedAnonBoxes(mozilla::ServoStyleSet& aStyleSet,
+ nsStyleChangeList& aChangeList,
+ nsChangeHint aHintForThisFrame);
+
+ /**
* Determines whether a frame is visible for painting;
* taking into account whether it is painting a selection or printing.
*/
bool IsVisibleForPainting(nsDisplayListBuilder* aBuilder);
/**
* Determines whether a frame is visible for painting or collapsed;
* taking into account whether it is painting a selection or printing,
*/