[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:24:24 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 9de353590612b29507f83c1f3ad5178ca3059d93
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 28 01:50:35 2004 +0000
WebCore:
Fixed:
<rdar://problem/3541812>: Implement Paste menu item
<rdar://problem/3541814>: Implement Delete menu item
<rdar://problem/3541811>: Implement Cut menu item
Reviewed by dave.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::deleteSelection): new
(DocumentImpl::pasteHTMLString): new
* khtml/xml/dom_docimpl.h:
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge isEditable]): new
(-[WebCoreBridge pasteHTMLString:]): new
(-[WebCoreBridge deleteSelection]): new
(-[WebCoreBridge haveSelection]): new
WebKit:
Fixed:
<rdar://problem/3541812>: Implement Paste menu item
<rdar://problem/3541814>: Implement Delete menu item
<rdar://problem/3541811>: Implement Cut menu item
Reviewed by dave.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _haveSelection]): new, renamed from hasSelection, calls haveSelection on the bridge, quicker than generating string rep of selection
(-[WebHTMLView _canDelete]): new
(-[WebHTMLView _canPaste]): new
(-[WebHTMLView takeFindStringFromSelection:]): call renamed _haveSelection
(-[WebHTMLView cut:]): new
(-[WebHTMLView delete:]): new
(-[WebHTMLView paste:]): new
(-[WebHTMLView validateUserInterfaceItem:]): updated for new methods
(-[WebHTMLView validRequestorForSendType:returnType:]): call renamed _haveSelection
* WebView.subproj/WebHTMLViewPrivate.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index cadfd71..dba1cf3 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,23 @@
+2004-01-27 Chris Blumenberg <cblu at apple.com>
+
+ Fixed:
+ <rdar://problem/3541812>: Implement Paste menu item
+ <rdar://problem/3541814>: Implement Delete menu item
+ <rdar://problem/3541811>: Implement Cut menu item
+
+ Reviewed by dave.
+
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::deleteSelection): new
+ (DocumentImpl::pasteHTMLString): new
+ * khtml/xml/dom_docimpl.h:
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge isEditable]): new
+ (-[WebCoreBridge pasteHTMLString:]): new
+ (-[WebCoreBridge deleteSelection]): new
+ (-[WebCoreBridge haveSelection]): new
+
2004-01-27 David Hyatt <hyatt at apple.com>
Add a new AtomicString type (that is really just a KJS::Identifier). Define a Name class that will eventually
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index fbefe75..67167db 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -1199,6 +1199,85 @@ void DocumentImpl::clearSelection()
static_cast<RenderCanvas*>(m_render)->clearSelection();
}
+void DocumentImpl::deleteSelection()
+{
+ KHTMLSelection &selection = part()->getKHTMLSelection();
+ clearSelection();
+ Range range(selection.startNode(), selection.startOffset(), selection.endNode(), selection.endOffset());
+ range.deleteContents();
+}
+
+void DocumentImpl::pasteHTMLString(const QString &HTMLString)
+{
+ deleteSelection();
+
+ KHTMLSelection &selection = part()->getKHTMLSelection();
+ DOM::NodeImpl *startNode = selection.startNode();
+ long startOffset = selection.startOffset();
+ DOM::NodeImpl *endNode = selection.endNode();
+
+ if (startNode == NULL || endNode == NULL) {
+ return;
+ }
+
+ DOMString string = DOMString(HTMLString);
+ DocumentFragmentImpl *root = static_cast<HTMLElementImpl *>(startNode)->createContextualFragment(string);
+ if (root == NULL) {
+ return;
+ }
+
+ TextImpl *textNode = startNode->isTextNode() ? static_cast<TextImpl *>(startNode) : NULL;
+ DOM::NodeImpl *firstChild = root->firstChild();
+ DOM::NodeImpl *lastChild = root->lastChild();
+ if (firstChild == NULL || lastChild == NULL) {
+ return;
+ }
+
+ int exceptionCode = 0;
+ long finalOffset;
+
+ if (textNode && firstChild == lastChild && firstChild->isTextNode()) {
+ // Simple text paste. Add the text to the text node with the caret.
+ textNode->insertData(startOffset, static_cast<TextImpl *>(firstChild)->data(), exceptionCode);
+ finalOffset = startOffset + static_cast<TextImpl *>(firstChild)->length();
+ selection.setSelection(textNode, finalOffset);
+ } else {
+ // HTML tree paste.
+ DOM::NodeImpl *parent = startNode->parentNode();
+ DOM::NodeImpl *afterNode = NULL;
+ if (textNode) {
+ // Split the text node.
+ TextImpl *textBeforeNode = createTextNode(textNode->substringData(0, startOffset, exceptionCode));
+ textNode->deleteData(0, selection.startOffset(), exceptionCode);
+ parent->insertBefore(textBeforeNode, textNode, exceptionCode);
+ afterNode = textNode;
+ }
+
+ // Add the children of the pasted root to the document.
+ DOM::NodeImpl *child = lastChild;
+ while (child) {
+ DOM::NodeImpl *previousSibling = child->previousSibling();
+ parent->insertBefore(child, afterNode, exceptionCode);
+ afterNode = child;
+ child = previousSibling;
+ }
+
+ // Find the last leaf and place the caret after it.
+ child = lastChild;
+ while (1) {
+ DOM::NodeImpl *nextChild = child->lastChild();
+ if (!nextChild) {
+ break;
+ }
+ child = nextChild;
+ }
+ finalOffset = child->isTextNode() ? static_cast<TextImpl *>(child)->length() : 0;
+ selection.setSelection(child, finalOffset);
+ }
+
+ setSelection(selection);
+}
+
Tokenizer *DocumentImpl::createTokenizer()
{
return new XMLTokenizer(docPtr(),m_view);
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 488b88d..d5a9f97 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -267,6 +267,9 @@ public:
void setSelection(NodeImpl* s, int sp, NodeImpl* e, int ep);
void setSelection(KHTMLSelection &);
void clearSelection();
+ void deleteSelection();
+
+ void pasteHTMLString(const QString &HTMLString);
void open();
void close();
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index f105718..33cd563 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -200,6 +200,11 @@ typedef enum {
- (void)setSelectionFrom:(id <WebDOMNode>)start startOffset:(int)startOffset to:(id <WebDOMNode>)end endOffset:(int) endOffset;
+- (BOOL)isEditable;
+- (void)pasteHTMLString:(NSString *)HTMLString;
+- (void)deleteSelection;
+
+- (BOOL)haveSelection;
- (NSString *)selectedHTML;
- (NSString *)selectedString;
- (NSAttributedString *)selectedAttributedString;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index b80bbff..9aa89f5 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -356,6 +356,33 @@ static bool initializedKJS = FALSE;
_part->gotoAnchor(QString::fromNSString(a));
}
+- (BOOL)isEditable
+{
+ NodeImpl *startNode = _part->getKHTMLSelection().startNode();
+ return startNode ? startNode->isContentEditable() : NO;
+}
+
+- (void)pasteHTMLString:(NSString *)HTMLString
+{
+ DocumentImpl *doc = _part->xmlDocImpl();
+ if (doc) {
+ doc->pasteHTMLString(QString::fromNSString(HTMLString));
+ }
+}
+
+- (void)deleteSelection
+{
+ DocumentImpl *doc = _part->xmlDocImpl();
+ if (doc) {
+ doc->deleteSelection();
+ }
+}
+
+- (BOOL)haveSelection
+{
+ return _part->getKHTMLSelection().state() == KHTMLSelection::RANGE;
+}
+
- (NSString *)selectedHTML
{
return _part->selection().toHTML().string().getNSString();
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6e54078..e0647b2 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,26 @@
2004-01-27 Chris Blumenberg <cblu at apple.com>
+ Fixed:
+ <rdar://problem/3541812>: Implement Paste menu item
+ <rdar://problem/3541814>: Implement Delete menu item
+ <rdar://problem/3541811>: Implement Cut menu item
+
+ Reviewed by dave.
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _haveSelection]): new, renamed from hasSelection, calls haveSelection on the bridge, quicker than generating string rep of selection
+ (-[WebHTMLView _canDelete]): new
+ (-[WebHTMLView _canPaste]): new
+ (-[WebHTMLView takeFindStringFromSelection:]): call renamed _haveSelection
+ (-[WebHTMLView cut:]): new
+ (-[WebHTMLView delete:]): new
+ (-[WebHTMLView paste:]): new
+ (-[WebHTMLView validateUserInterfaceItem:]): updated for new methods
+ (-[WebHTMLView validRequestorForSendType:returnType:]): call renamed _haveSelection
+ * WebView.subproj/WebHTMLViewPrivate.h:
+
+2004-01-27 Chris Blumenberg <cblu at apple.com>
+
Fixed build breakage.
Reviewed by darin.
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 8d5da0d..a14db7d 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -530,6 +530,20 @@ static WebHTMLView *lastHitView = nil;
[pasteboard setString:[self selectedString] forType:NSStringPboardType];
}
+- (BOOL)_haveSelection
+{
+ return [[self _bridge] haveSelection];
+}
+
+- (BOOL)_canDelete
+{
+ return [self _haveSelection] && [[self _bridge] isEditable];
+}
+
+- (BOOL)_canPaste
+{
+ return [[self _bridge] isEditable];
+}
-(NSImage *)_dragImageForLinkElement:(NSDictionary *)element
{
@@ -896,14 +910,9 @@ static WebHTMLView *lastHitView = nil;
[super dealloc];
}
-- (BOOL)hasSelection
-{
- return [[self selectedString] length] != 0;
-}
-
- (IBAction)takeFindStringFromSelection:(id)sender
{
- if (![self hasSelection]) {
+ if (![self _haveSelection]) {
NSBeep();
return;
}
@@ -916,6 +925,34 @@ static WebHTMLView *lastHitView = nil;
[self _writeSelectionToPasteboard:[NSPasteboard generalPasteboard]];
}
+- (void)cut:(id)sender
+{
+ [self copy:sender];
+ [[self _bridge] deleteSelection];
+}
+
+- (void)delete:(id)sender
+{
+ [[self _bridge] deleteSelection];
+}
+
+- (void)paste:(id)sender
+{
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ NSArray *types = [pasteboard types];
+ NSString *HTMLString = nil;
+
+ if ([types containsObject:NSHTMLPboardType]) {
+ HTMLString = [pasteboard stringForType:NSHTMLPboardType];
+ } else if ([types containsObject:NSStringPboardType]) {
+ HTMLString = [pasteboard stringForType:NSStringPboardType];
+ }
+
+ if (HTMLString) {
+ [[self _bridge] pasteHTMLString:HTMLString];
+ }
+}
+
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
{
[self _writeSelectionToPasteboard:pasteboard];
@@ -932,24 +969,30 @@ static WebHTMLView *lastHitView = nil;
[[self _bridge] jumpToSelection];
}
-
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
SEL action = [item action];
- if (action == @selector(copy:))
- return [self hasSelection];
- else if (action == @selector(takeFindStringFromSelection:))
- return [self hasSelection];
- else if (action == @selector(jumpToSelection:))
- return [self hasSelection];
+ if (action == @selector(cut:)) {
+ return [self _canDelete];
+ } else if (action == @selector(copy:)) {
+ return [self _haveSelection];
+ } else if (action == @selector(delete:)) {
+ return [self _canDelete];
+ } else if (action == @selector(paste:)) {
+ return [self _canPaste];
+ }else if (action == @selector(takeFindStringFromSelection:)) {
+ return [self _haveSelection];
+ }else if (action == @selector(jumpToSelection:)) {
+ return [self _haveSelection];
+ }
return YES;
}
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
{
- if (sendType && ([[[self class] _pasteboardTypes] containsObject:sendType]) && [self hasSelection]){
+ if (sendType && ([[[self class] _pasteboardTypes] containsObject:sendType]) && [self _haveSelection]){
return self;
}
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index 21fa082..e2bdf41 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -70,6 +70,10 @@
+ (NSArray *)_pasteboardTypes;
- (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard;
+- (BOOL)_canDelete;
+- (BOOL)_canPaste;
+- (BOOL)_haveSelection;
+
- (void)_frameOrBoundsChanged;
- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list