[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 07:20:58 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 5a77529937d9f9224f39b1bae263296dd9c70a92
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 22 18:25:34 2003 +0000
WebCore:
Added support for text dragging.
Reviewed by dave.
* khtml/khtml_events.cpp:
(khtml::MouseEvent::offset): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
* khtml/khtml_part.cpp:
(KHTMLPart::isPointSelected): new
(KHTMLPart::khtmlMousePressEvent): don't restart the selection when click was on the selection
(KHTMLPart::khtmlMouseMoveEvent): restart the selection since we may not do it in khtmlMousePressEvent
(KHTMLPart::khtmlMouseReleaseEvent): clear the selection if no selection took place
* khtml/khtml_part.h:
* khtml/khtmlpart_p.h:
* khtml/rendering/render_object.cpp:
(RenderObject::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
* khtml/rendering/render_object.h:
* khtml/rendering/render_text.cpp:
(RenderText::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
* khtml/rendering/render_text.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::khtmlMousePressEvent): set booleans indicating that it is OK to drag or select
(KWQKHTMLPart::khtmlMouseMoveEvent): ask WebKit if we can drag. Make this decision here instead of in khtmlMousePressEvent because WebKit needs the drag hysteresis to make the decision.
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge elementAtPoint:]): set the selection bit
WebKit:
Added support for text dragging.
Reviewed by dave.
* Resources/text_clipping.tiff: Added. Temp drag image until we can create an image of the selected text.
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge mayStartDragWithMouseDraggedEvent:]): renamed, we now ask if OK to drag during the drag
* WebKit.exp: renamed element key for selected text
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/WebController.h: renamed element key for selected text
* WebView.subproj/WebController.m: renamed element key for selected text
* WebView.subproj/WebHTMLViewPrivate.h:
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _handleMouseDragged:]): added support for text dragging
(-[WebHTMLView _mayStartDragWithMouseDragged:]): renamed, we now ask if OK to drag during the drag
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c4ab40b..7811f02 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,31 @@
+2003-01-21 Chris Blumenberg <cblu at apple.com>
+
+ Added support for text dragging.
+
+ Reviewed by dave.
+
+ * khtml/khtml_events.cpp:
+ (khtml::MouseEvent::offset): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::isPointSelected): new
+ (KHTMLPart::khtmlMousePressEvent): don't restart the selection when click was on the selection
+ (KHTMLPart::khtmlMouseMoveEvent): restart the selection since we may not do it in khtmlMousePressEvent
+ (KHTMLPart::khtmlMouseReleaseEvent): clear the selection if no selection took place
+ * khtml/khtml_part.h:
+ * khtml/khtmlpart_p.h:
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_text.cpp:
+ (RenderText::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/rendering/render_text.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::khtmlMousePressEvent): set booleans indicating that it is OK to drag or select
+ (KWQKHTMLPart::khtmlMouseMoveEvent): ask WebKit if we can drag. Make this decision here instead of in khtmlMousePressEvent because WebKit needs the drag hysteresis to make the decision.
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge elementAtPoint:]): set the selection bit
+
2003-01-21 Trey Matteson <trey at apple.com>
3032718 - I-beam cursor behavior different between web view and text view
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c4ab40b..7811f02 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2003-01-21 Chris Blumenberg <cblu at apple.com>
+
+ Added support for text dragging.
+
+ Reviewed by dave.
+
+ * khtml/khtml_events.cpp:
+ (khtml::MouseEvent::offset): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::isPointSelected): new
+ (KHTMLPart::khtmlMousePressEvent): don't restart the selection when click was on the selection
+ (KHTMLPart::khtmlMouseMoveEvent): restart the selection since we may not do it in khtmlMousePressEvent
+ (KHTMLPart::khtmlMouseReleaseEvent): clear the selection if no selection took place
+ * khtml/khtml_part.h:
+ * khtml/khtmlpart_p.h:
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_text.cpp:
+ (RenderText::checkSelectionPoint): made checkSelectionPoint take x,y coords, passing the whole event is unnecessary
+ * khtml/rendering/render_text.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::khtmlMousePressEvent): set booleans indicating that it is OK to drag or select
+ (KWQKHTMLPart::khtmlMouseMoveEvent): ask WebKit if we can drag. Make this decision here instead of in khtmlMousePressEvent because WebKit needs the drag hysteresis to make the decision.
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge elementAtPoint:]): set the selection bit
+
2003-01-21 Trey Matteson <trey at apple.com>
3032718 - I-beam cursor behavior different between web view and text view
diff --git a/WebCore/khtml/khtml_events.cpp b/WebCore/khtml/khtml_events.cpp
index 7451efb..706a571 100644
--- a/WebCore/khtml/khtml_events.cpp
+++ b/WebCore/khtml/khtml_events.cpp
@@ -56,7 +56,7 @@ long khtml::MouseEvent::offset() const
if (inner.nodeType() == Node::TEXT_NODE)
inner = inner.parentNode();
inner.handle()->renderer()->absolutePosition(absX, absY);
- inner.handle()->renderer()->checkSelectionPoint( this, absX, absY, tempNode, offset );
+ inner.handle()->renderer()->checkSelectionPoint(m_x, m_y, absX, absY, tempNode, offset );
}
return offset;
}
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 4dcf78b..409af1f 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4116,6 +4116,57 @@ static void findWordBoundary(QChar *chars, int len, int position, int *start, in
}
#endif
+bool KHTMLPart::isPointSelected(int x, int y)
+{
+ if (!xmlDocImpl()->renderer()) {
+ return false;
+ }
+
+ RenderObject::NodeInfo nodeInfo(true, true);
+ xmlDocImpl()->renderer()->layer()->nodeAtPoint(nodeInfo, x, y);
+ DOM::NodeImpl* innerNode = nodeInfo.innerNode();
+ if (!innerNode->renderer()) {
+ return false;
+ }
+
+ int offset = 0, ax, ay;
+ DOM::NodeImpl* node = 0;
+
+ // FIXME: Shouldn't be necessary to skip text nodes.
+ if (innerNode->nodeType() == Node::TEXT_NODE) {
+ innerNode = innerNode->parentNode();
+ }
+ innerNode->renderer()->absolutePosition (ax, ay);
+ innerNode->renderer()->checkSelectionPoint( x, y, ax-innerNode->renderer()->xPos(), ay-innerNode->renderer()->yPos(), node, offset);
+ if (!node) {
+ return false;
+ }
+
+ DOM::Node n = d->m_selectionStart;
+ while(!n.isNull()) {
+ if (n == node) {
+ if ((n == d->m_selectionStart && offset < d->m_startOffset) ||
+ (n == d->m_selectionEnd && offset > d->m_endOffset)) {
+ return false;
+ }
+ return true;
+ }
+ if (n == d->m_selectionEnd) {
+ break;
+ }
+ DOM::Node next = n.firstChild();
+ if (next.isNull()) {
+ next = n.nextSibling();
+ }
+ while (next.isNull() && !n.parentNode().isNull()) {
+ n = n.parentNode();
+ next = n.nextSibling();
+ }
+ n = next;
+ }
+ return false;
+}
+
void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
{
DOM::DOMString url = event->url();
@@ -4141,6 +4192,7 @@ void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
#if APPLE_CHANGES
d->m_selectionInitiatedWithDoubleClick = false;
d->m_selectionInitiatedWithTripleClick = false;
+ d->m_mouseMovedSinceLastMousePress = false;
if (event->qmouseEvent()->clickCount() == 2){
QMouseEvent *_mouse = event->qmouseEvent();
@@ -4159,7 +4211,7 @@ void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
// FIXME: Shouldn't be necessary to skip text nodes.
if (innerNode.nodeType() == Node::TEXT_NODE)
innerNode = innerNode.parentNode();
- innerNode.handle()->renderer()->checkSelectionPoint( event,
+ innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
event->absX()-innerNode.handle()->renderer()->xPos(),
event->absY()-innerNode.handle()->renderer()->yPos(),
node, startOffset);
@@ -4210,7 +4262,7 @@ void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
// FIXME: Shouldn't be necessary to skip text nodes.
if (innerNode.nodeType() == Node::TEXT_NODE)
innerNode = innerNode.parentNode();
- innerNode.handle()->renderer()->checkSelectionPoint( event,
+ innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
event->absX()-innerNode.handle()->renderer()->xPos(),
event->absY()-innerNode.handle()->renderer()->yPos(),
node, startOffset);
@@ -4238,13 +4290,20 @@ void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
if ( _mouse->button() == LeftButton )
{
if ( !innerNode.isNull() && innerNode.handle()->renderer()) {
+#if APPLE_CHANGES
+ // Don't restart the selection when the mouse is pressed on an
+ // existing selection so we can allow for text dragging.
+ if (isPointSelected(event->x(), event->y())) {
+ return;
+ }
+#endif
int offset = 0;
DOM::NodeImpl* node = 0;
// FIXME: Shouldn't be necessary to skip text nodes.
if (innerNode.nodeType() == Node::TEXT_NODE)
innerNode = innerNode.parentNode();
- innerNode.handle()->renderer()->checkSelectionPoint( event,
+ innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
event->absX()-innerNode.handle()->renderer()->xPos(),
event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
@@ -4401,7 +4460,7 @@ void KHTMLPart::khtmlMouseMoveEvent( khtml::MouseMoveEvent *event )
// FIXME: Shouldn't be necessary to skip text nodes.
if (innerNode.nodeType() == Node::TEXT_NODE)
innerNode = innerNode.parentNode();
- innerNode.handle()->renderer()->checkSelectionPoint( event,
+ innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
event->absX()-innerNode.handle()->renderer()->xPos(),
event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
// if (d->m_selectionEnd.handle() && d->m_selectionEnd.handle()->renderer())
@@ -4412,6 +4471,17 @@ void KHTMLPart::khtmlMouseMoveEvent( khtml::MouseMoveEvent *event )
// Don't modify the selection if we're not on a node.
if (node == 0)
return;
+
+ // Restart the selection if this is the first mouse move. This work is usually
+ // done in khtmlMousePressEvent, but not if the mouse press was on an existing selection.
+ if (!d->m_mouseMovedSinceLastMousePress) {
+ d->m_mouseMovedSinceLastMousePress = true;
+ d->m_selectionStart = node;
+ d->m_startOffset = offset;
+ d->m_selectionEnd = node;
+ d->m_endOffset = offset;
+ d->m_doc->clearSelection();
+ }
#endif
// we have to get to know if end is before start or not...
DOM::Node n = d->m_selectionStart;
@@ -4567,7 +4637,20 @@ void KHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event )
}
}
#endif
-
+
+#if APPLE_CHANGES
+ // Clear the selection if the mouse didn't move after the last mouse press.
+ // We do this so when clicking on the selection, the selection goes away.
+ if (!d->m_mouseMovedSinceLastMousePress &&
+ !d->m_selectionInitiatedWithDoubleClick &&
+ !d->m_selectionInitiatedWithTripleClick) {
+ d->m_selectionStart = 0;
+ d->m_selectionEnd = 0;
+ d->m_startOffset = 0;
+ d->m_endOffset = 0;
+ d->m_doc->clearSelection();
+ }
+#endif
#ifndef KHTML_NO_SELECTION
// delete selection in case start and end position are at the same point
if(d->m_selectionStart == d->m_selectionEnd && d->m_startOffset == d->m_endOffset) {
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 64e6934..6bcd8ad 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -707,6 +707,8 @@ public:
*/
void preloadScript(const QString &url, const QString &script);
+ bool isPointSelected(int x, int y);
+
/**
* @internal
*/
diff --git a/WebCore/khtml/khtmlpart_p.h b/WebCore/khtml/khtmlpart_p.h
index 9e3f764..91f8287 100644
--- a/WebCore/khtml/khtmlpart_p.h
+++ b/WebCore/khtml/khtmlpart_p.h
@@ -319,6 +319,7 @@ public:
long m_initialSelectionEndOffset;
bool m_selectionInitiatedWithDoubleClick:1;
bool m_selectionInitiatedWithTripleClick:1;
+ bool m_mouseMovedSinceLastMousePress;
#endif
DOM::Node m_selectionStart;
long m_startOffset;
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 4885eba..35bdbb1 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -1077,7 +1077,7 @@ void RenderObject::arenaDelete(RenderArena *arena)
arenaDelete(arena, dynamic_cast<void *>(this));
}
-FindSelectionResult RenderObject::checkSelectionPoint( const khtml::MouseEvent *event, int _tx, int _ty, DOM::NodeImpl*& node, int & offset )
+FindSelectionResult RenderObject::checkSelectionPoint(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int & offset )
{
int lastOffset=0;
int off = offset;
@@ -1085,7 +1085,7 @@ FindSelectionResult RenderObject::checkSelectionPoint( const khtml::MouseEvent *
DOM::NodeImpl* lastNode = 0;
for (RenderObject *child = firstChild(); child; child=child->nextSibling()) {
- khtml::FindSelectionResult pos = child->checkSelectionPoint(event, _tx+xPos(), _ty+yPos(), nod, off);
+ khtml::FindSelectionResult pos = child->checkSelectionPoint(_x, _y, _tx+xPos(), _ty+yPos(), nod, off);
//kdDebug(6030) << this << " child->findSelectionNode returned " << pos << endl;
switch(pos) {
case SelectionPointBeforeInLine:
@@ -1121,7 +1121,7 @@ FindSelectionResult RenderObject::checkSelectionPoint( const khtml::MouseEvent *
if (nextCont){
int ncx, ncy;
nextCont->absolutePosition(ncx, ncy);
- return nextCont->checkSelectionPoint(event, ncx-nextCont->xPos(), ncy-nextCont->yPos(), node, offset);
+ return nextCont->checkSelectionPoint(_x, _y, ncx-nextCont->xPos(), ncy-nextCont->yPos(), node, offset);
}
node = lastNode;
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 80d9add..6897977 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -349,7 +349,7 @@ public:
bool m_active;
};
- virtual FindSelectionResult checkSelectionPoint( const khtml::MouseEvent *event, int _tx, int _ty,
+ virtual FindSelectionResult checkSelectionPoint( int _x, int _y, int _tx, int _ty,
DOM::NodeImpl*&, int & offset );
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside=false);
void setHoverAndActive(NodeInfo& info, bool oldinside, bool inside);
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 583bc5b..57b91a1 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -481,12 +481,10 @@ bool RenderText::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, b
return inside;
}
-FindSelectionResult RenderText::checkSelectionPoint(const khtml::MouseEvent *event, int _tx, int _ty, DOM::NodeImpl*& node, int &offset)
+FindSelectionResult RenderText::checkSelectionPoint(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int &offset)
{
// kdDebug(6040) << "RenderText::checkSelectionPoint " << this << " _x=" << _x << " _y=" << _y
// << " _tx=" << _tx << " _ty=" << _ty << endl;
- int _x = event->x();
- int _y = event->y();
TextSlave *lastPointAfterInline=0;
for(unsigned int si = 0; si < m_lines.count(); si++)
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 96897fd..2af0f70 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -154,7 +154,7 @@ public:
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside = false);
// Return before, after (offset set to max), or inside the text, at @p offset
- virtual FindSelectionResult checkSelectionPoint( const khtml::MouseEvent *event, int _tx, int _ty,
+ virtual FindSelectionResult checkSelectionPoint(int _x, int _y, int _tx, int _ty,
DOM::NodeImpl*& node, int & offset );
unsigned int length() const { return str->l; }
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 6d99781..f78b0b5 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -814,11 +814,8 @@ void KWQKHTMLPart::khtmlMousePressEvent(MousePressEvent *event)
{
// If we got the event back, that must mean it wasn't prevented,
// so it's allowed to start a drag or selection.
- if ([_bridge mayStartDragWithMouseDown:_currentEvent]) {
- _mouseDownMayStartDrag = true;
- } else {
- _mouseDownMayStartSelect = true;
- }
+ _mouseDownMayStartDrag = true;
+ _mouseDownMayStartSelect = true;
if (!passWidgetMouseDownEventToWidget(event)) {
// We don't do this at the start of mouse down handling (before calling into WebCore),
@@ -953,12 +950,14 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
return;
}
- if (_mouseDownMayStartDrag) {
+ if (_mouseDownMayStartDrag && [_bridge mayStartDragWithMouseDragged:_currentEvent]) {
[_bridge handleMouseDragged:_currentEvent];
return;
} else if (_mouseDownMayStartSelect) {
// we use khtml's selection but our own autoscrolling
[_bridge handleAutoscrollForMouseDragged:_currentEvent];
+ // Don't allow dragging after we've started selecting.
+ _mouseDownMayStartDrag = false;
} else {
return;
}
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 839699a..b996913 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -62,11 +62,11 @@ extern NSString *WebCoreElementImageAltStringKey;
extern NSString *WebCoreElementImageKey;
extern NSString *WebCoreElementImageLocationKey;
extern NSString *WebCoreElementImageURLKey;
+extern NSString *WebCoreElementIsSelectedTextKey;
extern NSString *WebCoreElementLinkURLKey;
extern NSString *WebCoreElementLinkTargetFrameKey;
extern NSString *WebCoreElementLinkLabelKey;
extern NSString *WebCoreElementLinkTitleKey;
-extern NSString *WebCoreElementStringKey;
// WebCoreBridge objects are used by WebCore to abstract away operations that need
// to be implemented by library clients, for example WebKit. The objects are also
@@ -260,7 +260,7 @@ enum FrameBorderStyle {
- (void)handleMouseDragged:(NSEvent *)event;
- (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
-- (BOOL)mayStartDragWithMouseDown:(NSEvent *)event;
+- (BOOL)mayStartDragWithMouseDragged:(NSEvent *)event;
@end
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 773fccc..5b4e7f9 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -74,12 +74,12 @@ NSString *WebCoreElementImageAltStringKey = @"WebElementImageAltString";
NSString *WebCoreElementImageKey = @"WebElementImage";
NSString *WebCoreElementImageLocationKey = @"WebElementImageLocation";
NSString *WebCoreElementImageURLKey = @"WebElementImageURL";
+NSString *WebCoreElementIsSelectedTextKey = @"WebElementIsSelectedTextKey";
NSString *WebCoreElementLinkURLKey = @"WebElementLinkURL";
NSString *WebCoreElementLinkTargetFrameKey = @"WebElementTargetFrame";
NSString *WebCoreElementLinkLabelKey = @"WebElementLinkLabel";
NSString *WebCoreElementLinkTitleKey = @"WebElementLinkTitle";
NSString *WebCoreElementNameKey = @"WebElementName";
-NSString *WebCoreElementStringKey = @"WebElementString";
@implementation WebCoreBridge
@@ -437,6 +437,8 @@ static bool initializedObjectCacheSize = FALSE;
renderer->layer()->nodeAtPoint(nodeInfo, (int)point.x, (int)point.y);
NSMutableDictionary *element = [NSMutableDictionary dictionary];
+ [element setObject:[NSNumber numberWithBool:_part->isPointSelected((int)point.x, (int)point.y)]
+ forKey:WebCoreElementIsSelectedTextKey];
NodeImpl *URLNode = nodeInfo.URLElement();
if (URLNode) {
@@ -504,10 +506,6 @@ static bool initializedObjectCacheSize = FALSE;
[element setObject:[NSValue valueWithPoint:NSMakePoint(x,y)] forKey:WebCoreElementImageLocationKey];
}
}
-
- if (_part->hasSelection()) {
- [element setObject:[self selectedString] forKey:WebCoreElementStringKey];
- }
return element;
}
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 23bd78e..17cca5e 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,21 @@
+2003-01-21 Chris Blumenberg <cblu at apple.com>
+
+ Added support for text dragging.
+
+ Reviewed by dave.
+
+ * Resources/text_clipping.tiff: Added. Temp drag image until we can create an image of the selected text.
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge mayStartDragWithMouseDraggedEvent:]): renamed, we now ask if OK to drag during the drag
+ * WebKit.exp: renamed element key for selected text
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/WebController.h: renamed element key for selected text
+ * WebView.subproj/WebController.m: renamed element key for selected text
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ * WebView.subproj/WebHTMLViewPrivate.m:
+ (-[WebHTMLView _handleMouseDragged:]): added support for text dragging
+ (-[WebHTMLView _mayStartDragWithMouseDragged:]): renamed, we now ask if OK to drag during the drag
+
2003-01-20 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
diff --git a/WebKit/Resources/text_clipping.tiff b/WebKit/Resources/text_clipping.tiff
new file mode 100644
index 0000000..74ffaca
Binary files /dev/null and b/WebKit/Resources/text_clipping.tiff differ
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index df9bdf9..2669691 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -607,13 +607,13 @@ static BOOL loggedObjectCacheSize = NO;
[docView _handleAutoscrollForMouseDragged:event];
}
-- (BOOL)mayStartDragWithMouseDown:(NSEvent *)event
+- (BOOL)mayStartDragWithMouseDragged:(NSEvent *)event
{
WebHTMLView *docView = (WebHTMLView *)[[frame webView] documentView];
ASSERT ([docView isKindOfClass:[WebHTMLView class]]);
- return [docView _mayStartDragWithMouseDown:event];
+ return [docView _mayStartDragWithMouseDragged:event];
}
diff --git a/WebKit/WebKit.exp b/WebKit/WebKit.exp
index a7011ed..63baf57 100644
--- a/WebKit/WebKit.exp
+++ b/WebKit/WebKit.exp
@@ -41,11 +41,11 @@ _WebBookmarksWereRemovedNotification
_WebElementFrameKey
_WebElementImageKey
_WebElementImageURLKey
+_WebElementIsSelectedTextKey
_WebElementLinkLabelKey
_WebElementLinkTargetFrameKey
_WebElementLinkTitleKey
_WebElementLinkURLKey
-_WebElementStringKey
_WebErrorDomainWebKit
_WebHistoryAllEntriesRemovedNotification
_WebHistoryEntriesAddedNotification
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 8ab176e..93fff12 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -310,6 +310,7 @@
9345D17D0365BF35008635CE,
F5883BDF025E5C6A01000102,
F5B67131023EDF8901C1A525,
+ 8461DAAF03DDD6CD00CA2ACA,
);
isa = PBXResourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -434,8 +435,9 @@
089C1666FE841158C02AAC07,
35F3577E0198AAB80ACA1520,
932399D7034CF7F6008635CE,
- F5B67130023EDF8901C1A525,
F5883BDE025E5C6A01000102,
+ 8461DAAE03DDD6CD00CA2ACA,
+ F5B67130023EDF8901C1A525,
F5F732D202FF4D4F01A80180,
9345D4E70365C58D008635CE,
);
@@ -1824,6 +1826,18 @@
//842
//843
//844
+ 8461DAAE03DDD6CD00CA2ACA = {
+ isa = PBXFileReference;
+ name = text_clipping.tiff;
+ path = Resources/text_clipping.tiff;
+ refType = 4;
+ };
+ 8461DAAF03DDD6CD00CA2ACA = {
+ fileRef = 8461DAAE03DDD6CD00CA2ACA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
8467275C0367158500CA2ACA = {
fileEncoding = 30;
isa = PBXFileReference;
diff --git a/WebKit/WebView.subproj/WebController.h b/WebKit/WebView.subproj/WebController.h
index 064c002..fe6efb9 100644
--- a/WebKit/WebView.subproj/WebController.h
+++ b/WebKit/WebView.subproj/WebController.h
@@ -32,11 +32,11 @@ extern NSString *WebElementImageAltStringKey; // NSString of the ALT attribute o
extern NSString *WebElementImageKey; // NSImage of the image element
extern NSString *WebElementImageLocationKey; // NSValue of an NSPoint representing the origin of the image element
extern NSString *WebElementImageURLKey; // NSURL of the image element
+extern NSString *WebElementIsSelectedTextKey; // NSNumber of BOOL indicating whether the element is selected text or not
extern NSString *WebElementLinkURLKey; // NSURL if the element is within an anchor
extern NSString *WebElementLinkTargetFrameKey; // NSString of the target of the anchor
extern NSString *WebElementLinkTitleKey; // NSString of the title of the anchor
extern NSString *WebElementLinkLabelKey; // NSString of the text within the anchor
-extern NSString *WebElementStringKey; // NSString of the selected text
/*!
@class WebController
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index c4f7b13..9fa2c28 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -44,11 +44,11 @@ NSString *WebElementImageKey = @"WebElementImage";
NSString *WebElementImageAltStringKey = @"WebElementImageAltString";
NSString *WebElementImageLocationKey = @"WebElementImageLocation";
NSString *WebElementImageURLKey = @"WebElementImageURL";
+NSString *WebElementIsSelectedTextKey = @"WebElementIsSelectedTextKey";
NSString *WebElementLinkURLKey = @"WebElementLinkURL";
NSString *WebElementLinkTargetFrameKey = @"WebElementTargetFrame";
NSString *WebElementLinkLabelKey = @"WebElementLinkLabel";
NSString *WebElementLinkTitleKey = @"WebElementLinkTitle";
-NSString *WebElementStringKey = @"WebElementString";
@implementation WebController
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index 8bc636e..bd15f94 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -64,6 +64,6 @@
- (NSImage *)_dragImageForElement:(NSDictionary *)element;
- (void)_handleMouseDragged:(NSEvent *)event;
- (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
-- (BOOL)_mayStartDragWithMouseDown:(NSEvent *)event;
+- (BOOL)_mayStartDragWithMouseDragged:(NSEvent *)event;
@end
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index ba43e04..bf654d1 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -36,6 +36,8 @@
#define DragStartXHysteresis 10.0
#define DragStartYHysteresis 10.0
+#define TextDragDelay 0.2
+
#define DRAG_LABEL_BORDER_X 4.0
#define DRAG_LABEL_BORDER_Y 2.0
#define DRAG_LABEL_RADIUS 5
@@ -466,6 +468,9 @@ static BOOL forceRealHitTest = NO;
if ([[self _frame] provisionalDataSource]) {
return;
}
+
+ // FIXME: This cursor change should probably be moved to WebCore.
+ [[NSCursor arrowCursor] set];
NSPoint mouseDownPoint = [_private->mouseDownEvent locationInWindow];
float deltaX = ABS([event locationInWindow].x - mouseDownPoint.x);
@@ -480,14 +485,16 @@ static BOOL forceRealHitTest = NO;
_private->draggingImageURL = nil;
// We must have started over something draggable:
- ASSERT((imageURL && [[WebPreferences standardPreferences] willLoadImagesAutomatically]) || (!imageURL && linkURL));
+ ASSERT((imageURL && [[WebPreferences standardPreferences] willLoadImagesAutomatically]) ||
+ (!imageURL && linkURL) ||
+ [[element objectForKey:WebElementIsSelectedTextKey] boolValue]);
// drag hysteresis hasn't ben met yet but we don't want to do
// other drag actions like selection.
if (deltaX < DragStartXHysteresis && deltaY < DragStartYHysteresis) {
return;
}
-
+
if (imageURL) {
_private->draggingImageURL = [imageURL retain];
@@ -497,16 +504,24 @@ static BOOL forceRealHitTest = NO;
fileType:[[imageURL path] pathExtension]
title:[element objectForKey:WebElementImageAltStringKey]
event:_private->mouseDownEvent];
- } else if (linkURL) {
- NSImage *dragImage = [self _dragImageForElement:element];
- NSString *label = [element objectForKey: WebElementLinkLabelKey];
-
- NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- [pasteboard _web_writeURL:linkURL andTitle:label withOwner:self];
+ } else if (linkURL || [[element objectForKey:WebElementIsSelectedTextKey] boolValue]) {
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ NSSize centerOffset;
+ NSImage *dragImage;
+
+ if (linkURL) {
+ dragImage = [self _dragImageForElement:element];
+ NSString *label = [element objectForKey: WebElementLinkLabelKey];
+ centerOffset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
+ [pasteboard _web_writeURL:linkURL andTitle:label withOwner:self];
+ } else {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"text_clipping" ofType:@"tiff"];
+ dragImage = [[[NSImage alloc] initByReferencingFile:path] autorelease];
+ centerOffset = NSMakeSize([dragImage size].width / 2, -([dragImage size].width/4));
+ [self _writeSelectionToPasteboard:pasteboard];
+ }
- NSSize imageSize = [dragImage size];
NSPoint mousePoint = [self convertPoint:[event locationInWindow] fromView:nil];
- NSSize centerOffset = NSMakeSize(imageSize.width / 2, -DRAG_LABEL_BORDER_Y);
NSPoint imagePoint = NSMakePoint(mousePoint.x - centerOffset.width, mousePoint.y - centerOffset.height);
[self dragImage:dragImage
@@ -525,21 +540,24 @@ static BOOL forceRealHitTest = NO;
[self autoscroll:event];
}
-- (BOOL)_mayStartDragWithMouseDown:(NSEvent *)event
+- (BOOL)_mayStartDragWithMouseDragged:(NSEvent *)mouseDraggedEvent
{
- NSPoint mouseDownPoint = [event locationInWindow];
-
- NSPoint point = [self convertPoint:mouseDownPoint fromView:nil];
-
- NSDictionary *element = [[self _elementAtPoint: point] retain];
+ NSPoint mouseDownPoint = [self convertPoint:[_private->mouseDownEvent locationInWindow] fromView:nil];
+ NSDictionary *mouseDownElement = [[self _elementAtPoint:mouseDownPoint] retain];
+
[_private->dragElement release];
- _private->dragElement = element;
+ _private->dragElement = mouseDownElement;
- NSURL *linkURL = [element objectForKey: WebElementLinkURLKey];
- NSURL *imageURL = [element objectForKey: WebElementImageURLKey];
+ NSURL *imageURL = [mouseDownElement objectForKey: WebElementImageURLKey];
+
+ if ((imageURL && [[WebPreferences standardPreferences] willLoadImagesAutomatically]) ||
+ (!imageURL && [mouseDownElement objectForKey: WebElementLinkURLKey]) ||
+ ([[mouseDownElement objectForKey:WebElementIsSelectedTextKey] boolValue] &&
+ ([mouseDraggedEvent timestamp] - [_private->mouseDownEvent timestamp]) > TextDragDelay)) {
+ return YES;
+ }
- // are we over something draggable?
- return (imageURL && [[WebPreferences standardPreferences] willLoadImagesAutomatically]) || (!imageURL && linkURL);
+ return NO;
}
@end
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index 064c002..fe6efb9 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -32,11 +32,11 @@ extern NSString *WebElementImageAltStringKey; // NSString of the ALT attribute o
extern NSString *WebElementImageKey; // NSImage of the image element
extern NSString *WebElementImageLocationKey; // NSValue of an NSPoint representing the origin of the image element
extern NSString *WebElementImageURLKey; // NSURL of the image element
+extern NSString *WebElementIsSelectedTextKey; // NSNumber of BOOL indicating whether the element is selected text or not
extern NSString *WebElementLinkURLKey; // NSURL if the element is within an anchor
extern NSString *WebElementLinkTargetFrameKey; // NSString of the target of the anchor
extern NSString *WebElementLinkTitleKey; // NSString of the title of the anchor
extern NSString *WebElementLinkLabelKey; // NSString of the text within the anchor
-extern NSString *WebElementStringKey; // NSString of the selected text
/*!
@class WebController
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index c4f7b13..9fa2c28 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -44,11 +44,11 @@ NSString *WebElementImageKey = @"WebElementImage";
NSString *WebElementImageAltStringKey = @"WebElementImageAltString";
NSString *WebElementImageLocationKey = @"WebElementImageLocation";
NSString *WebElementImageURLKey = @"WebElementImageURL";
+NSString *WebElementIsSelectedTextKey = @"WebElementIsSelectedTextKey";
NSString *WebElementLinkURLKey = @"WebElementLinkURL";
NSString *WebElementLinkTargetFrameKey = @"WebElementTargetFrame";
NSString *WebElementLinkLabelKey = @"WebElementLinkLabel";
NSString *WebElementLinkTitleKey = @"WebElementLinkTitle";
-NSString *WebElementStringKey = @"WebElementString";
@implementation WebController
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list