[Shadow][Editing] applying document.execCommand('bold') twice to elements having...
authorshinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jun 2012 20:13:45 +0000 (20:13 +0000)
committershinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jun 2012 20:13:45 +0000 (20:13 +0000)
commit6ed9a4a2683bd66f86a1347385d3260054c9e7b6
tree9d022f3150d5c0892fa999336b1dafb29709c3d6
parent24bdf077b06c7a376b001e869822cd421f3c14e0
[Shadow][Editing] applying document.execCommand('bold') twice to elements having shadow insertion points causes a crash.
https://bugs.webkit.org/show_bug.cgi?id=88502

Reviewed by Ryosuke Niwa.

Source/WebCore:

When inserting or removing insertion points (<shadow> or <content>) into or from Shdaow DOM,
ElementShadow::invalidateDistribution() will be called immediately. It will remove all the renderers
of elements in the Shadow DOM. Since Node::rendererIsEditable() returns false when an renderer does not
exist, all the elements in the Shadow DOM will be considered as non-content-editable until recalculating
layout, though some of them may actually be content-editable.

Actually the current code does not recalculate layout inside editing command, so a disaster happens.
For example, performing an editing command quits before completing all the commands, because the command
thinks it is adding some elements to a non-content-editable element (but actually it's content-editable).

So we have to recalculate layout if necessary when checking an element is content-editable or not.
This can be achieved by using Node::isContentEditable() instead of Node::rendererIsEditable().

Test: editing/shadow/bold-twice-in-shadow.html

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
* editing/InsertNodeBeforeCommand.cpp:
(WebCore::InsertNodeBeforeCommand::doApply):
(WebCore::InsertNodeBeforeCommand::doUnapply):
* editing/RemoveNodeCommand.cpp:
(WebCore::RemoveNodeCommand::doApply):

LayoutTests:

* editing/shadow/bold-twice-in-shadow-expected.txt: Added.
* editing/shadow/bold-twice-in-shadow.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/shadow/bold-twice-in-shadow-expected.txt [new file with mode: 0644]
LayoutTests/editing/shadow/bold-twice-in-shadow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/InsertNodeBeforeCommand.cpp
Source/WebCore/editing/RemoveNodeCommand.cpp