Reviewed by justin
Improved table editing
* editing/deleting/delete-to-select-table-expected.checksum: Added.
* editing/deleting/delete-to-select-table-expected.png: Added.
* editing/deleting/delete-to-select-table-expected.txt: Added.
* editing/deleting/delete-to-select-table.html: Added.
* editing/input/text-input-controller-expected.txt:
WebCore:
Reviewed by justin
Improved table editing: pressing delete directly before or after a table will now select
the table first, then delete it, instead of just deleting it. Useful for when the table's
existence is non-obvious.
* bridge/mac/FrameMac.h: Added shouldDeleteSelection, which allows WebCore to trigger
deletion editing deligates
* bridge/mac/FrameMac.mm: ditto
(WebCore::FrameMac::shouldDeleteSelection):
* bridge/mac/WebCoreFrameBridge.h: ditto
* editing/TypingCommand.cpp: Implemented check for a caret position next to a table, and
subsequent selection (as opposed to removal)
(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):
* page/Frame.cpp: shouldDeleteSelection added
(WebCore::Frame::shouldDeleteSelection):
* page/Frame.h: ditto
WebKit:
Reviewed by justin
Improved table editing
* WebCoreSupport/WebFrameBridge.m: Added method to allow WebCore to trigger
deletion editing delegate
(-[WebFrameBridge shouldDeleteSelectedDOMRange:]):
* WebView/WebHTMLView.m: Moved code that expanded a selection when the delete
key is pressed over to WebCore so we can be more intelligent about how to handle it
(-[WebHTMLView _deleteRange:killRing:prepend:smartDeleteOK:deletionAction:]):
(-[NSArray _deleteWithDirection:granularity:killRing:isTypingAction:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15206
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-07 Levi Weintraub <lweintraub@apple.com>
+
+ Reviewed by justin
+
+ Improved table editing
+
+ * editing/deleting/delete-to-select-table-expected.checksum: Added.
+ * editing/deleting/delete-to-select-table-expected.png: Added.
+ * editing/deleting/delete-to-select-table-expected.txt: Added.
+ * editing/deleting/delete-to-select-table.html: Added.
+ * editing/input/text-input-controller-expected.txt:
+
2006-07-07 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
--- /dev/null
+4f3c4bb088358dbb7dd79f971a4a41b8
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of TABLE > DIV > BODY > HTML > #document to 2 of TABLE > DIV > BODY > HTML > #document toDOMRange:range from 0 of TABLE > DIV > BODY > HTML > #document to 2 of TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x52
+ RenderTable {TABLE} at (0,0) size 86x52 [border: (3px solid #AAAAAA)]
+ RenderTableSection {TBODY} at (3,3) size 80x46
+ RenderTableRow {TR} at (0,2) size 80x20
+ RenderTableCell {TD} at (2,2) size 27x20 [r=0 c=0 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 25x18
+ text run at (1,1) width 25: "Foo"
+ RenderTableCell {TD} at (31,2) size 47x20 [r=0 c=1 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 22x18
+ text run at (1,1) width 22: "baz"
+ RenderTableRow {TR} at (0,24) size 80x20
+ RenderTableCell {TD} at (2,24) size 27x20 [r=1 c=0 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 25x18
+ text run at (1,1) width 25: "bar "
+ RenderTableCell {TD} at (31,24) size 47x20 [r=1 c=1 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 45x18
+ text run at (1,1) width 45: "buffalo"
+selection start: position 0 of child 1 {TABLE} of child 0 {DIV} of child 2 {BODY} of child 0 {HTML} of document
+selection end: position 2 of child 1 {TABLE} of child 0 {DIV} of child 2 {BODY} of child 0 {HTML} of document
--- /dev/null
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+function editingTest() {
+ for (i = 0; i < 30; i++) {
+ moveSelectionForwardByCharacterCommand();
+ }
+ for (i = 0; i < 1; i++) {
+ deleteCommand();
+ }
+}
+</script>
+<div contenteditable="true" id="test">
+ <table style="border:3px solid #aaa;">
+ <tr>
+ <td>
+ Foo
+ </td>
+ <td>
+ baz
+ </td>
+ </tr>
+ <tr>
+ <td>
+ bar
+ </td>
+ <td>
+ buffalo
+ </td>
+ </tr>
+ </table>
+</div>
+<script>
+runEditingTest();
+</script>
\ No newline at end of file
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 13 of #text > DIV > BODY > HTML > #document to 13 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 13 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 13 of #text > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+2006-07-06 Levi Weintraub <lweintraub@apple.com>
+
+ Reviewed by justin
+
+ Improved table editing: pressing delete directly before or after a table will now select
+ the table first, then delete it, instead of just deleting it. Useful for when the table's
+ existence is non-obvious.
+
+ * bridge/mac/FrameMac.h: Added shouldDeleteSelection, which allows WebCore to trigger
+ deletion editing deligates
+ * bridge/mac/FrameMac.mm: ditto
+ (WebCore::FrameMac::shouldDeleteSelection):
+ * bridge/mac/WebCoreFrameBridge.h: ditto
+ * editing/TypingCommand.cpp: Implemented check for a caret position next to a table, and
+ subsequent selection (as opposed to removal)
+ (WebCore::TypingCommand::deleteKeyPressed):
+ (WebCore::TypingCommand::forwardDeleteKeyPressed):
+ * page/Frame.cpp: shouldDeleteSelection added
+ (WebCore::Frame::shouldDeleteSelection):
+ * page/Frame.h: ditto
+
2006-07-07 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Eric.
virtual void respondToChangedContents();
virtual bool isContentEditable() const;
virtual bool shouldChangeSelection(const SelectionController &oldSelection, const SelectionController &newSelection, EAffinity affinity, bool stillSelecting) const;
+ virtual bool shouldDeleteSelection(const SelectionController&) const;
virtual bool shouldBeginEditing(const Range*) const;
virtual bool shouldEndEditing(const Range*) const;
virtual void didBeginEditing() const;
stillSelecting:stillSelecting];
}
+bool FrameMac::shouldDeleteSelection(const SelectionController &selection) const
+{
+ return [_bridge shouldDeleteSelectedDOMRange:[DOMRange _rangeWith:selection.toRange().get()]];
+}
+
void FrameMac::respondToChangedContents()
{
if (AccessibilityObjectCache::accessibilityEnabled())
- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;
- (BOOL)isEditable;
- (BOOL)shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
+- (BOOL)shouldDeleteSelectedDOMRange:(DOMRange *)currentRange;
- (BOOL)shouldBeginEditing:(DOMRange *)range;
- (BOOL)shouldEndEditing:(DOMRange *)range;
- (void)didBeginEditing;
#include "BeforeTextInsertedEvent.h"
#include "BreakBlockquoteCommand.h"
+#include "DeleteSelectionCommand.h"
#include "Document.h"
#include "Element.h"
#include "Frame.h"
// root editable element or at the start of a document.
SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
sc.modify(SelectionController::EXTEND, SelectionController::BACKWARD, CharacterGranularity);
+ Position upstreamStart = endingSelection().start().upstream();
+ // When deleting tables: Select the table first, then perform the deletion
+ if (upstreamStart.node()->renderer() && upstreamStart.node()->renderer()->isTable() && upstreamStart.offset() == maxDeepOffset(upstreamStart.node())) {
+ setEndingSelection(Selection(Position(upstreamStart.node(), 0), upstreamStart, DOWNSTREAM));
+ return;
+ }
selectionToDelete = sc.selection();
break;
}
break;
}
- if (selectionToDelete.isCaretOrRange()) {
+ if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(SelectionController(selectionToDelete))) {
deleteSelection(selectionToDelete, m_smartDelete);
setSmartDelete(false);
typingAddedToOpenCommand();
// root editable element or at the start of a document.
SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
sc.modify(SelectionController::EXTEND, SelectionController::FORWARD, CharacterGranularity);
+ Position downstreamEnd = endingSelection().end().downstream();
+ // When deleting tables: Select the table first, then perform the deletion
+ if (downstreamEnd.node()->renderer() && downstreamEnd.node()->renderer()->isTable() && downstreamEnd.offset() == 0) {
+ setEndingSelection(Selection(downstreamEnd, Position(downstreamEnd.node(), maxDeepOffset(downstreamEnd.node())), DOWNSTREAM));
+ return;
+ }
selectionToDelete = sc.selection();
break;
}
break;
}
- if (selectionToDelete.isCaretOrRange()) {
+ if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(SelectionController(selectionToDelete))) {
deleteSelection(selectionToDelete, m_smartDelete);
setSmartDelete(false);
typingAddedToOpenCommand();
return shouldChangeSelection(d->m_selection, newselection, newselection.affinity(), false);
}
+bool Frame::shouldDeleteSelection(const SelectionController& newselection) const
+{
+ return true;
+}
+
bool Frame::shouldBeginEditing(const Range *range) const
{
return true;
// FIXME: Replace these with functions on the selection controller.
void setSelection(const SelectionController&, bool closeTyping = true, bool keepTypingStyle = false);
bool shouldChangeSelection(const SelectionController&) const;
+ bool shouldDeleteSelection(const SelectionController&) const;
void notifyRendererOfSelectionChange(bool userTriggered);
+2006-07-06 Levi Weintraub <lweintraub@apple.com>
+
+ Reviewed by justin
+
+ Improved table editing
+
+ * WebCoreSupport/WebFrameBridge.m: Added method to allow WebCore to trigger
+ deletion editing delegate
+ (-[WebFrameBridge shouldDeleteSelectedDOMRange:]):
+ * WebView/WebHTMLView.m: Moved code that expanded a selection when the delete
+ key is pressed over to WebCore so we can be more intelligent about how to handle it
+ (-[WebHTMLView _deleteRange:killRing:prepend:smartDeleteOK:deletionAction:]):
+ (-[NSArray _deleteWithDirection:granularity:killRing:isTypingAction:]):
+
2006-07-07 John Sullivan <sullivan@apple.com>
Reviewed by Tim Hatcher
return [[self webView] _shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange affinity:selectionAffinity stillSelecting:flag];
}
+- (BOOL)shouldDeleteSelectedDOMRange:(DOMRange *)range
+{
+ WebView *webView = [self webView];
+ return [[webView _editingDelegateForwarder] webView:webView shouldDeleteDOMRange:range];
+}
+
- (BOOL)shouldBeginEditing:(DOMRange *)range
{
return [[self webView] _shouldBeginEditingInDOMRange:range];
smartDeleteOK:(BOOL)smartDeleteOK
deletionAction:(WebDeletionAction)deletionAction
{
- if (![self _shouldDeleteRange:range]) {
- return;
- }
-
WebFrameBridge *bridge = [self _bridge];
BOOL smartDelete = smartDeleteOK ? [self _canSmartCopyOrDelete] : NO;
if (isTypingAction)
deletionAction = deleteKeyAction;
} else {
- range = [[self _bridge] rangeByAlteringCurrentSelection:WebSelectByExtending direction:direction granularity:granularity];
+ range = [self _selectedRange];
if (isTypingAction)
switch (direction) {
case WebBridgeSelectForward:
}
}
- if (range == nil || [range collapsed] || ![self _shouldDeleteRange:range])
+ if (range == nil)
return NO;
[self _deleteRange:range killRing:killRing prepend:NO smartDeleteOK:NO deletionAction:deletionAction];
return YES;