зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432490: Make nsComputedDOMStyle::GetStyleContext / GetStyleContextNoFlush not take a presShell. r=bz
Everyone calls them with the shell of the current composed document, and this allows the multi-presShell stuff to just be in UpdateCurrentStyleSources / DoGetStyleContextNoFlush. The only reason we need to use OwnerDoc()->GetShell() instead of the composed doc in GetStyleContext / GetStyleContextNoFlush is Element::GetBindingURL, which does expect to get the binding URL for stuff outside of the composed doc (and changing that gave me a useless browser). That's technically a behavior change on the cases that used to pass nullptr, but I think all callers are fine with that. I could also just add a special function for that particular case, it may be worth it. MozReview-Commit-ID: 2XlnkgdgDCK
This commit is contained in:
Родитель
96fbfba56f
Коммит
7dffe29d8f
|
@ -14,11 +14,11 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
StyleInfo::StyleInfo(dom::Element* aElement, nsIPresShell* aPresShell) :
|
||||
StyleInfo::StyleInfo(dom::Element* aElement) :
|
||||
mElement(aElement)
|
||||
{
|
||||
mStyleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, aPresShell);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace a11y {
|
|||
class StyleInfo
|
||||
{
|
||||
public:
|
||||
StyleInfo(dom::Element* aElement, nsIPresShell* aPresShell);
|
||||
explicit StyleInfo(dom::Element* aElement);
|
||||
~StyleInfo() { }
|
||||
|
||||
void Display(nsAString& aValue);
|
||||
|
|
|
@ -1085,7 +1085,7 @@ Accessible::NativeAttributes()
|
|||
|
||||
// CSS style based object attributes.
|
||||
nsAutoString value;
|
||||
StyleInfo styleInfo(mContent->AsElement(), mDoc->PresShell());
|
||||
StyleInfo styleInfo(mContent->AsElement());
|
||||
|
||||
// Expose 'display' attribute.
|
||||
styleInfo.Display(value);
|
||||
|
|
|
@ -1095,19 +1095,18 @@ KeyframeEffectReadOnly::RequestRestyle(
|
|||
already_AddRefed<nsStyleContext>
|
||||
KeyframeEffectReadOnly::GetTargetStyleContext()
|
||||
{
|
||||
nsIPresShell* shell = GetPresShell();
|
||||
if (!shell) {
|
||||
if (!GetRenderedDocument()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mTarget,
|
||||
"Should only have a presshell when we have a target element");
|
||||
"Should only have a document when we have a target element");
|
||||
|
||||
nsAtom* pseudo = mTarget->mPseudoType < CSSPseudoElementType::Count
|
||||
? nsCSSPseudoElements::GetPseudoAtom(mTarget->mPseudoType)
|
||||
: nullptr;
|
||||
|
||||
return nsComputedDOMStyle::GetStyleContext(mTarget->mElement, pseudo, shell);
|
||||
return nsComputedDOMStyle::GetStyleContext(mTarget->mElement, pseudo);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -536,15 +536,14 @@ Element::GetBindingURL(nsIDocument *aDocument, css::URLValue **aResult)
|
|||
bool isXULorPluginElement = (IsXULElement() ||
|
||||
IsHTMLElement(nsGkAtoms::object) ||
|
||||
IsHTMLElement(nsGkAtoms::embed));
|
||||
nsIPresShell* shell = aDocument->GetShell();
|
||||
if (!shell || GetPrimaryFrame() || !isXULorPluginElement) {
|
||||
if (!aDocument->GetShell() || GetPrimaryFrame() || !isXULorPluginElement) {
|
||||
*aResult = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the computed -moz-binding directly from the style context
|
||||
RefPtr<nsStyleContext> sc =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr, shell);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr);
|
||||
NS_ENSURE_TRUE(sc, false);
|
||||
|
||||
NS_IF_ADDREF(*aResult = sc->StyleDisplay()->mBinding);
|
||||
|
@ -559,14 +558,8 @@ Element::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDocument* doc;
|
||||
if (HasFlag(NODE_FORCE_XBL_BINDINGS)) {
|
||||
doc = OwnerDoc();
|
||||
}
|
||||
else {
|
||||
doc = GetComposedDoc();
|
||||
}
|
||||
|
||||
nsIDocument* doc =
|
||||
HasFlag(NODE_FORCE_XBL_BINDINGS) ? OwnerDoc() : GetComposedDoc();
|
||||
if (!doc) {
|
||||
// There's no baseclass that cares about this call so we just
|
||||
// return here.
|
||||
|
@ -1535,7 +1528,7 @@ Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements)
|
|||
auto IsDisplayGrid = [](Element* aElement) -> bool
|
||||
{
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
|
||||
if (styleContext) {
|
||||
const nsStyleDisplay* display = styleContext->StyleDisplay();
|
||||
return (display->mDisplay == StyleDisplay::Grid ||
|
||||
|
|
|
@ -2727,12 +2727,8 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
|
|||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
RefPtr<nsStyleContext> styleContext;
|
||||
nsIDocument* doc = element->GetComposedDoc();
|
||||
if (doc && doc->GetShell()) {
|
||||
styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(element, nullptr, doc->GetShell());
|
||||
}
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(element, nullptr);
|
||||
*aResult = v1.ComputeDistance(property, v2, styleContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2814,8 +2810,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(nsIDOMElement* aElement,
|
|||
case FLUSH_NONE:
|
||||
break;
|
||||
case FLUSH_STYLE: {
|
||||
nsIDocument* doc = element->GetComposedDoc();
|
||||
if (doc) {
|
||||
if (nsIDocument* doc = element->GetComposedDoc()) {
|
||||
doc->FlushPendingNotifications(FlushType::Style);
|
||||
}
|
||||
break;
|
||||
|
@ -2831,8 +2826,7 @@ nsDOMWindowUtils::GetUnanimatedComputedStyle(nsIDOMElement* aElement,
|
|||
|
||||
RefPtr<nsAtom> pseudo = nsCSSPseudoElements::GetPseudoAtom(aPseudoElement);
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetUnanimatedStyleContextNoFlush(element,
|
||||
pseudo, shell);
|
||||
nsComputedDOMStyle::GetUnanimatedStyleContextNoFlush(element, pseudo);
|
||||
if (!styleContext) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -1852,7 +1852,7 @@ bool
|
|||
nsPlainTextSerializer::IsElementPreformatted(Element* aElement)
|
||||
{
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
if (styleContext) {
|
||||
const nsStyleText* textStyle = styleContext->StyleText();
|
||||
return textStyle->WhiteSpaceOrNewlineIsSignificant();
|
||||
|
@ -1865,7 +1865,7 @@ bool
|
|||
nsPlainTextSerializer::IsElementBlock(Element* aElement)
|
||||
{
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
if (styleContext) {
|
||||
const nsStyleDisplay* displayStyle = styleContext->StyleDisplay();
|
||||
return displayStyle->IsBlockOutsideStyle();
|
||||
|
|
|
@ -3766,7 +3766,7 @@ ElementIsVisibleNoFlush(Element* aElement)
|
|||
return false;
|
||||
}
|
||||
RefPtr<nsStyleContext> sc =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
return sc && sc->StyleVisibility()->IsVisible();
|
||||
}
|
||||
|
||||
|
|
|
@ -721,8 +721,7 @@ nsXHTMLContentSerializer::IsElementPreformatted(nsIContent* aNode)
|
|||
return false;
|
||||
}
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aNode->AsElement(),
|
||||
nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aNode->AsElement(), nullptr);
|
||||
if (styleContext) {
|
||||
const nsStyleText* textStyle = styleContext->StyleText();
|
||||
return textStyle->WhiteSpaceOrNewlineIsSignificant();
|
||||
|
|
|
@ -1201,7 +1201,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
|
|||
// Otherwise, get the value of the color property, flushing style
|
||||
// if necessary.
|
||||
RefPtr<nsStyleContext> canvasStyle =
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr, presShell);
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);
|
||||
if (canvasStyle) {
|
||||
*aColor = canvasStyle->StyleColor()->mColor;
|
||||
}
|
||||
|
@ -1228,9 +1228,8 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
|
|||
RefPtr<nsStyleContext> parentContext;
|
||||
if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
|
||||
// Inherit from the canvas element.
|
||||
parentContext = nsComputedDOMStyle::GetStyleContext(mCanvasElement,
|
||||
nullptr,
|
||||
presShell);
|
||||
parentContext =
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);
|
||||
}
|
||||
|
||||
Unused << nsRuleNode::ComputeColor(
|
||||
|
@ -2003,20 +2002,18 @@ CanvasRenderingContext2D::ClearTarget()
|
|||
|
||||
SetInitialState();
|
||||
|
||||
if (!mCanvasElement || !mCanvasElement->IsInUncomposedDoc()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For vertical writing-mode, unless text-orientation is sideways,
|
||||
// we'll modify the initial value of textBaseline to 'middle'.
|
||||
RefPtr<nsStyleContext> canvasStyle;
|
||||
if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
canvasStyle =
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr, presShell);
|
||||
if (canvasStyle) {
|
||||
WritingMode wm(canvasStyle);
|
||||
if (wm.IsVertical() && !wm.IsSideways()) {
|
||||
CurrentState().textBaseline = TextBaseline::MIDDLE;
|
||||
}
|
||||
}
|
||||
RefPtr<nsStyleContext> canvasStyle =
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);
|
||||
if (canvasStyle) {
|
||||
WritingMode wm(canvasStyle);
|
||||
if (wm.IsVertical() && !wm.IsSideways()) {
|
||||
CurrentState().textBaseline = TextBaseline::MIDDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2738,18 +2735,19 @@ CreateFontDeclaration(const nsAString& aFont,
|
|||
}
|
||||
|
||||
static already_AddRefed<GeckoStyleContext>
|
||||
GetFontParentStyleContext(Element* aElement, nsIPresShell* aPresShell,
|
||||
GetFontParentStyleContext(Element* aElement,
|
||||
nsIPresShell* aPresShell,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (aElement && aElement->IsInUncomposedDoc()) {
|
||||
// Inherit from the canvas element.
|
||||
RefPtr<nsStyleContext> result =
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr, aPresShell);
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
|
||||
if (!result) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
return already_AddRefed<GeckoStyleContext>(result.forget().take()->AsGecko());
|
||||
return GeckoStyleContext::TakeRef(result.forget());
|
||||
}
|
||||
|
||||
// otherwise inherit from default (10px sans-serif)
|
||||
|
@ -2918,17 +2916,11 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont,
|
|||
|
||||
ServoStyleSet* styleSet = aPresShell->StyleSet()->AsServo();
|
||||
|
||||
RefPtr<ServoStyleContext> parentStyle;
|
||||
RefPtr<nsStyleContext> parentStyle;
|
||||
// have to get a parent style context for inherit-like relative
|
||||
// values (2em, bolder, etc.)
|
||||
if (aElement && aElement->IsInUncomposedDoc()) {
|
||||
// Inherit from the canvas element.
|
||||
aPresShell->FlushPendingNotifications(FlushType::Style);
|
||||
// We need to use ResolveStyleLazily, which involves traversal,
|
||||
// instead of ResolvestyleFor() because we need up-to-date style even if
|
||||
// the canvas element is display:none.
|
||||
parentStyle =
|
||||
styleSet->ResolveStyleLazily(aElement, CSSPseudoElementType::NotPseudo);
|
||||
parentStyle = nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
|
||||
} else {
|
||||
RefPtr<RawServoDeclarationBlock> declarations =
|
||||
CreateFontDeclarationForServo(NS_LITERAL_STRING("10px sans-serif"),
|
||||
|
@ -2945,14 +2937,13 @@ GetFontStyleForServo(Element* aElement, const nsAString& aFont,
|
|||
"GetFontParentStyleContext should have returned an error if the presshell is being destroyed.");
|
||||
|
||||
RefPtr<ServoStyleContext> sc =
|
||||
styleSet->ResolveForDeclarations(parentStyle, declarations);
|
||||
styleSet->ResolveForDeclarations(parentStyle->AsServo(), declarations);
|
||||
|
||||
// The font getter is required to be reserialized based on what we
|
||||
// parsed (including having line-height removed). (Older drafts of
|
||||
// the spec required font sizes be converted to pixels, but that no
|
||||
// longer seems to be required.)
|
||||
Servo_SerializeFontValueForCanvas(declarations, &aOutUsedFont);
|
||||
|
||||
return sc.forget();
|
||||
}
|
||||
|
||||
|
@ -4588,7 +4579,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
|||
if (mCanvasElement && mCanvasElement->IsInUncomposedDoc()) {
|
||||
// try to find the closest context
|
||||
canvasStyle =
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr, presShell);
|
||||
nsComputedDOMStyle::GetStyleContext(mCanvasElement, nullptr);
|
||||
if (!canvasStyle) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -2975,6 +2975,11 @@ nsGenericHTMLElement::NewURIFromString(const nsAString& aURISpec,
|
|||
static bool
|
||||
IsOrHasAncestorWithDisplayNone(Element* aElement, nsIPresShell* aPresShell)
|
||||
{
|
||||
// FIXME(emilio): In the servo case it should suffice to do something like:
|
||||
//
|
||||
// return !aElement->HasServoData() || Servo_Element_IsDisplayNone(aElement);
|
||||
//
|
||||
// at least in the case the element is part of the flattened tree...
|
||||
AutoTArray<Element*, 10> elementsToCheck;
|
||||
// Style and layout work on the flattened tree, so this is what we need to
|
||||
// check in order to figure out whether we're in a display: none subtree.
|
||||
|
@ -3005,8 +3010,7 @@ IsOrHasAncestorWithDisplayNone(Element* aElement, nsIPresShell* aPresShell)
|
|||
element, CSSPseudoElementType::NotPseudo);
|
||||
}
|
||||
} else {
|
||||
sc = nsComputedDOMStyle::GetStyleContextNoFlush(element,
|
||||
nullptr, aPresShell);
|
||||
sc = nsComputedDOMStyle::GetStyleContextNoFlush(element, nullptr);
|
||||
}
|
||||
if (sc->StyleDisplay()->mDisplay == StyleDisplay::None) {
|
||||
return true;
|
||||
|
|
|
@ -787,8 +787,7 @@ nsSMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID,
|
|||
}
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(aTargetElement, nullptr,
|
||||
presContext->PresShell());
|
||||
nsComputedDOMStyle::GetStyleContext(aTargetElement, nullptr);
|
||||
if (!styleContext) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ nsSMILCompositor::ComposeAttribute(bool& aMightHavePendingStyleUpdates)
|
|||
if (MightNeedBaseStyle()) {
|
||||
baseStyleContext =
|
||||
nsComputedDOMStyle::GetUnanimatedStyleContextNoFlush(mKey.mElement,
|
||||
nullptr, nullptr);
|
||||
nullptr);
|
||||
}
|
||||
|
||||
// FIRST: Get the nsISMILAttr (to grab base value from, and to eventually
|
||||
|
|
|
@ -180,7 +180,7 @@ SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
|
|||
styleContext = aStyleContext;
|
||||
} else {
|
||||
styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
}
|
||||
|
||||
if (!styleContext) {
|
||||
|
@ -253,7 +253,7 @@ SVGContentUtils::GetStrokeWidth(nsSVGElement* aElement,
|
|||
styleContext = aStyleContext;
|
||||
} else {
|
||||
styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
}
|
||||
|
||||
if (!styleContext) {
|
||||
|
@ -276,7 +276,7 @@ SVGContentUtils::GetFontSize(Element *aElement)
|
|||
return 1.0f;
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
if (!styleContext) {
|
||||
// ReportToConsole
|
||||
NS_WARNING("Couldn't get style context for content in GetFontStyle");
|
||||
|
@ -313,7 +313,7 @@ SVGContentUtils::GetFontXHeight(Element *aElement)
|
|||
return 1.0f;
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
|
||||
if (!styleContext) {
|
||||
// ReportToConsole
|
||||
NS_WARNING("Couldn't get style context for content in GetFontStyle");
|
||||
|
|
|
@ -134,7 +134,7 @@ SVGGeometryElement::GetFillRule()
|
|||
FillRule fillRule = FillRule::FILL_WINDING; // Equivalent to StyleFillRule::Nonzero
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr);
|
||||
|
||||
if (styleContext) {
|
||||
MOZ_ASSERT(styleContext->StyleSVG()->mFillRule == StyleFillRule::Nonzero ||
|
||||
|
|
|
@ -330,7 +330,7 @@ SVGPathElement::BuildPath(PathBuilder* aBuilder)
|
|||
Float strokeWidth = 0;
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr, nullptr);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(this, nullptr);
|
||||
if (styleContext) {
|
||||
const nsStyleSVG* style = styleContext->StyleSVG();
|
||||
// Note: the path that we return may be used for hit-testing, and SVG
|
||||
|
|
|
@ -556,7 +556,7 @@ CSSEditUtils::GetComputedStyle(Element* aElement)
|
|||
{
|
||||
MOZ_ASSERT(aElement);
|
||||
|
||||
nsIDocument* doc = aElement->GetUncomposedDoc();
|
||||
nsIDocument* doc = aElement->GetComposedDoc();
|
||||
NS_ENSURE_TRUE(doc, nullptr);
|
||||
|
||||
nsIPresShell* presShell = doc->GetShell();
|
||||
|
|
|
@ -4254,8 +4254,7 @@ EditorBase::IsPreformatted(nsIDOMNode* aNode,
|
|||
}
|
||||
if (content && content->IsElement()) {
|
||||
elementStyle =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(content->AsElement(),
|
||||
nullptr, ps);
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(content->AsElement(), nullptr);
|
||||
}
|
||||
|
||||
if (!elementStyle) {
|
||||
|
|
|
@ -1023,7 +1023,7 @@ InspectorUtils::GetCleanStyleContextForElement(dom::Element* aElement,
|
|||
presContext->EnsureSafeToHandOutCSSRules();
|
||||
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, aPseudo, presShell);
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, aPseudo);
|
||||
return styleContext.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -5541,14 +5541,10 @@ AnimationValue::FromString(nsCSSPropertyID aProperty,
|
|||
// GetStyleContext() flushes style, so we shouldn't assume that any
|
||||
// non-owning references we have are still valid.
|
||||
RefPtr<nsStyleContext> styleContext =
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr, shell);
|
||||
|
||||
if (auto servoContext = styleContext->GetAsServo()) {
|
||||
nsPresContext* presContext = shell->GetPresContext();
|
||||
if (!presContext) {
|
||||
return result;
|
||||
}
|
||||
nsComputedDOMStyle::GetStyleContext(aElement, nullptr);
|
||||
MOZ_ASSERT(styleContext);
|
||||
|
||||
if (auto* servoContext = styleContext->GetAsServo()) {
|
||||
RefPtr<RawServoDeclarationBlock> declarations =
|
||||
ServoCSSParser::ParseProperty(aProperty, aValue,
|
||||
ServoCSSParser::GetParsingEnvironment(doc));
|
||||
|
@ -5557,11 +5553,10 @@ AnimationValue::FromString(nsCSSPropertyID aProperty,
|
|||
return result;
|
||||
}
|
||||
|
||||
result.mServo = presContext->StyleSet()
|
||||
->AsServo()
|
||||
->ComputeAnimationValue(aElement,
|
||||
declarations,
|
||||
servoContext);
|
||||
result.mServo =
|
||||
shell->StyleSet()->AsServo()->ComputeAnimationValue(aElement,
|
||||
declarations,
|
||||
servoContext);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -378,12 +378,11 @@ nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
|
|||
, mAnimationFlag(aFlag)
|
||||
{
|
||||
MOZ_ASSERT(aElement && aPresShell);
|
||||
MOZ_ASSERT(aPresShell->GetPresContext());
|
||||
|
||||
mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
|
||||
mContent = aElement;
|
||||
mPseudo = nsCSSPseudoElements::GetPseudoAtom(aPseudoElt);
|
||||
|
||||
MOZ_ASSERT(aPresShell->GetPresContext());
|
||||
}
|
||||
|
||||
nsComputedDOMStyle::~nsComputedDOMStyle()
|
||||
|
@ -518,25 +517,12 @@ nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
|
|||
already_AddRefed<nsStyleContext>
|
||||
nsComputedDOMStyle::GetStyleContext(Element* aElement,
|
||||
nsAtom* aPseudo,
|
||||
nsIPresShell* aPresShell,
|
||||
StyleType aStyleType)
|
||||
{
|
||||
// If the content has a pres shell, we must use it. Otherwise we'd
|
||||
// potentially mix rule trees by using the wrong pres shell's style
|
||||
// set. Using the pres shell from the content also means that any
|
||||
// content that's actually *in* a document will get the style from the
|
||||
// correct document.
|
||||
nsCOMPtr<nsIPresShell> presShell =
|
||||
nsContentUtils::GetPresShellForContent(aElement);
|
||||
if (!presShell) {
|
||||
presShell = aPresShell;
|
||||
if (!presShell)
|
||||
return nullptr;
|
||||
if (nsIDocument* doc = aElement->GetComposedDoc()) {
|
||||
doc->FlushPendingNotifications(FlushType::Style);
|
||||
}
|
||||
|
||||
presShell->FlushPendingNotifications(FlushType::Style);
|
||||
|
||||
return GetStyleContextNoFlush(aElement, aPseudo, presShell, aStyleType);
|
||||
return GetStyleContextNoFlush(aElement, aPseudo, aStyleType);
|
||||
}
|
||||
|
||||
#ifdef MOZ_OLD_STYLE
|
||||
|
@ -834,8 +820,8 @@ nsComputedDOMStyle::DoGetStyleContextNoFlush(Element* aElement,
|
|||
// Don't resolve parent context for document fragments.
|
||||
if (parent && parent->IsElement()) {
|
||||
RefPtr<nsStyleContext> p =
|
||||
GetStyleContextNoFlush(parent->AsElement(), nullptr,
|
||||
aPresShell, aStyleType);
|
||||
DoGetStyleContextNoFlush(parent->AsElement(), nullptr,
|
||||
aPresShell, aStyleType, eWithAnimation);
|
||||
MOZ_ASSERT(p && p->IsGecko());
|
||||
parentContext = GeckoStyleContext::TakeRef(p.forget());
|
||||
}
|
||||
|
@ -978,6 +964,11 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO(emilio): We may want to handle a few special-cases here:
|
||||
//
|
||||
// * https://github.com/w3c/csswg-drafts/issues/1964
|
||||
// * https://github.com/w3c/csswg-drafts/issues/1548
|
||||
|
||||
// If the property we are computing relies on layout, then we must flush.
|
||||
FlushTarget target = aNeedsLayoutFlush ? FlushTarget::Normal : GetFlushTarget(document);
|
||||
|
||||
|
@ -1097,11 +1088,12 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
|
|||
#endif
|
||||
// Need to resolve a style context
|
||||
RefPtr<nsStyleContext> resolvedStyleContext =
|
||||
nsComputedDOMStyle::GetStyleContextNoFlush(
|
||||
DoGetStyleContextNoFlush(
|
||||
mContent->AsElement(),
|
||||
mPseudo,
|
||||
presShellForContent ? presShellForContent.get() : mPresShell,
|
||||
mStyleType);
|
||||
mStyleType,
|
||||
eWithAnimation);
|
||||
if (!resolvedStyleContext) {
|
||||
ClearStyleContext();
|
||||
return;
|
||||
|
@ -1111,9 +1103,8 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
|
|||
// will flush, since we flushed style at the top of this function.
|
||||
// We don't need to check this if we only flushed the parent.
|
||||
NS_ASSERTION(target == FlushTarget::ParentOnly ||
|
||||
(mPresShell &&
|
||||
currentGeneration ==
|
||||
mPresShell->GetPresContext()->GetUndisplayedRestyleGeneration()),
|
||||
currentGeneration ==
|
||||
mPresShell->GetPresContext()->GetUndisplayedRestyleGeneration(),
|
||||
"why should we have flushed style again?");
|
||||
|
||||
SetResolvedStyleContext(Move(resolvedStyleContext), currentGeneration);
|
||||
|
|
|
@ -98,18 +98,16 @@ public:
|
|||
|
||||
static already_AddRefed<nsStyleContext>
|
||||
GetStyleContext(mozilla::dom::Element* aElement, nsAtom* aPseudo,
|
||||
nsIPresShell* aPresShell,
|
||||
StyleType aStyleType = eAll);
|
||||
|
||||
static already_AddRefed<nsStyleContext>
|
||||
GetStyleContextNoFlush(mozilla::dom::Element* aElement,
|
||||
nsAtom* aPseudo,
|
||||
nsIPresShell* aPresShell,
|
||||
StyleType aStyleType = eAll)
|
||||
{
|
||||
return DoGetStyleContextNoFlush(aElement,
|
||||
aPseudo,
|
||||
aPresShell,
|
||||
aElement->OwnerDoc()->GetShell(),
|
||||
aStyleType,
|
||||
eWithAnimation);
|
||||
}
|
||||
|
@ -117,12 +115,11 @@ public:
|
|||
static already_AddRefed<nsStyleContext>
|
||||
GetUnanimatedStyleContextNoFlush(mozilla::dom::Element* aElement,
|
||||
nsAtom* aPseudo,
|
||||
nsIPresShell* aPresShell,
|
||||
StyleType aStyleType = eAll)
|
||||
{
|
||||
return DoGetStyleContextNoFlush(aElement,
|
||||
aPseudo,
|
||||
aPresShell,
|
||||
aElement->OwnerDoc()->GetShell(),
|
||||
aStyleType,
|
||||
eWithoutAnimation);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче