Reviewed by Tim Hatcher.
Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323
Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref
No layout tests added as this must be tested manually by the test
WebCore/manual-tests/contenteditable-link.html
* WebCore.exp: Exported HitTestResult::isLiveLink().
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::HTMLAnchorElement):
(WebCore::HTMLAnchorElement::defaultEventHandler):
(WebCore::HTMLAnchorElement::isLiveLink):
* html/HTMLAnchorElement.h: added m_wasShiftKeyDownOnMouseDown variable
to track shift key status.
* manual-tests/contenteditable-link.html: Added description about link
dragging behaviour.
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::isLiveLink): Added.
* rendering/HitTestResult.h:
WebKit:
Reviewed by Tim Hatcher.
Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323
Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref
* DefaultDelegates/WebDefaultUIDelegate.m:
(-[NSApplication webView:dragSourceActionMaskForPoint:]): Logic moved to
WebHTMLView's _mayStartDragAtEventLocation
* Misc/WebElementDictionary.m: added isLiveLink
(+[WebElementDictionary initializeLookupTable]):
(-[WebElementDictionary _isLiveLink]):
* WebView/WebHTMLView.m:
(-[WebHTMLView _mayStartDragAtEventLocation:]): Editable links should
only be followed if isLiveLink is true
(-[WebHTMLView _isMoveDrag:]): A drag of a live editable link is not
a move
(-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]):
(-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
* WebView/WebView.mm: added WebElementLinkIsLiveKey
* WebView/WebViewPrivate.h: ditto
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17629
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-11-06 Graham Dennis <graham.dennis@gmail.com>
+
+ Reviewed by Tim Hatcher.
+
+ Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323
+ Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref
+
+ No layout tests added as this must be tested manually by the test
+ WebCore/manual-tests/contenteditable-link.html
+
+ * WebCore.exp: Exported HitTestResult::isLiveLink().
+ * html/HTMLAnchorElement.cpp:
+ (WebCore::HTMLAnchorElement::HTMLAnchorElement):
+ (WebCore::HTMLAnchorElement::defaultEventHandler):
+ (WebCore::HTMLAnchorElement::isLiveLink):
+ * html/HTMLAnchorElement.h: added m_wasShiftKeyDownOnMouseDown variable
+ to track shift key status.
+ * manual-tests/contenteditable-link.html: Added description about link
+ dragging behaviour.
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::isLiveLink): Added.
+ * rendering/HitTestResult.h:
+
2006-11-06 Brady Eidson <beidson@apple.com>
Reviewed by Oliver
__ZNK7WebCore13HitTestResult18titleDisplayStringEv
__ZNK7WebCore13HitTestResult5imageEv
__ZNK7WebCore13HitTestResult5titleEv
+__ZNK7WebCore13HitTestResult10isLiveLinkEv
__ZNK7WebCore14DocumentLoader10isStoppingEv
__ZNK7WebCore14DocumentLoader11frameLoaderEv
__ZNK7WebCore14DocumentLoader11isCommittedEv
HTMLAnchorElement::HTMLAnchorElement(Document* doc)
: HTMLElement(aTag, doc)
, m_rootEditableElementForSelectionOnMouseDown(0)
+ , m_wasShiftKeyDownOnMouseDown(false)
{
}
HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* doc)
: HTMLElement(tagName, doc)
, m_rootEditableElementForSelectionOnMouseDown(0)
+ , m_wasShiftKeyDownOnMouseDown(false)
{
}
} else if (m_isLink && isContentEditable()) {
// This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
// for the LiveWhenNotFocused editable link behavior
- if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController())
+ if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController()) {
+ MouseEvent* e = static_cast<MouseEvent*>(evt);
+
m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selectionController()->rootEditableElement();
- else if (evt->type() == mouseoutEvent)
+ m_wasShiftKeyDownOnMouseDown = e && e->shiftKey();
+ } else if (evt->type() == mouseoverEvent) {
+ // These are cleared on mouseover and not mouseout because their values are needed for drag events, but these happen
+ // after mouse out events.
m_rootEditableElementForSelectionOnMouseDown = 0;
+ m_wasShiftKeyDownOnMouseDown = false;
+ }
}
HTMLElement::defaultEventHandler(evt);
return innerText();
}
+bool HTMLAnchorElement::isLiveLink() const
+{
+ if (!m_isLink)
+ return false;
+ if (!isContentEditable())
+ return true;
+
+ Settings::EditableLinkBehavior editableLinkBehavior = Settings::EditableLinkDefaultBehavior;
+ if (document() && document()->frame() && document()->frame()->settings())
+ editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior();
+
+ switch(editableLinkBehavior) {
+ default:
+ case Settings::EditableLinkDefaultBehavior:
+ case Settings::EditableLinkAlwaysLive:
+ return true;
+
+ // Don't set the link to be live if the current selection is in the same editable block as
+ // this link or if the shift key is down
+ case Settings::EditableLinkLiveWhenNotFocused:
+ return m_wasShiftKeyDownOnMouseDown || m_rootEditableElementForSelectionOnMouseDown != rootEditableElement();
+
+ case Settings::EditableLinkOnlyLiveWithShiftKey:
+ return m_wasShiftKeyDownOnMouseDown;
+ }
+ // not reached
+ ASSERT(0);
+ return false;
+}
}
String search() const;
String text() const;
+ bool isLiveLink() const;
+
private:
Element *m_rootEditableElementForSelectionOnMouseDown;
+ bool m_wasShiftKeyDownOnMouseDown;
};
} //namespace
<div>The behaviour of editable links is controlled by the user default WebKitEditableLinkBehavior. This can be set via a private WebPreference. If the preference is OnlyLiveWithShiftKey, then the link will only be active when the shift key is pressed (WinIE/Firefox behaviour). If the preference is WebKitEditableLinkAlwaysLive or WebKitEditableLinkDefaultBehavior, then the link is always active (Safari 2.0 behaviour). Finally, if the preference is WebKitEditableLinkLiveWhenNotFocused, the link will only be live if the selection before clicking on the link is not in the same editable block as the link.</div>
+<div>Also, when a link is 'live' it can be dragged as a link, and when the link isn't 'live', dragging a link just performs a normal text selection.
+</div>
+
<div id="editable" contentEditable="true">
<p>Test content</p>
<p><a href="about:blank">Test link</a></p>
#include "Document.h"
#include "Frame.h"
#include "FrameTree.h"
+#include "HTMLAnchorElement.h"
#include "HTMLElement.h"
#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
static_cast<Element*>(m_innerURLElement.get())->getAttribute("href")).deprecatedString()));
}
+bool HitTestResult::isLiveLink() const
+{
+ if (!(m_innerURLElement && m_innerURLElement->document()))
+ return false;
+
+ if (!m_innerURLElement->hasTagName(aTag))
+ return false;
+
+ return static_cast<HTMLAnchorElement*>(m_innerURLElement.get())->isLiveLink();
+}
+
String HitTestResult::titleDisplayString() const
{
if (!(m_innerURLElement && m_innerURLElement->isHTMLElement()))
KURL absoluteLinkURL() const;
String titleDisplayString() const;
String textContent() const;
+ bool isLiveLink() const;
private:
RefPtr<Node> m_innerNode;
+2006-11-06 Graham Dennis <graham.dennis@gmail.com>
+
+ Reviewed by Tim Hatcher.
+
+ Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323
+ Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref
+
+ * DefaultDelegates/WebDefaultUIDelegate.m:
+ (-[NSApplication webView:dragSourceActionMaskForPoint:]): Logic moved to
+ WebHTMLView's _mayStartDragAtEventLocation
+ * Misc/WebElementDictionary.m: added isLiveLink
+ (+[WebElementDictionary initializeLookupTable]):
+ (-[WebElementDictionary _isLiveLink]):
+ * WebView/WebHTMLView.m:
+ (-[WebHTMLView _mayStartDragAtEventLocation:]): Editable links should
+ only be followed if isLiveLink is true
+ (-[WebHTMLView _isMoveDrag:]): A drag of a live editable link is not
+ a move
+ (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]):
+ (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]):
+ * WebView/WebView.mm: added WebElementLinkIsLiveKey
+ * WebView/WebViewPrivate.h: ditto
+
2006-11-04 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver.
- (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
{
- DOMElement *elementAtPoint = [[webView elementAtPoint:point] objectForKey:WebElementDOMNodeKey];
- if ([elementAtPoint respondsToSelector:@selector(isContentEditable)] && [(id)elementAtPoint isContentEditable])
- return (WebDragSourceActionAny & ~WebDragSourceActionLink);
-
return WebDragSourceActionAny;
}
addLookupKey(WebElementLinkTargetFrameKey, @selector(_targetWebFrame));
addLookupKey(WebElementLinkTitleKey, @selector(_titleDisplayString));
addLookupKey(WebElementLinkLabelKey, @selector(_textContent));
+ addLookupKey(WebElementLinkIsLiveKey, @selector(_isLiveLink));
}
- (id)initWithHitTestResult:(const HitTestResult&)result
return _result->textContent();
}
+- (NSNumber *)_isLiveLink
+{
+ return [NSNumber numberWithBool:_result->isLiveLink()];
+}
+
@end
/*
* Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
return YES;
if ([mouseDownElement objectForKey:WebElementLinkURLKey]
- && (_private->dragSourceActionMask & WebDragSourceActionLink))
+ && (_private->dragSourceActionMask & WebDragSourceActionLink)
+ && [[mouseDownElement objectForKey:WebElementLinkIsLiveKey] boolValue])
return YES;
if ([[mouseDownElement objectForKey:WebElementIsSelectedKey] boolValue]
return NO;
}
-- (BOOL)_isMoveDrag
+- (BOOL)_isMoveDrag:(id <NSDraggingInfo>)draggingInfo
{
FrameMac* coreFrame = core([self _frame]);
return _private->initiatedDrag
&& coreFrame
&& coreFrame->selectionController()->isContentEditable()
- && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask);
+ && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
+ && ![[[draggingInfo draggingPasteboard] types] containsObject:NSURLPboardType];
}
- (BOOL)_isNSColorDrag:(id <NSDraggingInfo>)draggingInfo
ASSERT(innerFrame);
ASSERT([innerFrame isKindOfClass:[WebFrame class]]);
WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView];
- operation = [innerView _isMoveDrag] ? NSDragOperationMove : NSDragOperationCopy;
+ operation = [innerView _isMoveDrag:draggingInfo] ? NSDragOperationMove : NSDragOperationCopy;
}
} else
[[self _webView] removeDragCaret];
BOOL didInsert = NO;
if ([self _canProcessDragWithDraggingInfo:draggingInfo]) {
NSPasteboard *pasteboard = [draggingInfo draggingPasteboard];
- if ([innerView _isMoveDrag] || [innerBridge isDragCaretRichlyEditable]) {
+ if ([innerView _isMoveDrag:draggingInfo] || [innerBridge isDragCaretRichlyEditable]) {
DOMRange *range = [innerBridge dragCaretDOMRange];
BOOL chosePlainText;
DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
inContext:range allowPlainText:YES chosePlainText:&chosePlainText];
if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionDropped]) {
[[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo];
- if ([innerView _isMoveDrag]) {
+ if ([innerView _isMoveDrag:draggingInfo]) {
BOOL smartMove = [innerBridge selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard];
[innerBridge moveSelectionToDragCaret:fragment smartMove:smartMove];
} else {
NSString *WebElementLinkURLKey = @"WebElementLinkURL";
NSString *WebElementSpellingToolTipKey = @"WebElementSpellingToolTip";
NSString *WebElementTitleKey = @"WebElementTitle";
+NSString *WebElementLinkIsLiveKey = @"WebElementLinkIsLive";
NSString *WebViewProgressStartedNotification = @"WebProgressStartedNotification";
NSString *WebViewProgressEstimateChangedNotification = @"WebProgressEstimateChangedNotification";
extern NSString *WebElementTitleKey; // NSString of the title of the element (used by Safari)
extern NSString *WebElementSpellingToolTipKey; // NSString of a tooltip representing misspelling or bad grammar (used internally)
+// other WebElementDictionary keys
+extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not
+
typedef enum {
WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,