summaryrefslogtreecommitdiffstats
path: root/layout/painting/nsDisplayList.h
diff options
context:
space:
mode:
Diffstat (limited to 'layout/painting/nsDisplayList.h')
-rw-r--r--layout/painting/nsDisplayList.h51
1 files changed, 40 insertions, 11 deletions
diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h
index 5064677cc7..9862415f61 100644
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -659,7 +659,7 @@ class nsDisplayListBuilder {
* Get the frame that the caret is supposed to draw in.
* If the caret is currently invisible, this will be null.
*/
- nsIFrame* GetCaretFrame() { return mCaretFrame; }
+ nsIFrame* GetCaretFrame() { return CurrentPresShellState()->mCaretFrame; }
/**
* Get the rectangle we're supposed to draw the caret into.
*/
@@ -852,9 +852,9 @@ class nsDisplayListBuilder {
/**
* Notifies the builder that a particular themed widget exists
* at the given rectangle within the currently built display list.
- * For certain appearance values (currently only StyleAppearance::Toolbar and
- * StyleAppearance::WindowTitlebar) this gets called during every display list
- * construction, for every themed widget of the right type within the
+ * For certain appearance values (currently only
+ * StyleAppearance::MozWindowTitlebar) this gets called during every display
+ * list construction, for every themed widget of the right type within the
* display list, except for themed widgets which are transformed or have
* effects applied to them (e.g. CSS opacity or filters).
*
@@ -904,6 +904,11 @@ class nsDisplayListBuilder {
const dom::EffectsInfo& aUpdate);
/**
+ * Invalidates the caret frames from previous paints, if they have changed.
+ */
+ void InvalidateCaretFramesIfNeeded();
+
+ /**
* Allocate memory in our arena. It will only be freed when this display list
* builder is destroyed. This memory holds nsDisplayItems and
* DisplayItemClipChain objects.
@@ -1729,6 +1734,7 @@ class nsDisplayListBuilder {
bool mInsidePointerEventsNoneDoc;
bool mTouchEventPrefEnabledDoc;
nsIFrame* mPresShellIgnoreScrollFrame;
+ nsIFrame* mCaretFrame = nullptr;
};
PresShellState* CurrentPresShellState() {
@@ -1763,7 +1769,6 @@ class nsDisplayListBuilder {
// The reference frame for mCurrentFrame.
const nsIFrame* mCurrentReferenceFrame;
- nsIFrame* mCaretFrame;
// A temporary list that we append scroll info items to while building
// display items for the contents of frames with SVG effects.
// Only non-null when ShouldBuildScrollInfoItemsForHoisting() is true.
@@ -1808,6 +1813,9 @@ class nsDisplayListBuilder {
// Stores reusable items collected during display list preprocessing.
nsTHashSet<nsDisplayItem*> mReuseableItems;
+ // Tracked carets used for retained display list.
+ AutoTArray<RefPtr<nsCaret>, 1> mPaintedCarets;
+
// Tracked regions used for retained display list.
WeakFrameRegion mRetainedWindowDraggingRegion;
WeakFrameRegion mRetainedWindowNoDraggingRegion;
@@ -3195,12 +3203,13 @@ class nsDisplayList {
// array of 20 items should be able to avoid a lot of dynamic allocations
// here.
AutoTArray<Item, 20> items;
+ // Ensure we need just one alloc otherwise, no-op if enough.
+ items.SetCapacity(Length());
for (nsDisplayItem* item : TakeItems()) {
items.AppendElement(Item(item));
}
-
- std::stable_sort(items.begin(), items.end(), aComparator);
+ items.StableSort(aComparator);
for (Item& item : items) {
AppendToTop(item);
@@ -3208,6 +3217,7 @@ class nsDisplayList {
}
nsDisplayList TakeItems() {
+ // This std::move makes this a defined empty list, see assignment operator.
nsDisplayList list = std::move(*this);
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
list.mAllowNonEmptyDestruction = true;
@@ -5465,7 +5475,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList {
bool IsFixedPositionLayer() const;
bool IsStickyPositionLayer() const;
bool HasDynamicToolbar() const;
- virtual bool ShouldGetFixedOrStickyAnimationId() { return false; }
+ virtual bool ShouldGetFixedAnimationId() { return false; }
bool CreatesStackingContextHelper() override { return true; }
@@ -5481,6 +5491,16 @@ class nsDisplayOwnLayer : public nsDisplayWrapList {
*/
layers::ScrollbarData mScrollbarData;
bool mForceActive;
+
+ // Used for APZ to animate this layer for purposes such as
+ // pinch-zooming or scrollbar thumb movement. Note that setting this
+ // creates a WebRender ReferenceFrame spatial node, and should only
+ // be used for display items that establish a Gecko reference frame
+ // as well (or leaf items like scrollbar thumb nodes where it does not
+ // matter).
+ // FIXME: This is currently also used for adjusting position:fixed items
+ // for dynamic toolbar movement. This may be a problem as position:fixed
+ // items do not establish Gecko reference frames.
uint64_t mWrAnimationId;
};
@@ -5540,7 +5560,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
: nsDisplayOwnLayer(aBuilder, aOther),
mContainerASR(aOther.mContainerASR),
mClippedToDisplayPort(aOther.mClippedToDisplayPort),
- mShouldFlatten(false) {
+ mShouldFlatten(false),
+ mWrStickyAnimationId(0) {
MOZ_COUNT_CTOR(nsDisplayStickyPosition);
}
@@ -5565,7 +5586,6 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
bool UpdateScrollData(layers::WebRenderScrollData* aData,
layers::WebRenderLayerScrollData* aLayerData) override;
- bool ShouldGetFixedOrStickyAnimationId() override;
const ActiveScrolledRoot* GetContainerASR() const { return mContainerASR; }
@@ -5581,6 +5601,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
return mShouldFlatten;
}
+ bool ShouldGetStickyAnimationId() const;
+
private:
NS_DISPLAY_ALLOW_CLONING()
@@ -5610,6 +5632,13 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
// True if this item should be flattened away.
bool mShouldFlatten;
+
+ // Used for APZ to animate the sticky element in the compositor
+ // for purposes such as dynamic toolbar movement and (in the future)
+ // overscroll-related adjustment. Unlike nsDisplayOwnLayer::mWrAnimationId,
+ // this does not create a WebRender ReferenceFrame, which is important
+ // because sticky elements do not establish Gecko reference frames either.
+ uint64_t mWrStickyAnimationId;
};
class nsDisplayFixedPosition : public nsDisplayOwnLayer {
@@ -5651,7 +5680,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer {
nsDisplayListBuilder* aDisplayListBuilder) override;
bool UpdateScrollData(layers::WebRenderScrollData* aData,
layers::WebRenderLayerScrollData* aLayerData) override;
- bool ShouldGetFixedOrStickyAnimationId() override;
+ bool ShouldGetFixedAnimationId() override;
void WriteDebugInfo(std::stringstream& aStream) override;
protected: