Changeset 82791 in webkit
- Timestamp:
- Apr 3, 2011 12:54:33 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r82790 r82791 1 2011-03-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 editing commands shouldn't run when there's no body 6 https://bugs.webkit.org/show_bug.cgi?id=56771 7 8 Added tests to ensure WebKit does not crash when attempted to execute editing commands 9 in an empty document. Also added a test to ensure WebKit does not crash when InsertImage 10 is executed with selection endpoints being document. WebKit should ignore such attempts 11 and should not crash. 12 13 * editing/editability/empty-document-delete-expected.txt: Added. 14 * editing/editability/empty-document-delete.html: Added. 15 * editing/editability/empty-document-justify-right-expected.txt: Added. 16 * editing/editability/empty-document-justify-right.html: Added. 17 * editing/editability/empty-document-stylewithcss-expected.txt: Added. 18 * editing/editability/empty-document-stylewithcss.html: Added. 19 * editing/execCommand/insert-image-with-selecting-document-expected.txt: Added. 20 * editing/execCommand/insert-image-with-selecting-document.html: Added. 21 1 22 2011-04-02 Dan Bernstein <mitz@apple.com> 2 23 -
trunk/Source/WebCore/ChangeLog
r82788 r82791 1 2011-03-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 editing commands shouldn't run when there's no body 6 https://bugs.webkit.org/show_bug.cgi?id=56771 7 8 The bug was caused by WebKit's not checking the existence of root editable element 9 in enabled* functions. Although isContentEditable returns true whenever we're in design mode, 10 we should not run editing commands in a document without a body element editable because 11 doing so results in appending a non-body element to the document node. 12 13 Fixed the bug by modifying various enabled* functions to ensure we have a root editable element. 14 New behavior tries to match that of Firefox except StyleWithCSS, which Firefox seems to ignore 15 when there are no body element. Since StyleWithCSS is a document's state or property, we allow 16 execCommand('StyleWithCSS') even in a document without a body element. 17 18 WebKit's and Firefox's behaviors also deviate in insert-image-with-selecting-document.html. 19 Whereas WebKit respects selection set by script and ignores execCommand, Firefox modifies 20 the selection when document.write("x") is ran and successfully inserts image. 21 22 Thus, empty-document-delete.html and empty-document-justify-right.html both pass on Firefox 23 while empty-document-stylewithcss.html and insert-image-with-selecting-document.html both fail. 24 25 Since Internet Explorer does not allow execCommand to run under design mode properly, we could 26 not test its behavior. 27 28 Tests: editing/editability/empty-document-delete.html 29 editing/editability/empty-document-justify-right.html 30 editing/editability/empty-document-stylewithcss.html 31 editing/execCommand/insert-image-with-selecting-document.html 32 33 * editing/Editor.cpp: 34 (WebCore::Editor::canEdit): Verify that the root editable element exists 35 instead of just checking that selection endpoints are editable because 36 selection endpoints could be document node without a body element in design mode 37 and we don't want to consider such a document editable. 38 (WebCore::Editor::canDelete): Ditto. 39 * editing/EditorCommand.cpp: 40 (WebCore::enabledInEditableText): Ditto. 41 (WebCore::enabledInRichlyEditableText): Ditto. 42 (WebCore::enabledDelete): Call enabledCut and enabledInEditableText instead 43 of duplicating the code in order to fix the same bug. 44 1 45 2011-04-02 Dan Bernstein <mitz@apple.com> 2 46 -
trunk/Source/WebCore/editing/Editor.cpp
r82533 r82791 211 211 bool Editor::canEdit() const 212 212 { 213 return m_frame->selection()-> isContentEditable();213 return m_frame->selection()->rootEditableElement(); 214 214 } 215 215 … … 279 279 { 280 280 SelectionController* selection = m_frame->selection(); 281 return selection->isRange() && selection-> isContentEditable();281 return selection->isRange() && selection->rootEditableElement(); 282 282 } 283 283 -
trunk/Source/WebCore/editing/EditorCommand.cpp
r82176 r82791 1197 1197 } 1198 1198 1199 static bool enabledInEditableText(Frame* frame, Event* event, EditorCommandSource) 1200 { 1201 return frame->editor()->selectionForCommand(event).rootEditableElement(); 1202 } 1203 1199 1204 static bool enabledDelete(Frame* frame, Event* event, EditorCommandSource source) 1200 1205 { … … 1202 1207 case CommandFromMenuOrKeyBinding: 1203 1208 // "Delete" from menu only affects selected range, just like Cut but without affecting pasteboard 1204 return frame->editor()->canDHTMLCut() || frame->editor()->canCut();1209 return enabledCut(frame, event, source); 1205 1210 case CommandFromDOM: 1206 1211 case CommandFromDOMWithUserInterface: 1207 1212 // "Delete" from DOM is like delete/backspace keypress, affects selected range if non-empty, 1208 1213 // otherwise removes a character 1209 return frame->editor()->selectionForCommand(event).isContentEditable();1214 return enabledInEditableText(frame, event, source); 1210 1215 } 1211 1216 ASSERT_NOT_REACHED(); … … 1213 1218 } 1214 1219 1215 static bool enabledInEditableText(Frame* frame, Event* event, EditorCommandSource)1216 {1217 return frame->editor()->selectionForCommand(event).isContentEditable();1218 }1219 1220 1220 static bool enabledInEditableTextOrCaretBrowsing(Frame* frame, Event* event, EditorCommandSource) 1221 1221 { … … 1226 1226 static bool enabledInRichlyEditableText(Frame* frame, Event*, EditorCommandSource) 1227 1227 { 1228 return frame->selection()->isCaretOrRange() && frame->selection()->isContentRichlyEditable() ;1228 return frame->selection()->isCaretOrRange() && frame->selection()->isContentRichlyEditable() && frame->selection()->rootEditableElement(); 1229 1229 } 1230 1230
Note: See TracChangeset
for help on using the changeset viewer.