[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:33:05 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit aa4ca4292705f61c53a5e2f747a78b45795f84f7
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Apr 9 14:13:42 2004 +0000

            Reviewed by Dave
    
            Small collection of editing improvements.
    
            * ChangeLog:
            * khtml/editing/htmlediting_impl.cpp:
            (shouldDeleteUpstreamPosition): This was deleting significant spaces on preceding
            lines when the caret was at the start of a line. Fixed.
            (DeleteSelectionCommandImpl::doApply): Fixed a case where caret jumped to previous
            line when deleting a character at the start of a line after a BR.
            (InputNewlineCommandImpl::doApply): Handle more cases correctly. Previously, this
            only handled inserting a newline when the caret was already in a text node.
            (InputTextCommandImpl::prepareForTextInsertion): Ditto.
            (InputTextCommandImpl::execute): Ditto.
            * khtml/editing/htmlediting_impl.h:
            * khtml/rendering/render_block.cpp:
            (khtml::RenderBlock::checkSelectionPointIgnoringContinuations): Now can place caret
            with a click in an empty block.
            * khtml/rendering/render_block.h: Added checkSelectionPointIgnoringContinuations declaration.
            * khtml/rendering/render_replaced.cpp:
            (RenderReplaced::checkSelectionPointIgnoringContinuations): Now can place caret with a click
            on a replaced element.
            * khtml/rendering/render_replaced.h: Added checkSelectionPointIgnoringContinuations declaration.
            * khtml/rendering/render_text.cpp:
            (InlineTextBox::checkSelectionPoint): Now can place caret with a click in text on a line made "tall"
            by an image on the same line.
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::createEditingTextNode): This creates a text node subclass that whill always create
            a renderer for itself.
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_position.cpp:
            (DOMPosition::isLastRenderedPositionInEditableBlock): Improved code to handle more cases.
            * khtml/xml/dom_textimpl.cpp:
            (TextImpl::TextImpl): Rolled out m_rendererIsNeeded flag.
            (TextImpl::rendererIsNeeded): Ditto.
            (EditingTextImpl::EditingTextImpl): New class.
            (EditingTextImpl::~EditingTextImpl): New.
            (EditingTextImpl::rendererIsNeeded): New. Always returns true.
            * khtml/xml/dom_textimpl.h: New EditingTextImpl class.
            * layout-tests/editing/deleting/delete-3608430-fix-expected.txt: Added.
            * layout-tests/editing/deleting/delete-3608430-fix.html: Added.
            * layout-tests/editing/deleting/delete-3608462-fix-expected.txt: Added.
            * layout-tests/editing/deleting/delete-3608462-fix.html: Added.
            * layout-tests/editing/deleting/delete-trailing-ws-002-expected.txt: Added.
            * layout-tests/editing/deleting/delete-trailing-ws-002.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6341 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/editing/deleting/delete-selection-001-expected.txt b/LayoutTests/editing/deleting/delete-3608430-fix-expected.txt
similarity index 73%
copy from LayoutTests/editing/deleting/delete-selection-001-expected.txt
copy to LayoutTests/editing/deleting/delete-3608430-fix-expected.txt
index 4f53612..255efbf 100644
--- a/LayoutTests/editing/deleting/delete-selection-001-expected.txt
+++ b/LayoutTests/editing/deleting/delete-3608430-fix-expected.txt
@@ -4,10 +4,9 @@ layer at (0,0) size 800x72
   RenderBlock {HTML} at (0,0) size 800x72
     RenderBody {BODY} at (8,8) size 784x56
       RenderBlock {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
-        RenderInline {SPAN} at (0,0) size 77x28
-          RenderText {TEXT} at (14,14) size 77x28
-            text run at (14,14) width 43: " bar "
-            text run at (57,14) width 34: "baz"
+        RenderInline {SPAN} at (0,0) size 129x28
+          RenderText {TEXT} at (14,14) size 129x28
+            text run at (14,14) width 129: "start-deleting"
         RenderText {TEXT} at (0,0) size 0x0
 selection is CARET:
 start:      position 0 of child 1 {TEXT} of child 1 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-leading-ws-001.html b/LayoutTests/editing/deleting/delete-3608430-fix.html
similarity index 71%
copy from LayoutTests/editing/deleting/delete-leading-ws-001.html
copy to LayoutTests/editing/deleting/delete-3608430-fix.html
index a78d29f..446cbcb 100644
--- a/LayoutTests/editing/deleting/delete-leading-ws-001.html
+++ b/LayoutTests/editing/deleting/delete-3608430-fix.html
@@ -13,13 +13,12 @@
 <script>
 
 function editingTest() {
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < 28; i++) {
         moveSelectionForwardByCharacterCommand();    
     }
-    for (i = 0; i < 4; i++) {
-        extendSelectionForwardByCharacterCommand();    
+    for (i = 0; i < 28; i++) {
+        deleteCommand(); 
     }
-    deleteCommand();
 }
 
 </script>
@@ -28,7 +27,8 @@ function editingTest() {
 </head> 
 <body>
 <div contenteditable id="root" class="editing">
-<span id="test">f   baz</span>
+<span id="test">foo 
+<br>foo <i>  </i> <img src="../abe.gif""> select-in-me-and-start-deleting</span>
 </div>
 
 <script>
diff --git a/LayoutTests/editing/deleting/delete-3608462-fix-expected.txt b/LayoutTests/editing/deleting/delete-3608462-fix-expected.txt
new file mode 100644
index 0000000..b69ffa1
--- /dev/null
+++ b/LayoutTests/editing/deleting/delete-3608462-fix-expected.txt
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x262
+  RenderBlock {HTML} at (0,0) size 800x262
+    RenderBody {BODY} at (8,8) size 784x246
+      RenderBlock {DIV} at (0,0) size 784x246 [border: (2px solid #FF0000)]
+        RenderInline {SPAN} at (0,0) size 181x137
+          RenderText {TEXT} at (14,95) size 11x28
+            text run at (14,95) width 11: "a"
+          RenderImage {IMG} at (25,14) size 76x103
+          RenderText {TEXT} at (101,95) size 46x28
+            text run at (101,95) width 46: "new "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderImage {IMG} at (14,123) size 76x103
+          RenderText {TEXT} at (90,204) size 105x28
+            text run at (90,204) width 105: " conceived"
+        RenderText {TEXT} at (0,0) size 0x0
+selection is CARET:
+start:      position 0 of child 5 {IMG} of child 2 {SPAN} of root {DIV}
+upstream:   position 1 of child 4 {BR} of child 2 {SPAN} of root {DIV}
+downstream: position 0 of child 5 {IMG} of child 2 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-leading-ws-001.html b/LayoutTests/editing/deleting/delete-3608462-fix.html
similarity index 75%
copy from LayoutTests/editing/deleting/delete-leading-ws-001.html
copy to LayoutTests/editing/deleting/delete-3608462-fix.html
index a78d29f..b2e0dac 100644
--- a/LayoutTests/editing/deleting/delete-leading-ws-001.html
+++ b/LayoutTests/editing/deleting/delete-3608462-fix.html
@@ -13,13 +13,12 @@
 <script>
 
 function editingTest() {
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < 11; i++) {
         moveSelectionForwardByCharacterCommand();    
     }
     for (i = 0; i < 4; i++) {
-        extendSelectionForwardByCharacterCommand();    
+        deleteCommand(); 
     }
-    deleteCommand();
 }
 
 </script>
@@ -28,7 +27,8 @@ function editingTest() {
 </head> 
 <body>
 <div contenteditable id="root" class="editing">
-<span id="test">f   baz</span>
+<span id="test">a<img src="../abe.jpg">new 
+<br>foo <i>  </i> <img src="../abe.jpg"> conceived</span>
 </div>
 
 <script>
diff --git a/LayoutTests/editing/deleting/delete-br-005-expected.txt b/LayoutTests/editing/deleting/delete-trailing-ws-002-expected.txt
similarity index 54%
copy from LayoutTests/editing/deleting/delete-br-005-expected.txt
copy to LayoutTests/editing/deleting/delete-trailing-ws-002-expected.txt
index 8865591..e718063 100644
--- a/LayoutTests/editing/deleting/delete-br-005-expected.txt
+++ b/LayoutTests/editing/deleting/delete-trailing-ws-002-expected.txt
@@ -3,15 +3,13 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x100
   RenderBlock {HTML} at (0,0) size 800x100
     RenderBody {BODY} at (8,8) size 784x84
-      RenderBlock {DIV} at (0,0) size 628x84 [border: (2px solid #FF0000)]
-        RenderInline {SPAN} at (0,0) size 204x56
-          RenderText {TEXT} at (14,14) size 204x28
-            text run at (14,14) width 102: "Fourscore "
-            text run at (116,14) width 41: "and "
-            text run at (157,14) width 61: "seven "
+      RenderBlock {DIV} at (0,0) size 784x84 [border: (2px solid #FF0000)]
+        RenderInline {SPAN} at (0,0) size 40x56
+          RenderText {TEXT} at (14,14) size 32x28
+            text run at (14,14) width 32: "foo"
           RenderBR {BR} at (0,0) size 0x0
-          RenderText {TEXT} at (14,42) size 92x28
-            text run at (14,42) width 92: "years ago"
+          RenderText {TEXT} at (14,42) size 40x28
+            text run at (14,42) width 40: " baz"
         RenderText {TEXT} at (0,0) size 0x0
 selection is CARET:
 start:      position 0 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
diff --git a/LayoutTests/editing/deleting/delete-character-001.html b/LayoutTests/editing/deleting/delete-trailing-ws-002.html
similarity index 78%
copy from LayoutTests/editing/deleting/delete-character-001.html
copy to LayoutTests/editing/deleting/delete-trailing-ws-002.html
index 6776857..3b61c06 100644
--- a/LayoutTests/editing/deleting/delete-character-001.html
+++ b/LayoutTests/editing/deleting/delete-trailing-ws-002.html
@@ -13,10 +13,12 @@
 <script>
 
 function editingTest() {
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < 7; i++) {
         moveSelectionForwardByCharacterCommand();    
     }
-    deleteCommand();
+    for (i = 0; i < 3; i++) {
+        deleteCommand(); 
+    }
 }
 
 </script>
@@ -25,7 +27,7 @@ function editingTest() {
 </head> 
 <body>
 <div contenteditable id="root" class="editing">
-<span id="test">foo   bar    baz</span>
+<span id="test">foo<br>bar baz</span>
 </div>
 
 <script>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 71dfd9b..2784451 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,51 @@
+2004-04-09  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Dave
+        
+        Small collection of editing improvements.
+
+        * ChangeLog:
+        * khtml/editing/htmlediting_impl.cpp:
+        (shouldDeleteUpstreamPosition): This was deleting significant spaces on preceding
+        lines when the caret was at the start of a line. Fixed. 
+        (DeleteSelectionCommandImpl::doApply): Fixed a case where caret jumped to previous
+        line when deleting a character at the start of a line after a BR.
+        (InputNewlineCommandImpl::doApply): Handle more cases correctly. Previously, this
+        only handled inserting a newline when the caret was already in a text node.
+        (InputTextCommandImpl::prepareForTextInsertion): Ditto.
+        (InputTextCommandImpl::execute): Ditto.
+        * khtml/editing/htmlediting_impl.h:
+        * khtml/rendering/render_block.cpp:
+        (khtml::RenderBlock::checkSelectionPointIgnoringContinuations): Now can place caret
+        with a click in an empty block.
+        * khtml/rendering/render_block.h: Added checkSelectionPointIgnoringContinuations declaration.
+        * khtml/rendering/render_replaced.cpp: 
+        (RenderReplaced::checkSelectionPointIgnoringContinuations): Now can place caret with a click 
+        on a replaced element.
+        * khtml/rendering/render_replaced.h: Added checkSelectionPointIgnoringContinuations declaration.
+        * khtml/rendering/render_text.cpp:
+        (InlineTextBox::checkSelectionPoint): Now can place caret with a click in text on a line made "tall"
+        by an image on the same line.
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::createEditingTextNode): This creates a text node subclass that whill always create
+        a renderer for itself.
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_position.cpp:
+        (DOMPosition::isLastRenderedPositionInEditableBlock): Improved code to handle more cases.
+        * khtml/xml/dom_textimpl.cpp:
+        (TextImpl::TextImpl): Rolled out m_rendererIsNeeded flag.
+        (TextImpl::rendererIsNeeded): Ditto.
+        (EditingTextImpl::EditingTextImpl): New class.
+        (EditingTextImpl::~EditingTextImpl): New.
+        (EditingTextImpl::rendererIsNeeded): New. Always returns true.
+        * khtml/xml/dom_textimpl.h: New EditingTextImpl class.
+        * layout-tests/editing/deleting/delete-3608430-fix-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-3608430-fix.html: Added.
+        * layout-tests/editing/deleting/delete-3608462-fix-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-3608462-fix.html: Added.
+        * layout-tests/editing/deleting/delete-trailing-ws-002-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-trailing-ws-002.html: Added.
+
 2004-04-08  Chris Blumenberg  <cblu at apple.com>
 
 	Renamed the PasteHTMLCommand to PasteMarkupCommand. Removed PasteImageCommand because we will use PasteMarkupCommand for pasting images.
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 276b90a..5c45aa2 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -54,6 +54,7 @@ using DOM::DocumentImpl;
 using DOM::DOMPosition;
 using DOM::DOMString;
 using DOM::DOMStringImpl;
+using DOM::EditingTextImpl;
 using DOM::EditIterator;
 using DOM::ElementImpl;
 using DOM::HTMLElementImpl;
@@ -625,7 +626,7 @@ static bool shouldDeleteUpstreamPosition(const DOMPosition &pos)
     if (pos.isLastRenderedPositionInEditableBlock())
         return false;
 
-    if (pos.isFirstRenderedPositionOnLine())
+    if (pos.isFirstRenderedPositionOnLine() || pos.isLastRenderedPositionOnLine())
         return false;
 
     RenderText *textRenderer = static_cast<RenderText *>(renderer);
@@ -836,7 +837,6 @@ void DeleteSelectionCommandImpl::doApply()
          (downstreamStart.offset() <= downstreamStart.node()->caretMinOffset()));
 
     unsigned long startRenderedOffset = downstreamStart.renderedOffset();
-    //unsigned long endRenderedOffset = upstreamEnd.renderedOffset();
     
     bool startAtStartOfRootEditableBlock = startRenderedOffset == 0 && downstreamStart.inFirstEditableInRootEditableBlock();
     bool startAtStartOfBlock = startAtStartOfRootEditableBlock || 
@@ -869,12 +869,14 @@ void DeleteSelectionCommandImpl::doApply()
         endingPosition = upstreamStart;
         if (downstreamStart.node()->id() == ID_BR && downstreamStart.offset() == 0)
             adjustEndingPositionDownstream = true;
+        if (upstreamStart.node()->id() == ID_BR && upstreamStart.offset() == 1)
+            adjustEndingPositionDownstream = true;
     }
    
     //
     // Figure out the whitespace conversions to do
     //
-    if (startAtStartOfBlock && !endAtEndOfBlock) {
+    if ((startAtStartOfBlock && !endAtEndOfBlock) || (!startCompletelySelected && adjustEndingPositionDownstream)) {
         // convert trailing whitespace
         DOMPosition trailing = trailingWhitespacePosition(downstreamEnd.equivalentDownstreamPosition());
         if (trailing.notEmpty()) {
@@ -1031,47 +1033,50 @@ int InputNewlineCommandImpl::commandID() const
 
 void InputNewlineCommandImpl::doApply()
 {
-    KHTMLSelection selection = endingSelection();
-
-    if (!selection.startNode()->isTextNode())
-        return;
-
-    // Delete the current selection
     deleteSelection();
-    
-    // reset the selection since it may have changed due to the delete
-    selection = endingSelection();
+    KHTMLSelection selection = endingSelection();
 
     int exceptionCode = 0;
     ElementImpl *breakNode = document()->createHTMLElement("BR", exceptionCode);
     ASSERT(exceptionCode == 0);
 
-    TextImpl *textNode = static_cast<TextImpl *>(selection.startNode());
-    bool atStart = selection.startOffset() == textNode->renderer()->caretMinOffset();
-    bool atEnd = selection.startOffset() == textNode->renderer()->caretMaxOffset();
-    if (atStart) {
-        // Set the cursor at the beginning of text node now following the new BR.
-        insertNodeBefore(breakNode, textNode);
-        selection = KHTMLSelection(textNode, 0);
-        setEndingSelection(selection);
+    DOMPosition pos = selection.startPosition().equivalentDownstreamPosition();
+    bool atEnd = pos.offset() >= pos.node()->caretMaxOffset();
+    bool atStart = pos.offset() <= pos.node()->caretMinOffset();
+    bool atEndOfBlock = pos.isLastRenderedPositionInEditableBlock();
+    
+    if (atEndOfBlock) {
+        LOG(Editing, "input newline case 1");
+        appendNode(pos.node()->containingEditableBlock(), breakNode);
+        // EDIT FIXME: This should not insert a non-breaking space after the BR.
+        // But for right now, it gets the BR to render.
+        TextImpl *editingTextNode = document()->createEditingTextNode(nonBreakingSpaceString());
+        insertNodeAfter(editingTextNode, breakNode);
+        setEndingSelection(DOMPosition(editingTextNode, 1));
+        editingTextNode->deref();
     }
     else if (atEnd) {
-        insertNodeAfter(breakNode, textNode);
-        // Set the cursor at the beginning of the the BR.
-        DOMPosition pos(breakNode, 0);
-        setEndingSelection(pos);
+        LOG(Editing, "input newline case 2");
+        insertNodeAfter(breakNode, pos.node());
+        setEndingSelection(DOMPosition(breakNode, 0));
+    }
+    else if (atStart) {
+        LOG(Editing, "input newline case 3");
+        insertNodeAt(breakNode, pos.node(), 0);
+        setEndingSelection(DOMPosition(pos.node(), 0));
     }
     else {
+        LOG(Editing, "input newline case 4");
+        ASSERT(pos.node()->isTextNode());
+        TextImpl *textNode = static_cast<TextImpl *>(pos.node());
         TextImpl *textBeforeNode = document()->createTextNode(textNode->substringData(0, selection.startOffset(), exceptionCode));
         deleteText(textNode, 0, selection.startOffset());
         insertNodeBefore(textBeforeNode, textNode);
         insertNodeBefore(breakNode, textNode);
         textBeforeNode->deref();
-        // Set the cursor at the beginning of the node after the BR.
-        selection = KHTMLSelection(textNode, 0);
-        setEndingSelection(selection);
+        setEndingSelection(DOMPosition(textNode, 0));
     }
-    
+        
     breakNode->deref();
 }
 
@@ -1124,34 +1129,41 @@ void InputTextCommandImpl::deleteCharacter()
     }
 }
 
-DOMPosition InputTextCommandImpl::prepareForTextInsertion()
+DOMPosition InputTextCommandImpl::prepareForTextInsertion(bool adjustDownstream)
 {
     // Prepare for text input by looking at the current position.
     // It may be necessary to insert a text node to receive characters.
     KHTMLSelection selection = endingSelection();
     ASSERT(selection.state() == KHTMLSelection::CARET);
     
-    DOMPosition pos = selection.startPosition().equivalentUpstreamPosition();
-    if (!pos.inRenderedContent())
-        pos = pos.nextRenderedEditablePosition();
-    if (!pos.node()->inSameContainingEditableBlock(selection.startNode()))
-        pos = selection.startPosition();
+    DOMPosition pos = selection.startPosition();
+    if (adjustDownstream)
+        pos = pos.equivalentDownstreamPosition();
+    else
+        pos = pos.equivalentUpstreamPosition();
     
     if (!pos.node()->isTextNode()) {
         if (!m_insertedTextNode) {
-            m_insertedTextNode = document()->createTextNode("");
-            m_insertedTextNode->setRendererIsNeeded();
+            m_insertedTextNode = document()->createEditingTextNode("");
             m_insertedTextNode->ref();
         }
         
-        if (pos.node()->isEditableBlock())
+        if (pos.node()->isEditableBlock()) {
+            LOG(Editing, "prepareForTextInsertion case 1");
             appendNode(pos.node(), m_insertedTextNode);
-        else if (pos.node()->id() == ID_BR && pos.offset() == 1)
+        }
+        else if (pos.node()->id() == ID_BR && pos.offset() == 1) {
+            LOG(Editing, "prepareForTextInsertion case 2");
             insertNodeBefore(m_insertedTextNode, pos.node());
-        else if (pos.node()->caretMinOffset() == pos.offset())
+        }
+        else if (pos.node()->caretMinOffset() == pos.offset()) {
+            LOG(Editing, "prepareForTextInsertion case 3");
             insertNodeBefore(m_insertedTextNode, pos.node());
-        else if (pos.node()->caretMaxOffset() == pos.offset())
+        }
+        else if (pos.node()->caretMaxOffset() == pos.offset()) {
+            LOG(Editing, "prepareForTextInsertion case 4");
             insertNodeAfter(m_insertedTextNode, pos.node());
+        }
         else
             ASSERT_NOT_REACHED();
         
@@ -1164,15 +1176,18 @@ DOMPosition InputTextCommandImpl::prepareForTextInsertion()
 void InputTextCommandImpl::execute(const DOMString &text)
 {
     KHTMLSelection selection = endingSelection();
+    bool adjustDownstream = selection.startPosition().isFirstRenderedPositionOnLine();
 
     // Delete the current selection, or collapse whitespace, as needed
     if (selection.state() == KHTMLSelection::RANGE)
         deleteSelection();
     else
         deleteCollapsibleWhitespace();
+
+    // EDIT FIXME: Need to take typing style from upstream text, if any.
     
     // Make sure the document is set up to receive text
-    DOMPosition pos = prepareForTextInsertion();
+    DOMPosition pos = prepareForTextInsertion(adjustDownstream);
     
     TextImpl *textNode = static_cast<TextImpl *>(pos.node());
     long offset = pos.offset();
@@ -1184,8 +1199,7 @@ void InputTextCommandImpl::execute(const DOMString &text)
         insertSpace(textNode, offset);
     else
         insertText(textNode, offset, text);
-    selection = KHTMLSelection(textNode, offset + text.length());
-    setEndingSelection(selection);
+    setEndingSelection(DOMPosition(textNode, offset + text.length()));
     m_charactersAdded += text.length();
 }
 
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index 47fec02..e152656 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -260,7 +260,7 @@ public:
     unsigned long charactersAdded() const { return m_charactersAdded; }
     
 private:
-    DOM::DOMPosition prepareForTextInsertion();
+    DOM::DOMPosition prepareForTextInsertion(bool adjustDownstream);
     void execute(const DOM::DOMString &text);
     void insertSpace(DOM::TextImpl *textNode, unsigned long offset);
 
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index 0154eaa..29416da 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -2022,6 +2022,17 @@ bool RenderBlock::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
     return inBox;
 }
 
+FindSelectionResult RenderBlock::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&node, int &offset)
+{
+    if (!firstChild() && element()) {
+        node = element();
+        offset = 0;
+        return SelectionPointBefore;
+    }
+    
+    return RenderFlow::checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
+}
+
 void RenderBlock::calcMinMaxWidth()
 {
     KHTMLAssert( !minMaxKnown() );
diff --git a/WebCore/khtml/rendering/render_block.h b/WebCore/khtml/rendering/render_block.h
index 1c32daf..592dbad 100644
--- a/WebCore/khtml/rendering/render_block.h
+++ b/WebCore/khtml/rendering/render_block.h
@@ -167,6 +167,9 @@ public:
                              HitTestAction hitTestAction = HitTestAll, bool inside=false);
 
     bool isPointInScrollbar(int x, int y, int tx, int ty);
+
+    virtual FindSelectionResult checkSelectionPointIgnoringContinuations
+        (int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&, int &);
     
     virtual void calcMinMaxWidth();
     void calcInlineMinMaxWidth();
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index a9a399c..adfed15 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -126,6 +126,28 @@ unsigned long RenderReplaced::caretMaxRenderedOffset() const
     return 1; 
 }
 
+FindSelectionResult RenderReplaced::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&node, int &offset)
+{
+    int l = xPos() + _tx;
+    int r = xPos() + _tx + width();
+    int t = yPos() + _ty;
+    int b = yPos() + _ty + height();
+    
+    bool pointIsInside = (_x >= l && _x <= r && _y >= t && _y <= b);
+    
+    if (pointIsInside && element()) {
+        node = element();
+        if (_x < l + (width() / 2)) {
+            offset = 0;
+            return SelectionPointBefore;
+        }
+        offset = 1;
+        return SelectionPointAfter;
+    }
+    
+    return RenderBox::checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
+}
+
 // -----------------------------------------------------------------------------
 
 RenderWidget::RenderWidget(DOM::NodeImpl* node)
diff --git a/WebCore/khtml/rendering/render_replaced.h b/WebCore/khtml/rendering/render_replaced.h
index 1f7e91f..3a0a123 100644
--- a/WebCore/khtml/rendering/render_replaced.h
+++ b/WebCore/khtml/rendering/render_replaced.h
@@ -55,6 +55,9 @@ public:
     virtual long caretMinOffset() const;
     virtual long caretMaxOffset() const;
     virtual unsigned long caretMaxRenderedOffset() const;
+
+    virtual FindSelectionResult checkSelectionPointIgnoringContinuations
+        (int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&, int &);
     
 private:
     int m_intrinsicWidth;
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 8b1120c..021008b 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -208,10 +208,10 @@ FindSelectionResult InlineTextBox::checkSelectionPoint(int _x, int _y, int _tx,
 //                   << " _tx+m_x=" << _tx+m_x << " _ty+m_y=" << _ty+m_y << endl;
     offset = 0;
 
-    if ( _y < _ty + m_y )
+    if ( _y < _ty + root()->topOverflow() )
         return SelectionPointBefore; // above -> before
 
-    if ( _y > _ty + m_y + m_height ) {
+    if ( _y > _ty + root()->bottomOverflow() ) {
         // below -> after
         // Set the offset to the max
         offset = m_len;
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index c351083..e321b21 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -462,6 +462,11 @@ EntityReferenceImpl *DocumentImpl::createEntityReference ( const DOMString &name
     return new EntityReferenceImpl(docPtr(), name.implementation());
 }
 
+EditingTextImpl *DocumentImpl::createEditingTextNode(const DOMString &text)
+{
+    return new EditingTextImpl(docPtr(), text);
+}
+
 NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &exceptioncode)
 {
 	NodeImpl *result = 0;
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 09f587d..c3db8ea 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -85,6 +85,7 @@ namespace DOM {
 #if APPLE_CHANGES
     class DOMImplementation;
 #endif
+    class EditingTextImpl;
     class ElementImpl;
     class EntityReferenceImpl;
     class EventImpl;
@@ -245,6 +246,9 @@ public:
     TreeWalkerImpl *createTreeWalker(const Node &root, unsigned long whatToShow, const NodeFilter &filter,
                             bool entityReferenceExpansion);
 
+    // Special support for editing
+    EditingTextImpl *createEditingTextNode(const DOMString &text);
+
     virtual void recalcStyle( StyleChange = NoChange );
     static QPtrList<DocumentImpl> * changedDocuments;
     virtual void updateRendering();
diff --git a/WebCore/khtml/xml/dom_position.cpp b/WebCore/khtml/xml/dom_position.cpp
index e2ef22a..553f37c 100644
--- a/WebCore/khtml/xml/dom_position.cpp
+++ b/WebCore/khtml/xml/dom_position.cpp
@@ -643,8 +643,16 @@ bool DOMPosition::isLastRenderedPositionInEditableBlock() const
     if (renderedOffset() != (long)node()->caretMaxRenderedOffset())
         return false;
 
-    NodeImpl *next = node()->nextEditable();
-    return !next || !node()->inSameContainingEditableBlock(next);
+    DOMPosition pos(node(), offset());
+    EditIterator it(pos);
+    while (!it.atEnd()) {
+        it.next();
+        if (!it.current().node()->inSameContainingEditableBlock(node()))
+            return true;
+        if (it.current().inRenderedContent())
+            return false;
+    }
+    return true;
 }
 
 bool DOMPosition::inFirstEditableInRootEditableBlock() const
diff --git a/WebCore/khtml/xml/dom_textimpl.cpp b/WebCore/khtml/xml/dom_textimpl.cpp
index 344c6e6..1398eff 100644
--- a/WebCore/khtml/xml/dom_textimpl.cpp
+++ b/WebCore/khtml/xml/dom_textimpl.cpp
@@ -319,12 +319,12 @@ DOMString CommentImpl::toString() const
 // ### allow having children in text nodes for entities, comments etc.
 
 TextImpl::TextImpl(DocumentPtr *doc, const DOMString &_text)
-    : CharacterDataImpl(doc, _text), m_rendererIsNeeded(false)
+    : CharacterDataImpl(doc, _text)
 {
 }
 
 TextImpl::TextImpl(DocumentPtr *doc)
-    : CharacterDataImpl(doc), m_rendererIsNeeded(false)
+    : CharacterDataImpl(doc)
 {
 }
 
@@ -389,11 +389,6 @@ NodeImpl *TextImpl::cloneNode(bool /*deep*/)
 
 bool TextImpl::rendererIsNeeded(RenderStyle *style)
 {
-    if (m_rendererIsNeeded) {
-        m_rendererIsNeeded = false;
-        return true;
-    }
-
     if (!CharacterDataImpl::rendererIsNeeded(style)) {
         return false;
     }
@@ -528,5 +523,24 @@ DOMString CDATASectionImpl::toString() const
     return DOMString("<![CDATA[") + nodeValue() + "]]>";
 }
 
+// ---------------------------------------------------------------------------
+
+EditingTextImpl::EditingTextImpl(DocumentPtr *impl, const DOMString &text)
+    : TextImpl(impl, text)
+{
+}
+
+EditingTextImpl::EditingTextImpl(DocumentPtr *impl)
+    : TextImpl(impl)
+{
+}
 
+EditingTextImpl::~EditingTextImpl()
+{
+}
+
+bool EditingTextImpl::rendererIsNeeded(RenderStyle *style)
+{
+    return true;
+}
 
diff --git a/WebCore/khtml/xml/dom_textimpl.h b/WebCore/khtml/xml/dom_textimpl.h
index e6f2469..2f71c43 100644
--- a/WebCore/khtml/xml/dom_textimpl.h
+++ b/WebCore/khtml/xml/dom_textimpl.h
@@ -138,8 +138,6 @@ public:
     virtual bool childTypeAllowed( unsigned short type );
 
     virtual DOMString toString() const;
-    
-    void setRendererIsNeeded(bool flag=true) { m_rendererIsNeeded = flag; }
 
 #if APPLE_CHANGES
     static Text createInstance(TextImpl *impl);
@@ -147,9 +145,6 @@ public:
 
 protected:
     virtual TextImpl *createNew(DOMStringImpl *_str);
-    
-private:
-    bool m_rendererIsNeeded;
 };
 
 // ----------------------------------------------------------------------------
@@ -177,5 +172,17 @@ protected:
     virtual TextImpl *createNew(DOMStringImpl *_str);
 };
 
-}; //namespace
+// ----------------------------------------------------------------------------
+
+class EditingTextImpl : public TextImpl
+{
+public:
+    EditingTextImpl(DocumentPtr *impl, const DOMString &text);
+    EditingTextImpl(DocumentPtr *impl);
+    virtual ~EditingTextImpl();
+
+    virtual bool rendererIsNeeded(khtml::RenderStyle *);
+};
+
+} //namespace
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list