Diff
Modified: trunk/Source/WebCore/ChangeLog (154733 => 154734)
--- trunk/Source/WebCore/ChangeLog 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/ChangeLog 2013-08-28 12:31:10 UTC (rev 154734)
@@ -1,3 +1,35 @@
+2013-08-28 Antti Koivisto <[email protected]>
+
+ Make descendant iterators always require ContainerNode root
+ https://bugs.webkit.org/show_bug.cgi?id=120393
+
+ Reviewed by Andreas Kling.
+
+ Remove Node* root versions of the iterators.
+ Fix the few call sites that required them to have tighter typing.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
+ (WebCore::siblingWithAriaRole):
+ * dom/ChildIterator.h:
+ (WebCore::::ChildIteratorAdapter):
+ (WebCore::::begin):
+ (WebCore::::end):
+ (WebCore::elementChildren):
+ (WebCore::childrenOfType):
+ * dom/DescendantIterator.h:
+ (WebCore::::DescendantIterator):
+ (WebCore::::DescendantIteratorAdapter):
+ (WebCore::::begin):
+ (WebCore::::end):
+ (WebCore::elementDescendants):
+ (WebCore::descendantsOfType):
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::dummySpanAncestorForNode):
+ (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
+ (WebCore::ApplyStyleCommand::applyInlineStyle):
+ * editing/ApplyStyleCommand.h:
+
2013-08-28 Sergio Villar Senin <[email protected]>
WorkerGlobalScopeWebDatabase requires ENABLE(WORKERS)
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (154733 => 154734)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2013-08-28 12:31:10 UTC (rev 154734)
@@ -417,11 +417,11 @@
Node* node = this->node();
if (!node || !node->hasTagName(canvasTag))
return false;
-
+ Element* canvasElement = toElement(node);
// If it has any children that are elements, we'll assume it might be fallback
// content. If it has no children or its only children are not elements
// (e.g. just text nodes), it doesn't have fallback content.
- return elementChildren(node).begin() != elementChildren(node).end();
+ return elementChildren(canvasElement).begin() != elementChildren(canvasElement).end();
}
bool AccessibilityNodeObject::isImageButton() const
@@ -1122,10 +1122,9 @@
static Element* siblingWithAriaRole(String role, Node* node)
{
- Node* parent = node->parentNode();
+ ContainerNode* parent = node->parentNode();
if (!parent)
return 0;
-
for (auto sibling = elementChildren(parent).begin(), end = elementChildren(parent).end(); sibling != end; ++sibling) {
const AtomicString& siblingAriaRole = sibling->fastGetAttribute(roleAttr);
if (equalIgnoringCase(siblingAriaRole, role))
Modified: trunk/Source/WebCore/dom/ChildIterator.h (154733 => 154734)
--- trunk/Source/WebCore/dom/ChildIterator.h 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/dom/ChildIterator.h 2013-08-28 12:31:10 UTC (rev 154734)
@@ -54,21 +54,19 @@
#endif
};
-template <typename ElementType, typename ContainerType>
+template <typename ElementType>
class ChildIteratorAdapter {
public:
- ChildIteratorAdapter(ContainerType* root);
+ ChildIteratorAdapter(ContainerNode* root);
ChildIterator<ElementType> begin();
ChildIterator<ElementType> end();
private:
- const ContainerType* m_root;
+ const ContainerNode* m_root;
};
-ChildIteratorAdapter<Element, ContainerNode> elementChildren(ContainerNode* root);
-ChildIteratorAdapter<Element, Node> elementChildren(Node* root);
-template <typename ElementType> ChildIteratorAdapter<ElementType, ContainerNode> childrenOfType(ContainerNode* root);
-template <typename ElementType> ChildIteratorAdapter<ElementType, Node> childrenOfType(Node* root);
+ChildIteratorAdapter<Element> elementChildren(ContainerNode* root);
+template <typename ElementType> ChildIteratorAdapter<ElementType> childrenOfType(ContainerNode* root);
template <typename ElementType>
inline ChildIterator<ElementType>::ChildIterator()
@@ -134,46 +132,35 @@
return m_current != other.m_current;
}
-template <typename ElementType, typename ContainerType>
-inline ChildIteratorAdapter<ElementType, ContainerType>::ChildIteratorAdapter(ContainerType* root)
+template <typename ElementType>
+inline ChildIteratorAdapter<ElementType>::ChildIteratorAdapter(ContainerNode* root)
: m_root(root)
{
}
-template <typename ElementType, typename ContainerType>
-inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType, ContainerType>::begin()
+template <typename ElementType>
+inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::begin()
{
return ChildIterator<ElementType>(Traversal<ElementType>::firstChild(m_root));
}
-template <typename ElementType, typename ContainerType>
-inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType, ContainerType>::end()
+template <typename ElementType>
+inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::end()
{
return ChildIterator<ElementType>();
}
-inline ChildIteratorAdapter<Element, ContainerNode> elementChildren(ContainerNode* root)
+inline ChildIteratorAdapter<Element> elementChildren(ContainerNode* root)
{
- return ChildIteratorAdapter<Element, ContainerNode>(root);
+ return ChildIteratorAdapter<Element>(root);
}
-inline ChildIteratorAdapter<Element, Node> elementChildren(Node* root)
-{
- return ChildIteratorAdapter<Element, Node>(root);
-}
-
template <typename ElementType>
-inline ChildIteratorAdapter<ElementType, ContainerNode> childrenOfType(ContainerNode* root)
+inline ChildIteratorAdapter<ElementType> childrenOfType(ContainerNode* root)
{
- return ChildIteratorAdapter<ElementType, ContainerNode>(root);
+ return ChildIteratorAdapter<ElementType>(root);
}
-template <typename ElementType>
-inline ChildIteratorAdapter<ElementType, Node> childrenOfType(Node* root)
-{
- return ChildIteratorAdapter<ElementType, Node>(root);
}
-}
-
#endif
Modified: trunk/Source/WebCore/dom/DescendantIterator.h (154733 => 154734)
--- trunk/Source/WebCore/dom/DescendantIterator.h 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/dom/DescendantIterator.h 2013-08-28 12:31:10 UTC (rev 154734)
@@ -37,15 +37,15 @@
template <typename ElementType>
class DescendantIterator {
public:
- DescendantIterator(const Node* root);
- DescendantIterator(const Node* root, ElementType* current);
+ DescendantIterator(const ContainerNode* root);
+ DescendantIterator(const ContainerNode* root, ElementType* current);
DescendantIterator& operator++();
ElementType& operator*();
ElementType* operator->();
bool operator!=(const DescendantIterator& other) const;
private:
- const Node* m_root;
+ const ContainerNode* m_root;
ElementType* m_current;
#ifndef NDEBUG
@@ -55,24 +55,22 @@
#endif
};
-template <typename ElementType, typename ContainerType>
+template <typename ElementType>
class DescendantIteratorAdapter {
public:
- DescendantIteratorAdapter(ContainerType* root);
+ DescendantIteratorAdapter(ContainerNode* root);
DescendantIterator<ElementType> begin();
DescendantIterator<ElementType> end();
private:
- ContainerType* m_root;
+ ContainerNode* m_root;
};
-DescendantIteratorAdapter<Element, ContainerNode> elementDescendants(ContainerNode* root);
-DescendantIteratorAdapter<Element, Node> elementDescendants(Node* root);
-template <typename ElementType> DescendantIteratorAdapter<ElementType, ContainerNode> descendantsOfType(ContainerNode* root);
-template <typename ElementType> DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root);
+DescendantIteratorAdapter<Element> elementDescendants(ContainerNode* root);
+template <typename ElementType> DescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode* root);
template <typename ElementType>
-inline DescendantIterator<ElementType>::DescendantIterator(const Node* root)
+inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root)
: m_root(root)
, m_current(nullptr)
#ifndef NDEBUG
@@ -82,7 +80,7 @@
}
template <typename ElementType>
-inline DescendantIterator<ElementType>::DescendantIterator(const Node* root, ElementType* current)
+inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root, ElementType* current)
: m_root(root)
, m_current(current)
#ifndef NDEBUG
@@ -138,46 +136,35 @@
return m_current != other.m_current;
}
-template <typename ElementType, typename ContainerType>
-inline DescendantIteratorAdapter<ElementType, ContainerType>::DescendantIteratorAdapter(ContainerType* root)
+template <typename ElementType>
+inline DescendantIteratorAdapter<ElementType>::DescendantIteratorAdapter(ContainerNode* root)
: m_root(root)
{
}
-template <typename ElementType, typename ContainerType>
-inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType, ContainerType>::begin()
+template <typename ElementType>
+inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType>::begin()
{
return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(m_root));
}
-template <typename ElementType, typename ContainerType>
-inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType, ContainerType>::end()
+template <typename ElementType>
+inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType>::end()
{
return DescendantIterator<ElementType>(m_root);
}
-inline DescendantIteratorAdapter<Element, ContainerNode> elementDescendants(ContainerNode* root)
+inline DescendantIteratorAdapter<Element> elementDescendants(ContainerNode* root)
{
- return DescendantIteratorAdapter<Element, ContainerNode>(root);
+ return DescendantIteratorAdapter<Element>(root);
}
-inline DescendantIteratorAdapter<Element, Node> elementDescendants(Node* root)
-{
- return DescendantIteratorAdapter<Element, Node>(root);
-}
-
template <typename ElementType>
-inline DescendantIteratorAdapter<ElementType, ContainerNode> descendantsOfType(ContainerNode* root)
+inline DescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode* root)
{
- return DescendantIteratorAdapter<ElementType, ContainerNode>(root);
+ return DescendantIteratorAdapter<ElementType>(root);
}
-template <typename ElementType>
-inline DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root)
-{
- return DescendantIteratorAdapter<ElementType, Node>(root);
}
-}
-
#endif
Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (154733 => 154734)
--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp 2013-08-28 12:31:10 UTC (rev 154734)
@@ -425,7 +425,7 @@
removeNodePreservingChildren(unstyledSpans[i].get());
}
-static Node* dummySpanAncestorForNode(const Node* node)
+static ContainerNode* dummySpanAncestorForNode(const Node* node)
{
while (node && (!node->isElementNode() || !isStyleSpanOrSpanWithOnlyStyleAttribute(toElement(node))))
node = node->parentNode();
@@ -433,7 +433,7 @@
return node ? node->parentNode() : 0;
}
-void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor)
+void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanAncestor)
{
if (!dummySpanAncestor)
return;
@@ -551,8 +551,8 @@
void ApplyStyleCommand::applyInlineStyle(EditingStyle* style)
{
- RefPtr<Node> startDummySpanAncestor = 0;
- RefPtr<Node> endDummySpanAncestor = 0;
+ RefPtr<ContainerNode> startDummySpanAncestor = 0;
+ RefPtr<ContainerNode> endDummySpanAncestor = 0;
// update document layout once before removing styles
// so that we avoid the expense of updating before each and every call
Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.h (154733 => 154734)
--- trunk/Source/WebCore/editing/ApplyStyleCommand.h 2013-08-28 12:13:05 UTC (rev 154733)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.h 2013-08-28 12:31:10 UTC (rev 154734)
@@ -108,7 +108,7 @@
bool isValidCaretPositionInTextNode(const Position& position);
bool mergeStartWithPreviousIfIdentical(const Position& start, const Position& end);
bool mergeEndWithNextIfIdentical(const Position& start, const Position& end);
- void cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor);
+ void cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanAncestor);
void surroundNodeRangeWithElement(PassRefPtr<Node> start, PassRefPtr<Node> end, PassRefPtr<Element>);
float computedFontSize(Node*);