[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:32:34 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 4e68c769644b7074dd91555906fd10bae916788a
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Apr 6 23:08:51 2004 +0000

    Tests:
    
            Reviewed by Richard
    
            Default document is now blank, since blinking a caret in
            an empty document is now supported.
    
            Added some code to move the caret to the start of the
            body element after loading it.
    
            Improved the code which makes the whole document
            contenteditable (by checking for and setting contenteditable,
            if needed).
    
            * Blot/BlotDocument.m:
            (-[BlotDocument webView:didFinishLoadForFrame:]):
            * Blot/Resources/default.html:
    
    WebCore:
    
            Reviewed by Richard
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::setSelection): Now calls setFocusNodeIfNeeded.
            (KHTMLPart::takeSelectionFrom): Now calls setFocusNodeIfNeeded.
            (KHTMLPart::clearSelection): Now calls setFocusNodeIfNeeded.
            (KHTMLPart::invalidateSelection): Now calls setFocusNodeIfNeeded.
            (KHTMLPart::setSelectionVisible): Now calls setFocusNodeIfNeeded.
            (KHTMLPart::setFocusNodeIfNeeded): New function focuses first element
            of a selection that is contenteditable, if any of the nodes are. The "first"
            determination is made by doing a document-order search.
            * khtml/khtml_part.h:
            * khtml/xml/dom_nodeimpl.cpp: Remove debug spam.
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge setSelectedDOMRange:]): Now updates document layout before
            setting the selection. This was needed for Blot, so that setting the
            contenteditable attribute on the body is "seen" when the attempt is made
            to set the selection right immediately after.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6321 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index cfdcf4b..c20377b 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,24 @@
+2004-04-06  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Richard
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::setSelection): Now calls setFocusNodeIfNeeded.
+        (KHTMLPart::takeSelectionFrom): Now calls setFocusNodeIfNeeded.
+        (KHTMLPart::clearSelection): Now calls setFocusNodeIfNeeded.
+        (KHTMLPart::invalidateSelection): Now calls setFocusNodeIfNeeded.
+        (KHTMLPart::setSelectionVisible): Now calls setFocusNodeIfNeeded.
+        (KHTMLPart::setFocusNodeIfNeeded): New function focuses first element 
+        of a selection that is contenteditable, if any of the nodes are. The "first"
+        determination is made by doing a document-order search.
+        * khtml/khtml_part.h:
+        * khtml/xml/dom_nodeimpl.cpp: Remove debug spam.
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge setSelectedDOMRange:]): Now updates document layout before
+        setting the selection. This was needed for Blot, so that setting the 
+        contenteditable attribute on the body is "seen" when the attempt is made
+        to set the selection right immediately after.
+
 2004-04-06  David Hyatt  <hyatt at apple.com>
 
 	After columns have been expanded to their preferred sizes, if space is left over in the table, then
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 695c9e0..3a9ed7f 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -2472,6 +2472,7 @@ void KHTMLPart::setSelection(const KHTMLSelection &s)
 {
     if (d->m_selection != s) {
         clearCaretRectIfNeeded(); 
+        setFocusNodeIfNeeded(s);
         d->m_selection = s;
         notifySelectionChanged();
     }
@@ -2487,6 +2488,7 @@ void KHTMLPart::takeSelectionFrom(const EditCommand &cmd, bool useEndingSelectio
     
     if (d->m_selection != s) {
         clearCaretRectIfNeeded();        
+        setFocusNodeIfNeeded(s);
         d->m_selection = s;
         notifySelectionChanged(false);
     }
@@ -2495,6 +2497,7 @@ void KHTMLPart::takeSelectionFrom(const EditCommand &cmd, bool useEndingSelectio
 void KHTMLPart::clearSelection()
 {
     clearCaretRectIfNeeded();
+    setFocusNodeIfNeeded(d->m_selection);
     d->m_selection = KHTMLSelection();
     notifySelectionChanged();
 }
@@ -2508,6 +2511,7 @@ void KHTMLPart::deleteSelection()
 void KHTMLPart::invalidateSelection()
 {
     clearCaretRectIfNeeded();
+    setFocusNodeIfNeeded(d->m_selection);
     d->m_selection.setNeedsLayout();
     notifySelectionChanged(false);
 }
@@ -2518,6 +2522,7 @@ void KHTMLPart::setSelectionVisible(bool flag)
         return;
 
     clearCaretRectIfNeeded();
+    setFocusNodeIfNeeded(d->m_selection);
     d->m_caretVisible = flag;
     notifySelectionChanged();
 }
@@ -2539,6 +2544,33 @@ void KHTMLPart::clearCaretRectIfNeeded()
     }        
 }
 
+void KHTMLPart::setFocusNodeIfNeeded(const KHTMLSelection &s)
+{
+    if (!xmlDocImpl() || s.state() == KHTMLSelection::NONE)
+        return;
+
+    NodeImpl *n = s.startNode();
+    NodeImpl *target = n->isContentEditable() ? n : 0;
+    if (!target) {
+        while (n != s.endNode()) {
+            if (n->isContentEditable()) {
+                target = n;
+                break;
+            }
+            n = n->traverseNextNode();
+        }
+    }
+    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);
+    }
+}
+
 void KHTMLPart::notifySelectionChanged(bool endTyping)
 {
     // kill any caret blink timer now running
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 4fb2241..64d4945 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -1105,6 +1105,11 @@ private:
   /**
    * @internal
    */
+  void setFocusNodeIfNeeded(const KHTMLSelection &);
+
+  /**
+   * @internal
+   */
   void notifySelectionChanged(bool endTyping=true);
 
   /**
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index f526e91..d849c73 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -2039,7 +2039,6 @@ void NodeBaseImpl::setFocus(bool received)
     if (received && isEditableBlock() && !hasChildNodes()) {
         KHTMLPart *part = getDocument()->part();
         part->setSelection(KHTMLSelection(this, 0));
-        fprintf(stderr, "place caret in me\n");
     }
 
     // note that we need to recalc the style
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 516402c..d0194d0 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1327,6 +1327,13 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
 {
     NodeImpl *startContainer = [[range startContainer] _nodeImpl];
     NodeImpl *endContainer = [[range endContainer] _nodeImpl];
+    ASSERT(startContainer);
+    ASSERT(endContainer);
+    ASSERT(startContainer->getDocument());
+    ASSERT(startContainer->getDocument() == endContainer->getDocument());
+    
+    DocumentImpl *doc = startContainer->getDocument();
+    doc->updateLayout();
     KHTMLSelection selection(startContainer, [range startOffset], endContainer, [range endOffset]);
     _part->setSelection(selection);
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list