Source/WebCore/ChangeLog

 12012-12-06 Ryosuke Niwa <rniwa@webkit.org>
 2
 3 Use ownerNode() instead of base() in HTMLCollection
 4 https://bugs.webkit.org/show_bug.cgi?id=104244
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Use ownerNode() instead of base() in HTMLCollection to match LiveNodeList.
 9 Notice that the definition of base(), which this patch removes, is "return ownerNode()".
 10
 11 * bindings/js/JSHTMLFormControlsCollectionCustom.cpp:
 12 (WebCore::getNamedItems):
 13 * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
 14 (WebCore::JSHTMLOptionsCollection::indexSetter):
 15 (WebCore::JSHTMLOptionsCollection::remove):
 16 * bindings/scripts/CodeGeneratorJS.pm:
 17 (GenerateImplementation):
 18 * bindings/scripts/CodeGeneratorV8.pm:
 19 (GenerateOpaqueRootForGC):
 20 * bindings/scripts/IDLAttributes.txt:
 21 * bindings/v8/custom/V8HTMLFormControlsCollectionCustom.cpp:
 22 (WebCore::getNamedItems):
 23 * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
 24 (WebCore::V8HTMLOptionsCollection::removeCallback):
 25 (WebCore::V8HTMLOptionsCollection::indexedPropertySetter):
 26 * dom/WebKitNamedFlow.cpp:
 27 (WebCore::WebKitNamedFlow::ownerNode):
 28 * dom/WebKitNamedFlow.h:
 29 (WebKitNamedFlow):
 30 * dom/WebKitNamedFlow.idl:
 31 * html/HTMLAllCollection.idl:
 32 * html/HTMLCollection.h:
 33 (HTMLCollection):
 34 * html/HTMLCollection.idl:
 35 * html/HTMLFormControlsCollection.cpp:
 36 (WebCore::HTMLFormControlsCollection::HTMLFormControlsCollection):
 37 (WebCore::HTMLFormControlsCollection::create):
 38 (WebCore::HTMLFormControlsCollection::formControlElements):
 39 (WebCore::HTMLFormControlsCollection::formImageElements):
 40 (WebCore::HTMLFormControlsCollection::namedItem):
 41 (WebCore::HTMLFormControlsCollection::updateNameCache):
 42 * html/HTMLFormControlsCollection.idl:
 43 * html/HTMLNameCollection.cpp:
 44 (WebCore::HTMLNameCollection::~HTMLNameCollection):
 45 (WebCore::HTMLNameCollection::virtualItemAfter):
 46 * html/HTMLOptionsCollection.cpp:
 47 (WebCore::HTMLOptionsCollection::add):
 48 (WebCore::HTMLOptionsCollection::remove):
 49 (WebCore::HTMLOptionsCollection::selectedIndex):
 50 (WebCore::HTMLOptionsCollection::setSelectedIndex):
 51 (WebCore::HTMLOptionsCollection::setLength):
 52 * html/HTMLOptionsCollection.idl:
 53 * html/HTMLPropertiesCollection.cpp:
 54 (WebCore::HTMLPropertiesCollection::updateRefElements):
 55 (WebCore::HTMLPropertiesCollection::namedItem):
 56 * html/HTMLTableRowsCollection.cpp:
 57 (WebCore::HTMLTableRowsCollection::virtualItemAfter):
 58
1592012-12-06 Ulan Degenbaev <ulan@chromium.org>
260
361 [v8] Fix hidden property name of V8ArrayBufferView flag.
136825

Source/WebCore/bindings/js/JSHTMLFormControlsCollectionCustom.cpp

@@static JSValue getNamedItems(ExecState*
4949 return toJS(exec, collection->globalObject(), namedItems[0].get());
5050
5151 ASSERT(collection->impl()->type() == FormControls);
52  return toJS(exec, collection->globalObject(), collection->impl()->base()->radioNodeList(name).get());
 52 return toJS(exec, collection->globalObject(), collection->impl()->ownerNode()->radioNodeList(name).get());
5353}
5454
5555bool JSHTMLFormControlsCollection::canGetItemsForName(ExecState*, HTMLFormControlsCollection* collection, PropertyName propertyName)
136811

Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp

@@void JSHTMLOptionsCollection::setLength(
9090void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue value)
9191{
9292 HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
93  HTMLSelectElement* base = toHTMLSelectElement(imp->base());
 93 HTMLSelectElement* base = toHTMLSelectElement(imp->ownerNode());
9494 selectIndexSetter(base, exec, index, value);
9595}
9696

@@JSValue JSHTMLOptionsCollection::add(Exe
118118JSValue JSHTMLOptionsCollection::remove(ExecState* exec)
119119{
120120 HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
121  JSHTMLSelectElement* base = jsCast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base())));
 121 JSHTMLSelectElement* base = jsCast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->ownerNode())));
122122 return base->remove(exec);
123123}
124124
136811

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateImplementation
25102510 $rootString .= " void* root = WebCore::root(element);\n";
25112511 } elsif ($interfaceName eq "CanvasRenderingContext") {
25122512 $rootString = " void* root = WebCore::root(js${interfaceName}->impl()->canvas());\n";
2513  } elsif (GetGenerateIsReachable($interface) eq "ImplBaseRoot") {
2514  $rootString = " void* root = WebCore::root(js${interfaceName}->impl()->base());\n";
 2513 } elsif (GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") {
 2514 $rootString = " void* root = WebCore::root(js${interfaceName}->impl()->ownerNode());\n";
25152515 } else {
25162516 $rootString = " void* root = WebCore::root(js${interfaceName}->impl());\n";
25172517 }
136811

Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

@@END
195195 if (GetGenerateIsReachable($interface) eq "ImplDocument" ||
196196 GetGenerateIsReachable($interface) eq "ImplElementRoot" ||
197197 GetGenerateIsReachable($interface) eq "ImplOwnerRoot" ||
198  GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot" ||
199  GetGenerateIsReachable($interface) eq "ImplBaseRoot") {
 198 GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot") {
200199
201200 $implIncludes{"V8GCController.h"} = 1;
202201

@@END
205204 $methodName = "element" if (GetGenerateIsReachable($interface) eq "ImplElementRoot");
206205 $methodName = "owner" if (GetGenerateIsReachable($interface) eq "ImplOwnerRoot");
207206 $methodName = "ownerNode" if (GetGenerateIsReachable($interface) eq "ImplOwnerNodeRoot");
208  $methodName = "base" if (GetGenerateIsReachable($interface) eq "ImplBaseRoot");
209207
210208 push(@implContent, <<END);
211209 if (Node* owner = impl->${methodName}())
136811

Source/WebCore/bindings/scripts/IDLAttributes.txt

@@DoNotCheckSecurityOnGetter
5353DoNotCheckSecurityOnSetter
5454EventTarget
5555ExtendsDOMGlobalObject
56 GenerateIsReachable=ImplDocument|ImplElementRoot|ImplBaseRoot
 56GenerateIsReachable=ImplDocument|ImplElementRoot|ImplOwnerNodeRoot
5757Immutable
5858ImplementedAs=*
5959IndexedGetter

@@JSCustomPushEventHandlerScope
7676JSCustomSetter
7777JSCustomToJSObject
7878JSCustomToNativeObject
79 JSGenerateIsReachable=|Impl|ImplContext|ImplDocument|ImplElementRoot|ImplFrame|ImplBaseRoot
 79JSGenerateIsReachable=|Impl|ImplContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
8080JSGenerateToJSObject
8181JSGenerateToNativeObject
8282JSInlineGetOwnPropertySlot

@@V8DependentLifetime
118118V8DoNotCheckSignature
119119V8EnabledAtRuntime=*
120120V8EnabledPerContext=*
121 V8GenerateIsReachable=ImplDocument|ImplElementRoot|ImplOwnerRoot|ImplOwnerNodeRoot|ImplBaseRoot
 121V8GenerateIsReachable=ImplDocument|ImplElementRoot|ImplOwnerRoot|ImplOwnerNodeRoot
122122V8NoWrapperCache
123123V8MeasureAs=*
124124V8ReadOnly
136811

Source/WebCore/bindings/v8/custom/V8HTMLFormControlsCollectionCustom.cpp

@@static v8::Handle<v8::Value> getNamedIte
5050 if (namedItems.size() == 1)
5151 return toV8(namedItems.at(0).release(), creationContext, isolate);
5252
53  return toV8(collection->base()->radioNodeList(name).get(), creationContext, isolate);
 53 return toV8(collection->ownerNode()->radioNodeList(name).get(), creationContext, isolate);
5454}
5555
5656v8::Handle<v8::Value> V8HTMLFormControlsCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
136811

Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp

@@v8::Handle<v8::Value> V8HTMLOptionsColle
8888{
8989 INC_STATS("DOM.HTMLOptionsCollection.remove()");
9090 HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder());
91  HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
 91 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->ownerNode());
9292 return removeElement(base, args);
9393}
9494

@@v8::Handle<v8::Value> V8HTMLOptionsColle
155155{
156156 INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertySetter");
157157 HTMLOptionsCollection* collection = V8HTMLOptionsCollection::toNative(info.Holder());
158  HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base());
 158 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->ownerNode());
159159 return toOptionsCollectionSetter(index, value, base, info.GetIsolate());
160160}
161161
136811

Source/WebCore/dom/WebKitNamedFlow.cpp

@@ScriptExecutionContext* WebKitNamedFlow:
216216 return m_flowManager->document();
217217}
218218
219 Node* WebKitNamedFlow::base() const
 219Node* WebKitNamedFlow::ownerNode() const
220220{
221221 return m_flowManager->document();
222222}
136811

Source/WebCore/dom/WebKitNamedFlow.h

@@public:
6767
6868 // This function is called from the JS binding code to determine if the NamedFlow object is reachable or not.
6969 // If the object has listeners, the object should only be discarded if the parent Document is not reachable.
70  Node* base() const;
 70 Node* ownerNode() const;
7171
7272 void setRenderer(RenderNamedFlowThread* parentFlowThread);
7373
136811

Source/WebCore/dom/WebKitNamedFlow.idl

3030[
3131 EventTarget,
3232 JSGenerateToJSObject,
33  GenerateIsReachable=ImplBaseRoot
 33 GenerateIsReachable=ImplOwnerNodeRoot
3434] interface WebKitNamedFlow {
3535 readonly attribute DOMString name;
3636 readonly attribute boolean overset;
136811

Source/WebCore/html/HTMLAllCollection.idl

2828 NamedGetter,
2929 CustomCall,
3030 MasqueradesAsUndefined,
31  GenerateIsReachable=ImplBaseRoot,
 31 GenerateIsReachable=ImplOwnerNodeRoot,
3232 V8DependentLifetime
3333] interface HTMLAllCollection {
3434 readonly attribute unsigned long length;
136811

Source/WebCore/html/HTMLCollection.h

@@public:
6262 return item(0) && !item(1);
6363 }
6464
65  Node* base() const { return ownerNode(); }
6665 virtual Element* virtualItemAfter(unsigned& offsetInArray, Element*) const;
6766
6867protected:
136811

Source/WebCore/html/HTMLCollection.idl

2222 IndexedGetter,
2323 NamedGetter,
2424 CustomToJSObject,
25  GenerateIsReachable=ImplBaseRoot,
 25 GenerateIsReachable=ImplOwnerNodeRoot,
2626 V8DependentLifetime,
2727 ObjCPolymorphic
2828] interface HTMLCollection {
136811

Source/WebCore/html/HTMLFormControlsCollection.cpp

@@using namespace HTMLNames;
3636// Since the collections are to be "live", we have to do the
3737// calculation every time if anything has changed.
3838
39 HTMLFormControlsCollection::HTMLFormControlsCollection(Node* base)
40  : HTMLCollection(base, FormControls, OverridesItemAfter)
 39HTMLFormControlsCollection::HTMLFormControlsCollection(Node* ownerNode)
 40 : HTMLCollection(ownerNode, FormControls, OverridesItemAfter)
4141{
42  ASSERT(base->hasTagName(formTag) || base->hasTagName(fieldsetTag));
 42 ASSERT(ownerNode->hasTagName(formTag) || ownerNode->hasTagName(fieldsetTag));
4343}
4444
45 PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(Node* base, CollectionType)
 45PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(Node* ownerNode, CollectionType)
4646{
47  return adoptRef(new HTMLFormControlsCollection(base));
 47 return adoptRef(new HTMLFormControlsCollection(ownerNode));
4848}
4949
5050HTMLFormControlsCollection::~HTMLFormControlsCollection()

@@HTMLFormControlsCollection::~HTMLFormCon
5353
5454const Vector<FormAssociatedElement*>& HTMLFormControlsCollection::formControlElements() const
5555{
56  ASSERT(base());
57  ASSERT(base()->hasTagName(formTag) || base()->hasTagName(fieldsetTag));
58  if (base()->hasTagName(formTag))
59  return static_cast<HTMLFormElement*>(base())->associatedElements();
60  return static_cast<HTMLFieldSetElement*>(base())->associatedElements();
 56 ASSERT(ownerNode());
 57 ASSERT(ownerNode()->hasTagName(formTag) || ownerNode()->hasTagName(fieldsetTag));
 58 if (ownerNode()->hasTagName(formTag))
 59 return static_cast<HTMLFormElement*>(ownerNode())->associatedElements();
 60 return static_cast<HTMLFieldSetElement*>(ownerNode())->associatedElements();
6161}
6262
6363const Vector<HTMLImageElement*>& HTMLFormControlsCollection::formImageElements() const
6464{
65  ASSERT(base());
66  ASSERT(base()->hasTagName(formTag));
67  return static_cast<HTMLFormElement*>(base())->imageElements();
 65 ASSERT(ownerNode());
 66 ASSERT(ownerNode()->hasTagName(formTag));
 67 return static_cast<HTMLFormElement*>(ownerNode())->imageElements();
6868}
6969
7070Element* HTMLFormControlsCollection::virtualItemAfter(unsigned& offset, Element* previousItem) const

@@Node* HTMLFormControlsCollection::namedI
111111 // attribute. If a match is not found, the method then searches for an
112112 // object with a matching name attribute, but only on those elements
113113 // that are allowed a name attribute.
114  const Vector<HTMLImageElement*>* imagesElements = base()->hasTagName(fieldsetTag) ? 0 : &formImageElements();
 114 const Vector<HTMLImageElement*>* imagesElements = ownerNode()->hasTagName(fieldsetTag) ? 0 : &formImageElements();
115115 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements, idAttr, name))
116116 return item;
117117

@@void HTMLFormControlsCollection::updateN
144144 }
145145 }
146146
147  if (base()->hasTagName(formTag)) {
 147 if (ownerNode()->hasTagName(formTag)) {
148148 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements();
149149 for (unsigned i = 0; i < imageElementsArray.size(); ++i) {
150150 HTMLImageElement* element = imageElementsArray[i];
136811

Source/WebCore/html/HTMLFormControlsCollection.idl

2121[
2222 IndexedGetter,
2323 NamedGetter,
24  GenerateIsReachable=ImplBaseRoot,
 24 GenerateIsReachable=ImplOwnerNodeRoot,
2525 V8DependentLifetime,
2626] interface HTMLFormControlsCollection : HTMLCollection {
2727 [Custom] Node namedItem(in [Optional=DefaultIsUndefined] DOMString name);
136811

Source/WebCore/html/HTMLNameCollection.cpp

@@HTMLNameCollection::HTMLNameCollection(N
4141
4242HTMLNameCollection::~HTMLNameCollection()
4343{
44  ASSERT(base());
45  ASSERT(base()->isDocumentNode());
 44 ASSERT(ownerNode());
 45 ASSERT(ownerNode()->isDocumentNode());
4646 ASSERT(type() == WindowNamedItems || type() == DocumentNamedItems);
4747
4848 ownerNode()->nodeLists()->removeCacheWithAtomicName(this, type(), m_name);

@@HTMLNameCollection::~HTMLNameCollection(
5151Element* HTMLNameCollection::virtualItemAfter(unsigned& offsetInArray, Element* previous) const
5252{
5353 ASSERT_UNUSED(offsetInArray, !offsetInArray);
54  ASSERT(previous != base());
 54 ASSERT(previous != ownerNode());
5555
5656 Node* current;
5757 if (!previous)
58  current = base()->firstChild();
 58 current = ownerNode()->firstChild();
5959 else
60  current = previous->traverseNextNode(base());
 60 current = previous->traverseNextNode(ownerNode());
6161
62  for (; current; current = current->traverseNextNode(base())) {
 62 for (; current; current = current->traverseNextNode(ownerNode())) {
6363 if (!current->isElementNode())
6464 continue;
6565 Element* e = static_cast<Element*>(current);
136811

Source/WebCore/html/HTMLOptionsCollection.cpp

@@void HTMLOptionsCollection::add(PassRefP
5858 }
5959
6060 ec = 0;
61  HTMLSelectElement* select = toHTMLSelectElement(base());
 61 HTMLSelectElement* select = toHTMLSelectElement(ownerNode());
6262
6363 if (index == -1 || unsigned(index) >= length())
6464 select->add(newOption, 0, ec);

@@void HTMLOptionsCollection::add(PassRefP
7070
7171void HTMLOptionsCollection::remove(int index)
7272{
73  toHTMLSelectElement(base())->remove(index);
 73 toHTMLSelectElement(ownerNode())->remove(index);
7474}
7575
7676int HTMLOptionsCollection::selectedIndex() const
7777{
78  return toHTMLSelectElement(base())->selectedIndex();
 78 return toHTMLSelectElement(ownerNode())->selectedIndex();
7979}
8080
8181void HTMLOptionsCollection::setSelectedIndex(int index)
8282{
83  toHTMLSelectElement(base())->setSelectedIndex(index);
 83 toHTMLSelectElement(ownerNode())->setSelectedIndex(index);
8484}
8585
8686void HTMLOptionsCollection::setLength(unsigned length, ExceptionCode& ec)
8787{
88  toHTMLSelectElement(base())->setLength(length, ec);
 88 toHTMLSelectElement(ownerNode())->setLength(length, ec);
8989}
9090
9191} //namespace
136811

Source/WebCore/html/HTMLOptionsCollection.idl

2222 JSGenerateToNativeObject,
2323 CustomIndexedSetter,
2424 NamedGetter,
25  GenerateIsReachable=ImplBaseRoot,
 25 GenerateIsReachable=ImplOwnerNodeRoot,
2626 V8DependentLifetime,
2727] interface HTMLOptionsCollection : HTMLCollection {
2828 attribute long selectedIndex;
136811

Source/WebCore/html/HTMLPropertiesCollection.cpp

@@void HTMLPropertiesCollection::updateRef
6666
6767 m_itemRefElements.clear();
6868 setItemRefElementsCacheValid();
69  toHTMLElement(base())->getItemRefElements(m_itemRefElements);
 69 toHTMLElement(ownerNode())->getItemRefElements(m_itemRefElements);
7070}
7171
7272static Node* nextNodeWithProperty(Node* rootNode, Node* previous, Node* ownerNode)

@@PassRefPtr<DOMStringList> HTMLProperties
137137
138138PassRefPtr<PropertyNodeList> HTMLPropertiesCollection::namedItem(const String& name) const
139139{
140  return base()->propertyNodeList(name);
 140 return ownerNode()->propertyNodeList(name);
141141}
142142
143143bool HTMLPropertiesCollection::hasNamedItem(const AtomicString& name) const
136811

Source/WebCore/html/HTMLTableRowsCollection.cpp

@@Element* HTMLTableRowsCollection::virtua
166166{
167167 ASSERT_UNUSED(offsetInArray, !offsetInArray);
168168 ASSERT(!previous || (previous->isHTMLElement() && toHTMLElement(previous)->hasLocalName(trTag)));
169  return rowAfter(static_cast<HTMLTableElement*>(base()), static_cast<HTMLTableRowElement*>(previous));
 169 return rowAfter(static_cast<HTMLTableElement*>(ownerNode()), static_cast<HTMLTableRowElement*>(previous));
170170}
171171
172172}
136811