+2004-11-30 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by John
+
+ Fix for this bug:
+
+ <rdar://problem/3863031> REGRESSION (Mail): caret continues flashing while mouse is down
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::timerEvent): Add a check for whether the mouse is down. Keep the caret drawn
+ with no blink if it is.
+
+2004-11-30 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by John
+
+ Fix for this bug:
+
+ <rdar://problem/3861602> cursor gets lost trying to backspace to delete a form control
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::setFocusNodeIfNeeded): This function would clear the selection if a <button>
+ or <input type=image> was checked for focus since these elements are keyboard-focusable,
+ but not mouse focusable. Also, this function did not work hard enough to set the focused
+ node, and was content to clear it if the first element checked failed the test, rather
+ than looking more at parents. This would have the effect of clearing, then resetting the
+ focus on a DIV containing a button or image with content on either side of it in the
+ process of arrowing over such content.
+
+2004-11-30 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by John
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::ReplaceSelectionCommand::doApply): Fix smart replace, which I (knowingly) broke with yesterday's checkin.
+ Also, call updateLayout() in one more place to prevent stale information being returned from caretMaxOffset().
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::isCharacterSmartReplaceExempt): Make this virtual and always return true. This gets rid of an
+ ugly APPLE_CHANGES block and use of KWQ(part) in ReplaceSelectionCommand.
+ * khtml/khtml_part.h: To help out with the isCharacterSmartReplaceExempt cleanup, add declaration.
+ * kwq/KWQKHTMLPart.h: To help out with the isCharacterSmartReplaceExempt cleanup, make
+ isCharacterSmartReplaceExempt virtual.
+
2004-11-30 Ken Kocienda <kocienda@apple.com>
Reviewed by me
bool addTrailingSpace = false;
if (m_smartReplace) {
addLeadingSpace = startPos.leadingWhitespacePosition().isNull();
- addTrailingSpace = endPos.trailingWhitespacePosition().isNull();
- }
-
-#if APPLE_CHANGES
- if (addLeadingSpace) {
- QChar previousChar = VisiblePosition(startPos).previous().character();
- if (!previousChar.isNull()) {
- addLeadingSpace = !KWQ(part)->isCharacterSmartReplaceExempt(previousChar, true);
+ if (addLeadingSpace) {
+ QChar previousChar = VisiblePosition(startPos).previous().character();
+ if (!previousChar.isNull()) {
+ addLeadingSpace = !part->isCharacterSmartReplaceExempt(previousChar, true);
+ }
}
- }
- if (addTrailingSpace) {
- QChar thisChar = VisiblePosition(endPos).character();
- if (!thisChar.isNull()) {
- addTrailingSpace = !KWQ(part)->isCharacterSmartReplaceExempt(thisChar, false);
+ addTrailingSpace = endPos.trailingWhitespacePosition().isNull();
+ if (addTrailingSpace) {
+ QChar thisChar = VisiblePosition(endPos).character();
+ if (!thisChar.isNull()) {
+ addTrailingSpace = !part->isCharacterSmartReplaceExempt(thisChar, false);
+ }
}
}
-#endif
document()->updateLayout();
refNode = node;
node = next;
}
+ document()->updateLayout();
insertionPos = Position(lastNodeInserted, lastNodeInserted->caretMaxOffset());
}
+ // Handle "smart replace" whitespace
+ if (addTrailingSpace && lastNodeInserted) {
+ if (lastNodeInserted->isTextNode()) {
+ TextImpl *text = static_cast<TextImpl *>(lastNodeInserted);
+ insertTextIntoNode(text, text->length(), nonBreakingSpaceString());
+ insertionPos = Position(text, text->length());
+ }
+ else {
+ NodeImpl *node = document()->createEditingTextNode(nonBreakingSpaceString());
+ insertNodeAfter(node, lastNodeInserted);
+ if (!firstNodeInserted)
+ firstNodeInserted = node;
+ lastNodeInserted = node;
+ insertionPos = Position(node, 1);
+ }
+ }
+
+ if (addLeadingSpace && firstNodeInserted) {
+ if (firstNodeInserted->isTextNode()) {
+ TextImpl *text = static_cast<TextImpl *>(firstNodeInserted);
+ insertTextIntoNode(text, 0, nonBreakingSpaceString());
+ }
+ else {
+ NodeImpl *node = document()->createEditingTextNode(nonBreakingSpaceString());
+ insertNodeBefore(node, firstNodeInserted);
+ firstNodeInserted = node;
+ if (!lastNodeInsertedInMergeEnd)
+ lastNodeInserted = node;
+ }
+ }
+
+ // Handle trailing newline
if (m_fragment.hasInterchangeNewlineComment()) {
if (startBlock == endBlock && !isProbablyBlock(lastNodeInserted)) {
setEndingSelection(insertionPos);
assert(target == 0 || target->isContentEditable());
if (target) {
- for ( ; target && !target->isFocusable(); target = target->parentNode()); // loop
- if (target && target->isMouseFocusable())
- xmlDocImpl()->setFocusNode(target);
- else if (!target || !target->focused())
- xmlDocImpl()->setFocusNode(0);
+ for ( ; target; target = target->parentNode()) {
+ if (target->isMouseFocusable()) {
+ xmlDocImpl()->setFocusNode(target);
+ return;
+ }
+ }
+ xmlDocImpl()->setFocusNode(0);
}
}
d->m_caretVisible &&
d->m_caretBlinks &&
d->m_selection.isCaret()) {
- d->m_caretPaint = !d->m_caretPaint;
- d->m_selection.needsCaretRepaint();
+ if (d->m_bMousePressed) {
+ if (!d->m_caretPaint) {
+ d->m_caretPaint = true;
+ d->m_selection.needsCaretRepaint();
+ }
+ }
+ else {
+ d->m_caretPaint = !d->m_caretPaint;
+ d->m_selection.needsCaretRepaint();
+ }
}
}
#endif
+bool KHTMLPart::isCharacterSmartReplaceExempt(const QChar &, bool)
+{
+ // no smart replace
+ return true;
+}
+
void KHTMLPart::connectChild(const khtml::ChildFrame *child) const
{
ReadOnlyPart *part = child->m_part;
void applyEditingStyleToElement(DOM::ElementImpl *) const;
void removeEditingStyleFromElement(DOM::ElementImpl *) const;
void print();
+ virtual bool isCharacterSmartReplaceExempt(const QChar &, bool);
// Used to keep the part alive when running a script that might destroy it.
void keepAlive();
NSMutableDictionary *dashboardRegionsDictionary();
void dashboardRegionsChanged();
- bool isCharacterSmartReplaceExempt(const QChar &, bool);
+ virtual bool isCharacterSmartReplaceExempt(const QChar &, bool);
private:
virtual void khtmlMousePressEvent(khtml::MousePressEvent *);