From 1ef2a5628a07d3e53309657704379cf8ae110262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 11 Sep 2020 19:26:40 +0000 Subject: [PATCH] Bug 1664432 - Remove -moz-user-disabled. r=edgar We treat it exactly the same as -moz-broken. The pseudo-class is not exposed to content, so I don't think we have a reason to keep it around. Differential Revision: https://phabricator.services.mozilla.com/D89904 --- dom/base/nsIObjectLoadingContent.idl | 2 -- dom/base/nsImageLoadingContent.cpp | 8 ++------ dom/base/nsImageLoadingContent.h | 8 ++++---- dom/base/nsObjectLoadingContent.cpp | 4 +--- dom/base/nsObjectLoadingContent.h | 2 -- dom/base/test/test_blocking_image.html | 10 +++------- dom/events/EventStates.h | 5 +++-- dom/webidl/HTMLObjectElement.webidl | 3 --- layout/base/RestyleManager.cpp | 3 +-- layout/base/nsCSSFrameConstructor.cpp | 1 - layout/generic/nsImageFrame.cpp | 12 +++++------- layout/style/res/html.css | 6 +++--- .../test/test_non_content_accessible_pseudos.html | 1 - layout/style/test/test_selectors.html | 1 - servo/components/style/element_state.rs | 2 -- .../style/gecko/non_ts_pseudo_class_list.rs | 2 -- servo/components/style/gecko/wrapper.rs | 1 - .../url-classifier/tests/browser/classifierTester.js | 2 +- 18 files changed, 23 insertions(+), 50 deletions(-) diff --git a/dom/base/nsIObjectLoadingContent.idl b/dom/base/nsIObjectLoadingContent.idl index a25728948790..a3b95dfeb06f 100644 --- a/dom/base/nsIObjectLoadingContent.idl +++ b/dom/base/nsIObjectLoadingContent.idl @@ -55,8 +55,6 @@ interface nsIObjectLoadingContent : nsISupports const unsigned long PLUGIN_CRASHED = 5; // Suppressed by security policy const unsigned long PLUGIN_SUPPRESSED = 6; - // Blocked by content policy - const unsigned long PLUGIN_USER_DISABLED = 7; /// ** All values >= PLUGIN_CLICK_TO_PLAY are plugin placeholder types that /// would be replaced by a real plugin if activated (playPlugin()) /// ** Furthermore, values >= PLUGIN_CLICK_TO_PLAY and diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index e8b296ff87fc..55f482d56a68 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -102,7 +102,6 @@ nsImageLoadingContent::nsImageLoadingContent() mLoading(false), // mBroken starts out true, since an image without a URI is broken.... mBroken(true), - mUserDisabled(false), mSuppressed(false), mNewRequestsWillNeedAnimationReset(false), mUseUrgentStartForChannel(false), @@ -1279,9 +1278,6 @@ EventStates nsImageLoadingContent::ImageState() const { if (mBroken) { states |= NS_EVENT_STATE_BROKEN; } - if (mUserDisabled) { - states |= NS_EVENT_STATE_USERDISABLED; - } if (mSuppressed) { states |= NS_EVENT_STATE_SUPPRESSED; } @@ -1305,7 +1301,7 @@ void nsImageLoadingContent::UpdateImageState(bool aNotify) { nsIContent* thisContent = AsContent(); - mLoading = mBroken = mUserDisabled = mSuppressed = false; + mLoading = mBroken = mSuppressed = false; // If we were blocked by server-based content policy, we claim to be // suppressed. If we were blocked by type-based content policy, we claim to @@ -1313,7 +1309,7 @@ void nsImageLoadingContent::UpdateImageState(bool aNotify) { if (mImageBlockingStatus == nsIContentPolicy::REJECT_SERVER) { mSuppressed = true; } else if (mImageBlockingStatus == nsIContentPolicy::REJECT_TYPE) { - mUserDisabled = true; + mBroken = true; } else if (!mCurrentRequest) { if (!mLazyLoading) { // In case of non-lazy loading, no current request means error, since we diff --git a/dom/base/nsImageLoadingContent.h b/dom/base/nsImageLoadingContent.h index 70aecfb5fe6c..e98000e19212 100644 --- a/dom/base/nsImageLoadingContent.h +++ b/dom/base/nsImageLoadingContent.h @@ -120,9 +120,10 @@ class nsImageLoadingContent : public nsIImageLoadingContent { /** * ImageState is called by subclasses that are computing their content state. - * The return value will have the NS_EVENT_STATE_BROKEN, - * NS_EVENT_STATE_USERDISABLED, and NS_EVENT_STATE_SUPPRESSED bits set as - * needed. Note that this state assumes that this node is "trying" to be an + * The return value will have the NS_EVENT_STATE_BROKEN, and + * NS_EVENT_STATE_SUPPRESSED bits set as needed. + * + * Note that this state assumes that this node is "trying" to be an * image (so for example complete lack of attempt to load an image will lead * to NS_EVENT_STATE_BROKEN being set). Subclasses that are not "trying" to * be an image (eg an HTML of type other than "image") should just @@ -575,7 +576,6 @@ class nsImageLoadingContent : public nsIImageLoadingContent { */ bool mLoading : 1; bool mBroken : 1; - bool mUserDisabled : 1; bool mSuppressed : 1; protected: diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 86d5c0a23db9..5105ae539198 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -1276,8 +1276,6 @@ EventStates nsObjectLoadingContent::ObjectState() const { switch (mFallbackType) { case eFallbackSuppressed: return NS_EVENT_STATE_SUPPRESSED; - case eFallbackUserDisabled: - return NS_EVENT_STATE_USERDISABLED; case eFallbackClickToPlay: case eFallbackClickToPlayQuiet: return NS_EVENT_STATE_TYPE_CLICK_TO_PLAY; @@ -2047,7 +2045,7 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad, LOG(("OBJLC [%p]: Load denied by policy", this)); mType = eType_Null; if (contentPolicy == nsIContentPolicy::REJECT_TYPE) { - fallbackType = eFallbackUserDisabled; + fallbackType = eFallbackDisabled; } else { fallbackType = eFallbackSuppressed; } diff --git a/dom/base/nsObjectLoadingContent.h b/dom/base/nsObjectLoadingContent.h index e36924587c19..4d9dc7ac9640 100644 --- a/dom/base/nsObjectLoadingContent.h +++ b/dom/base/nsObjectLoadingContent.h @@ -91,8 +91,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent, eFallbackCrashed = nsIObjectLoadingContent::PLUGIN_CRASHED, // Suppressed by security policy eFallbackSuppressed = nsIObjectLoadingContent::PLUGIN_SUPPRESSED, - // Blocked by content policy - eFallbackUserDisabled = nsIObjectLoadingContent::PLUGIN_USER_DISABLED, /// ** All values >= eFallbackClickToPlay are plugin placeholder types /// that would be replaced by a real plugin if activated (PlayPlugin()) /// ** Furthermore, values >= eFallbackClickToPlay and diff --git a/dom/base/test/test_blocking_image.html b/dom/base/test/test_blocking_image.html index aef45b851c02..54c11ca622bc 100644 --- a/dom/base/test/test_blocking_image.html +++ b/dom/base/test/test_blocking_image.html @@ -28,9 +28,7 @@ function onLoad() { img:-moz-broken { color: red } - img:-moz-user-disabled { - color: blue - }`; + `; var sheetURL = "data:text/css," + encodeURIComponent(css); winUtils.loadSheetUsingURIString(sheetURL, winUtils.AGENT_SHEET); @@ -82,16 +80,14 @@ function onLoad() { }); }).then(() => { // Now image is denied, loading image will be rejected with REJECT_TYPE, - // which will be mapped to :-moz-user-disabled + // which will be mapped to :-moz-broken too. img3.src = "https://example.com/tests/image/test/mochitest/shaver.png"; doc.body.appendChild(img3); return imgListener(img3); }).then(() => { ok(true, "img3 shouldn't be loaded"); - // -moz-user-disabled is also chrome only, so we didn't use matches() to verify. - is(iframe.contentWindow.getComputedStyle(img3).color, "rgb(0, 0, 255)", - "color of img3 should be blue"); + ok(img3.matches(":-moz-broken"), "should match ':-moz-broken' selector"); is(img3.imageBlockingStatus, Ci.nsIContentPolicy.REJECT_TYPE, "imageBlockingStatues should be REJECT_TYPE."); diff --git a/dom/events/EventStates.h b/dom/events/EventStates.h index 5c0e121b58b8..149ce8f1f2f2 100644 --- a/dom/events/EventStates.h +++ b/dom/events/EventStates.h @@ -199,8 +199,9 @@ class EventStates { #define NS_EVENT_STATE_MOZ_UI_INVALID NS_DEFINE_EVENT_STATE_MACRO(13) // Content could not be rendered (image/object/etc). #define NS_EVENT_STATE_BROKEN NS_DEFINE_EVENT_STATE_MACRO(14) -// Content disabled by the user (images turned off, say). -#define NS_EVENT_STATE_USERDISABLED NS_DEFINE_EVENT_STATE_MACRO(15) + +// There's a free bit here. + // Content suppressed by the user (ad blocking, etc). #define NS_EVENT_STATE_SUPPRESSED NS_DEFINE_EVENT_STATE_MACRO(16) // Content is still loading such that there is nothing to show the diff --git a/dom/webidl/HTMLObjectElement.webidl b/dom/webidl/HTMLObjectElement.webidl index 53f0cc622161..0e67b8d21562 100644 --- a/dom/webidl/HTMLObjectElement.webidl +++ b/dom/webidl/HTMLObjectElement.webidl @@ -117,9 +117,6 @@ interface mixin MozObjectLoadingContent { // Suppressed by security policy [ChromeOnly] const unsigned long PLUGIN_SUPPRESSED = 6; - // Blocked by content policy - [ChromeOnly] - const unsigned long PLUGIN_USER_DISABLED = 7; /// ** All values >= PLUGIN_CLICK_TO_PLAY are plugin placeholder types that /// would be replaced by a real plugin if activated (playPlugin()) /// ** Furthermore, values >= PLUGIN_CLICK_TO_PLAY and diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 20efc8e1fff9..cef8a22c2d47 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -469,8 +469,7 @@ static bool StateChangeMayAffectFrame(const Element& aElement, } const bool brokenChanged = aStates.HasAtLeastOneOfStates( - NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED | - NS_EVENT_STATE_SUPPRESSED); + NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_SUPPRESSED); const bool loadingChanged = aStates.HasAtLeastOneOfStates(NS_EVENT_STATE_LOADING); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8fb571fc0f9f..d54aba4e838d 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3504,7 +3504,6 @@ nsCSSFrameConstructor::FindObjectData(const Element& aElement, // we want to treat those cases as TYPE_NULL uint32_t type; if (aElement.State().HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | - NS_EVENT_STATE_USERDISABLED | NS_EVENT_STATE_SUPPRESSED)) { type = nsIObjectLoadingContent::TYPE_NULL; } else { diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index d0310822b283..c65e186333a4 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -632,14 +632,12 @@ nsRect nsImageFrame::SourceRectToDest(const nsIntRect& aRect) { return r; } -// Note that we treat NS_EVENT_STATE_SUPPRESSED images as "OK". This means -// that we'll construct image frames for them as needed if their display is -// toggled from "none" (though we won't paint them, unless their visibility -// is changed too). -#define BAD_STATES (NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED) - static bool ImageOk(EventStates aState) { - return !aState.HasAtLeastOneOfStates(BAD_STATES); + // Note that we treat NS_EVENT_STATE_SUPPRESSED images as "OK". This means + // that we'll construct image frames for them as needed if their display is + // toggled from "none" (though we won't paint them, unless their visibility + // is changed too). + return !aState.HasState(NS_EVENT_STATE_BROKEN); } static bool HasAltText(const Element& aElement) { diff --git a/layout/style/res/html.css b/layout/style/res/html.css index 58b46fff2d73..56ab78719e4e 100644 --- a/layout/style/res/html.css +++ b/layout/style/res/html.css @@ -647,13 +647,13 @@ hr[size="1"] { border-style: solid none none none; } -input:is(:-moz-broken, :-moz-user-disabled)::before, -img:is(:-moz-broken, :-moz-user-disabled)::before { +input:-moz-broken::before, +img:-moz-broken::before { content: -moz-alt-content !important; unicode-bidi: isolate; } -object:is(:-moz-broken,:-moz-user-disabled) > *|* { +object:-moz-broken > *|* { /* Inherit in the object's alignment so that if we aren't aligned explicitly we'll end up in the right place vertically. See bug 36997. Note that this diff --git a/layout/style/test/test_non_content_accessible_pseudos.html b/layout/style/test/test_non_content_accessible_pseudos.html index c639c70e063b..7492a020662c 100644 --- a/layout/style/test/test_non_content_accessible_pseudos.html +++ b/layout/style/test/test_non_content_accessible_pseudos.html @@ -20,7 +20,6 @@ const NON_CONTENT_ACCESIBLE_PSEUDOS = [ ":-moz-browser-frame", ":-moz-devtools-highlighted", ":-moz-styleeditor-transitioning", - ":-moz-user-disabled", ":-moz-handler-clicktoplay", ":-moz-handler-vulnerable-updatable", ":-moz-handler-vulnerable-no-update", diff --git a/layout/style/test/test_selectors.html b/layout/style/test/test_selectors.html index 440f24d6d6a6..7be5b532367a 100644 --- a/layout/style/test/test_selectors.html +++ b/layout/style/test/test_selectors.html @@ -1125,7 +1125,6 @@ function runTests() { // Plugin pseudoclasses are chrome-only: test_unbalanced_unparseable(":-moz-type-unsupported"); - test_unbalanced_unparseable(":-moz-user-disabled"); test_unbalanced_unparseable(":-moz-suppressed"); test_unbalanced_unparseable(":-moz-type-unsupported"); test_unbalanced_unparseable(":-moz-type-unsupported-platform"); diff --git a/servo/components/style/element_state.rs b/servo/components/style/element_state.rs index a3d001a2fabf..cdce4d3cc75a 100644 --- a/servo/components/style/element_state.rs +++ b/servo/components/style/element_state.rs @@ -53,8 +53,6 @@ bitflags! { const IN_MOZ_UI_INVALID_STATE = 1 << 13; /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-broken const IN_BROKEN_STATE = 1 << 14; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-user-disabled - const IN_USER_DISABLED_STATE = 1 << 15; /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-suppressed const IN_SUPPRESSED_STATE = 1 << 16; /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading diff --git a/servo/components/style/gecko/non_ts_pseudo_class_list.rs b/servo/components/style/gecko/non_ts_pseudo_class_list.rs index 66851f1d46b5..030452a6c0a6 100644 --- a/servo/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/servo/components/style/gecko/non_ts_pseudo_class_list.rs @@ -92,8 +92,6 @@ macro_rules! apply_non_ts_list { ("-moz-meter-sub-optimum", MozMeterSubOptimum, IN_SUB_OPTIMUM_STATE, _), ("-moz-meter-sub-sub-optimum", MozMeterSubSubOptimum, IN_SUB_SUB_OPTIMUM_STATE, _), - ("-moz-user-disabled", MozUserDisabled, IN_USER_DISABLED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), - ("-moz-first-node", MozFirstNode, _, _), ("-moz-last-node", MozLastNode, _, _), ("-moz-only-whitespace", MozOnlyWhitespace, _, _), diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 0fd55f0e7e8e..fa63f4f4b08c 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -2023,7 +2023,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { NonTSPseudoClass::Invalid | NonTSPseudoClass::MozUIValid | NonTSPseudoClass::MozBroken | - NonTSPseudoClass::MozUserDisabled | NonTSPseudoClass::MozSuppressed | NonTSPseudoClass::MozLoading | NonTSPseudoClass::MozHandlerBlocked | diff --git a/toolkit/components/url-classifier/tests/browser/classifierTester.js b/toolkit/components/url-classifier/tests/browser/classifierTester.js index 38438348905e..19679780a12c 100644 --- a/toolkit/components/url-classifier/tests/browser/classifierTester.js +++ b/toolkit/components/url-classifier/tests/browser/classifierTester.js @@ -242,7 +242,7 @@ var classifierTester = { } return null; case "denied": - return Ci.nsIObjectLoadingContent.PLUGIN_USER_DISABLED; + return Ci.nsIObjectLoadingContent.PLUGIN_DISABLED; } throw new Error("Invalid classification or flash setting"); },