summaryrefslogtreecommitdiffstats
path: root/layout/base
diff options
context:
space:
mode:
authorwin7-7 <win7-7@users.noreply.github.com>2020-05-08 01:21:41 +0300
committerwin7-7 <win7-7@users.noreply.github.com>2020-05-08 15:27:28 +0300
commit64ffe81c5551d1fabb12aa2d529ed5711bbbe965 (patch)
tree8fee7e6c6c340e9e7ae6f2a3a1e106880e4b8414 /layout/base
parent45b20c5e4aabf1ba51af71b0a07d75c85e067dce (diff)
downloadUXP-64ffe81c5551d1fabb12aa2d529ed5711bbbe965.tar
UXP-64ffe81c5551d1fabb12aa2d529ed5711bbbe965.tar.gz
UXP-64ffe81c5551d1fabb12aa2d529ed5711bbbe965.tar.lz
UXP-64ffe81c5551d1fabb12aa2d529ed5711bbbe965.tar.xz
UXP-64ffe81c5551d1fabb12aa2d529ed5711bbbe965.zip
Issue #1355 - Better way to create display items for column backgrounds
Part 1: Remove current table item, as it's never set. Part 2: Get rid of generic table painting code, and handle each class separately. Part 4: Hoist outline skipping into col(group) frame code. Part 5: Skip box-shadow for table column and column groups. Part 6: Store column and column group backgrounds separately, and then append them before the rest of the table contents. Part 7: Pass rects in display list coordinates to AppendBackgroundItemsToTop. Part 8: Create column and column group background display items as part of the cell's BuildDisplayList. Part 9: Used cached values instead of calling nsDisplayListBuilder::ToReferenceFrame when possible, since it can be expensive when the requested frame isn't the builder's current frame. Part 10: Make sure we build display items for table parts where only the normal position is visible, since we may need to create background items for ancestors at that position. Part 11: Create an AutoBuildingDisplayList when we create background items for table columns and column groups, so that we initialize the invalidation state correctly.
Diffstat (limited to 'layout/base')
-rw-r--r--layout/base/nsDisplayList.cpp29
-rw-r--r--layout/base/nsDisplayList.h25
2 files changed, 36 insertions, 18 deletions
diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp
index a869564a4..55461f7c0 100644
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -721,7 +721,6 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
: mReferenceFrame(aReferenceFrame),
mIgnoreScrollFrame(nullptr),
mLayerEventRegions(nullptr),
- mCurrentTableItem(nullptr),
mCurrentFrame(aReferenceFrame),
mCurrentReferenceFrame(aReferenceFrame),
mCurrentAGR(&mRootAGR),
@@ -731,6 +730,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mGlassDisplayItem(nullptr),
mScrollInfoItemsForHoisting(nullptr),
mMode(aMode),
+ mTableBackgroundSet(nullptr),
mCurrentScrollParentId(FrameMetrics::NULL_SCROLL_ID),
mCurrentScrollbarTarget(FrameMetrics::NULL_SCROLL_ID),
mCurrentScrollbarFlags(0),
@@ -926,7 +926,6 @@ nsDisplayListBuilder::~nsDisplayListBuilder() {
"All frames should have been unmarked");
NS_ASSERTION(mPresShellStates.Length() == 0,
"All presshells should have been exited");
- NS_ASSERTION(!mCurrentTableItem, "No table item should be active");
nsCSSRendering::EndFrameTreesLocked();
@@ -2579,8 +2578,7 @@ static nsStyleContext* GetBackgroundStyleContext(nsIFrame* aFrame)
/* static */ void
SetBackgroundClipRegion(DisplayListClipState::AutoSaveRestore& aClipState,
- nsIFrame* aFrame, const nsPoint& aToReferenceFrame,
- const nsStyleImageLayers::Layer& aLayer,
+ nsIFrame* aFrame, const nsStyleImageLayers::Layer& aLayer,
const nsRect& aBackgroundRect,
bool aWillPaintBorder)
{
@@ -2640,14 +2638,16 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
bool aAllowWillPaintBorderOptimization,
nsStyleContext* aStyleContext,
const nsRect& aBackgroundOriginRect,
- nsIFrame* aSecondaryReferenceFrame)
+ nsIFrame* aSecondaryReferenceFrame,
+ Maybe<nsDisplayListBuilder::AutoBuildingDisplayList>*
+ aAutoBuildingDisplayList)
{
nsStyleContext* bgSC = aStyleContext;
const nsStyleBackground* bg = nullptr;
- nsRect bgRect = aBackgroundRect + aBuilder->ToReferenceFrame(aFrame);
+ nsRect bgRect = aBackgroundRect;
nsRect bgOriginRect = bgRect;
if (!aBackgroundOriginRect.IsEmpty()) {
- bgOriginRect = aBackgroundOriginRect + aBuilder->ToReferenceFrame(aFrame);
+ bgOriginRect = aBackgroundOriginRect;
}
nsPresContext* presContext = aFrame->PresContext();
bool isThemed = aFrame->IsThemed();
@@ -2683,8 +2683,6 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
!isThemed && !hasInsetShadow &&
borderStyle->HasBorder();
- nsPoint toRef = aBuilder->ToReferenceFrame(aFrame);
-
// An auxiliary list is necessary in case we have background blending; if that
// is the case, background items need to be wrapped by a blend container to
// isolate blending to the background
@@ -2693,6 +2691,9 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
// to create an item for hit testing.
if ((drawBackgroundColor && color != NS_RGBA(0,0,0,0)) ||
aBuilder->IsForEventDelivery()) {
+ if (aAutoBuildingDisplayList && !*aAutoBuildingDisplayList) {
+ aAutoBuildingDisplayList->emplace(aBuilder, aFrame);
+ }
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
if (bg && !aBuilder->IsForEventDelivery()) {
// Disable the will-paint-border optimization for background
@@ -2704,7 +2705,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
// artifacts along the rounded corners.
bool useWillPaintBorderOptimization = willPaintBorder &&
nsLayoutUtils::HasNonZeroCorner(borderStyle->mBorderRadius);
- SetBackgroundClipRegion(clipState, aFrame, toRef,
+ SetBackgroundClipRegion(clipState, aFrame,
bg->BottomLayer(), bgRect,
useWillPaintBorderOptimization);
}
@@ -2757,6 +2758,10 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
continue;
}
+ if (aAutoBuildingDisplayList && !*aAutoBuildingDisplayList) {
+ aAutoBuildingDisplayList->emplace(aBuilder, aFrame);
+ }
+
if (bg->mImage.mLayers[i].mBlendMode != NS_STYLE_BLEND_NORMAL) {
needBlendContainer = true;
}
@@ -2764,8 +2769,8 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
if (!aBuilder->IsForEventDelivery()) {
const nsStyleImageLayers::Layer& layer = bg->mImage.mLayers[i];
- SetBackgroundClipRegion(clipState, aFrame, toRef,
- layer, bgRect, willPaintBorder);
+ SetBackgroundClipRegion(clipState, aFrame, layer, bgRect,
+ willPaintBorder);
}
nsDisplayList thisItemList;
diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h
index 3aeb20d19..ff2a14dd7 100644
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -48,6 +48,7 @@ class nsISelection;
class nsIScrollableFrame;
class nsDisplayLayerEventRegions;
class nsDisplayScrollInfoLayer;
+class nsDisplayTableBackgroundSet;
class nsCaret;
namespace mozilla {
@@ -588,6 +589,16 @@ public:
mSyncDecodeImages = aSyncDecodeImages;
}
+ nsDisplayTableBackgroundSet* SetTableBackgroundSet(
+ nsDisplayTableBackgroundSet* aTableSet) {
+ nsDisplayTableBackgroundSet* old = mTableBackgroundSet;
+ mTableBackgroundSet = aTableSet;
+ return old;
+ }
+ nsDisplayTableBackgroundSet* GetTableBackgroundSet() const {
+ return mTableBackgroundSet;
+ }
+
/**
* Helper method to generate background painting flags based on the
* information available in the display list builder. Currently only
@@ -711,6 +722,10 @@ public:
class AutoBuildingDisplayList {
public:
+ AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild)
+ : AutoBuildingDisplayList(
+ aBuilder, aForChild, aBuilder->GetDirtyRect(), aForChild->IsTransformed()){}
+
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aForChild,
const nsRect& aDirtyRect, bool aIsRoot)
: mBuilder(aBuilder),
@@ -992,10 +1007,6 @@ public:
return mPreserves3DCtx.mAccumulatedRectLevels;
}
- // Helpers for tables
- nsDisplayTableItem* GetCurrentTableItem() { return mCurrentTableItem; }
- void SetCurrentTableItem(nsDisplayTableItem* aTableItem) { mCurrentTableItem = aTableItem; }
-
struct OutOfFlowDisplayData {
OutOfFlowDisplayData(const DisplayItemClip* aContainingBlockClip,
const DisplayItemScrollClip* aContainingBlockScrollClip,
@@ -1213,7 +1224,6 @@ private:
AutoTArray<PresShellState,8> mPresShellStates;
AutoTArray<nsIFrame*,400> mFramesMarkedForDisplay;
AutoTArray<ThemeGeometry,2> mThemeGeometries;
- nsDisplayTableItem* mCurrentTableItem;
DisplayListClipState mClipState;
// mCurrentFrame is the frame that we're currently calling (or about to call)
// BuildDisplayList on.
@@ -1256,6 +1266,7 @@ private:
nsTArray<DisplayItemScrollClip*> mScrollClipsToDestroy;
nsTArray<DisplayItemClip*> mDisplayItemClipsToDestroy;
nsDisplayListBuilderMode mMode;
+ nsDisplayTableBackgroundSet* mTableBackgroundSet;
ViewID mCurrentScrollParentId;
ViewID mCurrentScrollbarTarget;
uint32_t mCurrentScrollbarFlags;
@@ -2751,7 +2762,9 @@ public:
bool aAllowWillPaintBorderOptimization = true,
nsStyleContext* aStyleContext = nullptr,
const nsRect& aBackgroundOriginRect = nsRect(),
- nsIFrame* aSecondaryReferenceFrame = nullptr);
+ nsIFrame* aSecondaryReferenceFrame = nullptr,
+ mozilla::Maybe<nsDisplayListBuilder::AutoBuildingDisplayList>*
+ aAutoBuildingDisplayList = nullptr);
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,