Bug 1408235 part 2 - Parse XUL style attribute into stylo declaration block when the document should use stylo. r?heycam
MozReview-Commit-ID: H7l6M5hq04a
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -91,16 +91,17 @@
#include "nsIFrame.h"
#include "nsNodeInfoManager.h"
#include "nsXBLBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozAutoDocUpdate.h"
#include "nsIDOMXULCommandEvent.h"
#include "nsCCUncollectableMarker.h"
#include "nsICSSDeclaration.h"
+#include "nsLayoutUtils.h"
#include "mozilla/dom/XULElementBinding.h"
#include "mozilla/dom/BoxObject.h"
#include "mozilla/dom/HTMLIFrameElement.h"
using namespace mozilla;
using namespace mozilla::dom;
@@ -2326,28 +2327,36 @@ nsXULPrototypeElement::SetAttrAt(uint32_
// Compute the element's class list
mAttributes[aPos].mValue.ParseAtomArray(aValue);
return NS_OK;
} else if (mAttributes[aPos].mName.Equals(nsGkAtoms::style)) {
mHasStyleAttribute = true;
// Parse the element's 'style' attribute
- nsCSSParser parser;
-
+ // This is basically duplicating what nsINode::NodePrincipal() does
+ nsIPrincipal* principal =
+ mNodeInfo->NodeInfoManager()->DocumentPrincipal();
// XXX Get correct Base URI (need GetBaseURI on *prototype* element)
// TODO: If we implement Content Security Policy for chrome documents
// as has been discussed, the CSP should be checked here to see if
// inline styles are allowed to be applied.
- RefPtr<css::Declaration> declaration =
- parser.ParseStyleAttribute(aValue, aDocumentURI, aDocumentURI,
- // This is basically duplicating what
- // nsINode::NodePrincipal() does
- mNodeInfo->NodeInfoManager()->
- DocumentPrincipal());
+
+ RefPtr<DeclarationBlock> declaration;
+ if (nsLayoutUtils::StyloEnabled() &&
+ nsLayoutUtils::ShouldUseStylo(aDocumentURI, principal)) {
+ RefPtr<URLExtraData> data =
+ new URLExtraData(aDocumentURI, aDocumentURI, principal);
+ declaration = ServoDeclarationBlock::FromCssText(
+ aValue, data, eCompatibility_FullStandards, nullptr);
+ } else {
+ nsCSSParser parser;
+ declaration = parser.ParseStyleAttribute(aValue, aDocumentURI,
+ aDocumentURI, principal);
+ }
if (declaration) {
mAttributes[aPos].mValue.SetTo(declaration.forget(), &aValue);
return NS_OK;
}
// Don't abort if parsing failed, it could just be malformed css.
}