Diff
Modified: trunk/Source/WebCore/ChangeLog (203300 => 203301)
--- trunk/Source/WebCore/ChangeLog 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/ChangeLog 2016-07-15 21:34:16 UTC (rev 203301)
@@ -1,3 +1,30 @@
+2016-07-15 Chris Dumez <[email protected]>
+
+ Modernize StaticNodeList / StaticElementList
+ https://bugs.webkit.org/show_bug.cgi?id=159831
+
+ Reviewed by Ryosuke Niwa.
+
+ Modernize StaticNodeList / StaticElementList. Pass vector to adopt
+ as an rvalue reference instead of a non-const reference.
+
+ * bindings/js/JSHTMLAllCollectionCustom.cpp:
+ (WebCore::namedItems):
+ * dom/ChildListMutationScope.cpp:
+ (WebCore::ChildListMutationAccumulator::enqueueMutationRecord):
+ * dom/MutationRecord.cpp:
+ * dom/SelectorQuery.cpp:
+ (WebCore::SelectorDataList::queryAll):
+ * dom/StaticNodeList.h:
+ * dom/WebKitNamedFlow.cpp:
+ (WebCore::WebKitNamedFlow::getRegionsByContent):
+ (WebCore::WebKitNamedFlow::getRegions):
+ (WebCore::WebKitNamedFlow::getContent):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::collectIntersectionOrEnclosureList):
+ * testing/Internals.cpp:
+ (WebCore::Internals::nodesFromRect):
+
2016-07-15 Brent Fulgham <[email protected]>
Block insecure script running in a data: frame when the top-level page is HTTPS
Modified: trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp (203300 => 203301)
--- trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -47,7 +47,7 @@
// 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 toJS(&state, collection->globalObject(), StaticElementList::adopt(namedItems));
+ return toJS(&state, collection->globalObject(), StaticElementList::create(WTFMove(namedItems)));
}
// HTMLAllCollections are strange objects, they support both get and call.
Modified: trunk/Source/WebCore/dom/ChildListMutationScope.cpp (203300 => 203301)
--- trunk/Source/WebCore/dom/ChildListMutationScope.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/dom/ChildListMutationScope.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -127,7 +127,7 @@
ASSERT(hasObservers());
ASSERT(!isEmpty());
- auto record = MutationRecord::createChildList(m_target, StaticNodeList::adopt(m_addedNodes), StaticNodeList::adopt(m_removedNodes), WTFMove(m_previousSibling), WTFMove(m_nextSibling));
+ auto record = MutationRecord::createChildList(m_target, StaticNodeList::create(WTFMove(m_addedNodes)), StaticNodeList::create(WTFMove(m_removedNodes)), WTFMove(m_previousSibling), WTFMove(m_nextSibling));
m_observers->enqueueMutationRecord(WTFMove(record));
m_lastAdded = nullptr;
ASSERT(isEmpty());
Modified: trunk/Source/WebCore/dom/MutationRecord.cpp (203300 => 203301)
--- trunk/Source/WebCore/dom/MutationRecord.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/dom/MutationRecord.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -83,7 +83,7 @@
static NodeList* lazilyInitializeEmptyNodeList(RefPtr<NodeList>& nodeList)
{
if (!nodeList)
- nodeList = StaticNodeList::createEmpty();
+ nodeList = StaticNodeList::create();
return nodeList.get();
}
Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (203300 => 203301)
--- trunk/Source/WebCore/dom/SelectorQuery.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -165,7 +165,7 @@
{
Vector<Ref<Element>> result;
execute<AllElementExtractorSelectorQueryTrait>(rootNode, result);
- return StaticElementList::adopt(result);
+ return StaticElementList::create(WTFMove(result));
}
struct SingleElementExtractorSelectorQueryTrait {
Modified: trunk/Source/WebCore/dom/StaticNodeList.h (203300 => 203301)
--- trunk/Source/WebCore/dom/StaticNodeList.h 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/dom/StaticNodeList.h 2016-07-15 21:34:16 UTC (rev 203301)
@@ -39,23 +39,18 @@
class WEBCORE_EXPORT StaticNodeList final : public NodeList {
public:
- static Ref<StaticNodeList> adopt(Vector<Ref<Node>>& nodes)
+ static Ref<StaticNodeList> create(Vector<Ref<Node>>&& nodes = { })
{
- Ref<StaticNodeList> nodeList = adoptRef(*new StaticNodeList);
- nodeList->m_nodes.swap(nodes);
- return nodeList;
+ return adoptRef(*new StaticNodeList(WTFMove(nodes)));
}
- static Ref<StaticNodeList> createEmpty()
- {
- return adoptRef(*new StaticNodeList);
- }
-
unsigned length() const override;
Node* item(unsigned index) const override;
private:
- StaticNodeList() { }
+ StaticNodeList(Vector<Ref<Node>>&& nodes)
+ : m_nodes(WTFMove(nodes))
+ { }
Vector<Ref<Node>> m_nodes;
};
@@ -62,25 +57,18 @@
class StaticElementList final : public NodeList {
public:
- static Ref<StaticElementList> adopt(Vector<Ref<Element>>& elements)
+ static Ref<StaticElementList> create(Vector<Ref<Element>>&& elements = { })
{
- Ref<StaticElementList> nodeList = adoptRef(*new StaticElementList);
- nodeList->m_elements.swap(elements);
- return nodeList;
+ return adoptRef(*new StaticElementList(WTFMove(elements)));
}
- static Ref<StaticElementList> createEmpty()
- {
- return adoptRef(*new StaticElementList);
- }
-
unsigned length() const override;
Element* item(unsigned index) const override;
private:
- StaticElementList()
- {
- }
+ StaticElementList(Vector<Ref<Element>>&& elements)
+ : m_elements(WTFMove(elements))
+ { }
Vector<Ref<Element>> m_elements;
};
Modified: trunk/Source/WebCore/dom/WebKitNamedFlow.cpp (203300 => 203301)
--- trunk/Source/WebCore/dom/WebKitNamedFlow.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/dom/WebKitNamedFlow.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -122,7 +122,7 @@
Ref<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
{
if (!contentNode)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
if (m_flowManager->document())
m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
@@ -130,7 +130,7 @@
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
Vector<Ref<Element>> regionElements;
@@ -150,7 +150,7 @@
}
}
- return StaticElementList::adopt(regionElements);
+ return StaticElementList::create(WTFMove(regionElements));
}
Ref<NodeList> WebKitNamedFlow::getRegions()
@@ -161,7 +161,7 @@
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
Vector<Ref<Element>> regionElements;
@@ -177,7 +177,7 @@
regionElements.append(*namedFlowFragment.generatingElement());
}
- return StaticElementList::adopt(regionElements);
+ return StaticElementList::create(WTFMove(regionElements));
}
Ref<NodeList> WebKitNamedFlow::getContent()
@@ -188,17 +188,17 @@
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
+ auto& contentElementsList = m_parentFlowThread->contentElements();
Vector<Ref<Element>> contentElements;
-
- const NamedFlowContentElements& contentElementsList = m_parentFlowThread->contentElements();
+ contentElements.reserveInitialCapacity(contentElementsList.size());
for (auto& element : contentElementsList) {
ASSERT(element->computedStyle()->flowThread() == m_parentFlowThread->flowThreadName());
- contentElements.append(*element);
+ contentElements.uncheckedAppend(*element);
}
- return StaticElementList::adopt(contentElements);
+ return StaticElementList::create(WTFMove(contentElements));
}
void WebKitNamedFlow::setRenderer(RenderNamedFlowThread* parentFlowThread)
Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (203300 => 203301)
--- trunk/Source/WebCore/svg/SVGSVGElement.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -316,7 +316,7 @@
if (checkFunction(&element, rect))
elements.append(element);
}
- return RefPtr<NodeList>(StaticElementList::adopt(elements)).releaseNonNull();
+ return StaticElementList::create(WTFMove(elements));
}
Ref<NodeList> SVGSVGElement::getIntersectionList(const FloatRect& rect, SVGElement* referenceElement)
Modified: trunk/Source/WebCore/testing/Internals.cpp (203300 => 203301)
--- trunk/Source/WebCore/testing/Internals.cpp 2016-07-15 21:18:33 UTC (rev 203300)
+++ trunk/Source/WebCore/testing/Internals.cpp 2016-07-15 21:34:16 UTC (rev 203301)
@@ -1455,7 +1455,7 @@
matches.uncheckedAppend(*node);
}
- return StaticNodeList::adopt(matches);
+ return StaticNodeList::create(WTFMove(matches));
}
class GetCallerCodeBlockFunctor {