From 7682eb2b822ed4320691b72967967771067005e7 Mon Sep 17 00:00:00 2001 From: mjs Date: Sat, 7 May 2005 07:02:35 +0000 Subject: [PATCH] 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: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9131 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog-2005-08-23 | 21 ++++++++++++++++++ WebCore/khtml/editing/SelectionController.cpp | 13 ++++++----- WebCore/khtml/editing/htmlediting.cpp | 22 +++++++++---------- WebCore/khtml/editing/markup.cpp | 2 +- WebCore/khtml/editing/selection.cpp | 13 ++++++----- WebCore/khtml/xml/dom_position.h | 4 ++-- 6 files changed, 49 insertions(+), 26 deletions(-) diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23 index ffd2d1e52932..08198a9e1260 100644 --- a/WebCore/ChangeLog-2005-08-23 +++ b/WebCore/ChangeLog-2005-08-23 @@ -1,3 +1,24 @@ +2005-05-06 Maciej Stachowiak + + 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 Reviewed by Maciej, Darin. diff --git a/WebCore/khtml/editing/SelectionController.cpp b/WebCore/khtml/editing/SelectionController.cpp index c0eb391804d5..90558be329d7 100644 --- a/WebCore/khtml/editing/SelectionController.cpp +++ b/WebCore/khtml/editing/SelectionController.cpp @@ -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()); diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp index 9e8d98effaa6..2ae08ae432f4 100644 --- a/WebCore/khtml/editing/htmlediting.cpp +++ b/WebCore/khtml/editing/htmlediting.cpp @@ -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); } } } diff --git a/WebCore/khtml/editing/markup.cpp b/WebCore/khtml/editing/markup.cpp index b7312db04892..225ed4e67bda 100644 --- a/WebCore/khtml/editing/markup.cpp +++ b/WebCore/khtml/editing/markup.cpp @@ -436,7 +436,7 @@ QString createMarkup(const RangeImpl *range, QPtrList *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); } diff --git a/WebCore/khtml/editing/selection.cpp b/WebCore/khtml/editing/selection.cpp index c0eb391804d5..90558be329d7 100644 --- a/WebCore/khtml/editing/selection.cpp +++ b/WebCore/khtml/editing/selection.cpp @@ -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()); diff --git a/WebCore/khtml/xml/dom_position.h b/WebCore/khtml/xml/dom_position.h index ee095df8e98b..df802548a177 100644 --- a/WebCore/khtml/xml/dom_position.h +++ b/WebCore/khtml/xml/dom_position.h @@ -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; -- 2.36.0