Skip to content

Commit

Permalink
Bug 1253788 - Don't reload inline chrome:// style sheets in nsXBLProt…
Browse files Browse the repository at this point in the history
…otypeResources. r=bzbarsky
  • Loading branch information
heycam committed Mar 26, 2016
1 parent 9ca582d commit 3a4100f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
8 changes: 5 additions & 3 deletions chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,13 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow)
}

// Iterate over our old sheets and kick off a sync load of the new
// sheet if and only if it's a chrome URL.
// sheet if and only if it's a non-inline sheet with a chrome URL.
for (StyleSheetHandle sheet : oldSheets) {
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
MOZ_ASSERT(sheet, "GetStyleSheetAt shouldn't return nullptr for "
"in-range sheet indexes");
nsIURI* uri = sheet->GetSheetURI();

if (uri && IsChromeURI(uri)) {
if (!sheet->IsInline() && IsChromeURI(uri)) {
// Reload the sheet.
StyleSheetHandle::RefPtr newSheet;
// XXX what about chrome sheets that have a title or are disabled? This
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsStyleLinkElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ nsStyleLinkElement::UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
nsCOMPtr<nsIDocument> doc = thisContent->IsInShadowTree() ?
thisContent->OwnerDoc() : thisContent->GetUncomposedDoc();
if (doc && doc->CSSLoader()->GetEnabled() &&
mStyleSheet && mStyleSheet->GetOriginalURI()) {
mStyleSheet && !mStyleSheet->IsInline()) {
doc->CSSLoader()->ObsoleteSheet(mStyleSheet->GetOriginalURI());
}
}
Expand Down
6 changes: 4 additions & 2 deletions dom/xbl/nsXBLPrototypeResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ nsXBLPrototypeResources::FlushSkinSheets()

// We have scoped stylesheets. Reload any chrome stylesheets we
// encounter. (If they aren't skin sheets, it doesn't matter, since
// they'll still be in the chrome cache.
// they'll still be in the chrome cache. Skip inline sheets, which
// skin sheets can't be, and which in any case don't have a usable
// URL to reload.)

nsTArray<StyleSheetHandle::RefPtr> oldSheets;

Expand All @@ -94,7 +96,7 @@ nsXBLPrototypeResources::FlushSkinSheets()
nsIURI* uri = oldSheet->GetSheetURI();

StyleSheetHandle::RefPtr newSheet;
if (IsChromeURI(uri)) {
if (!oldSheet->IsInline() && IsChromeURI(uri)) {
if (NS_FAILED(cssLoader->LoadSheetSync(uri, &newSheet)))
continue;
}
Expand Down
3 changes: 3 additions & 0 deletions layout/style/CSSStyleSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class CSSStyleSheet final : public nsIDOMCSSStyleSheet,
return null */
nsIURI* GetOriginalURI() const { return mInner->mOriginalSheetURI; }

// Whether the sheet is for an inline <style> element.
bool IsInline() const { return mInner->IsInline(); }

// nsICSSLoaderObserver interface
NS_IMETHOD StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
nsresult aStatus) override;
Expand Down
1 change: 1 addition & 0 deletions layout/style/StyleSheetHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class StyleSheetHandle
// CSSStyleSheet or ServoStyleSheet. See corresponding comments in
// CSSStyleSheet.h for descriptions of these methods.

inline bool IsInline() const;
inline nsIURI* GetSheetURI() const;
inline nsIURI* GetOriginalURI() const;
inline nsIURI* GetBaseURI() const;
Expand Down
6 changes: 6 additions & 0 deletions layout/style/StyleSheetHandleInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ StyleSheetHandle::Ptr::Release()
FORWARD(Release, ());
}

bool
StyleSheetHandle::Ptr::IsInline() const
{
FORWARD(IsInline, ());
}

nsIURI*
StyleSheetHandle::Ptr::GetSheetURI() const
{
Expand Down
3 changes: 3 additions & 0 deletions layout/style/StyleSheetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class StyleSheetInfo
nsIURI* GetBaseURI() const { return mBaseURI; }
void SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, nsIURI* aBaseURI);

// Whether the sheet is for an inline <style> element.
bool IsInline() const { return !mOriginalSheetURI; }

nsIPrincipal* Principal() const { return mPrincipal; }
void SetPrincipal(nsIPrincipal* aPrincipal);

Expand Down

0 comments on commit 3a4100f

Please sign in to comment.