Commit a112e1a9 authored by antti@apple.com's avatar antti@apple.com

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154525 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6d3b8c62
2013-08-23 Antti Koivisto <antti@apple.com>
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 <akling@apple.com>
Let Document keep its RenderView during render tree attach.
......@@ -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 @@ bool AccessibilityNodeObject::canvasHasFallbackContent() const
// 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 @@ static Element* siblingWithAriaRole(String role, Node* node)
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;
}
......
......@@ -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 @@ bool AccessibilityTable::isDataTable() const
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;
}
......
......@@ -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 @@ PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription&
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.
......
......@@ -470,7 +470,8 @@ static void willRemoveChild(Node* child)
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)
......
......@@ -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 @@ public:
DescendantsOnly
};
explicit ChildFrameDisconnector(Node* root)
explicit ChildFrameDisconnector(ContainerNode* root)
: m_root(root)
{
}
......@@ -275,18 +276,18 @@ public:
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 @@ inline void ChildFrameDisconnector::collectFrameOwners(Node* root)
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 @@ inline void ChildFrameDisconnector::disconnect(DisconnectPolicy policy)
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);
}
......
......@@ -922,18 +922,12 @@ void HTMLMediaElement::selectMediaResource()
// 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 @@ void HTMLMediaElement::textTrackModeChanged(TextTrack* track)
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 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks()
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()
......
......@@ -153,25 +153,21 @@ void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<S
// 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 @@ bool HTMLObjectElement::containsJavaApplet() const
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()))
......
......@@ -44,6 +44,19 @@ private:
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
......@@ -57,6 +57,19 @@ private:
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
......
......@@ -67,9 +67,21 @@ private:
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);
}
......
(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)
......
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