Changeset 17223 in webkit


Ignore:
Timestamp:
Oct 23, 2006, 2:29:49 PM (18 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by john

<http://bugs.webkit.org/show_bug.cgi?id=11333>
Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document

  • editing/inserting/insert-br-009-expected.checksum: Added.
  • editing/inserting/insert-br-009-expected.png: Added.
  • editing/inserting/insert-br-009-expected.txt: Added.
  • editing/inserting/insert-br-009.html: Added.
  • editing/inserting/insert-paragraph-01-expected.checksum: Added.
  • editing/inserting/insert-paragraph-01-expected.png: Added.
  • editing/inserting/insert-paragraph-01-expected.txt: Added.
  • editing/inserting/insert-paragraph-01.html: Added.
  • editing/inserting/insert-paragraph-02-expected.checksum: Added.
  • editing/inserting/insert-paragraph-02-expected.png: Added.
  • editing/inserting/insert-paragraph-02-expected.txt: Added.
  • editing/inserting/insert-paragraph-02.html: Added.
  • editing/inserting/insert-paragraph-03-expected.checksum: Added.
  • editing/inserting/insert-paragraph-03-expected.png: Added.
  • editing/inserting/insert-paragraph-03-expected.txt: Added.
  • editing/inserting/insert-paragraph-03.html: Added.
  • editing/inserting/insert-paragraph-04-expected.checksum: Added.
  • editing/inserting/insert-paragraph-04-expected.png: Added.
  • editing/inserting/insert-paragraph-04-expected.txt: Added.
  • editing/inserting/insert-paragraph-04.html: Added.

WebCore:

Reviewed by john


<http://bugs.webkit.org/show_bug.cgi?id=11333>
Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document


Added special cases in InsertLineBreakCommand for inserting before
and after tables and horizontal rules. Also, perform InsertLineBreak
instead of InsertParagraphSeparator at these positions.

  • editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::doApply): Use the canonical form of the caret position when we check for the new special cases because we know that we canonicalize VisiblePositions to those positions. Added code to handle inserting before/after tables and horizontal rules. Fixed a bug when inserting at the end of a block (it checked for a collapse of the inserted br by looking for the absence of a br, but the line break might have been a '\n' in white-space:pre text). Removed unused LOGs.
  • editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::doApply): Perform an InsertLineBreakCommand when before/after a table or a horizontal rule so that we don't have to maintain two pieces of special case code. Migrated to enclosingBlock.
  • editing/htmlediting.cpp: Added a FIXME.
  • editing/visible_units.cpp: (WebCore::startOfParagraph): Added a workaround for 8622.
Location:
trunk
Files:
20 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r17183 r17223  
     12006-10-20  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by john
     4
     5        <http://bugs.webkit.org/show_bug.cgi?id=11333>
     6        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document
     7
     8        * editing/inserting/insert-br-009-expected.checksum: Added.
     9        * editing/inserting/insert-br-009-expected.png: Added.
     10        * editing/inserting/insert-br-009-expected.txt: Added.
     11        * editing/inserting/insert-br-009.html: Added.
     12        * editing/inserting/insert-paragraph-01-expected.checksum: Added.
     13        * editing/inserting/insert-paragraph-01-expected.png: Added.
     14        * editing/inserting/insert-paragraph-01-expected.txt: Added.
     15        * editing/inserting/insert-paragraph-01.html: Added.
     16        * editing/inserting/insert-paragraph-02-expected.checksum: Added.
     17        * editing/inserting/insert-paragraph-02-expected.png: Added.
     18        * editing/inserting/insert-paragraph-02-expected.txt: Added.
     19        * editing/inserting/insert-paragraph-02.html: Added.
     20        * editing/inserting/insert-paragraph-03-expected.checksum: Added.
     21        * editing/inserting/insert-paragraph-03-expected.png: Added.
     22        * editing/inserting/insert-paragraph-03-expected.txt: Added.
     23        * editing/inserting/insert-paragraph-03.html: Added.
     24        * editing/inserting/insert-paragraph-04-expected.checksum: Added.
     25        * editing/inserting/insert-paragraph-04-expected.png: Added.
     26        * editing/inserting/insert-paragraph-04-expected.txt: Added.
     27        * editing/inserting/insert-paragraph-04.html: Added.
     28
    1292006-10-20  Geoffrey Garen  <ggaren@apple.com>
    230
  • trunk/WebCore/ChangeLog

    r17221 r17223  
     12006-10-23  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by john
     4       
     5        <http://bugs.webkit.org/show_bug.cgi?id=11333>
     6        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document
     7       
     8        Added special cases in InsertLineBreakCommand for inserting before
     9        and after tables and horizontal rules.  Also, perform InsertLineBreak
     10        instead of InsertParagraphSeparator at these positions.
     11
     12        * editing/InsertLineBreakCommand.cpp:
     13        (WebCore::InsertLineBreakCommand::doApply):  Use the canonical form
     14        of the caret position when we check for the new special cases because
     15        we know that we canonicalize VisiblePositions to those positions.
     16        Added code to handle inserting before/after tables and horizontal rules. 
     17        Fixed a bug when inserting at the end of a block (it checked for a collapse
     18        of the inserted br by looking for the absence of a br, but the line break
     19        might have been a '\n' in white-space:pre text).  Removed unused LOGs.
     20        * editing/InsertParagraphSeparatorCommand.cpp:
     21        (WebCore::InsertParagraphSeparatorCommand::doApply): Perform an
     22        InsertLineBreakCommand when before/after a table or a horizontal rule
     23        so that we don't have to maintain two pieces of special case code.
     24        Migrated to enclosingBlock.
     25        * editing/htmlediting.cpp: Added a FIXME.
     26        * editing/visible_units.cpp:
     27        (WebCore::startOfParagraph): Added a workaround for 8622.
     28       
    1292006-10-23  Adam Roben  <aroben@apple.com>
    230
  • trunk/WebCore/editing/InsertLineBreakCommand.cpp

    r16026 r17223  
    3131#include "Element.h"
    3232#include "Frame.h"
    33 #include "Logging.h"
    3433#include "Text.h"
    3534#include "VisiblePosition.h"
     
    8786
    8887    Position pos(selection.start().upstream());
     88    Position canonicalPos(VisiblePosition(pos).deepEquivalent());
    8989
    9090    pos = positionAvoidingSpecialElementBoundary(pos);
     
    107107        insertNodeAtTabSpanPosition(nodeToInsert.get(), pos);
    108108        setEndingSelection(Selection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM));
    109     } else if (isEndOfBlock(VisiblePosition(pos, selection.affinity()))) {
    110         Node* block = pos.node()->enclosingBlockFlowElement();
     109    } else if (canonicalPos.node()->renderer() && canonicalPos.node()->renderer()->isTable() ||
     110               canonicalPos.node()->hasTagName(hrTag)) {
     111        if (canonicalPos.offset() == 0) {
     112            insertNodeBefore(nodeToInsert.get(), canonicalPos.node());
     113            // Insert an extra br if the just inserted one collapsed.
     114            if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))))
     115                insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
     116            // Leave the selection where it was, just before the table/horizontal rule.
     117        } else if (canonicalPos.offset() == maxDeepOffset(canonicalPos.node())) {
     118            insertNodeAfter(nodeToInsert.get(), canonicalPos.node());
     119            setEndingSelection(Selection(VisiblePosition(Position(nodeToInsert.get(), 0))));
     120        } else
     121            // There aren't any VisiblePositions like this yet.
     122            ASSERT_NOT_REACHED();
     123    // FIXME: The following doesn't handle positions at the ends of anonymous blocks, and
     124    // those cases are buggy.
     125    } else if (isEndOfBlock(selection.visibleStart())) {
     126        insertNodeAt(nodeToInsert.get(), pos.node(), pos.offset());
     127        VisiblePosition endingPosition(endOfBlock(VisiblePosition(pos)));
    111128       
    112         // Insert an extra break element so that there will be a blank line after the last
    113         // inserted line break. In HTML, a line break at the end of a block ends the last
    114         // line in the block, while in editable text, a line break at the end of block
    115         // creates a last blank line. We need an extra break element to get HTML to act
    116         // the way editable text would.
    117         bool haveBreak = pos.downstream().node()->hasTagName(brTag) && pos.downstream().offset() == 0;
    118         insertNodeAt(nodeToInsert.get(), pos.node(), pos.offset());
    119         if (!haveBreak)
    120             insertNodeAfter(createBreakElement(document()).get(), nodeToInsert.get());
    121            
    122         setEndingSelection(Selection(Position(block, maxDeepOffset(block)), DOWNSTREAM));
     129        // Insert an extra br if the inserted one collapsed.
     130        if (!isStartOfParagraph(endingPosition))
     131            insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
     132       
     133        setEndingSelection(Selection(endingPosition));
    123134    } else if (pos.offset() <= pos.node()->caretMinOffset()) {
    124         LOG(Editing, "input newline case 2");
    125135        // Insert node before downstream position, and place caret there as well.
    126136        Position endingPosition = pos.downstream();
     
    128138        setEndingSelection(Selection(endingPosition, DOWNSTREAM));
    129139    } else if (pos.offset() >= pos.node()->caretMaxOffset()) {
    130         LOG(Editing, "input newline case 3");
    131140        // Insert BR after this node. Place caret in the position that is downstream
    132141        // of the current position, reckoned before inserting the BR in between.
     
    136145    } else {
    137146        // Split a text node
    138         LOG(Editing, "input newline case 4");
    139147        ASSERT(pos.node()->isTextNode());
    140148       
  • trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp

    r16257 r17223  
    9898    // FIXME: Turn into an InsertLineBreak in other cases where we don't want to do the splitting/cloning that
    9999    // InsertParagraphSeparator does.
    100     Node* block = pos.node()->enclosingBlockFlowElement();
    101     if (!block || !block->parentNode() || block->renderer() && block->renderer()->isTableCell()) {
     100    Node* block = enclosingBlock(pos.node());
     101    Position canonicalPos = VisiblePosition(pos).deepEquivalent();
     102    if (!block || !block->parentNode() ||
     103        block->renderer() && block->renderer()->isTableCell() ||
     104        canonicalPos.node()->renderer() && canonicalPos.node()->renderer()->isTable() ||
     105        canonicalPos.node()->hasTagName(hrTag)) {
    102106        applyCommandToComposite(new InsertLineBreakCommand(document()));
    103107        return;
  • trunk/WebCore/editing/ReplaceSelectionCommand.cpp

    r17051 r17223  
    538538   
    539539    // 1) Insert the content.
    540     // 2) Restore the styles of inserted nodes (since styles were removed during the test insertion).
     540    // 2) Remove redundant styles and style tags, this inner <b> for example: <b>foo <b>bar</b> baz</b>.
    541541    // 3) Merge the start of the added content with the content before the position being pasted into.
    542542    // 4) Do one of the following: a) expand the last br if the fragment ends with one and it collapsed,
  • trunk/WebCore/editing/htmlediting.cpp

    r17143 r17223  
    272272
    273273// FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlockFlowOrTableElement are used.
     274// FIXME: Pass a position to this function.  The enclosing block of [table, x] for example, should be the
     275// block that contains the table and not the table, and this function should be the only one responsible for
     276// knowing about these kinds of special cases.
    274277Node* enclosingBlock(Node* node)
    275278{
  • trunk/WebCore/editing/visible_units.cpp

    r16384 r17223  
    564564{
    565565    Position p = c.deepEquivalent();
     566    // FIXME: Use the leftmost candidate.  Canonicalization should give us the leftmost candidate,
     567    // but it sometimes doesn't because of 8622.
     568    if (p.upstream().inRenderedContent()) {
     569        p = p.upstream();
     570        ASSERT(VisiblePosition(p) == c);
     571    }
     572
    566573    Node *startNode = p.node();
    567574
Note: See TracChangeset for help on using the changeset viewer.