Changeset 69640 in webkit


Ignore:
Timestamp:
Oct 12, 2010 11:34:18 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-12 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r69639.
http://trac.webkit.org/changeset/69639
https://bugs.webkit.org/show_bug.cgi?id=47575

"regressed nav-element.html" (Requested by rniwa on #webkit).

  • editing/execCommand/format-block-expected.txt:
  • editing/execCommand/format-block-from-range-selection-expected.txt:
  • editing/execCommand/format-block-multiple-paragraphs-expected.txt: Removed.
  • editing/execCommand/format-block-multiple-paragraphs.html: Removed.
  • editing/execCommand/format-block-table-expected.txt: Removed.
  • editing/execCommand/format-block-table.html: Removed.
  • editing/execCommand/format-block-with-braces-expected.txt:

2010-10-12 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r69639.
http://trac.webkit.org/changeset/69639
https://bugs.webkit.org/show_bug.cgi?id=47575

"regressed nav-element.html" (Requested by rniwa on #webkit).

  • editing/ApplyBlockElementCommand.cpp: (WebCore::ApplyBlockElementCommand::formatSelection):
  • editing/EditorCommand.cpp: (WebCore::executeFormatBlock):
  • editing/FormatBlockCommand.cpp: (WebCore::FormatBlockCommand::formatRange):
  • editing/FormatBlockCommand.h: (WebCore::FormatBlockCommand::editingAction):
  • editing/VisiblePosition.cpp: (WebCore::enclosingBlockFlowElement):
  • editing/VisiblePosition.h:
  • editing/htmlediting.cpp: (WebCore::validBlockTag):
  • editing/htmlediting.h:
Location:
trunk
Files:
4 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69639 r69640  
     12010-10-12  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r69639.
     4        http://trac.webkit.org/changeset/69639
     5        https://bugs.webkit.org/show_bug.cgi?id=47575
     6
     7        "regressed nav-element.html" (Requested by rniwa on #webkit).
     8
     9        * editing/execCommand/format-block-expected.txt:
     10        * editing/execCommand/format-block-from-range-selection-expected.txt:
     11        * editing/execCommand/format-block-multiple-paragraphs-expected.txt: Removed.
     12        * editing/execCommand/format-block-multiple-paragraphs.html: Removed.
     13        * editing/execCommand/format-block-table-expected.txt: Removed.
     14        * editing/execCommand/format-block-table.html: Removed.
     15        * editing/execCommand/format-block-with-braces-expected.txt:
     16
    1172010-10-12  Ryosuke Niwa  <rniwa@webkit.org>
    218
  • trunk/LayoutTests/editing/execCommand/format-block-expected.txt

    r69639 r69640  
    5353| <pre>
    5454|   "Make Pre"
     55|   <br>
    5556| "
    5657"
     
    6263|   <br>
    6364|   <h1>
    64 |     <span>
    65 |       id="item2"
    66 |       "Make h1"
     65|     "Make h1"
     66|     <br>
    6767|   "baz"
    6868| "
  • trunk/LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt

    r69639 r69640  
    3333| <dl>
    3434|   "Fo<#selection-anchor>o"
    35 |   <br>
    36 |   "bar"
    37 |   <br>
    38 |   <span>
    39 |     "baz"
    40 |     <br>
    41 |   "raz"
    42 |   <br>
    43 |   "
    44 dar"
    45 |   <br>
    46 |   "
    47 "
    48 |   "yar<#selection-focus>"
    4935| "
    5036"
     37| <div>
     38|   <dl>
     39|     "bar"
     40|   <span>
     41|     <dl>
     42|       "baz"
     43|   <dl>
     44|     "raz"
     45| <dl>
     46|   "dar"
     47|   " "
    5148| "
    5249"
     50| <dl>
     51|   "ya<#selection-focus>r"
    5352| "
    5453"
  • trunk/LayoutTests/editing/execCommand/format-block-with-braces-expected.txt

    r69639 r69640  
    1717After FormatBlock with <h1>:
    1818| <h1>
    19 |   "
    20 <#selection-caret>Format Me
    21 "
     19|   "<#selection-caret>Format Me"
     20|   <br>
  • trunk/WebCore/ChangeLog

    r69639 r69640  
     12010-10-12  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r69639.
     4        http://trac.webkit.org/changeset/69639
     5        https://bugs.webkit.org/show_bug.cgi?id=47575
     6
     7        "regressed nav-element.html" (Requested by rniwa on #webkit).
     8
     9        * editing/ApplyBlockElementCommand.cpp:
     10        (WebCore::ApplyBlockElementCommand::formatSelection):
     11        * editing/EditorCommand.cpp:
     12        (WebCore::executeFormatBlock):
     13        * editing/FormatBlockCommand.cpp:
     14        (WebCore::FormatBlockCommand::formatRange):
     15        * editing/FormatBlockCommand.h:
     16        (WebCore::FormatBlockCommand::editingAction):
     17        * editing/VisiblePosition.cpp:
     18        (WebCore::enclosingBlockFlowElement):
     19        * editing/VisiblePosition.h:
     20        * editing/htmlediting.cpp:
     21        (WebCore::validBlockTag):
     22        * editing/htmlediting.h:
     23
    1242010-10-12  Ryosuke Niwa  <rniwa@webkit.org>
    225
  • trunk/WebCore/editing/ApplyBlockElementCommand.cpp

    r69639 r69640  
    113113
    114114    bool atEnd = false;
    115     Position end;
    116115    while (endOfCurrentParagraph != endAfterSelection && !atEnd) {
     116        Position start;
     117        Position end;
     118
    117119        if (endOfCurrentParagraph == endOfLastParagraph)
    118120            atEnd = true;
  • trunk/WebCore/editing/EditorCommand.cpp

    r69639 r69640  
    433433    if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
    434434        tagName = tagName.substring(1, tagName.length() - 2);
     435    if (!validBlockTag(tagName))
     436        return false;
    435437
    436438    ExceptionCode ec;
     
    439441        return false;
    440442    QualifiedName qualifiedTagName(prefix, localName, xhtmlNamespaceURI);
    441 
    442     if (!FormatBlockCommand::isElementToApplyInFormatBlockCommand(qualifiedTagName))
    443         return false;
    444443
    445444    applyCommand(FormatBlockCommand::create(frame->document(), qualifiedTagName));
  • trunk/WebCore/editing/FormatBlockCommand.cpp

    r69639 r69640  
    3737using namespace HTMLNames;
    3838
    39 static Node* enclosingBlockToSplitTreeTo(Node* startNode);
    40 
    4139FormatBlockCommand::FormatBlockCommand(Document* document, const QualifiedName& tagName)
    4240    : ApplyBlockElementCommand(document, tagName)
     
    4442}
    4543
    46 void FormatBlockCommand::formatRange(const Position& start, const Position& end, RefPtr<Element>& blockNode)
     44void FormatBlockCommand::formatRange(const Position&, const Position& end, RefPtr<Element>&)
    4745{
    48     Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.node());
    49     RefPtr<Node> outerBlock = (start.node() == nodeToSplitTo) ? start.node() : splitTreeToNode(start.node(), nodeToSplitTo);
    50     RefPtr<Node> nodeAfterInsertionPosition = outerBlock;
     46    setEndingSelection(VisiblePosition(end));
    5147
    52     Element* refNode = enclosingBlockFlowElement(end);
    53     Element* root = editableRootForPosition(start);
    54     if (isElementToApplyInFormatBlockCommand(refNode->tagQName()) && start == startOfBlock(start) && end == endOfBlock(end)
    55         && refNode != root && !root->isDescendantOf(refNode)) {
    56         // Already in a block element that only contains the current paragraph
    57         if (refNode->hasTagName(tagName()))
    58             return;
    59         nodeAfterInsertionPosition = refNode;
     48    Node* refNode = enclosingBlockFlowElement(endingSelection().visibleStart());
     49    if (refNode->hasTagName(tagName()))
     50        // We're already in a block with the format we want, so we don't have to do anything
     51        return;
     52
     53    VisiblePosition paragraphStart = startOfParagraph(end);
     54    VisiblePosition paragraphEnd = endOfParagraph(end);
     55    VisiblePosition blockStart = startOfBlock(endingSelection().visibleStart());
     56    VisiblePosition blockEnd = endOfBlock(endingSelection().visibleStart());
     57    RefPtr<Element> blockNode = createBlockElement();
     58    RefPtr<Element> placeholder = createBreakElement(document());
     59
     60    Node* root = endingSelection().start().node()->rootEditableElement();
     61    if (validBlockTag(refNode->nodeName().lower()) &&
     62        paragraphStart == blockStart && paragraphEnd == blockEnd &&
     63        refNode != root && !root->isDescendantOf(refNode))
     64        // Already in a valid block tag that only contains the current paragraph, so we can swap with the new tag
     65        insertNodeBefore(blockNode, refNode);
     66    else {
     67        // Avoid inserting inside inline elements that surround paragraphStart with upstream().
     68        // This is only to avoid creating bloated markup.
     69        insertNodeAt(blockNode, paragraphStart.deepEquivalent().upstream());
    6070    }
     71    appendNode(placeholder, blockNode);
    6172
    62     if (!blockNode) {
    63         // Create a new blockquote and insert it as a child of the root editable element. We accomplish
    64         // this by splitting all parents of the current paragraph up to that point.
    65         blockNode = createBlockElement();
    66         insertNodeBefore(blockNode, nodeAfterInsertionPosition);
     73    VisiblePosition destination(Position(placeholder.get(), 0));
     74    if (paragraphStart == paragraphEnd && !lineBreakExistsAtVisiblePosition(paragraphStart)) {
     75        setEndingSelection(destination);
     76        return;
    6777    }
    68 
    69     Position lastParagraphInBlockNode = lastPositionInNode(blockNode.get());
    70     bool wasEndOfParagraph = isEndOfParagraph(lastParagraphInBlockNode);
    71 
    72     moveParagraphWithClones(start, end, blockNode.get(), outerBlock.get());
    73 
    74     if (wasEndOfParagraph && !isEndOfParagraph(lastParagraphInBlockNode) && !isStartOfParagraph(lastParagraphInBlockNode))
    75         insertBlockPlaceholder(lastParagraphInBlockNode);
    76 }
    77 
    78 // FIXME: We should consider mering this function with isElementForFormatBlockCommand in Editor.cpp
    79 // Checks if a tag name is valid for execCommand('FormatBlock').
    80 bool FormatBlockCommand::isElementToApplyInFormatBlockCommand(const QualifiedName& tagName)
    81 {
    82     DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, blockTags, ());
    83     if (blockTags.isEmpty()) {
    84         blockTags.add(addressTag);
    85         blockTags.add(articleTag);
    86         blockTags.add(asideTag);
    87         blockTags.add(blockquoteTag);
    88         blockTags.add(ddTag);
    89         blockTags.add(divTag);
    90         blockTags.add(dlTag);
    91         blockTags.add(dtTag);
    92         blockTags.add(footerTag);
    93         blockTags.add(h1Tag);
    94         blockTags.add(h2Tag);
    95         blockTags.add(h3Tag);
    96         blockTags.add(h4Tag);
    97         blockTags.add(h5Tag);
    98         blockTags.add(h6Tag);
    99         blockTags.add(headerTag);
    100         blockTags.add(hgroupTag);
    101         blockTags.add(navTag);
    102         blockTags.add(pTag);
    103         blockTags.add(preTag);
    104         blockTags.add(sectionTag);
    105     }
    106     return blockTags.contains(tagName);
    107 }
    108 
    109 Node* enclosingBlockToSplitTreeTo(Node* startNode)
    110 {
    111     Node* lastBlock = startNode;
    112     for (Node* n = startNode; n; n = n->parentNode()) {
    113         if (!n->isContentEditable())
    114             return lastBlock;
    115         if (isTableCell(n) || n->hasTagName(bodyTag) || !n->parentNode() || !n->parentNode()->isContentEditable()
    116             || (n->isElementNode() && FormatBlockCommand::isElementToApplyInFormatBlockCommand(static_cast<Element*>(n)->tagQName())))
    117             return n;
    118         if (isBlock(n))
    119             lastBlock = n;
    120         if (isListElement(n))
    121             return n->parentNode()->isContentEditable() ? n->parentNode() : n;
    122     }
    123     return lastBlock;
     78    moveParagraph(paragraphStart, paragraphEnd, destination, true, false);
    12479}
    12580
  • trunk/WebCore/editing/FormatBlockCommand.h

    r69639 r69640  
    3939    }
    4040
    41     static bool isElementToApplyInFormatBlockCommand(const QualifiedName& tagName);
    42 
    4341private:
    4442    FormatBlockCommand(Document*, const QualifiedName& tagName);
    4543
    46     void formatRange(const Position&, const Position&, RefPtr<Element>&);
    47     EditAction editingAction() const { return EditActionFormatBlock; }
     44    virtual void formatRange(const Position&, const Position&, RefPtr<Element>&);
     45    virtual EditAction editingAction() const { return EditActionFormatBlock; }
    4846};
    4947
  • trunk/WebCore/editing/VisiblePosition.cpp

    r69639 r69640  
    635635}
    636636
    637 Element* enclosingBlockFlowElement(const VisiblePosition &visiblePosition)
     637Node *enclosingBlockFlowElement(const VisiblePosition &visiblePosition)
    638638{
    639639    if (visiblePosition.isNull())
  • trunk/WebCore/editing/VisiblePosition.h

    r69639 r69640  
    137137VisiblePosition endVisiblePosition(const Range*, EAffinity);
    138138
    139 Element* enclosingBlockFlowElement(const VisiblePosition&);
     139Node *enclosingBlockFlowElement(const VisiblePosition&);
    140140
    141141bool isFirstVisiblePositionInNode(const VisiblePosition&, const Node*);
  • trunk/WebCore/editing/htmlediting.cpp

    r69639 r69640  
    466466}
    467467
     468// Checks if a string is a valid tag for the FormatBlockCommand function of execCommand. Expects lower case strings.
     469bool validBlockTag(const AtomicString& blockTag)
     470{
     471    if (blockTag.isEmpty())
     472        return false;
     473
     474    DEFINE_STATIC_LOCAL(HashSet<AtomicString>, blockTags, ());
     475    if (blockTags.isEmpty()) {
     476        blockTags.add(addressTag.localName());
     477        blockTags.add(articleTag.localName());
     478        blockTags.add(asideTag.localName());
     479        blockTags.add(blockquoteTag.localName());
     480        blockTags.add(ddTag.localName());
     481        blockTags.add(divTag.localName());
     482        blockTags.add(dlTag.localName());
     483        blockTags.add(dtTag.localName());
     484        blockTags.add(footerTag.localName());
     485        blockTags.add(h1Tag.localName());
     486        blockTags.add(h2Tag.localName());
     487        blockTags.add(h3Tag.localName());
     488        blockTags.add(h4Tag.localName());
     489        blockTags.add(h5Tag.localName());
     490        blockTags.add(h6Tag.localName());
     491        blockTags.add(headerTag.localName());
     492        blockTags.add(hgroupTag.localName());
     493        blockTags.add(navTag.localName());
     494        blockTags.add(pTag.localName());
     495        blockTags.add(preTag.localName());
     496        blockTags.add(sectionTag.localName());
     497    }
     498    return blockTags.contains(blockTag);
     499}
     500
    468501static Node* firstInSpecialElement(const Position& pos)
    469502{
  • trunk/WebCore/editing/htmlediting.h

    r69639 r69640  
    229229String stringWithRebalancedWhitespace(const String&, bool, bool);
    230230const String& nonBreakingSpaceString();
     231bool validBlockTag(const AtomicString&);
     232   
    231233
    232234}
Note: See TracChangeset for help on using the changeset viewer.