Commit 6d377800 authored by lweintraub's avatar lweintraub
Browse files

LayoutTests:

        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: http://svn.webkit.org/repository/webkit/trunk@15206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 22601712
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.
4f3c4bb088358dbb7dd79f971a4a41b8
\ No newline at end of file
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
<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
......@@ -9,7 +9,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
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.
......
......@@ -265,6 +265,7 @@ public:
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;
......
......@@ -3169,6 +3169,11 @@ bool FrameMac::shouldChangeSelection(const SelectionController &oldSelection, co
stillSelecting:stillSelecting];
}
bool FrameMac::shouldDeleteSelection(const SelectionController &selection) const
{
return [_bridge shouldDeleteSelectedDOMRange:[DOMRange _rangeWith:selection.toRange().get()]];
}
void FrameMac::respondToChangedContents()
{
if (AccessibilityObjectCache::accessibilityEnabled())
......
......@@ -665,6 +665,7 @@ typedef enum {
- (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;
......
......@@ -28,6 +28,7 @@
#include "BeforeTextInsertedEvent.h"
#include "BreakBlockquoteCommand.h"
#include "DeleteSelectionCommand.h"
#include "Document.h"
#include "Element.h"
#include "Frame.h"
......@@ -332,6 +333,12 @@ void TypingCommand::deleteKeyPressed()
// 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;
}
......@@ -340,7 +347,7 @@ void TypingCommand::deleteKeyPressed()
break;
}
if (selectionToDelete.isCaretOrRange()) {
if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(SelectionController(selectionToDelete))) {
deleteSelection(selectionToDelete, m_smartDelete);
setSmartDelete(false);
typingAddedToOpenCommand();
......@@ -361,6 +368,12 @@ void TypingCommand::forwardDeleteKeyPressed()
// 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;
}
......@@ -369,7 +382,7 @@ void TypingCommand::forwardDeleteKeyPressed()
break;
}
if (selectionToDelete.isCaretOrRange()) {
if (selectionToDelete.isCaretOrRange() && document()->frame()->shouldDeleteSelection(SelectionController(selectionToDelete))) {
deleteSelection(selectionToDelete, m_smartDelete);
setSmartDelete(false);
typingAddedToOpenCommand();
......
......@@ -1973,6 +1973,11 @@ bool Frame::shouldChangeSelection(const SelectionController& newselection) const
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;
......
......@@ -327,6 +327,7 @@ public:
// 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
......
......@@ -1471,6 +1471,12 @@ - (BOOL)shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRan
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];
......
......@@ -574,10 +574,6 @@ - (void)_deleteRange:(DOMRange *)range
smartDeleteOK:(BOOL)smartDeleteOK
deletionAction:(WebDeletionAction)deletionAction
{
if (![self _shouldDeleteRange:range]) {
return;
}
WebFrameBridge *bridge = [self _bridge];
BOOL smartDelete = smartDeleteOK ? [self _canSmartCopyOrDelete] : NO;
......@@ -4537,7 +4533,7 @@ - (BOOL)_deleteWithDirection:(WebBridgeSelectionDirection)direction granularity:
if (isTypingAction)
deletionAction = deleteKeyAction;
} else {
range = [[self _bridge] rangeByAlteringCurrentSelection:WebSelectByExtending direction:direction granularity:granularity];
range = [self _selectedRange];
if (isTypingAction)
switch (direction) {
case WebBridgeSelectForward:
......@@ -4551,7 +4547,7 @@ - (BOOL)_deleteWithDirection:(WebBridgeSelectionDirection)direction granularity:
}
}
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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment