Bug 1607135 - Don't require TriggerImageLoads method when not needed. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D58707

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Xidorn Quan 2020-01-07 08:51:19 +00:00
Родитель e12a18dac8
Коммит 75f5cd0cef
2 изменённых файлов: 41 добавлений и 45 удалений

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

@ -21,15 +21,28 @@
namespace mozilla {
namespace detail {
template <typename T, const T* (ComputedStyle::*Method)() const>
void TriggerImageLoads(dom::Document& aDocument, const ComputedStyle* aOldStyle,
ComputedStyle* aStyle) {
if constexpr (T::kHasTriggerImageLoads) {
auto* old = aOldStyle ? (aOldStyle->*Method)() : nullptr;
auto* current = const_cast<T*>((aStyle->*Method)());
current->TriggerImageLoads(aDocument, old);
} else {
Unused << aOldStyle;
Unused << aStyle;
}
}
} // namespace detail
void ComputedStyle::StartImageLoads(dom::Document& aDocument,
const ComputedStyle* aOldStyle) {
MOZ_ASSERT(NS_IsMainThread());
#define STYLE_STRUCT(name_) \
if (nsStyle##name_::kHasTriggerImageLoads) { \
auto* old = aOldStyle ? aOldStyle->Style##name_() : nullptr; \
auto* current = const_cast<nsStyle##name_*>(Style##name_()); \
current->TriggerImageLoads(aDocument, old); \
}
#define STYLE_STRUCT(name_) \
detail::TriggerImageLoads<nsStyle##name_, &ComputedStyle::Style##name_>( \
aDocument, aOldStyle, this);
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
}

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

@ -80,8 +80,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont {
nsStyleFont(const nsStyleFont& aStyleFont);
explicit nsStyleFont(const mozilla::dom::Document&);
~nsStyleFont() { MOZ_COUNT_DTOR(nsStyleFont); }
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleFont*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleFont& aNewData) const;
@ -593,7 +592,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
// style system, where those images must be resolved later than the OMT
// nsStyleBackground constructor call.
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleBackground*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleBackground& aNewData) const;
@ -627,8 +626,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin {
explicit nsStyleMargin(const mozilla::dom::Document&);
nsStyleMargin(const nsStyleMargin& aMargin);
~nsStyleMargin() { MOZ_COUNT_DTOR(nsStyleMargin); }
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleMargin*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleMargin& aNewData) const;
@ -666,8 +664,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding {
explicit nsStylePadding(const mozilla::dom::Document&);
nsStylePadding(const nsStylePadding& aPadding);
~nsStylePadding() { MOZ_COUNT_DTOR(nsStylePadding); }
void TriggerImageLoads(mozilla::dom::Document&, const nsStylePadding*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStylePadding& aNewData) const;
@ -713,7 +710,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder {
// style system, where those images must be resolved later than the OMT
// nsStyleBorder constructor call.
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleBorder*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleBorder& aNewData) const;
@ -879,8 +876,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline {
explicit nsStyleOutline(const mozilla::dom::Document&);
nsStyleOutline(const nsStyleOutline& aOutline);
~nsStyleOutline() { MOZ_COUNT_DTOR(nsStyleOutline); }
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleOutline*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleOutline& aNewData) const;
@ -925,7 +921,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList {
~nsStyleList();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleList*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleList& aNewData,
const nsStyleDisplay& aOldDisplay) const;
@ -972,8 +968,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
explicit nsStylePosition(const mozilla::dom::Document&);
nsStylePosition(const nsStylePosition& aOther);
~nsStylePosition();
void TriggerImageLoads(mozilla::dom::Document&, const nsStylePosition*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(
const nsStylePosition& aNewData,
@ -1099,8 +1094,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset {
explicit nsStyleTextReset(const mozilla::dom::Document&);
nsStyleTextReset(const nsStyleTextReset& aOther);
~nsStyleTextReset();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleTextReset*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
// Note the difference between this and
// ComputedStyle::HasTextDecorationLines.
@ -1127,8 +1121,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
explicit nsStyleText(const mozilla::dom::Document&);
nsStyleText(const nsStyleText& aOther);
~nsStyleText();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleText*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleText& aNewData) const;
@ -1261,8 +1254,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility {
explicit nsStyleVisibility(const mozilla::dom::Document&);
nsStyleVisibility(const nsStyleVisibility& aVisibility);
~nsStyleVisibility() { MOZ_COUNT_DTOR(nsStyleVisibility); }
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleVisibility*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleVisibility& aNewData) const;
@ -1479,7 +1471,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
~nsStyleDisplay();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleDisplay*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleDisplay& aNewData,
const nsStylePosition& aOldPosition) const;
@ -1898,8 +1890,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable {
explicit nsStyleTable(const mozilla::dom::Document&);
nsStyleTable(const nsStyleTable& aOther);
~nsStyleTable();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleTable*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleTable& aNewData) const;
@ -1911,8 +1902,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTableBorder {
explicit nsStyleTableBorder(const mozilla::dom::Document&);
nsStyleTableBorder(const nsStyleTableBorder& aOther);
~nsStyleTableBorder();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleTableBorder*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleTableBorder& aNewData) const;
@ -1929,9 +1919,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent {
explicit nsStyleContent(const mozilla::dom::Document&);
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleContent*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
size_t ContentCount() const {
return mContent.IsItems() ? mContent.AsItems().Length() : 0;
@ -1953,8 +1941,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUIReset {
explicit nsStyleUIReset(const mozilla::dom::Document&);
nsStyleUIReset(const nsStyleUIReset& aOther);
~nsStyleUIReset();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleUIReset*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleUIReset& aNewData) const;
@ -1993,7 +1980,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUI {
~nsStyleUI();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleUI*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleUI& aNewData) const;
@ -2018,8 +2005,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleXUL {
explicit nsStyleXUL(const mozilla::dom::Document&);
nsStyleXUL(const nsStyleXUL& aSource);
~nsStyleXUL();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleXUL*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleXUL& aNewData) const;
@ -2035,8 +2021,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn {
explicit nsStyleColumn(const mozilla::dom::Document&);
nsStyleColumn(const nsStyleColumn& aSource);
~nsStyleColumn();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleColumn*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleColumn& aNewData) const;
@ -2082,8 +2067,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVG {
explicit nsStyleSVG(const mozilla::dom::Document&);
nsStyleSVG(const nsStyleSVG& aSource);
~nsStyleSVG();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleSVG*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleSVG& aNewData) const;
@ -2187,7 +2171,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleSVGReset {
// style system, where those images must be resolved later than the OMT
// nsStyleSVGReset constructor call.
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleSVGReset*);
const static bool kHasTriggerImageLoads = true;
static constexpr bool kHasTriggerImageLoads = true;
nsChangeHint CalcDifference(const nsStyleSVGReset& aNewData) const;
@ -2227,8 +2211,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects {
explicit nsStyleEffects(const mozilla::dom::Document&);
nsStyleEffects(const nsStyleEffects& aSource);
~nsStyleEffects();
void TriggerImageLoads(mozilla::dom::Document&, const nsStyleEffects*) {}
const static bool kHasTriggerImageLoads = false;
static constexpr bool kHasTriggerImageLoads = false;
nsChangeHint CalcDifference(const nsStyleEffects& aNewData) const;