Commit 74edf861 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Merge NamedNodesCollection and StaticNodeList classes

Merge NamedNodesCollection and StaticNodeList classes into a single
StaticNodeTypeList templated class as these are identical besides the type
of Node they hold. NamedNodesCollection was holding Elements so it is now
named StaticElementList which is a typedef to StaticNodeTypeList<Element>.
StaticNodeList holds Node and is now a typedef to StaticNodeTypeList<Node>.

This avoids code duplication and allows for tighter typing when using a
StaticNodeList. As a side effect, memory used by StaticElementList (formely
NamedNodesCollection is now reported to V8 as StaticNodeList code was doing
so).

R=adamk@chromium.org, jochen@chromium.org

Review URL: https://codereview.chromium.org/465483002

git-svn-id: svn://svn.chromium.org/blink/trunk@180084 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6e3f3609
......@@ -34,7 +34,7 @@
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8Element.h"
#include "bindings/core/v8/V8NodeList.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/dom/StaticNodeList.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLAllCollection.h"
......@@ -54,7 +54,7 @@ static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, Atomic
// FIXME: HTML5 specification says this should be a HTMLCollection.
// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection
return toV8(NamedNodesCollection::create(namedItems), info.Holder(), info.GetIsolate());
return toV8(StaticElementList::adopt(namedItems), info.Holder(), info.GetIsolate());
}
template<class CallbackInfo>
......
......@@ -37,7 +37,6 @@
#include "bindings/core/v8/V8Node.h"
#include "bindings/core/v8/V8NodeList.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLOptionsCollection.h"
#include "core/html/HTMLSelectElement.h"
......
......@@ -2065,8 +2065,6 @@
'dom/NameNodeList.cpp',
'dom/NameNodeList.h',
'dom/NamedNodeMap.cpp',
'dom/NamedNodesCollection.cpp',
'dom/NamedNodesCollection.h',
'dom/Node.cpp',
'dom/NodeChildRemovalTracker.cpp',
'dom/NodeChildRemovalTracker.h',
......@@ -2123,7 +2121,6 @@
'dom/ShadowTreeStyleSheetCollection.h',
'dom/SimulatedClickOptions.h',
'dom/SpaceSplitString.cpp',
'dom/StaticNodeList.cpp',
'dom/StaticNodeList.h',
'dom/StringCallback.cpp',
'dom/StringCallback.h',
......
......@@ -1116,7 +1116,7 @@ PassRefPtrWillBeRawPtr<Element> ContainerNode::querySelector(const AtomicString&
return selectorQuery->queryFirst(*this);
}
PassRefPtrWillBeRawPtr<StaticNodeList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState)
PassRefPtrWillBeRawPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState)
{
if (selectors.isEmpty()) {
exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
......
......@@ -36,7 +36,8 @@ class ClassCollection;
class ExceptionState;
class FloatPoint;
class HTMLCollection;
class StaticNodeList;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Element> StaticElementList;
class TagCollection;
enum DynamicRestyleFlags {
......@@ -77,7 +78,7 @@ public:
unsigned countChildren() const;
PassRefPtrWillBeRawPtr<Element> querySelector(const AtomicString& selectors, ExceptionState&);
PassRefPtrWillBeRawPtr<StaticNodeList> querySelectorAll(const AtomicString& selectors, ExceptionState&);
PassRefPtrWillBeRawPtr<StaticElementList> querySelectorAll(const AtomicString& selectors, ExceptionState&);
PassRefPtrWillBeRawPtr<Node> insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* refChild, ExceptionState& = ASSERT_NO_EXCEPTION);
PassRefPtrWillBeRawPtr<Node> replaceChild(PassRefPtrWillBeRawPtr<Node> newChild, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& = ASSERT_NO_EXCEPTION);
......
......@@ -5692,18 +5692,18 @@ void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa
TrackExceptionState exceptionState;
AtomicString selector(metaElementContents.substring(0, firstSemicolon));
RefPtrWillBeRawPtr<StaticNodeList> nodeList = querySelectorAll(selector, exceptionState);
if (!nodeList || exceptionState.hadException())
RefPtrWillBeRawPtr<StaticElementList> elementList = querySelectorAll(selector, exceptionState);
if (!elementList || exceptionState.hadException())
continue;
unsigned nodeListLength = nodeList->length();
unsigned nodeListLength = elementList->length();
if (!nodeListLength)
continue;
StringBuilder markup;
for (unsigned nodeIndex = 0; nodeIndex < nodeListLength; ++nodeIndex) {
Node* node = nodeList->item(nodeIndex);
markup.append(createStyledMarkupForNavigationTransition(node));
Element* element = elementList->item(nodeIndex);
markup.append(createStyledMarkupForNavigationTransition(element));
}
TransitionElementData newElements;
......@@ -5717,13 +5717,13 @@ void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa
void Document::hideTransitionElements(const AtomicString& cssSelector)
{
TrackExceptionState exceptionState;
RefPtrWillBeRawPtr<StaticNodeList> nodeList = querySelectorAll(cssSelector, exceptionState);
if (nodeList && !exceptionState.hadException()) {
unsigned nodeListLength = nodeList->length();
RefPtrWillBeRawPtr<StaticElementList> elementList = querySelectorAll(cssSelector, exceptionState);
if (elementList && !exceptionState.hadException()) {
unsigned nodeListLength = elementList->length();
for (unsigned nodeIndex = 0; nodeIndex < nodeListLength; ++nodeIndex) {
Node* node = nodeList->item(nodeIndex);
toElement(node)->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
Element* element = elementList->item(nodeIndex);
element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
}
}
}
......
......@@ -41,7 +41,8 @@ namespace blink {
class Node;
class QualifiedName;
class StaticNodeList;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Node> StaticNodeList;
class MutationRecord : public RefCountedWillBeGarbageCollectedFinalized<MutationRecord>, public ScriptWrappable {
public:
......
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "config.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/dom/Element.h"
namespace blink {
Element* NamedNodesCollection::item(unsigned index) const
{
if (index < m_nodes.size())
return m_nodes[index].get();
return 0;
}
void NamedNodesCollection::trace(Visitor* visitor)
{
visitor->trace(m_nodes);
NodeList::trace(visitor);
}
} // namespace blink
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NamedNodesCollection_h
#define NamedNodesCollection_h
#include "core/dom/Element.h"
#include "core/dom/NodeList.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
namespace blink {
class NamedNodesCollection FINAL : public NodeList {
public:
static PassRefPtrWillBeRawPtr<NodeList> create(const WillBeHeapVector<RefPtrWillBeMember<Element> >& nodes)
{
return adoptRefWillBeNoop(new NamedNodesCollection(nodes));
}
virtual unsigned length() const OVERRIDE { return m_nodes.size(); }
virtual Element* item(unsigned) const OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
private:
explicit NamedNodesCollection(const WillBeHeapVector<RefPtrWillBeMember<Element> > nodes)
: m_nodes(nodes) { }
WillBeHeapVector<RefPtrWillBeMember<Element> > m_nodes;
};
} // namespace blink
#endif // NamedNodesCollection_h
......@@ -80,7 +80,8 @@ class RenderObject;
class RenderStyle;
class SVGQualifiedName;
class ShadowRoot;
class StaticNodeList;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Node> StaticNodeList;
class TagCollection;
class Text;
class TouchEvent;
......
......@@ -67,7 +67,7 @@ public:
return node.querySelector(selectors, exceptionState);
}
static PassRefPtrWillBeRawPtr<StaticNodeList> querySelectorAll(ContainerNode& node, const AtomicString& selectors, ExceptionState& exceptionState)
static PassRefPtrWillBeRawPtr<StaticElementList> querySelectorAll(ContainerNode& node, const AtomicString& selectors, ExceptionState& exceptionState)
{
return node.querySelectorAll(selectors, exceptionState);
}
......
......@@ -51,9 +51,9 @@ struct SingleElementSelectorQueryTrait {
};
struct AllElementsSelectorQueryTrait {
typedef WillBeHeapVector<RefPtrWillBeMember<Node> > OutputType;
typedef WillBeHeapVector<RefPtrWillBeMember<Element> > OutputType;
static const bool shouldOnlyMatchFirstElement = false;
ALWAYS_INLINE static void appendElement(OutputType& output, Node& element)
ALWAYS_INLINE static void appendElement(OutputType& output, Element& element)
{
output.append(&element);
}
......@@ -136,11 +136,11 @@ bool SelectorDataList::matches(Element& targetElement) const
return false;
}
PassRefPtrWillBeRawPtr<StaticNodeList> SelectorDataList::queryAll(ContainerNode& rootNode) const
PassRefPtrWillBeRawPtr<StaticElementList> SelectorDataList::queryAll(ContainerNode& rootNode) const
{
WillBeHeapVector<RefPtrWillBeMember<Node> > result;
WillBeHeapVector<RefPtrWillBeMember<Element> > result;
execute<AllElementsSelectorQueryTrait>(rootNode, result);
return StaticNodeList::adopt(result);
return StaticElementList::adopt(result);
}
PassRefPtrWillBeRawPtr<Element> SelectorDataList::queryFirst(ContainerNode& rootNode) const
......@@ -482,7 +482,7 @@ bool SelectorQuery::matches(Element& element) const
return m_selectors.matches(element);
}
PassRefPtrWillBeRawPtr<StaticNodeList> SelectorQuery::queryAll(ContainerNode& rootNode) const
PassRefPtrWillBeRawPtr<StaticElementList> SelectorQuery::queryAll(ContainerNode& rootNode) const
{
return m_selectors.queryAll(rootNode);
}
......
......@@ -40,13 +40,14 @@ class ContainerNode;
class Document;
class Element;
class ExceptionState;
class StaticNodeList;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Element> StaticElementList;
class SelectorDataList {
public:
void initialize(const CSSSelectorList&);
bool matches(Element&) const;
PassRefPtrWillBeRawPtr<StaticNodeList> queryAll(ContainerNode& rootNode) const;
PassRefPtrWillBeRawPtr<StaticElementList> queryAll(ContainerNode& rootNode) const;
PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const;
private:
......@@ -88,7 +89,7 @@ public:
static PassOwnPtr<SelectorQuery> adopt(CSSSelectorList&);
bool matches(Element&) const;
PassRefPtrWillBeRawPtr<StaticNodeList> queryAll(ContainerNode& rootNode) const;
PassRefPtrWillBeRawPtr<StaticElementList> queryAll(ContainerNode& rootNode) const;
PassRefPtrWillBeRawPtr<Element> queryFirst(ContainerNode& rootNode) const;
private:
explicit SelectorQuery(CSSSelectorList&);
......
/*
* Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "core/dom/StaticNodeList.h"
#include "core/dom/Element.h"
#include <v8.h>
namespace blink {
PassRefPtrWillBeRawPtr<StaticNodeList> StaticNodeList::adopt(WillBeHeapVector<RefPtrWillBeMember<Node> >& nodes)
{
RefPtrWillBeRawPtr<StaticNodeList> nodeList = adoptRefWillBeNoop(new StaticNodeList);
nodeList->m_nodes.swap(nodes);
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(nodeList->AllocationSize());
return nodeList.release();
}
StaticNodeList::~StaticNodeList()
{
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-AllocationSize());
}
unsigned StaticNodeList::length() const
{
return m_nodes.size();
}
Node* StaticNodeList::item(unsigned index) const
{
if (index < m_nodes.size())
return m_nodes[index].get();
return 0;
}
void StaticNodeList::trace(Visitor* visitor)
{
visitor->trace(m_nodes);
NodeList::trace(visitor);
}
} // namespace blink
......@@ -29,41 +29,82 @@
#ifndef StaticNodeList_h
#define StaticNodeList_h
#include "core/dom/Node.h"
#include "core/dom/NodeList.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
#include <v8.h>
namespace blink {
class Element;
class Node;
class StaticNodeList FINAL : public NodeList {
template <typename NodeType>
class StaticNodeTypeList FINAL : public NodeList {
public:
static PassRefPtrWillBeRawPtr<StaticNodeList> adopt(WillBeHeapVector<RefPtrWillBeMember<Node> >& nodes);
static PassRefPtrWillBeRawPtr<StaticNodeTypeList> adopt(WillBeHeapVector<RefPtrWillBeMember<NodeType> >& nodes);
static PassRefPtrWillBeRawPtr<StaticNodeList> createEmpty()
static PassRefPtrWillBeRawPtr<StaticNodeTypeList> createEmpty()
{
return adoptRefWillBeNoop(new StaticNodeList);
return adoptRefWillBeNoop(new StaticNodeTypeList);
}
virtual ~StaticNodeList();
virtual ~StaticNodeTypeList();
virtual unsigned length() const OVERRIDE;
virtual Node* item(unsigned index) const OVERRIDE;
virtual NodeType* item(unsigned index) const OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
private:
ptrdiff_t AllocationSize()
{
return m_nodes.capacity() * sizeof(RefPtrWillBeMember<Node>);
return m_nodes.capacity() * sizeof(RefPtrWillBeMember<NodeType>);
}
WillBeHeapVector<RefPtrWillBeMember<Node> > m_nodes;
WillBeHeapVector<RefPtrWillBeMember<NodeType> > m_nodes;
};
typedef StaticNodeTypeList<Node> StaticNodeList;
typedef StaticNodeTypeList<Element> StaticElementList;
template <typename NodeType>
PassRefPtrWillBeRawPtr<StaticNodeTypeList<NodeType> > StaticNodeTypeList<NodeType>::adopt(WillBeHeapVector<RefPtrWillBeMember<NodeType> >& nodes)
{
RefPtrWillBeRawPtr<StaticNodeTypeList<NodeType> > nodeList = adoptRefWillBeNoop(new StaticNodeTypeList<NodeType>);
nodeList->m_nodes.swap(nodes);
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(nodeList->AllocationSize());
return nodeList.release();
}
template <typename NodeType>
StaticNodeTypeList<NodeType>::~StaticNodeTypeList()
{
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-AllocationSize());
}
template <typename NodeType>
unsigned StaticNodeTypeList<NodeType>::length() const
{
return m_nodes.size();
}
template <typename NodeType>
NodeType* StaticNodeTypeList<NodeType>::item(unsigned index) const
{
if (index < m_nodes.size())
return m_nodes[index].get();
return 0;
}
template <typename NodeType>
void StaticNodeTypeList<NodeType>::trace(Visitor* visitor)
{
visitor->trace(m_nodes);
NodeList::trace(visitor);
}
} // namespace blink
#endif // StaticNodeList_h
......@@ -39,7 +39,8 @@ namespace blink {
class EventPath;
class EventTarget;
class Node;
class StaticNodeList;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Node> StaticNodeList;
class TouchEventContext;
class TreeScope;
......
......@@ -27,7 +27,7 @@
#include "core/html/HTMLAllCollection.h"
#include "core/dom/Element.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/dom/StaticNodeList.h"
namespace blink {
......@@ -83,7 +83,7 @@ void HTMLAllCollection::namedGetter(const AtomicString& name, bool& returnValue0
// FIXME: HTML5 specification says this should be a HTMLCollection.
// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection
returnValue0Enabled = true;
returnValue0 = NamedNodesCollection::create(namedItems);
returnValue0 = StaticElementList::adopt(namedItems);
}
} // namespace blink
......@@ -25,7 +25,7 @@
#include "bindings/core/v8/ExceptionMessages.h"
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/dom/StaticNodeList.h"
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLSelectElement.h"
......@@ -134,7 +134,7 @@ void HTMLOptionsCollection::namedGetter(const AtomicString& name, bool& returnVa
// FIXME: The spec and Firefox do not return a NodeList. They always return the first matching Element.
returnValue0Enabled = true;
returnValue0 = NamedNodesCollection::create(namedItems);
returnValue0 = StaticElementList::adopt(namedItems);
}
bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtrWillBeRawPtr<HTMLOptionElement> value, ExceptionState& exceptionState)
......
......@@ -657,7 +657,7 @@ void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c
return;
TrackExceptionState exceptionState;
RefPtrWillBeRawPtr<StaticNodeList> nodes = toContainerNode(node)->querySelectorAll(AtomicString(selectors), exceptionState);
RefPtrWillBeRawPtr<StaticElementList> elements = toContainerNode(node)->querySelectorAll(AtomicString(selectors), exceptionState);
if (exceptionState.hadException()) {
*errorString = "DOM Error while querying";
return;
......@@ -665,8 +665,8 @@ void InspectorDOMAgent::querySelectorAll(ErrorString* errorString, int nodeId, c
result = TypeBuilder::Array<int>::create();
for (unsigned i = 0; i < nodes->length(); ++i)
result->addItem(pushNodePathToFrontend(nodes->item(i)));
for (unsigned i = 0; i < elements->length(); ++i)
result->addItem(pushNodePathToFrontend(elements->item(i)));
}
int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
......@@ -1101,13 +1101,13 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
for (WillBeHeapVector<RawPtrWillBeMember<Document> >::iterator it = docs.begin(); it != docs.end(); ++it) {
Document* document = *it;
TrackExceptionState exceptionState;
RefPtrWillBeRawPtr<StaticNodeList> nodeList = document->querySelectorAll(AtomicString(whitespaceTrimmedQuery), exceptionState);
if (exceptionState.hadException() || !nodeList)
RefPtrWillBeRawPtr<StaticElementList> elementList = document->querySelectorAll(AtomicString(whitespaceTrimmedQuery), exceptionState);
if (exceptionState.hadException() || !elementList)
continue;
unsigned size = nodeList->length();
unsigned size = elementList->length();
for (unsigned i = 0; i < size; ++i)
resultCollector.add(nodeList->item(i));
resultCollector.add(elementList->item(i));
}
}
......
......@@ -66,8 +66,9 @@ class PagePopupController;
class PrivateScriptTest;
class Range;
class SerializedScriptValue;
class StaticNodeList;
class ShadowRoot;
template <typename NodeType> class StaticNodeTypeList;
typedef StaticNodeTypeList<Node> StaticNodeList;
class TypeConversions;
class Internals FINAL : public RefCountedWillBeGarbageCollectedFinalized<Internals>, public ScriptWrappable, public ContextLifecycleObserver {
......
......@@ -160,12 +160,12 @@ void TouchActionTest::runShadowDOMTest(std::string file)
// Oilpan: see runTouchActionTest() comment why these are persistent references.
RefPtrWillBePersistent<blink::Document> document = static_cast<PassRefPtrWillBeRawPtr<blink::Document> >(webView->mainFrame()->document());
RefPtrWillBePersistent<blink::StaticNodeList> hostNodes = document->querySelectorAll("[shadow-host]", es);
RefPtrWillBePersistent<blink::StaticElementList> hostNodes = document->querySelectorAll("[shadow-host]", es);
ASSERT_FALSE(es.hadException());
ASSERT_GE(hostNodes->length(), 1u);
for (unsigned index = 0; index < hostNodes->length(); index++) {
blink::ShadowRoot* shadowRoot = blink::toElement(hostNodes->item(index))->shadowRoot();
blink::ShadowRoot* shadowRoot = hostNodes->item(index)->shadowRoot();
runTestOnTree(shadowRoot, webView, client);
}
......@@ -201,13 +201,12 @@ void TouchActionTest::runTestOnTree(blink::ContainerNode* root, WebView* webView
blink::TrackExceptionState es;
// Oilpan: see runTouchActionTest() comment why these are persistent references.
RefPtrWillBePersistent<blink::StaticNodeList> nodes = root->querySelectorAll("[expected-action]", es);
RefPtrWillBePersistent<blink::StaticElementList> elements = root->querySelectorAll("[expected-action]", es);
ASSERT_FALSE(es.hadException());
for (unsigned index = 0; index < nodes->length(); index++) {
blink::Element* element = toElement(nodes->item(index));
for (unsigned index = 0; index < elements->length(); index++) {
Element* element = elements->item(index);
element->scrollIntoViewIfNeeded();
ASSERT_TRUE(nodes->item(index)->isElementNode());
std::string failureContext("Test case: ");
if (element->hasID()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment