<rdar://problem/
3834917> REGRESSION (Mail): double-clicking blank line selects end of previous line
Fixed originally reported bug plus the case of double-clicking whitespace at the beginning of a line, which has a similar result.
* khtml/editing/visible_text.cpp:
(khtml::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
(khtml::SimplifiedBackwardsTextIterator::handleTextNode):
(khtml::SimplifiedBackwardsTextIterator::handleReplacedElement):
(khtml::SimplifiedBackwardsTextIterator::handleNonTextNode):
(khtml::SimplifiedBackwardsTextIterator::emitCharacter):
Distinguish BR from whitespace.
* khtml/editing/visible_text.h:
Distinguish BR from whitespace.
* khtml/editing/visible_units.cpp:
(khtml::previousWordBoundary):
Use UPSTREAM visible position now that SimplifiedBackwardsTextIterator distinguishes BR from whitespace. Otherwise, double-clicking at end of line would result in caret selection at start of next line.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8101
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-12-02 David Harrison <harrison@apple.com>
+
+ Reviewed by Ken Kocienda.
+
+ <rdar://problem/3834917> REGRESSION (Mail): double-clicking blank line selects end of previous line
+ Fixed originally reported bug plus the case of double-clicking whitespace at the beginning of a line, which has a similar result.
+
+ * khtml/editing/visible_text.cpp:
+ (khtml::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
+ (khtml::SimplifiedBackwardsTextIterator::handleTextNode):
+ (khtml::SimplifiedBackwardsTextIterator::handleReplacedElement):
+ (khtml::SimplifiedBackwardsTextIterator::handleNonTextNode):
+ (khtml::SimplifiedBackwardsTextIterator::emitCharacter):
+ Distinguish BR from whitespace.
+ * khtml/editing/visible_text.h:
+ Distinguish BR from whitespace.
+ * khtml/editing/visible_units.cpp:
+ (khtml::previousWordBoundary):
+ Use UPSTREAM visible position now that SimplifiedBackwardsTextIterator distinguishes BR from whitespace. Otherwise, double-clicking at end of line would result in caret selection at start of next line.
+
2004-12-02 Ken Kocienda <kocienda@apple.com>
Reviewed by John
m_positionNode = endNode;
#endif
+ m_lastTextNode = 0;
+ m_lastCharacter = '\n';
+
advance();
}
bool SimplifiedBackwardsTextIterator::handleTextNode()
{
+ m_lastTextNode = m_node;
+
RenderText *renderer = static_cast<RenderText *>(m_node->renderer());
DOMString str = m_node->nodeValue();
m_textLength = m_positionEndOffset - m_positionStartOffset;
m_textCharacters = str.unicode() + m_positionStartOffset;
+ m_lastCharacter = str[m_positionEndOffset - 1];
+
return true;
}
m_textCharacters = 0;
m_textLength = 0;
+ m_lastCharacter = 0;
+
return true;
}
{
switch (m_node->id()) {
case ID_BR:
+ {
+ long offset;
+
+ if (m_lastTextNode) {
+ offset = m_lastTextNode->nodeIndex();
+ emitCharacter('\n', m_lastTextNode->parentNode(), offset, offset + 1);
+ } else {
+ offset = m_node->nodeIndex();
+ emitCharacter('\n', m_node->parentNode(), offset, offset + 1);
+ }
+ break;
+ }
+
case ID_TD:
case ID_TH:
case ID_BLOCKQUOTE:
case ID_H5:
case ID_H6:
case ID_HR:
- case ID_LI:
- case ID_OL:
case ID_P:
case ID_PRE:
case ID_TR:
+ case ID_OL:
case ID_UL:
+ case ID_LI:
// Emit a space to "break up" content. Any word break
// character will do.
emitCharacter(' ', m_node, 0, 0);
m_positionEndOffset = endOffset;
m_textCharacters = &m_singleCharacterBuffer;
m_textLength = 1;
+ m_lastCharacter = c;
}
Range SimplifiedBackwardsTextIterator::range() const
long m_positionEndOffset;
const QChar *m_textCharacters;
long m_textLength;
+
+ // Used to do the whitespace logic.
+ DOM::NodeImpl *m_lastTextNode;
+ QChar m_lastCharacter;
// Used for whitespace characters that aren't in the DOM, so we can point at them.
QChar m_singleCharacterBuffer;
pos = Position(node, it.range().startOffset());
}
}
- // Use DOWNSTREAM here so that we don't jump past words at the start of lines.
- // <rdar://problem/3765519> REGRESSION (Mail): word movement goes too far upstream at start of line
- return VisiblePosition(pos);
+
+ return VisiblePosition(pos, UPSTREAM);
}
static VisiblePosition nextWordBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))