Changeset 20214 in webkit


Ignore:
Timestamp:
Mar 15, 2007 12:07:15 PM (17 years ago)
Author:
bdakin
Message:

Rubber-stamped by Adele.

Rolling out http://trac.webkit.org/projects/webkit/changeset/20148
(which is a fix for http://bugs.webkit.org/show_bug.cgi?id=12595
and rdar://4722863) because it causes a horrible memory-trasher.

Location:
trunk
Files:
2 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r20209 r20214  
     12007-03-15  Beth Dakin  <bdakin@apple.com>
     2
     3        Rubber-stamped by Adele.
     4
     5        Rolling out http://trac.webkit.org/projects/webkit/changeset/20148
     6        (which is a fix for http://bugs.webkit.org/show_bug.cgi?id=12595
     7        and rdar://4722863) because it causes a horrible memory-trasher.
     8
     9        * fast/forms/old-names-expected.txt: Removed.
     10        * fast/forms/old-names.html: Removed.
     11
    1122007-03-14  Oliver Hunt  <oliver@apple.com>
    213
  • trunk/WebCore/ChangeLog

    r20211 r20214  
     12007-03-15  Beth Dakin  <bdakin@apple.com>
     2
     3        Rubber-stamped by Adele.
     4
     5        Rolling out http://trac.webkit.org/projects/webkit/changeset/20148
     6        (which is a fix for http://bugs.webkit.org/show_bug.cgi?id=12595
     7        and rdar://4722863) because it causes a horrible memory-trasher.
     8
     9        * bindings/js/JSHTMLFormElementCustom.cpp:
     10        (WebCore::JSHTMLFormElement::canGetItemsForName):
     11        (WebCore::JSHTMLFormElement::nameGetter):
     12        * bindings/js/kjs_dom.cpp:
     13        (KJS::):
     14        (KJS::DOMNamedNodesCollection::DOMNamedNodesCollection):
     15        (KJS::DOMNamedNodesCollection::lengthGetter):
     16        (KJS::DOMNamedNodesCollection::indexGetter):
     17        (KJS::DOMNamedNodesCollection::getOwnPropertySlot):
     18        * bindings/js/kjs_dom.h:
     19        (KJS::DOMNamedNodesCollection::classInfo):
     20        * bindings/js/kjs_html.cpp:
     21        (KJS::JSHTMLCollection::getNamedItems):
     22        * dom/ChildNodeList.cpp:
     23        (WebCore::ChildNodeList::ChildNodeList):
     24        (WebCore::ChildNodeList::length):
     25        (WebCore::ChildNodeList::item):
     26        (WebCore::ChildNodeList::nodeMatches):
     27        * dom/ChildNodeList.h:
     28        * dom/NameNodeList.cpp:
     29        (WebCore::NameNodeList::NameNodeList):
     30        (WebCore::NameNodeList::item):
     31        (WebCore::NameNodeList::nodeMatches):
     32        * dom/NameNodeList.h:
     33        (WebCore::NameNodeList::rootNodeAttributeChanged):
     34        * dom/Node.cpp:
     35        (WebCore::TagNodeList::TagNodeList):
     36        (WebCore::TagNodeList::nodeMatches):
     37        (WebCore::Node::registerNodeList):
     38        (WebCore::Node::unregisterNodeList):
     39        * dom/Node.h:
     40        * dom/NodeList.cpp:
     41        (WebCore::NodeList::NodeList):
     42        (WebCore::NodeList::~NodeList):
     43        (WebCore::NodeList::recursiveLength):
     44        (WebCore::NodeList::itemForwardsFromCurrent):
     45        (WebCore::NodeList::itemBackwardsFromCurrent):
     46        (WebCore::NodeList::recursiveItem):
     47        (WebCore::NodeList::itemWithName):
     48        (WebCore::NodeList::rootNodeChildrenChanged):
     49        * dom/NodeList.h:
     50        (WebCore::NodeList::rootNodeAttributeChanged):
     51        * html/HTMLFormElement.cpp:
     52        (WebCore::HTMLFormElement::HTMLFormElement):
     53        (WebCore::HTMLFormElement::~HTMLFormElement):
     54        (WebCore::HTMLFormElement::formData):
     55        (WebCore::HTMLFormElement::parseMappedAttribute):
     56        (WebCore::HTMLFormElement::removeFormElement):
     57        * html/HTMLFormElement.h:
     58        * html/HTMLGenericFormElement.cpp:
     59        (WebCore::HTMLGenericFormElement::parseMappedAttribute):
     60        (WebCore::HTMLGenericFormElement::insertedIntoTree):
     61        * html/HTMLGenericFormElement.h:
     62        * html/HTMLInputElement.cpp:
     63        (WebCore::HTMLInputElement::parseMappedAttribute):
     64
    1652007-03-15  Geoffrey Garen  <ggaren@apple.com>
    266
  • trunk/WebCore/bindings/js/JSHTMLFormElementCustom.cpp

    r20148 r20214  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#include "JSHTMLFormElement.h"
    2828
     29#include "HTMLFormElement.h"
    2930#include "HTMLCollection.h"
    30 #include "HTMLGenericFormElement.h"
    31 #include "HTMLFormElement.h"
    3231
    3332using namespace KJS;
     
    3736bool JSHTMLFormElement::canGetItemsForName(ExecState* exec, HTMLFormElement* form, const AtomicString& propertyName)
    3837{
    39     if (!JSHTMLCollection(exec, form->elements().get()).getNamedItems(exec, propertyName)->isUndefined())
    40         return true;
    41     return !!form->oldNamedElement(propertyName);
     38    // FIXME: ideally there should be a lighter-weight way of doing this
     39    JSValue* namedItems = JSHTMLCollection(exec, form->elements().get()).getNamedItems(exec, propertyName);
     40    return !namedItems->isUndefined();
    4241}
    4342
    4443JSValue* JSHTMLFormElement::nameGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    4544{
    46     HTMLFormElement* form = static_cast<HTMLFormElement*>(static_cast<JSHTMLElement*>(slot.slotBase())->impl());
    47     JSValue* items = JSHTMLCollection(exec, form->elements().get()).getNamedItems(exec, propertyName);
    48     if (!items->isUndefined())
    49         return items;
    50     return toJS(exec, form->oldNamedElement(propertyName));
     45    JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
     46    HTMLFormElement* form = static_cast<HTMLFormElement*>(thisObj->impl());
     47   
     48    return JSHTMLCollection(exec, form->elements().get()).getNamedItems(exec, propertyName);
    5149}
    5250
  • trunk/WebCore/bindings/js/kjs_dom.cpp

    r20148 r20214  
    11221122}
    11231123
     1124// -------------------------------------------------------------------------
     1125
     1126const ClassInfo DOMNamedNodesCollection::info = { "Collection", 0, 0, 0 };
     1127
     1128// Such a collection is usually very short-lived, it only exists
     1129// for constructs like document.forms.<name>[1],
     1130// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
     1131DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState* exec, const Vector<RefPtr<Node> >& nodes)
     1132  : m_nodes(nodes)
     1133{
     1134    setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
     1135}
     1136
     1137JSValue* DOMNamedNodesCollection::lengthGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
     1138{
     1139  DOMNamedNodesCollection *thisObj = static_cast<DOMNamedNodesCollection*>(slot.slotBase());
     1140  return jsNumber(thisObj->m_nodes.size());
     1141}
     1142
     1143JSValue* DOMNamedNodesCollection::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
     1144{
     1145  DOMNamedNodesCollection *thisObj = static_cast<DOMNamedNodesCollection*>(slot.slotBase());
     1146  return toJS(exec, thisObj->m_nodes[slot.index()].get());
     1147}
     1148
     1149bool DOMNamedNodesCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     1150{
     1151  if (propertyName == lengthPropertyName) {
     1152    slot.setCustom(this, lengthGetter);
     1153    return true;
     1154  }
     1155
     1156  // array index ?
     1157  bool ok;
     1158  unsigned idx = propertyName.toUInt32(&ok);
     1159  if (ok && idx < m_nodes.size()) {
     1160    slot.setCustomIndex(this, idx, indexGetter);
     1161    return true;
     1162  }
     1163
     1164  // For IE compatibility, we need to be able to look up elements in a
     1165  // document.formName.name result by id as well as be index.
     1166
     1167  AtomicString atomicPropertyName = propertyName;
     1168  for (unsigned i = 0; i < m_nodes.size(); i++) {
     1169    Node* node = m_nodes[i].get();
     1170    if (node->hasAttributes() && node->attributes()->id() == atomicPropertyName) {
     1171      slot.setCustomIndex(this, i, indexGetter);
     1172      return true;
     1173    }
     1174  }
     1175
     1176  return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
     1177}
     1178
    11241179} // namespace
  • trunk/WebCore/bindings/js/kjs_dom.h

    r20148 r20214  
    143143  JSObject* getDOMExceptionConstructor(ExecState*);
    144144
     145  // Internal class, used for the collection return by e.g. document.forms.myinput
     146  // when multiple nodes have the same name.
     147  class DOMNamedNodesCollection : public DOMObject {
     148  public:
     149    DOMNamedNodesCollection(ExecState *exec, const Vector<RefPtr<WebCore::Node> >& nodes);
     150    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     151    virtual const ClassInfo* classInfo() const { return &info; }
     152    static const ClassInfo info;
     153private:
     154    static JSValue *lengthGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
     155    static JSValue *indexGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
     156
     157    Vector<RefPtr<WebCore::Node> > m_nodes;
     158  };
     159
    145160} // namespace
    146161
  • trunk/WebCore/bindings/js/kjs_html.cpp

    r20148 r20214  
    11// -*- c-basic-offset: 4 -*-
    22/*
     3 *  This file is part of the KDE libraries
    34 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    4  *  Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     5 *  Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    56 *
    67 *  This library is free software; you can redistribute it and/or
     
    6869
    6970namespace KJS {
    70 
    71 class VectorNodeList : public NodeList {
    72 public:
    73     VectorNodeList(const Vector<RefPtr<Node> >& nodes) : m_nodes(nodes) { }
    74 
    75     virtual unsigned length() const { return m_nodes.size(); }
    76     virtual Node* item(unsigned index) const { return index < m_nodes.size() ? m_nodes[index].get() : 0; }
    77 
    78 private:
    79     Vector<RefPtr<Node> > m_nodes;
    80 };
    8171
    8272class HTMLElementFunction : public InternalFunctionImp {
     
    15611551        return toJS(exec, namedItems[0].get());
    15621552
    1563     return toJS(exec, new VectorNodeList(namedItems));
     1553    return new DOMNamedNodesCollection(exec, namedItems);
    15641554}
    15651555
  • trunk/WebCore/dom/ChildNodeList.cpp

    r20148 r20214  
    2525#include "config.h"
    2626#include "ChildNodeList.h"
    27 
    28 #include "Element.h"
     27#include "Node.h"
    2928
    3029using namespace WebCore;
     
    3231namespace WebCore {
    3332
    34 ChildNodeList::ChildNodeList(Node* n)
    35     : TreeNodeList(n)
     33ChildNodeList::ChildNodeList( Node *n )
     34    : NodeList(n)
    3635{
    3736}
     
    4342
    4443    unsigned len = 0;
    45     for (Node* n = rootNode->firstChild(); n; n = n->nextSibling())
     44    Node *n;
     45    for(n = rootNode->firstChild(); n != 0; n = n->nextSibling())
    4646        len++;
    4747
     
    5252}
    5353
    54 Node *ChildNodeList::item(unsigned index) const
     54Node *ChildNodeList::item ( unsigned index ) const
    5555{
    5656    unsigned int pos = 0;
    57     Node* n = rootNode->firstChild();
     57    Node *n = rootNode->firstChild();
    5858
    5959    if (isItemCacheValid) {
     
    8181}
    8282
    83 bool ChildNodeList::elementMatches(Element* element) const
     83bool ChildNodeList::nodeMatches(Node *testNode) const
    8484{
    85     return element->parentNode() == rootNode;
     85    return testNode->parentNode() == rootNode;
    8686}
    8787
  • trunk/WebCore/dom/ChildNodeList.h

    r20148 r20214  
    3030namespace WebCore {
    3131
    32 class ChildNodeList : public TreeNodeList {
     32class ChildNodeList : public NodeList {
    3333public:
    3434    ChildNodeList(Node*);
     
    3838
    3939protected:
    40     virtual bool elementMatches(Element*) const;
     40    virtual bool nodeMatches(Node* testNode) const;
    4141};
    4242
  • trunk/WebCore/dom/NameNodeList.cpp

    r20148 r20214  
    2929#include "HTMLNames.h"
    3030
     31using namespace WebCore;
     32
    3133namespace WebCore {
    3234
    3335using namespace HTMLNames;
    3436
    35 NameNodeList::NameNodeList(Node* n, const String &t)
    36     : TreeNodeList(n)
    37     , nodeName(t)
     37NameNodeList::NameNodeList(Node *n, const String &t)
     38  : NodeList(n), nodeName(t)
    3839{
    3940}
     
    4445}
    4546
    46 Node *NameNodeList::item(unsigned index) const
     47Node *NameNodeList::item (unsigned index) const
    4748{
    4849    return recursiveItem(index);
    4950}
    5051
    51 bool NameNodeList::elementMatches(Element* element) const
     52bool NameNodeList::nodeMatches(Node *testNode) const
    5253{
    53     return element->getAttribute(nameAttr) == nodeName;
     54    return static_cast<Element*>(testNode)->getAttribute(nameAttr) == nodeName;
    5455}
    5556
  • trunk/WebCore/dom/NameNodeList.h

    r20148 r20214  
    3434 * NodeList which lists all Nodes in a Element with a given "name=" tag
    3535 */
    36 class NameNodeList : public TreeNodeList {
     36class NameNodeList : public NodeList {
    3737public:
    3838    NameNodeList(Node* doc, const String& name);
     
    4545    // Other methods (not part of DOM)
    4646    virtual void rootNodeChildrenChanged() { }
    47     virtual void rootNodeAttributeChanged() { TreeNodeList::rootNodeChildrenChanged(); }
     47    virtual void rootNodeAttributeChanged() { NodeList::rootNodeChildrenChanged(); }
    4848
    4949protected:
    50     virtual bool elementMatches(Element*) const;
     50    virtual bool nodeMatches(Node* testNode) const;
    5151
    5252    String nodeName;
  • trunk/WebCore/dom/Node.cpp

    r20148 r20214  
    5151 * NodeList which lists all Nodes in a document with a given tag name
    5252 */
    53 class TagNodeList : public TreeNodeList {
     53class TagNodeList : public NodeList
     54{
    5455public:
    55     TagNodeList(Node*, const AtomicString& namespaceURI, const AtomicString& localName);
    56 
     56    TagNodeList(Node *n, const AtomicString& namespaceURI, const AtomicString& localName);
     57
     58    // DOM methods overridden from  parent classes
    5759    virtual unsigned length() const;
    58     virtual Node *item(unsigned index) const;
     60    virtual Node *item (unsigned index) const;
     61
     62    // Other methods (not part of DOM)
    5963
    6064protected:
    61     virtual bool elementMatches(Element*) const;
     65    virtual bool nodeMatches(Node *testNode) const;
    6266
    6367    AtomicString m_namespaceURI;
     
    6670
    6771TagNodeList::TagNodeList(Node *n, const AtomicString& namespaceURI, const AtomicString& localName)
    68     : TreeNodeList(n),
     72    : NodeList(n),
    6973      m_namespaceURI(namespaceURI),
    7074      m_localName(localName)
     
    8286}
    8387
    84 bool TagNodeList::elementMatches(Element* testNode) const
    85 {
     88bool TagNodeList::nodeMatches(Node *testNode) const
     89{
     90    if (!testNode->isElementNode())
     91        return false;
     92
    8693    if (m_namespaceURI != starAtom && m_namespaceURI != testNode->namespaceURI())
    8794        return false;
     
    421428}
    422429
    423 void Node::registerNodeList(TreeNodeList* list)
     430void Node::registerNodeList(NodeList* list)
    424431{
    425432    if (!m_nodeLists)
     
    428435}
    429436
    430 void Node::unregisterNodeList(TreeNodeList* list)
     437void Node::unregisterNodeList(NodeList* list)
    431438{
    432439    if (!m_nodeLists)
  • trunk/WebCore/dom/Node.h

    r20148 r20214  
    5555class RenderStyle;
    5656class TextStream;
    57 class TreeNodeList;
    5857
    5958typedef int ExceptionCode;
     
    441440#endif
    442441
    443     void registerNodeList(TreeNodeList*);
    444     void unregisterNodeList(TreeNodeList*);
     442    void registerNodeList(NodeList*);
     443    void unregisterNodeList(NodeList*);
    445444    void notifyNodeListsChildrenChanged();
    446445    void notifyLocalNodeListsChildrenChanged();
     
    458457
    459458protected:
    460     typedef HashSet<TreeNodeList*> NodeListSet;
     459    typedef HashSet<NodeList*> NodeListSet;
    461460    NodeListSet* m_nodeLists;
    462461
  • trunk/WebCore/dom/NodeList.cpp

    r20148 r20214  
    11/**
     2 * This file is part of the DOM implementation for KDE.
     3 *
    24 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    35 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    46 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
     7 * Copyright (C) 2004, 2006 Apple Computer, Inc.
    68 *
    79 * This library is free software; you can redistribute it and/or
     
    2931namespace WebCore {
    3032
    31 NodeList::~NodeList()
    32 {
    33 }
    34 
    35 Node* NodeList::itemWithName(const AtomicString& name) const
    36 {
    37     unsigned l = length();
    38     for (unsigned i = 0; i < l; i++) {
    39         Node* node = item(i);
    40         if (node->isElementNode() && static_cast<Element*>(node)->getIDAttribute() == name)
    41             return node;
    42     }
    43     return 0;
    44 }
    45 
    46 TreeNodeList::TreeNodeList(PassRefPtr<Node> _rootNode)
     33NodeList::NodeList(PassRefPtr<Node> _rootNode)
    4734    : rootNode(_rootNode),
    4835      isLengthCacheValid(false),
     
    5239}   
    5340
    54 TreeNodeList::~TreeNodeList()
     41NodeList::~NodeList()
    5542{
    5643    rootNode->unregisterNodeList(this);
    5744}
    5845
    59 unsigned TreeNodeList::recursiveLength(Node* start) const
     46unsigned NodeList::recursiveLength(Node* start) const
    6047{
    6148    if (!start)
     
    6956    for (Node* n = start->firstChild(); n; n = n->nextSibling())
    7057        if (n->isElementNode()) {
    71             len += elementMatches(static_cast<Element*>(n));
     58            if (nodeMatches(n))
     59                len++;
    7260            len += recursiveLength(n);
    7361        }
     
    8169}
    8270
    83 Node* TreeNodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
     71Node* NodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
    8472{
    8573    ASSERT(remainingOffset >= 0);
     
    8775    for (Node *n = start; n; n = n->traverseNextNode(rootNode.get())) {
    8876        if (n->isElementNode()) {
    89             if (elementMatches(static_cast<Element*>(n))) {
     77            if (nodeMatches(n)) {
    9078                if (!remainingOffset) {
    9179                    lastItem = n;
     
    10290}
    10391
    104 Node* TreeNodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
     92Node* NodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const
    10593{
    10694    ASSERT(remainingOffset < 0);
    10795    for (Node *n = start; n; n = n->traversePreviousNode(rootNode.get())) {
    10896        if (n->isElementNode()) {
    109             if (elementMatches(static_cast<Element*>(n))) {
     97            if (nodeMatches(n)) {
    11098                if (!remainingOffset) {
    11199                    lastItem = n;
     
    122110}
    123111
    124 Node* TreeNodeList::recursiveItem(unsigned offset, Node* start) const
     112Node* NodeList::recursiveItem(unsigned offset, Node* start) const
    125113{
    126114    int remainingOffset = offset;
     
    143131}
    144132
    145 Node* TreeNodeList::itemWithName(const AtomicString& name) const
     133Node* NodeList::itemWithName(const AtomicString& elementId) const
    146134{
    147135    if (rootNode->isDocumentNode() || rootNode->inDocument()) {
    148         Element* node = rootNode->document()->getElementById(name);
    149         if (!node || !elementMatches(node))
     136        Node* node = rootNode->document()->getElementById(elementId);
     137
     138        if (!node || !nodeMatches(node))
    150139            return 0;
    151140
     
    157146    }
    158147
    159     return NodeList::itemWithName(name);
     148    unsigned l = length();
     149    for (unsigned i = 0; i < l; i++) {
     150        Node* node = item(i);
     151        if (node->isElementNode() && static_cast<Element*>(node)->getIDAttribute() == elementId)
     152            return node;
     153    }
     154
     155    return 0;
    160156}
    161157
    162 void TreeNodeList::rootNodeAttributeChanged()
    163 {
    164 }
    165 
    166 void TreeNodeList::rootNodeChildrenChanged()
     158void NodeList::rootNodeChildrenChanged()
    167159{
    168160    isLengthCacheValid = false;
  • trunk/WebCore/dom/NodeList.h

    r20148 r20214  
    11/*
     2 * This file is part of the DOM implementation for KDE.
     3 *
    24 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    35 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    46 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
     7 * Copyright (C) 2004, 2006 Apple Computer, Inc.
    68 *
    79 * This library is free software; you can redistribute it and/or
     
    3234
    3335class AtomicString;
    34 class Element;
    3536class Node;
    3637
    3738class NodeList : public Shared<NodeList> {
    3839public:
     40    NodeList(PassRefPtr<Node> rootNode);
    3941    virtual ~NodeList();
    4042
     43    // DOM methods & attributes for NodeList
    4144    virtual unsigned length() const = 0;
    4245    virtual Node* item(unsigned index) const = 0;
    43     virtual Node* itemWithName(const AtomicString&) const;
    44 };
     46    Node* itemWithName(const AtomicString&) const;
    4547
    46 // FIXME: Move this to its own source file.
    47 class TreeNodeList : public NodeList {
    48 public:
    49     TreeNodeList(PassRefPtr<Node> rootNode);
    50     virtual ~TreeNodeList();
    51 
    52     virtual Node* itemWithName(const AtomicString&) const;
    53 
     48    // Other methods (not part of DOM)
    5449    virtual void rootNodeChildrenChanged();
    55     virtual void rootNodeAttributeChanged();
     50    virtual void rootNodeAttributeChanged() {}
    5651
    5752protected:
    58     // helper functions for searching all elements in a tree
     53    // helper functions for searching all ElementImpls in a tree
    5954    unsigned recursiveLength(Node* start = 0) const;
    60     Node* recursiveItem(unsigned offset, Node* start = 0) const;
    61     virtual bool elementMatches(Element*) const = 0;
     55    Node* recursiveItem (unsigned offset, Node* start = 0) const;
     56    virtual bool nodeMatches(Node* testNode) const = 0;
    6257
    6358    RefPtr<Node> rootNode;
  • trunk/WebCore/html/HTMLFormElement.cpp

    r20197 r20214  
    5050HTMLFormElement::HTMLFormElement(Document* doc)
    5151    : HTMLElement(formTag, doc)
    52     , m_oldNames(0)
    53     , collectionInfo(0)
    54     , m_enctype("application/x-www-form-urlencoded")
    55     , m_post(false)
    56     , m_multipart(false)
    57     , m_autocomplete(true)
    58     , m_insubmit(false)
    59     , m_doingsubmit(false)
    60     , m_inreset(false)
    61     , m_malformed(false)
    62     , m_preserveAcrossRemove(false)
    63 {
     52{
     53    collectionInfo = 0;
     54    m_post = false;
     55    m_multipart = false;
     56    m_autocomplete = true;
     57    m_insubmit = false;
     58    m_doingsubmit = false;
     59    m_inreset = false;
     60    m_enctype = "application/x-www-form-urlencoded";
     61    m_malformed = false;
     62    m_preserveAcrossRemove = false;
    6463}
    6564
    6665HTMLFormElement::~HTMLFormElement()
    6766{
    68     delete m_oldNames;
    6967    delete collectionInfo;
    7068   
     
    275273                    if (current->hasLocalName(inputTag) &&
    276274                        static_cast<HTMLInputElement*>(current)->inputType() == HTMLInputElement::FILE) {
    277                         const AtomicString& path = static_cast<HTMLInputElement*>(current)->value();
     275                        String path = static_cast<HTMLInputElement*>(current)->value();
    278276
    279277                        // FIXME: This won't work if the filename includes a " mark,
     
    282280                        // in the website's character set.
    283281                        hstr += "; filename=\"";
    284                         int start = path.domString().reverseFind('/') + 1;
     282                        int start = path.reverseFind('/') + 1;
    285283                        int length = path.length() - start;
    286284                        hstr += encoding.encode(reinterpret_cast<const UChar*>(path.characters() + start), length, true);
    287285                        hstr += "\"";
    288286
    289                         if (!path.isEmpty()) {
     287                        if (!static_cast<HTMLInputElement*>(current)->value().isEmpty()) {
    290288                            DeprecatedString mimeType = MimeTypeRegistry::getMIMETypeForPath(path).deprecatedString();
    291289                            if (!mimeType.isEmpty()) {
     
    501499        setHTMLEventListener(resetEvent, attr);
    502500    else if (attr->name() == nameAttr) {
    503         const AtomicString& newNameAttr = attr->value();
     501        String newNameAttr = attr->value();
    504502        if (inDocument() && document()->isHTMLDocument()) {
    505503            HTMLDocument *doc = static_cast<HTMLDocument *>(document());
     
    562560        if (currentCheckedRadio == e)
    563561            document()->removeRadioButtonGroup(e->name().impl(), this);
    564         formElementNameChanged(e, e->name());
    565562    }
    566563    removeFromVector(formElements, e);
     
    568565}
    569566
    570 void HTMLFormElement::formElementNameChanged(HTMLGenericFormElement* element, const AtomicString& oldName)
    571 {
    572     if (oldName.isEmpty())
    573         return;
    574     if (!m_oldNames)
    575         m_oldNames = new OldNameMap;
    576     m_oldNames->set(oldName.impl(), element);
    577 }
    578 
    579 HTMLGenericFormElement* HTMLFormElement::oldNamedElement(const AtomicString& oldName) const
    580 {
    581     if (oldName.isEmpty())
    582         return 0;
    583     if (!m_oldNames)
    584         return 0;
    585     return m_oldNames->get(oldName.impl()).get();
    586 }
    587 
    588567bool HTMLFormElement::isURLAttribute(Attribute *attr) const
    589568{
  • trunk/WebCore/html/HTMLFormElement.h

    r20148 r20214  
    6666    void registerFormElement(HTMLGenericFormElement*);
    6767    void removeFormElement(HTMLGenericFormElement*);
    68     void formElementNameChanged(HTMLGenericFormElement*, const AtomicString& oldName);
    69 
    7068    void registerImgElement(HTMLImageElement*);
    7169    void removeImgElement(HTMLImageElement*);
     
    102100    void setTarget(const String&);
    103101
    104     HTMLGenericFormElement* oldNamedElement(const AtomicString& oldName) const;
    105 
    106102    // FIXME: Change this to be private after getting rid of all the clients.
    107103    Vector<HTMLGenericFormElement*> formElements;
     
    114110    friend class HTMLFormCollection;
    115111
    116     typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLGenericFormElement> > OldNameMap;
    117 
    118     OldNameMap* m_oldNames;
    119112    HTMLCollection::CollectionInfo* collectionInfo;
    120113
     
    123116    String m_target;
    124117    String m_enctype;
     118    String m_boundary;
    125119    String m_acceptcharset;
    126120    bool m_post : 1;
  • trunk/WebCore/html/HTMLGenericFormElement.cpp

    r20148 r20214  
    11/*
     2 * This file is part of the DOM implementation for KDE.
     3 *
    24 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    35 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    46 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
    68 *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
    79 *
     
    5456}
    5557
    56 void HTMLGenericFormElement::parseMappedAttribute(MappedAttribute* attr)
     58void HTMLGenericFormElement::parseMappedAttribute(MappedAttribute *attr)
    5759{
    5860    if (attr->name() == nameAttr) {
    59         if (m_form) {
    60             m_form->formElementNameChanged(this, m_oldName);
    61             m_oldName = name();
    62         }
     61        // Do nothing.
    6362    } else if (attr->name() == disabledAttr) {
    6463        bool oldDisabled = m_disabled;
     
    102101        // and so we don't need to do anything.
    103102        m_form = getForm();
    104         if (m_form) {
     103        if (m_form)
    105104            m_form->registerFormElement(this);
    106             m_oldName = name();
    107         } else
     105        else
    108106            if (isRadioButton() && !name().isEmpty() && isChecked())
    109107                document()->radioButtonChecked((HTMLInputElement*)this, m_form);
  • trunk/WebCore/html/HTMLGenericFormElement.h

    r20148 r20214  
    107107    bool m_readOnly;
    108108    mutable bool m_valueMatchesRenderer;
    109     AtomicString m_oldName;
     109
    110110};
    111111
  • trunk/WebCore/html/HTMLInputElement.cpp

    r20148 r20214  
    592592                document()->radioButtonChecked(this, form());
    593593        }
    594         HTMLGenericFormElement::parseMappedAttribute(attr);
    595594    } else if (attr->name() == autocompleteAttr) {
    596595        m_autocomplete = !equalIgnoringCase(attr->value(), "off");
Note: See TracChangeset for help on using the changeset viewer.