Reviewed by John
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2004 16:33:40 +0000 (16:33 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2004 16:33:40 +0000 (16:33 +0000)
        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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8089 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting.cpp
WebCore/khtml/khtml_part.cpp
WebCore/khtml/khtml_part.h
WebCore/kwq/KWQKHTMLPart.h

index 91b8b4b21b325caea4dba25ac1c5c83d21c6f845..e2d9dfc7aab31ddfc806d30763fc675c7760580f 100644 (file)
@@ -1,3 +1,46 @@
+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
index 6b4082e9b2b45e0ccff8bfdb676181f47fbe623c..272376809fbc2e2cf84213fce30ca82c6cf0aa05 100644 (file)
@@ -2920,23 +2920,20 @@ void ReplaceSelectionCommand::doApply()
     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();
 
@@ -3030,9 +3027,42 @@ void ReplaceSelectionCommand::doApply()
             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);
index 3bc8b2d33bb63efa4df5d60b1cbf3944aa726ad6..8c4d457854eac3f988b73505523b4f5bee25ed49 100644 (file)
@@ -2470,11 +2470,13 @@ void KHTMLPart::setFocusNodeIfNeeded()
     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);
     }
 }
 
@@ -2514,8 +2516,16 @@ void KHTMLPart::timerEvent(QTimerEvent *e)
         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();
+        }
     }
 }
 
@@ -5626,6 +5636,12 @@ void KHTMLPart::print()
 
 #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;
index 663923c623cbaf87fb82168120eabfa244eafa5d..0f8c6fce5c63abf6d23b2b6cd9566f9fee156d83 100644 (file)
@@ -898,6 +898,7 @@ public:
   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();
index 106cac972781109646cc43f9c34f533e6b6d78a6..f88d1aba070f3139e538bb35889ac02b72f2505f 100644 (file)
@@ -360,7 +360,7 @@ public:
     NSMutableDictionary *dashboardRegionsDictionary();
     void dashboardRegionsChanged();
     
-    bool isCharacterSmartReplaceExempt(const QChar &, bool);
+    virtual bool isCharacterSmartReplaceExempt(const QChar &, bool);
     
 private:
     virtual void khtmlMousePressEvent(khtml::MousePressEvent *);