<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[173606] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/173606">173606</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-09-14 14:18:27 -0700 (Sun, 14 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Rename Node::childNodeCount() to countChildNodes() and avoid inefficient uses
https://bugs.webkit.org/show_bug.cgi?id=136789
Reviewed by Darin Adler.
Source/WebCore:
Rename Node::childNodeCount() to countChildNodes() to make it clearer
that the method actually computes the result rather than returning a
cached value.
This patch also introduces a new Node::hasOneChild() method that is
used to check if a Node has a single child. This is much more efficient
than calling countChildNodes() == 1.
The patch also leverages Node::hasChildNodes() in a lot of places
instead of calling countChildNodes().
Finally, in a couple of places, we now use childrenOfType() to iterate
over children more efficient than using countChildNodes() and
childNode(index).
No new tests, no behavior change.
* WebCore.exp.in:
* WebCore.order:
Update the name of the exposed symbol for countChildNodes().
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChildren):
(WebCore::ContainerNode::countChildNodes):
(WebCore::ContainerNode::childNodeCount): Deleted.
Rename childNodeCount() to countChildNodes() to make it obvious it is
computing the result rather than returning a cached value.
* dom/ContainerNode.h:
(WebCore::ContainerNode::hasOneChild):
Introduce an efficient way to check in a ContainerNode has a single
child as "countChildNodes() == 1" calls were frequent and inefficient.
(WebCore::Node::countChildNodes):
(WebCore::Node::childNodeCount): Deleted.
* dom/Node.h:
Rename childNodeCount() to countChildNodes().
* dom/Position.cpp:
(WebCore::Position::parentAnchoredEquivalent):
* dom/Position.h:
(WebCore::lastOffsetInNode):
* dom/Range.cpp:
Mechanical renaming.
(WebCore::lengthOfContentsInNode):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
(WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun):
(WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
(WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
(WebCore::ApplyStyleCommand::applyInlineStyleChange):
Call hasChildNodes() rather than countChildNodes() as it is a lot more
efficient.
* editing/Editor.cpp:
(WebCore::Editor::setTextAsChildOfElement):
(WebCore::Editor::rangeOfString):
(WebCore::Editor::countMatchesForText):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::elementRangeContainingCaretSelection):
Mechanical renaming.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::insertAsListItems):
Call hasOneChild() instead of countChildNodes() == 1. Also remove
redundant listElement->hasChildNodes() check as hasOneChild() takes
care of this already.
* editing/TextIterator.cpp:
(WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
* editing/VisibleUnits.cpp:
(WebCore::endOfDocument):
* editing/htmlediting.cpp:
(WebCore::lastOffsetForEditing):
Mechanical renaming.
(WebCore::visiblePositionBeforeNode):
(WebCore::visiblePositionAfterNode):
Call hasChildNodes() instead of converting countChildNodes() to a
boolean.
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
Call !hasChildNodes() instead of !countChildNodes().
(WebCore::isPlainTextMarkup):
- Drop !node->isElementNode() check as !node->hasTagName(divTag) takes
care of discarding non-Element Nodes already.
- Cast the Node to an HTMLDivElement as soon as possible to avoid
calling calling the slower Node APIs in several cases.
- Call hasOneChild() instead of countChildNodes() == 1.
* html/HTMLDivElement.h:
* html/HTMLTagNames.in:
Generate casting helpers as I use them in WebCore::isPlainTextMarkup().
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::setText):
* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::setText):
Call hasOneChild() / hasChildNodes() instead of countChildNodes().
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTimelineContainerElement::setTimeDisplaysHidden):
(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
Use childrenOfType<Element>() to iterate of child Elements instead of
slower childNodeCount() + childNode(index) + isElementNode(). Also,
childNodeCount() was not even cached before the loop.
* html/track/VTTRegion.cpp:
(WebCore::VTTRegion::displayLastTextTrackCueBox):
Use childrenOfType<Element>() to iterate of child Elements, thus
avoiding calling childNodeCount() + childNode(index).
* page/DOMSelection.cpp:
(WebCore::DOMSelection::extend):
(WebCore::DOMSelection::selectAllChildren):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::caretMaxOffset):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::isSelected):
* rendering/RenderView.cpp:
(WebCore::RenderView::splitSelectionBetweenSubtrees):
Mechanical renaming.
Source/WebKit/mac:
Rename childNodeCount() to countChildNodes().
* WebView/WebHTMLView.mm:
(-[WebHTMLView attributedString]):
Source/WebKit2:
Avoid calling slow Node::countChildNodes().
* WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
(WebKit::WebPage::findZoomableAreaForPoint):
Replace call to "node->parentNode()->childNodeCount() != 1" by
"!node->parentNode()->hasOneChild()" which is equivalent but more
efficient.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCoreorder">trunk/Source/WebCore/WebCore.order</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodecpp">trunk/Source/WebCore/dom/ContainerNode.cpp</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodeh">trunk/Source/WebCore/dom/ContainerNode.h</a></li>
<li><a href="#trunkSourceWebCoredomNodeh">trunk/Source/WebCore/dom/Node.h</a></li>
<li><a href="#trunkSourceWebCoredomPositioncpp">trunk/Source/WebCore/dom/Position.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPositionh">trunk/Source/WebCore/dom/Position.h</a></li>
<li><a href="#trunkSourceWebCoredomRangecpp">trunk/Source/WebCore/dom/Range.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingApplyStyleCommandcpp">trunk/Source/WebCore/editing/ApplyStyleCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFrameSelectioncpp">trunk/Source/WebCore/editing/FrameSelection.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingReplaceSelectionCommandcpp">trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorcpp">trunk/Source/WebCore/editing/TextIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleUnitscpp">trunk/Source/WebCore/editing/VisibleUnits.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditinghtmleditingcpp">trunk/Source/WebCore/editing/htmlediting.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLDivElementh">trunk/Source/WebCore/html/HTMLDivElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLScriptElementcpp">trunk/Source/WebCore/html/HTMLScriptElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTagNamesin">trunk/Source/WebCore/html/HTMLTagNames.in</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTitleElementcpp">trunk/Source/WebCore/html/HTMLTitleElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlElementscpp">trunk/Source/WebCore/html/shadow/MediaControlElements.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmltrackVTTRegioncpp">trunk/Source/WebCore/html/track/VTTRegion.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMSelectioncpp">trunk/Source/WebCore/page/DOMSelection.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderReplacedcpp">trunk/Source/WebCore/rendering/RenderReplaced.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsWebPageCoordinatedGraphicscpp">trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/ChangeLog        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1,3 +1,136 @@
</span><ins>+2014-09-14 Chris Dumez <cdumez@apple.com>
+
+ Rename Node::childNodeCount() to countChildNodes() and avoid inefficient uses
+ https://bugs.webkit.org/show_bug.cgi?id=136789
+
+ Reviewed by Darin Adler.
+
+ Rename Node::childNodeCount() to countChildNodes() to make it clearer
+ that the method actually computes the result rather than returning a
+ cached value.
+
+ This patch also introduces a new Node::hasOneChild() method that is
+ used to check if a Node has a single child. This is much more efficient
+ than calling countChildNodes() == 1.
+
+ The patch also leverages Node::hasChildNodes() in a lot of places
+ instead of calling countChildNodes().
+
+ Finally, in a couple of places, we now use childrenOfType() to iterate
+ over children more efficient than using countChildNodes() and
+ childNode(index).
+
+ No new tests, no behavior change.
+
+ * WebCore.exp.in:
+ * WebCore.order:
+ Update the name of the exposed symbol for countChildNodes().
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::removeChildren):
+ (WebCore::ContainerNode::countChildNodes):
+ (WebCore::ContainerNode::childNodeCount): Deleted.
+ Rename childNodeCount() to countChildNodes() to make it obvious it is
+ computing the result rather than returning a cached value.
+
+ * dom/ContainerNode.h:
+ (WebCore::ContainerNode::hasOneChild):
+ Introduce an efficient way to check in a ContainerNode has a single
+ child as "countChildNodes() == 1" calls were frequent and inefficient.
+
+ (WebCore::Node::countChildNodes):
+ (WebCore::Node::childNodeCount): Deleted.
+ * dom/Node.h:
+ Rename childNodeCount() to countChildNodes().
+
+ * dom/Position.cpp:
+ (WebCore::Position::parentAnchoredEquivalent):
+ * dom/Position.h:
+ (WebCore::lastOffsetInNode):
+ * dom/Range.cpp:
+ Mechanical renaming.
+
+ (WebCore::lengthOfContentsInNode):
+ * editing/ApplyStyleCommand.cpp:
+ (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+ (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun):
+ (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
+ (WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
+ (WebCore::ApplyStyleCommand::applyInlineStyleChange):
+ Call hasChildNodes() rather than countChildNodes() as it is a lot more
+ efficient.
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::setTextAsChildOfElement):
+ (WebCore::Editor::rangeOfString):
+ (WebCore::Editor::countMatchesForText):
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::elementRangeContainingCaretSelection):
+ Mechanical renaming.
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::insertAsListItems):
+ Call hasOneChild() instead of countChildNodes() == 1. Also remove
+ redundant listElement->hasChildNodes() check as hasOneChild() takes
+ care of this already.
+
+ * editing/TextIterator.cpp:
+ (WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
+ * editing/VisibleUnits.cpp:
+ (WebCore::endOfDocument):
+ * editing/htmlediting.cpp:
+ (WebCore::lastOffsetForEditing):
+ Mechanical renaming.
+
+ (WebCore::visiblePositionBeforeNode):
+ (WebCore::visiblePositionAfterNode):
+ Call hasChildNodes() instead of converting countChildNodes() to a
+ boolean.
+
+ * editing/markup.cpp:
+ (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
+ Call !hasChildNodes() instead of !countChildNodes().
+
+ (WebCore::isPlainTextMarkup):
+ - Drop !node->isElementNode() check as !node->hasTagName(divTag) takes
+ care of discarding non-Element Nodes already.
+ - Cast the Node to an HTMLDivElement as soon as possible to avoid
+ calling calling the slower Node APIs in several cases.
+ - Call hasOneChild() instead of countChildNodes() == 1.
+
+ * html/HTMLDivElement.h:
+ * html/HTMLTagNames.in:
+ Generate casting helpers as I use them in WebCore::isPlainTextMarkup().
+
+ * html/HTMLScriptElement.cpp:
+ (WebCore::HTMLScriptElement::setText):
+ * html/HTMLTitleElement.cpp:
+ (WebCore::HTMLTitleElement::setText):
+ Call hasOneChild() / hasChildNodes() instead of countChildNodes().
+
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTimelineContainerElement::setTimeDisplaysHidden):
+ (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
+ Use childrenOfType<Element>() to iterate of child Elements instead of
+ slower childNodeCount() + childNode(index) + isElementNode(). Also,
+ childNodeCount() was not even cached before the loop.
+
+ * html/track/VTTRegion.cpp:
+ (WebCore::VTTRegion::displayLastTextTrackCueBox):
+ Use childrenOfType<Element>() to iterate of child Elements, thus
+ avoiding calling childNodeCount() + childNode(index).
+
+ * page/DOMSelection.cpp:
+ (WebCore::DOMSelection::extend):
+ (WebCore::DOMSelection::selectAllChildren):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::caretMaxOffset):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::isSelected):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::splitSelectionBetweenSubtrees):
+ Mechanical renaming.
+
</ins><span class="cx"> 2014-09-13 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Un-inline Element constructor
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1625,7 +1625,7 @@
</span><span class="cx"> __ZNK7WebCore12TextEncoding6decodeEPKcmbRb
</span><span class="cx"> __ZNK7WebCore12TextIterator4nodeEv
</span><span class="cx"> __ZNK7WebCore12TextIterator5rangeEv
</span><del>-__ZNK7WebCore13ContainerNode14childNodeCountEv
</del><ins>+__ZNK7WebCore13ContainerNode15countChildNodesEv
</ins><span class="cx"> __ZNK7WebCore13ContainerNode9childNodeEj
</span><span class="cx"> __ZNK7WebCore13GraphicsLayer18accumulatedOpacityEv
</span><span class="cx"> __ZNK7WebCore13GraphicsLayer18getDebugBorderInfoERNS_5ColorERf
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreorder"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.order (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.order        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/WebCore.order        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -11622,7 +11622,7 @@
</span><span class="cx"> __ZN7WebCore24jsHTMLMetaElementContentEPN3JSC9ExecStateENS0_7JSValueENS0_12PropertyNameE
</span><span class="cx"> __ZN7WebCore26setJSHTMLScriptElementTextEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueE
</span><span class="cx"> __ZN7WebCore17HTMLScriptElement7setTextERKN3WTF6StringE
</span><del>-__ZNK7WebCore13ContainerNode14childNodeCountEv
</del><ins>+__ZNK7WebCore13ContainerNode15countChildNodesEv
</ins><span class="cx"> __ZN7WebCore20jsHTMLLinkElementRelEPN3JSC9ExecStateENS0_7JSValueENS0_12PropertyNameE
</span><span class="cx"> __ZN7WebCore21jsHTMLLinkElementHrefEPN3JSC9ExecStateENS0_7JSValueENS0_12PropertyNameE
</span><span class="cx"> __ZN7WebCore13NodeTraversal35nextIncludingPseudoSkippingChildrenEPKNS_4NodeES3_
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -653,7 +653,7 @@
</span><span class="cx"> WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
</span><span class="cx"> {
</span><span class="cx"> NoEventDispatchAssertion assertNoEventDispatch;
</span><del>- removedChildren.reserveInitialCapacity(childNodeCount());
</del><ins>+ removedChildren.reserveInitialCapacity(countChildNodes());
</ins><span class="cx"> while (RefPtr<Node> n = m_firstChild) {
</span><span class="cx"> removedChildren.append(*m_firstChild);
</span><span class="cx"> removeBetween(0, m_firstChild->nextSibling(), *m_firstChild);
</span><span class="lines">@@ -931,12 +931,11 @@
</span><span class="cx"> return enclosingLayoutRect(FloatRect(upperLeft, lowerRight.expandedTo(upperLeft) - upperLeft));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-unsigned ContainerNode::childNodeCount() const
</del><ins>+unsigned ContainerNode::countChildNodes() const
</ins><span class="cx"> {
</span><span class="cx"> unsigned count = 0;
</span><del>- Node *n;
- for (n = firstChild(); n; n = n->nextSibling())
- count++;
</del><ins>+ for (Node* child = firstChild(); child; child = child->nextSibling())
+ ++count;
</ins><span class="cx"> return count;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.h (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.h        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/ContainerNode.h        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -87,11 +87,12 @@
</span><span class="cx"> static ptrdiff_t firstChildMemoryOffset() { return OBJECT_OFFSETOF(ContainerNode, m_firstChild); }
</span><span class="cx"> Node* lastChild() const { return m_lastChild; }
</span><span class="cx"> bool hasChildNodes() const { return m_firstChild; }
</span><ins>+ bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling(); }
</ins><span class="cx">
</span><span class="cx"> bool directChildNeedsStyleRecalc() const { return getFlag(DirectChildNeedsStyleRecalcFlag); }
</span><span class="cx"> void setDirectChildNeedsStyleRecalc() { setFlag(DirectChildNeedsStyleRecalcFlag); }
</span><span class="cx">
</span><del>- WEBCORE_EXPORT unsigned childNodeCount() const;
</del><ins>+ WEBCORE_EXPORT unsigned countChildNodes() const;
</ins><span class="cx"> WEBCORE_EXPORT Node* childNode(unsigned index) const;
</span><span class="cx">
</span><span class="cx"> bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
</span><span class="lines">@@ -184,11 +185,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline unsigned Node::childNodeCount() const
</del><ins>+inline unsigned Node::countChildNodes() const
</ins><span class="cx"> {
</span><span class="cx"> if (!isContainerNode())
</span><span class="cx"> return 0;
</span><del>- return toContainerNode(this)->childNodeCount();
</del><ins>+ return toContainerNode(this)->countChildNodes();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline Node* Node::childNode(unsigned index) const
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.h (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.h        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/Node.h        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -416,7 +416,7 @@
</span><span class="cx"> bool isReadOnlyNode() const { return nodeType() == ENTITY_REFERENCE_NODE; }
</span><span class="cx"> bool isDocumentTypeNode() const { return nodeType() == DOCUMENT_TYPE_NODE; }
</span><span class="cx"> virtual bool childTypeAllowed(NodeType) const { return false; }
</span><del>- unsigned childNodeCount() const;
</del><ins>+ unsigned countChildNodes() const;
</ins><span class="cx"> Node* childNode(unsigned index) const;
</span><span class="cx">
</span><span class="cx"> void checkSetPrefix(const AtomicString& prefix, ExceptionCode&);
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Position.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Position.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/Position.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!m_anchorNode->offsetInCharacters()
</span><del>- && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsAfterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->childNodeCount())
</del><ins>+ && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsAfterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->countChildNodes())
</ins><span class="cx"> && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_anchorNode.get()))
</span><span class="cx"> && containerNode()) {
</span><span class="cx"> return positionInParentAfterNode(m_anchorNode.get());
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Position.h (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Position.h        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/Position.h        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -297,10 +297,10 @@
</span><span class="cx">
</span><span class="cx"> inline int lastOffsetInNode(Node* node)
</span><span class="cx"> {
</span><del>- return node->offsetInCharacters() ? node->maxCharacterOffset() : static_cast<int>(node->childNodeCount());
</del><ins>+ return node->offsetInCharacters() ? node->maxCharacterOffset() : static_cast<int>(node->countChildNodes());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to childNodeCount()
</del><ins>+// firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to countChildNodes()
</ins><span class="cx"> inline Position firstPositionInNode(Node* anchorNode)
</span><span class="cx"> {
</span><span class="cx"> if (anchorNode->isTextNode())
</span></span></pre></div>
<a id="trunkSourceWebCoredomRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Range.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Range.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/dom/Range.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -672,7 +672,7 @@
</span><span class="cx"> case Node::DOCUMENT_FRAGMENT_NODE:
</span><span class="cx"> case Node::NOTATION_NODE:
</span><span class="cx"> case Node::XPATH_NAMESPACE_NODE:
</span><del>- return node->childNodeCount();
</del><ins>+ return node->countChildNodes();
</ins><span class="cx"> }
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingApplyStyleCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -777,7 +777,7 @@
</span><span class="cx"> if (isBlock(node.get()))
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- if (node->childNodeCount()) {
</del><ins>+ if (node->hasChildNodes()) {
</ins><span class="cx"> if (node->contains(pastEndNode.get()) || containsNonEditableRegion(node.get()) || !node->parentNode()->hasEditableStyle())
</span><span class="cx"> continue;
</span><span class="cx"> if (editingIgnoresContent(node.get())) {
</span><span class="lines">@@ -835,7 +835,7 @@
</span><span class="cx"> ASSERT(style && runStart);
</span><span class="cx">
</span><span class="cx"> for (Node* node = runStart; node && node != pastEndNode; node = NodeTraversal::next(node)) {
</span><del>- if (node->childNodeCount())
</del><ins>+ if (node->hasChildNodes())
</ins><span class="cx"> continue;
</span><span class="cx"> // We don't consider m_isInlineElementToRemoveFunction here because we never apply style when m_isInlineElementToRemoveFunction is specified
</span><span class="cx"> if (!style->styleIsPresentInComputedStyleOfNode(node))
</span><span class="lines">@@ -1007,7 +1007,7 @@
</span><span class="cx">
</span><span class="cx"> // Since addInlineStyleIfNeeded can't add styles to block-flow render objects, add style attribute instead.
</span><span class="cx"> // FIXME: applyInlineStyleToRange should be used here instead.
</span><del>- if ((node->renderer()->isRenderBlockFlow() || node->childNodeCount()) && node->isHTMLElement()) {
</del><ins>+ if ((node->renderer()->isRenderBlockFlow() || node->hasChildNodes()) && node->isHTMLElement()) {
</ins><span class="cx"> setNodeAttribute(toHTMLElement(node), styleAttr, newInlineStyle->style()->asText());
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -1325,7 +1325,7 @@
</span><span class="cx"> mergeIdenticalElements(element, nextElement);
</span><span class="cx">
</span><span class="cx"> bool shouldUpdateStart = start.containerNode() == endNode;
</span><del>- int endOffset = nextChild ? nextChild->nodeIndex() : nextElement->childNodeCount();
</del><ins>+ int endOffset = nextChild ? nextChild->nodeIndex() : nextElement->countChildNodes();
</ins><span class="cx"> updateStartEnd(shouldUpdateStart ? Position(nextElement, start.offsetInContainerNode(), Position::PositionIsOffsetInAnchor) : start,
</span><span class="cx"> Position(nextElement, endOffset, Position::PositionIsOffsetInAnchor));
</span><span class="cx"> return true;
</span><span class="lines">@@ -1433,7 +1433,7 @@
</span><span class="cx"> if (container->isHTMLElement() && container->hasTagName(fontTag))
</span><span class="cx"> fontContainer = toHTMLElement(container);
</span><span class="cx"> bool styleContainerIsNotSpan = !styleContainer || !styleContainer->hasTagName(spanTag);
</span><del>- if (container->isHTMLElement() && (container->hasTagName(spanTag) || (styleContainerIsNotSpan && container->childNodeCount())))
</del><ins>+ if (container->isHTMLElement() && (container->hasTagName(spanTag) || (styleContainerIsNotSpan && container->hasChildNodes())))
</ins><span class="cx"> styleContainer = toHTMLElement(container);
</span><span class="cx"> if (!container->firstChild())
</span><span class="cx"> break;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/Editor.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -704,7 +704,7 @@
</span><span class="cx"> // set the selection to the end
</span><span class="cx"> VisibleSelection selection;
</span><span class="cx">
</span><del>- Position pos = createLegacyEditingPosition(elem, elem->childNodeCount());
</del><ins>+ Position pos = createLegacyEditingPosition(elem, elem->countChildNodes());
</ins><span class="cx">
</span><span class="cx"> VisiblePosition visiblePos(pos, VP_DEFAULT_AFFINITY);
</span><span class="cx"> if (visiblePos.isNull())
</span><span class="lines">@@ -3168,7 +3168,7 @@
</span><span class="cx"> RefPtr<Node> shadowTreeRoot = referenceRange && referenceRange->startContainer() ? referenceRange->startContainer()->nonBoundaryShadowTreeRootNode() : 0;
</span><span class="cx"> if (shadowTreeRoot) {
</span><span class="cx"> if (forward)
</span><del>- searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->childNodeCount());
</del><ins>+ searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->countChildNodes());
</ins><span class="cx"> else
</span><span class="cx"> searchRange->setStart(shadowTreeRoot.get(), 0);
</span><span class="cx"> }
</span><span class="lines">@@ -3186,7 +3186,7 @@
</span><span class="cx">
</span><span class="cx"> if (shadowTreeRoot) {
</span><span class="cx"> if (forward)
</span><del>- searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->childNodeCount());
</del><ins>+ searchRange->setEnd(shadowTreeRoot.get(), shadowTreeRoot->countChildNodes());
</ins><span class="cx"> else
</span><span class="cx"> searchRange->setStart(shadowTreeRoot.get(), 0);
</span><span class="cx"> }
</span><span class="lines">@@ -3279,7 +3279,7 @@
</span><span class="cx">
</span><span class="cx"> Node* shadowTreeRoot = searchRange->shadowRoot();
</span><span class="cx"> if (searchRange->collapsed(IGNORE_EXCEPTION) && shadowTreeRoot)
</span><del>- searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount(), IGNORE_EXCEPTION);
</del><ins>+ searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->countChildNodes(), IGNORE_EXCEPTION);
</ins><span class="cx"> } while (true);
</span><span class="cx">
</span><span class="cx"> if (markMatches || matches) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFrameSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FrameSelection.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -2196,7 +2196,7 @@
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><span class="cx"> Position startPos = createLegacyEditingPosition(element, 0);
</span><del>- Position endPos = createLegacyEditingPosition(element, element->childNodeCount());
</del><ins>+ Position endPos = createLegacyEditingPosition(element, element->countChildNodes());
</ins><span class="cx">
</span><span class="cx"> VisiblePosition startVisiblePos(startPos, VP_DEFAULT_AFFINITY);
</span><span class="cx"> VisiblePosition endVisiblePos(endPos, VP_DEFAULT_AFFINITY);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingReplaceSelectionCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1437,7 +1437,7 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<HTMLElement> listElement = prpListElement;
</span><span class="cx">
</span><del>- while (listElement->hasChildNodes() && isListElement(listElement->firstChild()) && listElement->childNodeCount() == 1)
</del><ins>+ while (listElement->hasOneChild() && isListElement(listElement->firstChild()))
</ins><span class="cx"> listElement = toHTMLElement(listElement->firstChild());
</span><span class="cx">
</span><span class="cx"> bool isStart = isStartOfParagraph(insertPos);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/TextIterator.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1146,13 +1146,13 @@
</span><span class="cx"> int endOffset = range.endOffset();
</span><span class="cx">
</span><span class="cx"> if (!startNode->offsetInCharacters()) {
</span><del>- if (startOffset >= 0 && startOffset < static_cast<int>(startNode->childNodeCount())) {
</del><ins>+ if (startOffset >= 0 && startOffset < static_cast<int>(startNode->countChildNodes())) {
</ins><span class="cx"> startNode = startNode->childNode(startOffset);
</span><span class="cx"> startOffset = 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> if (!endNode->offsetInCharacters()) {
</span><del>- if (endOffset > 0 && endOffset <= static_cast<int>(endNode->childNodeCount())) {
</del><ins>+ if (endOffset > 0 && endOffset <= static_cast<int>(endNode->countChildNodes())) {
</ins><span class="cx"> endNode = endNode->childNode(endOffset - 1);
</span><span class="cx"> endOffset = lastOffsetInNode(endNode);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1364,7 +1364,7 @@
</span><span class="cx"> // (As above, in startOfDocument.) The canonicalization can reject valid visible positions
</span><span class="cx"> // when descending from the root element, so we construct the visible position directly from a
</span><span class="cx"> // valid candidate.
</span><del>- Position lastPosition = createLegacyEditingPosition(node->document().documentElement(), node->document().documentElement()->childNodeCount());
</del><ins>+ Position lastPosition = createLegacyEditingPosition(node->document().documentElement(), node->document().documentElement()->countChildNodes());
</ins><span class="cx"> Position lastCandidate = previousCandidate(lastPosition);
</span><span class="cx"> if (lastCandidate.isNull())
</span><span class="cx"> return VisiblePosition();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditinghtmleditingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/htmlediting.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/htmlediting.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/htmlediting.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -343,7 +343,7 @@
</span><span class="cx"> return node->maxCharacterOffset();
</span><span class="cx">
</span><span class="cx"> if (node->hasChildNodes())
</span><del>- return node->childNodeCount();
</del><ins>+ return node->countChildNodes();
</ins><span class="cx">
</span><span class="cx"> // NOTE: This should preempt the childNodeCount for, e.g., select nodes
</span><span class="cx"> if (editingIgnoresContent(node))
</span><span class="lines">@@ -513,7 +513,7 @@
</span><span class="cx"> VisiblePosition visiblePositionBeforeNode(Node* node)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(node);
</span><del>- if (node->childNodeCount())
</del><ins>+ if (node->hasChildNodes())
</ins><span class="cx"> return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM);
</span><span class="cx"> ASSERT(node->parentNode());
</span><span class="cx"> ASSERT(!node->parentNode()->isShadowRoot());
</span><span class="lines">@@ -524,7 +524,7 @@
</span><span class="cx"> VisiblePosition visiblePositionAfterNode(Node* node)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(node);
</span><del>- if (node->childNodeCount())
</del><ins>+ if (node->hasChildNodes())
</ins><span class="cx"> return VisiblePosition(lastPositionInOrAfterNode(node), DOWNSTREAM);
</span><span class="cx"> ASSERT(node->parentNode());
</span><span class="cx"> ASSERT(!node->parentNode()->isShadowRoot());
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/editing/markup.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include "ExceptionCodePlaceholder.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "HTMLBodyElement.h"
</span><ins>+#include "HTMLDivElement.h"
</ins><span class="cx"> #include "HTMLElement.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "HTMLTableElement.h"
</span><span class="lines">@@ -398,7 +399,7 @@
</span><span class="cx"> appendStartTag(*n);
</span><span class="cx">
</span><span class="cx"> // If node has no children, close the tag now.
</span><del>- if (!n->childNodeCount()) {
</del><ins>+ if (!n->hasChildNodes()) {
</ins><span class="cx"> if (shouldEmit)
</span><span class="cx"> appendEndTag(*n);
</span><span class="cx"> lastClosed = n;
</span><span class="lines">@@ -740,15 +741,27 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool isPlainTextMarkup(Node *node)
</del><ins>+bool isPlainTextMarkup(Node* node)
</ins><span class="cx"> {
</span><del>- if (!node->isElementNode() || !node->hasTagName(divTag) || toElement(node)->hasAttributes())
</del><ins>+ if (!isHTMLDivElement(node))
</ins><span class="cx"> return false;
</span><ins>+
+ HTMLDivElement& element = toHTMLDivElement(*node);
+ if (element.hasAttributes())
+ return false;
+
+ Node* firstChild = element.firstChild();
+ if (!firstChild)
+ return false;
+
+ Node* secondChild = firstChild->nextSibling();
+ if (!secondChild)
+ return firstChild->isTextNode() || firstChild->firstChild();
</ins><span class="cx">
</span><del>- if (node->childNodeCount() == 1 && (node->firstChild()->isTextNode() || (node->firstChild()->firstChild())))
- return true;
</del><ins>+ if (secondChild->nextSibling())
+ return false;
</ins><span class="cx">
</span><del>- return (node->childNodeCount() == 2 && isTabSpanTextNode(node->firstChild()->firstChild()) && node->firstChild()->nextSibling()->isTextNode());
</del><ins>+ return isTabSpanTextNode(firstChild->firstChild()) && secondChild->isTextNode();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static bool contextPreservesNewline(const Range& context)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLDivElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLDivElement.h (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLDivElement.h        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/HTMLDivElement.h        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -40,6 +40,8 @@
</span><span class="cx"> virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+NODE_TYPE_CASTS(HTMLDivElement)
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // HTMLDivElement_h
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLScriptElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLScriptElement.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLScriptElement.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/HTMLScriptElement.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -81,14 +81,12 @@
</span><span class="cx"> {
</span><span class="cx"> Ref<HTMLScriptElement> protectFromMutationEvents(*this);
</span><span class="cx">
</span><del>- int numChildren = childNodeCount();
-
- if (numChildren == 1 && firstChild()->isTextNode()) {
</del><ins>+ if (hasOneChild() && firstChild()->isTextNode()) {
</ins><span class="cx"> toText(firstChild())->setData(value, IGNORE_EXCEPTION);
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (numChildren > 0)
</del><ins>+ if (hasChildNodes())
</ins><span class="cx"> removeChildren();
</span><span class="cx">
</span><span class="cx"> appendChild(document().createTextNode(value.impl()), IGNORE_EXCEPTION);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTagNamesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTagNames.in (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTagNames.in        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/HTMLTagNames.in        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> details conditional=DETAILS_ELEMENT, generateTypeHelpers
</span><span class="cx"> dfn interfaceName=HTMLElement
</span><span class="cx"> dir interfaceName=HTMLDirectoryElement
</span><del>-div
</del><ins>+div generateTypeHelpers
</ins><span class="cx"> dl interfaceName=HTMLDListElement
</span><span class="cx"> dt interfaceName=HTMLElement
</span><span class="cx"> em interfaceName=HTMLElement
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTitleElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTitleElement.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTitleElement.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/HTMLTitleElement.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -96,10 +96,8 @@
</span><span class="cx"> void HTMLTitleElement::setText(const String &value)
</span><span class="cx"> {
</span><span class="cx"> Ref<HTMLTitleElement> protectFromMutationEvents(*this);
</span><del>-
- int numChildren = childNodeCount();
</del><span class="cx">
</span><del>- if (numChildren == 1 && firstChild()->isTextNode())
</del><ins>+ if (hasOneChild() && firstChild()->isTextNode())
</ins><span class="cx"> toText(firstChild())->setData(value, IGNORE_EXCEPTION);
</span><span class="cx"> else {
</span><span class="cx"> // We make a copy here because entity of "value" argument can be Document::m_title,
</span><span class="lines">@@ -107,7 +105,7 @@
</span><span class="cx"> // which causes HTMLTitleElement::childrenChanged(), which ends up Document::setTitle().
</span><span class="cx"> String valueCopy(value);
</span><span class="cx">
</span><del>- if (numChildren > 0)
</del><ins>+ if (hasChildNodes())
</ins><span class="cx"> removeChildren();
</span><span class="cx">
</span><span class="cx"> appendChild(document().createTextNode(valueCopy.impl()), IGNORE_EXCEPTION);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlElementscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "MediaControlElements.h"
</span><span class="cx">
</span><span class="cx"> #include "DOMTokenList.h"
</span><ins>+#include "ElementChildIterator.h"
</ins><span class="cx"> #include "EventHandler.h"
</span><span class="cx"> #include "EventNames.h"
</span><span class="cx"> #include "ExceptionCodePlaceholder.h"
</span><span class="lines">@@ -296,20 +297,16 @@
</span><span class="cx">
</span><span class="cx"> void MediaControlTimelineContainerElement::setTimeDisplaysHidden(bool hidden)
</span><span class="cx"> {
</span><del>- for (unsigned i = 0; i < childNodeCount(); ++i) {
- Node* child = childNode(i);
- if (!child || !child->isElementNode())
</del><ins>+ for (auto& element : childrenOfType<Element>(*this)) {
+ if (element.shadowPseudoId() != getMediaControlTimeRemainingDisplayElementShadowPseudoId()
+ && element.shadowPseudoId() != getMediaControlCurrentTimeDisplayElementShadowPseudoId())
</ins><span class="cx"> continue;
</span><del>- Element* element = toElement(child);
- if (element->shadowPseudoId() != getMediaControlTimeRemainingDisplayElementShadowPseudoId()
- && element->shadowPseudoId() != getMediaControlCurrentTimeDisplayElementShadowPseudoId())
- continue;
</del><span class="cx">
</span><del>- MediaControlTimeDisplayElement* timeDisplay = static_cast<MediaControlTimeDisplayElement*>(element);
</del><ins>+ MediaControlTimeDisplayElement& timeDisplay = static_cast<MediaControlTimeDisplayElement&>(element);
</ins><span class="cx"> if (hidden)
</span><del>- timeDisplay->hide();
</del><ins>+ timeDisplay.hide();
</ins><span class="cx"> else
</span><del>- timeDisplay->show();
</del><ins>+ timeDisplay.show();
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1152,7 +1149,9 @@
</span><span class="cx"> // we wish to render (e.g., we are adding another cue in a set of roll-up
</span><span class="cx"> // cues), remove all the existing CSS boxes representing the cues and re-add
</span><span class="cx"> // them so that the new cue is at the bottom.
</span><del>- if (childNodeCount() < activeCues.size())
</del><ins>+ // FIXME: Calling countChildNodes() here is inefficient. We don't need to
+ // traverse all children just to check if there are less children than cues.
+ if (countChildNodes() < activeCues.size())
</ins><span class="cx"> removeChildren();
</span><span class="cx">
</span><span class="cx"> // Sort the active cues for the appropriate display order. For example, for roll-up
</span></span></pre></div>
<a id="trunkSourceWebCorehtmltrackVTTRegioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/track/VTTRegion.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/track/VTTRegion.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/html/track/VTTRegion.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx">
</span><span class="cx"> #include "ClientRect.h"
</span><span class="cx"> #include "DOMTokenList.h"
</span><ins>+#include "ElementChildIterator.h"
</ins><span class="cx"> #include "ExceptionCodePlaceholder.h"
</span><span class="cx"> #include "HTMLDivElement.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="lines">@@ -361,7 +362,7 @@
</span><span class="cx"> ASSERT(m_cueContainer);
</span><span class="cx">
</span><span class="cx"> // The container needs to be rendered, if it is not empty and the region is not currently scrolling.
</span><del>- if (!m_cueContainer->renderer() || !m_cueContainer->childNodeCount() || m_scrollTimer.isActive())
</del><ins>+ if (!m_cueContainer->renderer() || !m_cueContainer->hasChildNodes() || m_scrollTimer.isActive())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // If it's a scrolling region, add the scrolling class.
</span><span class="lines">@@ -371,9 +372,10 @@
</span><span class="cx"> float regionBottom = m_regionDisplayTree->getBoundingClientRect()->bottom();
</span><span class="cx">
</span><span class="cx"> // Find first cue that is not entirely displayed and scroll it upwards.
</span><del>- for (size_t i = 0; i < m_cueContainer->childNodeCount() && !m_scrollTimer.isActive(); ++i) {
- float childTop = static_cast<HTMLDivElement*>(m_cueContainer->childNode(i))->getBoundingClientRect()->top();
- float childBottom = static_cast<HTMLDivElement*>(m_cueContainer->childNode(i))->getBoundingClientRect()->bottom();
</del><ins>+ for (auto& child : childrenOfType<Element>(*m_cueContainer)) {
+ RefPtr<ClientRect> rect = child.getBoundingClientRect();
+ float childTop = rect->top();
+ float childBottom = rect->bottom();
</ins><span class="cx">
</span><span class="cx"> if (regionBottom >= childBottom)
</span><span class="cx"> continue;
</span><span class="lines">@@ -384,6 +386,7 @@
</span><span class="cx"> m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrimitiveValue::CSS_PX);
</span><span class="cx">
</span><span class="cx"> startTimer();
</span><ins>+ break;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMSelection.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMSelection.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/page/DOMSelection.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (offset < 0 || offset > (node->offsetInCharacters() ? caretMaxOffset(node) : (int)node->childNodeCount())) {
</del><ins>+ if (offset < 0 || offset > (node->offsetInCharacters() ? caretMaxOffset(node) : static_cast<int>(node->countChildNodes()))) {
</ins><span class="cx"> ec = INDEX_SIZE_ERR;
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -481,7 +481,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // This doesn't (and shouldn't) select text node characters.
</span><del>- setBaseAndExtent(n, 0, n, n->childNodeCount(), ec);
</del><ins>+ setBaseAndExtent(n, 0, n, n->countChildNodes(), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String DOMSelection::toString()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -2380,7 +2380,7 @@
</span><span class="cx"> int RenderObject::caretMaxOffset() const
</span><span class="cx"> {
</span><span class="cx"> if (isReplaced())
</span><del>- return node() ? std::max(1U, node()->childNodeCount()) : 1;
</del><ins>+ return node() ? std::max(1U, node()->countChildNodes()) : 1;
</ins><span class="cx"> if (isHR())
</span><span class="cx"> return 1;
</span><span class="cx"> return 0;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderReplacedcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -585,7 +585,7 @@
</span><span class="cx"> if (s == SelectionStart)
</span><span class="cx"> return selectionStart == 0;
</span><span class="cx">
</span><del>- int end = element()->hasChildNodes() ? element()->childNodeCount() : 1;
</del><ins>+ int end = element()->hasChildNodes() ? element()->countChildNodes() : 1;
</ins><span class="cx"> if (s == SelectionEnd)
</span><span class="cx"> return selectionEnd == end;
</span><span class="cx"> if (s == SelectionBoth)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -905,7 +905,7 @@
</span><span class="cx"> if (node == endNode)
</span><span class="cx"> selectionData.setSelectionEndPos(endPos);
</span><span class="cx"> else
</span><del>- selectionData.setSelectionEndPos(node->offsetInCharacters() ? node->maxCharacterOffset() : node->childNodeCount());
</del><ins>+ selectionData.setSelectionEndPos(node->offsetInCharacters() ? node->maxCharacterOffset() : node->countChildNodes());
</ins><span class="cx">
</span><span class="cx"> renderSubtreesMap.set(&root, selectionData);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-09-14 Chris Dumez <cdumez@apple.com>
+
+ Rename Node::childNodeCount() to countChildNodes() and avoid inefficient uses
+ https://bugs.webkit.org/show_bug.cgi?id=136789
+
+ Reviewed by Darin Adler.
+
+ Rename childNodeCount() to countChildNodes().
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView attributedString]):
+
</ins><span class="cx"> 2014-09-10 Jon Honeycutt <jhoneycutt@apple.com>
</span><span class="cx">
</span><span class="cx"> Re-add the request autocomplete feature
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -6686,7 +6686,7 @@
</span><span class="cx"> NSAttributedString *attributedString = [self _attributeStringFromDOMRange:[document _documentRange]];
</span><span class="cx"> if (!attributedString) {
</span><span class="cx"> Document* coreDocument = core(document);
</span><del>- attributedString = editingAttributedStringFromRange(*Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()));
</del><ins>+ attributedString = editingAttributedStringFromRange(*Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->countChildNodes()));
</ins><span class="cx"> }
</span><span class="cx"> return attributedString;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebKit2/ChangeLog        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-09-14 Chris Dumez <cdumez@apple.com>
+
+ Rename Node::childNodeCount() to countChildNodes() and avoid inefficient uses
+ https://bugs.webkit.org/show_bug.cgi?id=136789
+
+ Reviewed by Darin Adler.
+
+ Avoid calling slow Node::countChildNodes().
+
+ * WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
+ (WebKit::WebPage::findZoomableAreaForPoint):
+ Replace call to "node->parentNode()->childNodeCount() != 1" by
+ "!node->parentNode()->hasOneChild()" which is equivalent but more
+ efficient.
+
</ins><span class="cx"> 2014-09-10 Jon Honeycutt <jhoneycutt@apple.com>
</span><span class="cx">
</span><span class="cx"> Re-add the request autocomplete feature
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageCoordinatedGraphicsWebPageCoordinatedGraphicscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp (173605 => 173606)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp        2014-09-13 23:21:28 UTC (rev 173605)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp        2014-09-14 21:18:27 UTC (rev 173606)
</span><span class="lines">@@ -64,9 +64,9 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // Candidate found, and it is a better candidate than its parent.
</span><del>- // NB: A parent is considered a better candidate iff the node is
</del><ins>+ // NB: A parent is considered a better candidate if the node is
</ins><span class="cx"> // contained by it and it is the only child.
</span><del>- if (found && (!node->parentNode() || node->parentNode()->childNodeCount() != 1))
</del><ins>+ if (found && (!node->parentNode() || !node->parentNode()->hasOneChild()))
</ins><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> node = node->parentNode();
</span></span></pre>
</div>
</div>
</body>
</html>