Changeset 20214 in webkit
- Timestamp:
- Mar 15, 2007 12:07:15 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r20209 r20214 1 2007-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 1 12 2007-03-14 Oliver Hunt <oliver@apple.com> 2 13 -
trunk/WebCore/ChangeLog
r20211 r20214 1 2007-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 1 65 2007-03-15 Geoffrey Garen <ggaren@apple.com> 2 66 -
trunk/WebCore/bindings/js/JSHTMLFormElementCustom.cpp
r20148 r20214 1 1 /* 2 * Copyright (C) 2006 , 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "JSHTMLFormElement.h" 28 28 29 #include "HTMLFormElement.h" 29 30 #include "HTMLCollection.h" 30 #include "HTMLGenericFormElement.h"31 #include "HTMLFormElement.h"32 31 33 32 using namespace KJS; … … 37 36 bool JSHTMLFormElement::canGetItemsForName(ExecState* exec, HTMLFormElement* form, const AtomicString& propertyName) 38 37 { 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(); 42 41 } 43 42 44 43 JSValue* JSHTMLFormElement::nameGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) 45 44 { 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); 51 49 } 52 50 -
trunk/WebCore/bindings/js/kjs_dom.cpp
r20148 r20214 1122 1122 } 1123 1123 1124 // ------------------------------------------------------------------------- 1125 1126 const 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) 1131 DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState* exec, const Vector<RefPtr<Node> >& nodes) 1132 : m_nodes(nodes) 1133 { 1134 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); 1135 } 1136 1137 JSValue* 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 1143 JSValue* 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 1149 bool 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 1124 1179 } // namespace -
trunk/WebCore/bindings/js/kjs_dom.h
r20148 r20214 143 143 JSObject* getDOMExceptionConstructor(ExecState*); 144 144 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; 153 private: 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 145 160 } // namespace 146 161 -
trunk/WebCore/bindings/js/kjs_html.cpp
r20148 r20214 1 1 // -*- c-basic-offset: 4 -*- 2 2 /* 3 * This file is part of the KDE libraries 3 4 * 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. 5 6 * 6 7 * This library is free software; you can redistribute it and/or … … 68 69 69 70 namespace 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 };81 71 82 72 class HTMLElementFunction : public InternalFunctionImp { … … 1561 1551 return toJS(exec, namedItems[0].get()); 1562 1552 1563 return toJS(exec, new VectorNodeList(namedItems));1553 return new DOMNamedNodesCollection(exec, namedItems); 1564 1554 } 1565 1555 -
trunk/WebCore/dom/ChildNodeList.cpp
r20148 r20214 25 25 #include "config.h" 26 26 #include "ChildNodeList.h" 27 28 #include "Element.h" 27 #include "Node.h" 29 28 30 29 using namespace WebCore; … … 32 31 namespace WebCore { 33 32 34 ChildNodeList::ChildNodeList( Node* n)35 : TreeNodeList(n)33 ChildNodeList::ChildNodeList( Node *n ) 34 : NodeList(n) 36 35 { 37 36 } … … 43 42 44 43 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()) 46 46 len++; 47 47 … … 52 52 } 53 53 54 Node *ChildNodeList::item (unsigned index) const54 Node *ChildNodeList::item ( unsigned index ) const 55 55 { 56 56 unsigned int pos = 0; 57 Node *n = rootNode->firstChild();57 Node *n = rootNode->firstChild(); 58 58 59 59 if (isItemCacheValid) { … … 81 81 } 82 82 83 bool ChildNodeList:: elementMatches(Element* element) const83 bool ChildNodeList::nodeMatches(Node *testNode) const 84 84 { 85 return element->parentNode() == rootNode;85 return testNode->parentNode() == rootNode; 86 86 } 87 87 -
trunk/WebCore/dom/ChildNodeList.h
r20148 r20214 30 30 namespace WebCore { 31 31 32 class ChildNodeList : public TreeNodeList {32 class ChildNodeList : public NodeList { 33 33 public: 34 34 ChildNodeList(Node*); … … 38 38 39 39 protected: 40 virtual bool elementMatches(Element*) const;40 virtual bool nodeMatches(Node* testNode) const; 41 41 }; 42 42 -
trunk/WebCore/dom/NameNodeList.cpp
r20148 r20214 29 29 #include "HTMLNames.h" 30 30 31 using namespace WebCore; 32 31 33 namespace WebCore { 32 34 33 35 using namespace HTMLNames; 34 36 35 NameNodeList::NameNodeList(Node* n, const String &t) 36 : TreeNodeList(n) 37 , nodeName(t) 37 NameNodeList::NameNodeList(Node *n, const String &t) 38 : NodeList(n), nodeName(t) 38 39 { 39 40 } … … 44 45 } 45 46 46 Node *NameNodeList::item (unsigned index) const47 Node *NameNodeList::item (unsigned index) const 47 48 { 48 49 return recursiveItem(index); 49 50 } 50 51 51 bool NameNodeList:: elementMatches(Element* element) const52 bool NameNodeList::nodeMatches(Node *testNode) const 52 53 { 53 return element->getAttribute(nameAttr) == nodeName;54 return static_cast<Element*>(testNode)->getAttribute(nameAttr) == nodeName; 54 55 } 55 56 -
trunk/WebCore/dom/NameNodeList.h
r20148 r20214 34 34 * NodeList which lists all Nodes in a Element with a given "name=" tag 35 35 */ 36 class NameNodeList : public TreeNodeList {36 class NameNodeList : public NodeList { 37 37 public: 38 38 NameNodeList(Node* doc, const String& name); … … 45 45 // Other methods (not part of DOM) 46 46 virtual void rootNodeChildrenChanged() { } 47 virtual void rootNodeAttributeChanged() { TreeNodeList::rootNodeChildrenChanged(); }47 virtual void rootNodeAttributeChanged() { NodeList::rootNodeChildrenChanged(); } 48 48 49 49 protected: 50 virtual bool elementMatches(Element*) const;50 virtual bool nodeMatches(Node* testNode) const; 51 51 52 52 String nodeName; -
trunk/WebCore/dom/Node.cpp
r20148 r20214 51 51 * NodeList which lists all Nodes in a document with a given tag name 52 52 */ 53 class TagNodeList : public TreeNodeList { 53 class TagNodeList : public NodeList 54 { 54 55 public: 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 57 59 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) 59 63 60 64 protected: 61 virtual bool elementMatches(Element*) const;65 virtual bool nodeMatches(Node *testNode) const; 62 66 63 67 AtomicString m_namespaceURI; … … 66 70 67 71 TagNodeList::TagNodeList(Node *n, const AtomicString& namespaceURI, const AtomicString& localName) 68 : TreeNodeList(n),72 : NodeList(n), 69 73 m_namespaceURI(namespaceURI), 70 74 m_localName(localName) … … 82 86 } 83 87 84 bool TagNodeList::elementMatches(Element* testNode) const 85 { 88 bool TagNodeList::nodeMatches(Node *testNode) const 89 { 90 if (!testNode->isElementNode()) 91 return false; 92 86 93 if (m_namespaceURI != starAtom && m_namespaceURI != testNode->namespaceURI()) 87 94 return false; … … 421 428 } 422 429 423 void Node::registerNodeList( TreeNodeList* list)430 void Node::registerNodeList(NodeList* list) 424 431 { 425 432 if (!m_nodeLists) … … 428 435 } 429 436 430 void Node::unregisterNodeList( TreeNodeList* list)437 void Node::unregisterNodeList(NodeList* list) 431 438 { 432 439 if (!m_nodeLists) -
trunk/WebCore/dom/Node.h
r20148 r20214 55 55 class RenderStyle; 56 56 class TextStream; 57 class TreeNodeList;58 57 59 58 typedef int ExceptionCode; … … 441 440 #endif 442 441 443 void registerNodeList( TreeNodeList*);444 void unregisterNodeList( TreeNodeList*);442 void registerNodeList(NodeList*); 443 void unregisterNodeList(NodeList*); 445 444 void notifyNodeListsChildrenChanged(); 446 445 void notifyLocalNodeListsChildrenChanged(); … … 458 457 459 458 protected: 460 typedef HashSet< TreeNodeList*> NodeListSet;459 typedef HashSet<NodeList*> NodeListSet; 461 460 NodeListSet* m_nodeLists; 462 461 -
trunk/WebCore/dom/NodeList.cpp
r20148 r20214 1 1 /** 2 * This file is part of the DOM implementation for KDE. 3 * 2 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 6 * (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. 6 8 * 7 9 * This library is free software; you can redistribute it and/or … … 29 31 namespace WebCore { 30 32 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) 33 NodeList::NodeList(PassRefPtr<Node> _rootNode) 47 34 : rootNode(_rootNode), 48 35 isLengthCacheValid(false), … … 52 39 } 53 40 54 TreeNodeList::~TreeNodeList()41 NodeList::~NodeList() 55 42 { 56 43 rootNode->unregisterNodeList(this); 57 44 } 58 45 59 unsigned TreeNodeList::recursiveLength(Node* start) const46 unsigned NodeList::recursiveLength(Node* start) const 60 47 { 61 48 if (!start) … … 69 56 for (Node* n = start->firstChild(); n; n = n->nextSibling()) 70 57 if (n->isElementNode()) { 71 len += elementMatches(static_cast<Element*>(n)); 58 if (nodeMatches(n)) 59 len++; 72 60 len += recursiveLength(n); 73 61 } … … 81 69 } 82 70 83 Node* TreeNodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const71 Node* NodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const 84 72 { 85 73 ASSERT(remainingOffset >= 0); … … 87 75 for (Node *n = start; n; n = n->traverseNextNode(rootNode.get())) { 88 76 if (n->isElementNode()) { 89 if ( elementMatches(static_cast<Element*>(n))) {77 if (nodeMatches(n)) { 90 78 if (!remainingOffset) { 91 79 lastItem = n; … … 102 90 } 103 91 104 Node* TreeNodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const92 Node* NodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const 105 93 { 106 94 ASSERT(remainingOffset < 0); 107 95 for (Node *n = start; n; n = n->traversePreviousNode(rootNode.get())) { 108 96 if (n->isElementNode()) { 109 if ( elementMatches(static_cast<Element*>(n))) {97 if (nodeMatches(n)) { 110 98 if (!remainingOffset) { 111 99 lastItem = n; … … 122 110 } 123 111 124 Node* TreeNodeList::recursiveItem(unsigned offset, Node* start) const112 Node* NodeList::recursiveItem(unsigned offset, Node* start) const 125 113 { 126 114 int remainingOffset = offset; … … 143 131 } 144 132 145 Node* TreeNodeList::itemWithName(const AtomicString& name) const133 Node* NodeList::itemWithName(const AtomicString& elementId) const 146 134 { 147 135 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)) 150 139 return 0; 151 140 … … 157 146 } 158 147 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; 160 156 } 161 157 162 void TreeNodeList::rootNodeAttributeChanged() 163 { 164 } 165 166 void TreeNodeList::rootNodeChildrenChanged() 158 void NodeList::rootNodeChildrenChanged() 167 159 { 168 160 isLengthCacheValid = false; -
trunk/WebCore/dom/NodeList.h
r20148 r20214 1 1 /* 2 * This file is part of the DOM implementation for KDE. 3 * 2 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 6 * (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. 6 8 * 7 9 * This library is free software; you can redistribute it and/or … … 32 34 33 35 class AtomicString; 34 class Element;35 36 class Node; 36 37 37 38 class NodeList : public Shared<NodeList> { 38 39 public: 40 NodeList(PassRefPtr<Node> rootNode); 39 41 virtual ~NodeList(); 40 42 43 // DOM methods & attributes for NodeList 41 44 virtual unsigned length() const = 0; 42 45 virtual Node* item(unsigned index) const = 0; 43 virtual Node* itemWithName(const AtomicString&) const; 44 }; 46 Node* itemWithName(const AtomicString&) const; 45 47 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) 54 49 virtual void rootNodeChildrenChanged(); 55 virtual void rootNodeAttributeChanged() ;50 virtual void rootNodeAttributeChanged() {} 56 51 57 52 protected: 58 // helper functions for searching all elements in a tree53 // helper functions for searching all ElementImpls in a tree 59 54 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; 62 57 63 58 RefPtr<Node> rootNode; -
trunk/WebCore/html/HTMLFormElement.cpp
r20197 r20214 50 50 HTMLFormElement::HTMLFormElement(Document* doc) 51 51 : 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; 64 63 } 65 64 66 65 HTMLFormElement::~HTMLFormElement() 67 66 { 68 delete m_oldNames;69 67 delete collectionInfo; 70 68 … … 275 273 if (current->hasLocalName(inputTag) && 276 274 static_cast<HTMLInputElement*>(current)->inputType() == HTMLInputElement::FILE) { 277 const AtomicString&path = static_cast<HTMLInputElement*>(current)->value();275 String path = static_cast<HTMLInputElement*>(current)->value(); 278 276 279 277 // FIXME: This won't work if the filename includes a " mark, … … 282 280 // in the website's character set. 283 281 hstr += "; filename=\""; 284 int start = path. domString().reverseFind('/') + 1;282 int start = path.reverseFind('/') + 1; 285 283 int length = path.length() - start; 286 284 hstr += encoding.encode(reinterpret_cast<const UChar*>(path.characters() + start), length, true); 287 285 hstr += "\""; 288 286 289 if (! path.isEmpty()) {287 if (!static_cast<HTMLInputElement*>(current)->value().isEmpty()) { 290 288 DeprecatedString mimeType = MimeTypeRegistry::getMIMETypeForPath(path).deprecatedString(); 291 289 if (!mimeType.isEmpty()) { … … 501 499 setHTMLEventListener(resetEvent, attr); 502 500 else if (attr->name() == nameAttr) { 503 const AtomicString&newNameAttr = attr->value();501 String newNameAttr = attr->value(); 504 502 if (inDocument() && document()->isHTMLDocument()) { 505 503 HTMLDocument *doc = static_cast<HTMLDocument *>(document()); … … 562 560 if (currentCheckedRadio == e) 563 561 document()->removeRadioButtonGroup(e->name().impl(), this); 564 formElementNameChanged(e, e->name());565 562 } 566 563 removeFromVector(formElements, e); … … 568 565 } 569 566 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) const580 {581 if (oldName.isEmpty())582 return 0;583 if (!m_oldNames)584 return 0;585 return m_oldNames->get(oldName.impl()).get();586 }587 588 567 bool HTMLFormElement::isURLAttribute(Attribute *attr) const 589 568 { -
trunk/WebCore/html/HTMLFormElement.h
r20148 r20214 66 66 void registerFormElement(HTMLGenericFormElement*); 67 67 void removeFormElement(HTMLGenericFormElement*); 68 void formElementNameChanged(HTMLGenericFormElement*, const AtomicString& oldName);69 70 68 void registerImgElement(HTMLImageElement*); 71 69 void removeImgElement(HTMLImageElement*); … … 102 100 void setTarget(const String&); 103 101 104 HTMLGenericFormElement* oldNamedElement(const AtomicString& oldName) const;105 106 102 // FIXME: Change this to be private after getting rid of all the clients. 107 103 Vector<HTMLGenericFormElement*> formElements; … … 114 110 friend class HTMLFormCollection; 115 111 116 typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLGenericFormElement> > OldNameMap;117 118 OldNameMap* m_oldNames;119 112 HTMLCollection::CollectionInfo* collectionInfo; 120 113 … … 123 116 String m_target; 124 117 String m_enctype; 118 String m_boundary; 125 119 String m_acceptcharset; 126 120 bool m_post : 1; -
trunk/WebCore/html/HTMLGenericFormElement.cpp
r20148 r20214 1 1 /* 2 * This file is part of the DOM implementation for KDE. 3 * 2 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 6 * (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. 6 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 9 * … … 54 56 } 55 57 56 void HTMLGenericFormElement::parseMappedAttribute(MappedAttribute *attr)58 void HTMLGenericFormElement::parseMappedAttribute(MappedAttribute *attr) 57 59 { 58 60 if (attr->name() == nameAttr) { 59 if (m_form) { 60 m_form->formElementNameChanged(this, m_oldName); 61 m_oldName = name(); 62 } 61 // Do nothing. 63 62 } else if (attr->name() == disabledAttr) { 64 63 bool oldDisabled = m_disabled; … … 102 101 // and so we don't need to do anything. 103 102 m_form = getForm(); 104 if (m_form) {103 if (m_form) 105 104 m_form->registerFormElement(this); 106 m_oldName = name(); 107 } else 105 else 108 106 if (isRadioButton() && !name().isEmpty() && isChecked()) 109 107 document()->radioButtonChecked((HTMLInputElement*)this, m_form); -
trunk/WebCore/html/HTMLGenericFormElement.h
r20148 r20214 107 107 bool m_readOnly; 108 108 mutable bool m_valueMatchesRenderer; 109 AtomicString m_oldName; 109 110 110 }; 111 111 -
trunk/WebCore/html/HTMLInputElement.cpp
r20148 r20214 592 592 document()->radioButtonChecked(this, form()); 593 593 } 594 HTMLGenericFormElement::parseMappedAttribute(attr);595 594 } else if (attr->name() == autocompleteAttr) { 596 595 m_autocomplete = !equalIgnoringCase(attr->value(), "off");
Note: See TracChangeset
for help on using the changeset viewer.