[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

eric at webkit.org eric at webkit.org
Fri Feb 26 22:15:25 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit f53937c48f94f88f37af01afe2aedac05c93057f
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 9 06:48:48 2010 +0000

    2010-02-08  Dominic Cooney  <dominicc at google.com>
    
            Reviewed by Adam Barth.
    
            [V8] Move Element custom methods into generic bindings
    
            This patch moves the security checks in setAttribute,
            setAttributeNode, setAttributeNS and setAttributeNodeNS from
            V8ElementCustom into the generic bindings so that they can be
            reused in other bindings. This is in a similar vein to
            <https://bugs.webkit.org/attachment.cgi?id=45872>.
    
            https://bugs.webkit.org/show_bug.cgi?id=34554
    
            LayoutTests: None
    
            * WebCore.gypi:
            * bindings/generic/BindingElement.h: Added.
            (WebCore::::setAttribute):
            (WebCore::::setAttributeNode):
            (WebCore::::setAttributeNS):
            (WebCore::::setAttributeNodeNS):
            * bindings/v8/V8Binding.h:
            * bindings/v8/custom/V8ElementCustom.cpp:
            (WebCore::V8Element::setAttributeCallback):
            (WebCore::V8Element::setAttributeNodeCallback):
            (WebCore::V8Element::setAttributeNSCallback):
            (WebCore::V8Element::setAttributeNodeNSCallback):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54527 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 14a683e..9fdf2cf 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-02-08  Dominic Cooney  <dominicc at google.com>
+
+        Reviewed by Adam Barth.
+
+        [V8] Move Element custom methods into generic bindings
+
+        This patch moves the security checks in setAttribute,
+        setAttributeNode, setAttributeNS and setAttributeNodeNS from
+        V8ElementCustom into the generic bindings so that they can be
+        reused in other bindings. This is in a similar vein to
+        <https://bugs.webkit.org/attachment.cgi?id=45872>.
+
+        https://bugs.webkit.org/show_bug.cgi?id=34554
+
+        LayoutTests: None
+
+        * WebCore.gypi:
+        * bindings/generic/BindingElement.h: Added.
+        (WebCore::::setAttribute):
+        (WebCore::::setAttributeNode):
+        (WebCore::::setAttributeNS):
+        (WebCore::::setAttributeNodeNS):
+        * bindings/v8/V8Binding.h:
+        * bindings/v8/custom/V8ElementCustom.cpp:
+        (WebCore::V8Element::setAttributeCallback):
+        (WebCore::V8Element::setAttributeNodeCallback):
+        (WebCore::V8Element::setAttributeNSCallback):
+        (WebCore::V8Element::setAttributeNodeNSCallback):
+
 2010-02-08  Hayato Ito  <hayato at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 7cfd89f..b5499d4 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -450,6 +450,7 @@
             'accessibility/win/AccessibilityObjectWrapperWin.h',
             'accessibility/wx/AccessibilityObjectWx.cpp',
             'bindings/generic/BindingDOMWindow.h',
+            'bindings/generic/BindingElement.h',
             'bindings/generic/BindingSecurity.h',
             'bindings/generic/BindingSecurityBase.cpp',
             'bindings/generic/BindingSecurityBase.h',
diff --git a/WebCore/bindings/generic/BindingElement.h b/WebCore/bindings/generic/BindingElement.h
new file mode 100644
index 0000000..ba7856a
--- /dev/null
+++ b/WebCore/bindings/generic/BindingElement.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BindingElement_h
+#define BindingElement_h
+
+#include "Attr.h"
+#include "BindingSecurity.h"
+#include "Element.h"
+#include "ExceptionCode.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+template <class Binding>
+class BindingElement {
+public:
+    static void setAttribute(State<Binding>*, Element*, const AtomicString&, const AtomicString&, ExceptionCode&);
+    static RefPtr<Attr> setAttributeNode(State<Binding>*, Element*, Attr*, ExceptionCode&);
+    static void setAttributeNS(State<Binding>*, Element*, const AtomicString&, const AtomicString&, const AtomicString&, ExceptionCode&);
+    static RefPtr<Attr> setAttributeNodeNS(State<Binding>*, Element*, Attr*, ExceptionCode&);
+};
+
+// Implementations of templated methods must be in this file.
+
+template <class Binding>
+void BindingElement<Binding>::setAttribute(State<Binding>* state, Element* element, const AtomicString& name, const AtomicString& value, ExceptionCode& ec)
+{
+    ASSERT(element);
+
+    if (!BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(state, element, name, value))
+        return;
+
+    element->setAttribute(name, value, ec);
+}
+
+template <class Binding>
+RefPtr<Attr> BindingElement<Binding>::setAttributeNode(State<Binding>* state, Element* element, Attr* newAttr, ExceptionCode& ec)
+{
+    ASSERT(element);
+    ASSERT(newAttr);
+
+    if (!BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(state, element, newAttr->name(), newAttr->value()))
+        return 0;
+
+    return element->setAttributeNode(newAttr, ec);
+}
+
+template <class Binding>
+void BindingElement<Binding>::setAttributeNS(State<Binding>* state, Element* element, const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode& ec)
+{
+    ASSERT(element);
+
+    if (!BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(state, element, qualifiedName, value))
+        return;
+
+    element->setAttributeNS(namespaceURI, qualifiedName, value, ec);
+}
+
+template <class Binding>
+RefPtr<Attr> BindingElement<Binding>::setAttributeNodeNS(State<Binding>* state, Element* element, Attr* newAttr, ExceptionCode& ec)
+{
+    ASSERT(element);
+    ASSERT(newAttr);
+
+    if (!BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(state, element, newAttr->name(), newAttr->value()))
+        return 0;
+
+    return element->setAttributeNodeNS(newAttr, ec);
+}
+
+} // namespace WebCore
+
+#endif // BindingElement_h
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index 439dfd7..5eaa2dc 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -32,6 +32,7 @@
 #define V8Binding_h
 
 #include "AtomicString.h"
+#include "BindingElement.h"
 #include "BindingSecurity.h"
 #include "MathExtras.h"
 #include "PlatformString.h"
@@ -53,6 +54,7 @@ namespace WebCore {
         typedef V8BindingDOMWindow DOMWindow;
     };
     typedef BindingSecurity<V8Binding> V8BindingSecurity;
+    typedef BindingElement<V8Binding> V8BindingElement;
     
     enum ExternalMode {
         Externalize,
diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
index c3eb13e..8fa8339 100644
--- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp
@@ -58,11 +58,8 @@ v8::Handle<v8::Value> V8Element::setAttributeCallback(const v8::Arguments& args)
     String name = toWebCoreString(args[0]);
     String value = toWebCoreString(args[1]);
 
-    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, name, value))
-        return v8::Undefined();
-
     ExceptionCode ec = 0;
-    element->setAttribute(name, value, ec);
+    V8BindingElement::setAttribute(V8BindingState::Only(), element, name, value, ec);
     if (ec)
         return throwError(ec);
 
@@ -78,11 +75,8 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& a
     Attr* newAttr = V8Attr::toNative(v8::Handle<v8::Object>::Cast(args[0]));
     Element* element = V8Element::toNative(args.Holder());
 
-    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
-        return v8::Undefined();
-
     ExceptionCode ec = 0;
-    RefPtr<Attr> result = element->setAttributeNode(newAttr, ec);
+    RefPtr<Attr> result = V8BindingElement::setAttributeNode(V8BindingState::Only(), element, newAttr, ec);
     if (ec)
         throwError(ec);
 
@@ -97,11 +91,8 @@ v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& arg
     String qualifiedName = toWebCoreString(args[1]);
     String value = toWebCoreString(args[2]);
 
-    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, qualifiedName, value))
-        return v8::Undefined();
-
     ExceptionCode ec = 0;
-    element->setAttributeNS(namespaceURI, qualifiedName, value, ec);
+    V8BindingElement::setAttributeNS(V8BindingState::Only(), element, namespaceURI, qualifiedName, value, ec);
     if (ec)
         throwError(ec);
 
@@ -117,11 +108,8 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments&
     Attr* newAttr = V8Attr::toNative(v8::Handle<v8::Object>::Cast(args[0]));
     Element* element = V8Element::toNative(args.Holder());
 
-    if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
-        return v8::Undefined();
-
     ExceptionCode ec = 0;
-    RefPtr<Attr> result = element->setAttributeNodeNS(newAttr, ec);
+    RefPtr<Attr> result = V8BindingElement::setAttributeNodeNS(V8BindingState::Only(), element, newAttr, ec);
     if (ec)
         throwError(ec);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list