mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1525134 - Move image loads out of the style struct accessors. r=heycam
After this I can pass the document from the caller to ResolveSameStructsAs, and get rid of the pres context pointer. Differential Revision: https://phabricator.services.mozilla.com/D18600 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c072ec0173
commit
e38aff2db7
@ -1537,7 +1537,7 @@ void KeyframeEffect::CalculateCumulativeChangeHint(
|
||||
|
||||
uint32_t equalStructs = 0;
|
||||
nsChangeHint changeHint =
|
||||
fromContext->CalcStyleDifference(toContext, &equalStructs);
|
||||
fromContext->CalcStyleDifference(*toContext, &equalStructs);
|
||||
|
||||
mCumulativeChangeHint |= changeHint;
|
||||
}
|
||||
|
@ -54,6 +54,7 @@
|
||||
#endif
|
||||
|
||||
using mozilla::layers::AnimationInfo;
|
||||
using mozilla::layout::ScrollAnchorContainer;
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
@ -2439,7 +2440,7 @@ struct RestyleManager::TextPostTraversalState {
|
||||
if (mShouldComputeHints) {
|
||||
mShouldComputeHints = false;
|
||||
uint32_t equalStructs;
|
||||
mComputedHint = oldStyle->CalcStyleDifference(&aNewStyle, &equalStructs);
|
||||
mComputedHint = oldStyle->CalcStyleDifference(aNewStyle, &equalStructs);
|
||||
mComputedHint = NS_RemoveSubsumedHints(
|
||||
mComputedHint, mParentRestyleState.ChangesHandledFor(aTextFrame));
|
||||
}
|
||||
@ -2545,7 +2546,7 @@ static void UpdateOneAdditionalComputedStyle(nsIFrame* aFrame, uint32_t aIndex,
|
||||
|
||||
uint32_t equalStructs; // Not used, actually.
|
||||
nsChangeHint childHint =
|
||||
aOldContext.CalcStyleDifference(newStyle, &equalStructs);
|
||||
aOldContext.CalcStyleDifference(*newStyle, &equalStructs);
|
||||
if (!aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
|
||||
childHint = NS_RemoveSubsumedHints(childHint,
|
||||
aRestyleState.ChangesHandledFor(aFrame));
|
||||
@ -2796,7 +2797,8 @@ bool RestyleManager::ProcessPostTraversal(Element* aElement,
|
||||
// but it doesn't matter, since the only point of it is calling
|
||||
// TriggerImageLoads on the relevant structs, and those don't matter for
|
||||
// display: contents.
|
||||
upToDateContext->ResolveSameStructsAs(oldOrDisplayContentsStyle);
|
||||
upToDateContext->StartImageLoads(*mPresContext->Document(),
|
||||
oldOrDisplayContentsStyle);
|
||||
|
||||
// We want to walk all the continuations here, even the ones with different
|
||||
// styles. In practice, the only reason we get continuations with different
|
||||
|
@ -2336,9 +2336,6 @@ nsIFrame* nsCSSFrameConstructor::ConstructDocElementFrame(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Make sure to start any background image loads for the root element now.
|
||||
computedStyle->StartBackgroundImageLoads();
|
||||
|
||||
nsFrameConstructorSaveState docElementContainingBlockAbsoluteSaveState;
|
||||
if (mHasRootAbsPosContainingBlock) {
|
||||
// Push the absolute containing block now so we can absolutely position
|
||||
@ -5650,10 +5647,6 @@ void nsCSSFrameConstructor::ConstructFramesFromItem(
|
||||
return;
|
||||
}
|
||||
|
||||
// Start background loads during frame construction so that we're
|
||||
// guaranteed that they will be started before onload fires.
|
||||
computedStyle->StartBackgroundImageLoads();
|
||||
|
||||
AutoRestore<nsFrameState> savedStateBits(aState.mAdditionalStateBits);
|
||||
if (item.mIsGeneratedContent) {
|
||||
// Ensure that frames created here are all tagged with
|
||||
|
@ -382,12 +382,6 @@ void ViewportFrame::UpdateStyle(ServoRestyleState& aRestyleState) {
|
||||
aRestyleState.StyleSet().ResolveInheritingAnonymousBoxStyle(pseudo,
|
||||
nullptr);
|
||||
|
||||
// We're special because we have a null GetContent(), so don't call things
|
||||
// like UpdateStyleOfOwnedChildFrame that try to append changes for the
|
||||
// content to the change list. Nor do we computed a changehint, since we have
|
||||
// no way to apply it anyway.
|
||||
newStyle->ResolveSameStructsAs(Style());
|
||||
|
||||
MOZ_ASSERT(!GetNextContinuation(), "Viewport has continuations?");
|
||||
SetComputedStyle(newStyle);
|
||||
|
||||
|
@ -150,19 +150,17 @@ bool nsBulletFrame::IsSelfEmpty() {
|
||||
if (aOldComputedStyle) {
|
||||
nsAccessibilityService* accService = nsIPresShell::AccService();
|
||||
if (accService) {
|
||||
const nsStyleList* oldStyleList = aOldComputedStyle->PeekStyleList();
|
||||
if (oldStyleList) {
|
||||
bool hadBullet = oldStyleList->GetListStyleImage() ||
|
||||
!oldStyleList->mCounterStyle.IsNone();
|
||||
const nsStyleList* oldStyleList = aOldComputedStyle->StyleList();
|
||||
bool hadBullet = oldStyleList->GetListStyleImage() ||
|
||||
!oldStyleList->mCounterStyle.IsNone();
|
||||
|
||||
const nsStyleList* newStyleList = StyleList();
|
||||
bool hasBullet = newStyleList->GetListStyleImage() ||
|
||||
!newStyleList->mCounterStyle.IsNone();
|
||||
const nsStyleList* newStyleList = StyleList();
|
||||
bool hasBullet = newStyleList->GetListStyleImage() ||
|
||||
!newStyleList->mCounterStyle.IsNone();
|
||||
|
||||
if (hadBullet != hasBullet) {
|
||||
accService->UpdateListBullet(PresContext()->GetPresShell(), mContent,
|
||||
hasBullet);
|
||||
}
|
||||
if (hadBullet != hasBullet) {
|
||||
accService->UpdateListBullet(PresContext()->GetPresShell(), mContent,
|
||||
hasBullet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -589,6 +589,7 @@ void nsFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
NS_FRAME_MAY_BE_TRANSFORMED |
|
||||
NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN));
|
||||
} else {
|
||||
mComputedStyle->StartImageLoads(*PresContext()->Document());
|
||||
PresContext()->ConstructedFrame();
|
||||
}
|
||||
if (GetParent()) {
|
||||
@ -1066,8 +1067,8 @@ void nsIFrame::MarkNeedsDisplayItemRebuild() {
|
||||
// We don't want to set the property if one already exists.
|
||||
nsMargin oldValue(0, 0, 0, 0);
|
||||
nsMargin newValue(0, 0, 0, 0);
|
||||
const nsStyleMargin* oldMargin = aOldComputedStyle->PeekStyleMargin();
|
||||
if (oldMargin && oldMargin->GetMargin(oldValue)) {
|
||||
const nsStyleMargin* oldMargin = aOldComputedStyle->StyleMargin();
|
||||
if (oldMargin->GetMargin(oldValue)) {
|
||||
if (!StyleMargin()->GetMargin(newValue) || oldValue != newValue) {
|
||||
if (!HasProperty(UsedMarginProperty())) {
|
||||
AddProperty(UsedMarginProperty(), new nsMargin(oldValue));
|
||||
@ -1076,8 +1077,8 @@ void nsIFrame::MarkNeedsDisplayItemRebuild() {
|
||||
}
|
||||
}
|
||||
|
||||
const nsStylePadding* oldPadding = aOldComputedStyle->PeekStylePadding();
|
||||
if (oldPadding && oldPadding->GetPadding(oldValue)) {
|
||||
const nsStylePadding* oldPadding = aOldComputedStyle->StylePadding();
|
||||
if (oldPadding->GetPadding(oldValue)) {
|
||||
if (!StylePadding()->GetPadding(newValue) || oldValue != newValue) {
|
||||
if (!HasProperty(UsedPaddingProperty())) {
|
||||
AddProperty(UsedPaddingProperty(), new nsMargin(oldValue));
|
||||
@ -1086,20 +1087,16 @@ void nsIFrame::MarkNeedsDisplayItemRebuild() {
|
||||
}
|
||||
}
|
||||
|
||||
const nsStyleBorder* oldBorder = aOldComputedStyle->PeekStyleBorder();
|
||||
if (oldBorder) {
|
||||
oldValue = oldBorder->GetComputedBorder();
|
||||
newValue = StyleBorder()->GetComputedBorder();
|
||||
if (oldValue != newValue && !HasProperty(UsedBorderProperty())) {
|
||||
AddProperty(UsedBorderProperty(), new nsMargin(oldValue));
|
||||
}
|
||||
const nsStyleBorder* oldBorder = aOldComputedStyle->StyleBorder();
|
||||
oldValue = oldBorder->GetComputedBorder();
|
||||
newValue = StyleBorder()->GetComputedBorder();
|
||||
if (oldValue != newValue && !HasProperty(UsedBorderProperty())) {
|
||||
AddProperty(UsedBorderProperty(), new nsMargin(oldValue));
|
||||
}
|
||||
|
||||
const nsStyleDisplay* oldDisp = aOldComputedStyle->PeekStyleDisplay();
|
||||
if (oldDisp &&
|
||||
(oldDisp->mOverflowAnchor != StyleDisplay()->mOverflowAnchor)) {
|
||||
if (ScrollAnchorContainer* container =
|
||||
ScrollAnchorContainer::FindFor(this)) {
|
||||
const nsStyleDisplay* oldDisp = aOldComputedStyle->StyleDisplay();
|
||||
if (oldDisp->mOverflowAnchor != StyleDisplay()->mOverflowAnchor) {
|
||||
if (auto* container = ScrollAnchorContainer::FindFor(this)) {
|
||||
container->InvalidateAnchor();
|
||||
}
|
||||
if (nsIScrollableFrame* scrollableFrame = do_QueryFrame(this)) {
|
||||
@ -1109,20 +1106,19 @@ void nsIFrame::MarkNeedsDisplayItemRebuild() {
|
||||
|
||||
if (mInScrollAnchorChain) {
|
||||
const nsStylePosition* oldPosition =
|
||||
aOldComputedStyle->PeekStylePosition();
|
||||
if (oldPosition &&
|
||||
(oldPosition->mOffset != StylePosition()->mOffset ||
|
||||
oldPosition->mWidth != StylePosition()->mWidth ||
|
||||
oldPosition->mMinWidth != StylePosition()->mMinWidth ||
|
||||
oldPosition->mMaxWidth != StylePosition()->mMaxWidth ||
|
||||
oldPosition->mHeight != StylePosition()->mHeight ||
|
||||
oldPosition->mMinHeight != StylePosition()->mMinHeight ||
|
||||
oldPosition->mMaxHeight != StylePosition()->mMaxHeight)) {
|
||||
aOldComputedStyle->StylePosition();
|
||||
if (oldPosition->mOffset != StylePosition()->mOffset ||
|
||||
oldPosition->mWidth != StylePosition()->mWidth ||
|
||||
oldPosition->mMinWidth != StylePosition()->mMinWidth ||
|
||||
oldPosition->mMaxWidth != StylePosition()->mMaxWidth ||
|
||||
oldPosition->mHeight != StylePosition()->mHeight ||
|
||||
oldPosition->mMinHeight != StylePosition()->mMinHeight ||
|
||||
oldPosition->mMaxHeight != StylePosition()->mMaxHeight) {
|
||||
needAnchorSuppression = true;
|
||||
}
|
||||
|
||||
if (oldDisp && (oldDisp->mPosition != StyleDisplay()->mPosition ||
|
||||
oldDisp->TransformChanged(*StyleDisplay()))) {
|
||||
if (oldDisp->mPosition != StyleDisplay()->mPosition ||
|
||||
oldDisp->TransformChanged(*StyleDisplay())) {
|
||||
needAnchorSuppression = true;
|
||||
}
|
||||
}
|
||||
@ -10248,14 +10244,7 @@ void nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame,
|
||||
// anonymous boxes directly.
|
||||
uint32_t equalStructs; // Not used, actually.
|
||||
nsChangeHint childHint = aChildFrame->Style()->CalcStyleDifference(
|
||||
aNewComputedStyle, &equalStructs);
|
||||
|
||||
// CalcStyleDifference will handle caching structs on the new style, but only
|
||||
// if we're not on a style worker thread.
|
||||
MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal(),
|
||||
"if we can get in here from style worker threads, then we need "
|
||||
"a ResolveSameStructsAs call to ensure structs are cached on "
|
||||
"aNewComputedStyle");
|
||||
*aNewComputedStyle, &equalStructs);
|
||||
|
||||
// If aChildFrame is out of flow, then aRestyleState's "changes handled by the
|
||||
// parent" doesn't apply to it, because it may have some other parent in the
|
||||
|
@ -54,9 +54,8 @@ ComputedStyle::ComputedStyle(nsPresContext* aPresContext, nsAtom* aPseudoTag,
|
||||
MOZ_ASSERT(ComputedData());
|
||||
}
|
||||
|
||||
nsChangeHint ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
uint32_t* aEqualStructs) {
|
||||
MOZ_ASSERT(aNewContext);
|
||||
nsChangeHint ComputedStyle::CalcStyleDifference(const ComputedStyle& aNewStyle,
|
||||
uint32_t* aEqualStructs) const {
|
||||
AUTO_PROFILER_LABEL("ComputedStyle::CalcStyleDifference", LAYOUT);
|
||||
static_assert(StyleStructConstants::kStyleStructCount <= 32,
|
||||
"aEqualStructs is not big enough");
|
||||
@ -91,30 +90,25 @@ nsChangeHint ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
#define PEEK(struct_) ComputedData()->GetStyle##struct_()
|
||||
|
||||
#define EXPAND(...) __VA_ARGS__
|
||||
#define DO_STRUCT_DIFFERENCE_WITH_ARGS(struct_, extra_args_) \
|
||||
PR_BEGIN_MACRO \
|
||||
const nsStyle##struct_* this##struct_ = PEEK(struct_); \
|
||||
if (this##struct_) { \
|
||||
structsFound |= STYLE_STRUCT_BIT(struct_); \
|
||||
\
|
||||
const nsStyle##struct_* other##struct_ = \
|
||||
aNewContext->ThreadsafeStyle##struct_(); \
|
||||
if (this##struct_ == other##struct_) { \
|
||||
/* The very same struct, so we know that there will be no */ \
|
||||
/* differences. */ \
|
||||
*aEqualStructs |= STYLE_STRUCT_BIT(struct_); \
|
||||
} else { \
|
||||
nsChangeHint difference = \
|
||||
this##struct_->CalcDifference(*other##struct_ EXPAND extra_args_); \
|
||||
hint |= difference; \
|
||||
if (!difference) { \
|
||||
*aEqualStructs |= STYLE_STRUCT_BIT(struct_); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
*aEqualStructs |= STYLE_STRUCT_BIT(struct_); \
|
||||
} \
|
||||
styleStructCount++; \
|
||||
#define DO_STRUCT_DIFFERENCE_WITH_ARGS(struct_, extra_args_) \
|
||||
PR_BEGIN_MACRO \
|
||||
const nsStyle##struct_* this##struct_ = Style##struct_(); \
|
||||
structsFound |= STYLE_STRUCT_BIT(struct_); \
|
||||
\
|
||||
const nsStyle##struct_* other##struct_ = aNewStyle.Style##struct_(); \
|
||||
if (this##struct_ == other##struct_) { \
|
||||
/* The very same struct, so we know that there will be no */ \
|
||||
/* differences. */ \
|
||||
*aEqualStructs |= STYLE_STRUCT_BIT(struct_); \
|
||||
} else { \
|
||||
nsChangeHint difference = \
|
||||
this##struct_->CalcDifference(*other##struct_ EXPAND extra_args_); \
|
||||
hint |= difference; \
|
||||
if (!difference) { \
|
||||
*aEqualStructs |= STYLE_STRUCT_BIT(struct_); \
|
||||
} \
|
||||
} \
|
||||
styleStructCount++; \
|
||||
PR_END_MACRO
|
||||
#define DO_STRUCT_DIFFERENCE(struct_) \
|
||||
DO_STRUCT_DIFFERENCE_WITH_ARGS(struct_, ())
|
||||
@ -179,8 +173,8 @@ nsChangeHint ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
// here, we add nsChangeHint_RepaintFrame hints (the maximum for
|
||||
// things that can depend on :visited) for the properties on which we
|
||||
// call GetVisitedDependentColor.
|
||||
ComputedStyle* thisVis = GetStyleIfVisited();
|
||||
ComputedStyle* otherVis = aNewContext->GetStyleIfVisited();
|
||||
const ComputedStyle* thisVis = GetStyleIfVisited();
|
||||
const ComputedStyle* otherVis = aNewStyle.GetStyleIfVisited();
|
||||
if (!thisVis != !otherVis) {
|
||||
// One style has a style-if-visited and the other doesn't.
|
||||
// Presume a difference.
|
||||
@ -198,15 +192,14 @@ nsChangeHint ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
// due to change being true already or due to the old style not having a
|
||||
// style-if-visited), but not the other way around.
|
||||
#define STYLE_FIELD(name_) thisVisStruct->name_ != otherVisStruct->name_
|
||||
#define STYLE_STRUCT(name_, fields_) \
|
||||
if (PEEK(name_)) { \
|
||||
const nsStyle##name_* thisVisStruct = thisVis->ThreadsafeStyle##name_(); \
|
||||
const nsStyle##name_* otherVisStruct = otherVis->ThreadsafeStyle##name_(); \
|
||||
if (MOZ_FOR_EACH_SEPARATED(STYLE_FIELD, (||), (), fields_)) { \
|
||||
*aEqualStructs &= ~STYLE_STRUCT_BIT(name_); \
|
||||
change = true; \
|
||||
} \
|
||||
}
|
||||
#define STYLE_STRUCT(name_, fields_) { \
|
||||
const nsStyle##name_* thisVisStruct = thisVis->Style##name_(); \
|
||||
const nsStyle##name_* otherVisStruct = otherVis->Style##name_(); \
|
||||
if (MOZ_FOR_EACH_SEPARATED(STYLE_FIELD, (||), (), fields_)) { \
|
||||
*aEqualStructs &= ~STYLE_STRUCT_BIT(name_); \
|
||||
change = true; \
|
||||
} \
|
||||
}
|
||||
#include "nsCSSVisitedDependentPropList.h"
|
||||
#undef STYLE_STRUCT
|
||||
#undef STYLE_FIELD
|
||||
@ -231,15 +224,14 @@ nsChangeHint ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
// doesn't use Peek* functions to get the structs on the old
|
||||
// context. But this isn't a big concern because these struct
|
||||
// getters should be called during frame construction anyway.
|
||||
const nsStyleDisplay* oldDisp = ThreadsafeStyleDisplay();
|
||||
const nsStyleDisplay* newDisp = aNewContext->ThreadsafeStyleDisplay();
|
||||
const nsStyleDisplay* oldDisp = StyleDisplay();
|
||||
const nsStyleDisplay* newDisp = aNewStyle.StyleDisplay();
|
||||
bool isFixedCB;
|
||||
if (oldDisp->IsAbsPosContainingBlockForNonSVGTextFrames() ==
|
||||
newDisp->IsAbsPosContainingBlockForNonSVGTextFrames() &&
|
||||
(isFixedCB =
|
||||
oldDisp->IsFixedPosContainingBlockForNonSVGTextFrames(*this)) ==
|
||||
newDisp->IsFixedPosContainingBlockForNonSVGTextFrames(
|
||||
*aNewContext) &&
|
||||
newDisp->IsFixedPosContainingBlockForNonSVGTextFrames(aNewStyle) &&
|
||||
// transform-supporting frames are a subcategory of non-SVG-text
|
||||
// frames, so no need to test this if isFixedCB is true (both
|
||||
// before and after the change)
|
||||
|
@ -42,6 +42,10 @@ void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle*);
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class Document;
|
||||
}
|
||||
|
||||
enum class CSSPseudoElementType : uint8_t;
|
||||
class ComputedStyle;
|
||||
|
||||
@ -219,38 +223,10 @@ class ComputedStyle {
|
||||
mCachedInheritingStyles.Insert(aStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define typesafe getter functions for each style struct by
|
||||
* preprocessing the list of style structs. These functions are the
|
||||
* preferred way to get style data. The macro creates functions like:
|
||||
* const nsStyleBorder* StyleBorder();
|
||||
* const nsStyleColor* StyleColor();
|
||||
*/
|
||||
#define STYLE_STRUCT(name_) \
|
||||
inline const nsStyle##name_* Style##name_() MOZ_NONNULL_RETURN;
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
/**
|
||||
* Equivalent to StyleFoo(), except that we skip the cache write during the
|
||||
* servo traversal. This can cause incorrect behavior if used improperly,
|
||||
* since we won't record that layout potentially depends on the values in
|
||||
* this style struct. Use with care.
|
||||
*/
|
||||
|
||||
#define STYLE_STRUCT(name_) \
|
||||
inline const nsStyle##name_* ThreadsafeStyle##name_();
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
/**
|
||||
* PeekStyle* is like Style* but doesn't trigger style
|
||||
* computation if the data is not cached on either the ComputedStyle
|
||||
* or the rule node.
|
||||
*
|
||||
* Perhaps this shouldn't be a public ComputedStyle API.
|
||||
*/
|
||||
#define STYLE_STRUCT(name_) inline const nsStyle##name_* PeekStyle##name_();
|
||||
#define STYLE_STRUCT(name_) \
|
||||
inline const nsStyle##name_* Style##name_() const MOZ_NONNULL_RETURN { \
|
||||
return mSource.GetStyle##name_(); \
|
||||
}
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
@ -271,8 +247,8 @@ class ComputedStyle {
|
||||
* CSS Variables are not compared here. Instead, the caller is responsible for
|
||||
* that when needed (basically only for elements).
|
||||
*/
|
||||
nsChangeHint CalcStyleDifference(ComputedStyle* aNewContext,
|
||||
uint32_t* aEqualStructs);
|
||||
nsChangeHint CalcStyleDifference(const ComputedStyle& aNewContext,
|
||||
uint32_t* aEqualStructs) const;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -296,9 +272,13 @@ class ComputedStyle {
|
||||
static nscolor CombineVisitedColors(nscolor* aColors, bool aLinkIsVisited);
|
||||
|
||||
/**
|
||||
* Start the background image loads for this ComputedStyle.
|
||||
* Start image loads for this style.
|
||||
*
|
||||
* The Document is used to get a hand on the image loader. The old style is a
|
||||
* hack for bug 1439285.
|
||||
*/
|
||||
inline void StartBackgroundImageLoads();
|
||||
inline void StartImageLoads(dom::Document&,
|
||||
const ComputedStyle* aOldStyle = nullptr);
|
||||
|
||||
#ifdef DEBUG
|
||||
void List(FILE* out, int32_t aIndent);
|
||||
@ -306,25 +286,12 @@ class ComputedStyle {
|
||||
static Maybe<StyleStructID> LookupStruct(const nsACString& aName);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Makes this context match |aOther| in terms of which style structs have
|
||||
* been resolved.
|
||||
*/
|
||||
inline void ResolveSameStructsAs(const ComputedStyle* aOther);
|
||||
|
||||
// The |aCVsSize| outparam on this function is where the actual CVs size
|
||||
// value is added. It's done that way because the callers know which value
|
||||
// the size should be added to.
|
||||
void AddSizeOfIncludingThis(nsWindowSizes& aSizes, size_t* aCVsSize) const;
|
||||
|
||||
protected:
|
||||
bool HasRequestedStruct(StyleStructID aID) const {
|
||||
return mRequestedStructs & StyleStructConstants::BitFor(aID);
|
||||
}
|
||||
|
||||
void SetRequestedStruct(StyleStructID aID) {
|
||||
mRequestedStructs |= StyleStructConstants::BitFor(aID);
|
||||
}
|
||||
|
||||
// Needs to be friend so that it can call the destructor without making it
|
||||
// public.
|
||||
@ -339,24 +306,10 @@ class ComputedStyle {
|
||||
// A cache of anonymous box and lazy pseudo styles inheriting from this style.
|
||||
CachedInheritingStyles mCachedInheritingStyles;
|
||||
|
||||
// Helper functions for GetStyle* and PeekStyle*
|
||||
#define STYLE_STRUCT_INHERITED(name_) \
|
||||
template <bool aComputeData> \
|
||||
const nsStyle##name_* DoGetStyle##name_();
|
||||
#define STYLE_STRUCT_RESET(name_) \
|
||||
template <bool aComputeData> \
|
||||
const nsStyle##name_* DoGetStyle##name_();
|
||||
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT_RESET
|
||||
#undef STYLE_STRUCT_INHERITED
|
||||
|
||||
// If this ComputedStyle is for a pseudo-element or anonymous box,
|
||||
// the relevant atom.
|
||||
const RefPtr<nsAtom> mPseudoTag;
|
||||
|
||||
// A bitfield with the structs that have been requested so far.
|
||||
uint32_t mRequestedStructs = 0;
|
||||
const Bit mBits;
|
||||
const CSSPseudoElementType mPseudoType;
|
||||
};
|
||||
|
@ -21,67 +21,17 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#define STYLE_STRUCT(name_) \
|
||||
const nsStyle##name_* ComputedStyle::Style##name_() { \
|
||||
return DoGetStyle##name_<true>(); \
|
||||
} \
|
||||
const nsStyle##name_* ComputedStyle::ThreadsafeStyle##name_() { \
|
||||
if (mozilla::IsInServoTraversal()) { \
|
||||
return ComputedData()->GetStyle##name_(); \
|
||||
} \
|
||||
return Style##name_(); \
|
||||
} \
|
||||
const nsStyle##name_* ComputedStyle::PeekStyle##name_() { \
|
||||
return DoGetStyle##name_<false>(); \
|
||||
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); \
|
||||
}
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
// Helper functions for GetStyle* and PeekStyle*
|
||||
#define STYLE_STRUCT(name_) \
|
||||
template <bool aComputeData> \
|
||||
const nsStyle##name_* ComputedStyle::DoGetStyle##name_() { \
|
||||
const auto kStructID = StyleStructID::name_; \
|
||||
const bool needToCompute = !HasRequestedStruct(kStructID); \
|
||||
if (!aComputeData && needToCompute) { \
|
||||
return nullptr; \
|
||||
} \
|
||||
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
|
||||
/* perform any remaining main thread work on the struct */ \
|
||||
if (needToCompute) { \
|
||||
MOZ_ASSERT(NS_IsMainThread()); \
|
||||
MOZ_ASSERT(!mozilla::IsInServoTraversal()); \
|
||||
const_cast<nsStyle##name_*>(data)->TriggerImageLoads( \
|
||||
*mPresContext->Document(), nullptr); \
|
||||
/* the ComputedStyle owns the struct */ \
|
||||
SetRequestedStruct(kStructID); \
|
||||
} \
|
||||
return data; \
|
||||
}
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
void ComputedStyle::StartBackgroundImageLoads() {
|
||||
// Just get our background struct; that should do the trick
|
||||
StyleBackground();
|
||||
}
|
||||
|
||||
void ComputedStyle::ResolveSameStructsAs(const ComputedStyle* aOther) {
|
||||
// Only resolve structs that are not already resolved in this struct.
|
||||
auto newBits = aOther->mRequestedStructs & ~mRequestedStructs;
|
||||
|
||||
#define STYLE_STRUCT(name_) \
|
||||
if (nsStyle##name_::kHasTriggerImageLoads && \
|
||||
(newBits & StyleStructConstants::BitFor(StyleStructID::name_))) { \
|
||||
const nsStyle##name_* data = ComputedData()->GetStyle##name_(); \
|
||||
const nsStyle##name_* oldData = aOther->ComputedData()->GetStyle##name_(); \
|
||||
const_cast<nsStyle##name_*>(data)->TriggerImageLoads( \
|
||||
*mPresContext->Document(), oldData); \
|
||||
}
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
mRequestedStructs |= newBits;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -327,8 +327,7 @@ uint32_t Gecko_CalcStyleDifference(ComputedStyleBorrowed aOldStyle,
|
||||
|
||||
uint32_t equalStructs;
|
||||
nsChangeHint result =
|
||||
const_cast<ComputedStyle*>(aOldStyle)->CalcStyleDifference(
|
||||
const_cast<ComputedStyle*>(aNewStyle), &equalStructs);
|
||||
aOldStyle->CalcStyleDifference(*aNewStyle, &equalStructs);
|
||||
|
||||
*aAnyStyleStructChanged =
|
||||
equalStructs != StyleStructConstants::kAllStructsMask;
|
||||
|
@ -2294,7 +2294,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
|
||||
* frame (i.e., when calculating style changes).
|
||||
*/
|
||||
inline bool IsFixedPosContainingBlockForNonSVGTextFrames(
|
||||
mozilla::ComputedStyle&) const;
|
||||
const mozilla::ComputedStyle&) const;
|
||||
inline bool
|
||||
IsFixedPosContainingBlockForContainLayoutAndPaintSupportingFrames() const;
|
||||
inline bool IsFixedPosContainingBlockForTransformSupportingFrames() const;
|
||||
|
@ -130,16 +130,16 @@ bool nsStyleDisplay::HasPerspective(const nsIFrame* aContextFrame) const {
|
||||
}
|
||||
|
||||
bool nsStyleDisplay::IsFixedPosContainingBlockForNonSVGTextFrames(
|
||||
mozilla::ComputedStyle& aStyle) const {
|
||||
const mozilla::ComputedStyle& aStyle) const {
|
||||
// NOTE: Any CSS properties that influence the output of this function
|
||||
// should have the FIXPOS_CB flag set on them.
|
||||
NS_ASSERTION(aStyle.ThreadsafeStyleDisplay() == this, "unexpected aStyle");
|
||||
NS_ASSERTION(aStyle.StyleDisplay() == this, "unexpected aStyle");
|
||||
|
||||
if (mWillChangeBitField & NS_STYLE_WILL_CHANGE_FIXPOS_CB) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return aStyle.ThreadsafeStyleEffects()->HasFilters();
|
||||
return aStyle.StyleEffects()->HasFilters();
|
||||
}
|
||||
|
||||
bool nsStyleDisplay::
|
||||
@ -157,8 +157,7 @@ bool nsStyleDisplay::IsFixedPosContainingBlockForTransformSupportingFrames()
|
||||
bool nsStyleDisplay::IsFixedPosContainingBlock(
|
||||
const nsIFrame* aContextFrame) const {
|
||||
mozilla::ComputedStyle* style = aContextFrame->Style();
|
||||
NS_ASSERTION(style->ThreadsafeStyleDisplay() == this,
|
||||
"unexpected aContextFrame");
|
||||
NS_ASSERTION(style->StyleDisplay() == this, "unexpected aContextFrame");
|
||||
// NOTE: Any CSS properties that influence the output of this function
|
||||
// should have the FIXPOS_CB flag set on them.
|
||||
if (!IsFixedPosContainingBlockForNonSVGTextFrames(*style) &&
|
||||
@ -187,8 +186,7 @@ bool nsStyleDisplay::IsAbsPosContainingBlockForNonSVGTextFrames() const {
|
||||
bool nsStyleDisplay::IsAbsPosContainingBlock(
|
||||
const nsIFrame* aContextFrame) const {
|
||||
mozilla::ComputedStyle* style = aContextFrame->Style();
|
||||
NS_ASSERTION(style->ThreadsafeStyleDisplay() == this,
|
||||
"unexpected aContextFrame");
|
||||
NS_ASSERTION(style->StyleDisplay() == this, "unexpected aContextFrame");
|
||||
// NOTE: Any CSS properties that influence the output of this function
|
||||
// should have the ABSPOS_CB set on them.
|
||||
if (!IsAbsPosContainingBlockForNonSVGTextFrames() &&
|
||||
|
@ -176,8 +176,8 @@ nsresult SVGGeometryFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||
SVGGeometryElement* element =
|
||||
static_cast<SVGGeometryElement*>(GetContent());
|
||||
|
||||
auto oldStyleSVG = aOldComputedStyle->PeekStyleSVG();
|
||||
if (oldStyleSVG && !SVGContentUtils::ShapeTypeHasNoCorners(GetContent())) {
|
||||
auto* oldStyleSVG = aOldComputedStyle->StyleSVG();
|
||||
if (!SVGContentUtils::ShapeTypeHasNoCorners(GetContent())) {
|
||||
if (StyleSVG()->mStrokeLinecap != oldStyleSVG->mStrokeLinecap &&
|
||||
element->IsSVGElement(nsGkAtoms::path)) {
|
||||
// If the stroke-linecap changes to or from "butt" then our element
|
||||
|
@ -4756,9 +4756,7 @@ bool nsTableFrame::BCRecalcNeeded(ComputedStyle* aOldComputedStyle,
|
||||
// and hence possibly completely bogus for GetStyle* purposes.
|
||||
// We use PeekStyleData instead.
|
||||
|
||||
const nsStyleBorder* oldStyleData = aOldComputedStyle->PeekStyleBorder();
|
||||
if (!oldStyleData) return false;
|
||||
|
||||
const nsStyleBorder* oldStyleData = aOldComputedStyle->StyleBorder();
|
||||
const nsStyleBorder* newStyleData = aNewComputedStyle->StyleBorder();
|
||||
nsChangeHint change = newStyleData->CalcDifference(*oldStyleData);
|
||||
if (!change) return false;
|
||||
@ -7698,14 +7696,7 @@ void nsTableFrame::AppendDirectlyOwnedAnonBoxes(
|
||||
// compared to the owner frame.
|
||||
uint32_t equalStructs; // Not used, actually.
|
||||
nsChangeHint wrapperHint =
|
||||
aWrapperFrame->Style()->CalcStyleDifference(newStyle, &equalStructs);
|
||||
|
||||
// CalcStyleDifference will handle caching structs on the new ComputedStyle,
|
||||
// but only if we're not on a style worker thread.
|
||||
MOZ_ASSERT(!ServoStyleSet::IsInServoTraversal(),
|
||||
"if we can get in here from style worker threads, then we need "
|
||||
"a ResolveSameStructsAs call to ensure structs are cached on "
|
||||
"aNewComputedStyle");
|
||||
aWrapperFrame->Style()->CalcStyleDifference(*newStyle, &equalStructs);
|
||||
|
||||
if (wrapperHint) {
|
||||
aRestyleState.ChangeList().AppendChange(
|
||||
|
@ -892,12 +892,8 @@ void nsTextBoxFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nsStyleText* oldTextStyle = aOldComputedStyle->PeekStyleText();
|
||||
// We should really have oldTextStyle here, since we asked for our
|
||||
// nsStyleText during Init(), but if it's not there for some reason
|
||||
// just assume the worst and recompute mTitle.
|
||||
if (!oldTextStyle ||
|
||||
oldTextStyle->mTextTransform != StyleText()->mTextTransform) {
|
||||
const nsStyleText* oldTextStyle = aOldComputedStyle->StyleText();
|
||||
if (oldTextStyle->mTextTransform != StyleText()->mTextTransform) {
|
||||
RecomputeTitle();
|
||||
UpdateAccessTitle();
|
||||
}
|
||||
|
@ -74,6 +74,11 @@ ComputedStyle* nsTreeStyleCache::GetComputedStyle(
|
||||
aPresContext->StyleSet()->ResolveXULTreePseudoStyle(
|
||||
aContent->AsElement(), aPseudoElement, aStyle, aInputWord);
|
||||
|
||||
// Normally we rely on nsFrame::Init / RestyleManager to call this, but
|
||||
// these are weird and don't use a frame, yet ::-moz-tree-twisty definitely
|
||||
// pokes at list-style-image.
|
||||
newResult->StartImageLoads(*aPresContext->Document());
|
||||
|
||||
// Put the ComputedStyle in our table, transferring the owning reference to
|
||||
// the table.
|
||||
if (!mCache) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
<script>
|
||||
assert_not_inherited('counter-increment', 'none', 'foo 123');
|
||||
assert_not_inherited('counter-reset', 'none', 'foo 123');
|
||||
assert_inherited('list-style-image', 'none', 'url("https://example.com/")');
|
||||
assert_inherited('list-style-image', 'none', 'url("data:,a")');
|
||||
assert_inherited('list-style-position', 'outside', 'inside');
|
||||
assert_inherited('list-style-type', 'disc', 'square');
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user