1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : // vim:set et sw=2 sts=2 cin:
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla Communicator client code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 1998
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either of the GNU General Public License Version 2 or later (the "GPL"),
27 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "mozilla/Util.h"
40 :
41 : #include "nsAutoPtr.h"
42 : #include "nsGenericHTMLElement.h"
43 : #include "nsObjectLoadingContent.h"
44 : #include "nsGkAtoms.h"
45 : #include "nsDOMError.h"
46 : #include "nsIDocument.h"
47 : #include "nsIDOMDocument.h"
48 : #include "nsIDOMSVGDocument.h"
49 : #include "nsIDOMGetSVGDocument.h"
50 : #include "nsIDOMHTMLObjectElement.h"
51 : #include "nsFormSubmission.h"
52 : #include "nsIObjectFrame.h"
53 : #include "nsNPAPIPluginInstance.h"
54 : #include "nsIConstraintValidation.h"
55 : #include "nsIWidget.h"
56 :
57 : using namespace mozilla;
58 : using namespace mozilla::dom;
59 :
60 : class nsHTMLObjectElement : public nsGenericHTMLFormElement
61 : , public nsObjectLoadingContent
62 : , public nsIDOMHTMLObjectElement
63 : , public nsIConstraintValidation
64 : , public nsIDOMGetSVGDocument
65 : {
66 : public:
67 : using nsIConstraintValidation::GetValidationMessage;
68 :
69 : nsHTMLObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
70 : mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
71 : virtual ~nsHTMLObjectElement();
72 :
73 : // nsISupports
74 : NS_DECL_ISUPPORTS_INHERITED
75 :
76 : // nsIDOMNode
77 0 : NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::)
78 :
79 : // nsIDOMElement
80 0 : NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::)
81 :
82 : // nsIDOMHTMLElement
83 0 : NS_FORWARD_NSIDOMHTMLELEMENT_BASIC(nsGenericHTMLFormElement::)
84 0 : NS_SCRIPTABLE NS_IMETHOD Click() {
85 0 : return nsGenericHTMLFormElement::Click();
86 : }
87 : NS_SCRIPTABLE NS_IMETHOD GetTabIndex(PRInt32* aTabIndex);
88 : NS_SCRIPTABLE NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
89 0 : NS_SCRIPTABLE NS_IMETHOD Focus() {
90 0 : return nsGenericHTMLFormElement::Focus();
91 : }
92 0 : NS_SCRIPTABLE NS_IMETHOD GetDraggable(bool* aDraggable) {
93 0 : return nsGenericHTMLFormElement::GetDraggable(aDraggable);
94 : }
95 0 : NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) {
96 0 : return nsGenericHTMLFormElement::GetInnerHTML(aInnerHTML);
97 : }
98 0 : NS_SCRIPTABLE NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) {
99 0 : return nsGenericHTMLFormElement::SetInnerHTML(aInnerHTML);
100 : }
101 :
102 : // nsIDOMHTMLObjectElement
103 : NS_DECL_NSIDOMHTMLOBJECTELEMENT
104 :
105 : // nsIDOMGetSVGDocument
106 : NS_DECL_NSIDOMGETSVGDOCUMENT
107 :
108 : virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
109 : nsIContent *aBindingParent,
110 : bool aCompileEventHandlers);
111 : virtual void UnbindFromTree(bool aDeep = true,
112 : bool aNullParent = true);
113 : virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom *aName,
114 : nsIAtom *aPrefix, const nsAString &aValue,
115 : bool aNotify);
116 : virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
117 : bool aNotify);
118 :
119 : virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
120 : virtual IMEState GetDesiredIMEState();
121 :
122 : // Overriden nsIFormControl methods
123 0 : NS_IMETHOD_(PRUint32) GetType() const
124 : {
125 0 : return NS_FORM_OBJECT;
126 : }
127 :
128 : NS_IMETHOD Reset();
129 : NS_IMETHOD SubmitNamesValues(nsFormSubmission *aFormSubmission);
130 :
131 0 : virtual bool IsDisabled() const { return false; }
132 :
133 : virtual void DoneAddingChildren(bool aHaveNotified);
134 : virtual bool IsDoneAddingChildren();
135 :
136 : virtual bool ParseAttribute(PRInt32 aNamespaceID,
137 : nsIAtom *aAttribute,
138 : const nsAString &aValue,
139 : nsAttrValue &aResult);
140 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
141 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const;
142 : virtual nsEventStates IntrinsicState() const;
143 : virtual void DestroyContent();
144 :
145 : // nsObjectLoadingContent
146 : virtual PRUint32 GetCapabilities() const;
147 :
148 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
149 :
150 : nsresult CopyInnerTo(nsGenericElement* aDest) const;
151 :
152 0 : void StartObjectLoad() { StartObjectLoad(true); }
153 :
154 1464 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLObjectElement,
155 : nsGenericHTMLFormElement)
156 :
157 : virtual nsXPCClassInfo* GetClassInfo();
158 : private:
159 : /**
160 : * Calls LoadObject with the correct arguments to start the plugin load.
161 : */
162 : NS_HIDDEN_(void) StartObjectLoad(bool aNotify);
163 :
164 : /**
165 : * Returns if the element is currently focusable regardless of it's tabindex
166 : * value. This is used to know the default tabindex value.
167 : */
168 : bool IsFocusableForTabIndex();
169 :
170 : bool mIsDoneAddingChildren;
171 : };
172 :
173 :
174 0 : NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Object)
175 :
176 :
177 0 : nsHTMLObjectElement::nsHTMLObjectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
178 : FromParser aFromParser)
179 : : nsGenericHTMLFormElement(aNodeInfo),
180 0 : mIsDoneAddingChildren(!aFromParser)
181 : {
182 0 : RegisterFreezableElement();
183 0 : SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
184 :
185 : // <object> is always barred from constraint validation.
186 0 : SetBarredFromConstraintValidation(true);
187 :
188 : // By default we're in the loading state
189 0 : AddStatesSilently(NS_EVENT_STATE_LOADING);
190 0 : }
191 :
192 0 : nsHTMLObjectElement::~nsHTMLObjectElement()
193 : {
194 0 : UnregisterFreezableElement();
195 0 : DestroyImageLoadingContent();
196 0 : }
197 :
198 : bool
199 0 : nsHTMLObjectElement::IsDoneAddingChildren()
200 : {
201 0 : return mIsDoneAddingChildren;
202 : }
203 :
204 : void
205 0 : nsHTMLObjectElement::DoneAddingChildren(bool aHaveNotified)
206 : {
207 0 : mIsDoneAddingChildren = true;
208 :
209 : // If we're already in a document, we need to trigger the load
210 : // Otherwise, BindToTree takes care of that.
211 0 : if (IsInDoc()) {
212 0 : StartObjectLoad(aHaveNotified);
213 : }
214 0 : }
215 :
216 1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLObjectElement)
217 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLObjectElement,
218 : nsGenericHTMLFormElement)
219 0 : nsObjectLoadingContent::Traverse(tmp, cb);
220 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
221 :
222 0 : NS_IMPL_ADDREF_INHERITED(nsHTMLObjectElement, nsGenericElement)
223 0 : NS_IMPL_RELEASE_INHERITED(nsHTMLObjectElement, nsGenericElement)
224 :
225 0 : DOMCI_NODE_DATA(HTMLObjectElement, nsHTMLObjectElement)
226 :
227 0 : NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLObjectElement)
228 : NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(nsHTMLObjectElement)
229 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIDOMHTMLObjectElement)
230 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, imgIDecoderObserver)
231 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIRequestObserver)
232 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIStreamListener)
233 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIFrameLoaderOwner)
234 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIObjectLoadingContent)
235 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIImageLoadingContent)
236 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, imgIContainerObserver)
237 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIInterfaceRequestor)
238 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIChannelEventSink)
239 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIConstraintValidation)
240 : NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIDOMGetSVGDocument)
241 0 : NS_OFFSET_AND_INTERFACE_TABLE_END
242 0 : NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLObjectElement,
243 : nsGenericHTMLFormElement)
244 0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLObjectElement)
245 :
246 0 : NS_IMPL_ELEMENT_CLONE(nsHTMLObjectElement)
247 :
248 : // nsIConstraintValidation
249 0 : NS_IMPL_NSICONSTRAINTVALIDATION(nsHTMLObjectElement)
250 :
251 : NS_IMETHODIMP
252 0 : nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
253 : {
254 0 : return nsGenericHTMLFormElement::GetForm(aForm);
255 : }
256 :
257 : nsresult
258 0 : nsHTMLObjectElement::BindToTree(nsIDocument *aDocument,
259 : nsIContent *aParent,
260 : nsIContent *aBindingParent,
261 : bool aCompileEventHandlers)
262 : {
263 : nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
264 : aBindingParent,
265 0 : aCompileEventHandlers);
266 0 : NS_ENSURE_SUCCESS(rv, rv);
267 :
268 : // If we already have all the children, start the load.
269 0 : if (mIsDoneAddingChildren) {
270 0 : void (nsHTMLObjectElement::*start)() = &nsHTMLObjectElement::StartObjectLoad;
271 0 : nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
272 : }
273 :
274 0 : return NS_OK;
275 : }
276 :
277 : void
278 0 : nsHTMLObjectElement::UnbindFromTree(bool aDeep,
279 : bool aNullParent)
280 : {
281 0 : RemovedFromDocument();
282 0 : nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
283 0 : }
284 :
285 :
286 :
287 : nsresult
288 0 : nsHTMLObjectElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom *aName,
289 : nsIAtom *aPrefix, const nsAString &aValue,
290 : bool aNotify)
291 : {
292 : // If we plan to call LoadObject, we want to do it first so that the
293 : // object load kicks off _before_ the reflow triggered by the SetAttr. But if
294 : // aNotify is false, we are coming from the parser or some such place; we'll
295 : // get bound after all the attributes have been set, so we'll do the
296 : // object load from BindToTree/DoneAddingChildren.
297 : // Skip the LoadObject call in that case.
298 : // We also don't want to start loading the object when we're not yet in
299 : // a document, just in case that the caller wants to set additional
300 : // attributes before inserting the node into the document.
301 0 : if (aNotify && IsInDoc() && mIsDoneAddingChildren &&
302 : aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::data) {
303 0 : nsAutoString type;
304 0 : GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
305 0 : LoadObject(aValue, aNotify, NS_ConvertUTF16toUTF8(type), true);
306 : }
307 :
308 : return nsGenericHTMLFormElement::SetAttr(aNameSpaceID, aName, aPrefix,
309 0 : aValue, aNotify);
310 : }
311 :
312 : nsresult
313 0 : nsHTMLObjectElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
314 : bool aNotify)
315 : {
316 0 : if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::data) {
317 0 : Fallback(aNotify);
318 : }
319 :
320 0 : return nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
321 : }
322 :
323 : bool
324 0 : nsHTMLObjectElement::IsFocusableForTabIndex()
325 : {
326 0 : nsIDocument* doc = GetCurrentDoc();
327 0 : if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
328 0 : return false;
329 : }
330 :
331 0 : return IsEditableRoot() || (Type() == eType_Document &&
332 0 : nsContentUtils::IsSubDocumentTabbable(this));
333 : }
334 :
335 : bool
336 0 : nsHTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
337 : bool *aIsFocusable, PRInt32 *aTabIndex)
338 : {
339 : // TODO: this should probably be managed directly by IsHTMLFocusable.
340 : // See bug 597242.
341 0 : nsIDocument *doc = GetCurrentDoc();
342 0 : if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
343 0 : if (aTabIndex) {
344 0 : GetTabIndex(aTabIndex);
345 : }
346 :
347 0 : *aIsFocusable = false;
348 :
349 0 : return false;
350 : }
351 :
352 : // This method doesn't call nsGenericHTMLFormElement intentionally.
353 : // TODO: It should probably be changed when bug 597242 will be fixed.
354 0 : if (Type() == eType_Plugin || IsEditableRoot() ||
355 0 : (Type() == eType_Document && nsContentUtils::IsSubDocumentTabbable(this))) {
356 : // Has plugin content: let the plugin decide what to do in terms of
357 : // internal focus from mouse clicks
358 0 : if (aTabIndex) {
359 0 : GetTabIndex(aTabIndex);
360 : }
361 :
362 0 : *aIsFocusable = true;
363 :
364 0 : return false;
365 : }
366 :
367 : // TODO: this should probably be managed directly by IsHTMLFocusable.
368 : // See bug 597242.
369 0 : const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(nsGkAtoms::tabindex);
370 :
371 0 : *aIsFocusable = attrVal && attrVal->Type() == nsAttrValue::eInteger;
372 :
373 0 : if (aTabIndex && *aIsFocusable) {
374 0 : *aTabIndex = attrVal->GetIntegerValue();
375 : }
376 :
377 0 : return false;
378 : }
379 :
380 : nsIContent::IMEState
381 0 : nsHTMLObjectElement::GetDesiredIMEState()
382 : {
383 0 : if (Type() == eType_Plugin) {
384 0 : return IMEState(IMEState::PLUGIN);
385 : }
386 :
387 0 : return nsGenericHTMLFormElement::GetDesiredIMEState();
388 : }
389 :
390 : NS_IMETHODIMP
391 0 : nsHTMLObjectElement::Reset()
392 : {
393 0 : return NS_OK;
394 : }
395 :
396 : NS_IMETHODIMP
397 0 : nsHTMLObjectElement::SubmitNamesValues(nsFormSubmission *aFormSubmission)
398 : {
399 0 : nsAutoString name;
400 0 : if (!GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
401 : // No name, don't submit.
402 :
403 0 : return NS_OK;
404 : }
405 :
406 0 : nsIFrame* frame = GetPrimaryFrame();
407 :
408 0 : nsIObjectFrame *objFrame = do_QueryFrame(frame);
409 0 : if (!objFrame) {
410 : // No frame, nothing to submit.
411 :
412 0 : return NS_OK;
413 : }
414 :
415 0 : nsRefPtr<nsNPAPIPluginInstance> pi;
416 0 : objFrame->GetPluginInstance(getter_AddRefs(pi));
417 0 : if (!pi)
418 0 : return NS_OK;
419 :
420 0 : nsAutoString value;
421 0 : nsresult rv = pi->GetFormValue(value);
422 0 : NS_ENSURE_SUCCESS(rv, rv);
423 :
424 0 : return aFormSubmission->AddNameValuePair(name, value);
425 : }
426 :
427 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align)
428 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive)
429 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border)
430 0 : NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLObjectElement, Code, code, codebase)
431 0 : NS_IMPL_URI_ATTR(nsHTMLObjectElement, CodeBase, codebase)
432 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype)
433 0 : NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLObjectElement, Data, data, codebase)
434 0 : NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare)
435 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height)
436 0 : NS_IMPL_INT_ATTR(nsHTMLObjectElement, Hspace, hspace)
437 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Name, name)
438 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Standby, standby)
439 0 : NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLObjectElement, TabIndex, tabindex,
440 : IsFocusableForTabIndex() ? 0 : -1)
441 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Type, type)
442 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, UseMap, usemap)
443 0 : NS_IMPL_INT_ATTR(nsHTMLObjectElement, Vspace, vspace)
444 0 : NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Width, width)
445 :
446 : NS_IMETHODIMP
447 0 : nsHTMLObjectElement::GetContentDocument(nsIDOMDocument **aContentDocument)
448 : {
449 0 : NS_ENSURE_ARG_POINTER(aContentDocument);
450 :
451 0 : *aContentDocument = nsnull;
452 :
453 0 : if (!IsInDoc()) {
454 0 : return NS_OK;
455 : }
456 :
457 : // XXXbz should this use GetCurrentDoc()? sXBL/XBL2 issue!
458 0 : nsIDocument *sub_doc = OwnerDoc()->GetSubDocumentFor(this);
459 0 : if (!sub_doc) {
460 0 : return NS_OK;
461 : }
462 :
463 0 : return CallQueryInterface(sub_doc, aContentDocument);
464 : }
465 :
466 : NS_IMETHODIMP
467 0 : nsHTMLObjectElement::GetSVGDocument(nsIDOMDocument **aResult)
468 : {
469 0 : return GetContentDocument(aResult);
470 : }
471 :
472 : bool
473 0 : nsHTMLObjectElement::ParseAttribute(PRInt32 aNamespaceID,
474 : nsIAtom *aAttribute,
475 : const nsAString &aValue,
476 : nsAttrValue &aResult)
477 : {
478 0 : if (aNamespaceID == kNameSpaceID_None) {
479 0 : if (aAttribute == nsGkAtoms::align) {
480 0 : return ParseAlignValue(aValue, aResult);
481 : }
482 0 : if (ParseImageAttribute(aAttribute, aValue, aResult)) {
483 0 : return true;
484 : }
485 : }
486 :
487 : return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
488 0 : aValue, aResult);
489 : }
490 :
491 : static void
492 0 : MapAttributesIntoRule(const nsMappedAttributes *aAttributes,
493 : nsRuleData *aData)
494 : {
495 0 : nsGenericHTMLFormElement::MapImageAlignAttributeInto(aAttributes, aData);
496 0 : nsGenericHTMLFormElement::MapImageBorderAttributeInto(aAttributes, aData);
497 0 : nsGenericHTMLFormElement::MapImageMarginAttributeInto(aAttributes, aData);
498 0 : nsGenericHTMLFormElement::MapImageSizeAttributesInto(aAttributes, aData);
499 0 : nsGenericHTMLFormElement::MapCommonAttributesInto(aAttributes, aData);
500 0 : }
501 :
502 : NS_IMETHODIMP_(bool)
503 0 : nsHTMLObjectElement::IsAttributeMapped(const nsIAtom *aAttribute) const
504 : {
505 : static const MappedAttributeEntry* const map[] = {
506 : sCommonAttributeMap,
507 : sImageMarginSizeAttributeMap,
508 : sImageBorderAttributeMap,
509 : sImageAlignAttributeMap,
510 : };
511 :
512 0 : return FindAttributeDependence(aAttribute, map);
513 : }
514 :
515 :
516 : nsMapRuleToAttributesFunc
517 0 : nsHTMLObjectElement::GetAttributeMappingFunction() const
518 : {
519 0 : return &MapAttributesIntoRule;
520 : }
521 :
522 : void
523 0 : nsHTMLObjectElement::StartObjectLoad(bool aNotify)
524 : {
525 0 : nsAutoString type;
526 0 : GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
527 0 : NS_ConvertUTF16toUTF8 ctype(type);
528 :
529 0 : nsAutoString uri;
530 0 : if (GetAttr(kNameSpaceID_None, nsGkAtoms::data, uri)) {
531 0 : LoadObject(uri, aNotify, ctype);
532 : }
533 : else {
534 : // Be sure to call the nsIURI version if we have no attribute
535 : // That handles the case where no URI is specified. An empty string would
536 : // get interpreted as the page itself, instead of absence of URI.
537 0 : LoadObject(nsnull, aNotify, ctype);
538 : }
539 0 : SetIsNetworkCreated(false);
540 0 : }
541 :
542 : nsEventStates
543 0 : nsHTMLObjectElement::IntrinsicState() const
544 : {
545 0 : return nsGenericHTMLFormElement::IntrinsicState() | ObjectState();
546 : }
547 :
548 : PRUint32
549 0 : nsHTMLObjectElement::GetCapabilities() const
550 : {
551 0 : return nsObjectLoadingContent::GetCapabilities() | eSupportClassID;
552 : }
553 :
554 : void
555 0 : nsHTMLObjectElement::DestroyContent()
556 : {
557 0 : RemovedFromDocument();
558 0 : nsGenericHTMLFormElement::DestroyContent();
559 0 : }
560 :
561 : nsresult
562 0 : nsHTMLObjectElement::CopyInnerTo(nsGenericElement* aDest) const
563 : {
564 0 : nsresult rv = nsGenericHTMLFormElement::CopyInnerTo(aDest);
565 0 : NS_ENSURE_SUCCESS(rv, rv);
566 :
567 0 : if (aDest->OwnerDoc()->IsStaticDocument()) {
568 0 : CreateStaticClone(static_cast<nsHTMLObjectElement*>(aDest));
569 : }
570 :
571 0 : return rv;
572 4392 : }
|