+2004-11-10 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Harrison
+
+ (khtml::DeleteSelectionCommand::performGeneralDelete): Add some more comments to
+ make things more clear.
+ * khtml/editing/selection.cpp:
+ (khtml::Selection::toRange): Fixed the upstream and downstream calls so that the
+ resulting positions do not cross block boundaries. This was a bug and caused some
+ delete problems when whole blocks were selected. I will be addressing that issue
+ more fully in upcoming changes.
+
2004-11-10 Ken Kocienda <kocienda@apple.com>
Reviewed by Harrison
// ^ selected
//
ASSERT(isRange());
- s = m_start.downstream();
- e = m_end.upstream();
+ s = m_start.downstream(StayInBlock);
+ e = m_end.upstream(StayInBlock);
if (RangeImpl::compareBoundaryPoints(s.node(), s.offset(), e.node(), e.offset()) > 0) {
// Make sure the start is before the end.
// The end can wind up before the start if collapsed whitespace is the only thing selected.
Position rootEnd = Position(rootElement, rootElement ? rootElement->childNodeCount() : 0).equivalentDeepPosition();
if (pos == VisiblePosition(rootEnd).deepEquivalent())
pos = rootEnd;
- else if (m_smartDelete && pos.leadingWhitespacePosition().isNotNull())
+ else if (m_smartDelete && pos.trailingWhitespacePosition().isNotNull())
pos = VisiblePosition(pos).next().deepEquivalent();
return pos;
}
int startOffset = m_upstreamStart.offset();
if (startOffset >= m_startNode->caretMaxOffset()) {
+ // Move the start node to the next node in the tree since the startOffset is equal to
+ // or beyond the start node's caretMaxOffset This means there is nothing visible to delete.
+ // However, before moving on, delete any insignificant text that may be present in a text node.
if (m_startNode->isTextNode()) {
// Delete any insignificant text from this node.
TextImpl *text = static_cast<TextImpl *>(m_startNode);
}
if (m_startNode == m_downstreamEnd.node()) {
- // handle delete in one node
+ // The selection to delete is all in one node.
if (!m_startNode->renderer() ||
(startOffset <= m_startNode->caretMinOffset() && m_downstreamEnd.offset() >= m_startNode->caretMaxOffset())) {
// just delete
}
}
else {
+ // The selection to delete spans more than one node.
NodeImpl *node = m_startNode;
if (startOffset > 0) {
// ^ selected
//
ASSERT(isRange());
- s = m_start.downstream();
- e = m_end.upstream();
+ s = m_start.downstream(StayInBlock);
+ e = m_end.upstream(StayInBlock);
if (RangeImpl::compareBoundaryPoints(s.node(), s.offset(), e.node(), e.offset()) > 0) {
// Make sure the start is before the end.
// The end can wind up before the start if collapsed whitespace is the only thing selected.