2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:set et sw=2 sts=2 cin:
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-04-02 21:18:36 -07:00
|
|
|
#include "mozilla/EventStates.h"
|
2013-03-04 11:08:23 -08:00
|
|
|
#include "mozilla/dom/HTMLObjectElement.h"
|
2013-01-06 15:55:14 -08:00
|
|
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
2013-10-02 13:09:18 -07:00
|
|
|
#include "mozilla/dom/ElementInlines.h"
|
2011-05-17 18:48:34 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocument.h"
|
2012-12-10 16:35:05 -08:00
|
|
|
#include "nsIPluginDocument.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMDocument.h"
|
2010-05-26 05:49:38 -07:00
|
|
|
#include "nsFormSubmission.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIObjectFrame.h"
|
2011-05-17 18:48:34 -07:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2011-11-27 03:51:53 -08:00
|
|
|
#include "nsIWidget.h"
|
2013-01-31 15:11:49 -08:00
|
|
|
#include "nsContentUtils.h"
|
2015-02-20 08:37:02 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "mozilla/EventDispatcher.h"
|
|
|
|
#include "mozilla/dom/Event.h"
|
2015-03-26 17:38:13 -07:00
|
|
|
#include "nsFocusManager.h"
|
2015-02-20 08:37:02 -08:00
|
|
|
#endif
|
2010-08-27 17:36:45 -07:00
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-01-06 10:43:40 -08:00
|
|
|
FromParser aFromParser)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsGenericHTMLFormElement(aNodeInfo),
|
|
|
|
mIsDoneAddingChildren(!aFromParser)
|
|
|
|
{
|
2014-06-18 19:09:35 -07:00
|
|
|
RegisterActivityObserver();
|
2010-10-25 05:17:38 -07:00
|
|
|
SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
|
2010-09-09 22:08:56 -07:00
|
|
|
|
|
|
|
// <object> is always barred from constraint validation.
|
2011-10-17 07:59:28 -07:00
|
|
|
SetBarredFromConstraintValidation(true);
|
2011-05-31 18:46:57 -07:00
|
|
|
|
|
|
|
// By default we're in the loading state
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_LOADING);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::~HTMLObjectElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-03-24 15:02:52 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
OnFocusBlurPlugin(this, false);
|
|
|
|
#endif
|
2014-06-18 19:09:35 -07:00
|
|
|
UnregisterActivityObserver();
|
2007-03-22 10:30:00 -07:00
|
|
|
DestroyImageLoadingContent();
|
|
|
|
}
|
|
|
|
|
2015-01-20 12:39:28 -08:00
|
|
|
bool
|
2015-03-17 13:42:14 -07:00
|
|
|
HTMLObjectElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const
|
2015-01-20 12:39:28 -08:00
|
|
|
{
|
2015-03-23 02:02:33 -07:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap) ||
|
|
|
|
nsGenericHTMLFormElement::IsInteractiveHTMLContent(aIgnoreTabindex);
|
2015-01-20 12:39:28 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::IsDoneAddingChildren()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return mIsDoneAddingChildren;
|
|
|
|
}
|
|
|
|
|
2011-11-15 23:50:18 -08:00
|
|
|
void
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::DoneAddingChildren(bool aHaveNotified)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsDoneAddingChildren = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If we're already in a document, we need to trigger the load
|
|
|
|
// Otherwise, BindToTree takes care of that.
|
2015-02-24 06:41:43 -08:00
|
|
|
if (IsInComposedDoc()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
StartObjectLoad(aHaveNotified);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLObjectElement)
|
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLObjectElement,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericHTMLFormElement)
|
2013-02-01 06:10:08 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
2011-08-28 07:07:24 -07:00
|
|
|
nsObjectLoadingContent::Traverse(tmp, cb);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2013-08-01 18:29:05 -07:00
|
|
|
|
2013-02-01 06:10:08 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLObjectElement,
|
|
|
|
nsGenericHTMLFormElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
2013-09-11 18:57:53 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(HTMLObjectElement, Element)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(HTMLObjectElement, Element)
|
|
|
|
|
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLObjectElement)
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_INTERFACE_TABLE_INHERITED(HTMLObjectElement,
|
|
|
|
nsIDOMHTMLObjectElement,
|
|
|
|
imgINotificationObserver,
|
|
|
|
nsIRequestObserver,
|
|
|
|
nsIStreamListener,
|
|
|
|
nsIFrameLoaderOwner,
|
|
|
|
nsIObjectLoadingContent,
|
|
|
|
nsIImageLoadingContent,
|
|
|
|
imgIOnloadBlocker,
|
|
|
|
nsIChannelEventSink,
|
|
|
|
nsIConstraintValidation)
|
2013-08-07 13:23:08 -07:00
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLFormElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLObjectElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-27 17:36:45 -07:00
|
|
|
// nsIConstraintValidation
|
2013-01-06 10:43:40 -08:00
|
|
|
NS_IMPL_NSICONSTRAINTVALIDATION(HTMLObjectElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-02-20 08:37:02 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
|
|
|
static nsIWidget* GetWidget(Element* aElement)
|
|
|
|
{
|
2015-03-24 15:02:52 -07:00
|
|
|
return nsContentUtils::WidgetForDocument(aElement->OwnerDoc());
|
2015-03-24 10:07:26 -07:00
|
|
|
}
|
2015-03-24 09:41:32 -07:00
|
|
|
|
2015-03-24 15:02:52 -07:00
|
|
|
Element* HTMLObjectElement::sLastFocused = nullptr; // Weak
|
|
|
|
|
|
|
|
class PluginFocusSetter : public nsRunnable
|
2015-03-24 09:41:32 -07:00
|
|
|
{
|
2015-03-24 15:02:52 -07: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-26 17:38:13 -07: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) {
|
|
|
|
olc->GetHasRunningPlugin(&hasRunningPlugin);
|
|
|
|
}
|
|
|
|
if (!hasRunningPlugin) {
|
|
|
|
aFocus = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 15:02:52 -07: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 08:37:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 17:38:13 -07: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 08:37:02 -08:00
|
|
|
void
|
|
|
|
HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
|
|
|
|
WidgetEvent* aEvent)
|
|
|
|
{
|
|
|
|
if (!aEvent->mFlags.mIsTrusted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_FOCUS_CONTENT: {
|
|
|
|
OnFocusBlurPlugin(aElement, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_BLUR_CONTENT: {
|
|
|
|
OnFocusBlurPlugin(aElement, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
|
|
|
{
|
|
|
|
HandleFocusBlurPlugin(this, aVisitor.mEvent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifdef XP_MACOSX
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLFormElement::GetForm(aForm);
|
|
|
|
}
|
|
|
|
|
2012-06-04 16:49:57 -07:00
|
|
|
void
|
2015-02-12 17:27:39 -08:00
|
|
|
HTMLObjectElement::GetItemValueText(DOMString& aValue)
|
2012-06-04 16:49:57 -07:00
|
|
|
{
|
|
|
|
GetData(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::SetItemValueText(const nsAString& aValue)
|
2012-06-04 16:49:57 -07:00
|
|
|
{
|
|
|
|
SetData(aValue);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::BindToTree(nsIDocument *aDocument,
|
|
|
|
nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-03-28 08:53:56 -07:00
|
|
|
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-10 16:35:05 -08: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);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// If we already have all the children, start the load.
|
2012-12-10 16:35:05 -08:00
|
|
|
if (mIsDoneAddingChildren && !pluginDoc) {
|
2013-01-06 10:43:40 -08:00
|
|
|
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
|
2010-04-20 16:21:35 -07:00
|
|
|
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::UnbindFromTree(bool aDeep,
|
|
|
|
bool aNullParent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-03-24 15:02:52 -07:00
|
|
|
#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
|
2012-03-28 08:53:56 -07:00
|
|
|
nsObjectLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
|
|
|
nsIAtom *aPrefix, const nsAString &aValue,
|
|
|
|
bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-05 14:07:46 -07: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
|
2007-03-22 10:30:00 -07:00
|
|
|
// object load from BindToTree/DoneAddingChildren.
|
|
|
|
// Skip the LoadObject call in that case.
|
2007-07-20 13:14:38 -07: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 06:41:43 -08:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2007-07-20 13:14:38 -07:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::data) {
|
2012-07-05 14:07:46 -07:00
|
|
|
return LoadObject(aNotify, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-07-05 14:07:46 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-12 11:41:11 -08:00
|
|
|
nsresult
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
bool aNotify)
|
2008-12-12 11:41:11 -08:00
|
|
|
{
|
2012-07-05 14:07:46 -07:00
|
|
|
nsresult rv = nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID,
|
|
|
|
aAttribute, aNotify);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// See comment in SetAttr
|
2015-02-24 06:41:43 -08:00
|
|
|
if (aNotify && IsInComposedDoc() && mIsDoneAddingChildren &&
|
2012-07-05 14:07:46 -07:00
|
|
|
aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::data) {
|
|
|
|
return LoadObject(aNotify, true);
|
2008-12-12 11:41:11 -08:00
|
|
|
}
|
|
|
|
|
2012-07-05 14:07:46 -07:00
|
|
|
return NS_OK;
|
2008-12-12 11:41:11 -08:00
|
|
|
}
|
|
|
|
|
2010-10-08 03:20:20 -07:00
|
|
|
bool
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::IsFocusableForTabIndex()
|
2010-10-08 03:20:20 -07:00
|
|
|
{
|
2014-10-02 12:07:24 -07:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
2010-10-08 03:20:20 -07:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-10 15:30:15 -08:00
|
|
|
return IsEditableRoot() ||
|
|
|
|
(Type() == eType_Document &&
|
|
|
|
nsContentUtils::IsSubDocumentTabbable(this));
|
2010-10-08 03:20:20 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
|
|
|
|
bool *aIsFocusable, int32_t *aTabIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-10-08 03:20:20 -07:00
|
|
|
// TODO: this should probably be managed directly by IsHTMLFocusable.
|
|
|
|
// See bug 597242.
|
2014-10-02 12:07:24 -07:00
|
|
|
nsIDocument *doc = GetComposedDoc();
|
2010-10-08 03:20:20 -07:00
|
|
|
if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
|
|
|
|
if (aTabIndex) {
|
2012-02-07 04:52:45 -08:00
|
|
|
GetTabIndex(aTabIndex);
|
2010-10-08 03:20:20 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
*aIsFocusable = false;
|
2010-10-08 03:20:20 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-10-08 03:20:20 -07: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))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Has plugin content: let the plugin decide what to do in terms of
|
|
|
|
// internal focus from mouse clicks
|
|
|
|
if (aTabIndex) {
|
2012-02-07 04:52:45 -08:00
|
|
|
GetTabIndex(aTabIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-10-08 03:20:20 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
*aIsFocusable = true;
|
2008-04-15 11:40:38 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-10-08 03:20:20 -07: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 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-27 03:51:53 -08:00
|
|
|
nsIContent::IMEState
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::GetDesiredIMEState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (Type() == eType_Plugin) {
|
2011-11-27 03:51:53 -08:00
|
|
|
return IMEState(IMEState::PLUGIN);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLFormElement::GetDesiredIMEState();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::Reset()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::SubmitNamesValues(nsFormSubmission *aFormSubmission)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
|
|
|
|
// No name, don't submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIObjectFrame *objFrame = do_QueryFrame(frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!objFrame) {
|
|
|
|
// No frame, nothing to submit.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsRefPtr<nsNPAPIPluginInstance> pi;
|
|
|
|
objFrame->GetPluginInstance(getter_AddRefs(pi));
|
2009-07-01 21:52:07 -07:00
|
|
|
if (!pi)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsAutoString value;
|
2009-07-01 21:52:07 -07:00
|
|
|
nsresult rv = pi->GetFormValue(value);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-02-24 21:58:16 -08:00
|
|
|
return aFormSubmission->AddNameValuePair(name, value);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-06 10:43:40 -08: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)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-06 00:19:51 -07:00
|
|
|
int32_t
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::TabIndexDefault()
|
2012-10-06 00:19:51 -07:00
|
|
|
{
|
|
|
|
return IsFocusableForTabIndex() ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aContentDocument);
|
|
|
|
|
2013-03-04 11:08:24 -08:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetContentDocument());
|
|
|
|
domDoc.forget(aContentDocument);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-04 11:08:24 -08:00
|
|
|
nsIDOMWindow*
|
|
|
|
HTMLObjectElement::GetContentWindow()
|
|
|
|
{
|
|
|
|
nsIDocument* doc = GetContentDocument();
|
|
|
|
if (doc) {
|
|
|
|
return doc->GetWindow();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-04 11:08:24 -08:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
const nsAString &aValue,
|
|
|
|
nsAttrValue &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
|
|
|
return ParseAlignValue(aValue, aResult);
|
|
|
|
}
|
|
|
|
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
|
|
|
|
aValue, aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLObjectElement::MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
|
|
|
|
nsRuleData *aData)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsGenericHTMLFormElement::MapImageAlignAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLFormElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sCommonAttributeMap,
|
|
|
|
sImageMarginSizeAttributeMap,
|
|
|
|
sImageBorderAttributeMap,
|
|
|
|
sImageAlignAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::StartObjectLoad(bool aNotify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-05 17:56:25 -07:00
|
|
|
// BindToTree can call us asynchronously, and we may be removed from the tree
|
|
|
|
// in the interim
|
2015-02-24 06:41:43 -08:00
|
|
|
if (!IsInComposedDoc() || !OwnerDoc()->IsActive()) {
|
2012-07-05 17:56:25 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-05 14:07:46 -07:00
|
|
|
LoadObject(aNotify);
|
2011-10-17 07:59:28 -07:00
|
|
|
SetIsNetworkCreated(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-04-02 21:18:36 -07:00
|
|
|
EventStates
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::IntrinsicState() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::GetCapabilities() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsObjectLoadingContent::GetCapabilities() | eSupportClassID;
|
|
|
|
}
|
2007-12-04 23:11:00 -08:00
|
|
|
|
|
|
|
void
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::DestroyContent()
|
2007-12-04 23:11:00 -08:00
|
|
|
{
|
2012-07-05 14:07:46 -07:00
|
|
|
nsObjectLoadingContent::DestroyContent();
|
2007-12-04 23:11:00 -08:00
|
|
|
nsGenericHTMLFormElement::DestroyContent();
|
|
|
|
}
|
2009-12-10 20:02:13 -08:00
|
|
|
|
|
|
|
nsresult
|
2013-01-06 10:43:40 -08:00
|
|
|
HTMLObjectElement::CopyInnerTo(Element* aDest)
|
2009-12-10 20:02:13 -08:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLFormElement::CopyInnerTo(aDest);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-18 03:53:36 -07:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2013-01-06 10:43:40 -08:00
|
|
|
CreateStaticClone(static_cast<HTMLObjectElement*>(aDest));
|
2009-12-10 20:02:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2013-01-06 10:43:40 -08:00
|
|
|
|
2013-01-06 15:55:14 -08: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 07:13:33 -07:00
|
|
|
HTMLObjectElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-06 15:55:14 -08:00
|
|
|
{
|
2013-05-02 02:12:45 -07: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 07:13:33 -07:00
|
|
|
HTMLObjectElementBinding::Wrap(aCx, this, aGivenProto));
|
2013-01-06 15:55:14 -08:00
|
|
|
if (!obj) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
SetupProtoChain(aCx, obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2013-01-06 10:43:40 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Object)
|