Changeset 141300 in webkit


Ignore:
Timestamp:
Jan 30, 2013 12:51:07 PM (11 years ago)
Author:
benjamin@webkit.org
Message:

Do not convert to String->AtomicString for NamedNodeMap
https://bugs.webkit.org/show_bug.cgi?id=108289

Reviewed by Kentaro Hara.

NamedNodeMap's API was taking a WTF::String. Internally, attribute
names are AtomicString.

The conversions String->AtomicString was causing an additional ref-deref
for the JS/V8 bindings. And could cause an additional memory allocation for the Objective-C
bindings.

This patch changes the API to use AtomicString, and update the custom bindings accordingly.

  • bindings/js/JSNamedNodeMapCustom.cpp:

(WebCore::JSNamedNodeMap::canGetItemsForName):
(WebCore::JSNamedNodeMap::nameGetter):

  • bindings/v8/custom/V8NamedNodeMapCustom.cpp:

(WebCore::V8NamedNodeMap::namedPropertyGetter):

  • dom/NamedNodeMap.cpp:

(WebCore::NamedNodeMap::getNamedItem):
(WebCore::NamedNodeMap::getNamedItemNS):
(WebCore::NamedNodeMap::removeNamedItem):
(WebCore::NamedNodeMap::removeNamedItemNS):

  • dom/NamedNodeMap.h:

(NamedNodeMap):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141299 r141300  
     12013-01-30  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        Do not convert to String->AtomicString for NamedNodeMap
     4        https://bugs.webkit.org/show_bug.cgi?id=108289
     5
     6        Reviewed by Kentaro Hara.
     7
     8        NamedNodeMap's API was taking a WTF::String. Internally, attribute
     9        names are AtomicString.
     10
     11        The conversions String->AtomicString was causing an additional ref-deref
     12        for the JS/V8 bindings. And could cause an additional memory allocation for the Objective-C
     13        bindings.
     14
     15        This patch changes the API to use AtomicString, and update the custom bindings accordingly.
     16
     17        * bindings/js/JSNamedNodeMapCustom.cpp:
     18        (WebCore::JSNamedNodeMap::canGetItemsForName):
     19        (WebCore::JSNamedNodeMap::nameGetter):
     20        * bindings/v8/custom/V8NamedNodeMapCustom.cpp:
     21        (WebCore::V8NamedNodeMap::namedPropertyGetter):
     22        * dom/NamedNodeMap.cpp:
     23        (WebCore::NamedNodeMap::getNamedItem):
     24        (WebCore::NamedNodeMap::getNamedItemNS):
     25        (WebCore::NamedNodeMap::removeNamedItem):
     26        (WebCore::NamedNodeMap::removeNamedItemNS):
     27        * dom/NamedNodeMap.h:
     28        (NamedNodeMap):
     29
    1302013-01-30  Zan Dobersek  <zdobersek@igalia.com>
    231
  • trunk/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp

    r116828 r141300  
    11/*
    2  * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, PropertyName propertyName)
    3939{
    40     return impl->getNamedItem(propertyNameToString(propertyName));
     40    return impl->getNamedItem(propertyNameToAtomicString(propertyName));
    4141}
    4242
     
    4444{
    4545    JSNamedNodeMap* thisObj = jsCast<JSNamedNodeMap*>(asObject(slotBase));
    46     return toJS(exec, thisObj->globalObject(), thisObj->impl()->getNamedItem(propertyNameToString(propertyName)));
     46    return toJS(exec, thisObj->globalObject(), thisObj->impl()->getNamedItem(propertyNameToAtomicString(propertyName)));
    4747}
    4848
  • trunk/Source/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp

    r138677 r141300  
    6161
    6262    NamedNodeMap* imp = V8NamedNodeMap::toNative(info.Holder());
    63     RefPtr<Node> result = imp->getNamedItem(toWebCoreString(name));
     63    RefPtr<Node> result = imp->getNamedItem(toWebCoreAtomicString(name));
    6464    if (!result)
    6565        return v8Undefined();
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r118174 r141300  
    44 *           (C) 2001 Peter Kelly (pmk@post.com)
    55 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    6  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
    77 *           (C) 2007 Eric Seidel (eric@webkit.org)
    88 *
     
    5151}
    5252
    53 PassRefPtr<Node> NamedNodeMap::getNamedItem(const String& name) const
     53PassRefPtr<Node> NamedNodeMap::getNamedItem(const AtomicString& name) const
    5454{
    5555    return m_element->getAttributeNode(name);
    5656}
    5757
    58 PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const String& namespaceURI, const String& localName) const
     58PassRefPtr<Node> NamedNodeMap::getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const
    5959{
    6060    return m_element->getAttributeNodeNS(namespaceURI, localName);
    6161}
    6262
    63 PassRefPtr<Node> NamedNodeMap::removeNamedItem(const String& name, ExceptionCode& ec)
     63PassRefPtr<Node> NamedNodeMap::removeNamedItem(const AtomicString& name, ExceptionCode& ec)
    6464{
    6565    size_t index = m_element->getAttributeItemIndex(name, shouldIgnoreAttributeCase(m_element));
     
    7171}
    7272
    73 PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)
     73PassRefPtr<Node> NamedNodeMap::removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode& ec)
    7474{
    7575    size_t index = m_element->getAttributeItemIndex(QualifiedName(nullAtom, localName, namespaceURI));
  • trunk/Source/WebCore/dom/NamedNodeMap.h

    r135058 r141300  
    44 *           (C) 2001 Peter Kelly (pmk@post.com)
    55 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    6  * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
     6 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2013 Apple Inc. All rights reserved.
    77 *
    88 * This library is free software; you can redistribute it and/or
     
    2929#include <wtf/PassOwnPtr.h>
    3030#include <wtf/PassRefPtr.h>
    31 #include <wtf/text/WTFString.h>
     31#include <wtf/text/AtomicString.h>
    3232
    3333namespace WebCore {
     
    5252    // Public DOM interface.
    5353
    54     PassRefPtr<Node> getNamedItem(const String& name) const;
    55     PassRefPtr<Node> removeNamedItem(const String& name, ExceptionCode&);
     54    PassRefPtr<Node> getNamedItem(const AtomicString&) const;
     55    PassRefPtr<Node> removeNamedItem(const AtomicString& name, ExceptionCode&);
    5656
    57     PassRefPtr<Node> getNamedItemNS(const String& namespaceURI, const String& localName) const;
    58     PassRefPtr<Node> removeNamedItemNS(const String& namespaceURI, const String& localName, ExceptionCode&);
     57    PassRefPtr<Node> getNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
     58    PassRefPtr<Node> removeNamedItemNS(const AtomicString& namespaceURI, const AtomicString& localName, ExceptionCode&);
    5959
    6060    PassRefPtr<Node> setNamedItem(Node*, ExceptionCode&);
Note: See TracChangeset for help on using the changeset viewer.