Reviewed by Dave Harrison.
[WebKit-https.git] / WebCore / khtml / editing / htmlediting.cpp
index 9e8d98effaa69b84fb0f2da05ed91683206ec7f1..2ae08ae432f4e957caf968cb8fdd26fc95270943 100644 (file)
@@ -2135,7 +2135,7 @@ bool ApplyStyleCommand::nodeFullySelected(NodeImpl *node, const Position &start,
     ASSERT(node);
     ASSERT(node->isElementNode());
 
-    Position pos = Position(node, node->childNodeCount()).upstream();
+    Position pos = Position(node, node->childNodeCount()).upstream(DoNotStayInBlock);
     return RangeImpl::compareBoundaryPoints(node, 0, start.node(), start.offset()) >= 0 &&
         RangeImpl::compareBoundaryPoints(pos, end) <= 0;
 }
@@ -2145,7 +2145,7 @@ bool ApplyStyleCommand::nodeFullyUnselected(NodeImpl *node, const Position &star
     ASSERT(node);
     ASSERT(node->isElementNode());
 
-    Position pos = Position(node, node->childNodeCount()).upstream();
+    Position pos = Position(node, node->childNodeCount()).upstream(DoNotStayInBlock);
     bool isFullyBeforeStart = RangeImpl::compareBoundaryPoints(pos, start) < 0;
     bool isFullyAfterEnd = RangeImpl::compareBoundaryPoints(node, 0, end.node(), end.offset()) > 0;
 
@@ -2695,13 +2695,13 @@ void DeleteSelectionCommand::insertPlaceholderForAncestorBlockContent()
     // surrounded by child blocks.
     //
     NodeImpl *upstreamBlock = m_upstreamStart.node()->enclosingBlockFlowElement();
-    NodeImpl *beforeUpstreamBlock = m_upstreamStart.upstream().node()->enclosingBlockFlowElement();
+    NodeImpl *beforeUpstreamBlock = m_upstreamStart.upstream(DoNotStayInBlock).node()->enclosingBlockFlowElement();
     
     if (upstreamBlock != beforeUpstreamBlock && 
         beforeUpstreamBlock->isAncestor(upstreamBlock) &&
         upstreamBlock != m_upstreamStart.node()) {
         NodeImpl *downstreamBlock = m_downstreamEnd.node()->enclosingBlockFlowElement();
-        NodeImpl *afterDownstreamBlock = m_downstreamEnd.downstream().node()->enclosingBlockFlowElement();
+        NodeImpl *afterDownstreamBlock = m_downstreamEnd.downstream(DoNotStayInBlock).node()->enclosingBlockFlowElement();
         
         if ((afterDownstreamBlock != downstreamBlock && afterDownstreamBlock != upstreamBlock) ||
             (m_downstreamEnd == m_selectionToDelete.end() && isEndOfParagraph(VisiblePosition(m_downstreamEnd, VP_DEFAULT_AFFINITY)))) {
@@ -3719,7 +3719,7 @@ void InsertParagraphSeparatorInQuotedContentCommand::doApply()
     EAffinity affinity = selection.startAffinity();
     if (selection.isRange()) {
         deleteSelection(false, false);
-        pos = endingSelection().start().upstream();
+        pos = endingSelection().start().upstream(DoNotStayInBlock);
         affinity = endingSelection().startAffinity();
     }
     
@@ -4000,7 +4000,7 @@ void InsertTextCommand::insertSpace(TextImpl *textNode, unsigned long offset)
         // By checking the character at the downstream position, we can
         // check if there is a rendered WS at the caret
         Position pos(textNode, offset);
-        Position downstream = pos.downstream();
+        Position downstream = pos.downstream(DoNotStayInBlock);
         if (downstream.offset() < (long)text.length() && isCollapsibleWhitespace(text[downstream.offset()]))
             count--; // leave this WS in
         if (count > 0)
@@ -4973,7 +4973,7 @@ void ReplaceSelectionCommand::doApply()
         else if (!insertionBlockIsRoot && isProbablyBlock(refNode) && isLastVisiblePositionInBlock(visiblePos)) {
             insertNodeAfterAndUpdateNodesInserted(refNode, insertionBlock);
         } else if (mergeStart && !isProbablyBlock(refNode)) {
-            Position pos = insertionPos.downstream();
+            Position pos = insertionPos.downstream(DoNotStayInBlock);
             insertNodeAtAndUpdateNodesInserted(refNode, pos.node(), pos.offset());
         } else {
             insertNodeAtAndUpdateNodesInserted(refNode, insertionPos.node(), insertionPos.offset());
@@ -5030,7 +5030,7 @@ void ReplaceSelectionCommand::doApply()
         removeLinePlaceholderIfNeeded(linePlaceholder);
 
         if (!m_lastNodeInserted) {
-            lastPositionToSelect = endingSelection().end().downstream();
+            lastPositionToSelect = endingSelection().end().downstream(DoNotStayInBlock);
         }
         else {
             bool insertParagraph = false;
@@ -5047,13 +5047,13 @@ void ReplaceSelectionCommand::doApply()
             if (insertParagraph) {
                 setEndingSelection(insertionPos, DOWNSTREAM);
                 insertParagraphSeparator();
-                updateNodesInserted(endingSelection().end().downstream().node());
+                updateNodesInserted(endingSelection().end().downstream(DoNotStayInBlock).node());
                 // Select up to the paragraph separator that was added.
-                lastPositionToSelect = endingSelection().end().downstream();
+                lastPositionToSelect = endingSelection().end().downstream(DoNotStayInBlock);
             } 
             else {
                 // Select up to the preexising paragraph separator.
-                lastPositionToSelect = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset()).downstream();
+                lastPositionToSelect = Position(m_lastNodeInserted, m_lastNodeInserted->caretMaxOffset()).downstream(DoNotStayInBlock);
             }
         }
     }