2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 #include "html_objectimpl.h"
28 #include "CSSPropertyNames.h"
29 #include "CSSValueKeywords.h"
30 #include "DeprecatedString.h"
31 #include "EventNames.h"
33 #include "HTMLDocument.h"
34 #include "HTMLFormElement.h"
35 #include "HTMLNames.h"
36 #include "PlatformString.h"
37 #include "RenderApplet.h"
38 #include "RenderEmptyApplet.h"
39 #include "RenderImage.h"
41 #include "csshelper.h"
42 #include "cssstyleselector.h"
43 #include "dom2_eventsimpl.h"
44 #include "html_imageimpl.h"
45 #include "render_frames.h"
49 using namespace EventNames;
50 using namespace HTMLNames;
52 // -------------------------------------------------------------------------
54 HTMLAppletElement::HTMLAppletElement(Document *doc)
55 : HTMLElement(appletTag, doc)
56 , m_allParamsAvailable(false)
60 HTMLAppletElement::~HTMLAppletElement()
63 // m_appletInstance should have been cleaned up in detach().
64 assert(!m_appletInstance);
68 bool HTMLAppletElement::checkDTD(const Node* newChild)
70 return newChild->hasTagName(paramTag) || HTMLElement::checkDTD(newChild);
73 bool HTMLAppletElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
75 if (attrName == widthAttr ||
76 attrName == heightAttr ||
77 attrName == vspaceAttr ||
78 attrName == hspaceAttr) {
83 if (attrName == alignAttr) {
84 result = eReplaced; // Share with <img> since the alignment behavior is the same.
88 return HTMLElement::mapToEntry(attrName, result);
91 void HTMLAppletElement::parseMappedAttribute(MappedAttribute *attr)
93 if (attr->name() == altAttr ||
94 attr->name() == archiveAttr ||
95 attr->name() == codeAttr ||
96 attr->name() == codebaseAttr ||
97 attr->name() == mayscriptAttr ||
98 attr->name() == objectAttr) {
100 } else if (attr->name() == widthAttr) {
101 addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
102 } else if (attr->name() == heightAttr) {
103 addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
104 } else if (attr->name() == vspaceAttr) {
105 addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
106 addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
107 } else if (attr->name() == hspaceAttr) {
108 addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
109 addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
110 } else if (attr->name() == alignAttr) {
111 addHTMLAlignment(attr);
112 } else if (attr->name() == nameAttr) {
113 String newNameAttr = attr->value();
114 if (inDocument() && document()->isHTMLDocument()) {
115 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
116 doc->removeNamedItem(oldNameAttr);
117 doc->addNamedItem(newNameAttr);
119 oldNameAttr = newNameAttr;
120 } else if (attr->name() == idAttr) {
121 String newIdAttr = attr->value();
122 if (inDocument() && document()->isHTMLDocument()) {
123 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
124 doc->removeDocExtraNamedItem(oldIdAttr);
125 doc->addDocExtraNamedItem(newIdAttr);
127 oldIdAttr = newIdAttr;
128 // also call superclass
129 HTMLElement::parseMappedAttribute(attr);
131 HTMLElement::parseMappedAttribute(attr);
134 void HTMLAppletElement::insertedIntoDocument()
136 if (document()->isHTMLDocument()) {
137 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
138 doc->addNamedItem(oldNameAttr);
139 doc->addDocExtraNamedItem(oldIdAttr);
142 HTMLElement::insertedIntoDocument();
145 void HTMLAppletElement::removedFromDocument()
147 if (document()->isHTMLDocument()) {
148 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
149 doc->removeNamedItem(oldNameAttr);
150 doc->removeDocExtraNamedItem(oldIdAttr);
153 HTMLElement::removedFromDocument();
156 bool HTMLAppletElement::rendererIsNeeded(RenderStyle *style)
158 return !getAttribute(codeAttr).isNull();
161 RenderObject *HTMLAppletElement::createRenderer(RenderArena *arena, RenderStyle *style)
163 Frame *frame = document()->frame();
165 if (frame && frame->javaEnabled()) {
166 HashMap<String, String> args;
168 args.set("code", getAttribute(codeAttr));
169 const AtomicString& codeBase = getAttribute(codebaseAttr);
170 if(!codeBase.isNull())
171 args.set("codeBase", codeBase);
172 const AtomicString& name = getAttribute(document()->htmlMode() != Document::XHtml ? nameAttr : idAttr);
174 args.set("name", name);
175 const AtomicString& archive = getAttribute(archiveAttr);
176 if (!archive.isNull())
177 args.set("archive", archive);
179 args.set("baseURL", document()->baseURL());
181 const AtomicString& mayScript = getAttribute(mayscriptAttr);
182 if (!mayScript.isNull())
183 args.set("mayScript", mayScript);
185 // Other arguments (from <PARAM> tags) are added later.
187 return new (document()->renderArena()) RenderApplet(this, args);
190 // ### remove me. we should never show an empty applet, instead
191 // render the alternative content given by the webpage
192 return new (document()->renderArena()) RenderEmptyApplet(this);
196 KJS::Bindings::Instance *HTMLAppletElement::getAppletInstance() const
198 Frame *frame = document()->frame();
199 if (!frame || !frame->javaEnabled())
202 if (m_appletInstance)
203 return m_appletInstance.get();
205 RenderApplet *r = static_cast<RenderApplet*>(renderer());
207 r->createWidgetIfNecessary();
209 // Call into the frame (and over the bridge) to pull the Bindings::Instance
210 // from the guts of the plugin.
211 m_appletInstance = frame->getAppletInstanceForWidget(r->widget());
213 return m_appletInstance.get();
217 void HTMLAppletElement::closeRenderer()
219 // The parser just reached </applet>, so all the params are available now.
220 m_allParamsAvailable = true;
222 renderer()->setNeedsLayout(true); // This will cause it to create its widget & the Java applet
223 HTMLElement::closeRenderer();
226 void HTMLAppletElement::detach()
229 m_appletInstance = 0;
231 HTMLElement::detach();
234 bool HTMLAppletElement::allParamsAvailable()
236 return m_allParamsAvailable;
239 String HTMLAppletElement::align() const
241 return getAttribute(alignAttr);
244 void HTMLAppletElement::setAlign(const String &value)
246 setAttribute(alignAttr, value);
249 String HTMLAppletElement::alt() const
251 return getAttribute(altAttr);
254 void HTMLAppletElement::setAlt(const String &value)
256 setAttribute(altAttr, value);
259 String HTMLAppletElement::archive() const
261 return getAttribute(archiveAttr);
264 void HTMLAppletElement::setArchive(const String &value)
266 setAttribute(archiveAttr, value);
269 String HTMLAppletElement::code() const
271 return getAttribute(codeAttr);
274 void HTMLAppletElement::setCode(const String &value)
276 setAttribute(codeAttr, value);
279 String HTMLAppletElement::codeBase() const
281 return getAttribute(codebaseAttr);
284 void HTMLAppletElement::setCodeBase(const String &value)
286 setAttribute(codebaseAttr, value);
289 String HTMLAppletElement::height() const
291 return getAttribute(heightAttr);
294 void HTMLAppletElement::setHeight(const String &value)
296 setAttribute(heightAttr, value);
299 String HTMLAppletElement::hspace() const
301 return getAttribute(hspaceAttr);
304 void HTMLAppletElement::setHspace(const String &value)
306 setAttribute(hspaceAttr, value);
309 String HTMLAppletElement::name() const
311 return getAttribute(nameAttr);
314 void HTMLAppletElement::setName(const String &value)
316 setAttribute(nameAttr, value);
319 String HTMLAppletElement::object() const
321 return getAttribute(objectAttr);
324 void HTMLAppletElement::setObject(const String &value)
326 setAttribute(objectAttr, value);
329 String HTMLAppletElement::vspace() const
331 return getAttribute(vspaceAttr);
334 void HTMLAppletElement::setVspace(const String &value)
336 setAttribute(vspaceAttr, value);
339 String HTMLAppletElement::width() const
341 return getAttribute(widthAttr);
344 void HTMLAppletElement::setWidth(const String &value)
346 setAttribute(widthAttr, value);
349 // -------------------------------------------------------------------------
351 HTMLEmbedElement::HTMLEmbedElement(Document *doc)
352 : HTMLElement(embedTag, doc)
356 HTMLEmbedElement::~HTMLEmbedElement()
359 // m_embedInstance should have been cleaned up in detach().
360 assert(!m_embedInstance);
364 bool HTMLEmbedElement::checkDTD(const Node* newChild)
366 return newChild->hasTagName(paramTag) || HTMLElement::checkDTD(newChild);
370 KJS::Bindings::Instance *HTMLEmbedElement::getEmbedInstance() const
372 Frame *frame = document()->frame();
377 return m_embedInstance.get();
379 RenderObject *r = renderer();
381 Node *p = parentNode();
382 if (p && p->hasTagName(objectTag))
386 if (r && r->isWidget()){
387 if (Widget *widget = static_cast<RenderWidget *>(r)->widget()) {
388 // Call into the frame (and over the bridge) to pull the Bindings::Instance
389 // from the guts of the Java VM.
390 m_embedInstance = frame->getEmbedInstanceForWidget(widget);
391 // Applet may specified with <embed> tag.
392 if (!m_embedInstance)
393 m_embedInstance = frame->getAppletInstanceForWidget(widget);
396 return m_embedInstance.get();
400 bool HTMLEmbedElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
402 if (attrName == widthAttr ||
403 attrName == heightAttr ||
404 attrName == borderAttr ||
405 attrName == vspaceAttr ||
406 attrName == hspaceAttr ||
407 attrName == valignAttr ||
408 attrName == hiddenAttr) {
413 if (attrName == alignAttr) {
414 result = eReplaced; // Share with <img> since the alignment behavior is the same.
418 return HTMLElement::mapToEntry(attrName, result);
421 void HTMLEmbedElement::parseMappedAttribute(MappedAttribute *attr)
423 DeprecatedString val = attr->value().deprecatedString();
426 if (attr->name() == typeAttr) {
427 serviceType = val.lower();
428 pos = serviceType.find( ";" );
430 serviceType = serviceType.left( pos );
431 } else if (attr->name() == codeAttr ||
432 attr->name() == srcAttr) {
433 url = WebCore::parseURL(attr->value()).deprecatedString();
434 } else if (attr->name() == widthAttr) {
435 addCSSLength( attr, CSS_PROP_WIDTH, attr->value() );
436 } else if (attr->name() == heightAttr) {
437 addCSSLength( attr, CSS_PROP_HEIGHT, attr->value());
438 } else if (attr->name() == borderAttr) {
439 addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value());
440 addCSSProperty( attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID );
441 addCSSProperty( attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID );
442 addCSSProperty( attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID );
443 addCSSProperty( attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID );
444 } else if (attr->name() == vspaceAttr) {
445 addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
446 addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
447 } else if (attr->name() == hspaceAttr) {
448 addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
449 addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
450 } else if (attr->name() == alignAttr) {
451 addHTMLAlignment(attr);
452 } else if (attr->name() == valignAttr) {
453 addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
454 } else if (attr->name() == pluginpageAttr ||
455 attr->name() == pluginspageAttr) {
457 } else if (attr->name() == hiddenAttr) {
458 if (val.lower()=="yes" || val.lower()=="true") {
459 // FIXME: Not dynamic, but it's not really important that such a rarely-used
460 // feature work dynamically.
461 addCSSLength( attr, CSS_PROP_WIDTH, "0" );
462 addCSSLength( attr, CSS_PROP_HEIGHT, "0" );
464 } else if (attr->name() == nameAttr) {
465 String newNameAttr = attr->value();
466 if (inDocument() && document()->isHTMLDocument()) {
467 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
468 doc->removeNamedItem(oldNameAttr);
469 doc->addNamedItem(newNameAttr);
471 oldNameAttr = newNameAttr;
473 HTMLElement::parseMappedAttribute(attr);
476 bool HTMLEmbedElement::rendererIsNeeded(RenderStyle *style)
478 Frame *frame = document()->frame();
479 if (!frame || !frame->pluginsEnabled())
482 Node *p = parentNode();
483 if (p && p->hasTagName(objectTag)) {
484 assert(p->renderer());
491 RenderObject *HTMLEmbedElement::createRenderer(RenderArena *arena, RenderStyle *style)
493 return new (arena) RenderPartObject(this);
496 void HTMLEmbedElement::attach()
498 HTMLElement::attach();
501 static_cast<RenderPartObject*>(renderer())->updateWidget();
504 void HTMLEmbedElement::detach()
509 HTMLElement::detach();
512 void HTMLEmbedElement::insertedIntoDocument()
514 if (document()->isHTMLDocument()) {
515 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
516 doc->addNamedItem(oldNameAttr);
519 HTMLElement::insertedIntoDocument();
522 void HTMLEmbedElement::removedFromDocument()
524 if (document()->isHTMLDocument()) {
525 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
526 doc->removeNamedItem(oldNameAttr);
529 HTMLElement::removedFromDocument();
532 bool HTMLEmbedElement::isURLAttribute(Attribute *attr) const
534 return attr->name() == srcAttr;
537 // -------------------------------------------------------------------------
539 HTMLObjectElement::HTMLObjectElement(Document *doc)
540 : HTMLElement(objectTag, doc)
543 needWidgetUpdate = false;
544 m_useFallbackContent = false;
546 m_docNamedItem = true;
549 HTMLObjectElement::~HTMLObjectElement()
552 // m_objectInstance should have been cleaned up in detach().
553 assert(!m_objectInstance);
556 delete m_imageLoader;
559 bool HTMLObjectElement::checkDTD(const Node* newChild)
561 return newChild->hasTagName(paramTag) || HTMLElement::checkDTD(newChild);
565 KJS::Bindings::Instance *HTMLObjectElement::getObjectInstance() const
567 Frame *frame = document()->frame();
571 if (m_objectInstance)
572 return m_objectInstance.get();
574 if (RenderObject *r = renderer()) {
576 if (Widget *widget = static_cast<RenderWidget *>(r)->widget()) {
577 // Call into the frame (and over the bridge) to pull the Bindings::Instance
578 // from the guts of the plugin.
579 m_objectInstance = frame->getObjectInstanceForWidget(widget);
580 // Applet may specified with <object> tag.
581 if (!m_objectInstance)
582 m_objectInstance = frame->getAppletInstanceForWidget(widget);
587 return m_objectInstance.get();
591 HTMLFormElement *HTMLObjectElement::form() const
593 for (Node *p = parentNode(); p != 0; p = p->parentNode()) {
594 if (p->hasTagName(formTag))
595 return static_cast<HTMLFormElement *>(p);
601 bool HTMLObjectElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
603 if (attrName == widthAttr ||
604 attrName == heightAttr ||
605 attrName == vspaceAttr ||
606 attrName == hspaceAttr) {
611 if (attrName == alignAttr) {
612 result = eReplaced; // Share with <img> since the alignment behavior is the same.
616 return HTMLElement::mapToEntry(attrName, result);
619 void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
621 String val = attr->value();
623 if (attr->name() == typeAttr) {
624 serviceType = val.deprecatedString().lower();
625 pos = serviceType.find( ";" );
627 serviceType = serviceType.left( pos );
629 needWidgetUpdate = true;
630 if (!isImageType() && m_imageLoader) {
631 delete m_imageLoader;
634 } else if (attr->name() == dataAttr) {
635 url = WebCore::parseURL(val).deprecatedString();
637 needWidgetUpdate = true;
638 if (renderer() && isImageType()) {
640 m_imageLoader = new HTMLImageLoader(this);
641 m_imageLoader->updateFromElement();
643 } else if (attr->name() == widthAttr) {
644 addCSSLength( attr, CSS_PROP_WIDTH, attr->value());
645 } else if (attr->name() == heightAttr) {
646 addCSSLength( attr, CSS_PROP_HEIGHT, attr->value());
647 } else if (attr->name() == vspaceAttr) {
648 addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
649 addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
650 } else if (attr->name() == hspaceAttr) {
651 addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
652 addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
653 } else if (attr->name() == alignAttr) {
654 addHTMLAlignment(attr);
655 } else if (attr->name() == classidAttr) {
658 needWidgetUpdate = true;
659 } else if (attr->name() == onloadAttr) {
660 setHTMLEventListener(loadEvent, attr);
661 } else if (attr->name() == onunloadAttr) {
662 setHTMLEventListener(unloadEvent, attr);
663 } else if (attr->name() == nameAttr) {
664 String newNameAttr = attr->value();
665 if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
666 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
667 doc->removeNamedItem(oldNameAttr);
668 doc->addNamedItem(newNameAttr);
670 oldNameAttr = newNameAttr;
671 } else if (attr->name() == idAttr) {
672 String newIdAttr = attr->value();
673 if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
674 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
675 doc->removeDocExtraNamedItem(oldIdAttr);
676 doc->addDocExtraNamedItem(newIdAttr);
678 oldIdAttr = newIdAttr;
679 // also call superclass
680 HTMLElement::parseMappedAttribute(attr);
682 HTMLElement::parseMappedAttribute(attr);
685 Document* HTMLObjectElement::contentDocument() const
691 bool HTMLObjectElement::rendererIsNeeded(RenderStyle *style)
693 if (m_useFallbackContent || isImageType())
694 return HTMLElement::rendererIsNeeded(style);
696 Frame *frame = document()->frame();
697 if (!frame || !frame->pluginsEnabled())
703 RenderObject *HTMLObjectElement::createRenderer(RenderArena *arena, RenderStyle *style)
705 if (m_useFallbackContent)
706 return RenderObject::createObject(this, style);
708 return new (arena) RenderImage(this);
709 return new (arena) RenderPartObject(this);
712 void HTMLObjectElement::attach()
714 HTMLElement::attach();
716 if (renderer() && !m_useFallbackContent) {
719 m_imageLoader = new HTMLImageLoader(this);
720 m_imageLoader->updateFromElement();
722 RenderImage* imageObj = static_cast<RenderImage*>(renderer());
723 imageObj->setCachedImage(m_imageLoader->image());
726 if (needWidgetUpdate) {
727 // Set needWidgetUpdate to false before calling updateWidget because updateWidget may cause
728 // this method or recalcStyle (which also calls updateWidget) to be called.
729 needWidgetUpdate = false;
730 static_cast<RenderPartObject*>(renderer())->updateWidget();
732 needWidgetUpdate = true;
739 void HTMLObjectElement::closeRenderer()
741 // The parser just reached </object>.
744 HTMLElement::closeRenderer();
747 void HTMLObjectElement::setComplete(bool complete)
749 if (complete != m_complete) {
750 m_complete = complete;
751 if (complete && inDocument() && !m_useFallbackContent) {
752 needWidgetUpdate = true;
758 void HTMLObjectElement::detach()
760 if (attached() && renderer() && !m_useFallbackContent) {
761 // Update the widget the next time we attach (detaching destroys the plugin).
762 needWidgetUpdate = true;
766 m_objectInstance = 0;
768 HTMLElement::detach();
771 void HTMLObjectElement::insertedIntoDocument()
773 if (isDocNamedItem() && document()->isHTMLDocument()) {
774 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
775 doc->addNamedItem(oldNameAttr);
776 doc->addDocExtraNamedItem(oldIdAttr);
779 HTMLElement::insertedIntoDocument();
782 void HTMLObjectElement::removedFromDocument()
784 if (isDocNamedItem() && document()->isHTMLDocument()) {
785 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
786 doc->removeNamedItem(oldNameAttr);
787 doc->removeDocExtraNamedItem(oldIdAttr);
790 HTMLElement::removedFromDocument();
793 void HTMLObjectElement::recalcStyle(StyleChange ch)
795 if (!m_useFallbackContent && needWidgetUpdate && renderer() && !isImageType()) {
799 HTMLElement::recalcStyle(ch);
802 void HTMLObjectElement::childrenChanged()
804 updateDocNamedItem();
805 if (inDocument() && !m_useFallbackContent) {
806 needWidgetUpdate = true;
811 bool HTMLObjectElement::isURLAttribute(Attribute *attr) const
813 return (attr->name() == dataAttr || (attr->name() == usemapAttr && attr->value().domString()[0] != '#'));
816 bool HTMLObjectElement::isImageType()
818 if (serviceType.isEmpty() && url.startsWith("data:")) {
819 // Extract the MIME type from the data URL.
820 int index = url.find(';');
822 index = url.find(',');
826 serviceType = url.mid(5, len);
828 serviceType = "text/plain"; // Data URLs with no MIME type are considered text/plain.
832 return Image::supportsType(serviceType);
835 void HTMLObjectElement::renderFallbackContent()
837 if (m_useFallbackContent)
840 // Mark ourselves as using the fallback content.
841 m_useFallbackContent = true;
843 // Now do a detach and reattach.
844 // FIXME: Style gets recalculated which is suboptimal.
849 void HTMLObjectElement::updateDocNamedItem()
851 // The rule is "<object> elements with no children other than
852 // <param> elements and whitespace can be found by name in a
853 // document, and other <object> elements cannot."
854 bool wasNamedItem = m_docNamedItem;
855 bool isNamedItem = true;
856 Node *child = firstChild();
857 while (child && isNamedItem) {
858 if (child->isElementNode()) {
859 if (!static_cast<Element *>(child)->hasTagName(paramTag))
861 } else if (child->isTextNode()) {
862 if (!static_cast<Text *>(child)->containsOnlyWhitespace())
866 child = child->nextSibling();
868 if (isNamedItem != wasNamedItem && document()->isHTMLDocument()) {
869 HTMLDocument *doc = static_cast<HTMLDocument *>(document());
871 doc->addNamedItem(oldNameAttr);
872 doc->addDocExtraNamedItem(oldIdAttr);
874 doc->removeNamedItem(oldNameAttr);
875 doc->removeDocExtraNamedItem(oldIdAttr);
878 m_docNamedItem = isNamedItem;
881 String HTMLObjectElement::code() const
883 return getAttribute(codeAttr);
886 void HTMLObjectElement::setCode(const String &value)
888 setAttribute(codeAttr, value);
891 String HTMLObjectElement::align() const
893 return getAttribute(alignAttr);
896 void HTMLObjectElement::setAlign(const String &value)
898 setAttribute(alignAttr, value);
901 String HTMLObjectElement::archive() const
903 return getAttribute(archiveAttr);
906 void HTMLObjectElement::setArchive(const String &value)
908 setAttribute(archiveAttr, value);
911 String HTMLObjectElement::border() const
913 return getAttribute(borderAttr);
916 void HTMLObjectElement::setBorder(const String &value)
918 setAttribute(borderAttr, value);
921 String HTMLObjectElement::codeBase() const
923 return getAttribute(codebaseAttr);
926 void HTMLObjectElement::setCodeBase(const String &value)
928 setAttribute(codebaseAttr, value);
931 String HTMLObjectElement::codeType() const
933 return getAttribute(codetypeAttr);
936 void HTMLObjectElement::setCodeType(const String &value)
938 setAttribute(codetypeAttr, value);
941 String HTMLObjectElement::data() const
943 return getAttribute(dataAttr);
946 void HTMLObjectElement::setData(const String &value)
948 setAttribute(dataAttr, value);
951 bool HTMLObjectElement::declare() const
953 return !getAttribute(declareAttr).isNull();
956 void HTMLObjectElement::setDeclare(bool declare)
958 setAttribute(declareAttr, declare ? "" : 0);
961 String HTMLObjectElement::height() const
963 return getAttribute(heightAttr);
966 void HTMLObjectElement::setHeight(const String &value)
968 setAttribute(heightAttr, value);
971 String HTMLObjectElement::hspace() const
973 return getAttribute(hspaceAttr);
976 void HTMLObjectElement::setHspace(const String &value)
978 setAttribute(hspaceAttr, value);
981 String HTMLObjectElement::name() const
983 return getAttribute(nameAttr);
986 void HTMLObjectElement::setName(const String &value)
988 setAttribute(nameAttr, value);
991 String HTMLObjectElement::standby() const
993 return getAttribute(standbyAttr);
996 void HTMLObjectElement::setStandby(const String &value)
998 setAttribute(standbyAttr, value);
1001 int HTMLObjectElement::tabIndex() const
1003 return getAttribute(tabindexAttr).toInt();
1006 void HTMLObjectElement::setTabIndex(int tabIndex)
1008 setAttribute(tabindexAttr, String::number(tabIndex));
1011 String HTMLObjectElement::type() const
1013 return getAttribute(typeAttr);
1016 void HTMLObjectElement::setType(const String &value)
1018 setAttribute(typeAttr, value);
1021 String HTMLObjectElement::useMap() const
1023 return getAttribute(usemapAttr);
1026 void HTMLObjectElement::setUseMap(const String &value)
1028 setAttribute(usemapAttr, value);
1031 String HTMLObjectElement::vspace() const
1033 return getAttribute(vspaceAttr);
1036 void HTMLObjectElement::setVspace(const String &value)
1038 setAttribute(vspaceAttr, value);
1041 String HTMLObjectElement::width() const
1043 return getAttribute(widthAttr);
1046 void HTMLObjectElement::setWidth(const String &value)
1048 setAttribute(widthAttr, value);
1051 // -------------------------------------------------------------------------
1053 HTMLParamElement::HTMLParamElement(Document *doc)
1054 : HTMLElement(paramTag, doc)
1058 HTMLParamElement::~HTMLParamElement()
1062 void HTMLParamElement::parseMappedAttribute(MappedAttribute *attr)
1064 if (attr->name() == idAttr) {
1065 // Must call base class so that hasID bit gets set.
1066 HTMLElement::parseMappedAttribute(attr);
1067 if (document()->htmlMode() != Document::XHtml)
1069 m_name = attr->value();
1070 } else if (attr->name() == nameAttr) {
1071 m_name = attr->value();
1072 } else if (attr->name() == valueAttr) {
1073 m_value = attr->value();
1075 HTMLElement::parseMappedAttribute(attr);
1078 bool HTMLParamElement::isURLAttribute(Attribute *attr) const
1080 if (attr->name() == valueAttr) {
1081 Attribute *attr = attributes()->getAttributeItem(nameAttr);
1083 String value = attr->value().domString().lower();
1084 if (value == "src" || value == "movie" || value == "data")
1091 void HTMLParamElement::setName(const String &value)
1093 setAttribute(nameAttr, value);
1096 String HTMLParamElement::type() const
1098 return getAttribute(typeAttr);
1101 void HTMLParamElement::setType(const String &value)
1103 setAttribute(typeAttr, value);
1106 void HTMLParamElement::setValue(const String &value)
1108 setAttribute(valueAttr, value);
1111 String HTMLParamElement::valueType() const
1113 return getAttribute(valuetypeAttr);
1116 void HTMLParamElement::setValueType(const String &value)
1118 setAttribute(valuetypeAttr, value);