Bug 1684220 - Remove some dead plugins code. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D100472
This commit is contained in:
Emilio Cobos Álvarez 2021-01-04 20:12:05 +00:00
Родитель 2df51d08cb
Коммит 925ab25267
6 изменённых файлов: 35 добавлений и 68 удалений

Просмотреть файл

@ -1275,21 +1275,16 @@ EventStates nsObjectLoadingContent::ObjectState() const {
switch (mFallbackType) {
case eFallbackClickToPlay:
case eFallbackClickToPlayQuiet:
return NS_EVENT_STATE_TYPE_CLICK_TO_PLAY;
case eFallbackVulnerableUpdatable:
case eFallbackVulnerableNoUpdate:
return EventStates();
case eFallbackDisabled:
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_DISABLED;
case eFallbackBlocklisted:
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_BLOCKED;
case eFallbackCrashed:
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_CRASHED;
case eFallbackUnsupported:
case eFallbackOutdated:
case eFallbackAlternate:
return NS_EVENT_STATE_BROKEN;
case eFallbackVulnerableUpdatable:
return NS_EVENT_STATE_VULNERABLE_UPDATABLE;
case eFallbackVulnerableNoUpdate:
return NS_EVENT_STATE_VULNERABLE_NO_UPDATE;
case eFallbackBlockAllPlugins:
return NS_EVENT_STATE_HANDLER_NOPLUGINS;
}
@ -1918,6 +1913,7 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
// Save these for NotifyStateChanged();
EventStates oldState = ObjectState();
ObjectType oldType = mType;
FallbackType oldFallbackType = mFallbackType;
ParameterUpdateFlags stateChange = UpdateObjectParameters();
@ -2128,9 +2124,10 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
case eType_Plugin: {
if (mChannel) {
// Force a sync state change now, we need the frame created
NotifyStateChanged(oldType, oldState, true, aNotify);
NotifyStateChanged(oldType, oldState, oldFallbackType, true, aNotify);
oldType = mType;
oldState = ObjectState();
oldFallbackType = mFallbackType;
if (!thisContent->GetPrimaryFrame()) {
// We're un-rendered, and can't instantiate a plugin. HasNewFrame will
@ -2243,7 +2240,7 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
}
// Notify of our final state
NotifyStateChanged(oldType, oldState, false, aNotify);
NotifyStateChanged(oldType, oldState, oldFallbackType, false, aNotify);
NS_ENSURE_TRUE(mIsLoading, NS_OK);
//
@ -2548,6 +2545,7 @@ void nsObjectLoadingContent::UnloadObject(bool aResetState) {
void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
EventStates aOldState,
FallbackType aOldFallbackType,
bool aSync, bool aNotify) {
LOG(("OBJLC [%p]: Notifying about state change: (%u, %" PRIx64
") -> (%u, %" PRIx64 ")"
@ -2576,9 +2574,9 @@ void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
return; // Nothing to do
}
EventStates newState = ObjectState();
if (newState == aOldState && mType == aOldType) {
const EventStates newState = ObjectState();
if (newState == aOldState && mType == aOldType &&
(mType != eType_Null || mFallbackType == aOldFallbackType)) {
return; // Also done.
}
@ -2590,20 +2588,25 @@ void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
nsAutoScriptBlocker scriptBlocker;
doc->ContentStateChanged(thisEl, changedBits);
}
}
auto NeedsUAWidget = [](ObjectType aType, FallbackType aFallbackType) {
if (aType != eType_Null) {
return false;
}
return aFallbackType != eFallbackUnsupported &&
aFallbackType != eFallbackOutdated &&
aFallbackType != eFallbackAlternate &&
aFallbackType != eFallbackDisabled;
};
const bool needsWidget = NeedsUAWidget(mType, mFallbackType);
const bool neededWidget = NeedsUAWidget(aOldType, aOldFallbackType);
if (needsWidget != neededWidget) {
// Create/destroy plugin problem UAWidget.
const EventStates pluginProblemState =
NS_EVENT_STATE_HANDLER_BLOCKED | NS_EVENT_STATE_HANDLER_CRASHED |
NS_EVENT_STATE_TYPE_CLICK_TO_PLAY |
NS_EVENT_STATE_VULNERABLE_UPDATABLE |
NS_EVENT_STATE_VULNERABLE_NO_UPDATE | NS_EVENT_STATE_HANDLER_NOPLUGINS;
bool hadProblemState = !(aOldState & pluginProblemState).IsEmpty();
bool hasProblemState = !(newState & pluginProblemState).IsEmpty();
if (hadProblemState && !hasProblemState) {
if (neededWidget) {
thisEl->NotifyUAWidgetTeardown();
} else if (!hadProblemState && hasProblemState) {
} else {
thisEl->AttachAndSetUAShadowRoot();
// When blocking all plugins, we do not want the element to have focus
// so relinquish focus if we are in that state.
@ -2614,11 +2617,10 @@ void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
}
}
}
} else if (aOldType != mType) {
// If our state changed, then we already recreated frames
// Otherwise, need to do that here
RefPtr<PresShell> presShell = doc->GetPresShell();
if (presShell) {
}
if (aOldType != mType) {
if (RefPtr<PresShell> presShell = doc->GetPresShell()) {
presShell->PostRecreateFramesFor(thisEl);
}
}
@ -2840,6 +2842,7 @@ nsObjectLoadingContent::GetSrcURI(nsIURI** aURI) {
void nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
EventStates oldState = ObjectState();
ObjectType oldType = mType;
FallbackType oldFallbackType = mFallbackType;
NS_ASSERTION(!mInstanceOwner && !mFrameLoader && !mChannel,
"LoadFallback called with loaded content");
@ -2905,7 +2908,7 @@ void nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
return; // done
}
NotifyStateChanged(oldType, oldState, false, true);
NotifyStateChanged(oldType, oldState, oldFallbackType, false, true);
}
void nsObjectLoadingContent::DoStopPlugin(

Просмотреть файл

@ -540,7 +540,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent,
* @param aNotify if false, only need to update the state of our element.
*/
void NotifyStateChanged(ObjectType aOldType, mozilla::EventStates aOldState,
bool aSync, bool aNotify);
FallbackType aOldFallbackType, bool aSync,
bool aNotify);
/**
* Returns a ObjectType value corresponding to the type of content we would

Просмотреть файл

@ -205,12 +205,6 @@ class EventStates {
// Content is still loading such that there is nothing to show the
// user (eg an image which hasn't started coming in yet).
#define NS_EVENT_STATE_LOADING NS_DEFINE_EVENT_STATE_MACRO(17)
// Handler for the content has been blocked.
#define NS_EVENT_STATE_HANDLER_BLOCKED NS_DEFINE_EVENT_STATE_MACRO(18)
// Handler for the content has been disabled.
#define NS_EVENT_STATE_HANDLER_DISABLED NS_DEFINE_EVENT_STATE_MACRO(19)
// Handler for the content has crashed
#define NS_EVENT_STATE_HANDLER_CRASHED NS_DEFINE_EVENT_STATE_MACRO(20)
// Content is required.
#define NS_EVENT_STATE_REQUIRED NS_DEFINE_EVENT_STATE_MACRO(21)
// Content is optional (and can be required).
@ -250,12 +244,6 @@ class EventStates {
#define NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL NS_DEFINE_EVENT_STATE_MACRO(38)
// Content has focus and should show a ring.
#define NS_EVENT_STATE_FOCUSRING NS_DEFINE_EVENT_STATE_MACRO(39)
// Handler for click to play plugin
#define NS_EVENT_STATE_TYPE_CLICK_TO_PLAY NS_DEFINE_EVENT_STATE_MACRO(40)
// Handler for click to play plugin (vulnerable w/update)
#define NS_EVENT_STATE_VULNERABLE_UPDATABLE NS_DEFINE_EVENT_STATE_MACRO(41)
// Handler for click to play plugin (vulnerable w/no update)
#define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(42)
// Element has focus-within.
#define NS_EVENT_STATE_FOCUS_WITHIN NS_DEFINE_EVENT_STATE_MACRO(43)
// Element is ltr (for :dir pseudo-class)

Просмотреть файл

@ -55,12 +55,6 @@ bitflags! {
const IN_BROKEN_STATE = 1 << 14;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading
const IN_LOADING_STATE = 1 << 17;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-blocked
const IN_HANDLER_BLOCKED_STATE = 1 << 18;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-disabled
const IN_HANDLER_DISABLED_STATE = 1 << 19;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-crashed
const IN_HANDLER_CRASHED_STATE = 1 << 20;
/// <https://html.spec.whatwg.org/multipage/#selector-required>
const IN_REQUIRED_STATE = 1 << 21;
/// <https://html.spec.whatwg.org/multipage/#selector-optional>
@ -106,12 +100,6 @@ bitflags! {
///
/// But also https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo
const IN_FOCUSRING_STATE = 1 << 39;
/// Non-standard & undocumented.
const IN_HANDLER_CLICK_TO_PLAY_STATE = 1 << 40;
/// Non-standard & undocumented.
const IN_HANDLER_VULNERABLE_UPDATABLE_STATE = 1 << 41;
/// Non-standard & undocumented.
const IN_HANDLER_VULNERABLE_NO_UPDATE_STATE = 1 << 42;
/// <https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo>
const IN_FOCUS_WITHIN_STATE = 1 << 43;
/// :dir matching; the states are used for dynamic change detection.

Просмотреть файл

@ -66,13 +66,6 @@ macro_rules! apply_non_ts_list {
("-moz-autofill-preview", MozAutofillPreview, IN_AUTOFILL_PREVIEW_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-clicktoplay", MozHandlerClickToPlay, IN_HANDLER_CLICK_TO_PLAY_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-vulnerable-updatable", MozHandlerVulnerableUpdatable, IN_HANDLER_VULNERABLE_UPDATABLE_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-vulnerable-no-update", MozHandlerVulnerableNoUpdate, IN_HANDLER_VULNERABLE_NO_UPDATE_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-disabled", MozHandlerDisabled, IN_HANDLER_DISABLED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-blocked", MozHandlerBlocked, IN_HANDLER_BLOCKED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-crashed", MozHandlerCrashed, IN_HANDLER_CRASHED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-handler-noplugins", MozHandlerNoPlugins, IN_HANDLER_NOPLUGINS, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("-moz-math-increment-script-level", MozMathIncrementScriptLevel, IN_INCREMENT_SCRIPT_LEVEL_STATE, _),

Просмотреть файл

@ -2033,9 +2033,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozUIValid |
NonTSPseudoClass::MozBroken |
NonTSPseudoClass::MozLoading |
NonTSPseudoClass::MozHandlerBlocked |
NonTSPseudoClass::MozHandlerDisabled |
NonTSPseudoClass::MozHandlerCrashed |
NonTSPseudoClass::Required |
NonTSPseudoClass::Optional |
NonTSPseudoClass::ReadOnly |
@ -2046,9 +2043,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozDevtoolsHighlighted |
NonTSPseudoClass::MozStyleeditorTransitioning |
NonTSPseudoClass::MozFocusRing |
NonTSPseudoClass::MozHandlerClickToPlay |
NonTSPseudoClass::MozHandlerVulnerableUpdatable |
NonTSPseudoClass::MozHandlerVulnerableNoUpdate |
NonTSPseudoClass::MozHandlerNoPlugins |
NonTSPseudoClass::MozMathIncrementScriptLevel |
NonTSPseudoClass::InRange |