2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-05-22 01:00:09 +04:00
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2016-06-16 10:24:16 +03:00
|
|
|
#include "mozilla/dom/HTMLFormSubmission.h"
|
2013-03-04 23:08:23 +04:00
|
|
|
#include "mozilla/dom/HTMLObjectElement.h"
|
2013-01-07 03:55:14 +04:00
|
|
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
2013-10-03 00:09:18 +04:00
|
|
|
#include "mozilla/dom/ElementInlines.h"
|
2019-01-03 10:11:00 +03:00
|
|
|
#include "mozilla/dom/WindowProxyHolder.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2012-12-11 04:35:05 +04:00
|
|
|
#include "nsIPluginDocument.h"
|
2005-03-09 20:01:22 +03:00
|
|
|
#include "nsIObjectFrame.h"
|
2011-05-18 05:48:34 +04:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2011-11-27 15:51:53 +04:00
|
|
|
#include "nsIWidget.h"
|
2013-02-01 03:11:49 +04:00
|
|
|
#include "nsContentUtils.h"
|
2015-02-20 19:37:02 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
# include "mozilla/EventDispatcher.h"
|
|
|
|
# include "mozilla/dom/Event.h"
|
2015-03-27 03:38:13 +03:00
|
|
|
# include "nsFocusManager.h"
|
2015-02-20 19:37:02 +03:00
|
|
|
#endif
|
2010-08-28 04:36:45 +04:00
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
HTMLObjectElement::HTMLObjectElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-01-06 22:43:40 +04:00
|
|
|
FromParser aFromParser)
|
2018-09-21 23:45:49 +03:00
|
|
|
: nsGenericHTMLFormElement(std::move(aNodeInfo), NS_FORM_OBJECT),
|
2006-05-22 01:00:09 +04:00
|
|
|
mIsDoneAddingChildren(!aFromParser) {
|
2014-06-19 06:09:35 +04:00
|
|
|
RegisterActivityObserver();
|
2010-10-25 16:17:38 +04:00
|
|
|
SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
|
2010-09-10 09:08:56 +04:00
|
|
|
|
|
|
|
// <object> is always barred from constraint validation.
|
2011-10-17 18:59:28 +04:00
|
|
|
SetBarredFromConstraintValidation(true);
|
2011-06-01 05:46:57 +04:00
|
|
|
|
|
|
|
// By default we're in the loading state
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_LOADING);
|
1998-07-14 22:52:27 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::~HTMLObjectElement() {
|
2015-03-25 01:02:52 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
OnFocusBlurPlugin(this, false);
|
|
|
|
#endif
|
2014-06-19 06:09:35 +04:00
|
|
|
UnregisterActivityObserver();
|
2006-06-01 22:35:21 +04:00
|
|
|
DestroyImageLoadingContent();
|
|
|
|
}
|
|
|
|
|
2015-03-17 23:42:14 +03:00
|
|
|
bool HTMLObjectElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const {
|
2015-03-23 12:02:33 +03:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap) ||
|
|
|
|
nsGenericHTMLFormElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 23:39:28 +03:00
|
|
|
}
|
|
|
|
|
2016-10-06 07:30:35 +03:00
|
|
|
void HTMLObjectElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) {
|
|
|
|
nsImageLoadingContent::AsyncEventRunning(aEvent);
|
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
bool HTMLObjectElement::IsDoneAddingChildren() { return mIsDoneAddingChildren; }
|
2004-06-02 04:25:00 +04:00
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
void HTMLObjectElement::DoneAddingChildren(bool aHaveNotified) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsDoneAddingChildren = true;
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
// If we're already in a document, we need to trigger the load
|
|
|
|
// Otherwise, BindToTree takes care of that.
|
2015-02-24 17:41:43 +03:00
|
|
|
if (IsInComposedDoc()) {
|
2017-02-09 02:19:01 +03:00
|
|
|
StartObjectLoad(aHaveNotified, false);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2004-06-02 04:25:00 +04:00
|
|
|
}
|
1998-09-01 05:31:20 +04:00
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLObjectElement)
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLObjectElement,
|
2007-03-08 14:17:16 +03:00
|
|
|
nsGenericHTMLFormElement)
|
2013-02-01 18:10:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
2011-08-28 18:07:24 +04:00
|
|
|
nsObjectLoadingContent::Traverse(tmp, cb);
|
2007-03-08 14:17:16 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2013-08-02 05:29:05 +04:00
|
|
|
|
2013-02-01 18:10:08 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLObjectElement,
|
|
|
|
nsGenericHTMLFormElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
2013-09-12 05:57:53 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2017-09-01 02:29:22 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(
|
|
|
|
HTMLObjectElement, nsGenericHTMLFormElement, imgINotificationObserver,
|
2019-02-16 01:20:53 +03:00
|
|
|
nsIRequestObserver, nsIStreamListener, nsFrameLoaderOwner,
|
2017-09-01 02:29:22 +03:00
|
|
|
nsIObjectLoadingContent, nsIImageLoadingContent, nsIChannelEventSink,
|
|
|
|
nsIConstraintValidation)
|
1998-09-01 05:31:20 +04:00
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLObjectElement)
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2015-02-20 19:37:02 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
|
|
|
static nsIWidget* GetWidget(Element* aElement) {
|
2015-03-25 01:02:52 +03:00
|
|
|
return nsContentUtils::WidgetForDocument(aElement->OwnerDoc());
|
2015-03-24 20:07:26 +03:00
|
|
|
}
|
2015-03-24 19:41:32 +03:00
|
|
|
|
2015-03-25 01:02:52 +03:00
|
|
|
Element* HTMLObjectElement::sLastFocused = nullptr; // Weak
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class PluginFocusSetter : public Runnable {
|
2015-03-25 01:02:52 +03:00
|
|
|
public:
|
|
|
|
PluginFocusSetter(nsIWidget* aWidget, Element* aElement)
|
2017-06-12 22:34:10 +03:00
|
|
|
: Runnable("PluginFocusSetter"), mWidget(aWidget), mElement(aElement) {}
|
2015-03-25 01:02:52 +03:00
|
|
|
|
2016-08-08 05:18:10 +03:00
|
|
|
NS_IMETHOD Run() override {
|
2015-03-25 01:02:52 +03:00
|
|
|
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<nsIWidget> mWidget;
|
|
|
|
nsCOMPtr<Element> mElement;
|
|
|
|
};
|
|
|
|
|
|
|
|
void HTMLObjectElement::OnFocusBlurPlugin(Element* aElement, bool aFocus) {
|
2015-03-27 03:38:13 +03:00
|
|
|
// In general we don't want to call nsIWidget::SetPluginFocused() for any
|
|
|
|
// Element that doesn't have a plugin running. But if SetPluginFocused(true)
|
|
|
|
// was just called for aElement while it had a plugin running, we want to
|
|
|
|
// make sure nsIWidget::SetPluginFocused(false) gets called for it now, even
|
|
|
|
// if aFocus is true.
|
|
|
|
if (aFocus) {
|
|
|
|
nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(aElement);
|
|
|
|
bool hasRunningPlugin = false;
|
|
|
|
if (olc) {
|
2015-06-10 23:30:25 +03:00
|
|
|
hasRunningPlugin =
|
|
|
|
static_cast<nsObjectLoadingContent*>(olc.get())->HasRunningPlugin();
|
2015-03-27 03:38:13 +03:00
|
|
|
}
|
|
|
|
if (!hasRunningPlugin) {
|
|
|
|
aFocus = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 01:02:52 +03:00
|
|
|
if (aFocus || aElement == sLastFocused) {
|
|
|
|
if (!aFocus) {
|
|
|
|
sLastFocused = nullptr;
|
|
|
|
}
|
|
|
|
nsIWidget* widget = GetWidget(aElement);
|
|
|
|
if (widget) {
|
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
new PluginFocusSetter(widget, aFocus ? aElement : nullptr));
|
|
|
|
}
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-27 03:38:13 +03:00
|
|
|
void HTMLObjectElement::HandlePluginCrashed(Element* aElement) {
|
|
|
|
OnFocusBlurPlugin(aElement, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLObjectElement::HandlePluginInstantiated(Element* aElement) {
|
|
|
|
// If aElement is already focused when a plugin is instantiated, we need
|
|
|
|
// to initiate a call to nsIWidget::SetPluginFocused(true). Otherwise
|
|
|
|
// keyboard input won't work in a click-to-play plugin until aElement
|
|
|
|
// loses focus and regains it.
|
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
2018-04-26 22:28:31 +03:00
|
|
|
if (fm && fm->GetFocusedElement() == aElement) {
|
2015-03-27 03:38:13 +03:00
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 19:37:02 +03:00
|
|
|
void HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
|
|
|
|
WidgetEvent* aEvent) {
|
2016-03-17 10:01:30 +03:00
|
|
|
if (!aEvent->IsTrusted()) {
|
2015-02-20 19:37:02 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aEvent->mMessage) {
|
2015-09-02 09:08:00 +03:00
|
|
|
case eFocus: {
|
2015-02-20 19:37:02 +03:00
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
break;
|
|
|
|
}
|
2015-09-02 09:08:00 +03:00
|
|
|
case eBlur: {
|
2015-02-20 19:37:02 +03:00
|
|
|
OnFocusBlurPlugin(aElement, false);
|
|
|
|
break;
|
|
|
|
}
|
2015-08-26 15:56:59 +03:00
|
|
|
default:
|
|
|
|
break;
|
2015-02-20 19:37:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|
|
|
HandleFocusBlurPlugin(this, aVisitor.mEvent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifdef XP_MACOSX
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult HTMLObjectElement::BindToTree(Document* aDocument, nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) {
|
2005-09-21 23:14:30 +04:00
|
|
|
nsresult rv =
|
|
|
|
nsGenericHTMLFormElement::BindToTree(aDocument, aParent, aBindingParent);
|
2006-05-22 01:00:09 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2012-03-28 19:53:56 +04:00
|
|
|
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-11 04:35:05 +04:00
|
|
|
// Don't kick off load from being bound to a plugin document - the plugin
|
|
|
|
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
|
|
|
|
// initial load.
|
|
|
|
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// If we already have all the children, start the load.
|
2012-12-11 04:35:05 +04:00
|
|
|
if (mIsDoneAddingChildren && !pluginDoc) {
|
2013-01-06 22:43:40 +04:00
|
|
|
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
|
2017-06-12 22:34:10 +03:00
|
|
|
nsContentUtils::AddScriptRunner(
|
|
|
|
NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start));
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
void HTMLObjectElement::UnbindFromTree(bool aDeep, bool aNullParent) {
|
2015-03-25 01:02:52 +03:00
|
|
|
#ifdef XP_MACOSX
|
2019-01-02 16:05:23 +03:00
|
|
|
// When a page is reloaded (when an Document's content is removed), the
|
2015-09-02 09:08:00 +03:00
|
|
|
// focused element isn't necessarily sent an eBlur event. See
|
2015-03-25 01:02:52 +03:00
|
|
|
// 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
|
2012-03-28 19:53:56 +04:00
|
|
|
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2005-09-21 23:14:30 +04:00
|
|
|
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLObjectElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-06-07 20:28:20 +03:00
|
|
|
const nsAttrValue* aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
bool aNotify) {
|
2017-06-07 20:28:20 +03:00
|
|
|
nsresult rv = AfterMaybeChangeAttr(aNamespaceID, aName, aNotify);
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2017-06-07 20:28:20 +03:00
|
|
|
return nsGenericHTMLFormElement::AfterSetAttr(
|
2017-10-10 00:33:38 +03:00
|
|
|
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLObjectElement::OnAttrSetButNotChanged(
|
2017-06-07 20:28:20 +03:00
|
|
|
int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue,
|
|
|
|
bool aNotify) {
|
|
|
|
nsresult rv = AfterMaybeChangeAttr(aNamespaceID, aName, aNotify);
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2017-06-07 20:28:20 +03:00
|
|
|
return nsGenericHTMLFormElement::OnAttrSetButNotChanged(aNamespaceID, aName,
|
|
|
|
aValue, aNotify);
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLObjectElement::AfterMaybeChangeAttr(int32_t aNamespaceID,
|
2017-06-07 20:28:20 +03:00
|
|
|
nsAtom* aName, bool aNotify) {
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
// if aNotify is false, we are coming from the parser or some such place;
|
|
|
|
// we'll get bound after all the attributes have been set, so we'll do the
|
|
|
|
// object load from BindToTree/DoneAddingChildren.
|
|
|
|
// Skip the LoadObject call in that case.
|
|
|
|
// We also don't want to start loading the object when we're not yet in
|
|
|
|
// a document, just in case that the caller wants to set additional
|
|
|
|
// attributes before inserting the node into the document.
|
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
|
|
|
aName == nsGkAtoms::data && !BlockEmbedOrObjectContentLoading()) {
|
|
|
|
return LoadObject(aNotify, true);
|
|
|
|
}
|
2008-12-12 22:41:11 +03:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_OK;
|
2008-12-12 22:41:11 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
bool HTMLObjectElement::IsFocusableForTabIndex() {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetComposedDoc();
|
2010-10-08 14:20:20 +04:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-11 03:30:15 +04:00
|
|
|
return IsEditableRoot() ||
|
2015-05-20 16:30:05 +03:00
|
|
|
((Type() == eType_Document || Type() == eType_FakePlugin) &&
|
2012-11-11 03:30:15 +04:00
|
|
|
nsContentUtils::IsSubDocumentTabbable(this));
|
2010-10-08 14:20:20 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
bool HTMLObjectElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|
|
|
int32_t* aTabIndex) {
|
2010-10-08 14:20:20 +04:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetComposedDoc();
|
2010-10-08 14:20:20 +04:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
if (aTabIndex) {
|
2017-07-14 06:45:49 +03:00
|
|
|
*aTabIndex = TabIndex();
|
2010-10-08 14:20:20 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*aIsFocusable = false;
|
2010-10-08 14:20:20 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-10-08 14:20:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method doesn't call nsGenericHTMLFormElement intentionally.
|
|
|
|
// TODO: It should probably be changed when bug 597242 will be fixed.
|
|
|
|
if (Type() == eType_Plugin || IsEditableRoot() ||
|
2015-05-20 16:30:05 +03:00
|
|
|
((Type() == eType_Document || Type() == eType_FakePlugin) &&
|
|
|
|
nsContentUtils::IsSubDocumentTabbable(this))) {
|
2005-10-03 23:29:52 +04:00
|
|
|
// Has plugin content: let the plugin decide what to do in terms of
|
|
|
|
// internal focus from mouse clicks
|
2005-10-05 03:43:54 +04:00
|
|
|
if (aTabIndex) {
|
2017-07-14 06:45:49 +03:00
|
|
|
*aTabIndex = TabIndex();
|
2005-10-05 03:43:54 +04:00
|
|
|
}
|
2010-10-08 14:20:20 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*aIsFocusable = true;
|
2008-04-15 22:40:38 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-10-03 23:29:52 +04:00
|
|
|
}
|
2005-10-05 03:43:54 +04:00
|
|
|
|
2010-10-08 14:20:20 +04:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
2018-08-07 22:07:26 +03:00
|
|
|
const nsAttrValue* attrVal = mAttrs.GetAttr(nsGkAtoms::tabindex);
|
2010-10-08 14:20:20 +04:00
|
|
|
|
|
|
|
*aIsFocusable = attrVal && attrVal->Type() == nsAttrValue::eInteger;
|
|
|
|
|
|
|
|
if (aTabIndex && *aIsFocusable) {
|
|
|
|
*aTabIndex = attrVal->GetIntegerValue();
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-10-03 23:29:52 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
nsIContent::IMEState HTMLObjectElement::GetDesiredIMEState() {
|
2006-05-22 01:00:09 +04:00
|
|
|
if (Type() == eType_Plugin) {
|
2011-11-27 15:51:53 +04:00
|
|
|
return IMEState(IMEState::PLUGIN);
|
2006-05-22 01:00:09 +04:00
|
|
|
}
|
2015-05-20 16:30:05 +03:00
|
|
|
|
2005-11-15 02:55:24 +03:00
|
|
|
return nsGenericHTMLFormElement::GetDesiredIMEState();
|
|
|
|
}
|
|
|
|
|
2002-08-06 12:32:19 +04:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::Reset() { return NS_OK; }
|
1998-09-03 03:53:16 +04:00
|
|
|
|
2002-08-06 12:32:19 +04:00
|
|
|
NS_IMETHODIMP
|
2016-06-16 10:24:16 +03:00
|
|
|
HTMLObjectElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) {
|
2005-03-09 20:01:22 +03:00
|
|
|
nsAutoString name;
|
2006-05-22 01:00:09 +04:00
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
|
2005-03-09 20:01:22 +03:00
|
|
|
// No name, don't submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-12 20:14:31 +04:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2005-03-09 20:01:22 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIObjectFrame* objFrame = do_QueryFrame(frame);
|
2005-03-09 20:01:22 +03:00
|
|
|
if (!objFrame) {
|
|
|
|
// No frame, nothing to submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-11-20 04:20:17 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi = objFrame->GetPluginInstance();
|
|
|
|
if (!pi) {
|
2005-03-09 20:01:22 +03:00
|
|
|
return NS_OK;
|
2018-11-20 04:20:17 +03:00
|
|
|
}
|
2005-03-09 20:01:22 +03:00
|
|
|
|
|
|
|
nsAutoString value;
|
2009-07-02 08:52:07 +04:00
|
|
|
nsresult rv = pi->GetFormValue(value);
|
2005-03-09 20:01:22 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-02-25 08:58:16 +03:00
|
|
|
return aFormSubmission->AddNameValuePair(name, value);
|
2002-08-06 12:32:19 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
int32_t HTMLObjectElement::TabIndexDefault() {
|
2012-10-06 11:19:51 +04:00
|
|
|
return IsFocusableForTabIndex() ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
Nullable<WindowProxyHolder> HTMLObjectElement::GetContentWindow(
|
2016-10-11 04:07:48 +03:00
|
|
|
nsIPrincipal& aSubjectPrincipal) {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = GetContentDocument(aSubjectPrincipal);
|
2013-03-04 23:08:24 +04:00
|
|
|
if (doc) {
|
2019-01-02 16:26:56 +03:00
|
|
|
nsPIDOMWindowOuter* win = doc->GetWindow();
|
|
|
|
if (win) {
|
2019-01-02 16:27:05 +03:00
|
|
|
return WindowProxyHolder(win->GetBrowsingContext());
|
2019-01-02 16:26:56 +03:00
|
|
|
}
|
2002-04-17 08:17:16 +04:00
|
|
|
}
|
2002-04-05 09:42:10 +04:00
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
return nullptr;
|
2000-04-19 02:57:42 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
bool HTMLObjectElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-01-06 22:43:40 +04:00
|
|
|
nsAttrValue& aResult) {
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-05-22 01:00:09 +04:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return ParseAlignValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
1998-09-01 05:31:20 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLFormElement::ParseAttribute(
|
2017-11-02 06:35:52 +03:00
|
|
|
aNamespaceID, aAttribute, aValue, aMaybeScriptedPrincipal, aResult);
|
1998-09-01 05:31:20 +04:00
|
|
|
}
|
|
|
|
|
2018-06-22 19:48:42 +03:00
|
|
|
void HTMLObjectElement::MapAttributesIntoRule(
|
|
|
|
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
|
|
|
nsGenericHTMLFormElement::MapImageAlignAttributeInto(aAttributes, aDecls);
|
|
|
|
nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aDecls);
|
|
|
|
nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aDecls);
|
|
|
|
nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aDecls);
|
|
|
|
nsGenericHTMLFormElement::MapCommonAttributesInto(aAttributes, aDecls);
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
HTMLObjectElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-17 00:54:20 +04:00
|
|
|
sCommonAttributeMap,
|
2003-07-12 01:16:12 +04:00
|
|
|
sImageMarginSizeAttributeMap,
|
2003-04-17 00:54:20 +04:00
|
|
|
sImageBorderAttributeMap,
|
|
|
|
sImageAlignAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
nsMapRuleToAttributesFunc HTMLObjectElement::GetAttributeMappingFunction()
|
|
|
|
const {
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-01 05:31:20 +04:00
|
|
|
}
|
2005-09-18 22:05:40 +04:00
|
|
|
|
2017-02-09 02:19:01 +03:00
|
|
|
void HTMLObjectElement::StartObjectLoad(bool aNotify, bool aForce) {
|
2012-07-06 04:56:25 +04:00
|
|
|
// BindToTree can call us asynchronously, and we may be removed from the tree
|
|
|
|
// in the interim
|
2017-02-09 02:19:01 +03:00
|
|
|
if (!IsInComposedDoc() || !OwnerDoc()->IsActive() ||
|
|
|
|
BlockEmbedOrObjectContentLoading()) {
|
2012-07-06 04:56:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-09 02:19:01 +03:00
|
|
|
LoadObject(aNotify, aForce);
|
2011-10-17 18:59:28 +04:00
|
|
|
SetIsNetworkCreated(false);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
EventStates HTMLObjectElement::IntrinsicState() const {
|
2005-09-21 23:14:30 +04:00
|
|
|
return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
|
|
|
|
}
|
2005-09-18 22:05:40 +04:00
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
uint32_t HTMLObjectElement::GetCapabilities() const {
|
2018-05-01 07:53:48 +03:00
|
|
|
return nsObjectLoadingContent::GetCapabilities() | eFallbackIfClassIDPresent;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2007-12-05 10:11:00 +03:00
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
void HTMLObjectElement::DestroyContent() {
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent::DestroyContent();
|
2007-12-05 10:11:00 +03:00
|
|
|
nsGenericHTMLFormElement::DestroyContent();
|
|
|
|
}
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult HTMLObjectElement::CopyInnerTo(Element* aDest) {
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::CopyInnerTo(aDest);
|
2009-12-11 07:02:13 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-18 14:53:36 +04:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2013-01-06 22:43:40 +04:00
|
|
|
CreateStaticClone(static_cast<HTMLObjectElement*>(aDest));
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2013-01-06 22:43:40 +04:00
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* HTMLObjectElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2013-05-02 13:12:45 +04:00
|
|
|
JS::Rooted<JSObject*> obj(
|
2018-06-26 00:20:54 +03:00
|
|
|
aCx, HTMLObjectElement_Binding::Wrap(aCx, this, aGivenProto));
|
2013-01-07 03:55:14 +04:00
|
|
|
if (!obj) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
SetupProtoChain(aCx, obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Object)
|