Reviewed by Dave Harrison.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 May 2005 07:02:35 +0000 (07:02 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 May 2005 07:02:35 +0000 (07:02 +0000)
- make StayInBlock vs DoNotStayInBlock explicit in all calls to
upstream/downstream, in preparation for phasing out the
DoNotStayInBlock variant.

        * khtml/editing/htmlediting.cpp:
        (khtml::ApplyStyleCommand::nodeFullySelected):
        (khtml::ApplyStyleCommand::nodeFullyUnselected):
        (khtml::DeleteSelectionCommand::insertPlaceholderForAncestorBlockContent):
        (khtml::InsertParagraphSeparatorInQuotedContentCommand::doApply):
        (khtml::InsertTextCommand::insertSpace):
        (khtml::ReplaceSelectionCommand::doApply):
        * khtml/editing/markup.cpp:
        (khtml::createMarkup):
        * khtml/editing/selection.cpp:
        (khtml::Selection::debugPosition):
        * khtml/xml/dom_position.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/SelectionController.cpp
WebCore/khtml/editing/htmlediting.cpp
WebCore/khtml/editing/markup.cpp
WebCore/khtml/editing/selection.cpp
WebCore/khtml/xml/dom_position.h

index ffd2d1e52932fa0aebac565a4f9e5b5d2edeea12..08198a9e12609f4b7a09dbe9f3a53348210c5bb6 100644 (file)
@@ -1,3 +1,24 @@
+2005-05-06  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Dave Harrison.
+
+       - make StayInBlock vs DoNotStayInBlock explicit in all calls to
+       upstream/downstream, in preparation for phasing out the
+       DoNotStayInBlock variant.
+
+        * khtml/editing/htmlediting.cpp:
+        (khtml::ApplyStyleCommand::nodeFullySelected):
+        (khtml::ApplyStyleCommand::nodeFullyUnselected):
+        (khtml::DeleteSelectionCommand::insertPlaceholderForAncestorBlockContent):
+        (khtml::InsertParagraphSeparatorInQuotedContentCommand::doApply):
+        (khtml::InsertTextCommand::insertSpace):
+        (khtml::ReplaceSelectionCommand::doApply):
+        * khtml/editing/markup.cpp:
+        (khtml::createMarkup):
+        * khtml/editing/selection.cpp:
+        (khtml::Selection::debugPosition):
+        * khtml/xml/dom_position.h:
+
 2005-05-06  David Harrison  <harrison@apple.com>
 
         Reviewed by Maciej, Darin.
index c0eb391804d5ecac23ce093fd049dce87079cd16..90558be329d765dc34dfa7aca347f892a502d069 100644 (file)
@@ -61,6 +61,7 @@ using DOM::Position;
 using DOM::Range;
 using DOM::RangeImpl;
 using DOM::StayInBlock;
+using DOM::DoNotStayInBlock;
 
 namespace khtml {
 
@@ -1026,23 +1027,23 @@ void Selection::debugPosition() const
 
     if (m_start == m_end) {
         Position pos = m_start;
-        Position upstream = pos.upstream();
-        Position downstream = pos.downstream();
+        Position upstream = pos.upstream(DoNotStayInBlock);
+        Position downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "pos:        %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
     }
     else {
         Position pos = m_start;
-        Position upstream = pos.upstream();
-        Position downstream = pos.downstream();
+        Position upstream = pos.upstream(DoNotStayInBlock);
+        Position downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "start:      %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
         fprintf(stderr, "-----------------------------------\n");
         pos = m_end;
-        upstream = pos.upstream();
-        downstream = pos.downstream();
+        upstream = pos.upstream(DoNotStayInBlock);
+        downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "end:        %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
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);
             }
         }
     } 
index b7312db04892319c05dbc3459905fd84200edd86..225ed4e67bdae70a5299de106defe8167f5c7d0b 100644 (file)
@@ -436,7 +436,7 @@ QString createMarkup(const RangeImpl *range, QPtrList<NodeImpl> *nodes, EAnnotat
     if (annotate) {
         Position pos(endPosition(range));
         NodeImpl *block = pos.node()->enclosingBlockFlowElement();
-        NodeImpl *upstreamBlock = pos.upstream().node()->enclosingBlockFlowElement();
+        NodeImpl *upstreamBlock = pos.upstream(DOM::DoNotStayInBlock).node()->enclosingBlockFlowElement();
         if (block != upstreamBlock) {
             markups.append(interchangeNewlineString);
         }
index c0eb391804d5ecac23ce093fd049dce87079cd16..90558be329d765dc34dfa7aca347f892a502d069 100644 (file)
@@ -61,6 +61,7 @@ using DOM::Position;
 using DOM::Range;
 using DOM::RangeImpl;
 using DOM::StayInBlock;
+using DOM::DoNotStayInBlock;
 
 namespace khtml {
 
@@ -1026,23 +1027,23 @@ void Selection::debugPosition() const
 
     if (m_start == m_end) {
         Position pos = m_start;
-        Position upstream = pos.upstream();
-        Position downstream = pos.downstream();
+        Position upstream = pos.upstream(DoNotStayInBlock);
+        Position downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "pos:        %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
     }
     else {
         Position pos = m_start;
-        Position upstream = pos.upstream();
-        Position downstream = pos.downstream();
+        Position upstream = pos.upstream(DoNotStayInBlock);
+        Position downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "start:      %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
         fprintf(stderr, "-----------------------------------\n");
         pos = m_end;
-        upstream = pos.upstream();
-        downstream = pos.downstream();
+        upstream = pos.upstream(DoNotStayInBlock);
+        downstream = pos.downstream(DoNotStayInBlock);
         fprintf(stderr, "upstream:   %s %p:%ld\n", upstream.node()->nodeName().string().latin1(), upstream.node(), upstream.offset());
         fprintf(stderr, "end:        %s %p:%ld\n", pos.node()->nodeName().string().latin1(), pos.node(), pos.offset());
         fprintf(stderr, "downstream: %s %p:%ld\n", downstream.node()->nodeName().string().latin1(), downstream.node(), downstream.offset());
index ee095df8e98b0c2aca9fc6de37746b4b23d93c32..df802548a177474306075342fc2a54c7e3863128 100644 (file)
@@ -81,8 +81,8 @@ public:
     // same position as the caller's position. The same goes for downstream position
     // except that it is the latest position for earliest position in the above 
     // description.
-    Position upstream(EStayInBlock stayInBlock = DoNotStayInBlock) const;
-    Position downstream(EStayInBlock stayInBlock = DoNotStayInBlock) const;
+    Position upstream(EStayInBlock stayInBlock) const;
+    Position downstream(EStayInBlock stayInBlock) const;
     
     Position equivalentRangeCompliantPosition() const;
     Position equivalentDeepPosition() const;