Bug 1410906 - Store ThemeGeometry for display item instead of frame r=mattwoodrow

MozReview-Commit-ID: 6x7GRRTEVja

--HG--
extra : rebase_source : 3dc139938317e00b4f96498f1c1f84826fc64755
This commit is contained in:
Miko Mynttinen 2017-10-23 18:07:36 +02:00
Родитель 952fef1951
Коммит 27b7485c40
3 изменённых файлов: 23 добавлений и 21 удалений

Просмотреть файл

@ -3220,15 +3220,15 @@ nsDisplaySolidColorRegion::CreateWebRenderCommands(mozilla::wr::DisplayListBuild
} }
static void static void
RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
nsITheme::ThemeGeometryType aType) nsIFrame* aFrame, nsITheme::ThemeGeometryType aType)
{ {
if (aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) { if (aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) {
nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame); nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(aFrame);
nsPoint offset = aBuilder->IsInSubdocument() ? aBuilder->ToReferenceFrame(aFrame) nsPoint offset = aBuilder->IsInSubdocument() ? aBuilder->ToReferenceFrame(aFrame)
: aFrame->GetOffsetTo(displayRoot); : aFrame->GetOffsetTo(displayRoot);
nsRect borderBox = nsRect(offset, aFrame->GetSize()); nsRect borderBox = nsRect(offset, aFrame->GetSize());
aBuilder->RegisterThemeGeometry(aType, aFrame, aBuilder->RegisterThemeGeometry(aType, aItem,
LayoutDeviceIntRect::FromUnknownRect( LayoutDeviceIntRect::FromUnknownRect(
borderBox.ToNearestPixels( borderBox.ToNearestPixels(
aFrame->PresContext()->AppUnitsPerDevPixel()))); aFrame->PresContext()->AppUnitsPerDevPixel())));
@ -4184,7 +4184,7 @@ nsDisplayThemedBackground::nsDisplayThemedBackground(nsDisplayListBuilder* aBuil
nsITheme::ThemeGeometryType type = nsITheme::ThemeGeometryType type =
theme->ThemeGeometryTypeForWidget(mFrame, disp->mAppearance); theme->ThemeGeometryTypeForWidget(mFrame, disp->mAppearance);
if (type != nsITheme::eThemeGeometryTypeUnknown) { if (type != nsITheme::eThemeGeometryTypeUnknown) {
RegisterThemeGeometry(aBuilder, aFrame, type); RegisterThemeGeometry(aBuilder, this, aFrame, type);
} }
if (disp->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS || if (disp->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS ||

Просмотреть файл

@ -874,25 +874,27 @@ public:
* effects applied to them (e.g. CSS opacity or filters). * effects applied to them (e.g. CSS opacity or filters).
* *
* @param aWidgetType the -moz-appearance value for the themed widget * @param aWidgetType the -moz-appearance value for the themed widget
* @param aItem the item associated with the theme geometry
* @param aRect the device-pixel rect relative to the widget's displayRoot * @param aRect the device-pixel rect relative to the widget's displayRoot
* for the themed widget * for the themed widget
*/ */
void RegisterThemeGeometry(uint8_t aWidgetType, nsIFrame* aFrame, void RegisterThemeGeometry(uint8_t aWidgetType, nsDisplayItem* aItem,
const mozilla::LayoutDeviceIntRect& aRect) { const mozilla::LayoutDeviceIntRect& aRect)
if (mIsPaintingToWindow) { {
nsTArray<ThemeGeometry>* geometries = if (!mIsPaintingToWindow) {
mThemeGeometries.LookupOrAdd(aFrame); return;
geometries->AppendElement(ThemeGeometry(aWidgetType, aRect));
} }
nsTArray<ThemeGeometry>* geometries = mThemeGeometries.LookupOrAdd(aItem);
geometries->AppendElement(ThemeGeometry(aWidgetType, aRect));
} }
/** /**
* Removes theme geometries associated with the given frame. * Removes theme geometries associated with the given display item |aItem|.
*/ */
void UnregisterThemeGeometry(nsIFrame* aFrame) void UnregisterThemeGeometry(nsDisplayItem* aItem)
{ {
mThemeGeometries.Remove(aFrame); mThemeGeometries.Remove(aItem);
} }
/** /**
@ -1703,7 +1705,7 @@ private:
nsCOMPtr<nsISelection> mBoundingSelection; nsCOMPtr<nsISelection> mBoundingSelection;
AutoTArray<PresShellState,8> mPresShellStates; AutoTArray<PresShellState,8> mPresShellStates;
AutoTArray<nsIFrame*,400> mFramesMarkedForDisplay; AutoTArray<nsIFrame*,400> mFramesMarkedForDisplay;
nsClassHashtable<nsPtrHashKey<nsIFrame>, nsTArray<ThemeGeometry>> mThemeGeometries; nsClassHashtable<nsPtrHashKey<nsDisplayItem>, nsTArray<ThemeGeometry>> mThemeGeometries;
nsDisplayTableItem* mCurrentTableItem; nsDisplayTableItem* mCurrentTableItem;
DisplayListClipState mClipState; DisplayListClipState mClipState;
const ActiveScrolledRoot* mCurrentActiveScrolledRoot; const ActiveScrolledRoot* mCurrentActiveScrolledRoot;
@ -3858,7 +3860,7 @@ public:
void Destroy(nsDisplayListBuilder* aBuilder) override void Destroy(nsDisplayListBuilder* aBuilder) override
{ {
aBuilder->UnregisterThemeGeometry(mFrame); aBuilder->UnregisterThemeGeometry(this);
nsDisplayItem::Destroy(aBuilder); nsDisplayItem::Destroy(aBuilder);
} }

Просмотреть файл

@ -2790,7 +2790,7 @@ public:
void Destroy(nsDisplayListBuilder* aBuilder) override void Destroy(nsDisplayListBuilder* aBuilder) override
{ {
aBuilder->UnregisterThemeGeometry(mFrame); aBuilder->UnregisterThemeGeometry(this);
nsDisplayItem::Destroy(aBuilder); nsDisplayItem::Destroy(aBuilder);
} }
@ -2849,6 +2849,9 @@ nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
if (!mView || !GetContent ()->GetComposedDoc()->GetWindow()) if (!mView || !GetContent ()->GetComposedDoc()->GetWindow())
return; return;
nsDisplayItem* item = new (aBuilder) nsDisplayTreeBody(aBuilder, this);
aLists.Content()->AppendToTop(item);
#ifdef XP_MACOSX #ifdef XP_MACOSX
nsIContent* baseElement = GetBaseElement(); nsIContent* baseElement = GetBaseElement();
nsIFrame* treeFrame = nsIFrame* treeFrame =
@ -2884,7 +2887,7 @@ nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsRect rowRect(mInnerBox.x, mInnerBox.y + mRowHeight * nsRect rowRect(mInnerBox.x, mInnerBox.y + mRowHeight *
(i - FirstVisibleRow()), mInnerBox.width, (i - FirstVisibleRow()), mInnerBox.width,
mRowHeight); mRowHeight);
aBuilder->RegisterThemeGeometry(type, this, aBuilder->RegisterThemeGeometry(type, item,
LayoutDeviceIntRect::FromUnknownRect( LayoutDeviceIntRect::FromUnknownRect(
(rowRect + aBuilder->ToReferenceFrame(this)).ToNearestPixels( (rowRect + aBuilder->ToReferenceFrame(this)).ToNearestPixels(
PresContext()->AppUnitsPerDevPixel()))); PresContext()->AppUnitsPerDevPixel())));
@ -2895,9 +2898,6 @@ nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
} }
} }
#endif #endif
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayTreeBody(aBuilder, this));
} }
DrawResult DrawResult