Bug 1345343 - Add a pref to turn off effect of xml:base on style attribute. r=bz

MozReview-Commit-ID: EzNLxIW0OCv

--HG--
extra : rebase_source : 7c6d1278ed47d35b109bbe3e6305032b7f125fa4
This commit is contained in:
Xidorn Quan 2017-03-10 18:04:34 +11:00
Родитель aaf9f3b7ae
Коммит 6eb58892f8
7 изменённых файлов: 33 добавлений и 2 удалений

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

@ -414,6 +414,23 @@ nsIContent::GetBaseURI(bool aTryUseXHRDocBaseURI) const
return base.forget();
}
already_AddRefed<nsIURI>
nsIContent::GetBaseURIForStyleAttr() const
{
if (!nsLayoutUtils::StyleAttrWithXMLBaseDisabled()) {
return GetBaseURI();
}
if (IsInAnonymousSubtree() && IsAnonymousContentInSVGUseSubtree()) {
nsIContent* bindingParent = GetBindingParent();
MOZ_ASSERT(bindingParent);
SVGUseElement* useElement = static_cast<SVGUseElement*>(bindingParent);
return do_AddRef(useElement->GetContentBaseURI());
}
// This also ignores the case that SVG inside XBL binding.
// But it is probably fine.
return do_AddRef(OwnerDoc()->GetDocBaseURI());
}
//----------------------------------------------------------------------
static inline JSObject*

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

@ -1702,7 +1702,7 @@ nsAttrValue::ParseStyleAttribute(const nsAString& aString,
{
nsIDocument* ownerDoc = aElement->OwnerDoc();
nsHTMLCSSStyleSheet* sheet = ownerDoc->GetInlineStyleSheet();
nsCOMPtr<nsIURI> baseURI = aElement->GetBaseURI();
nsCOMPtr<nsIURI> baseURI = aElement->GetBaseURIForStyleAttr();
nsIURI* docURI = ownerDoc->GetDocumentURI();
NS_ASSERTION(aElement->NodePrincipal() == ownerDoc->NodePrincipal(),

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

@ -970,6 +970,9 @@ public:
// Overloaded from nsINode
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
// Returns base URI for style attribute.
already_AddRefed<nsIURI> GetBaseURIForStyleAttr() const;
virtual nsresult GetEventTargetParent(
mozilla::EventChainPreVisitor& aVisitor) override;

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

@ -186,6 +186,7 @@ typedef nsStyleTransformMatrix::TransformReferenceBox TransformReferenceBox;
#ifdef MOZ_STYLO
/* static */ bool nsLayoutUtils::sStyloEnabled;
#endif
/* static */ bool nsLayoutUtils::sStyleAttrWithXMLBaseDisabled;
/* static */ uint32_t nsLayoutUtils::sIdlePeriodDeadlineLimit;
/* static */ uint32_t nsLayoutUtils::sQuiescentFramesBeforeIdlePeriod;
@ -7667,6 +7668,8 @@ nsLayoutUtils::Initialize()
Preferences::AddBoolVarCache(&sStyloEnabled,
"layout.css.servo.enabled");
#endif
Preferences::AddBoolVarCache(&sStyleAttrWithXMLBaseDisabled,
"layout.css.style-attr-with-xml-base.disabled");
Preferences::AddUintVarCache(&sIdlePeriodDeadlineLimit,
"layout.idle_period.time_limit",
DEFAULT_IDLE_PERIOD_TIME_LIMIT);

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

@ -2447,6 +2447,10 @@ public:
#endif
}
static bool StyleAttrWithXMLBaseDisabled() {
return sStyleAttrWithXMLBaseDisabled;
}
static uint32_t IdlePeriodDeadlineLimit() {
return sIdlePeriodDeadlineLimit;
}
@ -2919,6 +2923,7 @@ private:
#ifdef MOZ_STYLO
static bool sStyloEnabled;
#endif
static bool sStyleAttrWithXMLBaseDisabled;
static uint32_t sIdlePeriodDeadlineLimit;
static uint32_t sQuiescentFramesBeforeIdlePeriod;

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

@ -168,7 +168,7 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(CSSParsingEnvironment& aC
nsIDocument* doc = mElement->OwnerDoc();
aCSSParseEnv.mSheetURI = doc->GetDocumentURI();
aCSSParseEnv.mBaseURI = mElement->GetBaseURI();
aCSSParseEnv.mBaseURI = mElement->GetBaseURIForStyleAttr();
aCSSParseEnv.mPrincipal = mElement->NodePrincipal();
aCSSParseEnv.mCSSLoader = doc->CSSLoader();
}

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

@ -2679,6 +2679,9 @@ pref("layout.css.control-characters.visible", true);
// Is support for column-span enabled?
pref("layout.css.column-span.enabled", false);
// Is effect of xml:base disabled for style attribute?
pref("layout.css.style-attr-with-xml-base.disabled", false);
// pref for which side vertical scrollbars should be on
// 0 = end-side in UI direction
// 1 = end-side in document/content direction