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 b6c334d428
commit be74dd7ef8
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);
}