Changeset 32353 in webkit


Ignore:
Timestamp:
Apr 21, 2008 3:48:41 PM (16 years ago)
Author:
justin.garcia@apple.com
Message:

WebCore:

2008-04-21 Justin Garcia <justin.garcia@apple.com>

Reviewed by John Sullivan.

<rdar://problem/5803706> Pressing return at the end of a header doesn't break out of header (17460)


If we're doing InsertParagraphSeparator at the end of a header element, do not clone it.
Renamed m_useDefaultParagraphElement to m_mustUseDefaultParagraphElement, since now,
when it is false, that does not necessarily mean that a default paragraph element
will not be used. Callers that passed false for this argument are OK with this.

  • editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand): (WebCore::InsertParagraphSeparatorCommand::shouldUseDefaultParagraphElement): (WebCore::InsertParagraphSeparatorCommand::doApply):
  • editing/InsertParagraphSeparatorCommand.h:

LayoutTests:

2008-04-21 Justin Garcia <justin.garcia@apple.com>

Reviewed by John Sullivan.

<rdar://problem/5803706> Pressing return at the end of a header doesn't break out of header (17460)

  • editing/inserting/5803706-1-expected.txt: Added.
  • editing/inserting/5803706-1.html: Added.
  • editing/inserting/5803706-2-expected.txt: Added.
  • editing/inserting/5803706-2.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r32352 r32353  
     12008-04-21  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by John Sullivan.
     4
     5        <rdar://problem/5803706> Pressing return at the end of a header doesn't break out of header (17460)
     6
     7        * editing/inserting/5803706-1-expected.txt: Added.
     8        * editing/inserting/5803706-1.html: Added.
     9        * editing/inserting/5803706-2-expected.txt: Added.
     10        * editing/inserting/5803706-2.html: Added.
     11
    1122008-04-21  Mark Rowe  <mrowe@apple.com>
    213
  • trunk/WebCore/ChangeLog

    r32351 r32353  
     12008-04-21  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by John Sullivan.
     4
     5        <rdar://problem/5803706> Pressing return at the end of a header doesn't break out of header (17460)
     6       
     7        If we're doing InsertParagraphSeparator at the end of a header element, do not clone it.
     8        Renamed m_useDefaultParagraphElement to m_mustUseDefaultParagraphElement, since now,
     9        when it is false, that does not necessarily mean that a default paragraph element
     10        will not be used.  Callers that passed false for this argument are OK with this.
     11
     12        * editing/InsertParagraphSeparatorCommand.cpp:
     13        (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand):
     14        (WebCore::InsertParagraphSeparatorCommand::shouldUseDefaultParagraphElement):
     15        (WebCore::InsertParagraphSeparatorCommand::doApply):
     16        * editing/InsertParagraphSeparatorCommand.h:
     17
    1182008-04-21  Anders Carlsson  <andersca@apple.com>
    219
  • trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp

    r30016 r32353  
    4343using namespace HTMLNames;
    4444
    45 InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool useDefaultParagraphElement)
     45InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool mustUseDefaultParagraphElement)
    4646    : CompositeEditCommand(document)
    47     , m_useDefaultParagraphElement(useDefaultParagraphElement)
     47    , m_mustUseDefaultParagraphElement(mustUseDefaultParagraphElement)
    4848{
    4949}
     
    7777    if (m_style->length() > 0)
    7878        applyStyle(m_style.get());
     79}
     80
     81bool InsertParagraphSeparatorCommand::shouldUseDefaultParagraphElement(Node* enclosingBlock) const
     82{
     83    if (m_mustUseDefaultParagraphElement)
     84        return true;
     85   
     86    // Assumes that if there was a range selection, it was already deleted.
     87    if (!isEndOfBlock(endingSelection().visibleStart()))
     88        return false;
     89
     90    return enclosingBlock->hasTagName(h1Tag) ||
     91           enclosingBlock->hasTagName(h2Tag) ||
     92           enclosingBlock->hasTagName(h3Tag) ||
     93           enclosingBlock->hasTagName(h4Tag) ||
     94           enclosingBlock->hasTagName(h5Tag);
    7995}
    8096
     
    140156        blockToInsert = static_pointer_cast<Node>(createDefaultParagraphElement(document()));
    141157        nestNewBlock = true;
    142     } else if (m_useDefaultParagraphElement)
     158    } else if (shouldUseDefaultParagraphElement(startBlock))
    143159        blockToInsert = static_pointer_cast<Node>(createDefaultParagraphElement(document()));
    144160    else
  • trunk/WebCore/editing/InsertParagraphSeparatorCommand.h

    r25327 r32353  
    4040    void calculateStyleBeforeInsertion(const Position&);
    4141    void applyStyleAfterInsertion();
     42   
     43    bool shouldUseDefaultParagraphElement(Node*) const;
    4244
    4345    virtual bool preservesTypingStyle() const;
     
    4547    RefPtr<CSSMutableStyleDeclaration> m_style;
    4648   
    47     bool m_useDefaultParagraphElement;
     49    bool m_mustUseDefaultParagraphElement;
    4850};
    4951
Note: See TracChangeset for help on using the changeset viewer.