2015-05-03 19:32:37 +00: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 11:12:37 +00: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-21 21:00:09 +00:00
|
|
|
|
2014-04-03 04:18:36 +00:00
|
|
|
#include "mozilla/EventStates.h"
|
2016-06-16 07:24:16 +00:00
|
|
|
#include "mozilla/dom/HTMLFormSubmission.h"
|
2013-03-04 19:08:23 +00:00
|
|
|
#include "mozilla/dom/HTMLObjectElement.h"
|
2013-01-06 23:55:14 +00:00
|
|
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
2013-10-02 20:09:18 +00:00
|
|
|
#include "mozilla/dom/ElementInlines.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2002-02-21 02:01:12 +00:00
|
|
|
#include "nsIDocument.h"
|
2012-12-11 00:35:05 +00:00
|
|
|
#include "nsIPluginDocument.h"
|
2002-02-21 02:01:12 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2005-03-09 17:01:22 +00:00
|
|
|
#include "nsIObjectFrame.h"
|
2011-05-18 01:48:34 +00:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2011-11-27 11:51:53 +00:00
|
|
|
#include "nsIWidget.h"
|
2013-01-31 23:11:49 +00:00
|
|
|
#include "nsContentUtils.h"
|
2015-02-20 16:37:02 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "mozilla/EventDispatcher.h"
|
|
|
|
#include "mozilla/dom/Event.h"
|
2015-03-27 00:38:13 +00:00
|
|
|
#include "nsFocusManager.h"
|
2015-02-20 16:37:02 +00:00
|
|
|
#endif
|
2010-08-28 00:36:45 +00:00
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-01-06 18:43:40 +00:00
|
|
|
FromParser aFromParser)
|
2006-05-21 21:00:09 +00:00
|
|
|
: nsGenericHTMLFormElement(aNodeInfo),
|
|
|
|
mIsDoneAddingChildren(!aFromParser)
|
1998-07-14 18:52:27 +00:00
|
|
|
{
|
2014-06-19 02:09:35 +00:00
|
|
|
RegisterActivityObserver();
|
2010-10-25 12:17:38 +00:00
|
|
|
SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
|
2010-09-10 05:08:56 +00:00
|
|
|
|
|
|
|
// <object> is always barred from constraint validation.
|
2011-10-17 14:59:28 +00:00
|
|
|
SetBarredFromConstraintValidation(true);
|
2011-06-01 01:46:57 +00:00
|
|
|
|
|
|
|
// By default we're in the loading state
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_LOADING);
|
1998-07-14 18:52:27 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::~HTMLObjectElement()
|
2006-06-01 18:35:21 +00:00
|
|
|
{
|
2015-03-24 22:02:52 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
OnFocusBlurPlugin(this, false);
|
|
|
|
#endif
|
2014-06-19 02:09:35 +00:00
|
|
|
UnregisterActivityObserver();
|
2006-06-01 18:35:21 +00:00
|
|
|
DestroyImageLoadingContent();
|
|
|
|
}
|
|
|
|
|
2015-01-20 20:39:28 +00:00
|
|
|
bool
|
2015-03-17 20:42:14 +00:00
|
|
|
HTMLObjectElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
2015-01-20 20:39:28 +00:00
|
|
|
{
|
2015-03-23 09:02:33 +00:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap) ||
|
|
|
|
nsGenericHTMLFormElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 20:39:28 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::IsDoneAddingChildren()
|
2004-06-02 00:25:00 +00:00
|
|
|
{
|
|
|
|
return mIsDoneAddingChildren;
|
|
|
|
}
|
|
|
|
|
2011-11-16 07:50:18 +00:00
|
|
|
void
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::DoneAddingChildren(bool aHaveNotified)
|
2004-06-02 00:25:00 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsDoneAddingChildren = true;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
// If we're already in a document, we need to trigger the load
|
|
|
|
// Otherwise, BindToTree takes care of that.
|
2015-02-24 14:41:43 +00:00
|
|
|
if (IsInComposedDoc()) {
|
2005-09-22 02:33:36 +00:00
|
|
|
StartObjectLoad(aHaveNotified);
|
2005-09-21 19:14:30 +00:00
|
|
|
}
|
2004-06-02 00:25:00 +00:00
|
|
|
}
|
1998-09-01 01:31:20 +00:00
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLObjectElement)
|
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLObjectElement,
|
2007-03-08 11:17:16 +00:00
|
|
|
nsGenericHTMLFormElement)
|
2013-02-01 14:10:08 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
2011-08-28 14:07:24 +00:00
|
|
|
nsObjectLoadingContent::Traverse(tmp, cb);
|
2007-03-08 11:17:16 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2013-08-02 01:29:05 +00:00
|
|
|
|
2013-02-01 14:10:08 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLObjectElement,
|
|
|
|
nsGenericHTMLFormElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
2013-09-12 01:57:53 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2007-03-08 11:17:16 +00:00
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLObjectElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLObjectElement, Element)
|
|
|
|
|
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLObjectElement)
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_INTERFACE_TABLE_INHERITED(HTMLObjectElement,
|
|
|
|
nsIDOMHTMLObjectElement,
|
|
|
|
imgINotificationObserver,
|
|
|
|
nsIRequestObserver,
|
|
|
|
nsIStreamListener,
|
|
|
|
nsIFrameLoaderOwner,
|
|
|
|
nsIObjectLoadingContent,
|
|
|
|
nsIImageLoadingContent,
|
|
|
|
imgIOnloadBlocker,
|
|
|
|
nsIChannelEventSink,
|
|
|
|
nsIConstraintValidation)
|
2013-08-07 20:23:08 +00:00
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElement)
|
1998-09-01 01:31:20 +00:00
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLObjectElement)
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2010-08-28 00:36:45 +00:00
|
|
|
// nsIConstraintValidation
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
|
1998-09-01 01:31:20 +00:00
|
|
|
|
2015-02-20 16:37:02 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
|
|
|
static nsIWidget* GetWidget(Element* aElement)
|
|
|
|
{
|
2015-03-24 22:02:52 +00:00
|
|
|
return nsContentUtils::WidgetForDocument(aElement->OwnerDoc());
|
2015-03-24 17:07:26 +00:00
|
|
|
}
|
2015-03-24 16:41:32 +00:00
|
|
|
|
2015-03-24 22:02:52 +00:00
|
|
|
Element* HTMLObjectElement::sLastFocused = nullptr; // Weak
|
|
|
|
|
2016-04-26 00:23:21 +00:00
|
|
|
class PluginFocusSetter : public Runnable
|
2015-03-24 16:41:32 +00:00
|
|
|
{
|
2015-03-24 22:02:52 +00:00
|
|
|
public:
|
|
|
|
PluginFocusSetter(nsIWidget* aWidget, Element* aElement)
|
|
|
|
: mWidget(aWidget), mElement(aElement)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-08 02:18:10 +00:00
|
|
|
NS_IMETHOD Run() override
|
2015-03-24 22:02:52 +00: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 00:38:13 +00: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 20:30:25 +00:00
|
|
|
// nsIObjectLoadingContent::GetHasRunningPlugin() fails when
|
|
|
|
// nsContentUtils::IsCallerChrome() returns false (which it can do even
|
|
|
|
// when we're processing a trusted focus event). We work around this by
|
|
|
|
// calling nsObjectLoadingContent::HasRunningPlugin() directly.
|
|
|
|
hasRunningPlugin =
|
|
|
|
static_cast<nsObjectLoadingContent*>(olc.get())->HasRunningPlugin();
|
2015-03-27 00:38:13 +00:00
|
|
|
}
|
|
|
|
if (!hasRunningPlugin) {
|
|
|
|
aFocus = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 22:02:52 +00: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 16:37:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-27 00:38:13 +00: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.
|
|
|
|
nsIContent* focusedContent = nullptr;
|
|
|
|
nsFocusManager *fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (fm) {
|
|
|
|
focusedContent = fm->GetFocusedContent();
|
|
|
|
}
|
|
|
|
if (SameCOMIdentity(focusedContent, aElement)) {
|
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 16:37:02 +00:00
|
|
|
void
|
|
|
|
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
|
|
|
|
WidgetEvent* aEvent)
|
|
|
|
{
|
2016-03-17 07:01:30 +00:00
|
|
|
if (!aEvent->IsTrusted()) {
|
2015-02-20 16:37:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-08-22 01:34:51 +00:00
|
|
|
switch (aEvent->mMessage) {
|
2015-09-02 06:08:00 +00:00
|
|
|
case eFocus: {
|
2015-02-20 16:37:02 +00:00
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
break;
|
|
|
|
}
|
2015-09-02 06:08:00 +00:00
|
|
|
case eBlur: {
|
2015-02-20 16:37:02 +00:00
|
|
|
OnFocusBlurPlugin(aElement, false);
|
|
|
|
break;
|
|
|
|
}
|
2015-08-26 12:56:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-02-20 16:37:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|
|
|
{
|
|
|
|
HandleFocusBlurPlugin(this, aVisitor.mEvent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifdef XP_MACOSX
|
|
|
|
|
1998-09-02 23:53:16 +00:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
|
1998-09-02 23:53:16 +00:00
|
|
|
{
|
2004-02-10 19:36:43 +00:00
|
|
|
return nsGenericHTMLFormElement::GetForm(aForm);
|
2002-08-06 08:32:19 +00:00
|
|
|
}
|
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
nsresult
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::BindToTree(nsIDocument *aDocument,
|
|
|
|
nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2005-09-21 19:14:30 +00:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2006-05-21 21:00:09 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-03-28 15:53:56 +00:00
|
|
|
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-11 00:35:05 +00: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 19:14:30 +00:00
|
|
|
// If we already have all the children, start the load.
|
2012-12-11 00:35:05 +00:00
|
|
|
if (mIsDoneAddingChildren && !pluginDoc) {
|
2013-01-06 18:43:40 +00:00
|
|
|
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
|
2016-05-05 08:45:00 +00:00
|
|
|
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start));
|
2005-09-21 19:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::UnbindFromTree(bool aDeep,
|
|
|
|
bool aNullParent)
|
2005-09-21 19:14:30 +00:00
|
|
|
{
|
2015-03-24 22:02:52 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// When a page is reloaded (when an nsIDocument's content is removed), the
|
2015-09-02 06:08:00 +00:00
|
|
|
// focused element isn't necessarily sent an eBlur event. See
|
2015-03-24 22:02:52 +00: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 15:53:56 +00:00
|
|
|
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2005-09-21 19:14:30 +00:00
|
|
|
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
|
|
|
nsIAtom *aPrefix, const nsAString &aValue,
|
|
|
|
bool aNotify)
|
2005-09-21 19:14:30 +00:00
|
|
|
{
|
2012-07-05 21:07:46 +00:00
|
|
|
nsresult rv = nsGenericHTMLFormElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
|
|
|
aValue, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// 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
|
2005-09-21 19:14:30 +00:00
|
|
|
// object load from BindToTree/DoneAddingChildren.
|
2006-01-01 11:25:43 +00:00
|
|
|
// Skip the LoadObject call in that case.
|
2007-07-20 20:14:38 +00:00
|
|
|
// 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.
|
2015-02-24 14:41:43 +00:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2007-07-20 20:14:38 +00:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::data) {
|
2012-07-05 21:07:46 +00:00
|
|
|
return LoadObject(aNotify, true);
|
2005-09-21 19:14:30 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
return NS_OK;
|
2005-09-21 19:14:30 +00:00
|
|
|
}
|
|
|
|
|
2008-12-12 19:41:11 +00:00
|
|
|
nsresult
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2008-12-12 19:41:11 +00:00
|
|
|
{
|
2012-07-05 21:07:46 +00:00
|
|
|
nsresult rv = nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID,
|
|
|
|
aAttribute, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// See comment in SetAttr
|
2015-02-24 14:41:43 +00:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2012-07-05 21:07:46 +00:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::data) {
|
|
|
|
return LoadObject(aNotify, true);
|
2008-12-12 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
return NS_OK;
|
2008-12-12 19:41:11 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 10:20:20 +00:00
|
|
|
bool
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::IsFocusableForTabIndex()
|
2010-10-08 10:20:20 +00:00
|
|
|
{
|
2014-10-02 19:07:24 +00:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-10-08 10:20:20 +00:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-10 23:30:15 +00:00
|
|
|
return IsEditableRoot() ||
|
|
|
|
(Type() == eType_Document &&
|
|
|
|
nsContentUtils::IsSubDocumentTabbable(this));
|
2010-10-08 10:20:20 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
|
|
|
|
bool *aIsFocusable, int32_t *aTabIndex)
|
2005-10-03 19:29:52 +00:00
|
|
|
{
|
2010-10-08 10:20:20 +00:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
2014-10-02 19:07:24 +00:00
|
|
|
nsIDocument *doc = GetComposedDoc();
|
2010-10-08 10:20:20 +00:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
if (aTabIndex) {
|
2012-02-07 12:52:45 +00:00
|
|
|
GetTabIndex(aTabIndex);
|
2010-10-08 10:20:20 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsFocusable = false;
|
2010-10-08 10:20:20 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-10-08 10:20:20 +00: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() ||
|
|
|
|
(Type() == eType_Document && nsContentUtils::IsSubDocumentTabbable(this))) {
|
2005-10-03 19:29:52 +00:00
|
|
|
// Has plugin content: let the plugin decide what to do in terms of
|
|
|
|
// internal focus from mouse clicks
|
2005-10-04 23:43:54 +00:00
|
|
|
if (aTabIndex) {
|
2012-02-07 12:52:45 +00:00
|
|
|
GetTabIndex(aTabIndex);
|
2005-10-04 23:43:54 +00:00
|
|
|
}
|
2010-10-08 10:20:20 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsFocusable = true;
|
2008-04-15 18:40:38 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2005-10-03 19:29:52 +00:00
|
|
|
}
|
2005-10-04 23:43:54 +00:00
|
|
|
|
2010-10-08 10:20:20 +00:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
|
|
|
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(nsGkAtoms::tabindex);
|
|
|
|
|
|
|
|
*aIsFocusable = attrVal && attrVal->Type() == nsAttrValue::eInteger;
|
|
|
|
|
|
|
|
if (aTabIndex && *aIsFocusable) {
|
|
|
|
*aTabIndex = attrVal->GetIntegerValue();
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2005-10-03 19:29:52 +00:00
|
|
|
}
|
|
|
|
|
2011-11-27 11:51:53 +00:00
|
|
|
nsIContent::IMEState
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::GetDesiredIMEState()
|
2005-11-14 23:55:24 +00:00
|
|
|
{
|
2006-05-21 21:00:09 +00:00
|
|
|
if (Type() == eType_Plugin) {
|
2011-11-27 11:51:53 +00:00
|
|
|
return IMEState(IMEState::PLUGIN);
|
2006-05-21 21:00:09 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 23:55:24 +00:00
|
|
|
return nsGenericHTMLFormElement::GetDesiredIMEState();
|
|
|
|
}
|
|
|
|
|
2002-08-06 08:32:19 +00:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::Reset()
|
2002-08-06 08:32:19 +00:00
|
|
|
{
|
1998-09-02 23:53:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-08-06 08:32:19 +00:00
|
|
|
NS_IMETHODIMP
|
2016-06-16 07:24:16 +00:00
|
|
|
HTMLObjectElement::SubmitNamesValues(HTMLFormSubmission *aFormSubmission)
|
2002-08-06 08:32:19 +00:00
|
|
|
{
|
2005-03-09 17:01:22 +00:00
|
|
|
nsAutoString name;
|
2006-05-21 21:00:09 +00:00
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
|
2005-03-09 17:01:22 +00:00
|
|
|
// No name, don't submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-12 16:14:31 +00:00
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
2005-03-09 17:01:22 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIObjectFrame *objFrame = do_QueryFrame(frame);
|
2005-03-09 17:01:22 +00:00
|
|
|
if (!objFrame) {
|
|
|
|
// No frame, nothing to submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi;
|
2011-05-18 01:48:34 +00:00
|
|
|
objFrame->GetPluginInstance(getter_AddRefs(pi));
|
2009-07-02 04:52:07 +00:00
|
|
|
if (!pi)
|
2005-03-09 17:01:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsAutoString value;
|
2009-07-02 04:52:07 +00:00
|
|
|
nsresult rv = pi->GetFormValue(value);
|
2005-03-09 17:01:22 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-02-25 05:58:16 +00:00
|
|
|
return aFormSubmission->AddNameValuePair(name, value);
|
2002-08-06 08:32:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Align, align)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Archive, archive)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Border, border)
|
2016-05-05 18:29:54 +00:00
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Code, code)
|
2013-01-06 18:43:40 +00:00
|
|
|
NS_IMPL_URI_ATTR(HTMLObjectElement, CodeBase, codebase)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, CodeType, codetype)
|
|
|
|
NS_IMPL_URI_ATTR_WITH_BASE(HTMLObjectElement, Data, data, codebase)
|
|
|
|
NS_IMPL_BOOL_ATTR(HTMLObjectElement, Declare, declare)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Height, height)
|
|
|
|
NS_IMPL_INT_ATTR(HTMLObjectElement, Hspace, hspace)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Name, name)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Standby, standby)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Type, type)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, UseMap, usemap)
|
|
|
|
NS_IMPL_INT_ATTR(HTMLObjectElement, Vspace, vspace)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Width, width)
|
1998-09-01 01:31:20 +00:00
|
|
|
|
2012-10-06 07:19:51 +00:00
|
|
|
int32_t
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::TabIndexDefault()
|
2012-10-06 07:19:51 +00:00
|
|
|
{
|
|
|
|
return IsFocusableForTabIndex() ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2000-04-18 22:57:42 +00:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
|
2000-04-18 22:57:42 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aContentDocument);
|
2002-02-21 02:01:12 +00:00
|
|
|
|
2013-03-04 19:08:24 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetContentDocument());
|
|
|
|
domDoc.forget(aContentDocument);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-04-05 05:42:10 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsPIDOMWindowOuter*
|
2013-03-04 19:08:24 +00:00
|
|
|
HTMLObjectElement::GetContentWindow()
|
|
|
|
{
|
|
|
|
nsIDocument* doc = GetContentDocument();
|
|
|
|
if (doc) {
|
|
|
|
return doc->GetWindow();
|
2002-04-17 04:17:16 +00:00
|
|
|
}
|
2002-04-05 05:42:10 +00:00
|
|
|
|
2013-03-04 19:08:24 +00:00
|
|
|
return nullptr;
|
2000-04-18 22:57:42 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
const nsAString &aValue,
|
|
|
|
nsAttrValue &aResult)
|
1998-09-01 01:31:20 +00:00
|
|
|
{
|
2005-11-29 16:37:15 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-05-21 21:00:09 +00:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return ParseAlignValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
1998-09-01 01:31:20 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
|
|
|
|
aValue, aResult);
|
1998-09-01 01:31:20 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLObjectElement::MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
|
|
|
|
nsRuleData *aData)
|
1998-09-05 04:00:06 +00:00
|
|
|
{
|
2004-02-10 19:36:43 +00:00
|
|
|
nsGenericHTMLFormElement::MapImageAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
|
1999-07-07 01:24:40 +00:00
|
|
|
{
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-16 20:54:20 +00:00
|
|
|
sCommonAttributeMap,
|
2003-07-11 21:16:12 +00:00
|
|
|
sImageMarginSizeAttributeMap,
|
2003-04-16 20:54:20 +00:00
|
|
|
sImageBorderAttributeMap,
|
|
|
|
sImageAlignAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 01:24:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::GetAttributeMappingFunction() const
|
1998-09-01 01:31:20 +00:00
|
|
|
{
|
2005-01-12 19:45:38 +00:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-01 01:31:20 +00:00
|
|
|
}
|
2005-09-18 18:05:40 +00:00
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
void
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::StartObjectLoad(bool aNotify)
|
2005-09-21 19:14:30 +00:00
|
|
|
{
|
2012-07-06 00:56:25 +00:00
|
|
|
// BindToTree can call us asynchronously, and we may be removed from the tree
|
|
|
|
// in the interim
|
2015-02-24 14:41:43 +00:00
|
|
|
if (!IsInComposedDoc() || !OwnerDoc()->IsActive()) {
|
2012-07-06 00:56:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
LoadObject(aNotify);
|
2011-10-17 14:59:28 +00:00
|
|
|
SetIsNetworkCreated(false);
|
2005-09-21 19:14:30 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 04:18:36 +00:00
|
|
|
EventStates
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::IntrinsicState() const
|
2005-09-18 18:05:40 +00:00
|
|
|
{
|
2005-09-21 19:14:30 +00:00
|
|
|
return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
|
|
|
|
}
|
2005-09-18 18:05:40 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::GetCapabilities() const
|
2005-09-21 19:14:30 +00:00
|
|
|
{
|
|
|
|
return nsObjectLoadingContent::GetCapabilities() | eSupportClassID;
|
|
|
|
}
|
2007-12-05 07:11:00 +00:00
|
|
|
|
|
|
|
void
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::DestroyContent()
|
2007-12-05 07:11:00 +00:00
|
|
|
{
|
2012-07-05 21:07:46 +00:00
|
|
|
nsObjectLoadingContent::DestroyContent();
|
2007-12-05 07:11:00 +00:00
|
|
|
nsGenericHTMLFormElement::DestroyContent();
|
|
|
|
}
|
2009-12-11 04:02:13 +00:00
|
|
|
|
|
|
|
nsresult
|
2013-01-06 18:43:40 +00:00
|
|
|
HTMLObjectElement::CopyInnerTo(Element* aDest)
|
2009-12-11 04:02:13 +00:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::CopyInnerTo(aDest);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-18 10:53:36 +00:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2013-01-06 18:43:40 +00:00
|
|
|
CreateStaticClone(static_cast<HTMLObjectElement*>(aDest));
|
2009-12-11 04:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2013-01-06 18:43:40 +00:00
|
|
|
|
2013-01-06 23:55:14 +00:00
|
|
|
JSObject*
|
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 14:13:33 +00:00
|
|
|
HTMLObjectElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-06 23:55:14 +00:00
|
|
|
{
|
2013-05-02 09:12:45 +00:00
|
|
|
JS::Rooted<JSObject*> obj(aCx,
|
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 14:13:33 +00:00
|
|
|
HTMLObjectElementBinding::Wrap(aCx, this, aGivenProto));
|
2013-01-06 23:55:14 +00:00
|
|
|
if (!obj) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
SetupProtoChain(aCx, obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2013-01-06 18:43:40 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Object)
|