diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 2bd6af209a00..976b545a7b07 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -2621,6 +2621,14 @@ void nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType, thisEl->NotifyUAWidgetTeardown(); } else if (!hadProblemState && hasProblemState) { thisEl->AttachAndSetUAShadowRoot(); + // When blocking all plugins, we do not want the element to have focus + // so relinquish focus if we are in that state. + if (PluginFallbackType() == eFallbackBlockAllPlugins) { + nsFocusManager* fm = nsFocusManager::GetFocusManager(); + if (fm && fm->GetFocusedElement() == thisEl) { + fm->ClearFocus(doc->GetWindow()); + } + } } } else if (aOldType != mType) { // If our state changed, then we already recreated frames diff --git a/dom/html/HTMLEmbedElement.cpp b/dom/html/HTMLEmbedElement.cpp index 8581cd742693..e7d3be1b3782 100644 --- a/dom/html/HTMLEmbedElement.cpp +++ b/dom/html/HTMLEmbedElement.cpp @@ -163,7 +163,18 @@ nsresult HTMLEmbedElement::AfterMaybeChangeAttr(int32_t aNamespaceID, bool HTMLEmbedElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) { - // Has plugin content: let the plugin decide what to do in terms of + // If we have decided that this is a blocked plugin then do not allow focus. + if ((Type() == eType_Null) && + (PluginFallbackType() == eFallbackBlockAllPlugins)) { + if (aTabIndex) { + *aTabIndex = -1; + } + + *aIsFocusable = false; + return false; + } + + // Has non-plugin content: let the plugin decide what to do in terms of // internal focus from mouse clicks if (aTabIndex) { *aTabIndex = TabIndex(); diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index 689955b1719d..1a601cf7ddd3 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -289,6 +289,17 @@ bool HTMLObjectElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, return false; } + // If we have decided that this is a blocked plugin then do not allow focus. + if ((Type() == eType_Null) && + (PluginFallbackType() == eFallbackBlockAllPlugins)) { + if (aTabIndex) { + *aTabIndex = -1; + } + + *aIsFocusable = false; + return false; + } + const nsAttrValue* attrVal = mAttrs.GetAttr(nsGkAtoms::tabindex); bool isFocusable = attrVal && attrVal->Type() == nsAttrValue::eInteger;