Changeset 17629 in webkit
- Timestamp:
- Nov 6, 2006 2:44:23 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r17626 r17629 1 2006-11-06 Graham Dennis <graham.dennis@gmail.com> 2 3 Reviewed by Tim Hatcher. 4 5 Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323 6 Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref 7 8 No layout tests added as this must be tested manually by the test 9 WebCore/manual-tests/contenteditable-link.html 10 11 * WebCore.exp: Exported HitTestResult::isLiveLink(). 12 * html/HTMLAnchorElement.cpp: 13 (WebCore::HTMLAnchorElement::HTMLAnchorElement): 14 (WebCore::HTMLAnchorElement::defaultEventHandler): 15 (WebCore::HTMLAnchorElement::isLiveLink): 16 * html/HTMLAnchorElement.h: added m_wasShiftKeyDownOnMouseDown variable 17 to track shift key status. 18 * manual-tests/contenteditable-link.html: Added description about link 19 dragging behaviour. 20 * rendering/HitTestResult.cpp: 21 (WebCore::HitTestResult::isLiveLink): Added. 22 * rendering/HitTestResult.h: 23 1 24 2006-11-06 Brady Eidson <beidson@apple.com> 2 25 -
trunk/WebCore/WebCore.exp
r17597 r17629 308 308 __ZNK7WebCore13HitTestResult5imageEv 309 309 __ZNK7WebCore13HitTestResult5titleEv 310 __ZNK7WebCore13HitTestResult10isLiveLinkEv 310 311 __ZNK7WebCore14DocumentLoader10isStoppingEv 311 312 __ZNK7WebCore14DocumentLoader11frameLoaderEv -
trunk/WebCore/html/HTMLAnchorElement.cpp
r17597 r17629 51 51 : HTMLElement(aTag, doc) 52 52 , m_rootEditableElementForSelectionOnMouseDown(0) 53 , m_wasShiftKeyDownOnMouseDown(false) 53 54 { 54 55 } … … 57 58 : HTMLElement(tagName, doc) 58 59 , m_rootEditableElementForSelectionOnMouseDown(0) 60 , m_wasShiftKeyDownOnMouseDown(false) 59 61 { 60 62 } … … 213 215 // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked 214 216 // for the LiveWhenNotFocused editable link behavior 215 if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController()) 217 if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController()) { 218 MouseEvent* e = static_cast<MouseEvent*>(evt); 219 216 220 m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selectionController()->rootEditableElement(); 217 else if (evt->type() == mouseoutEvent) 221 m_wasShiftKeyDownOnMouseDown = e && e->shiftKey(); 222 } else if (evt->type() == mouseoverEvent) { 223 // These are cleared on mouseover and not mouseout because their values are needed for drag events, but these happen 224 // after mouse out events. 218 225 m_rootEditableElementForSelectionOnMouseDown = 0; 226 m_wasShiftKeyDownOnMouseDown = false; 227 } 219 228 } 220 229 … … 447 456 } 448 457 449 450 } 458 bool HTMLAnchorElement::isLiveLink() const 459 { 460 if (!m_isLink) 461 return false; 462 if (!isContentEditable()) 463 return true; 464 465 Settings::EditableLinkBehavior editableLinkBehavior = Settings::EditableLinkDefaultBehavior; 466 if (document() && document()->frame() && document()->frame()->settings()) 467 editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior(); 468 469 switch(editableLinkBehavior) { 470 default: 471 case Settings::EditableLinkDefaultBehavior: 472 case Settings::EditableLinkAlwaysLive: 473 return true; 474 475 // Don't set the link to be live if the current selection is in the same editable block as 476 // this link or if the shift key is down 477 case Settings::EditableLinkLiveWhenNotFocused: 478 return m_wasShiftKeyDownOnMouseDown || m_rootEditableElementForSelectionOnMouseDown != rootEditableElement(); 479 480 case Settings::EditableLinkOnlyLiveWithShiftKey: 481 return m_wasShiftKeyDownOnMouseDown; 482 } 483 // not reached 484 ASSERT(0); 485 return false; 486 } 487 488 } -
trunk/WebCore/html/HTMLAnchorElement.h
r17399 r17629 96 96 String text() const; 97 97 98 bool isLiveLink() const; 99 98 100 private: 99 101 Element *m_rootEditableElementForSelectionOnMouseDown; 102 bool m_wasShiftKeyDownOnMouseDown; 100 103 }; 101 104 -
trunk/WebCore/manual-tests/contenteditable-link.html
r16760 r17629 18 18 <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> 19 19 20 <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. 21 </div> 22 20 23 <div id="editable" contentEditable="true"> 21 24 <p>Test content</p> -
trunk/WebCore/rendering/HitTestResult.cpp
r17515 r17629 28 28 #include "Frame.h" 29 29 #include "FrameTree.h" 30 #include "HTMLAnchorElement.h" 30 31 #include "HTMLElement.h" 31 32 #include "HTMLImageElement.h" … … 229 230 } 230 231 232 bool HitTestResult::isLiveLink() const 233 { 234 if (!(m_innerURLElement && m_innerURLElement->document())) 235 return false; 236 237 if (!m_innerURLElement->hasTagName(aTag)) 238 return false; 239 240 return static_cast<HTMLAnchorElement*>(m_innerURLElement.get())->isLiveLink(); 241 } 242 231 243 String HitTestResult::titleDisplayString() const 232 244 { -
trunk/WebCore/rendering/HitTestResult.h
r17511 r17629 67 67 String titleDisplayString() const; 68 68 String textContent() const; 69 bool isLiveLink() const; 69 70 70 71 private: -
trunk/WebKit/ChangeLog
r17607 r17629 1 2006-11-06 Graham Dennis <graham.dennis@gmail.com> 2 3 Reviewed by Tim Hatcher. 4 5 Part of patch for http://bugs.webkit.org/show_bug.cgi?id=11323 6 Link dragging behaviour does not obey WebKitEditableLinkBehavior WebPref 7 8 * DefaultDelegates/WebDefaultUIDelegate.m: 9 (-[NSApplication webView:dragSourceActionMaskForPoint:]): Logic moved to 10 WebHTMLView's _mayStartDragAtEventLocation 11 * Misc/WebElementDictionary.m: added isLiveLink 12 (+[WebElementDictionary initializeLookupTable]): 13 (-[WebElementDictionary _isLiveLink]): 14 * WebView/WebHTMLView.m: 15 (-[WebHTMLView _mayStartDragAtEventLocation:]): Editable links should 16 only be followed if isLiveLink is true 17 (-[WebHTMLView _isMoveDrag:]): A drag of a live editable link is not 18 a move 19 (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): 20 (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): 21 * WebView/WebView.mm: added WebElementLinkIsLiveKey 22 * WebView/WebViewPrivate.h: ditto 23 1 24 2006-11-04 Maciej Stachowiak <mjs@apple.com> 2 25 -
trunk/WebKit/DefaultDelegates/WebDefaultUIDelegate.m
r17023 r17629 204 204 - (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point; 205 205 { 206 DOMElement *elementAtPoint = [[webView elementAtPoint:point] objectForKey:WebElementDOMNodeKey];207 if ([elementAtPoint respondsToSelector:@selector(isContentEditable)] && [(id)elementAtPoint isContentEditable])208 return (WebDragSourceActionAny & ~WebDragSourceActionLink);209 210 206 return WebDragSourceActionAny; 211 207 } -
trunk/WebKit/Misc/WebElementDictionary.m
r17597 r17629 80 80 addLookupKey(WebElementLinkTitleKey, @selector(_titleDisplayString)); 81 81 addLookupKey(WebElementLinkLabelKey, @selector(_textContent)); 82 addLookupKey(WebElementLinkIsLiveKey, @selector(_isLiveLink)); 82 83 } 83 84 … … 219 220 } 220 221 222 - (NSNumber *)_isLiveLink 223 { 224 return [NSNumber numberWithBool:_result->isLiveLink()]; 225 } 226 221 227 @end -
trunk/WebKit/WebView/WebHTMLView.m
r17597 r17629 1 1 /* 2 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 1513 1514 1514 1515 if ([mouseDownElement objectForKey:WebElementLinkURLKey] 1515 && (_private->dragSourceActionMask & WebDragSourceActionLink)) 1516 && (_private->dragSourceActionMask & WebDragSourceActionLink) 1517 && [[mouseDownElement objectForKey:WebElementLinkIsLiveKey] boolValue]) 1516 1518 return YES; 1517 1519 … … 5973 5975 } 5974 5976 5975 - (BOOL)_isMoveDrag 5977 - (BOOL)_isMoveDrag:(id <NSDraggingInfo>)draggingInfo 5976 5978 { 5977 5979 FrameMac* coreFrame = core([self _frame]); … … 5979 5981 && coreFrame 5980 5982 && coreFrame->selectionController()->isContentEditable() 5981 && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask); 5983 && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) 5984 && ![[[draggingInfo draggingPasteboard] types] containsObject:NSURLPboardType]; 5982 5985 } 5983 5986 … … 6009 6012 ASSERT([innerFrame isKindOfClass:[WebFrame class]]); 6010 6013 WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView]; 6011 operation = [innerView _isMoveDrag ] ? NSDragOperationMove : NSDragOperationCopy;6014 operation = [innerView _isMoveDrag:draggingInfo] ? NSDragOperationMove : NSDragOperationCopy; 6012 6015 } 6013 6016 } else … … 6073 6076 if ([self _canProcessDragWithDraggingInfo:draggingInfo]) { 6074 6077 NSPasteboard *pasteboard = [draggingInfo draggingPasteboard]; 6075 if ([innerView _isMoveDrag ] || [innerBridge isDragCaretRichlyEditable]) {6078 if ([innerView _isMoveDrag:draggingInfo] || [innerBridge isDragCaretRichlyEditable]) { 6076 6079 DOMRange *range = [innerBridge dragCaretDOMRange]; 6077 6080 BOOL chosePlainText; … … 6080 6083 if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionDropped]) { 6081 6084 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo]; 6082 if ([innerView _isMoveDrag ]) {6085 if ([innerView _isMoveDrag:draggingInfo]) { 6083 6086 BOOL smartMove = [innerBridge selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard]; 6084 6087 [innerBridge moveSelectionToDragCaret:fragment smartMove:smartMove]; -
trunk/WebKit/WebView/WebView.mm
r17597 r17629 343 343 NSString *WebElementSpellingToolTipKey = @"WebElementSpellingToolTip"; 344 344 NSString *WebElementTitleKey = @"WebElementTitle"; 345 NSString *WebElementLinkIsLiveKey = @"WebElementLinkIsLive"; 345 346 346 347 NSString *WebViewProgressStartedNotification = @"WebProgressStartedNotification"; -
trunk/WebKit/WebView/WebViewPrivate.h
r17548 r17629 85 85 extern NSString *WebElementSpellingToolTipKey; // NSString of a tooltip representing misspelling or bad grammar (used internally) 86 86 87 // other WebElementDictionary keys 88 extern NSString *WebElementLinkIsLiveKey; // NSNumber of BOOL indictating whether the link is live or not 89 87 90 typedef enum { 88 91 WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
Note: See TracChangeset
for help on using the changeset viewer.