Backed out changeset cb2fce9d19c7 (bug 1137229) for OSX Werror bustage.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-03-24 13:07:26 -04:00
parent f38180eace
commit 4dd9a03e24
3 changed files with 11 additions and 67 deletions

View File

@ -45,9 +45,6 @@ HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& a
HTMLObjectElement::~HTMLObjectElement()
{
#ifdef XP_MACOSX
OnFocusBlurPlugin(this, false);
#endif
UnregisterActivityObserver();
DestroyImageLoadingContent();
}
@ -116,50 +113,20 @@ NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
static nsIWidget* GetWidget(Element* aElement)
{
return nsContentUtils::WidgetForDocument(aElement->OwnerDoc());
nsIWidget* retval = NULL;
nsIFrame* frame = aElement->GetPrimaryFrame();
if (frame) {
retval = frame->GetNearestWidget();
}
return retval;
}
Element* HTMLObjectElement::sLastFocused = nullptr; // Weak
class PluginFocusSetter : public nsRunnable
static void OnFocusBlurPlugin(Element* aElement, bool aFocus)
{
public:
PluginFocusSetter(nsIWidget* aWidget, Element* aElement)
: mWidget(aWidget), mElement(aElement)
{
}
NS_IMETHOD Run()
{
if (mElement) {
HTMLObjectElement::sLastFocused = mElement;
bool value = true;
mWidget->SetPluginFocused(value);
} else if (!HTMLObjectElement::sLastFocused) {
bool value = false;
mWidget->SetPluginFocused(value);
}
return NS_OK;
}
private:
nsCOMPtr<Element> mElement;
nsCOMPtr<nsIWidget> mWidget;
};
void
HTMLObjectElement::OnFocusBlurPlugin(Element* aElement, bool aFocus)
{
if (aFocus || aElement == sLastFocused) {
if (!aFocus) {
sLastFocused = nullptr;
}
nsIWidget* widget = GetWidget(aElement);
if (widget) {
nsContentUtils::AddScriptRunner(
new PluginFocusSetter(widget, aFocus ? aElement : nullptr));
}
nsIWidget* widget = GetWidget(aElement);
if (widget) {
bool value = aFocus;
widget->SetPluginFocused(value);
}
}
@ -243,14 +210,6 @@ void
HTMLObjectElement::UnbindFromTree(bool aDeep,
bool aNullParent)
{
#ifdef XP_MACOSX
// When a page is reloaded (when an nsIDocument's content is removed), the
// focused element isn't necessarily sent an NS_BLUR_CONTENT event. See
// nsFocusManager::ContentRemoved(). This means that a widget may think it
// still contains a focused plugin when it doesn't -- which in turn can
// disable text input in the browser window. See bug 1137229.
OnFocusBlurPlugin(this, false);
#endif
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
}

View File

@ -33,11 +33,7 @@ public:
#ifdef XP_MACOSX
// nsIDOMEventTarget
NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override;
// Helper methods
static void OnFocusBlurPlugin(Element* aElement, bool aFocus);
static void HandleFocusBlurPlugin(Element* aElement, WidgetEvent* aEvent);
// Weak pointer. Null if last action was blur.
static Element* sLastFocused;
#endif
// Element

View File

@ -62,9 +62,6 @@ HTMLSharedObjectElement::SetItemValueText(const nsAString& aValue)
HTMLSharedObjectElement::~HTMLSharedObjectElement()
{
#ifdef XP_MACOSX
HTMLObjectElement::OnFocusBlurPlugin(this, false);
#endif
UnregisterActivityObserver();
DestroyImageLoadingContent();
}
@ -162,14 +159,6 @@ void
HTMLSharedObjectElement::UnbindFromTree(bool aDeep,
bool aNullParent)
{
#ifdef XP_MACOSX
// When a page is reloaded (when an nsIDocument's content is removed), the
// focused element isn't necessarily sent an NS_BLUR_CONTENT event. See
// nsFocusManager::ContentRemoved(). This means that a widget may think it
// still contains a focused plugin when it doesn't -- which in turn can
// disable text input in the browser window. See bug 1137229.
HTMLObjectElement::OnFocusBlurPlugin(this, false);
#endif
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}