Bug 1087801. Don't assume the global is a Window in the DOM CSS object. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 29 Oct 2014 17:00:48 -0400
changeset 213020 51aa419a7b82409bce864bddecacff4717ae27e7
parent 213019 2a12da881f9250ee446d699eb9d6405bdc133284
child 213021 8509aaff4c6a86e1f09a80d89c4a9ebfac66cecb
push id27738
push usercbook@mozilla.com
push dateThu, 30 Oct 2014 13:46:07 +0000
treeherdermozilla-central@1aa1b23d799e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1087801
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1087801. Don't assume the global is a Window in the DOM CSS object. r=bholley
layout/style/CSS.cpp
--- a/layout/style/CSS.cpp
+++ b/layout/style/CSS.cpp
@@ -8,36 +8,37 @@
 #include "CSS.h"
 
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsCSSParser.h"
 #include "nsGlobalWindow.h"
 #include "nsIDocument.h"
 #include "nsIURI.h"
 #include "nsStyleUtil.h"
+#include "xpcpublic.h"
 
 namespace mozilla {
 namespace dom {
 
 struct SupportsParsingInfo
 {
   nsIURI* mDocURI;
   nsIURI* mBaseURI;
   nsIPrincipal* mPrincipal;
 };
 
 static nsresult
-GetParsingInfo(nsISupports* aGlobal,
+GetParsingInfo(const GlobalObject& aGlobal,
                SupportsParsingInfo& aInfo)
 {
-  if (!aGlobal) {
+  nsGlobalWindow* win = xpc::WindowOrNull(aGlobal.Get());
+  if (!win) {
     return NS_ERROR_FAILURE;
   }
 
-  nsGlobalWindow* win = nsGlobalWindow::FromSupports(aGlobal);
   nsCOMPtr<nsIDocument> doc = win->GetDoc();
   if (!doc) {
     return NS_ERROR_FAILURE;
   }
 
   aInfo.mDocURI = nsCOMPtr<nsIURI>(doc->GetDocumentURI());
   aInfo.mBaseURI = nsCOMPtr<nsIURI>(doc->GetBaseURI());
   aInfo.mPrincipal = win->GetPrincipal();
@@ -48,17 +49,17 @@ GetParsingInfo(nsISupports* aGlobal,
 CSS::Supports(const GlobalObject& aGlobal,
               const nsAString& aProperty,
               const nsAString& aValue,
               ErrorResult& aRv)
 {
   nsCSSParser parser;
   SupportsParsingInfo info;
 
-  nsresult rv = GetParsingInfo(aGlobal.GetAsSupports(), info);
+  nsresult rv = GetParsingInfo(aGlobal, info);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return false;
   }
 
   return parser.EvaluateSupportsDeclaration(aProperty, aValue, info.mDocURI,
                                             info.mBaseURI, info.mPrincipal);
 }
@@ -66,17 +67,17 @@ CSS::Supports(const GlobalObject& aGloba
 /* static */ bool
 CSS::Supports(const GlobalObject& aGlobal,
               const nsAString& aCondition,
               ErrorResult& aRv)
 {
   nsCSSParser parser;
   SupportsParsingInfo info;
 
-  nsresult rv = GetParsingInfo(aGlobal.GetAsSupports(), info);
+  nsresult rv = GetParsingInfo(aGlobal, info);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return false;
   }
 
   return parser.EvaluateSupportsCondition(aCondition, info.mDocURI,
                                           info.mBaseURI, info.mPrincipal);
 }