From 7a19c4858cd162b3dc17d11b3379cb4937637721 Mon Sep 17 00:00:00 2001 From: Miko Mynttinen Date: Thu, 15 Feb 2018 15:26:56 +0100 Subject: [PATCH] Bug 1438165 - Ensure that all display items have a unique type r=mattwoodrow MozReview-Commit-ID: HIlSQFcvG9A --HG-- extra : rebase_source : aba9cdf8e578ed3fd98a77aef8a183dac08baea1 extra : amend_source : 329ff3b9124c05b35ff1e0807afe9ac455bbebce --- layout/base/PresShell.cpp | 12 +++++++++--- layout/painting/nsDisplayItemTypesList.h | 4 ++++ layout/painting/nsDisplayList.cpp | 8 +++++--- layout/painting/nsDisplayList.h | 9 +++++---- layout/svg/SVGTextFrame.cpp | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 984e84c47522..8c5bf6705fe5 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5231,15 +5231,21 @@ AddCanvasBackgroundColor(const nsDisplayList& aList, nsIFrame* aCanvasFrame, nscolor aColor, bool aCSSBackgroundColor) { for (nsDisplayItem* i = aList.GetBottom(); i; i = i->GetAbove()) { + const DisplayItemType type = i->GetType(); + if (i->Frame() == aCanvasFrame && - i->GetType() == DisplayItemType::TYPE_CANVAS_BACKGROUND_COLOR) { + type == DisplayItemType::TYPE_CANVAS_BACKGROUND_COLOR) { nsDisplayCanvasBackgroundColor* bg = static_cast(i); bg->SetExtraBackgroundColor(aColor); return true; } + + const bool isBlendContainer = + type == DisplayItemType::TYPE_BLEND_CONTAINER || + type == DisplayItemType::TYPE_TABLE_BLEND_CONTAINER; + nsDisplayList* sublist = i->GetSameCoordinateSystemChildren(); - if (sublist && - !(i->GetType() == DisplayItemType::TYPE_BLEND_CONTAINER && !aCSSBackgroundColor) && + if (sublist && !(isBlendContainer && !aCSSBackgroundColor) && AddCanvasBackgroundColor(*sublist, aCanvasFrame, aColor, aCSSBackgroundColor)) return true; } diff --git a/layout/painting/nsDisplayItemTypesList.h b/layout/painting/nsDisplayItemTypesList.h index 9675e332dfec..cc62af99eb44 100644 --- a/layout/painting/nsDisplayItemTypesList.h +++ b/layout/painting/nsDisplayItemTypesList.h @@ -9,7 +9,9 @@ DECLARE_DISPLAY_ITEM_TYPE(BACKGROUND, 0) DECLARE_DISPLAY_ITEM_TYPE(THEMED_BACKGROUND, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BACKGROUND_COLOR, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BLEND_CONTAINER, TYPE_RENDERS_NO_IMAGES) +DECLARE_DISPLAY_ITEM_TYPE(TABLE_BLEND_CONTAINER, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BLEND_MODE, TYPE_RENDERS_NO_IMAGES) +DECLARE_DISPLAY_ITEM_TYPE(TABLE_BLEND_MODE, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BORDER, 0) DECLARE_DISPLAY_ITEM_TYPE(BOX_SHADOW_OUTER, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BOX_SHADOW_INNER, TYPE_RENDERS_NO_IMAGES) @@ -59,12 +61,14 @@ DECLARE_DISPLAY_ITEM_TYPE(FILTER, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(SVG_OUTER_SVG, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(SVG_GEOMETRY, 0) DECLARE_DISPLAY_ITEM_TYPE(SVG_TEXT, 0) +DECLARE_DISPLAY_ITEM_TYPE(SVG_CHAR_CLIP, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(SVG_WRAPPER, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_BACKGROUND, 0) DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_SELECTION, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(TABLE_BORDER_COLLAPSE, 0) DECLARE_DISPLAY_ITEM_TYPE(TABLE_BACKGROUND_COLOR, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(TABLE_BACKGROUND_IMAGE, 0) +DECLARE_DISPLAY_ITEM_TYPE(TABLE_THEMED_BACKGROUND_IMAGE, 0) DECLARE_DISPLAY_ITEM_TYPE(TABLE_FIXED_POSITION, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(TEXT, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(TEXT_OVERFLOW, TYPE_RENDERS_NO_IMAGES) diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 3ddcbe038d35..75577a4c5ba3 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -1572,8 +1572,8 @@ nsDisplayListBuilder::Allocate(size_t aSize, DisplayItemType aType) size_t roundedUpSize = RoundUpPow2(aSize); uint_fast8_t type = FloorLog2Size(roundedUpSize); - MOZ_ASSERT(gDisplayItemSizes[static_cast(aType)] == type || - gDisplayItemSizes[static_cast(aType)] == 0); + MOZ_RELEASE_ASSERT(gDisplayItemSizes[static_cast(aType)] == type || + gDisplayItemSizes[static_cast(aType)] == 0); gDisplayItemSizes[static_cast(aType)] = type; return mPool.AllocateByCustomID(type, roundedUpSize); } @@ -6367,7 +6367,9 @@ RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder, } LayerState state = i->GetLayerState(aBuilder, aManager, aParameters); - if (state == LAYER_ACTIVE && i->GetType() == DisplayItemType::TYPE_BLEND_MODE) { + if (state == LAYER_ACTIVE && + (i->GetType() == DisplayItemType::TYPE_BLEND_MODE || + i->GetType() == DisplayItemType::TYPE_TABLE_BLEND_MODE)) { // nsDisplayBlendMode always returns LAYER_ACTIVE to ensure that the // blending operation happens in the intermediate surface of its parent // display item (usually an nsDisplayBlendContainer). But this does not diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 7124e1ffa3b0..c629ae0f3cb1 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -4136,7 +4136,7 @@ public: virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; } - NS_DISPLAY_DECL_NAME("TableThemedBackground", TYPE_TABLE_BACKGROUND_IMAGE) + NS_DISPLAY_DECL_NAME("TableThemedBackground", TYPE_TABLE_THEMED_BACKGROUND_IMAGE) protected: virtual nsIFrame* StyleFrame() const override { return mAncestorFrame; } nsIFrame* mAncestorFrame; @@ -5259,7 +5259,7 @@ public: nsDisplayItem::GetPerFrameKey(); } - NS_DISPLAY_DECL_NAME("BlendMode", TYPE_BLEND_MODE) + NS_DISPLAY_DECL_NAME("TableBlendMode", TYPE_TABLE_BLEND_MODE) protected: nsIFrame* mAncestorFrame; @@ -5354,7 +5354,7 @@ public: nsDisplayItem::GetPerFrameKey(); } - NS_DISPLAY_DECL_NAME("BlendContainer", TYPE_BLEND_CONTAINER) + NS_DISPLAY_DECL_NAME("TableBlendContainer", TYPE_TABLE_BLEND_CONTAINER) protected: nsDisplayTableBlendContainer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, @@ -6680,7 +6680,8 @@ public: static nsCharClipDisplayItem* CheckCast(nsDisplayItem* aItem) { DisplayItemType t = aItem->GetType(); - return (t == DisplayItemType::TYPE_TEXT) + return (t == DisplayItemType::TYPE_TEXT || + t == DisplayItemType::TYPE_SVG_CHAR_CLIP) ? static_cast(aItem) : nullptr; } diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index b9fb327e9c45..4a76b3e88db0 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -2733,7 +2733,7 @@ public: aRun.GetClipEdges(mVisIStartEdge, mVisIEndEdge); } - NS_DISPLAY_DECL_NAME("SVGText", TYPE_TEXT) + NS_DISPLAY_DECL_NAME("SVGCharClip", TYPE_SVG_CHAR_CLIP) }; // -----------------------------------------------------------------------------