Changeset 17629 in webkit


Ignore:
Timestamp:
Nov 6, 2006 2:44:23 PM (18 years ago)
Author:
gdennis
Message:

WebCore:

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
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r17626 r17629  
     12006-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
    1242006-11-06  Brady Eidson  <beidson@apple.com>
    225
  • trunk/WebCore/WebCore.exp

    r17597 r17629  
    308308__ZNK7WebCore13HitTestResult5imageEv
    309309__ZNK7WebCore13HitTestResult5titleEv
     310__ZNK7WebCore13HitTestResult10isLiveLinkEv
    310311__ZNK7WebCore14DocumentLoader10isStoppingEv
    311312__ZNK7WebCore14DocumentLoader11frameLoaderEv
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r17597 r17629  
    5151    : HTMLElement(aTag, doc)
    5252    , m_rootEditableElementForSelectionOnMouseDown(0)
     53    , m_wasShiftKeyDownOnMouseDown(false)
    5354{
    5455}
     
    5758    : HTMLElement(tagName, doc)
    5859    , m_rootEditableElementForSelectionOnMouseDown(0)
     60    , m_wasShiftKeyDownOnMouseDown(false)
    5961{
    6062}
     
    213215    // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
    214216    // 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
    216220            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.
    218225            m_rootEditableElementForSelectionOnMouseDown = 0;
     226            m_wasShiftKeyDownOnMouseDown = false;
     227        }
    219228    }
    220229
     
    447456}
    448457
    449 
    450 }
     458bool 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  
    9696    String text() const;
    9797   
     98    bool isLiveLink() const;
     99   
    98100private:
    99101    Element *m_rootEditableElementForSelectionOnMouseDown;
     102    bool m_wasShiftKeyDownOnMouseDown;
    100103};
    101104
  • trunk/WebCore/manual-tests/contenteditable-link.html

    r16760 r17629  
    1818<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>
    1919
     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
    2023<div id="editable" contentEditable="true">
    2124  <p>Test content</p>
  • trunk/WebCore/rendering/HitTestResult.cpp

    r17515 r17629  
    2828#include "Frame.h"
    2929#include "FrameTree.h"
     30#include "HTMLAnchorElement.h"
    3031#include "HTMLElement.h"
    3132#include "HTMLImageElement.h"
     
    229230}
    230231
     232bool 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
    231243String HitTestResult::titleDisplayString() const
    232244{
  • trunk/WebCore/rendering/HitTestResult.h

    r17511 r17629  
    6767    String titleDisplayString() const;
    6868    String textContent() const;
     69    bool isLiveLink() const;
    6970
    7071private:
  • trunk/WebKit/ChangeLog

    r17607 r17629  
     12006-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
    1242006-11-04  Maciej Stachowiak  <mjs@apple.com>
    225
  • trunk/WebKit/DefaultDelegates/WebDefaultUIDelegate.m

    r17023 r17629  
    204204- (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
    205205{
    206     DOMElement *elementAtPoint = [[webView elementAtPoint:point] objectForKey:WebElementDOMNodeKey];
    207     if ([elementAtPoint respondsToSelector:@selector(isContentEditable)] && [(id)elementAtPoint isContentEditable])
    208         return (WebDragSourceActionAny & ~WebDragSourceActionLink);
    209 
    210206    return WebDragSourceActionAny;
    211207}
  • trunk/WebKit/Misc/WebElementDictionary.m

    r17597 r17629  
    8080    addLookupKey(WebElementLinkTitleKey, @selector(_titleDisplayString));
    8181    addLookupKey(WebElementLinkLabelKey, @selector(_textContent));
     82    addLookupKey(WebElementLinkIsLiveKey, @selector(_isLiveLink));
    8283}
    8384
     
    219220}
    220221
     222- (NSNumber *)_isLiveLink
     223{
     224    return [NSNumber numberWithBool:_result->isLiveLink()];
     225}
     226
    221227@end
  • trunk/WebKit/WebView/WebHTMLView.m

    r17597 r17629  
    11/*
    22 * Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
     3 *           (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    15131514   
    15141515    if ([mouseDownElement objectForKey:WebElementLinkURLKey]
    1515             && (_private->dragSourceActionMask & WebDragSourceActionLink))
     1516            && (_private->dragSourceActionMask & WebDragSourceActionLink)
     1517            && [[mouseDownElement objectForKey:WebElementLinkIsLiveKey] boolValue])
    15161518        return YES;
    15171519   
     
    59735975}
    59745976
    5975 - (BOOL)_isMoveDrag
     5977- (BOOL)_isMoveDrag:(id <NSDraggingInfo>)draggingInfo
    59765978{
    59775979    FrameMac* coreFrame = core([self _frame]);
     
    59795981        && coreFrame
    59805982        && coreFrame->selectionController()->isContentEditable()
    5981         && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask);
     5983        && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
     5984        && ![[[draggingInfo draggingPasteboard] types] containsObject:NSURLPboardType];
    59825985}
    59835986
     
    60096012            ASSERT([innerFrame isKindOfClass:[WebFrame class]]);
    60106013            WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView];
    6011             operation = [innerView _isMoveDrag] ? NSDragOperationMove : NSDragOperationCopy;
     6014            operation = [innerView _isMoveDrag:draggingInfo] ? NSDragOperationMove : NSDragOperationCopy;
    60126015        }
    60136016    } else
     
    60736076    if ([self _canProcessDragWithDraggingInfo:draggingInfo]) {
    60746077        NSPasteboard *pasteboard = [draggingInfo draggingPasteboard];
    6075         if ([innerView _isMoveDrag] || [innerBridge isDragCaretRichlyEditable]) {
     6078        if ([innerView _isMoveDrag:draggingInfo] || [innerBridge isDragCaretRichlyEditable]) {
    60766079            DOMRange *range = [innerBridge dragCaretDOMRange];
    60776080            BOOL chosePlainText;
     
    60806083            if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionDropped]) {
    60816084                [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo];
    6082                 if ([innerView _isMoveDrag]) {
     6085                if ([innerView _isMoveDrag:draggingInfo]) {
    60836086                    BOOL smartMove = [innerBridge selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard];
    60846087                    [innerBridge moveSelectionToDragCaret:fragment smartMove:smartMove];
  • trunk/WebKit/WebView/WebView.mm

    r17597 r17629  
    343343NSString *WebElementSpellingToolTipKey =    @"WebElementSpellingToolTip";
    344344NSString *WebElementTitleKey =              @"WebElementTitle";
     345NSString *WebElementLinkIsLiveKey =         @"WebElementLinkIsLive";
    345346
    346347NSString *WebViewProgressStartedNotification =          @"WebProgressStartedNotification";
  • trunk/WebKit/WebView/WebViewPrivate.h

    r17548 r17629  
    8585extern NSString *WebElementSpellingToolTipKey;   // NSString of a tooltip representing misspelling or bad grammar (used internally)
    8686
     87// other WebElementDictionary keys
     88extern NSString *WebElementLinkIsLiveKey;        // NSNumber of BOOL indictating whether the link is live or not
     89
    8790typedef enum {
    8891    WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
Note: See TracChangeset for help on using the changeset viewer.