Changeset 81185 in webkit


Ignore:
Timestamp:
Mar 15, 2011 3:37:47 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

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

Reviewed by Tony Chang.

Crash in ReplaceSelectionCommand::doApply when inserting a node under a document node
https://bugs.webkit.org/show_bug.cgi?id=56372

The bug was caused by insertNodeAfter's calling parentElement on document's child.
Fixed this by changing the node that AppendNodeCommand takes.

There was also a bug that document node always returned false for isContentEditable
and isContentRichlyEditable because they never overrode Node's default implementation.
Fixed this by overriding them in Document.

Test: editing/execCommand/append-node-under-document.html

  • dom/Document.cpp: (WebCore::Document::isContentEditable): Added. (WebCore::Document::isContentRichlyEditable): Added.
  • dom/Document.h:
  • editing/AppendNodeCommand.cpp: (WebCore::AppendNodeCommand::AppendNodeCommand): Takes ContainerNode instead of Element.
  • editing/AppendNodeCommand.h: (WebCore::AppendNodeCommand::create): Ditto.
  • editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::appendNode): Ditto. (WebCore::CompositeEditCommand::insertNodeAfter): Calls parentNode instead of parentElement.
  • editing/CompositeEditCommand.h:

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

Reviewed by Tony Chang.

Crash in ReplaceSelectionCommand::doApply when inserting a node under a document node
https://bugs.webkit.org/show_bug.cgi?id=56372

Added a test to ensure WebKit does not crash when appending a node to a document
that has only two nested iframes.

  • editing/execCommand/append-node-under-document-expected.txt: Added.
  • editing/execCommand/append-node-under-document.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r81184 r81185  
     12011-03-15  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        Crash in ReplaceSelectionCommand::doApply when inserting a node under a document node
     6        https://bugs.webkit.org/show_bug.cgi?id=56372
     7
     8        Added a test to ensure WebKit does not crash when appending a node to a document
     9        that has only two nested iframes.
     10
     11        * editing/execCommand/append-node-under-document-expected.txt: Added.
     12        * editing/execCommand/append-node-under-document.html: Added.
     13
    1142011-03-15  David Levin  <levin@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r81181 r81185  
     12011-03-15  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        Crash in ReplaceSelectionCommand::doApply when inserting a node under a document node
     6        https://bugs.webkit.org/show_bug.cgi?id=56372
     7
     8        The bug was caused by insertNodeAfter's calling parentElement on document's child.
     9        Fixed this by changing the node that AppendNodeCommand takes.
     10
     11        There was also a bug that document node always returned false for isContentEditable
     12        and isContentRichlyEditable because they never overrode Node's default implementation.
     13        Fixed this by overriding them in Document.
     14
     15        Test: editing/execCommand/append-node-under-document.html
     16
     17        * dom/Document.cpp:
     18        (WebCore::Document::isContentEditable): Added.
     19        (WebCore::Document::isContentRichlyEditable): Added.
     20        * dom/Document.h:
     21        * editing/AppendNodeCommand.cpp:
     22        (WebCore::AppendNodeCommand::AppendNodeCommand): Takes ContainerNode instead of Element.
     23        * editing/AppendNodeCommand.h:
     24        (WebCore::AppendNodeCommand::create): Ditto.
     25        * editing/CompositeEditCommand.cpp:
     26        (WebCore::CompositeEditCommand::appendNode): Ditto.
     27        (WebCore::CompositeEditCommand::insertNodeAfter): Calls parentNode instead of parentElement.
     28        * editing/CompositeEditCommand.h:
     29
    1302011-03-15  David Grogan  <dgrogan@chromium.org>
    231
  • trunk/Source/WebCore/dom/Document.cpp

    r81038 r81185  
    41184118}
    41194119
     4120bool Document::isContentEditable() const
     4121{
     4122    if (inDesignMode())
     4123        return true;
     4124
     4125    return renderer() && (renderer()->style()->userModify() == READ_WRITE || renderer()->style()->userModify() == READ_WRITE_PLAINTEXT_ONLY);
     4126}
     4127
     4128bool Document::isContentRichlyEditable() const
     4129{
     4130    if (inDesignMode())
     4131        return true;
     4132
     4133    return renderer() && renderer()->style()->userModify() == READ_WRITE;
     4134}
     4135
    41204136Document* Document::parentDocument() const
    41214137{
  • trunk/Source/WebCore/dom/Document.h

    r81038 r81185  
    895895    InheritedBool getDesignMode() const;
    896896    bool inDesignMode() const;
     897    virtual bool isContentEditable() const;
     898    virtual bool isContentRichlyEditable() const;
    897899
    898900    Document* parentDocument() const;
  • trunk/Source/WebCore/editing/AppendNodeCommand.cpp

    r72259 r81185  
    3232namespace WebCore {
    3333
    34 AppendNodeCommand::AppendNodeCommand(PassRefPtr<Element> parent, PassRefPtr<Node> node)
     34AppendNodeCommand::AppendNodeCommand(PassRefPtr<ContainerNode> parent, PassRefPtr<Node> node)
    3535    : SimpleEditCommand(parent->document())
    3636    , m_parent(parent)
  • trunk/Source/WebCore/editing/AppendNodeCommand.h

    r39456 r81185  
    3333class AppendNodeCommand : public SimpleEditCommand {
    3434public:
    35     static PassRefPtr<AppendNodeCommand> create(PassRefPtr<Element> parent, PassRefPtr<Node> node)
     35    static PassRefPtr<AppendNodeCommand> create(PassRefPtr<ContainerNode> parent, PassRefPtr<Node> node)
    3636    {
    3737        return adoptRef(new AppendNodeCommand(parent, node));
     
    3939
    4040private:
    41     AppendNodeCommand(PassRefPtr<Element> parent, PassRefPtr<Node> node);
     41    AppendNodeCommand(PassRefPtr<ContainerNode> parent, PassRefPtr<Node>);
    4242
    4343    virtual void doApply();
    4444    virtual void doUnapply();
    4545
    46     RefPtr<Element> m_parent;
     46    RefPtr<ContainerNode> m_parent;
    4747    RefPtr<Node> m_node;
    4848};
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r81165 r81185  
    145145    ASSERT(refChild);
    146146    ASSERT(!refChild->hasTagName(bodyTag));
    147     Element* parent = refChild->parentElement();
     147    ContainerNode* parent = refChild->parentNode();
    148148    ASSERT(parent);
    149149    if (parent->lastChild() == refChild)
     
    185185}
    186186
    187 void CompositeEditCommand::appendNode(PassRefPtr<Node> node, PassRefPtr<Element> parent)
     187void CompositeEditCommand::appendNode(PassRefPtr<Node> node, PassRefPtr<ContainerNode> parent)
    188188{
    189189    ASSERT(canHaveChildrenForEditing(parent.get()));
  • trunk/Source/WebCore/editing/CompositeEditCommand.h

    r80780 r81185  
    5050    // sugary-sweet convenience functions to help create and apply edit commands in composite commands
    5151    //
    52     void appendNode(PassRefPtr<Node>, PassRefPtr<Element> parent);
     52    void appendNode(PassRefPtr<Node>, PassRefPtr<ContainerNode> parent);
    5353    void applyCommandToComposite(PassRefPtr<EditCommand>);
    5454    void applyStyle(const EditingStyle*, EditAction = EditActionChangeAttributes);
Note: See TracChangeset for help on using the changeset viewer.