summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/Attr.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/dom/Attr.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/dom/Attr.cpp')
-rw-r--r--WebCore/dom/Attr.cpp65
1 files changed, 15 insertions, 50 deletions
diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp
index 24ea6b9..435c1af 100644
--- a/WebCore/dom/Attr.cpp
+++ b/WebCore/dom/Attr.cpp
@@ -30,15 +30,15 @@
namespace WebCore {
-Attr::Attr(Element* element, Document* docPtr, Attribute* a)
- : ContainerNode(docPtr),
- m_element(element),
- m_attribute(a),
- m_ignoreChildrenChanged(0)
+Attr::Attr(Element* element, Document* docPtr, PassRefPtr<Attribute> a)
+ : ContainerNode(docPtr)
+ , m_element(element)
+ , m_attribute(a)
+ , m_ignoreChildrenChanged(0)
+ , m_specified(true)
{
ASSERT(!m_attribute->attr());
m_attribute->m_impl = this;
- m_attrWasSpecifiedOrElementHasRareData = true;
}
Attr::~Attr()
@@ -51,7 +51,7 @@ void Attr::createTextChild()
{
ASSERT(refCount());
if (!m_attribute->value().isEmpty()) {
- RefPtr<Text> textNode = document()->createTextNode(m_attribute->value().domString());
+ RefPtr<Text> textNode = document()->createTextNode(m_attribute->value().string());
// This does everything appendChild() would do in this situation (assuming m_ignoreChildrenChanged was set),
// but much more efficiently.
@@ -101,32 +101,20 @@ String Attr::nodeValue() const
return value();
}
-void Attr::setValue( const String& v, ExceptionCode& ec)
+void Attr::setValue(const String& v, ExceptionCode&)
{
- ec = 0;
-
- // do not interprete entities in the string, its literal!
-
- // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly
- if (isReadOnlyNode()) {
- ec = NO_MODIFICATION_ALLOWED_ERR;
- return;
- }
-
- int e = 0;
m_ignoreChildrenChanged++;
removeChildren();
- appendChild(document()->createTextNode(v), e);
- m_ignoreChildrenChanged--;
-
m_attribute->setValue(v.impl());
+ createTextChild();
+ m_ignoreChildrenChanged--;
+
if (m_element)
m_element->attributeChanged(m_attribute.get());
}
void Attr::setNodeValue(const String& v, ExceptionCode& ec)
{
- // NO_MODIFICATION_ALLOWED_ERR: taken care of by setValue()
setValue(v, ec);
}
@@ -149,13 +137,13 @@ bool Attr::childTypeAllowed(NodeType type)
}
}
-void Attr::childrenChanged(bool changedByParser)
+void Attr::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
- Node::childrenChanged(changedByParser);
-
if (m_ignoreChildrenChanged > 0)
return;
-
+
+ Node::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+
// FIXME: We should include entity references in the value
String val = "";
@@ -169,27 +157,4 @@ void Attr::childrenChanged(bool changedByParser)
m_element->attributeChanged(m_attribute.get());
}
-String Attr::toString() const
-{
- String result;
-
- result += nodeName();
-
- // FIXME: substitute entities for any instances of " or ' --
- // maybe easier to just use text value and ignore existing
- // entity refs?
-
- if (firstChild() != NULL) {
- result += "=\"";
-
- for (Node *child = firstChild(); child != NULL; child = child->nextSibling()) {
- result += child->toString();
- }
-
- result += "\"";
- }
-
- return result;
-}
-
}