Reviewed by Harrison
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Nov 2004 22:13:42 +0000 (22:13 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Nov 2004 22:13:42 +0000 (22:13 +0000)
        * khtml/xml/dom_position.cpp:
        (DOM::Position::downstream): Fix a bug in downstream that prevented a call with DoNotStayInBlock
        specified from obeying that directive. The old code would stop at an outer block boundary in
        the case where that block had a block as its first child. The correct behavior is to drill into
        that inner block (and continue on drilling down, if possible), to find the correct position.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/xml/dom_position.cpp

index 5077bbbdacf1b8a4967fdb2980e60f436f7d7ef0..490f237d7b8cb7d6dde2da59a0c516bbb1c966d0 100644 (file)
@@ -1,3 +1,13 @@
+2004-11-29  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Harrison
+
+        * khtml/xml/dom_position.cpp:
+        (DOM::Position::downstream): Fix a bug in downstream that prevented a call with DoNotStayInBlock
+        specified from obeying that directive. The old code would stop at an outer block boundary in
+        the case where that block had a block as its first child. The correct behavior is to drill into
+        that inner block (and continue on drilling down, if possible), to find the correct position.
+
 2004-11-29  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Harrison
index 91ba1f12664b14466c5ecf8730ffdb12b1183d88..6b931a05ce22ae594e4afd73993bccb39239ca5e 100644 (file)
@@ -443,7 +443,20 @@ Position Position::downstream(EStayInBlock stayInBlock) const
         if (renderer->style()->visibility() != VISIBLE)
             continue;
 
-        if ((currentNode != startNode && renderer->isBlockFlow()) || renderer->isReplaced() || renderer->isBR()) {
+        if (currentNode != startNode && renderer->isBlockFlow()) {
+            if (it.current().offset() == 0) {
+                NodeImpl *node = currentNode;
+                while (NodeImpl *firstChild = node->firstChild()) {
+                    if (node->renderer()->style()->visibility() == VISIBLE && node->renderer()->isBlockFlow())
+                        node = firstChild;
+                }
+                return Position(node, 0);
+            }
+            else
+                continue;
+        }
+
+        if (renderer->isReplaced() || renderer->isBR()) {
             if (it.current().offset() <= renderer->caretMinOffset())
                 return Position(currentNode, renderer->caretMinOffset());
             else