Title: [168358] trunk
Revision
168358
Author
k...@webkit.org
Date
2014-05-06 07:04:13 -0700 (Tue, 06 May 2014)

Log Message

[SVG2] Share "on"- event attributes with HTMLElement
https://bugs.webkit.org/show_bug.cgi?id=132604

Reviewed by Mihnea Ovidenie.

Source/WebCore:
Share "on" event attribute parsing between SVGElement and HTMLElement.

Tests: fast/dom/script-tests/event-attribute-availability.js:

* html/HTMLElement.cpp:
(WebCore::HTMLElement::populateEventNameForAttributeLocalNameMap):
(WebCore::populateEventNameForAttributeLocalNameMap): Deleted.
* html/HTMLElement.h: Make populateEventNameForAttributeLocalNameMap
    public for use in SVGElement.
* svg/SVGElement.cpp: Use HTMLElement code to parse "on" event
    attributes.
(WebCore::SVGElement::parseAttribute):

LayoutTests:
Test that the "on" event attributes supported by HTMLElement are
supported by SVGElement as well.

* fast/dom/event-attribute-availability-expected.txt:
* fast/dom/script-tests/event-attribute-availability.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (168357 => 168358)


--- trunk/LayoutTests/ChangeLog	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/LayoutTests/ChangeLog	2014-05-06 14:04:13 UTC (rev 168358)
@@ -1,3 +1,16 @@
+2014-05-06  Dirk Schulze  <k...@webkit.org>
+
+        [SVG2] Share "on"- event attributes with HTMLElement
+        https://bugs.webkit.org/show_bug.cgi?id=132604
+
+        Reviewed by Mihnea Ovidenie.
+
+        Test that the "on" event attributes supported by HTMLElement are
+        supported by SVGElement as well.
+
+        * fast/dom/event-attribute-availability-expected.txt:
+        * fast/dom/script-tests/event-attribute-availability.js:
+
 2014-05-06  Ion Rosca  <ro...@adobe.com>
 
         [CSS Blending] Rename all the tests css3/compositing to css3/blending

Modified: trunk/LayoutTests/fast/dom/event-attribute-availability-expected.txt (168357 => 168358)


--- trunk/LayoutTests/fast/dom/event-attribute-availability-expected.txt	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/LayoutTests/fast/dom/event-attribute-availability-expected.txt	2014-05-06 14:04:13 UTC (rev 168358)
@@ -42,6 +42,45 @@
 PASS 'onreset' in element is true
 PASS 'onsearch' in element is true
 PASS 'onselectstart' in element is true
+Test SVGElement
+PASS 'onabort' in svgelement is true
+PASS 'onblur' in svgelement is true
+PASS 'onchange' in svgelement is true
+PASS 'onclick' in svgelement is true
+PASS 'oncontextmenu' in svgelement is true
+PASS 'ondblclick' in svgelement is true
+PASS 'ondrag' in svgelement is true
+PASS 'ondragend' in svgelement is true
+PASS 'ondragenter' in svgelement is true
+PASS 'ondragleave' in svgelement is true
+PASS 'ondragover' in svgelement is true
+PASS 'ondragstart' in svgelement is true
+PASS 'ondrop' in svgelement is true
+PASS 'onerror' in svgelement is true
+PASS 'onfocus' in svgelement is true
+PASS 'oninput' in svgelement is true
+PASS 'onkeydown' in svgelement is true
+PASS 'onkeypress' in svgelement is true
+PASS 'onkeyup' in svgelement is true
+PASS 'onload' in svgelement is true
+PASS 'onmousedown' in svgelement is true
+PASS 'onmousemove' in svgelement is true
+PASS 'onmouseout' in svgelement is true
+PASS 'onmouseover' in svgelement is true
+PASS 'onmouseup' in svgelement is true
+PASS 'onmousewheel' in svgelement is true
+PASS 'onscroll' in svgelement is true
+PASS 'onselect' in svgelement is true
+PASS 'onsubmit' in svgelement is true
+PASS 'onbeforecut' in svgelement is true
+PASS 'oncut' in svgelement is true
+PASS 'onbeforecopy' in svgelement is true
+PASS 'oncopy' in svgelement is true
+PASS 'onbeforepaste' in svgelement is true
+PASS 'onpaste' in svgelement is true
+PASS 'onreset' in svgelement is true
+PASS 'onsearch' in svgelement is true
+PASS 'onselectstart' in svgelement is true
 
 Test Document
 PASS 'onabort' in document is true

Modified: trunk/LayoutTests/fast/dom/script-tests/event-attribute-availability.js (168357 => 168358)


--- trunk/LayoutTests/fast/dom/script-tests/event-attribute-availability.js	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/LayoutTests/fast/dom/script-tests/event-attribute-availability.js	2014-05-06 14:04:13 UTC (rev 168358)
@@ -32,6 +32,12 @@
     shouldBeTrue("'" + elementAndDocumentProperties[i] + "' in element");
 }
 
+debug("Test SVGElement");
+var svgelement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+for (var i = 0; i < elementAndDocumentProperties.length; ++i) {
+    shouldBeTrue("'" + elementAndDocumentProperties[i] + "' in svgelement");
+}
+
 debug("\nTest Document");
 for (var i = 0; i < elementAndDocumentProperties.length; ++i) {
     shouldBeTrue("'" + elementAndDocumentProperties[i] + "' in document");

Modified: trunk/Source/WebCore/ChangeLog (168357 => 168358)


--- trunk/Source/WebCore/ChangeLog	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/Source/WebCore/ChangeLog	2014-05-06 14:04:13 UTC (rev 168358)
@@ -1,3 +1,23 @@
+2014-05-06  Dirk Schulze  <k...@webkit.org>
+
+        [SVG2] Share "on"- event attributes with HTMLElement
+        https://bugs.webkit.org/show_bug.cgi?id=132604
+
+        Reviewed by Mihnea Ovidenie.
+
+        Share "on" event attribute parsing between SVGElement and HTMLElement.
+
+        Tests: fast/dom/script-tests/event-attribute-availability.js:
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::populateEventNameForAttributeLocalNameMap):
+        (WebCore::populateEventNameForAttributeLocalNameMap): Deleted.
+        * html/HTMLElement.h: Make populateEventNameForAttributeLocalNameMap
+            public for use in SVGElement.
+        * svg/SVGElement.cpp: Use HTMLElement code to parse "on" event
+            attributes.
+        (WebCore::SVGElement::parseAttribute):
+
 2014-05-05  Zan Dobersek  <zdober...@igalia.com>
 
         [Soup] Use std::unique_ptr<char[]> for the read buffer in SocketStreamHandle

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (168357 => 168358)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2014-05-06 14:04:13 UTC (rev 168358)
@@ -220,7 +220,7 @@
         StyledElement::collectStyleForPresentationAttribute(name, value, style);
 }
 
-static NEVER_INLINE void populateEventNameForAttributeLocalNameMap(HashMap<AtomicStringImpl*, AtomicString>& map)
+void HTMLElement::populateEventNameForAttributeLocalNameMap(HashMap<AtomicStringImpl*, AtomicString>& map)
 {
     static const QualifiedName* const simpleTable[] = {
         &onabortAttr,

Modified: trunk/Source/WebCore/html/HTMLElement.h (168357 => 168358)


--- trunk/Source/WebCore/html/HTMLElement.h	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/Source/WebCore/html/HTMLElement.h	2014-05-06 14:04:13 UTC (rev 168358)
@@ -98,6 +98,8 @@
     virtual bool isLabelable() const { return false; }
     virtual FormNamedItem* asFormNamedItem() { return 0; }
 
+    static void populateEventNameForAttributeLocalNameMap(HashMap<AtomicStringImpl*, AtomicString>&);
+
     bool hasTagName(const HTMLQualifiedName& name) const { return hasLocalName(name.localName()); }
 
 protected:

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (168357 => 168358)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2014-05-06 13:34:58 UTC (rev 168357)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2014-05-06 14:04:13 UTC (rev 168358)
@@ -5,6 +5,7 @@
  * Copyright (C) 2008 Alp Toker <a...@atoker.com>
  * Copyright (C) 2009 Cameron McCormack <c...@mcc.id.au>
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,6 +34,7 @@
 #include "ElementIterator.h"
 #include "Event.h"
 #include "EventNames.h"
+#include "HTMLElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "RenderObject.h"
@@ -471,51 +473,8 @@
 
 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
-    // standard events
-    if (name == onloadAttr)
-        setAttributeEventListener(eventNames().loadEvent, name, value);
-    else if (name == onclickAttr)
-        setAttributeEventListener(eventNames().clickEvent, name, value);
-    else if (name == onmousedownAttr)
-        setAttributeEventListener(eventNames().mousedownEvent, name, value);
-    else if (name == onmouseenterAttr)
-        setAttributeEventListener(eventNames().mouseenterEvent, name, value);
-    else if (name == onmouseleaveAttr)
-        setAttributeEventListener(eventNames().mouseleaveEvent, name, value);
-    else if (name == onmousemoveAttr)
-        setAttributeEventListener(eventNames().mousemoveEvent, name, value);
-    else if (name == onmouseoutAttr)
-        setAttributeEventListener(eventNames().mouseoutEvent, name, value);
-    else if (name == onmouseoverAttr)
-        setAttributeEventListener(eventNames().mouseoverEvent, name, value);
-    else if (name == onmouseupAttr)
-        setAttributeEventListener(eventNames().mouseupEvent, name, value);
-    else if (name == SVGNames::onfocusinAttr)
-        setAttributeEventListener(eventNames().focusinEvent, name, value);
-    else if (name == SVGNames::onfocusoutAttr)
-        setAttributeEventListener(eventNames().focusoutEvent, name, value);
-    else if (name == SVGNames::onactivateAttr)
-        setAttributeEventListener(eventNames().DOMActivateEvent, name, value);
-    else if (name == HTMLNames::classAttr)
+    if (name == HTMLNames::classAttr)
         setClassNameBaseValue(value);
-#if ENABLE(TOUCH_EVENTS)
-    else if (name == ontouchstartAttr)
-        setAttributeEventListener(eventNames().touchstartEvent, name, value);
-    else if (name == ontouchmoveAttr)
-        setAttributeEventListener(eventNames().touchmoveEvent, name, value);
-    else if (name == ontouchendAttr)
-        setAttributeEventListener(eventNames().touchendEvent, name, value);
-    else if (name == ontouchcancelAttr)
-        setAttributeEventListener(eventNames().touchcancelEvent, name, value);
-#endif
-#if ENABLE(IOS_GESTURE_EVENTS)
-    else if (name == ongesturestartAttr)
-        setAttributeEventListener(eventNames().gesturestartEvent, name, value);
-    else if (name == ongesturechangeAttr)
-        setAttributeEventListener(eventNames().gesturechangeEvent, name, value);
-    else if (name == ongestureendAttr)
-        setAttributeEventListener(eventNames().gestureendEvent, name, value);
-#endif
     else if (name == tabindexAttr) {
         int tabindex = 0;
         if (value.isEmpty())
@@ -524,9 +483,21 @@
             // Clamp tabindex to the range of 'short' to match Firefox's behavior.
             setTabIndexExplicitly(std::max(static_cast<int>(std::numeric_limits<short>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
         }
-    } else if (SVGLangSpace::parseAttribute(name, value)) {
-    } else
-        StyledElement::parseAttribute(name, value);
+    } else if (SVGLangSpace::parseAttribute(name, value))
+        return;
+    else {
+        // FIXME: Can we do this even faster by checking the local name "on" prefix before we do anything with the map?
+        // See HTMLElement::parseAttribute().
+        static NeverDestroyed<HashMap<AtomicStringImpl*, AtomicString>> eventNamesGlobal;
+        auto& eventNames = eventNamesGlobal.get();
+        if (eventNames.isEmpty())
+            HTMLElement::populateEventNameForAttributeLocalNameMap(eventNames);
+        const AtomicString& eventName = eventNames.get(name.localName().impl());
+        if (!eventName.isNull())
+            setAttributeEventListener(eventName, name, value);
+        else
+            StyledElement::parseAttribute(name, value);
+    }
 }
 
 void SVGElement::animatedPropertyTypeForAttribute(const QualifiedName& attributeName, Vector<AnimatedPropertyType>& propertyTypes)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to