<!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>[200931] 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/200931">200931</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2016-05-15 15:08:52 -0700 (Sun, 15 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>More CTTE and other cleanups for HTML editing header
https://bugs.webkit.org/show_bug.cgi?id=157722

Reviewed by Chris Dumez.

Source/WebCore:

These changes are mostly things Chris asked for in his review of my last patch
or other related style and small efficiency improvements.

- using nullptr instead of 0
- using is&lt;Text&gt; instead of isTextNode and is&lt;&gt; instead of hasTagName
- changing argument type of functions like editingIgnoresContent to a reference
- using { } instead of constructor calls for classes like Position
- using words like position intead of abbreviations like pos
- using auto rather than explicit types
- rename functions that return true for HTMLElement to express that in the function names

* dom/Position.cpp:
(WebCore::nextRenderedEditable): nullptr
(WebCore::previousRenderedEditable): nullptr
(WebCore::Position::Position): is&lt;&gt;, reference
(WebCore::Position::moveToPosition): reference
(WebCore::Position::offsetForPositionAfterAnchor): Added a null assertion and
null check that replaces the one that used to be in lastOffsetForEditing.
(WebCore::Position::parentAnchoredEquivalent): { }, reference
(WebCore::Position::computeNodeBeforePosition): nullptr
(WebCore::Position::computeNodeAfterPosition): nullptr
(WebCore::Position::anchorTypeForLegacyEditingPosition): reference
(WebCore::Position::previous): reference
(WebCore::Position::next): reference
(WebCore::Position::parentEditingBoundary): nullptr
(WebCore::Position::previousCharacterPosition): { }, pos -&gt; position
(WebCore::Position::nextCharacterPosition): { }, pos -&gt; position
(WebCore::endsOfNodeAreVisuallyDistinctPositions): reference
(WebCore::Position::upstream): { }, pos -&gt; position
(WebCore::Position::downstream): { }, pos -&gt; position
(WebCore::Position::rootUserSelectAllForNode): nullptr
(WebCore::Position::isCandidate): auto, reference, is&lt;&gt;
(WebCore::Position::rendersInDifferentPosition): pos -&gt; position, auto, is&lt;&gt;
(WebCore::Position::leadingWhitespacePosition): { }, is&lt;&gt;
(WebCore::Position::trailingWhitespacePosition): { }
(WebCore::Position::getInlineBoxAndOffset): reference
(WebCore::Position::equals): reference, is&lt;&gt;

* dom/PositionIterator.cpp:
(WebCore::PositionIterator::operator Position): reference
(WebCore::PositionIterator::isCandidate): reference

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): is&lt;&gt;
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange): is&lt;&gt;, reference
(WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun): reference
(WebCore::ApplyStyleCommand::removeInlineStyle): auto, is&lt;&gt;, reference
(WebCore::ApplyStyleCommand::nodeFullySelected): is&lt;&gt;
(WebCore::ApplyStyleCommand::nodeFullyUnselected): is&lt;&gt;
(WebCore::ApplyStyleCommand::splitTextAtStart): is&lt;&gt;
(WebCore::ApplyStyleCommand::splitTextElementAtStart): is&lt;&gt;
(WebCore::ApplyStyleCommand::splitTextElementAtEnd): is&lt;&gt;
(WebCore::ApplyStyleCommand::isValidCaretPositionInTextNode): is&lt;&gt;
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement): Removed unneeded
is&lt;Element&gt; calls before calling areIdenticalElements.
(WebCore::ApplyStyleCommand::positionToComputeInlineStyleChange): Tightened
up logic for the loop to avoid redundant checks.
(WebCore::ApplyStyleCommand::applyInlineStyleChange): auto

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::insertNodeAt): reference
(WebCore::CompositeEditCommand::appendNode): reference
(WebCore::CompositeEditCommand::moveParagraphs): isListHTMLElement

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleGeneralDelete): reference

* editing/FormatBlockCommand.cpp: Fixed order of includes.
(WebCore::enclosingBlockToSplitTreeTo): isListHTMLElement

* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply): reference

* editing/ModifySelectionListLevel.cpp:
(WebCore::getStartEndListChildren): isListHTMLElement
(WebCore::IncreaseSelectionListLevelCommand::doApply):isListHTMLElement
(WebCore::canDecreaseListLevel):isListHTMLElement

* editing/RemoveNodeCommand.cpp: Removed unneeded include.

* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::ReplaceNodeWithSpanCommand::doApply): Use HTMLSpanElement::create.

* editing/ReplaceSelectionCommand.cpp:
(WebCore::isInterchangeNewlineNode): is&lt;&gt;, downcast&lt;&gt;
(WebCore::isInterchangeConvertedSpaceSpan): is&lt;&gt;, downcast&lt;&gt;
(WebCore::positionAvoidingPrecedingNodes): pos -&gt; position, reference
(WebCore::ReplaceSelectionCommand::doApply): isListHTMLElement
(WebCore::ReplaceSelectionCommand::insertAsListItems): isListHTMLElement

* editing/SpellChecker.cpp: Removed unneeded include.

* editing/TextIterator.cpp:
(WebCore::SimplifiedBackwardsTextIterator::advance): reference

* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::selectionFromContentsOfNode): reference

* editing/VisibleUnits.cpp:
(WebCore::previousLinePosition): reference
(WebCore::nextLinePosition): reference
(WebCore::findStartOfParagraph): reference
(WebCore::findEndOfParagraph): reference

* editing/htmlediting.cpp:
(WebCore::canHaveChildrenForEditing): Moved here from header file so we don't
have to include &quot;Text.h&quot;. Not critical to inline this.
(WebCore::isAtomicNode): reference
(WebCore::lastOffsetForEditing): reference
(WebCore::stringWithRebalancedWhitespace): Changed to use StringBuilder instead
of Vector&lt;UChar&gt; so this won't turn 8-bit strings into 16-bit strings. Changed
to not use the StringBuilder at all until we encounter a character that needs
to be changed.
(WebCore::isSpecialHTMLElement): Renamed to make it clear that it only can return
true for a Node that is an HTMLElement.
(WebCore::firstInSpecialElement): isSpecialHTMLElement
(WebCore::lastInSpecialElement): isSpecialHTMLElement
(WebCore::isListHTMLElement): Renamed to make it clear that it can only return
true for a Node that is an HTMLElement.
(WebCore::isListItem): isListHTMLElement, is&lt;&gt;
(WebCore::enclosingNodeOfType): p -&gt; position, nullptr
(WebCore::highestEnclosingNodeOfType): p -&gt; position
(WebCore::enclosingListChild): isListHTMLElement, is&lt;&gt;
(WebCore::embeddedSublist): isListHTMLElement
(WebCore::appendedSublist):isListHTMLElement
(WebCore::caretMaxOffset): is&lt;&gt;
(WebCore::caretRendersInsideNode): changed to take a reference
(WebCore::rendererForCaretPainting): reference

* editing/htmlediting.h: Updated for name changes and type changes above.

* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::traverseNodesForSerialization): reference
(WebCore::highestAncestorToWrapMarkup): auto, reference, isListHTMLElement

* html/HTMLSpanElement.cpp:
(WebCore::HTMLSpanElement::create): Added overload that does not require a tag name.
* html/HTMLSpanElement.h: Ditto.

* page/DOMSelection.cpp: Removed unneeded includes.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::localCaretRect): reference

Source/WebKit/ios:

* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame previousUnperturbedDictationResultBoundaryFromPosition:]): auto
(-[WebFrame nextUnperturbedDictationResultBoundaryFromPosition:]): auto</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomPositioncpp">trunk/Source/WebCore/dom/Position.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPositionIteratorcpp">trunk/Source/WebCore/dom/PositionIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingApplyStyleCommandcpp">trunk/Source/WebCore/editing/ApplyStyleCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingApplyStyleCommandh">trunk/Source/WebCore/editing/ApplyStyleCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingCompositeEditCommandcpp">trunk/Source/WebCore/editing/CompositeEditCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingDeleteSelectionCommandcpp">trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingFormatBlockCommandcpp">trunk/Source/WebCore/editing/FormatBlockCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingInsertParagraphSeparatorCommandcpp">trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingModifySelectionListLevelcpp">trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingRemoveNodeCommandcpp">trunk/Source/WebCore/editing/RemoveNodeCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingReplaceNodeWithSpanCommandcpp">trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingReplaceSelectionCommandcpp">trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingSpellCheckercpp">trunk/Source/WebCore/editing/SpellChecker.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextIteratorcpp">trunk/Source/WebCore/editing/TextIterator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleSelectioncpp">trunk/Source/WebCore/editing/VisibleSelection.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="#trunkSourceWebCoreeditinghtmleditingh">trunk/Source/WebCore/editing/htmlediting.h</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSpanElementcpp">trunk/Source/WebCore/html/HTMLSpanElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSpanElementh">trunk/Source/WebCore/html/HTMLSpanElement.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMSelectioncpp">trunk/Source/WebCore/page/DOMSelection.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxcpp">trunk/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#trunkSourceWebKitiosChangeLog">trunk/Source/WebKit/ios/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitiosWebCoreSupportWebFrameIOSmm">trunk/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/ChangeLog        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -1,3 +1,154 @@
</span><ins>+2016-05-15  Darin Adler  &lt;darin@apple.com&gt;
+
+        More CTTE and other cleanups for HTML editing header
+        https://bugs.webkit.org/show_bug.cgi?id=157722
+
+        Reviewed by Chris Dumez.
+
+        These changes are mostly things Chris asked for in his review of my last patch
+        or other related style and small efficiency improvements.
+
+        - using nullptr instead of 0
+        - using is&lt;Text&gt; instead of isTextNode and is&lt;&gt; instead of hasTagName
+        - changing argument type of functions like editingIgnoresContent to a reference
+        - using { } instead of constructor calls for classes like Position
+        - using words like position intead of abbreviations like pos
+        - using auto rather than explicit types
+        - rename functions that return true for HTMLElement to express that in the function names
+
+        * dom/Position.cpp:
+        (WebCore::nextRenderedEditable): nullptr
+        (WebCore::previousRenderedEditable): nullptr
+        (WebCore::Position::Position): is&lt;&gt;, reference
+        (WebCore::Position::moveToPosition): reference
+        (WebCore::Position::offsetForPositionAfterAnchor): Added a null assertion and
+        null check that replaces the one that used to be in lastOffsetForEditing.
+        (WebCore::Position::parentAnchoredEquivalent): { }, reference
+        (WebCore::Position::computeNodeBeforePosition): nullptr
+        (WebCore::Position::computeNodeAfterPosition): nullptr
+        (WebCore::Position::anchorTypeForLegacyEditingPosition): reference
+        (WebCore::Position::previous): reference
+        (WebCore::Position::next): reference
+        (WebCore::Position::parentEditingBoundary): nullptr
+        (WebCore::Position::previousCharacterPosition): { }, pos -&gt; position
+        (WebCore::Position::nextCharacterPosition): { }, pos -&gt; position
+        (WebCore::endsOfNodeAreVisuallyDistinctPositions): reference
+        (WebCore::Position::upstream): { }, pos -&gt; position
+        (WebCore::Position::downstream): { }, pos -&gt; position
+        (WebCore::Position::rootUserSelectAllForNode): nullptr
+        (WebCore::Position::isCandidate): auto, reference, is&lt;&gt;
+        (WebCore::Position::rendersInDifferentPosition): pos -&gt; position, auto, is&lt;&gt;
+        (WebCore::Position::leadingWhitespacePosition): { }, is&lt;&gt;
+        (WebCore::Position::trailingWhitespacePosition): { }
+        (WebCore::Position::getInlineBoxAndOffset): reference
+        (WebCore::Position::equals): reference, is&lt;&gt;
+
+        * dom/PositionIterator.cpp:
+        (WebCore::PositionIterator::operator Position): reference
+        (WebCore::PositionIterator::isCandidate): reference
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange): is&lt;&gt;, reference
+        (WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun): reference
+        (WebCore::ApplyStyleCommand::removeInlineStyle): auto, is&lt;&gt;, reference
+        (WebCore::ApplyStyleCommand::nodeFullySelected): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::nodeFullyUnselected): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::splitTextAtStart): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::splitTextElementAtStart): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::splitTextElementAtEnd): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::isValidCaretPositionInTextNode): is&lt;&gt;
+        (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement): Removed unneeded
+        is&lt;Element&gt; calls before calling areIdenticalElements.
+        (WebCore::ApplyStyleCommand::positionToComputeInlineStyleChange): Tightened
+        up logic for the loop to avoid redundant checks.
+        (WebCore::ApplyStyleCommand::applyInlineStyleChange): auto
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::insertNodeAt): reference
+        (WebCore::CompositeEditCommand::appendNode): reference
+        (WebCore::CompositeEditCommand::moveParagraphs): isListHTMLElement
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::handleGeneralDelete): reference
+
+        * editing/FormatBlockCommand.cpp: Fixed order of includes.
+        (WebCore::enclosingBlockToSplitTreeTo): isListHTMLElement
+
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply): reference
+
+        * editing/ModifySelectionListLevel.cpp:
+        (WebCore::getStartEndListChildren): isListHTMLElement
+        (WebCore::IncreaseSelectionListLevelCommand::doApply):isListHTMLElement
+        (WebCore::canDecreaseListLevel):isListHTMLElement
+
+        * editing/RemoveNodeCommand.cpp: Removed unneeded include.
+
+        * editing/ReplaceNodeWithSpanCommand.cpp:
+        (WebCore::ReplaceNodeWithSpanCommand::doApply): Use HTMLSpanElement::create.
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::isInterchangeNewlineNode): is&lt;&gt;, downcast&lt;&gt;
+        (WebCore::isInterchangeConvertedSpaceSpan): is&lt;&gt;, downcast&lt;&gt;
+        (WebCore::positionAvoidingPrecedingNodes): pos -&gt; position, reference
+        (WebCore::ReplaceSelectionCommand::doApply): isListHTMLElement
+        (WebCore::ReplaceSelectionCommand::insertAsListItems): isListHTMLElement
+
+        * editing/SpellChecker.cpp: Removed unneeded include.
+
+        * editing/TextIterator.cpp:
+        (WebCore::SimplifiedBackwardsTextIterator::advance): reference
+
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::selectionFromContentsOfNode): reference
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::previousLinePosition): reference
+        (WebCore::nextLinePosition): reference
+        (WebCore::findStartOfParagraph): reference
+        (WebCore::findEndOfParagraph): reference
+
+        * editing/htmlediting.cpp:
+        (WebCore::canHaveChildrenForEditing): Moved here from header file so we don't
+        have to include &quot;Text.h&quot;. Not critical to inline this.
+        (WebCore::isAtomicNode): reference
+        (WebCore::lastOffsetForEditing): reference
+        (WebCore::stringWithRebalancedWhitespace): Changed to use StringBuilder instead
+        of Vector&lt;UChar&gt; so this won't turn 8-bit strings into 16-bit strings. Changed
+        to not use the StringBuilder at all until we encounter a character that needs
+        to be changed.
+        (WebCore::isSpecialHTMLElement): Renamed to make it clear that it only can return
+        true for a Node that is an HTMLElement.
+        (WebCore::firstInSpecialElement): isSpecialHTMLElement
+        (WebCore::lastInSpecialElement): isSpecialHTMLElement
+        (WebCore::isListHTMLElement): Renamed to make it clear that it can only return
+        true for a Node that is an HTMLElement.
+        (WebCore::isListItem): isListHTMLElement, is&lt;&gt;
+        (WebCore::enclosingNodeOfType): p -&gt; position, nullptr
+        (WebCore::highestEnclosingNodeOfType): p -&gt; position
+        (WebCore::enclosingListChild): isListHTMLElement, is&lt;&gt;
+        (WebCore::embeddedSublist): isListHTMLElement
+        (WebCore::appendedSublist):isListHTMLElement
+        (WebCore::caretMaxOffset): is&lt;&gt;
+        (WebCore::caretRendersInsideNode): changed to take a reference
+        (WebCore::rendererForCaretPainting): reference
+
+        * editing/htmlediting.h: Updated for name changes and type changes above.
+
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization): reference
+        (WebCore::highestAncestorToWrapMarkup): auto, reference, isListHTMLElement
+
+        * html/HTMLSpanElement.cpp:
+        (WebCore::HTMLSpanElement::create): Added overload that does not require a tag name.
+        * html/HTMLSpanElement.h: Ditto.
+
+        * page/DOMSelection.cpp: Removed unneeded includes.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::localCaretRect): reference
+
</ins><span class="cx"> 2016-05-15  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r200925.
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Position.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Position.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/dom/Position.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> #include &lt;stdio.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/unicode/CharacterNames.h&gt;
</span><ins>+
</ins><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -79,7 +80,7 @@
</span><span class="cx">         if (hasInlineBoxWrapper(*renderer))
</span><span class="cx">             return node;
</span><span class="cx">     }
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static Node* previousRenderedEditable(Node* node)
</span><span class="lines">@@ -91,7 +92,7 @@
</span><span class="cx">         if (hasInlineBoxWrapper(*renderer))
</span><span class="cx">             return node;
</span><span class="cx">     }
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Position::Position(PassRefPtr&lt;Node&gt; anchorNode, LegacyEditingOffset offset)
</span><span class="lines">@@ -114,7 +115,7 @@
</span><span class="cx">     ASSERT(!m_anchorNode || !m_anchorNode-&gt;isPseudoElement());
</span><span class="cx">     ASSERT(anchorType != PositionIsOffsetInAnchor);
</span><span class="cx">     ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIsAfterChildren)
</span><del>-        &amp;&amp; (m_anchorNode-&gt;isTextNode() || editingIgnoresContent(m_anchorNode.get()))));
</del><ins>+        &amp;&amp; (is&lt;Text&gt;(*m_anchorNode) || editingIgnoresContent(*m_anchorNode))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Position::Position(PassRefPtr&lt;Node&gt; anchorNode, int offset, AnchorType anchorType)
</span><span class="lines">@@ -123,7 +124,7 @@
</span><span class="cx">     , m_anchorType(anchorType)
</span><span class="cx">     , m_isLegacyEditingPosition(false)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anchorNode-&gt;isShadowRoot());
</del><ins>+    ASSERT(!m_anchorNode || !editingIgnoresContent(*m_anchorNode) || !m_anchorNode-&gt;isShadowRoot());
</ins><span class="cx">     ASSERT(!m_anchorNode || !m_anchorNode-&gt;isPseudoElement());
</span><span class="cx">     ASSERT(anchorType == PositionIsOffsetInAnchor);
</span><span class="cx"> }
</span><span class="lines">@@ -139,7 +140,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Position::moveToPosition(PassRefPtr&lt;Node&gt; node, int offset)
</span><span class="cx"> {
</span><del>-    ASSERT(!editingIgnoresContent(node.get()));
</del><ins>+    ASSERT(!editingIgnoresContent(*node));
</ins><span class="cx">     ASSERT(anchorType() == PositionIsOffsetInAnchor || m_isLegacyEditingPosition);
</span><span class="cx">     m_anchorNode = node;
</span><span class="cx">     m_offset = offset;
</span><span class="lines">@@ -214,7 +215,8 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsAfterChildren);
</span><span class="cx">     ASSERT(!m_isLegacyEditingPosition);
</span><del>-    return lastOffsetForEditing(*m_anchorNode);
</del><ins>+    ASSERT(m_anchorNode);
+    return m_anchorNode ? lastOffsetForEditing(*m_anchorNode) : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Neighbor-anchored positions are invalid DOM positions, so they need to be
</span><span class="lines">@@ -222,33 +224,33 @@
</span><span class="cx"> Position Position::parentAnchoredEquivalent() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_anchorNode)
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx">     
</span><span class="cx">     // FIXME: This should only be necessary for legacy positions, but is also needed for positions before and after Tables
</span><span class="cx">     if (m_offset &lt;= 0 &amp;&amp; (m_anchorType != PositionIsAfterAnchor &amp;&amp; m_anchorType != PositionIsAfterChildren)) {
</span><del>-        if (findParent(*m_anchorNode) &amp;&amp; (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_anchorNode.get())))
</del><ins>+        if (findParent(*m_anchorNode) &amp;&amp; (editingIgnoresContent(*m_anchorNode) || isRenderedTable(m_anchorNode.get())))
</ins><span class="cx">             return positionInParentBeforeNode(m_anchorNode.get());
</span><span class="cx">         return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_anchorNode-&gt;offsetInCharacters()
</span><span class="cx">         &amp;&amp; (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsAfterChildren || static_cast&lt;unsigned&gt;(m_offset) == m_anchorNode-&gt;countChildNodes())
</span><del>-        &amp;&amp; (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_anchorNode.get()))
</del><ins>+        &amp;&amp; (editingIgnoresContent(*m_anchorNode) || isRenderedTable(m_anchorNode.get()))
</ins><span class="cx">         &amp;&amp; containerNode()) {
</span><span class="cx">         return positionInParentAfterNode(m_anchorNode.get());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return Position(containerNode(), computeOffsetInContainerNode(), PositionIsOffsetInAnchor);
</del><ins>+    return { containerNode(), computeOffsetInContainerNode(), PositionIsOffsetInAnchor };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node* Position::computeNodeBeforePosition() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_anchorNode)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     switch (anchorType()) {
</span><span class="cx">     case PositionIsBeforeChildren:
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     case PositionIsAfterChildren:
</span><span class="cx">         return m_anchorNode-&gt;lastChild();
</span><span class="cx">     case PositionIsOffsetInAnchor:
</span><span class="lines">@@ -259,19 +261,19 @@
</span><span class="cx">         return m_anchorNode.get();
</span><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node* Position::computeNodeAfterPosition() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_anchorNode)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     switch (anchorType()) {
</span><span class="cx">     case PositionIsBeforeChildren:
</span><span class="cx">         return m_anchorNode-&gt;firstChild();
</span><span class="cx">     case PositionIsAfterChildren:
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     case PositionIsOffsetInAnchor:
</span><span class="cx">         return m_anchorNode-&gt;traverseToChildAt(m_offset);
</span><span class="cx">     case PositionIsBeforeAnchor:
</span><span class="lines">@@ -280,12 +282,12 @@
</span><span class="cx">         return m_anchorNode-&gt;nextSibling();
</span><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Position::AnchorType Position::anchorTypeForLegacyEditingPosition(Node* anchorNode, int offset)
</span><span class="cx"> {
</span><del>-    if (anchorNode &amp;&amp; editingIgnoresContent(anchorNode)) {
</del><ins>+    if (anchorNode &amp;&amp; editingIgnoresContent(*anchorNode)) {
</ins><span class="cx">         if (offset == 0)
</span><span class="cx">             return Position::PositionIsBeforeAnchor;
</span><span class="cx">         return Position::PositionIsAfterAnchor;
</span><span class="lines">@@ -343,11 +345,11 @@
</span><span class="cx">     if (!parent)
</span><span class="cx">         return *this;
</span><span class="cx"> 
</span><del>-    if (positionBeforeOrAfterNodeIsCandidate(node))
</del><ins>+    if (positionBeforeOrAfterNodeIsCandidate(*node))
</ins><span class="cx">         return positionBeforeNode(node);
</span><span class="cx"> 
</span><span class="cx">     Node* previousSibling = node-&gt;previousSibling();
</span><del>-    if (previousSibling &amp;&amp; positionBeforeOrAfterNodeIsCandidate(previousSibling))
</del><ins>+    if (previousSibling &amp;&amp; positionBeforeOrAfterNodeIsCandidate(*previousSibling))
</ins><span class="cx">         return positionAfterNode(previousSibling);
</span><span class="cx"> 
</span><span class="cx">     return createLegacyEditingPosition(parent, node-&gt;computeNodeIndex());
</span><span class="lines">@@ -390,11 +392,11 @@
</span><span class="cx">     if (!parent)
</span><span class="cx">         return *this;
</span><span class="cx"> 
</span><del>-    if (isRenderedTable(node) || editingIgnoresContent(node))
</del><ins>+    if (isRenderedTable(node) || editingIgnoresContent(*node))
</ins><span class="cx">         return positionAfterNode(node);
</span><span class="cx"> 
</span><span class="cx">     Node* nextSibling = node-&gt;nextSibling();
</span><del>-    if (nextSibling &amp;&amp; positionBeforeOrAfterNodeIsCandidate(nextSibling))
</del><ins>+    if (nextSibling &amp;&amp; positionBeforeOrAfterNodeIsCandidate(*nextSibling))
</ins><span class="cx">         return positionBeforeNode(nextSibling);
</span><span class="cx"> 
</span><span class="cx">     return createLegacyEditingPosition(parent, node-&gt;computeNodeIndex() + 1);
</span><span class="lines">@@ -468,11 +470,11 @@
</span><span class="cx"> Node* Position::parentEditingBoundary() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_anchorNode)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     Node* documentElement = m_anchorNode-&gt;document().documentElement();
</span><span class="cx">     if (!documentElement)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     Node* boundary = m_anchorNode.get();
</span><span class="cx">     while (boundary != documentElement &amp;&amp; boundary-&gt;nonShadowBoundaryParentNode() &amp;&amp; m_anchorNode-&gt;hasEditableStyle() == boundary-&gt;parentNode()-&gt;hasEditableStyle())
</span><span class="lines">@@ -536,25 +538,25 @@
</span><span class="cx"> Position Position::previousCharacterPosition(EAffinity affinity) const
</span><span class="cx"> {
</span><span class="cx">     if (isNull())
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx"> 
</span><span class="cx">     Node* fromRootEditableElement = deprecatedNode()-&gt;rootEditableElement();
</span><span class="cx"> 
</span><span class="cx">     bool atStartOfLine = isStartOfLine(VisiblePosition(*this, affinity));
</span><span class="cx">     bool rendered = isCandidate();
</span><span class="cx">     
</span><del>-    Position currentPos = *this;
-    while (!currentPos.atStartOfTree()) {
-        currentPos = currentPos.previous();
</del><ins>+    Position currentPosition = *this;
+    while (!currentPosition.atStartOfTree()) {
+        currentPosition = currentPosition.previous();
</ins><span class="cx"> 
</span><del>-        if (currentPos.deprecatedNode()-&gt;rootEditableElement() != fromRootEditableElement)
</del><ins>+        if (currentPosition.deprecatedNode()-&gt;rootEditableElement() != fromRootEditableElement)
</ins><span class="cx">             return *this;
</span><span class="cx"> 
</span><span class="cx">         if (atStartOfLine || !rendered) {
</span><del>-            if (currentPos.isCandidate())
-                return currentPos;
-        } else if (rendersInDifferentPosition(currentPos))
-            return currentPos;
</del><ins>+            if (currentPosition.isCandidate())
+                return currentPosition;
+        } else if (rendersInDifferentPosition(currentPosition))
+            return currentPosition;
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     return *this;
</span><span class="lines">@@ -564,25 +566,25 @@
</span><span class="cx"> Position Position::nextCharacterPosition(EAffinity affinity) const
</span><span class="cx"> {
</span><span class="cx">     if (isNull())
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx"> 
</span><span class="cx">     Node* fromRootEditableElement = deprecatedNode()-&gt;rootEditableElement();
</span><span class="cx"> 
</span><del>-    bool atEndOfLine = isEndOfLine(VisiblePosition(*this, affinity));
</del><ins>+    bool atEndOfLine = isEndOfLine({ *this, affinity });
</ins><span class="cx">     bool rendered = isCandidate();
</span><span class="cx">     
</span><del>-    Position currentPos = *this;
-    while (!currentPos.atEndOfTree()) {
-        currentPos = currentPos.next();
</del><ins>+    Position currentPosition = *this;
+    while (!currentPosition.atEndOfTree()) {
+        currentPosition = currentPosition.next();
</ins><span class="cx"> 
</span><del>-        if (currentPos.deprecatedNode()-&gt;rootEditableElement() != fromRootEditableElement)
</del><ins>+        if (currentPosition.deprecatedNode()-&gt;rootEditableElement() != fromRootEditableElement)
</ins><span class="cx">             return *this;
</span><span class="cx"> 
</span><span class="cx">         if (atEndOfLine || !rendered) {
</span><del>-            if (currentPos.isCandidate())
-                return currentPos;
-        } else if (rendersInDifferentPosition(currentPos))
-            return currentPos;
</del><ins>+            if (currentPosition.isCandidate())
+                return currentPosition;
+        } else if (rendersInDifferentPosition(currentPosition))
+            return currentPosition;
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     return *this;
</span><span class="lines">@@ -605,7 +607,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     
</span><span class="cx">     // There is a VisiblePosition inside an empty inline-block container.
</span><del>-    return node-&gt;renderer()-&gt;isReplaced() &amp;&amp; canHaveChildrenForEditing(node) &amp;&amp; downcast&lt;RenderBox&gt;(*node-&gt;renderer()).height() &amp;&amp; !node-&gt;firstChild();
</del><ins>+    return node-&gt;renderer()-&gt;isReplaced() &amp;&amp; canHaveChildrenForEditing(*node) &amp;&amp; downcast&lt;RenderBox&gt;(*node-&gt;renderer()).height() &amp;&amp; !node-&gt;firstChild();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static Node* enclosingVisualBoundary(Node* node)
</span><span class="lines">@@ -639,60 +641,60 @@
</span><span class="cx"> {
</span><span class="cx">     Node* startNode = deprecatedNode();
</span><span class="cx">     if (!startNode)
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx">     
</span><span class="cx">     // iterate backward from there, looking for a qualified position
</span><span class="cx">     Node* boundary = enclosingVisualBoundary(startNode);
</span><span class="cx">     // FIXME: PositionIterator should respect Before and After positions.
</span><span class="cx">     PositionIterator lastVisible = m_anchorType == PositionIsAfterAnchor ? createLegacyEditingPosition(m_anchorNode.get(), caretMaxOffset(*m_anchorNode)) : *this;
</span><del>-    PositionIterator currentPos = lastVisible;
</del><ins>+    PositionIterator currentPosition = lastVisible;
</ins><span class="cx">     bool startEditable = startNode-&gt;hasEditableStyle();
</span><span class="cx">     Node* lastNode = startNode;
</span><span class="cx">     bool boundaryCrossed = false;
</span><del>-    for (; !currentPos.atStart(); currentPos.decrement()) {
-        Node* currentNode = currentPos.node();
</del><ins>+    for (; !currentPosition.atStart(); currentPosition.decrement()) {
+        auto&amp; currentNode = *currentPosition.node();
</ins><span class="cx">         
</span><span class="cx">         // Don't check for an editability change if we haven't moved to a different node,
</span><span class="cx">         // to avoid the expense of computing hasEditableStyle().
</span><del>-        if (currentNode != lastNode) {
</del><ins>+        if (&amp;currentNode != lastNode) {
</ins><span class="cx">             // Don't change editability.
</span><del>-            bool currentEditable = currentNode-&gt;hasEditableStyle();
</del><ins>+            bool currentEditable = currentNode.hasEditableStyle();
</ins><span class="cx">             if (startEditable != currentEditable) {
</span><span class="cx">                 if (rule == CannotCrossEditingBoundary)
</span><span class="cx">                     break;
</span><span class="cx">                 boundaryCrossed = true;
</span><span class="cx">             }
</span><del>-            lastNode = currentNode;
</del><ins>+            lastNode = &amp;currentNode;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // If we've moved to a position that is visually distinct, return the last saved position. There 
</span><span class="cx">         // is code below that terminates early if we're *about* to move to a visually distinct position.
</span><del>-        if (endsOfNodeAreVisuallyDistinctPositions(currentNode) &amp;&amp; currentNode != boundary)
</del><ins>+        if (endsOfNodeAreVisuallyDistinctPositions(&amp;currentNode) &amp;&amp; &amp;currentNode != boundary)
</ins><span class="cx">             return lastVisible;
</span><span class="cx"> 
</span><span class="cx">         // skip position in unrendered or invisible node
</span><del>-        RenderObject* renderer = currentNode-&gt;renderer();
</del><ins>+        RenderObject* renderer = currentNode.renderer();
</ins><span class="cx">         if (!renderer || renderer-&gt;style().visibility() != VISIBLE)
</span><span class="cx">             continue;
</span><span class="cx">                  
</span><span class="cx">         if (rule == CanCrossEditingBoundary &amp;&amp; boundaryCrossed) {
</span><del>-            lastVisible = currentPos;
</del><ins>+            lastVisible = currentPosition;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         // track last visible streamer position
</span><del>-        if (isStreamer(currentPos))
-            lastVisible = currentPos;
</del><ins>+        if (isStreamer(currentPosition))
+            lastVisible = currentPosition;
</ins><span class="cx">         
</span><span class="cx">         // Don't move past a position that is visually distinct.  We could rely on code above to terminate and 
</span><span class="cx">         // return lastVisible on the next iteration, but we terminate early to avoid doing a computeNodeIndex() call.
</span><del>-        if (endsOfNodeAreVisuallyDistinctPositions(currentNode) &amp;&amp; currentPos.atStartOfNode())
</del><ins>+        if (endsOfNodeAreVisuallyDistinctPositions(&amp;currentNode) &amp;&amp; currentPosition.atStartOfNode())
</ins><span class="cx">             return lastVisible;
</span><span class="cx"> 
</span><span class="cx">         // Return position after tables and nodes which have content that can be ignored.
</span><del>-        if (editingIgnoresContent(currentNode) || isRenderedTable(currentNode)) {
-            if (currentPos.atEndOfNode())
-                return positionAfterNode(currentNode);
</del><ins>+        if (editingIgnoresContent(currentNode) || isRenderedTable(&amp;currentNode)) {
+            if (currentPosition.atEndOfNode())
+                return positionAfterNode(&amp;currentNode);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -703,21 +705,21 @@
</span><span class="cx"> 
</span><span class="cx">             if (!textRenderer.firstTextBox())
</span><span class="cx">                 continue;
</span><del>-            if (currentNode != startNode) {
</del><ins>+            if (&amp;currentNode != startNode) {
</ins><span class="cx">                 // This assertion fires in layout tests in the case-transform.html test because
</span><span class="cx">                 // of a mix-up between offsets in the text in the DOM tree with text in the
</span><span class="cx">                 // render tree which can have a different length due to case transformation.
</span><span class="cx">                 // Until we resolve that, disable this so we can run the layout tests!
</span><span class="cx">                 //ASSERT(currentOffset &gt;= renderer-&gt;caretMaxOffset());
</span><del>-                return createLegacyEditingPosition(currentNode, renderer-&gt;caretMaxOffset());
</del><ins>+                return createLegacyEditingPosition(&amp;currentNode, renderer-&gt;caretMaxOffset());
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            unsigned textOffset = currentPos.offsetInLeafNode();
</del><ins>+            unsigned textOffset = currentPosition.offsetInLeafNode();
</ins><span class="cx">             auto lastTextBox = textRenderer.lastTextBox();
</span><span class="cx">             for (auto* box = textRenderer.firstTextBox(); box; box = box-&gt;nextTextBox()) {
</span><span class="cx">                 if (textOffset &lt;= box-&gt;start() + box-&gt;len()) {
</span><span class="cx">                     if (textOffset &gt; box-&gt;start())
</span><del>-                        return currentPos;
</del><ins>+                        return currentPosition;
</ins><span class="cx">                     continue;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -747,7 +749,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (continuesOnNextLine)
</span><del>-                    return currentPos;
</del><ins>+                    return currentPosition;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -766,65 +768,65 @@
</span><span class="cx"> {
</span><span class="cx">     Node* startNode = deprecatedNode();
</span><span class="cx">     if (!startNode)
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx"> 
</span><span class="cx">     // iterate forward from there, looking for a qualified position
</span><span class="cx">     Node* boundary = enclosingVisualBoundary(startNode);
</span><span class="cx">     // FIXME: PositionIterator should respect Before and After positions.
</span><span class="cx">     PositionIterator lastVisible = m_anchorType == PositionIsAfterAnchor ? createLegacyEditingPosition(m_anchorNode.get(), caretMaxOffset(*m_anchorNode)) : *this;
</span><del>-    PositionIterator currentPos = lastVisible;
</del><ins>+    PositionIterator currentPosition = lastVisible;
</ins><span class="cx">     bool startEditable = startNode-&gt;hasEditableStyle();
</span><span class="cx">     Node* lastNode = startNode;
</span><span class="cx">     bool boundaryCrossed = false;
</span><del>-    for (; !currentPos.atEnd(); currentPos.increment()) {   
-        Node* currentNode = currentPos.node();
</del><ins>+    for (; !currentPosition.atEnd(); currentPosition.increment()) {
+        auto&amp; currentNode = *currentPosition.node();
</ins><span class="cx">         
</span><span class="cx">         // Don't check for an editability change if we haven't moved to a different node,
</span><span class="cx">         // to avoid the expense of computing hasEditableStyle().
</span><del>-        if (currentNode != lastNode) {
</del><ins>+        if (&amp;currentNode != lastNode) {
</ins><span class="cx">             // Don't change editability.
</span><del>-            bool currentEditable = currentNode-&gt;hasEditableStyle();
</del><ins>+            bool currentEditable = currentNode.hasEditableStyle();
</ins><span class="cx">             if (startEditable != currentEditable) {
</span><span class="cx">                 if (rule == CannotCrossEditingBoundary)
</span><span class="cx">                     break;
</span><span class="cx">                 boundaryCrossed = true;
</span><span class="cx">             }
</span><span class="cx">                 
</span><del>-            lastNode = currentNode;
</del><ins>+            lastNode = &amp;currentNode;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // stop before going above the body, up into the head
</span><span class="cx">         // return the last visible streamer position
</span><del>-        if (currentNode-&gt;hasTagName(bodyTag) &amp;&amp; currentPos.atEndOfNode())
</del><ins>+        if (is&lt;HTMLBodyElement&gt;(currentNode) &amp;&amp; currentPosition.atEndOfNode())
</ins><span class="cx">             break;
</span><del>-            
</del><ins>+
</ins><span class="cx">         // Do not move to a visually distinct position.
</span><del>-        if (endsOfNodeAreVisuallyDistinctPositions(currentNode) &amp;&amp; currentNode != boundary)
</del><ins>+        if (endsOfNodeAreVisuallyDistinctPositions(&amp;currentNode) &amp;&amp; &amp;currentNode != boundary)
</ins><span class="cx">             return lastVisible;
</span><span class="cx">         // Do not move past a visually disinct position.
</span><span class="cx">         // Note: The first position after the last in a node whose ends are visually distinct
</span><span class="cx">         // positions will be [boundary-&gt;parentNode(), originalBlock-&gt;computeNodeIndex() + 1].
</span><del>-        if (boundary &amp;&amp; boundary-&gt;parentNode() == currentNode)
</del><ins>+        if (boundary &amp;&amp; boundary-&gt;parentNode() == &amp;currentNode)
</ins><span class="cx">             return lastVisible;
</span><span class="cx"> 
</span><span class="cx">         // skip position in unrendered or invisible node
</span><del>-        RenderObject* renderer = currentNode-&gt;renderer();
</del><ins>+        auto* renderer = currentNode.renderer();
</ins><span class="cx">         if (!renderer || renderer-&gt;style().visibility() != VISIBLE)
</span><span class="cx">             continue;
</span><span class="cx">             
</span><span class="cx">         if (rule == CanCrossEditingBoundary &amp;&amp; boundaryCrossed) {
</span><del>-            lastVisible = currentPos;
</del><ins>+            lastVisible = currentPosition;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         // track last visible streamer position
</span><del>-        if (isStreamer(currentPos))
-            lastVisible = currentPos;
</del><ins>+        if (isStreamer(currentPosition))
+            lastVisible = currentPosition;
</ins><span class="cx"> 
</span><span class="cx">         // Return position before tables and nodes which have content that can be ignored.
</span><del>-        if (editingIgnoresContent(currentNode) || isRenderedTable(currentNode)) {
-            if (currentPos.atStartOfNode())
-                return positionBeforeNode(currentNode);
</del><ins>+        if (editingIgnoresContent(currentNode) || isRenderedTable(&amp;currentNode)) {
+            if (currentPosition.atStartOfNode())
+                return positionBeforeNode(&amp;currentNode);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -835,17 +837,17 @@
</span><span class="cx"> 
</span><span class="cx">             if (!textRenderer.firstTextBox())
</span><span class="cx">                 continue;
</span><del>-            if (currentNode != startNode) {
-                ASSERT(currentPos.atStartOfNode());
-                return createLegacyEditingPosition(currentNode, renderer-&gt;caretMinOffset());
</del><ins>+            if (&amp;currentNode != startNode) {
+                ASSERT(currentPosition.atStartOfNode());
+                return createLegacyEditingPosition(&amp;currentNode, renderer-&gt;caretMinOffset());
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            unsigned textOffset = currentPos.offsetInLeafNode();
</del><ins>+            unsigned textOffset = currentPosition.offsetInLeafNode();
</ins><span class="cx">             auto lastTextBox = textRenderer.lastTextBox();
</span><span class="cx">             for (auto* box = textRenderer.firstTextBox(); box; box = box-&gt;nextTextBox()) {
</span><span class="cx">                 if (textOffset &lt;= box-&gt;end()) {
</span><span class="cx">                     if (textOffset &gt;= box-&gt;start())
</span><del>-                        return currentPos;
</del><ins>+                        return currentPosition;
</ins><span class="cx">                     continue;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -875,7 +877,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if (continuesOnNextLine)
</span><del>-                    return currentPos;
</del><ins>+                    return currentPosition;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -962,7 +964,7 @@
</span><span class="cx"> Node* Position::rootUserSelectAllForNode(Node* node)
</span><span class="cx"> {
</span><span class="cx">     if (!node || !nodeIsUserSelectAll(node))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     Node* parent = node-&gt;parentNode();
</span><span class="cx">     if (!parent)
</span><span class="cx">         return node;
</span><span class="lines">@@ -987,27 +989,28 @@
</span><span class="cx">     if (isNull())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    RenderObject* renderer = deprecatedNode()-&gt;renderer();
</del><ins>+    auto* renderer = deprecatedNode()-&gt;renderer();
</ins><span class="cx">     if (!renderer)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (renderer-&gt;style().visibility() != VISIBLE)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (renderer-&gt;isBR())
</del><ins>+    if (renderer-&gt;isBR()) {
</ins><span class="cx">         // FIXME: The condition should be m_anchorType == PositionIsBeforeAnchor, but for now we still need to support legacy positions.
</span><span class="cx">         return !m_offset &amp;&amp; m_anchorType != PositionIsAfterAnchor &amp;&amp; !nodeIsUserSelectNone(deprecatedNode()-&gt;parentNode());
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     if (is&lt;RenderText&gt;(*renderer))
</span><span class="cx">         return !nodeIsUserSelectNone(deprecatedNode()) &amp;&amp; downcast&lt;RenderText&gt;(*renderer).containsCaretOffset(m_offset);
</span><span class="cx"> 
</span><del>-    if (positionBeforeOrAfterNodeIsCandidate(deprecatedNode())) {
</del><ins>+    if (positionBeforeOrAfterNodeIsCandidate(*deprecatedNode())) {
</ins><span class="cx">         return ((atFirstEditingPositionForNode() &amp;&amp; m_anchorType == PositionIsBeforeAnchor)
</span><span class="cx">             || (atLastEditingPositionForNode() &amp;&amp; m_anchorType == PositionIsAfterAnchor))
</span><span class="cx">             &amp;&amp; !nodeIsUserSelectNone(deprecatedNode()-&gt;parentNode());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_anchorNode-&gt;hasTagName(htmlTag))
</del><ins>+    if (is&lt;HTMLHtmlElement&gt;(*m_anchorNode))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (is&lt;RenderBlockFlow&gt;(*renderer)
</span><span class="lines">@@ -1016,7 +1019,7 @@
</span><span class="cx"> #endif
</span><span class="cx">         || is&lt;RenderFlexibleBox&gt;(*renderer)) {
</span><span class="cx">         RenderBlock&amp; block = downcast&lt;RenderBlock&gt;(*renderer);
</span><del>-        if (block.logicalHeight() || m_anchorNode-&gt;hasTagName(bodyTag)) {
</del><ins>+        if (block.logicalHeight() || is&lt;HTMLBodyElement&gt;(*m_anchorNode)) {
</ins><span class="cx">             if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block))
</span><span class="cx">                 return atFirstEditingPositionForNode() &amp;&amp; !Position::nodeIsUserSelectNone(deprecatedNode());
</span><span class="cx">             return m_anchorNode-&gt;hasEditableStyle() &amp;&amp; !Position::nodeIsUserSelectNone(deprecatedNode()) &amp;&amp; atEditingBoundary();
</span><span class="lines">@@ -1044,69 +1047,68 @@
</span><span class="cx">     return a &amp;&amp; b &amp;&amp; deprecatedEnclosingBlockFlowElement(a) == deprecatedEnclosingBlockFlowElement(b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Position::rendersInDifferentPosition(const Position &amp;pos) const
</del><ins>+bool Position::rendersInDifferentPosition(const Position&amp; position) const
</ins><span class="cx"> {
</span><del>-    if (isNull() || pos.isNull())
</del><ins>+    if (isNull() || position.isNull())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    RenderObject* renderer = deprecatedNode()-&gt;renderer();
</del><ins>+    auto* renderer = deprecatedNode()-&gt;renderer();
</ins><span class="cx">     if (!renderer)
</span><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    RenderObject* posRenderer = pos.deprecatedNode()-&gt;renderer();
-    if (!posRenderer)
</del><ins>+    auto* positionRenderer = position.deprecatedNode()-&gt;renderer();
+    if (!positionRenderer)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (renderer-&gt;style().visibility() != VISIBLE ||
-        posRenderer-&gt;style().visibility() != VISIBLE)
</del><ins>+    if (renderer-&gt;style().visibility() != VISIBLE || positionRenderer-&gt;style().visibility() != VISIBLE)
</ins><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    if (deprecatedNode() == pos.deprecatedNode()) {
-        if (deprecatedNode()-&gt;hasTagName(brTag))
</del><ins>+    if (deprecatedNode() == position.deprecatedNode()) {
+        if (is&lt;HTMLBRElement&gt;(*deprecatedNode()))
</ins><span class="cx">             return false;
</span><span class="cx"> 
</span><del>-        if (m_offset == pos.deprecatedEditingOffset())
</del><ins>+        if (m_offset == position.deprecatedEditingOffset())
</ins><span class="cx">             return false;
</span><del>-            
-        if (!deprecatedNode()-&gt;isTextNode() &amp;&amp; !pos.deprecatedNode()-&gt;isTextNode()) {
-            if (m_offset != pos.deprecatedEditingOffset())
</del><ins>+
+        if (!is&lt;Text&gt;(*deprecatedNode()) &amp;&amp; !is&lt;Text&gt;(*position.deprecatedNode())) {
+            if (m_offset != position.deprecatedEditingOffset())
</ins><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    
-    if (deprecatedNode()-&gt;hasTagName(brTag) &amp;&amp; pos.isCandidate())
</del><ins>+
+    if (is&lt;HTMLBRElement&gt;(*deprecatedNode()) &amp;&amp; position.isCandidate())
</ins><span class="cx">         return true;
</span><del>-                
-    if (pos.deprecatedNode()-&gt;hasTagName(brTag) &amp;&amp; isCandidate())
</del><ins>+
+    if (is&lt;HTMLBRElement&gt;(*position.deprecatedNode()) &amp;&amp; isCandidate())
</ins><span class="cx">         return true;
</span><del>-                
-    if (!inSameEnclosingBlockFlowElement(deprecatedNode(), pos.deprecatedNode()))
</del><ins>+
+    if (!inSameEnclosingBlockFlowElement(deprecatedNode(), position.deprecatedNode()))
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     if (is&lt;RenderText&gt;(*renderer) &amp;&amp; !downcast&lt;RenderText&gt;(*renderer).containsCaretOffset(m_offset))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (is&lt;RenderText&gt;(*posRenderer) &amp;&amp; !downcast&lt;RenderText&gt;(*posRenderer).containsCaretOffset(pos.m_offset))
</del><ins>+    if (is&lt;RenderText&gt;(*positionRenderer) &amp;&amp; !downcast&lt;RenderText&gt;(*positionRenderer).containsCaretOffset(position.m_offset))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     int thisRenderedOffset = is&lt;RenderText&gt;(*renderer) ? downcast&lt;RenderText&gt;(*renderer).countRenderedCharacterOffsetsUntil(m_offset) : m_offset;
</span><del>-    int posRenderedOffset = is&lt;RenderText&gt;(*posRenderer) ? downcast&lt;RenderText&gt;(*posRenderer).countRenderedCharacterOffsetsUntil(pos.m_offset) : pos.m_offset;
</del><ins>+    int positionRenderedOffset = is&lt;RenderText&gt;(*positionRenderer) ? downcast&lt;RenderText&gt;(*positionRenderer).countRenderedCharacterOffsetsUntil(position.m_offset) : position.m_offset;
</ins><span class="cx"> 
</span><del>-    if (renderer == posRenderer &amp;&amp; thisRenderedOffset == posRenderedOffset)
</del><ins>+    if (renderer == positionRenderer &amp;&amp; thisRenderedOffset == positionRenderedOffset)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     int ignoredCaretOffset;
</span><span class="cx">     InlineBox* b1;
</span><span class="cx">     getInlineBoxAndOffset(DOWNSTREAM, b1, ignoredCaretOffset);
</span><span class="cx">     InlineBox* b2;
</span><del>-    pos.getInlineBoxAndOffset(DOWNSTREAM, b2, ignoredCaretOffset);
</del><ins>+    position.getInlineBoxAndOffset(DOWNSTREAM, b2, ignoredCaretOffset);
</ins><span class="cx"> 
</span><span class="cx">     LOG(Editing, &quot;renderer:               %p [%p]\n&quot;, renderer, b1);
</span><span class="cx">     LOG(Editing, &quot;thisRenderedOffset:         %d\n&quot;, thisRenderedOffset);
</span><del>-    LOG(Editing, &quot;posRenderer:            %p [%p]\n&quot;, posRenderer, b2);
-    LOG(Editing, &quot;posRenderedOffset:      %d\n&quot;, posRenderedOffset);
</del><ins>+    LOG(Editing, &quot;posRenderer:            %p [%p]\n&quot;, positionRenderer, b2);
+    LOG(Editing, &quot;posRenderedOffset:      %d\n&quot;, positionRenderedOffset);
</ins><span class="cx">     LOG(Editing, &quot;node min/max:           %d:%d\n&quot;, caretMinOffset(*deprecatedNode()), caretMaxOffset(*deprecatedNode()));
</span><del>-    LOG(Editing, &quot;pos node min/max:       %d:%d\n&quot;, caretMinOffset(*pos.deprecatedNode()), caretMaxOffset(*pos.deprecatedNode()));
</del><ins>+    LOG(Editing, &quot;pos node min/max:       %d:%d\n&quot;, caretMinOffset(*position.deprecatedNode()), caretMaxOffset(*position.deprecatedNode()));
</ins><span class="cx">     LOG(Editing, &quot;----------------------------------------------------------------------\n&quot;);
</span><span class="cx"> 
</span><span class="cx">     if (!b1 || !b2) {
</span><span class="lines">@@ -1117,13 +1119,13 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (nextRenderedEditable(deprecatedNode()) == pos.deprecatedNode()
-        &amp;&amp; thisRenderedOffset == caretMaxOffset(*deprecatedNode()) &amp;&amp; !posRenderedOffset) {
</del><ins>+    if (nextRenderedEditable(deprecatedNode()) == position.deprecatedNode()
+        &amp;&amp; thisRenderedOffset == caretMaxOffset(*deprecatedNode()) &amp;&amp; !positionRenderedOffset) {
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (previousRenderedEditable(deprecatedNode()) == pos.deprecatedNode()
-        &amp;&amp; !thisRenderedOffset &amp;&amp; posRenderedOffset == caretMaxOffset(*pos.deprecatedNode())) {
</del><ins>+    if (previousRenderedEditable(deprecatedNode()) == position.deprecatedNode()
+        &amp;&amp; !thisRenderedOffset &amp;&amp; positionRenderedOffset == caretMaxOffset(*position.deprecatedNode())) {
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1135,10 +1137,10 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isEditablePosition(*this));
</span><span class="cx">     if (isNull())
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx">     
</span><del>-    if (upstream().deprecatedNode()-&gt;hasTagName(brTag))
-        return Position();
</del><ins>+    if (is&lt;HTMLBRElement&gt;(*upstream().deprecatedNode()))
+        return { };
</ins><span class="cx"> 
</span><span class="cx">     Position prev = previousCharacterPosition(affinity);
</span><span class="cx">     if (prev != *this &amp;&amp; inSameEnclosingBlockFlowElement(deprecatedNode(), prev.deprecatedNode()) &amp;&amp; is&lt;Text&gt;(*prev.deprecatedNode())) {
</span><span class="lines">@@ -1149,7 +1151,7 @@
</span><span class="cx">                 return prev;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return Position();
</del><ins>+    return { };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // This assumes that it starts in editable content.
</span><span class="lines">@@ -1157,7 +1159,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isEditablePosition(*this));
</span><span class="cx">     if (isNull())
</span><del>-        return Position();
</del><ins>+        return { };
</ins><span class="cx">     
</span><span class="cx">     VisiblePosition v(*this);
</span><span class="cx">     UChar c = v.characterAfter();
</span><span class="lines">@@ -1166,7 +1168,7 @@
</span><span class="cx">         if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : deprecatedIsCollapsibleWhitespace(c))
</span><span class="cx">             return *this;
</span><span class="cx">     
</span><del>-    return Position();
</del><ins>+    return { };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Position::getInlineBoxAndOffset(EAffinity affinity, InlineBox*&amp; inlineBox, int&amp; caretOffset) const
</span><span class="lines">@@ -1270,7 +1272,7 @@
</span><span class="cx">         inlineBox = box ? box : candidate;
</span><span class="cx">     } else {
</span><span class="cx">         inlineBox = nullptr;
</span><del>-        if (canHaveChildrenForEditing(deprecatedNode()) &amp;&amp; is&lt;RenderBlockFlow&gt;(*renderer) &amp;&amp; hasRenderedNonAnonymousDescendantsWithHeight(downcast&lt;RenderBlockFlow&gt;(*renderer))) {
</del><ins>+        if (canHaveChildrenForEditing(*deprecatedNode()) &amp;&amp; is&lt;RenderBlockFlow&gt;(*renderer) &amp;&amp; hasRenderedNonAnonymousDescendantsWithHeight(downcast&lt;RenderBlockFlow&gt;(*renderer))) {
</ins><span class="cx">             // Try a visually equivalent position with possibly opposite editability. This helps in case |this| is in
</span><span class="cx">             // an editable block but surrounded by non-editable positions. It acts to negate the logic at the beginning
</span><span class="cx">             // of RenderObject::createVisiblePosition().
</span><span class="lines">@@ -1463,13 +1465,13 @@
</span><span class="cx"> 
</span><span class="cx">     switch (anchorType()) {
</span><span class="cx">     case PositionIsBeforeChildren:
</span><del>-        ASSERT(!m_anchorNode-&gt;isTextNode());
</del><ins>+        ASSERT(!is&lt;Text&gt;(*m_anchorNode));
</ins><span class="cx">         switch (other.anchorType()) {
</span><span class="cx">         case PositionIsBeforeChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode;
</span><span class="cx">         case PositionIsAfterChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; !m_anchorNode-&gt;hasChildNodes();
</span><span class="cx">         case PositionIsOffsetInAnchor:
</span><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; !other.m_offset;
</span><span class="lines">@@ -1480,13 +1482,13 @@
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case PositionIsAfterChildren:
</span><del>-        ASSERT(!m_anchorNode-&gt;isTextNode());
</del><ins>+        ASSERT(!is&lt;Text&gt;(*m_anchorNode));
</ins><span class="cx">         switch (other.anchorType()) {
</span><span class="cx">         case PositionIsBeforeChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; !m_anchorNode-&gt;hasChildNodes();
</span><span class="cx">         case PositionIsAfterChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode;
</span><span class="cx">         case PositionIsOffsetInAnchor:
</span><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; m_anchorNode-&gt;countChildNodes() == static_cast&lt;unsigned&gt;(m_offset);
</span><span class="lines">@@ -1499,10 +1501,10 @@
</span><span class="cx">     case PositionIsOffsetInAnchor:
</span><span class="cx">         switch (other.anchorType()) {
</span><span class="cx">         case PositionIsBeforeChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; !m_offset;
</span><span class="cx">         case PositionIsAfterChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; m_offset == static_cast&lt;int&gt;(other.m_anchorNode-&gt;countChildNodes());
</span><span class="cx">         case PositionIsOffsetInAnchor:
</span><span class="cx">             return m_anchorNode == other.m_anchorNode &amp;&amp; m_offset == other.m_offset;
</span><span class="lines">@@ -1515,10 +1517,10 @@
</span><span class="cx">     case PositionIsBeforeAnchor:
</span><span class="cx">         switch (other.anchorType()) {
</span><span class="cx">         case PositionIsBeforeChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode-&gt;firstChild();
</span><span class="cx">         case PositionIsAfterChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return false;
</span><span class="cx">         case PositionIsOffsetInAnchor:
</span><span class="cx">             return m_anchorNode == other.m_anchorNode-&gt;traverseToChildAt(other.m_offset);
</span><span class="lines">@@ -1531,10 +1533,10 @@
</span><span class="cx">     case PositionIsAfterAnchor:
</span><span class="cx">         switch (other.anchorType()) {
</span><span class="cx">         case PositionIsBeforeChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return false;
</span><span class="cx">         case PositionIsAfterChildren:
</span><del>-            ASSERT(!other.m_anchorNode-&gt;isTextNode());
</del><ins>+            ASSERT(!is&lt;Text&gt;(*other.m_anchorNode));
</ins><span class="cx">             return m_anchorNode == other.m_anchorNode-&gt;lastChild();
</span><span class="cx">         case PositionIsOffsetInAnchor:
</span><span class="cx">             return other.m_offset &amp;&amp; m_anchorNode == other.m_anchorNode-&gt;traverseToChildAt(other.m_offset - 1);
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositionIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/PositionIterator.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/PositionIterator.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/dom/PositionIterator.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -43,11 +43,11 @@
</span><span class="cx">     if (m_nodeAfterPositionInAnchor) {
</span><span class="cx">         ASSERT(m_nodeAfterPositionInAnchor-&gt;parentNode() == m_anchorNode);
</span><span class="cx">         // FIXME: This check is inadaquete because any ancestor could be ignored by editing
</span><del>-        if (positionBeforeOrAfterNodeIsCandidate(m_anchorNode))
</del><ins>+        if (positionBeforeOrAfterNodeIsCandidate(*m_anchorNode))
</ins><span class="cx">             return positionBeforeNode(m_anchorNode);
</span><span class="cx">         return positionInParentBeforeNode(m_nodeAfterPositionInAnchor);
</span><span class="cx">     }
</span><del>-    if (positionBeforeOrAfterNodeIsCandidate(m_anchorNode))
</del><ins>+    if (positionBeforeOrAfterNodeIsCandidate(*m_anchorNode))
</ins><span class="cx">         return atStartOfNode() ? positionBeforeNode(m_anchorNode) : positionAfterNode(m_anchorNode);
</span><span class="cx">     if (m_anchorNode-&gt;hasChildNodes())
</span><span class="cx">         return lastPositionInOrAfterNode(m_anchorNode);
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx">     if (is&lt;RenderText&gt;(*renderer))
</span><span class="cx">         return !Position::nodeIsUserSelectNone(m_anchorNode) &amp;&amp; downcast&lt;RenderText&gt;(*renderer).containsCaretOffset(m_offsetInAnchor);
</span><span class="cx"> 
</span><del>-    if (isRenderedTable(m_anchorNode) || editingIgnoresContent(m_anchorNode))
</del><ins>+    if (isRenderedTable(m_anchorNode) || editingIgnoresContent(*m_anchorNode))
</ins><span class="cx">         return (atStartOfNode() || atEndOfNode()) &amp;&amp; !Position::nodeIsUserSelectNone(m_anchorNode-&gt;parentNode());
</span><span class="cx"> 
</span><span class="cx">     if (!is&lt;HTMLHtmlElement&gt;(*m_anchorNode) &amp;&amp; is&lt;RenderBlockFlow&gt;(*renderer)) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingApplyStyleCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ApplyStyleCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -312,7 +312,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Join up any adjacent text nodes.
</span><del>-    if (start.deprecatedNode()-&gt;isTextNode()) {
</del><ins>+    if (is&lt;Text&gt;(*start.deprecatedNode())) {
</ins><span class="cx">         joinChildTextNodes(start.deprecatedNode()-&gt;parentNode(), start, end);
</span><span class="cx">         start = startPosition();
</span><span class="cx">         end = endPosition();
</span><span class="lines">@@ -321,7 +321,7 @@
</span><span class="cx">     if (start.isNull() || end.isNull())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (end.deprecatedNode()-&gt;isTextNode() &amp;&amp; start.deprecatedNode()-&gt;parentNode() != end.deprecatedNode()-&gt;parentNode()) {
</del><ins>+    if (is&lt;Text&gt;(*end.deprecatedNode()) &amp;&amp; start.deprecatedNode()-&gt;parentNode() != end.deprecatedNode()-&gt;parentNode()) {
</ins><span class="cx">         joinChildTextNodes(end.deprecatedNode()-&gt;parentNode(), start, end);
</span><span class="cx">         start = startPosition();
</span><span class="cx">         end = endPosition();
</span><span class="lines">@@ -367,7 +367,7 @@
</span><span class="cx">     if (startNode == beyondEnd)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (startNode-&gt;isTextNode() &amp;&amp; start.deprecatedEditingOffset() &gt;= caretMaxOffset(*startNode)) {
</del><ins>+    if (is&lt;Text&gt;(*startNode) &amp;&amp; start.deprecatedEditingOffset() &gt;= caretMaxOffset(*startNode)) {
</ins><span class="cx">         // Move out of text node if range does not include its characters.
</span><span class="cx">         startNode = NodeTraversal::next(*startNode);
</span><span class="cx">         if (!startNode)
</span><span class="lines">@@ -391,10 +391,10 @@
</span><span class="cx">         RefPtr&lt;HTMLElement&gt; element;
</span><span class="cx">         if (is&lt;HTMLElement&gt;(*node)) {
</span><span class="cx">             // Only work on fully selected nodes.
</span><del>-            if (!nodeFullySelected(node, start, end))
</del><ins>+            if (!nodeFullySelected(downcast&lt;HTMLElement&gt;(*node), start, end))
</ins><span class="cx">                 continue;
</span><del>-            element = downcast&lt;HTMLElement&gt;(node);
-        } else if (node-&gt;isTextNode() &amp;&amp; node-&gt;renderer() &amp;&amp; node-&gt;parentNode() != lastStyledNode) {
</del><ins>+            element = &amp;downcast&lt;HTMLElement&gt;(*node);
+        } else if (is&lt;Text&gt;(*node) &amp;&amp; node-&gt;renderer() &amp;&amp; node-&gt;parentNode() != lastStyledNode) {
</ins><span class="cx">             // Last styled node was not parent node of this text node, but we wish to style this
</span><span class="cx">             // text node. To make this possible, add a style span to surround this text node.
</span><span class="cx">             auto span = createStyleSpanElement(document());
</span><span class="lines">@@ -626,11 +626,11 @@
</span><span class="cx"> 
</span><span class="cx">         // Avoid removing the dir attribute and the unicode-bidi and direction properties from the unsplit ancestors.
</span><span class="cx">         Position embeddingRemoveStart = removeStart;
</span><del>-        if (startUnsplitAncestor &amp;&amp; nodeFullySelected(startUnsplitAncestor, removeStart, end))
</del><ins>+        if (startUnsplitAncestor &amp;&amp; nodeFullySelected(*startUnsplitAncestor, removeStart, end))
</ins><span class="cx">             embeddingRemoveStart = positionInParentAfterNode(startUnsplitAncestor);
</span><span class="cx"> 
</span><span class="cx">         Position embeddingRemoveEnd = end;
</span><del>-        if (endUnsplitAncestor &amp;&amp; nodeFullySelected(endUnsplitAncestor, removeStart, end))
</del><ins>+        if (endUnsplitAncestor &amp;&amp; nodeFullySelected(*endUnsplitAncestor, removeStart, end))
</ins><span class="cx">             embeddingRemoveEnd = positionInParentBeforeNode(endUnsplitAncestor).downstream();
</span><span class="cx"> 
</span><span class="cx">         if (embeddingRemoveEnd != removeStart || embeddingRemoveEnd != end) {
</span><span class="lines">@@ -802,7 +802,7 @@
</span><span class="cx">         if (node-&gt;hasChildNodes()) {
</span><span class="cx">             if (node-&gt;contains(pastEndNode.get()) || containsNonEditableRegion(*node) || !node-&gt;parentNode()-&gt;hasEditableStyle())
</span><span class="cx">                 continue;
</span><del>-            if (editingIgnoresContent(node.get())) {
</del><ins>+            if (editingIgnoresContent(*node)) {
</ins><span class="cx">                 next = NodeTraversal::nextSkippingChildren(*node);
</span><span class="cx">                 continue;
</span><span class="cx">             }
</span><span class="lines">@@ -870,7 +870,7 @@
</span><span class="cx">     ASSERT(runStart &amp;&amp; runEnd);
</span><span class="cx">     RefPtr&lt;Node&gt; next = runStart;
</span><span class="cx">     for (RefPtr&lt;Node&gt; node = next; node &amp;&amp; node-&gt;inDocument() &amp;&amp; node != pastEndNode; node = next) {
</span><del>-        if (editingIgnoresContent(node.get())) {
</del><ins>+        if (editingIgnoresContent(*node)) {
</ins><span class="cx">             ASSERT(!node-&gt;contains(pastEndNode.get()));
</span><span class="cx">             next = NodeTraversal::nextSkippingChildren(*node);
</span><span class="cx">         } else
</span><span class="lines">@@ -1092,7 +1092,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ApplyStyleCommand::removeInlineStyle(EditingStyle* style, const Position &amp;start, const Position &amp;end)
</del><ins>+void ApplyStyleCommand::removeInlineStyle(EditingStyle* style, const Position&amp; start, const Position&amp; end)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(start.isNotNull());
</span><span class="cx">     ASSERT(end.isNotNull());
</span><span class="lines">@@ -1105,15 +1105,14 @@
</span><span class="cx">     // If the pushDownStart is at the end of a text node, then this node is not fully selected.
</span><span class="cx">     // Move it to the next deep quivalent position to avoid removing the style from this node.
</span><span class="cx">     // e.g. if pushDownStart was at Position(&quot;hello&quot;, 5) in &lt;b&gt;hello&lt;div&gt;world&lt;/div&gt;&lt;/b&gt;, we want Position(&quot;world&quot;, 0) instead.
</span><del>-    Node* pushDownStartContainer = pushDownStart.containerNode();
-    if (pushDownStartContainer &amp;&amp; pushDownStartContainer-&gt;isTextNode()
-        &amp;&amp; pushDownStart.computeOffsetInContainerNode() == pushDownStartContainer-&gt;maxCharacterOffset())
</del><ins>+    auto* pushDownStartContainer = pushDownStart.containerNode();
+    if (is&lt;Text&gt;(pushDownStartContainer) &amp;&amp; pushDownStart.computeOffsetInContainerNode() == pushDownStartContainer-&gt;maxCharacterOffset())
</ins><span class="cx">         pushDownStart = nextVisuallyDistinctCandidate(pushDownStart);
</span><span class="cx">     // If pushDownEnd is at the start of a text node, then this node is not fully selected.
</span><span class="cx">     // Move it to the previous deep equivalent position to avoid removing the style from this node.
</span><span class="cx">     Position pushDownEnd = end.upstream();
</span><del>-    Node* pushDownEndContainer = pushDownEnd.containerNode();
-    if (pushDownEndContainer &amp;&amp; pushDownEndContainer-&gt;isTextNode() &amp;&amp; !pushDownEnd.computeOffsetInContainerNode())
</del><ins>+    auto* pushDownEndContainer = pushDownEnd.containerNode();
+    if (is&lt;Text&gt;(pushDownEndContainer) &amp;&amp; !pushDownEnd.computeOffsetInContainerNode())
</ins><span class="cx">         pushDownEnd = previousVisuallyDistinctCandidate(pushDownEnd);
</span><span class="cx"> 
</span><span class="cx">     pushDownInlineStyleAroundNode(style, pushDownStart.deprecatedNode());
</span><span class="lines">@@ -1130,32 +1129,32 @@
</span><span class="cx">     RefPtr&lt;Node&gt; node = start.deprecatedNode();
</span><span class="cx">     while (node) {
</span><span class="cx">         RefPtr&lt;Node&gt; next;
</span><del>-        if (editingIgnoresContent(node.get())) {
</del><ins>+        if (editingIgnoresContent(*node)) {
</ins><span class="cx">             ASSERT(node == end.deprecatedNode() || !node-&gt;contains(end.deprecatedNode()));
</span><span class="cx">             next = NodeTraversal::nextSkippingChildren(*node);
</span><span class="cx">         } else
</span><span class="cx">             next = NodeTraversal::next(*node);
</span><span class="cx"> 
</span><del>-        if (is&lt;HTMLElement&gt;(*node) &amp;&amp; nodeFullySelected(node.get(), start, end)) {
-            Ref&lt;HTMLElement&gt; elem = downcast&lt;HTMLElement&gt;(*node);
-            RefPtr&lt;Node&gt; prev = NodeTraversal::previousPostOrder(elem);
-            RefPtr&lt;Node&gt; next = NodeTraversal::next(elem);
</del><ins>+        if (is&lt;HTMLElement&gt;(*node) &amp;&amp; nodeFullySelected(downcast&lt;HTMLElement&gt;(*node), start, end)) {
+            Ref&lt;HTMLElement&gt; element = downcast&lt;HTMLElement&gt;(*node);
+            RefPtr&lt;Node&gt; prev = NodeTraversal::previousPostOrder(element);
+            RefPtr&lt;Node&gt; next = NodeTraversal::next(element);
</ins><span class="cx">             RefPtr&lt;EditingStyle&gt; styleToPushDown;
</span><span class="cx">             RefPtr&lt;Node&gt; childNode;
</span><del>-            if (isStyledInlineElementToRemove(elem.ptr())) {
</del><ins>+            if (isStyledInlineElementToRemove(element.ptr())) {
</ins><span class="cx">                 styleToPushDown = EditingStyle::create();
</span><del>-                childNode = elem-&gt;firstChild();
</del><ins>+                childNode = element-&gt;firstChild();
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            removeInlineStyleFromElement(style, elem.ptr(), RemoveIfNeeded, styleToPushDown.get());
-            if (!elem-&gt;inDocument()) {
-                if (s.deprecatedNode() == elem.ptr()) {
</del><ins>+            removeInlineStyleFromElement(style, element.ptr(), RemoveIfNeeded, styleToPushDown.get());
+            if (!element-&gt;inDocument()) {
+                if (s.deprecatedNode() == element.ptr()) {
</ins><span class="cx">                     // Since elem must have been fully selected, and it is at the start
</span><span class="cx">                     // of the selection, it is clear we can set the new s offset to 0.
</span><span class="cx">                     ASSERT(s.anchorType() == Position::PositionIsBeforeAnchor || s.offsetInContainerNode() &lt;= 0);
</span><span class="cx">                     s = firstPositionInOrBeforeNode(next.get());
</span><span class="cx">                 }
</span><del>-                if (e.deprecatedNode() == elem.ptr()) {
</del><ins>+                if (e.deprecatedNode() == element.ptr()) {
</ins><span class="cx">                     // Since elem must have been fully selected, and it is at the end
</span><span class="cx">                     // of the selection, it is clear we can set the new e offset to
</span><span class="cx">                     // the max range offset of prev.
</span><span class="lines">@@ -1177,32 +1176,27 @@
</span><span class="cx">     updateStartEnd(s, e);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ApplyStyleCommand::nodeFullySelected(Node *node, const Position &amp;start, const Position &amp;end) const
</del><ins>+bool ApplyStyleCommand::nodeFullySelected(Element&amp; element, const Position&amp; start, const Position&amp; end) const
</ins><span class="cx"> {
</span><del>-    ASSERT(node);
-    ASSERT(node-&gt;isElementNode());
-
</del><span class="cx">     // The tree may have changed and Position::upstream() relies on an up-to-date layout.
</span><del>-    node-&gt;document().updateLayoutIgnorePendingStylesheets();
</del><ins>+    element.document().updateLayoutIgnorePendingStylesheets();
</ins><span class="cx"> 
</span><del>-    return comparePositions(firstPositionInOrBeforeNode(node), start) &gt;= 0
-        &amp;&amp; comparePositions(lastPositionInOrAfterNode(node).upstream(), end) &lt;= 0;
</del><ins>+    return comparePositions(firstPositionInOrBeforeNode(&amp;element), start) &gt;= 0
+        &amp;&amp; comparePositions(lastPositionInOrAfterNode(&amp;element).upstream(), end) &lt;= 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ApplyStyleCommand::nodeFullyUnselected(Node *node, const Position &amp;start, const Position &amp;end) const
</del><ins>+bool ApplyStyleCommand::nodeFullyUnselected(Element&amp; element, const Position&amp; start, const Position&amp; end) const
</ins><span class="cx"> {
</span><del>-    ASSERT(node);
-    ASSERT(node-&gt;isElementNode());
</del><ins>+    // The tree may have changed and Position::upstream() relies on an up-to-date layout.
+    element.document().updateLayoutIgnorePendingStylesheets();
</ins><span class="cx"> 
</span><del>-    bool isFullyBeforeStart = comparePositions(lastPositionInOrAfterNode(node).upstream(), start) &lt; 0;
-    bool isFullyAfterEnd = comparePositions(firstPositionInOrBeforeNode(node), end) &gt; 0;
-
-    return isFullyBeforeStart || isFullyAfterEnd;
</del><ins>+    return comparePositions(lastPositionInOrAfterNode(&amp;element).upstream(), start) &lt; 0
+        || comparePositions(firstPositionInOrBeforeNode(&amp;element), end) &gt; 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ApplyStyleCommand::splitTextAtStart(const Position&amp; start, const Position&amp; end)
</span><span class="cx"> {
</span><del>-    ASSERT(start.containerNode()-&gt;isTextNode());
</del><ins>+    ASSERT(is&lt;Text&gt;(start.containerNode()));
</ins><span class="cx"> 
</span><span class="cx">     Position newEnd;
</span><span class="cx">     if (end.anchorType() == Position::PositionIsOffsetInAnchor &amp;&amp; start.containerNode() == end.containerNode())
</span><span class="lines">@@ -1233,7 +1227,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ApplyStyleCommand::splitTextElementAtStart(const Position&amp; start, const Position&amp; end)
</span><span class="cx"> {
</span><del>-    ASSERT(start.containerNode()-&gt;isTextNode());
</del><ins>+    ASSERT(is&lt;Text&gt;(start.containerNode()));
</ins><span class="cx"> 
</span><span class="cx">     Position newEnd;
</span><span class="cx">     if (start.containerNode() == end.containerNode())
</span><span class="lines">@@ -1247,7 +1241,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ApplyStyleCommand::splitTextElementAtEnd(const Position&amp; start, const Position&amp; end)
</span><span class="cx"> {
</span><del>-    ASSERT(end.containerNode()-&gt;isTextNode());
</del><ins>+    ASSERT(is&lt;Text&gt;(end.containerNode()));
</ins><span class="cx"> 
</span><span class="cx">     bool shouldUpdateStart = start.containerNode() == end.containerNode();
</span><span class="cx">     splitTextNodeContainingElement(end.containerText(), end.offsetInContainerNode());
</span><span class="lines">@@ -1268,13 +1262,13 @@
</span><span class="cx">     if (!is&lt;HTMLElement&gt;(element))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    return shouldRemoveInlineStyleFromElement(style, downcast&lt;HTMLElement&gt;(element));
</del><ins>+    return shouldRemoveInlineStyleFromElement(style, &amp;downcast&lt;HTMLElement&gt;(*element));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ApplyStyleCommand::isValidCaretPositionInTextNode(const Position&amp; position)
</span><span class="cx"> {
</span><span class="cx">     Node* node = position.containerNode();
</span><del>-    if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node-&gt;isTextNode())
</del><ins>+    if (position.anchorType() != Position::PositionIsOffsetInAnchor || !is&lt;Text&gt;(node))
</ins><span class="cx">         return false;
</span><span class="cx">     int offsetInText = position.offsetInContainerNode();
</span><span class="cx">     return offsetInText &gt; caretMinOffset(*node) &amp;&amp; offsetInText &lt; caretMaxOffset(*node);
</span><span class="lines">@@ -1369,13 +1363,14 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Node&gt; nextSibling = element-&gt;nextSibling();
</span><span class="cx">     RefPtr&lt;Node&gt; previousSibling = element-&gt;previousSibling();
</span><del>-    if (is&lt;Element&gt;(nextSibling.get()) &amp;&amp; nextSibling-&gt;hasEditableStyle() &amp;&amp; areIdenticalElements(*element, *nextSibling))
</del><ins>+
+    if (nextSibling &amp;&amp; nextSibling-&gt;hasEditableStyle() &amp;&amp; areIdenticalElements(*element, *nextSibling))
</ins><span class="cx">         mergeIdenticalElements(element.get(), downcast&lt;Element&gt;(nextSibling.get()));
</span><span class="cx"> 
</span><span class="cx">     if (is&lt;Element&gt;(previousSibling.get()) &amp;&amp; previousSibling-&gt;hasEditableStyle()) {
</span><del>-        Node* mergedElement = previousSibling-&gt;nextSibling();
</del><ins>+        auto* mergedElement = previousSibling-&gt;nextSibling();
</ins><span class="cx">         ASSERT(mergedElement);
</span><del>-        if (is&lt;Element&gt;(*mergedElement) &amp;&amp; mergedElement-&gt;hasEditableStyle() &amp;&amp; areIdenticalElements(*previousSibling, *mergedElement))
</del><ins>+        if (mergedElement-&gt;hasEditableStyle() &amp;&amp; areIdenticalElements(*previousSibling, *mergedElement))
</ins><span class="cx">             mergeIdenticalElements(downcast&lt;Element&gt;(previousSibling.get()), downcast&lt;Element&gt;(mergedElement));
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1421,7 +1416,7 @@
</span><span class="cx"> Position ApplyStyleCommand::positionToComputeInlineStyleChange(PassRefPtr&lt;Node&gt; startNode, RefPtr&lt;Node&gt;&amp; dummyElement)
</span><span class="cx"> {
</span><span class="cx">     // It's okay to obtain the style at the startNode because we've removed all relevant styles from the current run.
</span><del>-    if (!startNode-&gt;isElementNode()) {
</del><ins>+    if (!is&lt;Element&gt;(*startNode)) {
</ins><span class="cx">         dummyElement = createStyleSpanElement(document());
</span><span class="cx">         insertNodeAt(dummyElement, positionBeforeNode(startNode.get()));
</span><span class="cx">         return firstPositionInOrBeforeNode(dummyElement.get());
</span><span class="lines">@@ -1440,16 +1435,19 @@
</span><span class="cx">     // Find appropriate font and span elements top-down.
</span><span class="cx">     HTMLFontElement* fontContainer = nullptr;
</span><span class="cx">     HTMLElement* styleContainer = nullptr;
</span><del>-    for (Node* container = startNode.get(); container &amp;&amp; startNode == endNode; container = container-&gt;firstChild()) {
-        if (is&lt;HTMLFontElement&gt;(*container))
-            fontContainer = downcast&lt;HTMLFontElement&gt;(container);
-        bool styleContainerIsNotSpan = !is&lt;HTMLSpanElement&gt;(styleContainer);
-        if (is&lt;HTMLElement&gt;(*container) &amp;&amp; (is&lt;HTMLSpanElement&gt;(*container) || (styleContainerIsNotSpan &amp;&amp; container-&gt;hasChildNodes())))
-            styleContainer = downcast&lt;HTMLElement&gt;(container);
-        if (!container-&gt;firstChild())
</del><ins>+    while (startNode &amp;&amp; startNode == endNode) {
+        if (is&lt;HTMLElement&gt;(*startNode)) {
+            auto&amp; container = downcast&lt;HTMLElement&gt;(*startNode);
+            if (is&lt;HTMLFontElement&gt;(container))
+                fontContainer = &amp;downcast&lt;HTMLFontElement&gt;(container);
+            if (is&lt;HTMLSpanElement&gt;(container) || (!is&lt;HTMLSpanElement&gt;(styleContainer) &amp;&amp; container.hasChildNodes()))
+                styleContainer = &amp;container;
+        }
+        auto* startNodeFirstChild = startNode-&gt;firstChild();
+        if (!startNodeFirstChild)
</ins><span class="cx">             break;
</span><del>-        startNode = container-&gt;firstChild();
-        endNode = container-&gt;lastChild();
</del><ins>+        endNode = startNode-&gt;lastChild();
+        startNode = startNodeFirstChild;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Font tags need to go outside of CSS so that CSS font sizes override leagcy font sizes.
</span><span class="lines">@@ -1482,9 +1480,9 @@
</span><span class="cx">             } else
</span><span class="cx">                 setNodeAttribute(styleContainer, styleAttr, styleToMerge-&gt;asText());
</span><span class="cx">         } else {
</span><del>-            RefPtr&lt;Element&gt; styleElement = createStyleSpanElement(document());
</del><ins>+            auto styleElement = createStyleSpanElement(document());
</ins><span class="cx">             styleElement-&gt;setAttribute(styleAttr, styleToMerge-&gt;asText());
</span><del>-            surroundNodeRangeWithElement(startNode, endNode, styleElement.release());
</del><ins>+            surroundNodeRangeWithElement(startNode, endNode, WTFMove(styleElement));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingApplyStyleCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ApplyStyleCommand.h (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ApplyStyleCommand.h        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/ApplyStyleCommand.h        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -86,8 +86,8 @@
</span><span class="cx">     void applyInlineStyleToPushDown(Node*, EditingStyle*);
</span><span class="cx">     void pushDownInlineStyleAroundNode(EditingStyle*, Node*);
</span><span class="cx">     void removeInlineStyle(EditingStyle* , const Position&amp; start, const Position&amp; end);
</span><del>-    bool nodeFullySelected(Node*, const Position&amp; start, const Position&amp; end) const;
-    bool nodeFullyUnselected(Node*, const Position&amp; start, const Position&amp; end) const;
</del><ins>+    bool nodeFullySelected(Element&amp;, const Position&amp; start, const Position&amp; end) const;
+    bool nodeFullyUnselected(Element&amp;, const Position&amp; start, const Position&amp; end) const;
</ins><span class="cx"> 
</span><span class="cx">     // style-application helpers
</span><span class="cx">     void applyBlockStyle(EditingStyle*);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingCompositeEditCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -486,7 +486,7 @@
</span><span class="cx">     Node* refChild = p.deprecatedNode();
</span><span class="cx">     int offset = p.deprecatedEditingOffset();
</span><span class="cx">     
</span><del>-    if (canHaveChildrenForEditing(refChild)) {
</del><ins>+    if (canHaveChildrenForEditing(*refChild)) {
</ins><span class="cx">         Node* child = refChild-&gt;firstChild();
</span><span class="cx">         for (int i = 0; child &amp;&amp; i &lt; offset; i++)
</span><span class="cx">             child = child-&gt;nextSibling();
</span><span class="lines">@@ -509,7 +509,7 @@
</span><span class="cx"> 
</span><span class="cx"> void CompositeEditCommand::appendNode(PassRefPtr&lt;Node&gt; node, PassRefPtr&lt;ContainerNode&gt; parent)
</span><span class="cx"> {
</span><del>-    ASSERT(canHaveChildrenForEditing(parent.get()));
</del><ins>+    ASSERT(canHaveChildrenForEditing(*parent));
</ins><span class="cx">     ASSERT(node);
</span><span class="cx">     applyCommandToComposite(AppendNodeCommand::create(parent, *node, editingAction()));
</span><span class="cx"> }
</span><span class="lines">@@ -1503,9 +1503,9 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Node&gt; previousListNode = emptyListItem-&gt;isElementNode() ? ElementTraversal::previousSibling(*emptyListItem): emptyListItem-&gt;previousSibling();
</span><span class="cx">     RefPtr&lt;Node&gt; nextListNode = emptyListItem-&gt;isElementNode() ? ElementTraversal::nextSibling(*emptyListItem): emptyListItem-&gt;nextSibling();
</span><del>-    if (isListItem(nextListNode.get()) || isListElement(nextListNode.get())) {
</del><ins>+    if (isListItem(nextListNode.get()) || isListHTMLElement(nextListNode.get())) {
</ins><span class="cx">         // If emptyListItem follows another list item or nested list, split the list node.
</span><del>-        if (isListItem(previousListNode.get()) || isListElement(previousListNode.get()))
</del><ins>+        if (isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()))
</ins><span class="cx">             splitElement(downcast&lt;Element&gt;(listNode.get()), emptyListItem);
</span><span class="cx"> 
</span><span class="cx">         // If emptyListItem is followed by other list item or nested list, then insert newBlock before the list node.
</span><span class="lines">@@ -1517,7 +1517,7 @@
</span><span class="cx">         // When emptyListItem does not follow any list item or nested list, insert newBlock after the enclosing list node.
</span><span class="cx">         // Remove the enclosing node if emptyListItem is the only child; otherwise just remove emptyListItem.
</span><span class="cx">         insertNodeAfter(newBlock, listNode);
</span><del>-        removeNode(isListItem(previousListNode.get()) || isListElement(previousListNode.get()) ? emptyListItem.get() : listNode.get());
</del><ins>+        removeNode(isListItem(previousListNode.get()) || isListHTMLElement(previousListNode.get()) ? emptyListItem.get() : listNode.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     appendBlockPlaceholder(newBlock);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingDeleteSelectionCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -457,7 +457,7 @@
</span><span class="cx">     makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss();
</span><span class="cx"> 
</span><span class="cx">     // Never remove the start block unless it's a table, in which case we won't merge content in.
</span><del>-    if (startNode == m_startBlock &amp;&amp; !startOffset &amp;&amp; canHaveChildrenForEditing(startNode) &amp;&amp; !is&lt;HTMLTableElement&gt;(*startNode)) {
</del><ins>+    if (startNode == m_startBlock &amp;&amp; !startOffset &amp;&amp; canHaveChildrenForEditing(*startNode) &amp;&amp; !is&lt;HTMLTableElement&gt;(*startNode)) {
</ins><span class="cx">         startOffset = 0;
</span><span class="cx">         startNode = NodeTraversal::next(*startNode);
</span><span class="cx">         if (!startNode)
</span><span class="lines">@@ -538,7 +538,7 @@
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         if (m_downstreamEnd.deprecatedNode() != startNode &amp;&amp; !m_upstreamStart.deprecatedNode()-&gt;isDescendantOf(m_downstreamEnd.deprecatedNode()) &amp;&amp; m_downstreamEnd.anchorNode()-&gt;inDocument() &amp;&amp; m_downstreamEnd.deprecatedEditingOffset() &gt;= caretMinOffset(*m_downstreamEnd.deprecatedNode())) {
</span><del>-            if (m_downstreamEnd.atLastEditingPositionForNode() &amp;&amp; !canHaveChildrenForEditing(m_downstreamEnd.deprecatedNode())) {
</del><ins>+            if (m_downstreamEnd.atLastEditingPositionForNode() &amp;&amp; !canHaveChildrenForEditing(*m_downstreamEnd.deprecatedNode())) {
</ins><span class="cx">                 // The node itself is fully selected, not just its contents.  Delete it.
</span><span class="cx">                 removeNode(m_downstreamEnd.deprecatedNode());
</span><span class="cx">             } else {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingFormatBlockCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/FormatBlockCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/FormatBlockCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/FormatBlockCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -24,15 +24,16 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><del>-#include &quot;Element.h&quot;
</del><span class="cx"> #include &quot;FormatBlockCommand.h&quot;
</span><ins>+
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;Element.h&quot;
</ins><span class="cx"> #include &quot;ExceptionCodePlaceholder.h&quot;
</span><del>-#include &quot;htmlediting.h&quot;
</del><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;Range.h&quot;
</span><span class="cx"> #include &quot;VisibleUnits.h&quot;
</span><ins>+#include &quot;htmlediting.h&quot;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -41,6 +42,7 @@
</span><span class="cx"> 
</span><span class="cx"> static Node* enclosingBlockToSplitTreeTo(Node* startNode);
</span><span class="cx"> static bool isElementForFormatBlock(const QualifiedName&amp; tagName);
</span><ins>+
</ins><span class="cx"> static inline bool isElementForFormatBlock(Node* node)
</span><span class="cx"> {
</span><span class="cx">     return is&lt;Element&gt;(*node) &amp;&amp; isElementForFormatBlock(downcast&lt;Element&gt;(*node).tagQName());
</span><span class="lines">@@ -156,7 +158,7 @@
</span><span class="cx">             return n;
</span><span class="cx">         if (isBlock(n))
</span><span class="cx">             lastBlock = n;
</span><del>-        if (isListElement(n))
</del><ins>+        if (isListHTMLElement(n))
</ins><span class="cx">             return n-&gt;parentNode()-&gt;hasEditableStyle() ? n-&gt;parentNode() : n;
</span><span class="cx">     }
</span><span class="cx">     return lastBlock;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingInsertParagraphSeparatorCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -319,7 +319,7 @@
</span><span class="cx"> 
</span><span class="cx">     // If the returned position lies either at the end or at the start of an element that is ignored by editing
</span><span class="cx">     // we should move to its upstream or downstream position.
</span><del>-    if (editingIgnoresContent(insertionPosition.deprecatedNode())) {
</del><ins>+    if (editingIgnoresContent(*insertionPosition.deprecatedNode())) {
</ins><span class="cx">         if (insertionPosition.atLastEditingPositionForNode())
</span><span class="cx">             insertionPosition = insertionPosition.downstream();
</span><span class="cx">         else if (insertionPosition.atFirstEditingPositionForNode())
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingModifySelectionListLevelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/ModifySelectionListLevel.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">     // if the selection ends on a list item with a sublist, include the entire sublist
</span><span class="cx">     if (endListChild-&gt;renderer()-&gt;isListItem()) {
</span><span class="cx">         RenderObject* r = endListChild-&gt;renderer()-&gt;nextSibling();
</span><del>-        if (r &amp;&amp; isListElement(r-&gt;node()))
</del><ins>+        if (r &amp;&amp; isListHTMLElement(r-&gt;node()))
</ins><span class="cx">             endListChild = r-&gt;node();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -177,7 +177,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     Node* previousItem = startListChild-&gt;renderer()-&gt;previousSibling()-&gt;node();
</span><del>-    if (isListElement(previousItem)) {
</del><ins>+    if (isListHTMLElement(previousItem)) {
</ins><span class="cx">         // move nodes up into preceding list
</span><span class="cx">         appendSiblingNodeRange(startListChild, endListChild, downcast&lt;Element&gt;(previousItem));
</span><span class="cx">         m_listElement = previousItem;
</span><span class="lines">@@ -244,11 +244,11 @@
</span><span class="cx"> {
</span><span class="cx">     if (!getStartEndListChildren(selection, start, end))
</span><span class="cx">         return false;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // there must be a destination list to move the items to
</span><del>-    if (!isListElement(start-&gt;parentNode()-&gt;parentNode()))
</del><ins>+    if (!isListHTMLElement(start-&gt;parentNode()-&gt;parentNode()))
</ins><span class="cx">         return false;
</span><del>-        
</del><ins>+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingRemoveNodeCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/RemoveNodeCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/RemoveNodeCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/RemoveNodeCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> #include &quot;RemoveNodeCommand.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ExceptionCodePlaceholder.h&quot;
</span><del>-#include &quot;Node.h&quot;
</del><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="cx"> #include &quot;htmlediting.h&quot;
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingReplaceNodeWithSpanCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -31,16 +31,11 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ReplaceNodeWithSpanCommand.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;HTMLSpanElement.h&quot;
</ins><span class="cx"> #include &quot;htmlediting.h&quot;
</span><del>-#include &quot;HTMLElement.h&quot;
-#include &quot;HTMLNames.h&quot;
</del><span class="cx"> 
</span><del>-#include &lt;wtf/Assertions.h&gt;
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-using namespace HTMLNames;
-
</del><span class="cx"> ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtr&lt;HTMLElement&gt; element)
</span><span class="cx">     : SimpleEditCommand(element-&gt;document())
</span><span class="cx">     , m_elementToReplace(element)
</span><span class="lines">@@ -69,7 +64,7 @@
</span><span class="cx">     if (!m_elementToReplace-&gt;inDocument())
</span><span class="cx">         return;
</span><span class="cx">     if (!m_spanElement)
</span><del>-        m_spanElement = createHTMLElement(m_elementToReplace-&gt;document(), spanTag);
</del><ins>+        m_spanElement = HTMLSpanElement::create(m_elementToReplace-&gt;document());
</ins><span class="cx">     swapInNodePreservingAttributesAndChildren(*m_spanElement, *m_elementToReplace);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingReplaceSelectionCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -101,44 +101,46 @@
</span><span class="cx">     bool m_hasInterchangeNewlineAtEnd;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-static bool isInterchangeNewlineNode(const Node *node)
</del><ins>+static bool isInterchangeNewlineNode(const Node* node)
</ins><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;String&gt; interchangeNewlineClassString(AppleInterchangeNewline);
</span><del>-    return node &amp;&amp; node-&gt;hasTagName(brTag) &amp;&amp; 
-           static_cast&lt;const Element *&gt;(node)-&gt;getAttribute(classAttr) == interchangeNewlineClassString;
</del><ins>+    return is&lt;HTMLBRElement&gt;(node) &amp;&amp; downcast&lt;HTMLBRElement&gt;(*node).fastGetAttribute(classAttr) == interchangeNewlineClassString;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isInterchangeConvertedSpaceSpan(const Node *node)
</del><ins>+static bool isInterchangeConvertedSpaceSpan(const Node* node)
</ins><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;String&gt; convertedSpaceSpanClassString(AppleConvertedSpace);
</span><del>-    return node-&gt;isHTMLElement() &amp;&amp; 
-           static_cast&lt;const HTMLElement *&gt;(node)-&gt;getAttribute(classAttr) == convertedSpaceSpanClassString;
</del><ins>+    return is&lt;HTMLElement&gt;(node) &amp;&amp; downcast&lt;HTMLElement&gt;(*node).fastGetAttribute(classAttr) == convertedSpaceSpanClassString;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Position positionAvoidingPrecedingNodes(Position pos)
</del><ins>+static Position positionAvoidingPrecedingNodes(Position position)
</ins><span class="cx"> {
</span><ins>+    ASSERT(position.isNotNull());
+
</ins><span class="cx">     // If we're already on a break, it's probably a placeholder and we shouldn't change our position.
</span><del>-    if (editingIgnoresContent(pos.deprecatedNode()))
-        return pos;
</del><ins>+    if (editingIgnoresContent(*position.deprecatedNode()))
+        return position;
</ins><span class="cx"> 
</span><span class="cx">     // We also stop when changing block flow elements because even though the visual position is the
</span><span class="cx">     // same.  E.g.,
</span><span class="cx">     //   &lt;div&gt;foo^&lt;/div&gt;^
</span><span class="cx">     // The two positions above are the same visual position, but we want to stay in the same block.
</span><del>-    Node* enclosingBlockNode = enclosingBlock(pos.containerNode());
-    for (Position nextPosition = pos; nextPosition.containerNode() != enclosingBlockNode; pos = nextPosition) {
-        if (lineBreakExistsAtPosition(pos))
</del><ins>+    auto* enclosingBlockNode = enclosingBlock(position.containerNode());
+    for (Position nextPosition = position; nextPosition.containerNode() != enclosingBlockNode; position = nextPosition) {
+        if (lineBreakExistsAtPosition(position))
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        if (pos.containerNode()-&gt;nonShadowBoundaryParentNode())
-            nextPosition = positionInParentAfterNode(pos.containerNode());
-        
-        if (nextPosition == pos 
-            || enclosingBlock(nextPosition.containerNode()) != enclosingBlockNode
-            || VisiblePosition(pos) != VisiblePosition(nextPosition))
</del><ins>+        if (position.containerNode()-&gt;nonShadowBoundaryParentNode())
+            nextPosition = positionInParentAfterNode(position.containerNode());
+
+        if (nextPosition == position)
</ins><span class="cx">             break;
</span><ins>+        if (enclosingBlock(nextPosition.containerNode()) != enclosingBlockNode)
+            break;
+        if (VisiblePosition(position) != VisiblePosition(nextPosition))
+            break;
</ins><span class="cx">     }
</span><del>-    return pos;
</del><ins>+    return position;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ReplacementFragment::ReplacementFragment(Document&amp; document, DocumentFragment* fragment, const VisibleSelection&amp; selection)
</span><span class="lines">@@ -1101,7 +1103,7 @@
</span><span class="cx">     fragment.removeNode(refNode);
</span><span class="cx"> 
</span><span class="cx">     Node* blockStart = enclosingBlock(insertionPos.deprecatedNode());
</span><del>-    if ((isListElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get()) &amp;&amp; isListElement(refNode-&gt;firstChild())))
</del><ins>+    if ((isListHTMLElement(refNode.get()) || (isLegacyAppleStyleSpan(refNode.get()) &amp;&amp; isListHTMLElement(refNode-&gt;firstChild())))
</ins><span class="cx">         &amp;&amp; blockStart &amp;&amp; blockStart-&gt;renderer()-&gt;isListItem())
</span><span class="cx">         refNode = insertAsListItems(downcast&lt;HTMLElement&gt;(refNode.get()), blockStart, insertionPos, insertedNodes);
</span><span class="cx">     else {
</span><span class="lines">@@ -1439,7 +1441,7 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;HTMLElement&gt; listElement = prpListElement;
</span><span class="cx"> 
</span><del>-    while (listElement-&gt;hasOneChild() &amp;&amp; isListElement(listElement-&gt;firstChild()))
</del><ins>+    while (listElement-&gt;hasOneChild() &amp;&amp; isListHTMLElement(listElement-&gt;firstChild()))
</ins><span class="cx">         listElement = downcast&lt;HTMLElement&gt;(listElement-&gt;firstChild());
</span><span class="cx"> 
</span><span class="cx">     bool isStart = isStartOfParagraph(insertPos);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSpellCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SpellChecker.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SpellChecker.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/SpellChecker.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;HTMLInputElement.h&quot;
</span><span class="cx"> #include &quot;HTMLTextAreaElement.h&quot;
</span><del>-#include &quot;Node.h&quot;
</del><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PositionIterator.h&quot;
</span><span class="cx"> #include &quot;RenderObject.h&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextIterator.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextIterator.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/TextIterator.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -1261,10 +1261,7 @@
</span><span class="cx">         } else {
</span><span class="cx">             // Exit empty containers as we pass over them or containers
</span><span class="cx">             // where [container, 0] is where we started iterating.
</span><del>-            if (!m_handledNode
-                    &amp;&amp; canHaveChildrenForEditing(m_node)
-                    &amp;&amp; m_node-&gt;parentNode()
-                    &amp;&amp; (!m_node-&gt;lastChild() || (m_node == m_endContainer &amp;&amp; !m_endOffset))) {
</del><ins>+            if (!m_handledNode &amp;&amp; canHaveChildrenForEditing(*m_node)  &amp;&amp; m_node-&gt;parentNode() &amp;&amp; (!m_node-&gt;lastChild() || (m_node == m_endContainer &amp;&amp; !m_endOffset))) {
</ins><span class="cx">                 exitNode();
</span><span class="cx">                 if (m_positionNode) {
</span><span class="cx">                     m_handledNode = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleSelection.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx"> 
</span><span class="cx"> VisibleSelection VisibleSelection::selectionFromContentsOfNode(Node* node)
</span><span class="cx"> {
</span><del>-    ASSERT(!editingIgnoresContent(node));
</del><ins>+    ASSERT(!editingIgnoresContent(*node));
</ins><span class="cx">     return VisibleSelection(firstPositionInNode(node), lastPositionInNode(node), DOWNSTREAM);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -1028,7 +1028,7 @@
</span><span class="cx">         IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
</span><span class="cx">         RenderObject&amp; renderer = root-&gt;closestLeafChildForPoint(pointInLine, isEditablePosition(p))-&gt;renderer();
</span><span class="cx">         Node* node = renderer.node();
</span><del>-        if (node &amp;&amp; editingIgnoresContent(node))
</del><ins>+        if (node &amp;&amp; editingIgnoresContent(*node))
</ins><span class="cx">             return positionInParentBeforeNode(node);
</span><span class="cx">         return renderer.positionForPoint(pointInLine, nullptr);
</span><span class="cx">     }
</span><span class="lines">@@ -1086,7 +1086,7 @@
</span><span class="cx">         IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
</span><span class="cx">         RenderObject&amp; renderer = root-&gt;closestLeafChildForPoint(pointInLine, isEditablePosition(p))-&gt;renderer();
</span><span class="cx">         Node* node = renderer.node();
</span><del>-        if (node &amp;&amp; editingIgnoresContent(node))
</del><ins>+        if (node &amp;&amp; editingIgnoresContent(*node))
</ins><span class="cx">             return positionInParentBeforeNode(node);
</span><span class="cx">         return renderer.positionForPoint(pointInLine, nullptr);
</span><span class="cx">     }
</span><span class="lines">@@ -1198,7 +1198,7 @@
</span><span class="cx">             node = n;
</span><span class="cx">             offset = 0;
</span><span class="cx">             n = NodeTraversal::previousPostOrder(*n, startBlock);
</span><del>-        } else if (editingIgnoresContent(n) || isRenderedTable(n)) {
</del><ins>+        } else if (editingIgnoresContent(*n) || isRenderedTable(n)) {
</ins><span class="cx">             node = n;
</span><span class="cx">             type = Position::PositionIsBeforeAnchor;
</span><span class="cx">             n = n-&gt;previousSibling() ? n-&gt;previousSibling() : NodeTraversal::previousPostOrder(*n, startBlock);
</span><span class="lines">@@ -1260,7 +1260,7 @@
</span><span class="cx">             node = n;
</span><span class="cx">             offset = r-&gt;caretMaxOffset();
</span><span class="cx">             n = NodeTraversal::next(*n, stayInsideBlock);
</span><del>-        } else if (editingIgnoresContent(n) || isRenderedTable(n)) {
</del><ins>+        } else if (editingIgnoresContent(*n) || isRenderedTable(n)) {
</ins><span class="cx">             node = n;
</span><span class="cx">             type = Position::PositionIsAfterAnchor;
</span><span class="cx">             n = NodeTraversal::nextSkippingChildren(*n, stayInsideBlock);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditinghtmleditingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/htmlediting.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/htmlediting.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/htmlediting.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2007, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #include &quot;VisibleUnits.h&quot;
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><ins>+#include &lt;wtf/text/StringBuilder.h&gt;
</ins><span class="cx"> #include &lt;wtf/unicode/CharacterNames.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -63,10 +64,15 @@
</span><span class="cx"> 
</span><span class="cx"> static bool isVisiblyAdjacent(const Position&amp;, const Position&amp;);
</span><span class="cx"> 
</span><ins>+bool canHaveChildrenForEditing(const Node&amp; node)
+{
+    return !is&lt;Text&gt;(node) &amp;&amp; node.canContainRangeEndPoint();
+}
+
</ins><span class="cx"> // Atomic means that the node has no children, or has children which are ignored for the purposes of editing.
</span><span class="cx"> bool isAtomicNode(const Node* node)
</span><span class="cx"> {
</span><del>-    return node &amp;&amp; (!node-&gt;hasChildNodes() || editingIgnoresContent(node));
</del><ins>+    return node &amp;&amp; (!node-&gt;hasChildNodes() || editingIgnoresContent(*node));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Compare two positions, taking into account the possibility that one or both
</span><span class="lines">@@ -373,8 +379,9 @@
</span><span class="cx">     if (node.hasChildNodes())
</span><span class="cx">         return node.countChildNodes();
</span><span class="cx"> 
</span><del>-    // NOTE: This should preempt the countChildNodes() for, e.g., select nodes (what does this mean)?
-    if (editingIgnoresContent(&amp;node))
</del><ins>+    // NOTE: This should preempt the countChildNodes() for, e.g., select nodes.
+    // FIXME: What does the comment above mean?
+    if (editingIgnoresContent(node))
</ins><span class="cx">         return 1;
</span><span class="cx"> 
</span><span class="cx">     return 0;
</span><span class="lines">@@ -382,33 +389,37 @@
</span><span class="cx"> 
</span><span class="cx"> String stringWithRebalancedWhitespace(const String&amp; string, bool startIsStartOfParagraph, bool endIsEndOfParagraph)
</span><span class="cx"> {
</span><del>-    Vector&lt;UChar&gt; rebalancedString(string.length());
-    StringView(string).getCharactersWithUpconvert(rebalancedString.data());
</del><ins>+    StringBuilder rebalancedString;
</ins><span class="cx"> 
</span><del>-    bool changedSomething = false;
-
</del><span class="cx">     bool previousCharacterWasSpace = false;
</span><del>-    for (size_t i = 0; i &lt; rebalancedString.size(); i++) {
-        if (!deprecatedIsEditingWhitespace(rebalancedString[i])) {
</del><ins>+    unsigned length = string.length();
+    for (unsigned i = 0; i &lt; length; ++i) {
+        auto character = string[i];
+        if (!deprecatedIsEditingWhitespace(character)) {
</ins><span class="cx">             previousCharacterWasSpace = false;
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><del>-        if (previousCharacterWasSpace || (!i &amp;&amp; startIsStartOfParagraph) || (i + 1 == rebalancedString.size() &amp;&amp; endIsEndOfParagraph)) {
-            if (rebalancedString[i] != noBreakSpace) {
-                rebalancedString[i] = noBreakSpace;
-                changedSomething = true;
-            }
</del><ins>+        LChar selectedWhitespaceCharacter;
+        if (previousCharacterWasSpace || (!i &amp;&amp; startIsStartOfParagraph) || (i == length - 1 &amp;&amp; endIsEndOfParagraph)) {
+            selectedWhitespaceCharacter = noBreakSpace;
</ins><span class="cx">             previousCharacterWasSpace = false;
</span><span class="cx">         } else {
</span><del>-            if (rebalancedString[i] != ' ') {
-                rebalancedString[i] = ' ';
-                changedSomething = true;
-            }
</del><ins>+            selectedWhitespaceCharacter = ' ';
</ins><span class="cx">             previousCharacterWasSpace = true;
</span><span class="cx">         }
</span><ins>+        if (character == selectedWhitespaceCharacter)
+            continue;
+        rebalancedString.reserveCapacity(length);
+        rebalancedString.append(string, rebalancedString.length(), i - rebalancedString.length());
+        rebalancedString.append(selectedWhitespaceCharacter);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return changedSomething ? String::adopt(rebalancedString) : string;
</del><ins>+    if (rebalancedString.isEmpty())
+        return string;
+
+    rebalancedString.reserveCapacity(length);
+    rebalancedString.append(string, rebalancedString.length(), length - rebalancedString.length());
+    return rebalancedString.toString();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool isTableStructureNode(const Node* node)
</span><span class="lines">@@ -423,7 +434,7 @@
</span><span class="cx">     return nonBreakingSpaceString;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isSpecialElement(const Node* node)
</del><ins>+static bool isSpecialHTMLElement(const Node* node)
</ins><span class="cx"> {
</span><span class="cx">     if (!is&lt;HTMLElement&gt;(node))
</span><span class="cx">         return false;
</span><span class="lines">@@ -451,7 +462,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto* rootEditableElement = position.containerNode()-&gt;rootEditableElement();
</span><span class="cx">     for (Node* node = position.deprecatedNode(); node &amp;&amp; node-&gt;rootEditableElement() == rootEditableElement; node = node-&gt;parentNode()) {
</span><del>-        if (!isSpecialElement(node))
</del><ins>+        if (!isSpecialHTMLElement(node))
</ins><span class="cx">             continue;
</span><span class="cx">         VisiblePosition vPos(position, DOWNSTREAM);
</span><span class="cx">         VisiblePosition firstInElement(firstPositionInOrBeforeNode(node), DOWNSTREAM);
</span><span class="lines">@@ -465,7 +476,7 @@
</span><span class="cx"> {
</span><span class="cx">     auto* rootEditableElement = position.containerNode()-&gt;rootEditableElement();
</span><span class="cx">     for (Node* node = position.deprecatedNode(); node &amp;&amp; node-&gt;rootEditableElement() == rootEditableElement; node = node-&gt;parentNode()) {
</span><del>-        if (!isSpecialElement(node))
</del><ins>+        if (!isSpecialHTMLElement(node))
</ins><span class="cx">             continue;
</span><span class="cx">         VisiblePosition vPos(position, DOWNSTREAM);
</span><span class="cx">         VisiblePosition lastInElement(lastPositionInOrAfterNode(node), DOWNSTREAM);
</span><span class="lines">@@ -564,14 +575,14 @@
</span><span class="cx">     return positionInParentAfterNode(&amp;node);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool isListElement(Node* node)
</del><ins>+bool isListHTMLElement(Node* node)
</ins><span class="cx"> {
</span><del>-    return node &amp;&amp; (node-&gt;hasTagName(ulTag) || node-&gt;hasTagName(olTag) || node-&gt;hasTagName(dlTag));
</del><ins>+    return node &amp;&amp; (is&lt;HTMLUListElement&gt;(*node) || is&lt;HTMLOListElement&gt;(*node) || is&lt;HTMLDListElement&gt;(*node));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool isListItem(const Node* node)
</span><span class="cx"> {
</span><del>-    return node &amp;&amp; (isListElement(node-&gt;parentNode()) || (node-&gt;renderer() &amp;&amp; node-&gt;renderer()-&gt;isListItem()));
</del><ins>+    return node &amp;&amp; (isListHTMLElement(node-&gt;parentNode()) || (node-&gt;renderer() &amp;&amp; node-&gt;renderer()-&gt;isListItem()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Element* enclosingElementWithTag(const Position&amp; position, const QualifiedName&amp; tagName)
</span><span class="lines">@@ -590,12 +601,12 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* enclosingNodeOfType(const Position&amp; p, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule)
</del><ins>+Node* enclosingNodeOfType(const Position&amp; position, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: support CanSkipCrossEditingBoundary
</span><span class="cx">     ASSERT(rule == CanCrossEditingBoundary || rule == CannotCrossEditingBoundary);
</span><del>-    auto* root = rule == CannotCrossEditingBoundary ? highestEditableRoot(p) : 0;
-    for (Node* n = p.deprecatedNode(); n; n = n-&gt;parentNode()) {
</del><ins>+    auto* root = rule == CannotCrossEditingBoundary ? highestEditableRoot(position) : nullptr;
+    for (Node* n = position.deprecatedNode(); n; n = n-&gt;parentNode()) {
</ins><span class="cx">         // Don't return a non-editable node if the input position was editable, since
</span><span class="cx">         // the callers from editing will no doubt want to perform editing inside the returned node.
</span><span class="cx">         if (root &amp;&amp; !n-&gt;hasEditableStyle())
</span><span class="lines">@@ -608,11 +619,11 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Node* highestEnclosingNodeOfType(const Position&amp; p, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule, Node* stayWithin)
</del><ins>+Node* highestEnclosingNodeOfType(const Position&amp; position, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule rule, Node* stayWithin)
</ins><span class="cx"> {
</span><span class="cx">     Node* highest = nullptr;
</span><del>-    auto* root = rule == CannotCrossEditingBoundary ? highestEditableRoot(p) : 0;
-    for (Node* n = p.containerNode(); n &amp;&amp; n != stayWithin; n = n-&gt;parentNode()) {
</del><ins>+    auto* root = rule == CannotCrossEditingBoundary ? highestEditableRoot(position) : nullptr;
+    for (Node* n = position.containerNode(); n &amp;&amp; n != stayWithin; n = n-&gt;parentNode()) {
</ins><span class="cx">         if (root &amp;&amp; !n-&gt;hasEditableStyle())
</span><span class="cx">             continue;
</span><span class="cx">         if (nodeIsOfType(n))
</span><span class="lines">@@ -693,7 +704,7 @@
</span><span class="cx">     
</span><span class="cx">     // FIXME: This function is inappropriately named since it starts with node instead of node-&gt;parentNode()
</span><span class="cx">     for (Node* n = node; n &amp;&amp; n-&gt;parentNode(); n = n-&gt;parentNode()) {
</span><del>-        if (n-&gt;hasTagName(liTag) || (isListElement(n-&gt;parentNode()) &amp;&amp; n != root))
</del><ins>+        if (is&lt;HTMLLIElement&gt;(*n) || (isListHTMLElement(n-&gt;parentNode()) &amp;&amp; n != root))
</ins><span class="cx">             return n;
</span><span class="cx">         if (n == root || isTableCell(n))
</span><span class="cx">             return nullptr;
</span><span class="lines">@@ -706,7 +717,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Check the DOM so that we'll find collapsed sublists without renderers.
</span><span class="cx">     for (Node* n = listItem-&gt;firstChild(); n; n = n-&gt;nextSibling()) {
</span><del>-        if (isListElement(n))
</del><ins>+        if (isListHTMLElement(n))
</ins><span class="cx">             return downcast&lt;HTMLElement&gt;(n);
</span><span class="cx">     }
</span><span class="cx">     return nullptr;
</span><span class="lines">@@ -716,7 +727,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Check the DOM so that we'll find collapsed sublists without renderers.
</span><span class="cx">     for (Node* n = listItem-&gt;nextSibling(); n; n = n-&gt;nextSibling()) {
</span><del>-        if (isListElement(n))
</del><ins>+        if (isListHTMLElement(n))
</ins><span class="cx">             return downcast&lt;HTMLElement&gt;(n);
</span><span class="cx">         if (isListItem(listItem))
</span><span class="cx">             return nullptr;
</span><span class="lines">@@ -994,9 +1005,10 @@
</span><span class="cx"> int caretMaxOffset(const Node&amp; node)
</span><span class="cx"> {
</span><span class="cx">     // For rendered text nodes, return the last position that a caret could occupy.
</span><del>-    if (node.isTextNode() &amp;&amp; node.renderer())
-        return node.renderer()-&gt;caretMaxOffset();
-    // For containers return the number of children. For others do the same as above.
</del><ins>+    if (is&lt;Text&gt;(node)) {
+        if (auto* renderer = downcast&lt;Text&gt;(node).renderer())
+            return renderer-&gt;caretMaxOffset();
+    }
</ins><span class="cx">     return lastOffsetForEditing(node);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1216,9 +1228,9 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool caretRendersInsideNode(Node* node)
</del><ins>+static inline bool caretRendersInsideNode(Node&amp; node)
</ins><span class="cx"> {
</span><del>-    return node &amp;&amp; !isRenderedTable(node) &amp;&amp; !editingIgnoresContent(node);
</del><ins>+    return !isRenderedTable(&amp;node) &amp;&amp; !editingIgnoresContent(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderBlock* rendererForCaretPainting(Node* node)
</span><span class="lines">@@ -1231,7 +1243,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     // If caretNode is a block and caret is inside it, then caret should be painted by that block.
</span><del>-    bool paintedByBlock = is&lt;RenderBlockFlow&gt;(*renderer) &amp;&amp; caretRendersInsideNode(node);
</del><ins>+    bool paintedByBlock = is&lt;RenderBlockFlow&gt;(*renderer) &amp;&amp; caretRendersInsideNode(*node);
</ins><span class="cx">     return paintedByBlock ? downcast&lt;RenderBlock&gt;(renderer) : renderer-&gt;containingBlock();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditinghtmleditingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/htmlediting.h (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/htmlediting.h        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/htmlediting.h        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -71,14 +71,13 @@
</span><span class="cx"> bool hasEditableStyle(const Node&amp;, EditableType);
</span><span class="cx"> bool isEditableNode(const Node&amp;);
</span><span class="cx"> 
</span><del>-// FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode should be renamed to better reflect their usage.
</del><ins>+// FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode should be named to clarify how they differ.
</ins><span class="cx"> 
</span><span class="cx"> // Returns true for nodes that either have no content, or have content that is ignored (skipped over) while editing.
</span><span class="cx"> // There are no VisiblePositions inside these nodes.
</span><del>-bool editingIgnoresContent(const Node*);
</del><ins>+bool editingIgnoresContent(const Node&amp;);
</ins><span class="cx"> 
</span><del>-bool canHaveChildrenForEditing(const Node*);
-
</del><ins>+bool canHaveChildrenForEditing(const Node&amp;);
</ins><span class="cx"> bool isAtomicNode(const Node*);
</span><span class="cx"> 
</span><span class="cx"> bool isBlock(const Node*);
</span><span class="lines">@@ -91,7 +90,7 @@
</span><span class="cx"> bool isTableCell(const Node*);
</span><span class="cx"> bool isEmptyTableCell(const Node*);
</span><span class="cx"> bool isTableStructureNode(const Node*);
</span><del>-bool isListElement(Node*);
</del><ins>+bool isListHTMLElement(Node*);
</ins><span class="cx"> bool isListItem(const Node*);
</span><span class="cx"> bool isNodeRendered(const Node&amp;);
</span><span class="cx"> bool isRenderedAsNonInlineTableImageOrHR(const Node*);
</span><span class="lines">@@ -101,7 +100,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool areIdenticalElements(const Node&amp;, const Node&amp;);
</span><span class="cx"> 
</span><del>-bool positionBeforeOrAfterNodeIsCandidate(Node*);
</del><ins>+bool positionBeforeOrAfterNodeIsCandidate(Node&amp;);
</ins><span class="cx"> 
</span><span class="cx"> // -------------------------------------------------------------------------
</span><span class="cx"> // Position
</span><span class="lines">@@ -224,33 +223,28 @@
</span><span class="cx">     return character == '\'' || character == rightSingleQuotationMark || character == hebrewPunctuationGershayim;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool editingIgnoresContent(const Node* node)
</del><ins>+inline bool editingIgnoresContent(const Node&amp; node)
</ins><span class="cx"> {
</span><del>-    return !node-&gt;canContainRangeEndPoint();
</del><ins>+    return !node.canContainRangeEndPoint();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool canHaveChildrenForEditing(const Node* node)
</del><ins>+inline bool positionBeforeOrAfterNodeIsCandidate(Node&amp; node)
</ins><span class="cx"> {
</span><del>-    return !node-&gt;isTextNode() &amp;&amp; node-&gt;canContainRangeEndPoint();
</del><ins>+    return isRenderedTable(&amp;node) || editingIgnoresContent(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool positionBeforeOrAfterNodeIsCandidate(Node* node)
-{
-    return isRenderedTable(node) || editingIgnoresContent(node);
-}
-
</del><span class="cx"> inline Position firstPositionInOrBeforeNode(Node* node)
</span><span class="cx"> {
</span><span class="cx">     if (!node)
</span><span class="cx">         return { };
</span><del>-    return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositionInNode(node);
</del><ins>+    return editingIgnoresContent(*node) ? positionBeforeNode(node) : firstPositionInNode(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline Position lastPositionInOrAfterNode(Node* node)
</span><span class="cx"> {
</span><span class="cx">     if (!node)
</span><span class="cx">         return { };
</span><del>-    return editingIgnoresContent(node) ? positionAfterNode(node) : lastPositionInNode(node);
</del><ins>+    return editingIgnoresContent(*node) ? positionAfterNode(node) : lastPositionInNode(node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/editing/markup.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -402,9 +402,10 @@
</span><span class="cx">         next = NodeTraversal::next(*n);
</span><span class="cx">         bool openedTag = false;
</span><span class="cx"> 
</span><del>-        if (isBlock(n) &amp;&amp; canHaveChildrenForEditing(n) &amp;&amp; next == pastEnd)
</del><ins>+        if (isBlock(n) &amp;&amp; canHaveChildrenForEditing(*n) &amp;&amp; next == pastEnd) {
</ins><span class="cx">             // Don't write out empty block containers that aren't fully selected.
</span><span class="cx">             continue;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!n-&gt;renderer() &amp;&amp; !enclosingElementWithTag(firstPositionInOrBeforeNode(n), selectTag)) {
</span><span class="cx">             next = NodeTraversal::nextSkippingChildren(*n);
</span><span class="lines">@@ -529,7 +530,7 @@
</span><span class="cx"> 
</span><span class="cx"> static Node* highestAncestorToWrapMarkup(const Range* range, EAnnotateForInterchange shouldAnnotate)
</span><span class="cx"> {
</span><del>-    Node* commonAncestor = range-&gt;commonAncestorContainer();
</del><ins>+    auto* commonAncestor = range-&gt;commonAncestorContainer();
</ins><span class="cx">     ASSERT(commonAncestor);
</span><span class="cx">     Node* specialCommonAncestor = nullptr;
</span><span class="cx">     if (shouldAnnotate == AnnotateForInterchange) {
</span><span class="lines">@@ -537,10 +538,10 @@
</span><span class="cx">         // the structure and appearance of the copied markup.
</span><span class="cx">         specialCommonAncestor = ancestorToRetainStructureAndAppearance(commonAncestor);
</span><span class="cx"> 
</span><del>-        if (Node* parentListNode = enclosingNodeOfType(firstPositionInOrBeforeNode(range-&gt;firstNode()), isListItem)) {
-            if (!editingIgnoresContent(parentListNode) &amp;&amp; WebCore::areRangesEqual(VisibleSelection::selectionFromContentsOfNode(parentListNode).toNormalizedRange().get(), range)) {
</del><ins>+        if (auto* parentListNode = downcast&lt;Element&gt;(enclosingNodeOfType(firstPositionInOrBeforeNode(range-&gt;firstNode()), isListItem))) {
+            if (!editingIgnoresContent(*parentListNode) &amp;&amp; WebCore::areRangesEqual(VisibleSelection::selectionFromContentsOfNode(parentListNode).toNormalizedRange().get(), range)) {
</ins><span class="cx">                 specialCommonAncestor = parentListNode-&gt;parentNode();
</span><del>-                while (specialCommonAncestor &amp;&amp; !isListElement(specialCommonAncestor))
</del><ins>+                while (specialCommonAncestor &amp;&amp; !isListHTMLElement(specialCommonAncestor))
</ins><span class="cx">                     specialCommonAncestor = specialCommonAncestor-&gt;parentNode();
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="lines">@@ -550,7 +551,7 @@
</span><span class="cx">             specialCommonAncestor = highestMailBlockquote;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Node* checkAncestor = specialCommonAncestor ? specialCommonAncestor : commonAncestor;
</del><ins>+    auto* checkAncestor = specialCommonAncestor ? specialCommonAncestor : commonAncestor;
</ins><span class="cx">     if (checkAncestor-&gt;renderer() &amp;&amp; checkAncestor-&gt;renderer()-&gt;containingBlock()) {
</span><span class="cx">         Node* newSpecialCommonAncestor = highestEnclosingNodeOfType(firstPositionInNode(checkAncestor), &amp;isElementPresentational, CanCrossEditingBoundary, checkAncestor-&gt;renderer()-&gt;containingBlock()-&gt;element());
</span><span class="cx">         if (newSpecialCommonAncestor)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSpanElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSpanElement.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSpanElement.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/html/HTMLSpanElement.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -38,6 +38,11 @@
</span><span class="cx">     ASSERT(hasTagName(spanTag));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Ref&lt;HTMLSpanElement&gt; HTMLSpanElement::create(Document&amp; document)
+{
+    return adoptRef(*new HTMLSpanElement(spanTag, document));
+}
+
</ins><span class="cx"> Ref&lt;HTMLSpanElement&gt; HTMLSpanElement::create(const QualifiedName&amp; tagName, Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(*new HTMLSpanElement(tagName, document));
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSpanElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSpanElement.h (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSpanElement.h        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/html/HTMLSpanElement.h        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class HTMLSpanElement final : public HTMLElement {
</span><span class="cx"> public:
</span><ins>+    static Ref&lt;HTMLSpanElement&gt; create(Document&amp;);
</ins><span class="cx">     static Ref&lt;HTMLSpanElement&gt; create(const QualifiedName&amp;, Document&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMSelection.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMSelection.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/page/DOMSelection.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -35,12 +35,9 @@
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;FrameSelection.h&quot;
</span><del>-#include &quot;Node.h&quot;
</del><span class="cx"> #include &quot;Range.h&quot;
</span><span class="cx"> #include &quot;TextIterator.h&quot;
</span><del>-#include &quot;TreeScope.h&quot;
</del><span class="cx"> #include &quot;htmlediting.h&quot;
</span><del>-#include &lt;wtf/text/WTFString.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.cpp        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -37,8 +37,8 @@
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;HTMLBodyElement.h&quot;
</span><span class="cx"> #include &quot;HTMLButtonElement.h&quot;
</span><del>-#include &quot;HTMLElement.h&quot;
</del><span class="cx"> #include &quot;HTMLFrameOwnerElement.h&quot;
</span><ins>+#include &quot;HTMLHtmlElement.h&quot;
</ins><span class="cx"> #include &quot;HTMLInputElement.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLTextAreaElement.h&quot;
</span><span class="lines">@@ -4386,7 +4386,7 @@
</span><span class="cx">     // FIXME: Border/padding should be added for all elements but this workaround
</span><span class="cx">     // is needed because we use offsets inside an &quot;atomic&quot; element to represent
</span><span class="cx">     // positions before and after the element in deprecated editing offsets.
</span><del>-    if (element() &amp;&amp; !(editingIgnoresContent(element()) || isRenderedTable(element()))) {
</del><ins>+    if (element() &amp;&amp; !(editingIgnoresContent(*element()) || isRenderedTable(element()))) {
</ins><span class="cx">         rect.setX(rect.x() + borderLeft() + paddingLeft());
</span><span class="cx">         rect.setY(rect.y() + paddingTop() + borderTop());
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKitiosChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/ChangeLog (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/ChangeLog        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebKit/ios/ChangeLog        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-05-15  Darin Adler  &lt;darin@apple.com&gt;
+
+        More CTTE and other cleanups for HTML editing header
+        https://bugs.webkit.org/show_bug.cgi?id=157722
+
+        Reviewed by Chris Dumez.
+
+        * WebCoreSupport/WebFrameIOS.mm:
+        (-[WebFrame previousUnperturbedDictationResultBoundaryFromPosition:]): auto
+        (-[WebFrame nextUnperturbedDictationResultBoundaryFromPosition:]): auto
+
</ins><span class="cx"> 2016-05-14  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CTTE for the HTML editing header
</span></span></pre></div>
<a id="trunkSourceWebKitiosWebCoreSupportWebFrameIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm (200930 => 200931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm        2016-05-15 22:05:56 UTC (rev 200930)
+++ trunk/Source/WebKit/ios/WebCoreSupport/WebFrameIOS.mm        2016-05-15 22:08:52 UTC (rev 200931)
</span><span class="lines">@@ -848,7 +848,7 @@
</span><span class="cx">     while (currentVisiblePosition.isNotNull()) {
</span><span class="cx">         WebVisiblePosition *currentWebVisiblePosition = [WebVisiblePosition _wrapVisiblePosition:currentVisiblePosition];
</span><span class="cx">         
</span><del>-        Node *currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
</del><ins>+        auto* currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
</ins><span class="cx">         int lastOffset = lastOffsetForEditing(*currentNode);
</span><span class="cx">         ASSERT(lastOffset &gt;= 0);
</span><span class="cx">         if (lastOffset &lt; 0)
</span><span class="lines">@@ -904,7 +904,7 @@
</span><span class="cx">     while (currentVisiblePosition.isNotNull()) {
</span><span class="cx">         WebVisiblePosition *currentWebVisiblePosition = [WebVisiblePosition _wrapVisiblePosition:currentVisiblePosition];
</span><span class="cx">         
</span><del>-        Node *currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
</del><ins>+        auto* currentNode = currentVisiblePosition.deepEquivalent().anchorNode();
</ins><span class="cx">         int lastOffset = lastOffsetForEditing(*currentNode);
</span><span class="cx">         ASSERT(lastOffset &gt;= 0);
</span><span class="cx">         if (lastOffset &lt; 0)
</span></span></pre>
</div>
</div>

</body>
</html>