Changeset 54527 in webkit


Ignore:
Timestamp:
Feb 8, 2010 10:48:48 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-08 Dominic Cooney <dominicc@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):
Location:
trunk/WebCore
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54526 r54527  
     12010-02-08  Dominic Cooney  <dominicc@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        [V8] Move Element custom methods into generic bindings
     6
     7        This patch moves the security checks in setAttribute,
     8        setAttributeNode, setAttributeNS and setAttributeNodeNS from
     9        V8ElementCustom into the generic bindings so that they can be
     10        reused in other bindings. This is in a similar vein to
     11        <https://bugs.webkit.org/attachment.cgi?id=45872>.
     12
     13        https://bugs.webkit.org/show_bug.cgi?id=34554
     14
     15        LayoutTests: None
     16
     17        * WebCore.gypi:
     18        * bindings/generic/BindingElement.h: Added.
     19        (WebCore::::setAttribute):
     20        (WebCore::::setAttributeNode):
     21        (WebCore::::setAttributeNS):
     22        (WebCore::::setAttributeNodeNS):
     23        * bindings/v8/V8Binding.h:
     24        * bindings/v8/custom/V8ElementCustom.cpp:
     25        (WebCore::V8Element::setAttributeCallback):
     26        (WebCore::V8Element::setAttributeNodeCallback):
     27        (WebCore::V8Element::setAttributeNSCallback):
     28        (WebCore::V8Element::setAttributeNodeNSCallback):
     29
    1302010-02-08  Hayato Ito  <hayato@chromium.org>
    231
  • trunk/WebCore/WebCore.gypi

    r54349 r54527  
    451451            'accessibility/wx/AccessibilityObjectWx.cpp',
    452452            'bindings/generic/BindingDOMWindow.h',
     453            'bindings/generic/BindingElement.h',
    453454            'bindings/generic/BindingSecurity.h',
    454455            'bindings/generic/BindingSecurityBase.cpp',
  • trunk/WebCore/bindings/v8/V8Binding.h

    r54038 r54527  
    3333
    3434#include "AtomicString.h"
     35#include "BindingElement.h"
    3536#include "BindingSecurity.h"
    3637#include "MathExtras.h"
     
    5455    };
    5556    typedef BindingSecurity<V8Binding> V8BindingSecurity;
     57    typedef BindingElement<V8Binding> V8BindingElement;
    5658   
    5759    enum ExternalMode {
  • trunk/WebCore/bindings/v8/custom/V8ElementCustom.cpp

    r54349 r54527  
    5959    String value = toWebCoreString(args[1]);
    6060
    61     if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, name, value))
    62         return v8::Undefined();
    63 
    6461    ExceptionCode ec = 0;
    65     element->setAttribute(name, value, ec);
     62    V8BindingElement::setAttribute(V8BindingState::Only(), element, name, value, ec);
    6663    if (ec)
    6764        return throwError(ec);
     
    7976    Element* element = V8Element::toNative(args.Holder());
    8077
    81     if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
    82         return v8::Undefined();
    83 
    8478    ExceptionCode ec = 0;
    85     RefPtr<Attr> result = element->setAttributeNode(newAttr, ec);
     79    RefPtr<Attr> result = V8BindingElement::setAttributeNode(V8BindingState::Only(), element, newAttr, ec);
    8680    if (ec)
    8781        throwError(ec);
     
    9892    String value = toWebCoreString(args[2]);
    9993
    100     if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, qualifiedName, value))
    101         return v8::Undefined();
    102 
    10394    ExceptionCode ec = 0;
    104     element->setAttributeNS(namespaceURI, qualifiedName, value, ec);
     95    V8BindingElement::setAttributeNS(V8BindingState::Only(), element, namespaceURI, qualifiedName, value, ec);
    10596    if (ec)
    10697        throwError(ec);
     
    118109    Element* element = V8Element::toNative(args.Holder());
    119110
    120     if (!V8BindingSecurity::allowSettingSrcToJavascriptURL(V8BindingState::Only(), element, newAttr->name(), newAttr->value()))
    121         return v8::Undefined();
    122 
    123111    ExceptionCode ec = 0;
    124     RefPtr<Attr> result = element->setAttributeNodeNS(newAttr, ec);
     112    RefPtr<Attr> result = V8BindingElement::setAttributeNodeNS(V8BindingState::Only(), element, newAttr, ec);
    125113    if (ec)
    126114        throwError(ec);
Note: See TracChangeset for help on using the changeset viewer.