Changeset 81374 in webkit


Ignore:
Timestamp:
Mar 17, 2011 12:02:50 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-03-17 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Justin Garcia.

Assert that editing does not ignore position's anchorNode if position is an offset in anchor
https://bugs.webkit.org/show_bug.cgi?id=56027

Added a test to ensure WebKit lets users edit contents inside a button element properly.

  • editing/execCommand/button-expected.txt: Added.
  • editing/execCommand/button.html: Added.

2011-03-17 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Justin Garcia.

Assert that editing does not ignore position's anchorNode if position is an offset in anchor
https://bugs.webkit.org/show_bug.cgi?id=56027

Added the assertion in Position::Position and Position::moveToPosition. This assertion catches
places where we instantiate positions inside a node on which editingIgnoresContent returns true.

Test: editing/execCommand/button.html

  • dom/Position.cpp: (WebCore::Position::Position): Added an assertion. (WebCore::Position::moveToPosition): Ditto.
  • dom/PositionIterator.cpp: (WebCore::PositionIterator::operator Position): Avoid creating a position immediately below a node whose content is ignored by editing. While this does not avoid creation of positions inside ignored contents completely, it works in most cases. Filed the bug 56027 to resolve the underlying problem. Without this change, the assertion hits in existing layout tests. cannot be tested directly.
  • editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded): Call firstPositionInOrBeforeNode instead of firstPositionInNode because startNode may as well be a br element. Without this change, the assertion hits in existing layout tests.
  • editing/htmlediting.cpp: (WebCore::canHaveChildrenForEditing): button is editable so content is not ignored. Added a test for this.
  • editing/visible_units.cpp: (WebCore::previousBoundary): Added a FIXME. (WebCore::startPositionForLine): Because br can also have an inline text box, checking that startBox is an inline text box isn't an adequate to instantiate a position inside startNode. Call startNode->isTextNode() instead. Without this change, the assertion hits in existing layout tests.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r81373 r81374  
     12011-03-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        Assert that editing does not ignore position's anchorNode if position is an offset in anchor
     6        https://bugs.webkit.org/show_bug.cgi?id=56027
     7
     8        Added a test to ensure WebKit lets users edit contents inside a button element properly.
     9
     10        * editing/execCommand/button-expected.txt: Added.
     11        * editing/execCommand/button.html: Added.
     12
    1132011-03-17  Adam Roben  <aroben@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r81369 r81374  
     12011-03-17  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        Assert that editing does not ignore position's anchorNode if position is an offset in anchor
     6        https://bugs.webkit.org/show_bug.cgi?id=56027
     7
     8        Added the assertion in Position::Position and Position::moveToPosition. This assertion catches
     9        places where we instantiate positions inside a node on which editingIgnoresContent returns true.
     10
     11        Test: editing/execCommand/button.html
     12
     13        * dom/Position.cpp:
     14        (WebCore::Position::Position): Added an assertion.
     15        (WebCore::Position::moveToPosition): Ditto.
     16        * dom/PositionIterator.cpp:
     17        (WebCore::PositionIterator::operator Position): Avoid creating a position immediately below
     18        a node whose content is ignored by editing. While this does not avoid creation of positions
     19        inside ignored contents completely, it works in most cases. Filed the bug 56027 to resolve
     20        the underlying problem. Without this change, the assertion hits in existing layout tests.
     21        cannot be tested directly.
     22        * editing/ApplyStyleCommand.cpp:
     23        (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded): Call firstPositionInOrBeforeNode
     24        instead of firstPositionInNode because startNode may as well be a br element. Without this change,
     25        the assertion hits in existing layout tests.
     26        * editing/htmlediting.cpp:
     27        (WebCore::canHaveChildrenForEditing): button is editable so content is not ignored. Added a test
     28        for this.
     29        * editing/visible_units.cpp:
     30        (WebCore::previousBoundary): Added a FIXME.
     31        (WebCore::startPositionForLine): Because br can also have an inline text box, checking that
     32        startBox is an inline text box isn't an adequate to instantiate a position inside startNode.
     33        Call startNode->isTextNode() instead. Without this change, the assertion hits in existing layout
     34        tests.
     35
    1362011-03-17  Pavel Podivilov  <podivilov@chromium.org>
    237
  • trunk/Source/WebCore/dom/Position.cpp

    r81165 r81374  
    9595    , m_isLegacyEditingPosition(false)
    9696{
     97    ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()));
    9798    ASSERT(anchorType == PositionIsOffsetInAnchor);
    9899}
     
    100101void Position::moveToPosition(PassRefPtr<Node> node, int offset)
    101102{
     103    ASSERT(!editingIgnoresContent(node.get()));
    102104    ASSERT(anchorType() == PositionIsOffsetInAnchor || m_isLegacyEditingPosition);
    103105    m_anchorNode = node;
  • trunk/Source/WebCore/dom/PositionIterator.cpp

    r81165 r81374  
    3939    if (m_nodeAfterPositionInAnchor) {
    4040        ASSERT(m_nodeAfterPositionInAnchor->parentNode() == m_anchorNode);
     41        // FIXME: This check is inadaquete because any ancestor could be ignored by editing
     42        if (editingIgnoresContent(m_nodeAfterPositionInAnchor->parentNode()))
     43            return positionBeforeNode(m_anchorNode);
    4144        return positionInParentBeforeNode(m_nodeAfterPositionInAnchor);
    4245    }
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r80580 r81374  
    16971697        positionForStyleComparison = positionBeforeNode(dummyElement.get());
    16981698    } else
    1699         positionForStyleComparison = firstPositionInNode(startNode.get());
     1699        positionForStyleComparison = firstPositionInOrBeforeNode(startNode.get());
    17001700
    17011701    StyleChange styleChange(style, positionForStyleComparison);
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r81295 r81374  
    7777        && !node->hasTagName(brTag)
    7878        && !node->hasTagName(imgTag)
    79         && !node->hasTagName(buttonTag)
    8079        && !node->hasTagName(inputTag)
    8180        && !node->hasTagName(textareaTag)
  • trunk/Source/WebCore/editing/visible_units.cpp

    r81165 r81374  
    127127    BackwardsCharacterIterator charIt(searchRange.get());
    128128    charIt.advance(string.size() - suffixLength - next);
     129    // FIXME: charIt can get out of shadow host.
    129130    return VisiblePosition(charIt.range()->endPosition(), DOWNSTREAM);
    130131}
     
    378379    }
    379380   
    380     VisiblePosition visPos = startBox->isInlineTextBox() ? VisiblePosition(Position(startNode, static_cast<InlineTextBox *>(startBox)->start(), Position::PositionIsOffsetInAnchor), DOWNSTREAM)
    381                                                          : VisiblePosition(positionBeforeNode(startNode), DOWNSTREAM);
     381    VisiblePosition visPos = startNode->isTextNode() ? VisiblePosition(Position(startNode, static_cast<InlineTextBox *>(startBox)->start(), Position::PositionIsOffsetInAnchor), DOWNSTREAM)
     382                                                     : VisiblePosition(positionBeforeNode(startNode), DOWNSTREAM);
    382383    return positionAvoidingFirstPositionInTable(visPos);
    383384}
Note: See TracChangeset for help on using the changeset viewer.