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"
|
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"
|
2011-05-18 05:48:34 +04:00
|
|
|
#include "nsAutoPtr.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"
|
2002-02-21 05:01:12 +03:00
|
|
|
#include "nsIDocument.h"
|
2012-12-11 04:35:05 +04:00
|
|
|
#include "nsIPluginDocument.h"
|
2002-02-21 05:01:12 +03:00
|
|
|
#include "nsIDOMDocument.h"
|
2010-05-26 16:49:38 +04:00
|
|
|
#include "nsFormSubmission.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 {
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-01-06 22:43:40 +04:00
|
|
|
FromParser aFromParser)
|
2006-05-22 01:00:09 +04:00
|
|
|
: nsGenericHTMLFormElement(aNodeInfo),
|
|
|
|
mIsDoneAddingChildren(!aFromParser)
|
1998-07-14 22:52:27 +04:00
|
|
|
{
|
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()
|
2006-06-01 22:35:21 +04:00
|
|
|
{
|
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-01-20 23:39:28 +03:00
|
|
|
bool
|
2015-03-17 23:42:14 +03:00
|
|
|
HTMLObjectElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
2015-01-20 23:39:28 +03:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::IsDoneAddingChildren()
|
2004-06-02 04:25:00 +04:00
|
|
|
{
|
|
|
|
return mIsDoneAddingChildren;
|
|
|
|
}
|
|
|
|
|
2011-11-16 11:50:18 +04:00
|
|
|
void
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::DoneAddingChildren(bool aHaveNotified)
|
2004-06-02 04:25:00 +04:00
|
|
|
{
|
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()) {
|
2005-09-22 06:33:36 +04:00
|
|
|
StartObjectLoad(aHaveNotified);
|
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
|
|
|
|
2013-01-06 22:43:40 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLObjectElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLObjectElement, Element)
|
|
|
|
|
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLObjectElement)
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_INTERFACE_TABLE_INHERITED(HTMLObjectElement,
|
|
|
|
nsIDOMHTMLObjectElement,
|
|
|
|
imgINotificationObserver,
|
|
|
|
nsIRequestObserver,
|
|
|
|
nsIStreamListener,
|
|
|
|
nsIFrameLoaderOwner,
|
|
|
|
nsIObjectLoadingContent,
|
|
|
|
nsIImageLoadingContent,
|
|
|
|
imgIOnloadBlocker,
|
|
|
|
nsIChannelEventSink,
|
|
|
|
nsIConstraintValidation)
|
2013-08-08 00:23:08 +04:00
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElement)
|
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
|
|
|
|
2010-08-28 04:36:45 +04:00
|
|
|
// nsIConstraintValidation
|
2013-01-06 22:43:40 +04:00
|
|
|
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
|
1998-09-01 05:31:20 +04: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
|
|
|
|
|
|
|
|
class PluginFocusSetter : public nsRunnable
|
2015-03-24 19:41:32 +03:00
|
|
|
{
|
2015-03-25 01:02:52 +03:00
|
|
|
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<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
|
|
|
// 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 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.
|
|
|
|
nsIContent* focusedContent = nullptr;
|
|
|
|
nsFocusManager *fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (fm) {
|
|
|
|
focusedContent = fm->GetFocusedContent();
|
|
|
|
}
|
|
|
|
if (SameCOMIdentity(focusedContent, aElement)) {
|
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 19:37:02 +03:00
|
|
|
void
|
|
|
|
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
|
|
|
|
WidgetEvent* aEvent)
|
|
|
|
{
|
|
|
|
if (!aEvent->mFlags.mIsTrusted) {
|
|
|
|
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
|
|
|
|
|
1998-09-03 03:53:16 +04:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
|
1998-09-03 03:53:16 +04:00
|
|
|
{
|
2004-02-10 22:36:43 +03:00
|
|
|
return nsGenericHTMLFormElement::GetForm(aForm);
|
2002-08-06 12:32:19 +04:00
|
|
|
}
|
|
|
|
|
2012-06-05 03:49:57 +04:00
|
|
|
void
|
2015-02-13 04:27:39 +03:00
|
|
|
HTMLObjectElement::GetItemValueText(DOMString& aValue)
|
2012-06-05 03:49:57 +04:00
|
|
|
{
|
|
|
|
GetData(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::SetItemValueText(const nsAString& aValue)
|
2012-06-05 03:49:57 +04:00
|
|
|
{
|
|
|
|
SetData(aValue);
|
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
nsresult
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::BindToTree(nsIDocument *aDocument,
|
|
|
|
nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
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,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
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;
|
2010-04-21 03:21:35 +04:00
|
|
|
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::UnbindFromTree(bool aDeep,
|
|
|
|
bool aNullParent)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2015-03-25 01:02:52 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// When a page is reloaded (when an nsIDocument'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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
|
|
|
nsIAtom *aPrefix, const nsAString &aValue,
|
|
|
|
bool aNotify)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-07-06 01:07:46 +04: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 23:14:30 +04:00
|
|
|
// object load from BindToTree/DoneAddingChildren.
|
2006-01-01 14:25:43 +03:00
|
|
|
// Skip the LoadObject call in that case.
|
2007-07-21 00:14:38 +04: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 17:41:43 +03:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2007-07-21 00:14:38 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::data) {
|
2012-07-06 01:07:46 +04:00
|
|
|
return LoadObject(aNotify, true);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_OK;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2008-12-12 22:41:11 +03:00
|
|
|
nsresult
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2008-12-12 22:41:11 +03:00
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
nsresult rv = nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID,
|
|
|
|
aAttribute, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// See comment in SetAttr
|
2015-02-24 17:41:43 +03:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2012-07-06 01:07:46 +04:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::data) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-10-08 14:20:20 +04:00
|
|
|
bool
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::IsFocusableForTabIndex()
|
2010-10-08 14:20:20 +04:00
|
|
|
{
|
2014-10-02 23:07:24 +04:00
|
|
|
nsIDocument* 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() ||
|
|
|
|
(Type() == eType_Document &&
|
|
|
|
nsContentUtils::IsSubDocumentTabbable(this));
|
2010-10-08 14:20:20 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
|
|
|
|
bool *aIsFocusable, int32_t *aTabIndex)
|
2005-10-03 23:29:52 +04:00
|
|
|
{
|
2010-10-08 14:20:20 +04:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
2014-10-02 23:07:24 +04:00
|
|
|
nsIDocument *doc = GetComposedDoc();
|
2010-10-08 14:20:20 +04:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
if (aTabIndex) {
|
2012-02-07 16:52:45 +04:00
|
|
|
GetTabIndex(aTabIndex);
|
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() ||
|
|
|
|
(Type() == eType_Document && 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) {
|
2012-02-07 16:52:45 +04:00
|
|
|
GetTabIndex(aTabIndex);
|
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.
|
|
|
|
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(nsGkAtoms::tabindex);
|
|
|
|
|
|
|
|
*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
|
|
|
}
|
|
|
|
|
2011-11-27 15:51:53 +04:00
|
|
|
nsIContent::IMEState
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::GetDesiredIMEState()
|
2005-11-15 02:55:24 +03:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
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()
|
2002-08-06 12:32:19 +04:00
|
|
|
{
|
1998-09-03 03:53:16 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-08-06 12:32:19 +04:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::SubmitNamesValues(nsFormSubmission *aFormSubmission)
|
2002-08-06 12:32:19 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi;
|
2011-05-18 05:48:34 +04:00
|
|
|
objFrame->GetPluginInstance(getter_AddRefs(pi));
|
2009-07-02 08:52:07 +04:00
|
|
|
if (!pi)
|
2005-03-09 20:01:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
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
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Align, align)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Archive, archive)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLObjectElement, Border, border)
|
|
|
|
NS_IMPL_URI_ATTR_WITH_BASE(HTMLObjectElement, Code, code, codebase)
|
|
|
|
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 05:31:20 +04:00
|
|
|
|
2012-10-06 11:19:51 +04:00
|
|
|
int32_t
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::TabIndexDefault()
|
2012-10-06 11:19:51 +04:00
|
|
|
{
|
|
|
|
return IsFocusableForTabIndex() ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2000-04-19 02:57:42 +04:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
|
2000-04-19 02:57:42 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aContentDocument);
|
2002-02-21 05:01:12 +03:00
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetContentDocument());
|
|
|
|
domDoc.forget(aContentDocument);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-04-05 09:42:10 +04:00
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
nsIDOMWindow*
|
|
|
|
HTMLObjectElement::GetContentWindow()
|
|
|
|
{
|
|
|
|
nsIDocument* doc = GetContentDocument();
|
|
|
|
if (doc) {
|
|
|
|
return doc->GetWindow();
|
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
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
const nsAString &aValue,
|
|
|
|
nsAttrValue &aResult)
|
1998-09-01 05:31:20 +04:00
|
|
|
{
|
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(aNamespaceID, aAttribute,
|
|
|
|
aValue, aResult);
|
1998-09-01 05:31:20 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void
|
|
|
|
HTMLObjectElement::MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
|
|
|
|
nsRuleData *aData)
|
1998-09-05 08:00:06 +04:00
|
|
|
{
|
2004-02-10 22:36:43 +03:00
|
|
|
nsGenericHTMLFormElement::MapImageAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
|
1999-07-07 05:24:40 +04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::GetAttributeMappingFunction() const
|
1998-09-01 05:31:20 +04:00
|
|
|
{
|
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
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
void
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::StartObjectLoad(bool aNotify)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-07-06 04:56:25 +04:00
|
|
|
// BindToTree can call us asynchronously, and we may be removed from the tree
|
|
|
|
// in the interim
|
2015-02-24 17:41:43 +03:00
|
|
|
if (!IsInComposedDoc() || !OwnerDoc()->IsActive()) {
|
2012-07-06 04:56:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
LoadObject(aNotify);
|
2011-10-17 18:59:28 +04:00
|
|
|
SetIsNetworkCreated(false);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::IntrinsicState() const
|
2005-09-18 22:05:40 +04:00
|
|
|
{
|
2005-09-21 23:14:30 +04:00
|
|
|
return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
|
|
|
|
}
|
2005-09-18 22:05:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::GetCapabilities() const
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
|
|
|
return nsObjectLoadingContent::GetCapabilities() | eSupportClassID;
|
|
|
|
}
|
2007-12-05 10:11:00 +03:00
|
|
|
|
|
|
|
void
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::DestroyContent()
|
2007-12-05 10:11:00 +03:00
|
|
|
{
|
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
|
|
|
|
|
|
|
nsresult
|
2013-01-06 22:43:40 +04:00
|
|
|
HTMLObjectElement::CopyInnerTo(Element* aDest)
|
2009-12-11 07:02:13 +03:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::CopyInnerTo(aDest);
|
|
|
|
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
|
|
|
|
2013-01-07 03:55:14 +04: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 17:13:33 +03:00
|
|
|
HTMLObjectElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-07 03:55:14 +04:00
|
|
|
{
|
2013-05-02 13:12:45 +04: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 17:13:33 +03:00
|
|
|
HTMLObjectElementBinding::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)
|