summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-23 17:03:15 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-23 17:03:15 +0200
commita73d1c176f2f3e0458861de8590dc20321a501ae (patch)
treed897fc5974797c3cb300d7f5916f258df765401f /Source/WebCore/dom
parentc311cf639cc1d6570d67b0a80a8ba04dc992a658 (diff)
downloadqtwebkit-a73d1c176f2f3e0458861de8590dc20321a501ae.tar.gz
Imported WebKit commit a5ae8a56a48e44ebfb9b81aaa5488affaffdb175 (http://svn.webkit.org/repository/webkit/trunk@126420)
New snapshot with OS X 10.6 build fix
Diffstat (limited to 'Source/WebCore/dom')
-rw-r--r--Source/WebCore/dom/CharacterData.cpp1
-rw-r--r--Source/WebCore/dom/ClassNodeList.cpp7
-rw-r--r--Source/WebCore/dom/Element.cpp30
-rw-r--r--Source/WebCore/dom/Element.h14
-rw-r--r--Source/WebCore/dom/ElementRareData.h1
-rw-r--r--Source/WebCore/dom/MessagePort.cpp2
-rw-r--r--Source/WebCore/dom/NodeRenderingContext.cpp1
-rw-r--r--Source/WebCore/dom/StyledElement.cpp30
-rw-r--r--Source/WebCore/dom/StyledElement.h16
-rw-r--r--Source/WebCore/dom/Text.cpp1
10 files changed, 58 insertions, 45 deletions
diff --git a/Source/WebCore/dom/CharacterData.cpp b/Source/WebCore/dom/CharacterData.cpp
index b613ab97c..8c930d8f2 100644
--- a/Source/WebCore/dom/CharacterData.cpp
+++ b/Source/WebCore/dom/CharacterData.cpp
@@ -32,6 +32,7 @@
#include "MutationRecord.h"
#include "NodeRenderingContext.h"
#include "RenderText.h"
+#include "StyleInheritedData.h"
#include "TextBreakIterator.h"
#include "UndoManager.h"
diff --git a/Source/WebCore/dom/ClassNodeList.cpp b/Source/WebCore/dom/ClassNodeList.cpp
index c0ce6d2e0..a4d88ab35 100644
--- a/Source/WebCore/dom/ClassNodeList.cpp
+++ b/Source/WebCore/dom/ClassNodeList.cpp
@@ -54,8 +54,11 @@ bool ClassNodeList::nodeMatches(Element* testNode) const
return false;
if (!m_classNames.size())
return false;
- ASSERT(testNode->isStyledElement());
- return static_cast<StyledElement*>(testNode)->classNames().containsAll(m_classNames);
+ // FIXME: DOM4 allows getElementsByClassName to return non StyledElement.
+ // https://bugs.webkit.org/show_bug.cgi?id=94718
+ if (!testNode->isStyledElement())
+ return false;
+ return testNode->classNames().containsAll(m_classNames);
}
} // namespace WebCore
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 743e12278..04bc20b0b 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -696,6 +696,8 @@ inline void Element::setAttributeInternal(size_t index, const QualifiedName& nam
void Element::attributeChanged(const Attribute& attribute)
{
+ parseAttribute(attribute);
+
document()->incDOMTreeVersion();
if (isIdAttributeName(attribute.name())) {
@@ -747,6 +749,34 @@ void Element::attributeChanged(const Attribute& attribute)
document()->axObjectCache()->postNotification(this, AXObjectCache::AXInvalidStatusChanged, true);
}
+void Element::parseAttribute(const Attribute& attribute)
+{
+ if (attribute.name() == classAttr)
+ classAttributeChanged(attribute.value());
+}
+
+void Element::classAttributeChanged(const AtomicString& newClassString)
+{
+ const UChar* characters = newClassString.characters();
+ unsigned length = newClassString.length();
+ unsigned i;
+ for (i = 0; i < length; ++i) {
+ if (isNotHTMLSpace(characters[i]))
+ break;
+ }
+ bool hasClass = i < length;
+ if (hasClass) {
+ const bool shouldFoldCase = document()->inQuirksMode();
+ ensureAttributeData()->setClass(newClassString, shouldFoldCase);
+ } else if (attributeData())
+ mutableAttributeData()->clearClass();
+
+ if (DOMTokenList* classList = optionalClassList())
+ static_cast<ClassList*>(classList)->reset(newClassString);
+
+ setNeedsStyleRecalc();
+}
+
// Returns true is the given attribute is an event handler.
// We consider an event handler any attribute that begins with "on".
// It is a simple solution that has the advantage of not requiring any
diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h
index 97a16f636..f79227e9e 100644
--- a/Source/WebCore/dom/Element.h
+++ b/Source/WebCore/dom/Element.h
@@ -246,6 +246,7 @@ public:
// This method is called whenever an attribute is added, changed or removed.
virtual void attributeChanged(const Attribute&);
+ virtual void parseAttribute(const Attribute&);
// Only called by the parser immediately after element construction.
void parserSetAttributes(const Vector<Attribute>&, FragmentScriptingPermission);
@@ -428,6 +429,7 @@ public:
bool hasID() const;
bool hasClass() const;
+ const SpaceSplitString& classNames() const;
IntSize savedLayerScrollOffset() const;
void setSavedLayerScrollOffset(const IntSize&);
@@ -461,6 +463,11 @@ protected:
PassRefPtr<HTMLCollection> ensureCachedHTMLCollection(CollectionType);
HTMLCollection* cachedHTMLCollection(CollectionType);
+ // classAttributeChanged() exists to share code between
+ // parseAttribute (called via setAttribute()) and
+ // svgAttributeChanged (called when element.className.baseValue is set)
+ void classAttributeChanged(const AtomicString& newClassString);
+
private:
void updateInvalidAttributes() const;
@@ -687,6 +694,13 @@ inline void Element::setIdAttribute(const AtomicString& value)
setAttribute(document()->idAttributeName(), value);
}
+inline const SpaceSplitString& Element::classNames() const
+{
+ ASSERT(hasClass());
+ ASSERT(attributeData());
+ return attributeData()->classNames();
+}
+
inline size_t Element::attributeCount() const
{
ASSERT(attributeData());
diff --git a/Source/WebCore/dom/ElementRareData.h b/Source/WebCore/dom/ElementRareData.h
index 07394ebd1..b75a0bda9 100644
--- a/Source/WebCore/dom/ElementRareData.h
+++ b/Source/WebCore/dom/ElementRareData.h
@@ -29,6 +29,7 @@
#include "HTMLCollection.h"
#include "NamedNodeMap.h"
#include "NodeRareData.h"
+#include "StyleInheritedData.h"
#include <wtf/OwnPtr.h>
namespace WebCore {
diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp
index ab4dcdc0d..50d4b16e3 100644
--- a/Source/WebCore/dom/MessagePort.cpp
+++ b/Source/WebCore/dom/MessagePort.cpp
@@ -83,7 +83,7 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
for (unsigned int i = 0; i < ports->size(); ++i) {
MessagePort* dataPort = (*ports)[i].get();
if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort)) {
- ec = DATA_CLONE_ERR;
+ ec = INVALID_STATE_ERR;
return;
}
}
diff --git a/Source/WebCore/dom/NodeRenderingContext.cpp b/Source/WebCore/dom/NodeRenderingContext.cpp
index c8e23502d..21f1c3f89 100644
--- a/Source/WebCore/dom/NodeRenderingContext.cpp
+++ b/Source/WebCore/dom/NodeRenderingContext.cpp
@@ -40,6 +40,7 @@
#include "RenderObject.h"
#include "RenderView.h"
#include "ShadowRoot.h"
+#include "StyleInheritedData.h"
#if ENABLE(SVG)
#include "SVGNames.h"
diff --git a/Source/WebCore/dom/StyledElement.cpp b/Source/WebCore/dom/StyledElement.cpp
index c5616b082..e75cd531d 100644
--- a/Source/WebCore/dom/StyledElement.cpp
+++ b/Source/WebCore/dom/StyledElement.cpp
@@ -147,8 +147,6 @@ CSSStyleDeclaration* StyledElement::style()
void StyledElement::attributeChanged(const Attribute& attribute)
{
- parseAttribute(attribute);
-
if (isPresentationAttribute(attribute.name())) {
setAttributeStyleDirty();
setNeedsStyleRecalc(InlineStyleChange);
@@ -157,28 +155,6 @@ void StyledElement::attributeChanged(const Attribute& attribute)
Element::attributeChanged(attribute);
}
-void StyledElement::classAttributeChanged(const AtomicString& newClassString)
-{
- const UChar* characters = newClassString.characters();
- unsigned length = newClassString.length();
- unsigned i;
- for (i = 0; i < length; ++i) {
- if (isNotHTMLSpace(characters[i]))
- break;
- }
- bool hasClass = i < length;
- if (hasClass) {
- const bool shouldFoldCase = document()->inQuirksMode();
- ensureAttributeData()->setClass(newClassString, shouldFoldCase);
- } else if (attributeData())
- mutableAttributeData()->clearClass();
-
- if (DOMTokenList* classList = optionalClassList())
- static_cast<ClassList*>(classList)->reset(newClassString);
-
- setNeedsStyleRecalc();
-}
-
void StyledElement::styleAttributeChanged(const AtomicString& newStyleString, ShouldReparseStyleAttribute shouldReparse)
{
if (shouldReparse) {
@@ -197,10 +173,10 @@ void StyledElement::styleAttributeChanged(const AtomicString& newStyleString, Sh
void StyledElement::parseAttribute(const Attribute& attribute)
{
- if (attribute.name() == classAttr)
- classAttributeChanged(attribute.value());
- else if (attribute.name() == styleAttr)
+ if (attribute.name() == styleAttr)
styleAttributeChanged(attribute.value());
+ else
+ Element::parseAttribute(attribute);
}
void StyledElement::inlineStyleChanged()
diff --git a/Source/WebCore/dom/StyledElement.h b/Source/WebCore/dom/StyledElement.h
index a080dc136..66418ddfd 100644
--- a/Source/WebCore/dom/StyledElement.h
+++ b/Source/WebCore/dom/StyledElement.h
@@ -53,8 +53,6 @@ public:
const StylePropertySet* attributeStyle();
- const SpaceSplitString& classNames() const;
-
virtual void collectStyleForAttribute(const Attribute&, StylePropertySet*) { }
// May be called by ElementAttributeData::cloneDataFrom().
@@ -65,7 +63,7 @@ protected:
StyledElement(const QualifiedName&, Document*, ConstructionType);
virtual void attributeChanged(const Attribute&) OVERRIDE;
- virtual void parseAttribute(const Attribute&);
+ virtual void parseAttribute(const Attribute&) OVERRIDE;
virtual bool isPresentationAttribute(const QualifiedName&) const { return false; }
@@ -75,11 +73,6 @@ protected:
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
- // classAttributeChanged() exists to share code between
- // parseAttribute (called via setAttribute()) and
- // svgAttributeChanged (called when element.className.baseValue is set)
- void classAttributeChanged(const AtomicString& newClassString);
-
private:
virtual void updateStyleAttribute() const;
void inlineStyleChanged();
@@ -94,13 +87,6 @@ private:
}
};
-inline const SpaceSplitString& StyledElement::classNames() const
-{
- ASSERT(hasClass());
- ASSERT(attributeData());
- return attributeData()->classNames();
-}
-
inline void StyledElement::invalidateStyleAttribute()
{
clearIsStyleAttributeValid();
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 9945f94aa..87e366362 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -32,6 +32,7 @@
#include "SVGNames.h"
#endif
+#include "StyleInheritedData.h"
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>