Bug 1463752 - Part 1: Avoid unnecessary cast in FLBDisplayItemIterator::StartNested()
MozReview-Commit-ID: 4oEpvVFSaU3
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -133,16 +133,17 @@ struct DisplayItemEntry {
class FLBDisplayItemIterator : protected FlattenedDisplayItemIterator
{
public:
FLBDisplayItemIterator(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList,
ContainerState* aState)
: FlattenedDisplayItemIterator(aBuilder, aList, false)
, mState(aState)
+ , mStoreMarker(false)
{
MOZ_ASSERT(mState);
ResolveFlattening();
}
DisplayItemEntry GetNextEntry()
{
if (!mMarkers.empty()) {
@@ -171,32 +172,30 @@ public:
}
nsDisplayItem* PeekNext()
{
return mNext;
}
private:
- bool ShouldFlattenNextItem() const override;
+ bool ShouldFlattenNextItem() override;
void StartNested(nsDisplayItem* aItem) override
{
+ if (!mStoreMarker) {
+ return;
+ }
+
if (aItem->GetType() == DisplayItemType::TYPE_OPACITY) {
- nsDisplayOpacity* opacity = static_cast<nsDisplayOpacity*> (aItem);
-
- if (opacity->OpacityAppliedToChildren()) {
- // If the opacity was already applied to children, there is no need to
- // emit opacity markers.
- return;
- }
-
mMarkers.emplace_back(aItem, DisplayItemEntryType::PUSH_OPACITY);
mActiveMarkers.AppendElement(aItem);
}
+
+ mStoreMarker = false;
}
void EndNested(nsDisplayItem* aItem) override
{
if (mActiveMarkers.IsEmpty() || mActiveMarkers.LastElement() != aItem) {
// Do not emit an end marker if this item did not emit a start marker.
return;
}
@@ -205,16 +204,17 @@ private:
mMarkers.emplace_back(aItem, DisplayItemEntryType::POP_OPACITY);
mActiveMarkers.RemoveLastElement();
}
}
std::deque<DisplayItemEntry> mMarkers;
AutoTArray<nsDisplayItem*, 4> mActiveMarkers;
ContainerState* mState;
+ bool mStoreMarker;
};
DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
Layer* aLayer, nsIFrame* aFrame)
: mRefCnt(0)
, mParent(aParent)
, mLayer(aLayer)
@@ -1588,17 +1588,17 @@ protected:
CachedScrollMetadata()
: mASR(nullptr), mClip(nullptr)
{}
};
CachedScrollMetadata mCachedScrollMetadata;
};
bool
-FLBDisplayItemIterator::ShouldFlattenNextItem() const
+FLBDisplayItemIterator::ShouldFlattenNextItem()
{
if (!mNext) {
return false;
}
if (!mNext->ShouldFlattenAway(mBuilder)) {
return false;
}
@@ -1617,18 +1617,22 @@ FLBDisplayItemIterator::ShouldFlattenNex
return false;
}
LayerState layerState = mNext->GetLayerState(mState->mBuilder,
mState->mManager,
mState->mParameters);
// Do not flatten opacity if child display items require an active layer.
- return (layerState == LayerState::LAYER_NONE ||
- layerState == LayerState::LAYER_INACTIVE);
+ if (layerState != LayerState::LAYER_NONE &&
+ layerState != LayerState::LAYER_INACTIVE) {
+ return false;
+ }
+
+ mStoreMarker = true;
}
return true;
}
class PaintedDisplayItemLayerUserData : public LayerUserData
{
public:
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -3301,17 +3301,17 @@ public:
}
protected:
bool AtEndOfNestedList() const
{
return !mNext && mStack.Length() > 0;
}
- virtual bool ShouldFlattenNextItem() const
+ virtual bool ShouldFlattenNextItem()
{
return mNext && mNext->ShouldFlattenAway(mBuilder);
}
void ResolveFlattening()
{
// Handle the case where we reach the end of a nested list, or the current
// item should start a new nested list. Repeat this until we find an actual