Diff
Modified: trunk/Source/WebCore/ChangeLog (103637 => 103638)
--- trunk/Source/WebCore/ChangeLog 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/ChangeLog 2011-12-23 21:36:59 UTC (rev 103638)
@@ -1,3 +1,102 @@
+2011-12-21 Andreas Kling <[email protected]>
+
+ Automate elements' registration as document namedItem/extraNamedItem.
+ <http://webkit.org/b/74991>
+
+ Reviewed by Antti Koivisto.
+
+ Remove caching of the "id" and "name" attributes on applet, embed, form,
+ image and object elements. We were caching them to keep the document's
+ map of named and "extra named" (named by id) item counts in sync.
+
+ Instead, add a hook to Element::willModifyAttribute() that detects when
+ the attributes are being changed and handle the registration/unregistration
+ automatically if the element returns true for shouldRegisterAsNamedItem()
+ or shouldRegisterAsExtraNamedItem() respectively.
+
+ This shrinks the elements by two AtomicStrings (8 or 16 bytes) each.
+
+ IFrame elements retain the old mechanism for now, as there are some subtle
+ differences to how that's handled.
+
+ * dom/Node.h:
+ (WebCore::Node::hasName):
+ (WebCore::Node::setHasName):
+
+ Cache whether we have a "name" attribute or not (1 bit on Node.)
+ This is done in order to minimize the overhead added to Element's
+ insertedIntoDocument() and removeFromDocument().
+
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::attributeChanged):
+
+ Update the Node's has-name flag as appropriate.
+
+ * dom/Element.cpp:
+ (WebCore::Element::updateNamedItemRegistration):
+ (WebCore::Element::updateExtraNamedItemRegistration):
+
+ Added. Called when the "name" and "id" attributes are changed.
+ Updates the document's named item maps accordingly.
+
+ (WebCore::Element::insertedIntoDocument):
+ (WebCore::Element::removedFromDocument):
+
+ Make sure updateName() is called in addition to updateId() when applicable.
+
+ * dom/Element.h:
+ (WebCore::Element::shouldRegisterAsNamedItem):
+ (WebCore::Element::shouldRegisterAsExtraNamedItem):
+
+ Added. If an element returns true for these, it will be automatically
+ registered with the document when the name/id attribute changes.
+
+ (WebCore::Element::updateId):
+ (WebCore::Element::updateName):
+
+ Register/unregister from the document's named item maps as appropriate.
+
+ (WebCore::Element::willModifyAttribute):
+
+ Add updateName() hook in addition to the existing updateId() hook.
+
+ * dom/NamedNodeMap.cpp:
+ (WebCore::NamedNodeMap::setAttributes):
+
+ Make sure updateName() is called when we're cloning the attributes
+ from another element.
+
+ * html/HTMLAppletElement.cpp:
+ (WebCore::HTMLAppletElement::parseMappedAttribute):
+ * html/HTMLAppletElement.h:
+ * html/HTMLEmbedElement.cpp:
+ (WebCore::HTMLEmbedElement::parseMappedAttribute):
+ (WebCore::HTMLEmbedElement::insertedIntoDocument):
+ * html/HTMLEmbedElement.h:
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::insertedIntoDocument):
+ (WebCore::HTMLFormElement::removedFromDocument):
+ (WebCore::HTMLFormElement::parseMappedAttribute):
+ * html/HTMLFormElement.h:
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseMappedAttribute):
+ (WebCore::HTMLImageElement::insertedIntoDocument):
+ * html/HTMLImageElement.h:
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parseMappedAttribute):
+ (WebCore::HTMLObjectElement::insertedIntoDocument):
+ (WebCore::HTMLObjectElement::removedFromDocument):
+ * html/HTMLObjectElement.h:
+ * html/HTMLPlugInElement.h:
+
+ Remove duplicated code that is now handled by Element.
+
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::updateDocNamedItem):
+ (WebCore::HTMLObjectElement::formControlName):
+
+ Use fastGetAttribute() since we no longer cache the name.
+
2011-12-23 Anders Carlsson <[email protected]>
Add two (currently unused) new member functions to ScrollElasticityControllerClient
Modified: trunk/Source/WebCore/dom/Element.cpp (103637 => 103638)
--- trunk/Source/WebCore/dom/Element.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/dom/Element.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -43,6 +43,7 @@
#include "FocusController.h"
#include "Frame.h"
#include "FrameView.h"
+#include "HTMLDocument.h"
#include "HTMLElement.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLNames.h"
@@ -868,23 +869,33 @@
if (ShadowRoot* shadow = shadowRoot())
shadow->insertedIntoDocument();
- if (hasID()) {
- if (m_attributeMap) {
+ if (m_attributeMap) {
+ if (hasID()) {
Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());
if (idItem && !idItem->isNull())
updateId(nullAtom, idItem->value());
}
+ if (hasName()) {
+ Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);
+ if (nameItem && !nameItem->isNull())
+ updateName(nullAtom, nameItem->value());
+ }
}
}
void Element::removedFromDocument()
{
- if (hasID()) {
- if (m_attributeMap) {
+ if (m_attributeMap) {
+ if (hasID()) {
Attribute* idItem = m_attributeMap->getAttributeItem(document()->idAttributeName());
if (idItem && !idItem->isNull())
updateId(idItem->value(), nullAtom);
}
+ if (hasName()) {
+ Attribute* nameItem = m_attributeMap->getAttributeItem(HTMLNames::nameAttr);
+ if (nameItem && !nameItem->isNull())
+ updateName(nameItem->value(), nullAtom);
+ }
}
ContainerNode::removedFromDocument();
@@ -1954,6 +1965,8 @@
if (isIdAttributeName(name))
updateId(oldValue, newValue);
+ else if (name == HTMLNames::nameAttr)
+ updateName(oldValue, newValue);
#if ENABLE(MUTATION_OBSERVERS)
if (!isSynchronizingStyleAttribute()) {
@@ -1995,4 +2008,28 @@
}
+void Element::updateNamedItemRegistration(const AtomicString& oldName, const AtomicString& newName)
+{
+ if (!document()->isHTMLDocument())
+ return;
+
+ if (!oldName.isEmpty())
+ static_cast<HTMLDocument*>(document())->removeNamedItem(oldName);
+
+ if (!newName.isEmpty())
+ static_cast<HTMLDocument*>(document())->addNamedItem(newName);
+}
+
+void Element::updateExtraNamedItemRegistration(const AtomicString& oldId, const AtomicString& newId)
+{
+ if (!document()->isHTMLDocument())
+ return;
+
+ if (!oldId.isEmpty())
+ static_cast<HTMLDocument*>(document())->removeExtraNamedItem(oldId);
+
+ if (!newId.isEmpty())
+ static_cast<HTMLDocument*>(document())->addExtraNamedItem(newId);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Element.h (103637 => 103638)
--- trunk/Source/WebCore/dom/Element.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/dom/Element.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -27,6 +27,7 @@
#include "Document.h"
#include "FragmentScriptingPermission.h"
+#include "HTMLNames.h"
#include "NamedNodeMap.h"
#include "ScrollTypes.h"
@@ -265,6 +266,7 @@
virtual String title() const;
void updateId(const AtomicString& oldId, const AtomicString& newId);
+ void updateName(const AtomicString& oldName, const AtomicString& newName);
void willModifyAttribute(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue);
void willRemoveAttribute(const QualifiedName&, const AtomicString& value);
@@ -381,6 +383,9 @@
virtual void didRecalcStyle(StyleChange) { }
virtual PassRefPtr<RenderStyle> customStyleForRenderer();
+ virtual bool shouldRegisterAsNamedItem() const { return false; }
+ virtual bool shouldRegisterAsExtraNamedItem() const { return false; }
+
// The implementation of Element::attributeChanged() calls the following two functions.
// They are separated to allow a different flow of control in StyledElement::attributeChanged().
void recalcStyleIfNeededAfterAttributeChanged(Attribute*);
@@ -432,6 +437,9 @@
SpellcheckAttributeState spellcheckAttributeState() const;
+ void updateNamedItemRegistration(const AtomicString& oldName, const AtomicString& newName);
+ void updateExtraNamedItemRegistration(const AtomicString& oldName, const AtomicString& newName);
+
private:
mutable RefPtr<NamedNodeMap> m_attributeMap;
};
@@ -498,6 +506,18 @@
attributes(false)->setAttributes(*attributeMap);
}
+inline void Element::updateName(const AtomicString& oldName, const AtomicString& newName)
+{
+ if (!inDocument())
+ return;
+
+ if (oldName == newName)
+ return;
+
+ if (shouldRegisterAsNamedItem())
+ updateNamedItemRegistration(oldName, newName);
+}
+
inline void Element::updateId(const AtomicString& oldId, const AtomicString& newId)
{
if (!inDocument())
@@ -511,6 +531,9 @@
scope->removeElementById(oldId, this);
if (!newId.isEmpty())
scope->addElementById(newId, this);
+
+ if (shouldRegisterAsExtraNamedItem())
+ updateExtraNamedItemRegistration(oldId, newId);
}
inline void Element::willRemoveAttribute(const QualifiedName& name, const AtomicString& value)
Modified: trunk/Source/WebCore/dom/NamedNodeMap.cpp (103637 => 103638)
--- trunk/Source/WebCore/dom/NamedNodeMap.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/dom/NamedNodeMap.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -219,6 +219,12 @@
if (oldId || newId)
m_element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom);
+ Attribute* oldName = getAttributeItem(HTMLNames::nameAttr);
+ Attribute* newName = other.getAttributeItem(HTMLNames::nameAttr);
+
+ if (oldName || newName)
+ m_element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom);
+
clearAttributes();
unsigned newLength = other.length();
m_attributes.resize(newLength);
Modified: trunk/Source/WebCore/dom/Node.h (103637 => 103638)
--- trunk/Source/WebCore/dom/Node.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/dom/Node.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -295,6 +295,7 @@
virtual bool sheetLoaded() { return true; }
virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }
+ bool hasName() const { return getFlag(HasNameFlag); }
bool hasID() const { return getFlag(HasIDFlag); }
bool hasClass() const { return getFlag(HasClassFlag); }
bool active() const { return getFlag(IsActiveFlag); }
@@ -309,6 +310,7 @@
bool childNeedsStyleRecalc() const { return getFlag(ChildNeedsStyleRecalcFlag); }
bool isLink() const { return getFlag(IsLinkFlag); }
+ void setHasName(bool f) { setFlag(f, HasNameFlag); }
void setHasID(bool f) { setFlag(f, HasIDFlag); }
void setHasClass(bool f) { setFlag(f, HasClassFlag); }
void setChildNeedsStyleRecalc() { setFlag(ChildNeedsStyleRecalcFlag); }
@@ -645,6 +647,8 @@
HasCustomWillOrDidRecalcStyleFlag = 1 << 28,
HasCustomStyleForRendererFlag = 1 << 29,
+ HasNameFlag = 1 << 30,
+
#if ENABLE(SVG)
DefaultNodeFlags = IsParsingChildrenFinishedFlag | IsStyleAttributeValidFlag | AreSVGAttributesValidFlag
#else
@@ -652,7 +656,7 @@
#endif
};
- // 2 bits remaining
+ // 1 bit remaining
bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
void setFlag(bool f, NodeFlags mask) const { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -145,6 +145,9 @@
void StyledElement::attributeChanged(Attribute* attr, bool preserveDecls)
{
+ if (attr->name() == HTMLNames::nameAttr)
+ setHasName(!attr->isNull());
+
if (!attr->isMappedAttribute()) {
Element::attributeChanged(attr, preserveDecls);
return;
Modified: trunk/Source/WebCore/html/HTMLAppletElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLAppletElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLAppletElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -56,50 +56,10 @@
attr->name() == mayscriptAttr ||
attr->name() == objectAttr) {
// Do nothing.
- } else if (attr->name() == nameAttr) {
- const AtomicString& newName = attr->value();
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->addNamedItem(newName);
- }
- m_name = newName;
- } else if (isIdAttributeName(attr->name())) {
- const AtomicString& newId = attr->value();
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeExtraNamedItem(m_id);
- document->addExtraNamedItem(newId);
- }
- m_id = newId;
- // also call superclass
- HTMLPlugInElement::parseMappedAttribute(attr);
} else
HTMLPlugInElement::parseMappedAttribute(attr);
}
-void HTMLAppletElement::insertedIntoDocument()
-{
- if (document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->addNamedItem(m_name);
- document->addExtraNamedItem(m_id);
- }
-
- HTMLPlugInElement::insertedIntoDocument();
-}
-
-void HTMLAppletElement::removedFromDocument()
-{
- if (document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->removeExtraNamedItem(m_id);
- }
-
- HTMLPlugInElement::removedFromDocument();
-}
-
bool HTMLAppletElement::rendererIsNeeded(const NodeRenderingContext& context)
{
if (!fastHasAttribute(codeAttr))
Modified: trunk/Source/WebCore/html/HTMLAppletElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLAppletElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLAppletElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -47,10 +47,8 @@
void setupApplet() const;
bool canEmbedJava() const;
- virtual void insertedIntoDocument();
- virtual void removedFromDocument();
-
- AtomicString m_id;
+ virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return true; }
+ virtual bool shouldRegisterAsExtraNamedItem() const OVERRIDE { return true; }
};
}
Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -111,13 +111,6 @@
addCSSLength(attr, CSSPropertyWidth, "0");
addCSSLength(attr, CSSPropertyHeight, "0");
}
- } else if (attr->name() == nameAttr) {
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->addNamedItem(value);
- }
- m_name = value;
} else
HTMLPlugInImageElement::parseMappedAttribute(attr);
}
@@ -219,9 +212,6 @@
if (!inDocument())
return;
- if (document()->isHTMLDocument())
- static_cast<HTMLDocument*>(document())->addNamedItem(m_name);
-
String width = getAttribute(widthAttr);
String height = getAttribute(heightAttr);
if (!width.isEmpty() || !height.isEmpty()) {
@@ -237,14 +227,6 @@
}
}
-void HTMLEmbedElement::removedFromDocument()
-{
- if (document()->isHTMLDocument())
- static_cast<HTMLDocument*>(document())->removeNamedItem(m_name);
-
- HTMLPlugInImageElement::removedFromDocument();
-}
-
void HTMLEmbedElement::attributeChanged(Attribute* attr, bool preserveDecls)
{
HTMLPlugInImageElement::attributeChanged(attr, preserveDecls);
Modified: trunk/Source/WebCore/html/HTMLEmbedElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLEmbedElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -39,7 +39,6 @@
virtual bool rendererIsNeeded(const NodeRenderingContext&);
virtual void insertedIntoDocument();
- virtual void removedFromDocument();
virtual void attributeChanged(Attribute*, bool preserveDecls = false);
virtual bool isURLAttribute(Attribute*) const;
@@ -57,6 +56,8 @@
virtual String itemValueText() const OVERRIDE;
virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
#endif
+
+ virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return true; }
};
}
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -132,9 +132,6 @@
void HTMLFormElement::insertedIntoDocument()
{
- if (document()->isHTMLDocument())
- static_cast<HTMLDocument*>(document())->addNamedItem(m_name);
-
HTMLElement::insertedIntoDocument();
if (hasID())
@@ -143,9 +140,6 @@
void HTMLFormElement::removedFromDocument()
{
- if (document()->isHTMLDocument())
- static_cast<HTMLDocument*>(document())->removeNamedItem(m_name);
-
HTMLElement::removedFromDocument();
if (hasID())
@@ -384,15 +378,7 @@
setAttributeEventListener(eventNames().submitEvent, createAttributeEventListener(this, attr));
else if (attr->name() == onresetAttr)
setAttributeEventListener(eventNames().resetEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == nameAttr) {
- const AtomicString& newName = attr->value();
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->addNamedItem(newName);
- }
- m_name = newName;
- } else
+ else
HTMLElement::parseMappedAttribute(attr);
}
Modified: trunk/Source/WebCore/html/HTMLFormElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLFormElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLFormElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -131,6 +131,8 @@
virtual void willMoveToNewOwnerDocument();
virtual void didMoveToNewOwnerDocument();
+ virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return true; }
+
void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger);
unsigned formElementIndexWithFormAttribute(Element*);
@@ -167,8 +169,6 @@
bool m_wasMalformed;
bool m_wasDemoted;
-
- AtomicString m_name;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -133,24 +133,6 @@
else if (attrName == compositeAttr) {
if (!parseCompositeOperator(attr->value(), m_compositeOperator))
m_compositeOperator = CompositeSourceOver;
- } else if (attrName == nameAttr) {
- const AtomicString& newName = attr->value();
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->addNamedItem(newName);
- }
- m_name = newName;
- } else if (isIdAttributeName(attr->name())) {
- const AtomicString& newId = attr->value();
- if (inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeExtraNamedItem(m_id);
- document->addExtraNamedItem(newId);
- }
- m_id = newId;
- // also call superclass
- HTMLElement::parseMappedAttribute(attr);
} else
HTMLElement::parseMappedAttribute(attr);
}
@@ -197,12 +179,6 @@
void HTMLImageElement::insertedIntoDocument()
{
- if (document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->addNamedItem(m_name);
- document->addExtraNamedItem(m_id);
- }
-
// If we have been inserted from a renderer-less document,
// our loader may have not fetched the image, so do it now.
if (!m_imageLoader.image())
@@ -211,17 +187,6 @@
HTMLElement::insertedIntoDocument();
}
-void HTMLImageElement::removedFromDocument()
-{
- if (document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->removeExtraNamedItem(m_id);
- }
-
- HTMLElement::removedFromDocument();
-}
-
void HTMLImageElement::insertedIntoTree(bool deep)
{
if (!m_form) {
Modified: trunk/Source/WebCore/html/HTMLImageElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLImageElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLImageElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -98,10 +98,12 @@
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
virtual void insertedIntoDocument();
- virtual void removedFromDocument();
virtual void insertedIntoTree(bool deep);
virtual void removedFromTree(bool deep);
+ virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return true; }
+ virtual bool shouldRegisterAsExtraNamedItem() const OVERRIDE { return true; }
+
#if ENABLE(MICRODATA)
virtual String itemValueText() const OVERRIDE;
virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
@@ -109,8 +111,6 @@
HTMLImageLoader m_imageLoader;
HTMLFormElement* m_form;
- AtomicString m_name;
- AtomicString m_id;
CompositeOperator m_compositeOperator;
};
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2011-12-23 21:36:59 UTC (rev 103638)
@@ -114,28 +114,10 @@
setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
else if (attr->name() == onbeforeloadAttr)
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == nameAttr) {
- const AtomicString& newName = attr->value();
- if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->addNamedItem(newName);
- }
- m_name = newName;
- } else if (attr->name() == borderAttr)
+ else if (attr->name() == borderAttr)
applyBorderAttribute(attr);
- else if (isIdAttributeName(attr->name())) {
- const AtomicString& newId = attr->value();
- if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeExtraNamedItem(m_id);
- document->addExtraNamedItem(newId);
- }
- m_id = newId;
- // also call superclass
+ else
HTMLPlugInImageElement::parseMappedAttribute(attr);
- } else
- HTMLPlugInImageElement::parseMappedAttribute(attr);
}
static void mapDataParamToSrc(Vector<String>* paramNames, Vector<String>* paramValues)
@@ -346,26 +328,11 @@
void HTMLObjectElement::insertedIntoDocument()
{
HTMLPlugInImageElement::insertedIntoDocument();
- if (!inDocument())
- return;
-
- if (isDocNamedItem() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->addNamedItem(m_name);
- document->addExtraNamedItem(m_id);
- }
-
FormAssociatedElement::insertedIntoDocument();
}
void HTMLObjectElement::removedFromDocument()
{
- if (isDocNamedItem() && document()->isHTMLDocument()) {
- HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
- document->removeNamedItem(m_name);
- document->removeExtraNamedItem(m_id);
- }
-
HTMLPlugInImageElement::removedFromDocument();
FormAssociatedElement::removedFromDocument();
}
@@ -466,11 +433,11 @@
if (isNamedItem != wasNamedItem && document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
if (isNamedItem) {
- document->addNamedItem(m_name);
- document->addExtraNamedItem(m_id);
+ document->addNamedItem(fastGetAttribute(nameAttr));
+ document->addExtraNamedItem(getIdAttribute());
} else {
- document->removeNamedItem(m_name);
- document->removeExtraNamedItem(m_id);
+ document->removeNamedItem(fastGetAttribute(nameAttr));
+ document->removeExtraNamedItem(getIdAttribute());
}
}
m_docNamedItem = isNamedItem;
@@ -544,7 +511,8 @@
const AtomicString& HTMLObjectElement::formControlName() const
{
- return m_name.isNull() ? emptyAtom : m_name;
+ const AtomicString& name = fastGetAttribute(nameAttr);
+ return name.isNull() ? emptyAtom : name;
}
HTMLFormElement* HTMLObjectElement::virtualForm() const
Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLObjectElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -107,7 +107,9 @@
virtual void setItemValueText(const String&, ExceptionCode&) OVERRIDE;
#endif
- AtomicString m_id;
+ virtual bool shouldRegisterAsNamedItem() const OVERRIDE { return isDocNamedItem(); }
+ virtual bool shouldRegisterAsExtraNamedItem() const OVERRIDE { return isDocNamedItem(); }
+
String m_classId;
bool m_docNamedItem : 1;
bool m_useFallbackContent : 1;
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (103637 => 103638)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2011-12-23 21:08:12 UTC (rev 103637)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2011-12-23 21:36:59 UTC (rev 103638)
@@ -68,9 +68,6 @@
virtual RenderWidget* renderWidgetForJSBindings() = 0;
-protected:
- AtomicString m_name;
-
private:
mutable ScriptInstance m_instance;
#if ENABLE(NETSCAPE_PLUGIN_API)