Diff
Modified: trunk/Source/WebCore/ChangeLog (154524 => 154525)
--- trunk/Source/WebCore/ChangeLog 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/ChangeLog 2013-08-23 22:00:06 UTC (rev 154525)
@@ -1,3 +1,43 @@
+2013-08-23 Antti Koivisto <[email protected]>
+
+ Use ElementTraversal some more
+ https://bugs.webkit.org/show_bug.cgi?id=120226
+
+ Reviewed by Darin Adler.
+
+ More traversal with tighter typing.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::canvasHasFallbackContent):
+ (WebCore::siblingWithAriaRole):
+ * accessibility/AccessibilityTable.cpp:
+ (WebCore::AccessibilityTable::isDataTable):
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::getFontData):
+ * dom/ContainerNode.cpp:
+ (WebCore::willRemoveChild):
+ * dom/ContainerNodeAlgorithms.h:
+ (WebCore::ChildFrameDisconnector::ChildFrameDisconnector):
+ (WebCore::ChildFrameDisconnector::collectFrameOwners):
+ (WebCore::ChildFrameDisconnector::disconnect):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::selectMediaResource):
+ (WebCore::HTMLMediaElement::textTrackModeChanged):
+ (WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parametersForPlugin):
+ (WebCore::HTMLObjectElement::containsJavaApplet):
+ * html/HTMLParamElement.h:
+ (WebCore::isHTMLParamElement):
+ (WebCore::HTMLParamElement):
+ * html/HTMLSourceElement.h:
+ (WebCore::isHTMLSourceElement):
+ (WebCore::HTMLSourceElement):
+ * svg/SVGFontFaceElement.h:
+ (WebCore::isSVGFontFaceElement):
+ (WebCore::SVGFontFaceElement):
+ (WebCore::toSVGFontFaceElement):
+
2013-08-23 Andreas Kling <[email protected]>
Let Document keep its RenderView during render tree attach.
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (154524 => 154525)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -34,6 +34,7 @@
#include "AccessibilityListBox.h"
#include "AccessibilitySpinButton.h"
#include "AccessibilityTable.h"
+#include "ElementTraversal.h"
#include "EventNames.h"
#include "FloatRect.h"
#include "Frame.h"
@@ -416,12 +417,7 @@
// 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.
- for (Node* child = node->firstChild(); child; child = child->nextSibling()) {
- if (child->isElementNode())
- return true;
- }
-
- return false;
+ return !!ElementTraversal::firstChild(node);
}
bool AccessibilityNodeObject::isImageButton() const
@@ -1126,14 +1122,12 @@
if (!parent)
return 0;
- for (Node* sibling = parent->firstChild(); sibling; sibling = sibling->nextSibling()) {
- if (sibling->isElementNode()) {
- const AtomicString& siblingAriaRole = toElement(sibling)->getAttribute(roleAttr);
- if (equalIgnoringCase(siblingAriaRole, role))
- return toElement(sibling);
- }
+ for (Element* sibling = ElementTraversal::firstChild(parent); sibling; sibling = ElementTraversal::nextSibling(sibling)) {
+ const AtomicString& siblingAriaRole = sibling->fastGetAttribute(roleAttr);
+ if (equalIgnoringCase(siblingAriaRole, role))
+ return sibling;
}
-
+
return 0;
}
Modified: trunk/Source/WebCore/accessibility/AccessibilityTable.cpp (154524 => 154525)
--- trunk/Source/WebCore/accessibility/AccessibilityTable.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/accessibility/AccessibilityTable.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -34,6 +34,7 @@
#include "AccessibilityTableColumn.h"
#include "AccessibilityTableHeaderContainer.h"
#include "AccessibilityTableRow.h"
+#include "ElementTraversal.h"
#include "HTMLNames.h"
#include "HTMLTableCaptionElement.h"
#include "HTMLTableCellElement.h"
@@ -124,7 +125,7 @@
return true;
// if there's a colgroup or col element, it's probably a data table.
- for (Node* child = tableElement->firstChild(); child; child = child->nextSibling()) {
+ for (Element* child = ElementTraversal::firstChild(tableElement); child; child = ElementTraversal::nextSibling(child)) {
if (child->hasTagName(colTag) || child->hasTagName(colgroupTag))
return true;
}
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (154524 => 154525)
--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -31,6 +31,7 @@
#include "CSSFontSelector.h"
#include "CachedResourceLoader.h"
#include "Document.h"
+#include "ElementTraversal.h"
#include "FontCache.h"
#include "FontDescription.h"
#include "SimpleFontData.h"
@@ -138,17 +139,7 @@
if (!m_externalSVGFontElement)
return 0;
- SVGFontFaceElement* fontFaceElement = 0;
-
- // Select first <font-face> child
- for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
- if (fontChild->hasTagName(SVGNames::font_faceTag)) {
- fontFaceElement = toSVGFontFaceElement(fontChild);
- break;
- }
- }
-
- if (fontFaceElement) {
+ if (auto fontFaceElement = Traversal<SVGFontFaceElement>::firstChild(m_externalSVGFontElement.get())) {
if (!m_svgFontFaceElement) {
// We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
// Use the imported <font-face> tag as referencing font-face element for these cases.
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (154524 => 154525)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -470,7 +470,8 @@
child->notifyMutationObserversNodeWillDetach();
dispatchChildRemovalEvents(child);
child->document()->nodeWillBeRemoved(child); // e.g. mutation event listener can create a new range.
- ChildFrameDisconnector(child).disconnect();
+ if (child->isContainerNode())
+ ChildFrameDisconnector(toContainerNode(child)).disconnect();
}
static void willRemoveChildren(ContainerNode* container)
Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h (154524 => 154525)
--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h 2013-08-23 22:00:06 UTC (rev 154525)
@@ -23,6 +23,7 @@
#define ContainerNodeAlgorithms_h
#include "Document.h"
+#include "ElementTraversal.h"
#include "Frame.h"
#include "HTMLFrameOwnerElement.h"
#include "InspectorInstrumentation.h"
@@ -267,7 +268,7 @@
DescendantsOnly
};
- explicit ChildFrameDisconnector(Node* root)
+ explicit ChildFrameDisconnector(ContainerNode* root)
: m_root(root)
{
}
@@ -275,18 +276,18 @@
void disconnect(DisconnectPolicy = RootAndDescendants);
private:
- void collectFrameOwners(Node* root);
+ void collectFrameOwners(ContainerNode* root);
void disconnectCollectedFrameOwners();
Vector<RefPtr<HTMLFrameOwnerElement>, 10> m_frameOwners;
- Node* m_root;
+ ContainerNode* m_root;
};
#ifndef NDEBUG
unsigned assertConnectedSubrameCountIsConsistent(Node*);
#endif
-inline void ChildFrameDisconnector::collectFrameOwners(Node* root)
+inline void ChildFrameDisconnector::collectFrameOwners(ContainerNode* root)
{
if (!root->connectedSubframeCount())
return;
@@ -294,7 +295,7 @@
if (root->isHTMLElement() && root->isFrameOwnerElement())
m_frameOwners.append(toFrameOwnerElement(root));
- for (Node* child = root->firstChild(); child; child = child->nextSibling())
+ for (Element* child = ElementTraversal::firstChild(root); child; child = ElementTraversal::nextSibling(child))
collectFrameOwners(child);
ShadowRoot* shadow = root->isElementNode() ? toElement(root)->shadowRoot() : 0;
@@ -329,7 +330,7 @@
if (policy == RootAndDescendants)
collectFrameOwners(m_root);
else {
- for (Node* child = m_root->firstChild(); child; child = child->nextSibling())
+ for (Element* child = ElementTraversal::firstChild(m_root); child; child = ElementTraversal::nextSibling(child))
collectFrameOwners(child);
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (154524 => 154525)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -922,18 +922,12 @@
// 3 - If the media element has a src attribute, then let mode be attribute.
Mode mode = attribute;
if (!fastHasAttribute(srcAttr)) {
- Node* node;
- for (node = firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(sourceTag))
- break;
- }
-
// Otherwise, if the media element does not have a src attribute but has a source
// element child, then let mode be children and let candidate be the first such
// source element child in tree order.
- if (node) {
+ if (auto sourceElement = Traversal<HTMLSourceElement>::firstChild(this)) {
mode = children;
- m_nextChildNodeToConsider = node;
+ m_nextChildNodeToConsider = sourceElement;
m_currentSourceNode = 0;
} else {
// Otherwise the media element has neither a src attribute nor a source element
@@ -1421,11 +1415,7 @@
bool trackIsLoaded = true;
if (track->trackType() == TextTrack::TrackElement) {
trackIsLoaded = false;
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (!node->hasTagName(trackTag))
- continue;
-
- HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node);
+ for (auto trackElement = Traversal<HTMLTrackElement>::firstChild(this); trackElement; trackElement = Traversal<HTMLTrackElement>::nextSibling(trackElement)) {
if (trackElement->track() == track) {
if (trackElement->readyState() == HTMLTrackElement::LOADING || trackElement->readyState() == HTMLTrackElement::LOADED)
trackIsLoaded = true;
@@ -1657,10 +1647,8 @@
LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks");
m_asyncEventQueue->cancelAllEvents();
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(sourceTag))
- static_cast<HTMLSourceElement*>(node)->cancelPendingErrorEvent();
- }
+ for (auto source = Traversal<HTMLSourceElement>::firstChild(this); source; source = Traversal<HTMLSourceElement>::nextSibling(source))
+ source->cancelPendingErrorEvent();
}
Document* HTMLMediaElement::mediaPlayerOwningDocument()
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (154524 => 154525)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2013-08-23 22:00:06 UTC (rev 154525)
@@ -153,25 +153,21 @@
// Scan the PARAM children and store their name/value pairs.
// Get the URL and type from the params if we don't already have them.
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (!child->hasTagName(paramTag))
- continue;
-
- HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
- String name = p->name();
+ for (auto param = Traversal<HTMLParamElement>::firstChild(this); param; param = Traversal<HTMLParamElement>::nextSibling(param)) {
+ String name = param->name();
if (name.isEmpty())
continue;
uniqueParamNames.add(name.impl());
- paramNames.append(p->name());
- paramValues.append(p->value());
+ paramNames.append(param->name());
+ paramValues.append(param->value());
// FIXME: url adjustment does not belong in this function.
if (url.isEmpty() && urlParameter.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
- urlParameter = stripLeadingAndTrailingHTMLSpaces(p->value());
+ urlParameter = stripLeadingAndTrailingHTMLSpaces(param->value());
// FIXME: serviceType calculation does not belong in this function.
if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
- serviceType = p->value();
+ serviceType = param->value();
size_t pos = serviceType.find(";");
if (pos != notFound)
serviceType = serviceType.left(pos);
@@ -465,7 +461,7 @@
if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
return true;
- for (Element* child = ElementTraversal::firstWithin(this); child; child = ElementTraversal::nextSibling(child)) {
+ for (auto child = ElementTraversal::firstChild(this); child; child = ElementTraversal::nextSibling(child)) {
if (child->hasTagName(paramTag)
&& equalIgnoringCase(child->getNameAttribute(), "type")
&& MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(valueAttr).string()))
Modified: trunk/Source/WebCore/html/HTMLParamElement.h (154524 => 154525)
--- trunk/Source/WebCore/html/HTMLParamElement.h 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/html/HTMLParamElement.h 2013-08-23 22:00:06 UTC (rev 154525)
@@ -44,6 +44,19 @@
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
};
+inline bool isHTMLParamElement(const Node* node)
+{
+ return node->hasTagName(HTMLNames::paramTag);
+}
+
+inline bool isHTMLParamElement(const Element* element)
+{
+ return element->hasTagName(HTMLNames::paramTag);
+}
+
+template <> inline bool isElementOfType<HTMLParamElement>(const Element* element) { return isHTMLParamElement(element); }
+
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/html/HTMLSourceElement.h (154524 => 154525)
--- trunk/Source/WebCore/html/HTMLSourceElement.h 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/html/HTMLSourceElement.h 2013-08-23 22:00:06 UTC (rev 154525)
@@ -57,6 +57,19 @@
Timer<HTMLSourceElement> m_errorEventTimer;
};
+inline bool isHTMLSourceElement(const Node* node)
+{
+ return node->hasTagName(HTMLNames::sourceTag);
+}
+
+inline bool isHTMLSourceElement(const Element* element)
+{
+ return element->hasTagName(HTMLNames::sourceTag);
+}
+
+template <> inline bool isElementOfType<HTMLSourceElement>(const Element* element) { return isHTMLSourceElement(element); }
+
+
} //namespace
#endif
Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.h (154524 => 154525)
--- trunk/Source/WebCore/svg/SVGFontFaceElement.h 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.h 2013-08-23 22:00:06 UTC (rev 154525)
@@ -67,9 +67,21 @@
SVGFontElement* m_fontElement;
};
+inline bool isSVGFontFaceElement(const Node* node)
+{
+ return node->hasTagName(SVGNames::font_faceTag);
+}
+
+inline bool isSVGFontFaceElement(const Element* element)
+{
+ return element->hasTagName(SVGNames::font_faceTag);
+}
+
+template <> inline bool isElementOfType<SVGFontFaceElement>(const Element* element) { return isSVGFontFaceElement(element); }
+
inline SVGFontFaceElement* toSVGFontFaceElement(Node* node)
{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::font_faceTag));
+ ASSERT_WITH_SECURITY_IMPLICATION(!node || isSVGFontFaceElement(node));
return static_cast<SVGFontFaceElement*>(node);
}
Modified: trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in (154524 => 154525)
--- trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in 2013-08-23 21:58:17 UTC (rev 154524)
+++ trunk/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in 2013-08-23 22:00:06 UTC (rev 154525)
@@ -1,5 +1,5 @@
(version 1)
-(deny default (with partial-symbolication))
+(allow default (with partial-symbolication))
(allow system-audit file-read-metadata)
#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
(allow ipc-posix-shm)