<!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>[176032] trunk/Source/WebCore</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/176032">176032</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-11-12 12:16:47 -0800 (Wed, 12 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Minor improvements to RenderListItem
https://bugs.webkit.org/show_bug.cgi?id=138601

Reviewed by Darin Adler.

Make several minor improvements to RenderListItem and clean up the
code a bit.

No new tests, no behavior change.

* rendering/RenderListItem.cpp:
(WebCore::isHTMLListElement):
- Rename isList to isHTMLListElement() for clarity as it checks
  for HTMLOListElement and HTMLUListElement types
- Inline the function as it is short.
- Use is&lt;HTML*Element&gt;() for type checking
- Update the argument to take a Node&amp; instead of an Element*. This
  is because the argument is expected to the non-null. Also using
  looser typing here allows us to use this utility function is one
  more place, without impacting performance as
  hasTagName(HTMLQualifiedName) is defined on Node.

(WebCore::enclosingList):
- Pass the argument as a reference instead of a pointer as it is
  expected to be non-null.
- Initialize firstNode before the loop to avoid the if (!firstNode)
  check for every iteration.

(WebCore::nextListItem):
- Take an Element as second argument instead of a RenderListItem*
  and provide convenience overloads so that we don't need to do
  null checks just because some calls sites call this function
  with 2 arguments and others with 1 argument. This way, we avoid
  unnecessary null checks as most call sites already do such
  checks (or have references).
- Transform the while loop into a for loop for clarity.
- Don't traverse an Element's subtree if the Element does not have
  a renderer as it is impossible of any of its descendant to have
  a renderer (and we are looking for a specific type of renderer).

(WebCore::previousListItem):
- Pass the item argument as a reference instead of a pointer as it
  is expected to be non-null.
- Reduce the scope of the |current| so that it is now declared
  inside the loop.

(WebCore::RenderListItem::updateItemValuesForOrderedList):
(WebCore::RenderListItem::itemCountForOrderedList):
- Pass argument as a reference instead of a pointer as it was expected
  to be non-null (There was an assertion in place to make sure of it).

(WebCore::RenderListItem::calcValue):
- Use is&lt;HTMLOListElement&gt;() instead of hasTagName().

(WebCore::getParentOfFirstLineBox):
- Rename variables to stop using abbreviations.
- Pass arguments as references instead of pointers as they are expected
  to be non-null.
- Remove the firstChild null check before the loop as it does not
  change behavior. The loop will abort early if firstChild is null
  and we will end up returning nullptr as well.
- Use is&lt;&gt;() more for type checking.
- Reuse the isHTMLListElement() utility function instead of duplicating
  its code inside this function.

(WebCore::firstNonMarkerChild):
- Pass argument as a reference as it is expected to be non-null.
- Rename variable from result to child for clarity, as we are traversing
  the children.

(WebCore::RenderListItem::markerTextWithSuffix):
- Use String appending instead of StringBuilder as it simplifies the
  code a lot and should not impact performance in this case.

(WebCore::RenderListItem::explicitValueChanged):
- Restructure the code a bit to do the |listNode| null check before the
  loop, now that nextListItem() takes a reference in argument. This is
  the only call site where we didn't already know that listNode is
  non-null.

(WebCore::previousOrNextItem):
- Mark this function as inline as it is short and called repeatedly.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLOListElementcpp">trunk/Source/WebCore/html/HTMLOListElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderListItemcpp">trunk/Source/WebCore/rendering/RenderListItem.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderListItemh">trunk/Source/WebCore/rendering/RenderListItem.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176031 => 176032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-12 20:09:42 UTC (rev 176031)
+++ trunk/Source/WebCore/ChangeLog        2014-11-12 20:16:47 UTC (rev 176032)
</span><span class="lines">@@ -1,5 +1,90 @@
</span><span class="cx"> 2014-11-12  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Minor improvements to RenderListItem
+        https://bugs.webkit.org/show_bug.cgi?id=138601
+
+        Reviewed by Darin Adler.
+
+        Make several minor improvements to RenderListItem and clean up the
+        code a bit.
+
+        No new tests, no behavior change.
+
+        * rendering/RenderListItem.cpp:
+        (WebCore::isHTMLListElement):
+        - Rename isList to isHTMLListElement() for clarity as it checks
+          for HTMLOListElement and HTMLUListElement types
+        - Inline the function as it is short.
+        - Use is&lt;HTML*Element&gt;() for type checking
+        - Update the argument to take a Node&amp; instead of an Element*. This
+          is because the argument is expected to the non-null. Also using
+          looser typing here allows us to use this utility function is one
+          more place, without impacting performance as
+          hasTagName(HTMLQualifiedName) is defined on Node.
+
+        (WebCore::enclosingList):
+        - Pass the argument as a reference instead of a pointer as it is
+          expected to be non-null.
+        - Initialize firstNode before the loop to avoid the if (!firstNode)
+          check for every iteration.
+
+        (WebCore::nextListItem):
+        - Take an Element as second argument instead of a RenderListItem*
+          and provide convenience overloads so that we don't need to do
+          null checks just because some calls sites call this function
+          with 2 arguments and others with 1 argument. This way, we avoid
+          unnecessary null checks as most call sites already do such
+          checks (or have references).
+        - Transform the while loop into a for loop for clarity.
+        - Don't traverse an Element's subtree if the Element does not have
+          a renderer as it is impossible of any of its descendant to have
+          a renderer (and we are looking for a specific type of renderer).
+
+        (WebCore::previousListItem):
+        - Pass the item argument as a reference instead of a pointer as it
+          is expected to be non-null.
+        - Reduce the scope of the |current| so that it is now declared
+          inside the loop.
+
+        (WebCore::RenderListItem::updateItemValuesForOrderedList):
+        (WebCore::RenderListItem::itemCountForOrderedList):
+        - Pass argument as a reference instead of a pointer as it was expected
+          to be non-null (There was an assertion in place to make sure of it).
+
+        (WebCore::RenderListItem::calcValue):
+        - Use is&lt;HTMLOListElement&gt;() instead of hasTagName().
+
+        (WebCore::getParentOfFirstLineBox):
+        - Rename variables to stop using abbreviations.
+        - Pass arguments as references instead of pointers as they are expected
+          to be non-null.
+        - Remove the firstChild null check before the loop as it does not
+          change behavior. The loop will abort early if firstChild is null
+          and we will end up returning nullptr as well.
+        - Use is&lt;&gt;() more for type checking.
+        - Reuse the isHTMLListElement() utility function instead of duplicating
+          its code inside this function.
+
+        (WebCore::firstNonMarkerChild):
+        - Pass argument as a reference as it is expected to be non-null.
+        - Rename variable from result to child for clarity, as we are traversing
+          the children.
+
+        (WebCore::RenderListItem::markerTextWithSuffix):
+        - Use String appending instead of StringBuilder as it simplifies the
+          code a lot and should not impact performance in this case.
+
+        (WebCore::RenderListItem::explicitValueChanged):
+        - Restructure the code a bit to do the |listNode| null check before the
+          loop, now that nextListItem() takes a reference in argument. This is
+          the only call site where we didn't already know that listNode is
+          non-null.
+
+        (WebCore::previousOrNextItem):
+        - Mark this function as inline as it is short and called repeatedly.
+
+2014-11-12  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Speed up HTMLTextFormControlElement::setInnerTextValue() a bit
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=138619
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLOListElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLOListElement.cpp (176031 => 176032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLOListElement.cpp        2014-11-12 20:09:42 UTC (rev 176031)
+++ trunk/Source/WebCore/html/HTMLOListElement.cpp        2014-11-12 20:16:47 UTC (rev 176032)
</span><span class="lines">@@ -106,12 +106,12 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLOListElement::updateItemValues()
</span><span class="cx"> {
</span><del>-    RenderListItem::updateItemValuesForOrderedList(this);
</del><ins>+    RenderListItem::updateItemValuesForOrderedList(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLOListElement::recalculateItemCount()
</span><span class="cx"> {
</span><del>-    m_itemCount = RenderListItem::itemCountForOrderedList(this);
</del><ins>+    m_itemCount = RenderListItem::itemCountForOrderedList(*this);
</ins><span class="cx">     m_shouldRecalculateItemCount = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderListItemcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (176031 => 176032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderListItem.cpp        2014-11-12 20:09:42 UTC (rev 176031)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp        2014-11-12 20:16:47 UTC (rev 176032)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;RenderInline.h&quot;
</span><span class="cx"> #include &quot;RenderListMarker.h&quot;
</span><span class="cx"> #include &quot;RenderMultiColumnFlowThread.h&quot;
</span><ins>+#include &quot;RenderTable.h&quot;
</ins><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;StyleInheritedData.h&quot;
</span><span class="cx"> #include &lt;wtf/StackStats.h&gt;
</span><span class="lines">@@ -99,23 +100,21 @@
</span><span class="cx">     updateListMarkerNumbers();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isList(const Element* element)
</del><ins>+static inline bool isHTMLListElement(const Node&amp; node)
</ins><span class="cx"> {
</span><del>-    return element-&gt;hasTagName(ulTag) || element-&gt;hasTagName(olTag);
</del><ins>+    return is&lt;HTMLUListElement&gt;(node) || is&lt;HTMLOListElement&gt;(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Returns the enclosing list with respect to the DOM order.
</span><del>-static Element* enclosingList(const RenderListItem* listItem)
</del><ins>+static Element* enclosingList(const RenderListItem&amp; listItem)
</ins><span class="cx"> {
</span><del>-    Element&amp; listItemElement = listItem-&gt;element();
-    Element* firstNode = nullptr;
</del><ins>+    Element&amp; listItemElement = listItem.element();
</ins><span class="cx">     Element* parent = is&lt;PseudoElement&gt;(listItemElement) ? downcast&lt;PseudoElement&gt;(listItemElement).hostElement() : listItemElement.parentElement();
</span><ins>+    Element* firstNode = parent;
</ins><span class="cx">     // We use parentNode because the enclosing list could be a ShadowRoot that's not Element.
</span><span class="cx">     for (; parent; parent = parent-&gt;parentElement()) {
</span><del>-        if (isList(parent))
</del><ins>+        if (isHTMLListElement(*parent))
</ins><span class="cx">             return parent;
</span><del>-        if (!firstNode)
-            firstNode = parent;
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If there's no actual &lt;ul&gt; or &lt;ol&gt; list element, then the first found
</span><span class="lines">@@ -125,41 +124,43 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Returns the next list item with respect to the DOM order.
</span><del>-static RenderListItem* nextListItem(const Element* listNode, const RenderListItem* item = nullptr)
</del><ins>+static RenderListItem* nextListItem(const Element&amp; listNode, const Element&amp; element)
</ins><span class="cx"> {
</span><del>-    if (!listNode)
-        return nullptr;
-
-    const Element* current = item ? &amp;item-&gt;element() : listNode;
-    current = ElementTraversal::nextIncludingPseudo(current, listNode);
-
-    while (current) {
-        if (isList(current)) {
-            // We've found a nested, independent list: nothing to do here.
-            current = ElementTraversal::nextIncludingPseudoSkippingChildren(current, listNode);
</del><ins>+    for (const Element* next = ElementTraversal::nextIncludingPseudo(&amp;element, &amp;listNode); next; ) {
+        auto* renderer = next-&gt;renderer();
+        if (!renderer || isHTMLListElement(*next)) {
+            // We've found a nested, independent list or an unrendered Element : nothing to do here.
+            next = ElementTraversal::nextIncludingPseudoSkippingChildren(next, &amp;listNode);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        RenderElement* renderer = current-&gt;renderer();
-        if (is&lt;RenderListItem&gt;(renderer))
</del><ins>+        if (is&lt;RenderListItem&gt;(*renderer))
</ins><span class="cx">             return downcast&lt;RenderListItem&gt;(renderer);
</span><span class="cx"> 
</span><del>-        // FIXME: Can this be optimized to skip the children of the elements without a renderer?
-        current = ElementTraversal::nextIncludingPseudo(current, listNode);
</del><ins>+        next = ElementTraversal::nextIncludingPseudo(next, &amp;listNode);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline RenderListItem* nextListItem(const Element&amp; listNode, const RenderListItem&amp; item)
+{
+    return nextListItem(listNode, item.element());
+}
+
+static inline RenderListItem* nextListItem(const Element&amp; listNode)
+{
+    return nextListItem(listNode, listNode);
+}
+
</ins><span class="cx"> // Returns the previous list item with respect to the DOM order.
</span><del>-static RenderListItem* previousListItem(const Element* listNode, const RenderListItem* item)
</del><ins>+static RenderListItem* previousListItem(const Element* listNode, const RenderListItem&amp; item)
</ins><span class="cx"> {
</span><del>-    Element* current = &amp;item-&gt;element();
-    for (current = ElementTraversal::previousIncludingPseudo(current, listNode); current; current = ElementTraversal::previousIncludingPseudo(current, listNode)) {
</del><ins>+    for (const Element* current = ElementTraversal::previousIncludingPseudo(&amp;item.element(), listNode); current; current = ElementTraversal::previousIncludingPseudo(current, listNode)) {
</ins><span class="cx">         RenderElement* renderer = current-&gt;renderer();
</span><span class="cx">         if (!is&lt;RenderListItem&gt;(renderer))
</span><span class="cx">             continue;
</span><del>-        Element* otherList = enclosingList(downcast&lt;RenderListItem&gt;(renderer));
</del><ins>+        Element* otherList = enclosingList(downcast&lt;RenderListItem&gt;(*renderer));
</ins><span class="cx">         // This item is part of our current list, so it's what we're looking for.
</span><span class="cx">         if (listNode == otherList)
</span><span class="cx">             return downcast&lt;RenderListItem&gt;(renderer);
</span><span class="lines">@@ -173,22 +174,17 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderListItem::updateItemValuesForOrderedList(const HTMLOListElement* listNode)
</del><ins>+void RenderListItem::updateItemValuesForOrderedList(const HTMLOListElement&amp; listNode)
</ins><span class="cx"> {
</span><del>-    ASSERT(listNode);
-
-    for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, listItem))
</del><ins>+    for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, *listItem))
</ins><span class="cx">         listItem-&gt;updateValue();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned RenderListItem::itemCountForOrderedList(const HTMLOListElement* listNode)
</del><ins>+unsigned RenderListItem::itemCountForOrderedList(const HTMLOListElement&amp; listNode)
</ins><span class="cx"> {
</span><del>-    ASSERT(listNode);
-
</del><span class="cx">     unsigned itemCount = 0;
</span><del>-    for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, listItem))
-        itemCount++;
-
</del><ins>+    for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, *listItem))
+        ++itemCount;
</ins><span class="cx">     return itemCount;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -197,15 +193,15 @@
</span><span class="cx">     if (m_hasExplicitValue)
</span><span class="cx">         return m_explicitValue;
</span><span class="cx"> 
</span><del>-    Element* list = enclosingList(this);
-    HTMLOListElement* oListElement = (list &amp;&amp; list-&gt;hasTagName(olTag)) ? downcast&lt;HTMLOListElement&gt;(list) : nullptr;
</del><ins>+    Element* list = enclosingList(*this);
+    HTMLOListElement* oListElement = is&lt;HTMLOListElement&gt;(list) ? downcast&lt;HTMLOListElement&gt;(list) : nullptr;
</ins><span class="cx">     int valueStep = 1;
</span><span class="cx">     if (oListElement &amp;&amp; oListElement-&gt;isReversed())
</span><span class="cx">         valueStep = -1;
</span><span class="cx"> 
</span><span class="cx">     // FIXME: This recurses to a possible depth of the length of the list.
</span><span class="cx">     // That's not good -- we need to change this to an iterative algorithm.
</span><del>-    if (RenderListItem* previousItem = previousListItem(list, this))
</del><ins>+    if (RenderListItem* previousItem = previousListItem(list, *this))
</ins><span class="cx">         return previousItem-&gt;value() + valueStep;
</span><span class="cx"> 
</span><span class="cx">     if (oListElement)
</span><span class="lines">@@ -225,31 +221,26 @@
</span><span class="cx">     return lastChild() == m_marker;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RenderBlock* getParentOfFirstLineBox(RenderBlock* curr, RenderObject* marker)
</del><ins>+static RenderBlock* getParentOfFirstLineBox(RenderBlock&amp; current, RenderObject&amp; marker)
</ins><span class="cx"> {
</span><del>-    RenderObject* firstChild = curr-&gt;firstChild();
-    if (!firstChild)
-        return 0;
-
-    bool inQuirksMode = curr-&gt;document().inQuirksMode();
-    for (RenderObject* currChild = firstChild; currChild; currChild = currChild-&gt;nextSibling()) {
-        if (currChild == marker)
</del><ins>+    bool inQuirksMode = current.document().inQuirksMode();
+    for (RenderObject* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
+        if (child == &amp;marker)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        if (currChild-&gt;isInline() &amp;&amp; (!is&lt;RenderInline&gt;(*currChild) || curr-&gt;generatesLineBoxesForInlineChild(currChild)))
-            return curr;
</del><ins>+        if (child-&gt;isInline() &amp;&amp; (!is&lt;RenderInline&gt;(*child) || current.generatesLineBoxesForInlineChild(child)))
+            return &amp;current;
</ins><span class="cx"> 
</span><del>-        if (currChild-&gt;isFloating() || currChild-&gt;isOutOfFlowPositioned())
</del><ins>+        if (child-&gt;isFloating() || child-&gt;isOutOfFlowPositioned())
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        if (currChild-&gt;isTable() || !is&lt;RenderBlock&gt;(*currChild) || (is&lt;RenderBox&gt;(*currChild) &amp;&amp; downcast&lt;RenderBox&gt;(*currChild).isWritingModeRoot()))
</del><ins>+        if (is&lt;RenderTable&gt;(*child) || !is&lt;RenderBlock&gt;(*child) || (is&lt;RenderBox&gt;(*child) &amp;&amp; downcast&lt;RenderBox&gt;(*child).isWritingModeRoot()))
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        if (curr-&gt;isListItem() &amp;&amp; inQuirksMode &amp;&amp; currChild-&gt;node() &amp;&amp;
-            (is&lt;HTMLUListElement&gt;(*currChild-&gt;node()) || is&lt;HTMLOListElement&gt;(*currChild-&gt;node())))
</del><ins>+        if (is&lt;RenderListItem&gt;(current) &amp;&amp; inQuirksMode &amp;&amp; child-&gt;node() &amp;&amp; isHTMLListElement(*child-&gt;node()))
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        if (RenderBlock* lineBox = getParentOfFirstLineBox(downcast&lt;RenderBlock&gt;(currChild), marker))
</del><ins>+        if (RenderBlock* lineBox = getParentOfFirstLineBox(downcast&lt;RenderBlock&gt;(*child), marker))
</ins><span class="cx">             return lineBox;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -265,12 +256,12 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RenderObject* firstNonMarkerChild(RenderBlock* parent)
</del><ins>+static RenderObject* firstNonMarkerChild(RenderBlock&amp; parent)
</ins><span class="cx"> {
</span><del>-    RenderObject* result = parent-&gt;firstChild();
-    while (result &amp;&amp; result-&gt;isListMarker())
-        result = result-&gt;nextSibling();
-    return result;
</del><ins>+    RenderObject* child = parent.firstChild();
+    while (is&lt;RenderListMarker&gt;(child))
+        child = child-&gt;nextSibling();
+    return child;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderListItem::insertOrMoveMarkerRendererIfNeeded()
</span><span class="lines">@@ -280,7 +271,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RenderElement* currentParent = m_marker-&gt;parent();
</span><del>-    RenderBlock* newParent = getParentOfFirstLineBox(this, m_marker);
</del><ins>+    RenderBlock* newParent = getParentOfFirstLineBox(*this, *m_marker);
</ins><span class="cx">     if (!newParent) {
</span><span class="cx">         // If the marker is currently contained inside an anonymous box,
</span><span class="cx">         // then we are the only item in that anonymous box (since no line box
</span><span class="lines">@@ -299,7 +290,7 @@
</span><span class="cx">         // containers other than ourselves, so we need to disable LayoutState.
</span><span class="cx">         LayoutStateDisabler layoutStateDisabler(&amp;view());
</span><span class="cx">         m_marker-&gt;removeFromParent();
</span><del>-        newParent-&gt;addChild(m_marker, firstNonMarkerChild(newParent));
</del><ins>+        newParent-&gt;addChild(m_marker, firstNonMarkerChild(*newParent));
</ins><span class="cx">         m_marker-&gt;updateMarginsAndContent();
</span><span class="cx">         // If current parent is an anonymous block that has lost all its children, destroy it.
</span><span class="cx">         if (currentParent &amp;&amp; currentParent-&gt;isAnonymousBlock() &amp;&amp; !currentParent-&gt;firstChild() &amp;&amp; !downcast&lt;RenderBlock&gt;(*currentParent).continuation())
</span><span class="lines">@@ -452,28 +443,21 @@
</span><span class="cx"> 
</span><span class="cx">     // Append the suffix for the marker in the right place depending
</span><span class="cx">     // on the direction of the text (right-to-left or left-to-right).
</span><del>-
-    const String&amp; markerText = m_marker-&gt;text();
-    const String markerSuffix = m_marker-&gt;suffix();
-    StringBuilder result;
-
-    if (!m_marker-&gt;style().isLeftToRightDirection())
-        result.append(markerSuffix);
-
-    result.append(markerText);
-
</del><span class="cx">     if (m_marker-&gt;style().isLeftToRightDirection())
</span><del>-        result.append(markerSuffix);
-
-    return result.toString();
</del><ins>+        return m_marker-&gt;text() + m_marker-&gt;suffix();
+    return m_marker-&gt;suffix() + m_marker-&gt;text();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderListItem::explicitValueChanged()
</span><span class="cx"> {
</span><span class="cx">     if (m_marker)
</span><span class="cx">         m_marker-&gt;setNeedsLayoutAndPrefWidthsRecalc();
</span><del>-    Element* listNode = enclosingList(this);
-    for (RenderListItem* item = this; item; item = nextListItem(listNode, item))
</del><ins>+
+    updateValue();
+    Element* listNode = enclosingList(*this);
+    if (!listNode)
+        return;
+    for (RenderListItem* item = nextListItem(*listNode, *this); item; item = nextListItem(*listNode, *item))
</ins><span class="cx">         item-&gt;updateValue();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -496,25 +480,25 @@
</span><span class="cx">     explicitValueChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RenderListItem* previousOrNextItem(bool isListReversed, Element* list, RenderListItem* item)
</del><ins>+static inline RenderListItem* previousOrNextItem(bool isListReversed, Element&amp; list, RenderListItem&amp; item)
</ins><span class="cx"> {
</span><del>-    return isListReversed ? previousListItem(list, item) : nextListItem(list, item);
</del><ins>+    return isListReversed ? previousListItem(&amp;list, item) : nextListItem(list, item);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderListItem::updateListMarkerNumbers()
</span><span class="cx"> {
</span><del>-    Element* listNode = enclosingList(this);
</del><ins>+    Element* listNode = enclosingList(*this);
</ins><span class="cx">     // The list node can be the shadow root which has no renderer.
</span><span class="cx">     if (!listNode)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     bool isListReversed = false;
</span><del>-    HTMLOListElement* oListElement = (listNode &amp;&amp; listNode-&gt;hasTagName(olTag)) ? downcast&lt;HTMLOListElement&gt;(listNode) : nullptr;
-    if (oListElement) {
-        oListElement-&gt;itemCountChanged();
-        isListReversed = oListElement-&gt;isReversed();
</del><ins>+    if (is&lt;HTMLOListElement&gt;(*listNode)) {
+        HTMLOListElement&amp; oListElement = downcast&lt;HTMLOListElement&gt;(*listNode);
+        oListElement.itemCountChanged();
+        isListReversed = oListElement.isReversed();
</ins><span class="cx">     }
</span><del>-    for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, this); item; item = previousOrNextItem(isListReversed, listNode, item)) {
</del><ins>+    for (RenderListItem* item = previousOrNextItem(isListReversed, *listNode, *this); item; item = previousOrNextItem(isListReversed, *listNode, *item)) {
</ins><span class="cx">         if (!item-&gt;m_isValueUpToDate) {
</span><span class="cx">             // If an item has been marked for update before, we can safely
</span><span class="cx">             // assume that all the following ones have too.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderListItemh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderListItem.h (176031 => 176032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderListItem.h        2014-11-12 20:09:42 UTC (rev 176031)
+++ trunk/Source/WebCore/rendering/RenderListItem.h        2014-11-12 20:16:47 UTC (rev 176032)
</span><span class="lines">@@ -53,8 +53,8 @@
</span><span class="cx"> 
</span><span class="cx">     void updateListMarkerNumbers();
</span><span class="cx"> 
</span><del>-    static void updateItemValuesForOrderedList(const HTMLOListElement*);
-    static unsigned itemCountForOrderedList(const HTMLOListElement*);
</del><ins>+    static void updateItemValuesForOrderedList(const HTMLOListElement&amp;);
+    static unsigned itemCountForOrderedList(const HTMLOListElement&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void didDestroyListMarker() { m_marker = nullptr; }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>