Diff
Modified: trunk/LayoutTests/ChangeLog (106417 => 106418)
--- trunk/LayoutTests/ChangeLog 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/LayoutTests/ChangeLog 2012-02-01 01:54:09 UTC (rev 106418)
@@ -1,3 +1,13 @@
+2012-01-31 Adam Klein <[email protected]>
+
+ ProcessingInstruction should not be a ContainerNode
+ https://bugs.webkit.org/show_bug.cgi?id=75141
+
+ Reviewed by Darin Adler.
+
+ * fast/dom/processing-instruction-appendChild-exceptions-expected.txt: Added.
+ * fast/dom/processing-instruction-appendChild-exceptions.xhtml: Added.
+
2012-01-31 Matthew Delaney <[email protected]>
Failing 2d.shadow.enable.off.2.html on Lion
Added: trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions-expected.txt (0 => 106418)
--- trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions-expected.txt 2012-02-01 01:54:09 UTC (rev 106418)
@@ -0,0 +1,12 @@
+Test that appropriate exceptions are thrown when adding children to a ProcessingInstruction.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pi.appendChild(null) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS pi.appendChild(div) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS pi.appendChild(textNode) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions.xhtml (0 => 106418)
--- trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions.xhtml (rev 0)
+++ trunk/LayoutTests/fast/dom/processing-instruction-appendChild-exceptions.xhtml 2012-02-01 01:54:09 UTC (rev 106418)
@@ -0,0 +1,17 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<body>
+<script src=""
+<script>
+<![CDATA[
+description("Test that appropriate exceptions are thrown when adding children to a ProcessingInstruction.");
+var pi = document.createProcessingInstruction('target', 'data');
+shouldThrow("pi.appendChild(null)", "'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'");
+var div = document.createElement('div');
+shouldThrow("pi.appendChild(div)", "'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'");
+var textNode = document.createTextNode('sometext');
+shouldThrow("pi.appendChild(textNode)", "'Error: HIERARCHY_REQUEST_ERR: DOM Exception 3'");
+]]>
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (106417 => 106418)
--- trunk/Source/WebCore/ChangeLog 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/ChangeLog 2012-02-01 01:54:09 UTC (rev 106418)
@@ -1,3 +1,32 @@
+2012-01-31 Adam Klein <[email protected]>
+
+ ProcessingInstruction should not be a ContainerNode
+ https://bugs.webkit.org/show_bug.cgi?id=75141
+
+ Reviewed by Darin Adler.
+
+ Per the DOM spec, ProcessingInstruction can't have any children.
+ And the WebCore behavior already matches the spec by always returning
+ false for childTypeAllowed(). This change simplifies
+ ProcessingInstruction's implementation by making it subclass Node
+ instead of ContainerNode.
+
+ Test: fast/dom/processing-instruction-appendChild-exceptions.xhtml
+
+ * dom/ContainerNode.cpp: Moved dispatchBeforeLoadEvent up to Node.
+ * dom/ContainerNode.h:
+ * dom/Node.cpp:
+ (WebCore::Node::dispatchBeforeLoadEvent): Moved up from ContainerNode
+ since it's used both by ProcessingInstruction and various Element
+ subclasses.
+ * dom/Node.h:
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::ProcessingInstruction): Call Node constructor.
+ (WebCore::ProcessingInstruction::insertedIntoDocument): Call Node impl.
+ (WebCore::ProcessingInstruction::removedFromDocument): ditto.
+ (WebCore::ProcessingInstruction::finishParsingChildren): ditto.
+ * dom/ProcessingInstruction.h:
+
2012-01-31 Matthew Delaney <[email protected]>
Failing 2d.shadow.enable.off.2.html on Lion
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (106417 => 106418)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-02-01 01:54:09 UTC (rev 106418)
@@ -23,7 +23,6 @@
#include "config.h"
#include "ContainerNode.h"
-#include "BeforeLoadEvent.h"
#include "ChildListMutationScope.h"
#include "ContainerNodeAlgorithms.h"
#include "DeleteButtonController.h"
@@ -1160,15 +1159,4 @@
}
}
-bool ContainerNode::dispatchBeforeLoadEvent(const String& sourceURL)
-{
- if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER))
- return true;
-
- RefPtr<ContainerNode> protector(this);
- RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
- dispatchEvent(beforeLoadEvent.get());
- return !beforeLoadEvent->defaultPrevented();
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/ContainerNode.h (106417 => 106418)
--- trunk/Source/WebCore/dom/ContainerNode.h 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2012-02-01 01:54:09 UTC (rev 106418)
@@ -69,9 +69,7 @@
void takeAllChildrenFrom(ContainerNode*);
void cloneChildNodes(ContainerNode* clone);
-
- bool dispatchBeforeLoadEvent(const String& sourceURL);
-
+
virtual void attach() OVERRIDE;
virtual void detach() OVERRIDE;
virtual void willRemove() OVERRIDE;
Modified: trunk/Source/WebCore/dom/Node.cpp (106417 => 106418)
--- trunk/Source/WebCore/dom/Node.cpp 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-02-01 01:54:09 UTC (rev 106418)
@@ -28,6 +28,7 @@
#include "AXObjectCache.h"
#include "Attr.h"
#include "Attribute.h"
+#include "BeforeLoadEvent.h"
#include "ChildListMutationScope.h"
#include "Chrome.h"
#include "ChromeClient.h"
@@ -2809,6 +2810,17 @@
EventDispatcher::dispatchSimulatedClick(this, event, sendMouseEvents, showPressedLook);
}
+bool Node::dispatchBeforeLoadEvent(const String& sourceURL)
+{
+ if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER))
+ return true;
+
+ RefPtr<Node> protector(this);
+ RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
+ dispatchEvent(beforeLoadEvent.get());
+ return !beforeLoadEvent->defaultPrevented();
+}
+
bool Node::dispatchWheelEvent(const PlatformWheelEvent& event)
{
return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document()->defaultView()));
Modified: trunk/Source/WebCore/dom/Node.h (106417 => 106418)
--- trunk/Source/WebCore/dom/Node.h 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/Node.h 2012-02-01 01:54:09 UTC (rev 106418)
@@ -594,6 +594,7 @@
bool dispatchWheelEvent(const PlatformWheelEvent&);
bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0);
void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true);
+ bool dispatchBeforeLoadEvent(const String& sourceURL);
virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode);
virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (106417 => 106418)
--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2012-02-01 01:54:09 UTC (rev 106418)
@@ -36,7 +36,7 @@
namespace WebCore {
inline ProcessingInstruction::ProcessingInstruction(Document* document, const String& target, const String& data)
- : ContainerNode(document)
+ : Node(document, CreateOther)
, m_target(target)
, m_data(data)
, m_cachedSheet(0)
@@ -103,12 +103,6 @@
return create(document(), m_target, m_data);
}
-// DOM Section 1.1.1
-bool ProcessingInstruction::childTypeAllowed(NodeType) const
-{
- return false;
-}
-
void ProcessingInstruction::checkStyleSheet()
{
if (m_target == "xml-stylesheet" && document()->frame() && parentNode() == document()) {
@@ -280,14 +274,14 @@
void ProcessingInstruction::insertedIntoDocument()
{
- ContainerNode::insertedIntoDocument();
+ Node::insertedIntoDocument();
document()->addStyleSheetCandidateNode(this, m_createdByParser);
checkStyleSheet();
}
void ProcessingInstruction::removedFromDocument()
{
- ContainerNode::removedFromDocument();
+ Node::removedFromDocument();
document()->removeStyleSheetCandidateNode(this);
@@ -304,7 +298,7 @@
void ProcessingInstruction::finishParsingChildren()
{
m_createdByParser = false;
- ContainerNode::finishParsingChildren();
+ Node::finishParsingChildren();
}
} // namespace
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.h (106417 => 106418)
--- trunk/Source/WebCore/dom/ProcessingInstruction.h 2012-02-01 01:49:15 UTC (rev 106417)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.h 2012-02-01 01:54:09 UTC (rev 106418)
@@ -24,14 +24,14 @@
#include "CachedResourceHandle.h"
#include "CachedStyleSheetClient.h"
-#include "ContainerNode.h"
+#include "Node.h"
namespace WebCore {
class StyleSheet;
class CSSStyleSheet;
-class ProcessingInstruction : public ContainerNode, private CachedStyleSheetClient {
+class ProcessingInstruction : public Node, private CachedStyleSheetClient {
public:
static PassRefPtr<ProcessingInstruction> create(Document*, const String& target, const String& data);
virtual ~ProcessingInstruction();
@@ -61,7 +61,6 @@
virtual String nodeValue() const;
virtual void setNodeValue(const String&, ExceptionCode&);
virtual PassRefPtr<Node> cloneNode(bool deep);
- virtual bool childTypeAllowed(NodeType) const;
virtual bool offsetInCharacters() const;
virtual int maxCharacterOffset() const;