Skip to content

Commit

Permalink
Bug 1418177 - Add nsDisplayTableBlendMode and nsDisplayTableBlendCont…
Browse files Browse the repository at this point in the history
…ainer. r=mattwoodrow

MozReview-Commit-ID: G4dwfweH8D3
  • Loading branch information
mephisto41 committed Dec 5, 2017
1 parent 76445de commit 04ac2e0
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 8 deletions.
34 changes: 28 additions & 6 deletions layout/painting/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3774,18 +3774,31 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
// asr is scrolled. Even if we wrap a fixed background layer, that's
// fine, because the item will have a scrolled clip that limits the
// item with respect to asr.
thisItemList.AppendNewToTop(
new (aBuilder) nsDisplayBlendMode(aBuilder, aFrame, &thisItemList,
bg->mImage.mLayers[i].mBlendMode,
asr, i + 1));
if (aSecondaryReferenceFrame) {
thisItemList.AppendNewToTop(
new (aBuilder) nsDisplayTableBlendMode(aBuilder, aSecondaryReferenceFrame, &thisItemList,
bg->mImage.mLayers[i].mBlendMode,
asr, i + 1, aFrame));
} else {
thisItemList.AppendNewToTop(
new (aBuilder) nsDisplayBlendMode(aBuilder, aFrame, &thisItemList,
bg->mImage.mLayers[i].mBlendMode,
asr, i + 1));
}
}
bgItemList.AppendToTop(&thisItemList);
}

if (needBlendContainer) {
DisplayListClipState::AutoSaveRestore blendContainerClip(aBuilder);
bgItemList.AppendNewToTop(
nsDisplayBlendContainer::CreateForBackgroundBlendMode(aBuilder, aFrame, &bgItemList, asr));
if (aSecondaryReferenceFrame) {
bgItemList.AppendNewToTop(
nsDisplayTableBlendContainer::CreateForBackgroundBlendMode(aBuilder, aSecondaryReferenceFrame,
&bgItemList, asr, aFrame));
} else {
bgItemList.AppendNewToTop(
nsDisplayBlendContainer::CreateForBackgroundBlendMode(aBuilder, aFrame, &bgItemList, asr));
}
}

aList->AppendToTop(&bgItemList);
Expand Down Expand Up @@ -6941,6 +6954,15 @@ nsDisplayBlendContainer::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder
aManager, aDisplayListBuilder);
}

/* static */ nsDisplayTableBlendContainer*
nsDisplayTableBlendContainer::CreateForBackgroundBlendMode(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
nsIFrame* aAncestorFrame)
{
return new (aBuilder) nsDisplayTableBlendContainer(aBuilder, aFrame, aList, aActiveScrolledRoot, true, aAncestorFrame);
}

nsDisplayOwnLayer::nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
Expand Down
63 changes: 61 additions & 2 deletions layout/painting/nsDisplayList.h
Original file line number Diff line number Diff line change
Expand Up @@ -5014,11 +5014,38 @@ class nsDisplayBlendMode : public nsDisplayWrapList {

NS_DISPLAY_DECL_NAME("BlendMode", TYPE_BLEND_MODE)

private:
protected:
uint8_t mBlendMode;
uint32_t mIndex;
};

class nsDisplayTableBlendMode : public nsDisplayBlendMode
{
public:
nsDisplayTableBlendMode(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList, uint8_t aBlendMode,
const ActiveScrolledRoot* aActiveScrolledRoot,
uint32_t aIndex, nsIFrame* aAncestorFrame)
: nsDisplayBlendMode(aBuilder, aFrame, aList, aBlendMode, aActiveScrolledRoot, aIndex)
, mAncestorFrame(aAncestorFrame)
, mTableType(GetTableTypeFromFrame(aAncestorFrame))
{ }

virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; }

virtual uint32_t GetPerFrameKey() const override {
return (mIndex << (TYPE_BITS + static_cast<uint8_t>(TableTypeBits::COUNT))) |
(static_cast<uint8_t>(mTableType) << TYPE_BITS) |
nsDisplayItem::GetPerFrameKey();
}

NS_DISPLAY_DECL_NAME("BlendMode", TYPE_BLEND_MODE)

protected:
nsIFrame* mAncestorFrame;
TableType mTableType;
};

class nsDisplayBlendContainer : public nsDisplayWrapList {
public:
static nsDisplayBlendContainer*
Expand Down Expand Up @@ -5070,7 +5097,7 @@ class nsDisplayBlendContainer : public nsDisplayWrapList {
}
NS_DISPLAY_DECL_NAME("BlendContainer", TYPE_BLEND_CONTAINER)

private:
protected:
nsDisplayBlendContainer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
Expand All @@ -5086,6 +5113,38 @@ class nsDisplayBlendContainer : public nsDisplayWrapList {
bool mIsForBackground;
};

class nsDisplayTableBlendContainer : public nsDisplayBlendContainer
{
public:
static nsDisplayTableBlendContainer*
CreateForBackgroundBlendMode(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
nsIFrame* aAncestorFrame);
virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; }

virtual uint32_t GetPerFrameKey() const override {
return (static_cast<uint8_t>(mTableType) << TYPE_BITS) |
nsDisplayItem::GetPerFrameKey();
}

NS_DISPLAY_DECL_NAME("BlendContainer", TYPE_BLEND_CONTAINER)

protected:
nsDisplayTableBlendContainer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList,
const ActiveScrolledRoot* aActiveScrolledRoot,
bool aIsForBackground, nsIFrame* aAncestorFrame)
: nsDisplayBlendContainer(aBuilder, aFrame, aList, aActiveScrolledRoot, aIsForBackground)
, mAncestorFrame(aAncestorFrame)
, mTableType(GetTableTypeFromFrame(aAncestorFrame))
{ }

nsIFrame* mAncestorFrame;
TableType mTableType;
};


/**
* nsDisplayOwnLayer constructor flags. If we nest this class inside
* nsDisplayOwnLayer then we can't forward-declare it up at the top of this
Expand Down

0 comments on commit 04ac2e0

Please sign in to comment.