summaryrefslogtreecommitdiffstats
path: root/layout
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-08-30 09:29:45 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-30 09:29:45 +0000
commita4780ebaeb123ce9c793b85bb38a1701fad8f7ac (patch)
tree6354d39f9cda4637b084c265befd88e895e74aa8 /layout
parentc384fa6e25b07b37e9cc406da0c0aef583c61513 (diff)
downloadUXP-a4780ebaeb123ce9c793b85bb38a1701fad8f7ac.tar
UXP-a4780ebaeb123ce9c793b85bb38a1701fad8f7ac.tar.gz
UXP-a4780ebaeb123ce9c793b85bb38a1701fad8f7ac.tar.lz
UXP-a4780ebaeb123ce9c793b85bb38a1701fad8f7ac.tar.xz
UXP-a4780ebaeb123ce9c793b85bb38a1701fad8f7ac.zip
Issue #1629 - Uplift implementation of <link disabled> behavior for stylesheets.
Diffstat (limited to 'layout')
-rw-r--r--layout/style/Loader.cpp28
-rw-r--r--layout/style/Loader.h13
2 files changed, 28 insertions, 13 deletions
diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp
index 0ce337e29..df523174d 100644
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1277,7 +1277,8 @@ Loader::PrepareSheet(StyleSheet* aSheet,
const nsSubstring& aMediaString,
nsMediaList* aMediaList,
Element* aScopeElement,
- bool isAlternate)
+ bool isAlternate,
+ bool isExplicitlyEnabled)
{
NS_PRECONDITION(aSheet, "Must have a sheet!");
@@ -1306,7 +1307,7 @@ Loader::PrepareSheet(StyleSheet* aSheet,
sheet->SetMedia(mediaList);
sheet->SetTitle(aTitle);
- sheet->SetEnabled(!isAlternate);
+ sheet->SetEnabled(!isAlternate || isExplicitlyEnabled);
sheet->SetScopeElement(aScopeElement);
}
@@ -1984,7 +1985,8 @@ Loader::LoadInlineStyle(nsIContent* aElement,
Element* aScopeElement,
nsICSSLoaderObserver* aObserver,
bool* aCompleted,
- bool* aIsAlternate)
+ bool* aIsAlternate,
+ bool* aIsExplicitlyEnabled)
{
LOG(("css::Loader::LoadInlineStyle"));
NS_ASSERTION(mParsingDatas.Length() == 0, "We're in the middle of a parse?");
@@ -2016,8 +2018,9 @@ Loader::LoadInlineStyle(nsIContent* aElement,
"Inline sheets should not be cached");
LOG((" Sheet is alternate: %d", *aIsAlternate));
+ LOG((" Sheet is explicitly enabled: %d", *aIsExplicitlyEnabled));
- PrepareSheet(sheet, aTitle, aMedia, nullptr, aScopeElement, *aIsAlternate);
+ PrepareSheet(sheet, aTitle, aMedia, nullptr, aScopeElement, *aIsAlternate, *aIsExplicitlyEnabled);
if (aElement->HasFlag(NODE_IS_IN_SHADOW_TREE)) {
ShadowRoot* containingShadow = aElement->GetContainingShadow();
@@ -2058,7 +2061,8 @@ Loader::LoadStyleLink(nsIContent* aElement,
ReferrerPolicy aReferrerPolicy,
const nsAString& aIntegrity,
nsICSSLoaderObserver* aObserver,
- bool* aIsAlternate)
+ bool* aIsAlternate,
+ bool* aIsExplicitlyEnabled)
{
LOG(("css::Loader::LoadStyleLink"));
NS_PRECONDITION(aURL, "Must have URL to load");
@@ -2111,8 +2115,9 @@ Loader::LoadStyleLink(nsIContent* aElement,
NS_ENSURE_SUCCESS(rv, rv);
LOG((" Sheet is alternate: %d", *aIsAlternate));
+ LOG((" Sheet is explicitly enabled: %d", *aIsExplicitlyEnabled));
- PrepareSheet(sheet, aTitle, aMedia, nullptr, nullptr, *aIsAlternate);
+ PrepareSheet(sheet, aTitle, aMedia, nullptr, nullptr, *aIsAlternate, *aIsExplicitlyEnabled);
rv = InsertSheetInDoc(sheet, aElement, mDocument);
NS_ENSURE_SUCCESS(rv, rv);
@@ -2137,9 +2142,10 @@ Loader::LoadStyleLink(nsIContent* aElement,
aObserver, principal, requestingNode);
NS_ADDREF(data);
- // If we have to parse and it's an alternate non-inline, defer it
+ // If we have to parse and it's an alternate non-inline, defer it unless
+ // it's explicitly enabled.
if (aURL && state == eSheetNeedsParser && mSheets->mLoadingDatas.Count() != 0 &&
- *aIsAlternate) {
+ *aIsAlternate && !*aIsExplicitlyEnabled) {
LOG((" Deferring alternate sheet load"));
URIPrincipalReferrerPolicyAndCORSModeHashKey key(data->mURI,
data->mLoaderPrincipal,
@@ -2266,6 +2272,7 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet,
state = eSheetComplete;
} else {
bool isAlternate;
+ bool isExplicitlyEnabled;
const nsSubstring& empty = EmptyString();
// For now, use CORS_NONE for child sheets
rv = CreateSheet(aURL, nullptr, principal,
@@ -2276,7 +2283,7 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet,
false, empty, state, &isAlternate, &sheet);
NS_ENSURE_SUCCESS(rv, rv);
- PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate);
+ PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate, isExplicitlyEnabled);
}
rv = InsertChildSheet(sheet, aParentSheet, aParentRule);
@@ -2389,6 +2396,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
StyleSheetState state;
bool isAlternate;
+ bool isExplicitlyEnabled;
RefPtr<StyleSheet> sheet;
bool syncLoad = (aObserver == nullptr);
const nsSubstring& empty = EmptyString();
@@ -2398,7 +2406,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
false, empty, state, &isAlternate, &sheet);
NS_ENSURE_SUCCESS(rv, rv);
- PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate);
+ PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate, isExplicitlyEnabled);
if (state == eSheetComplete) {
LOG((" Sheet already complete"));
diff --git a/layout/style/Loader.h b/layout/style/Loader.h
index 209783a80..4a3088b6b 100644
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -230,6 +230,8 @@ public:
* @param [out] aCompleted whether parsing of the sheet completed.
* @param [out] aIsAlternate whether the stylesheet ended up being an
* alternate sheet.
+ * @param [out] aIsExplicitlyEnabled whether the stylesheet was explicitly
+ * enabled by having the disabled attribute removed.
*/
nsresult LoadInlineStyle(nsIContent* aElement,
const nsAString& aBuffer,
@@ -239,7 +241,8 @@ public:
mozilla::dom::Element* aScopeElement,
nsICSSLoaderObserver* aObserver,
bool* aCompleted,
- bool* aIsAlternate);
+ bool* aIsAlternate,
+ bool* aIsExplicitlyEnabled);
/**
* Load a linked (document) stylesheet. If a successful result is returned,
@@ -260,6 +263,8 @@ public:
* @param [out] aIsAlternate whether the stylesheet actually ended up beinga
* an alternate sheet. Note that this need not match
* aHasAlternateRel.
+ * @param [out] aIsExplicitlyEnabled whether the stylesheet was explicitly
+ * enabled by having the disabled attribute removed.
*/
nsresult LoadStyleLink(nsIContent* aElement,
nsIURI* aURL,
@@ -270,7 +275,8 @@ public:
ReferrerPolicy aReferrerPolicy,
const nsAString& aIntegrity,
nsICSSLoaderObserver* aObserver,
- bool* aIsAlternate);
+ bool* aIsAlternate,
+ bool* aIsExplicitlyEnabled);
/**
* Load a child (@import-ed) style sheet. In addition to loading the sheet,
@@ -476,7 +482,8 @@ private:
const nsAString& aMediaString,
nsMediaList* aMediaList,
dom::Element* aScopeElement,
- bool isAlternate);
+ bool isAlternate,
+ bool isExplicitlyEnabled);
nsresult InsertSheetInDoc(StyleSheet* aSheet,
nsIContent* aLinkingContent,