+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.
using DOM::Range;
using DOM::RangeImpl;
using DOM::StayInBlock;
+using DOM::DoNotStayInBlock;
namespace khtml {
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());
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;
}
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;
// 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)))) {
EAffinity affinity = selection.startAffinity();
if (selection.isRange()) {
deleteSelection(false, false);
- pos = endingSelection().start().upstream();
+ pos = endingSelection().start().upstream(DoNotStayInBlock);
affinity = endingSelection().startAffinity();
}
// 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)
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());
removeLinePlaceholderIfNeeded(linePlaceholder);
if (!m_lastNodeInserted) {
- lastPositionToSelect = endingSelection().end().downstream();
+ lastPositionToSelect = endingSelection().end().downstream(DoNotStayInBlock);
}
else {
bool insertParagraph = false;
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);
}
}
}
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);
}
using DOM::Range;
using DOM::RangeImpl;
using DOM::StayInBlock;
+using DOM::DoNotStayInBlock;
namespace khtml {
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());
// 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;