Changeset 182957 in webkit


Ignore:
Timestamp:
Apr 17, 2015 11:21:30 AM (9 years ago)
Author:
dbates@webkit.org
Message:

REGRESSION: SVG does not support link dragging
https://bugs.webkit.org/show_bug.cgi?id=141597

Reviewed by Darin Adler.

Source/WebCore:

Fixes an issue where a SVG hyperlink cannot be dragged. We should support
dragging an SVG A element just as we support dragging an HTML A element.

Test: fast/events/drag-and-drop-link.html

  • page/DragController.cpp: Removed explicit include of header Element.h as it will

be ultimately included by HTMLAnchorElement.h, among other headers.
(WebCore::isDraggableLink): Added. Extracted code from HitTestResult::isLiveLink().
(WebCore::DragController::draggableElement): Call WebCore::isDraggableLink() to
determine whether a element is a hyperlink that can be dragged.

  • page/DragController.h:
  • page/EventHandler.cpp:

(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent): Write code in terms of

WebCore::isDraggableLink().

  • rendering/HitTestResult.cpp:

(WebCore::HitTestResult::isLiveLink): Deleted.

  • rendering/HitTestResult.h:

Source/WebKit/mac:

Write -[WebElementDictionary _isLiveLink] in terms of WebCore::isDraggableLink().

  • Misc/WebElementDictionary.mm:

(-[WebElementDictionary _isLiveLink]):

LayoutTests:

Add a test to ensure we do not regress dragging of a HTML hyperlink or a SVG hyperlink.

  • fast/events/drag-and-drop-link-expected.txt: Added.
  • fast/events/drag-and-drop-link.html: Added.
  • platform/efl/TestExpectations: Mark the test as "failure" since EFL does not support drag-and-drop.
  • platform/gtk/TestExpectations: Mark the test as "failure" until we implement drag-and-drop support for

GTK+ as part of fixing <https://bugs.webkit.org/show_bug.cgi?id=42194>.

  • platform/ios-simulator/TestExpectations: Skip the test since iOS does not implement

drag-and-drop support.

  • platform/mac-wk2/TestExpectations: Skip the test until we implement drag-and-drop support in EventSender

for Mac as part of fixing <https://bugs.webkit.org/show_bug.cgi?id=42194>.

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r182956 r182957  
     12015-04-17  Daniel Bates  <dabates@apple.com>
     2
     3        REGRESSION: SVG does not support link dragging
     4        https://bugs.webkit.org/show_bug.cgi?id=141597
     5
     6        Reviewed by Darin Adler.
     7
     8        Add a test to ensure we do not regress dragging of a HTML hyperlink or a SVG hyperlink.
     9
     10        * fast/events/drag-and-drop-link-expected.txt: Added.
     11        * fast/events/drag-and-drop-link.html: Added.
     12        * platform/efl/TestExpectations: Mark the test as "failure" since EFL does not support drag-and-drop.
     13        * platform/gtk/TestExpectations: Mark the test as "failure" until we implement drag-and-drop support for
     14        GTK+ as part of fixing <https://bugs.webkit.org/show_bug.cgi?id=42194>.
     15        * platform/ios-simulator/TestExpectations: Skip the test since iOS does not implement
     16        drag-and-drop support.
     17        * platform/mac-wk2/TestExpectations: Skip the test until we implement drag-and-drop support in EventSender
     18        for Mac as part of fixing <https://bugs.webkit.org/show_bug.cgi?id=42194>.
     19
    1202015-04-17  Commit Queue  <commit-queue@webkit.org>
    221
  • trunk/LayoutTests/platform/efl/TestExpectations

    r182956 r182957  
    344344webkit.org/b/86623 fast/events/drag-image-filename.html [ Timeout ]
    345345webkit.org/b/86623 fast/events/drag-in-frames.html [ Failure ]
     346webkit.org/b/86623 fast/events/drag-and-drop-link.html [ Failure ]
    346347webkit.org/b/86623 fast/events/drag-and-drop-link-into-focused-contenteditable.html [ Failure ]
    347348webkit.org/b/86623 fast/events/drag-parent-node.html [ Failure ]
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r182956 r182957  
    14111411webkit.org/b/63706 fast/events/drag-and-drop.html [ Failure Timeout ]
    14121412webkit.org/b/63706 fast/events/drag-and-drop-subframe-dataTransfer.html [ Failure Timeout ]
     1413webkit.org/b/42194 fast/events/drag-and-drop-link.html [ Failure ]
    14131414webkit.org/b/63706 fast/events/drag-and-drop-link-into-focused-contenteditable.html [ Failure ]
    14141415webkit.org/b/63706 fast/events/drag-parent-node.html [ Failure ]
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r182956 r182957  
    158158fast/events/drag-image-filename.html
    159159fast/events/drag-in-frames.html
     160fast/events/drag-and-drop-link.html
    160161fast/events/drag-and-drop-link-into-focused-contenteditable.html
    161162fast/events/drag-outside-window.html
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r182925 r182957  
    7777fast/events/drag-and-drop-fire-drag-dragover.html
    7878fast/events/drag-and-drop.html
     79fast/events/drag-and-drop-link.html
    7980fast/events/drag-in-frames.html
    8081fast/events/drag-parent-node.html
  • trunk/Source/WebCore/ChangeLog

    r182956 r182957  
     12015-04-17  Daniel Bates  <dabates@apple.com>
     2
     3        REGRESSION: SVG does not support link dragging
     4        https://bugs.webkit.org/show_bug.cgi?id=141597
     5
     6        Reviewed by Darin Adler.
     7
     8        Fixes an issue where a SVG hyperlink cannot be dragged. We should support
     9        dragging an SVG A element just as we support dragging an HTML A element.
     10
     11        Test: fast/events/drag-and-drop-link.html
     12
     13        * page/DragController.cpp: Removed explicit include of header Element.h as it will
     14        be ultimately included by HTMLAnchorElement.h, among other headers.
     15        (WebCore::isDraggableLink): Added. Extracted code from HitTestResult::isLiveLink().
     16        (WebCore::DragController::draggableElement): Call WebCore::isDraggableLink() to
     17        determine whether a element is a hyperlink that can be dragged.
     18        * page/DragController.h:
     19        * page/EventHandler.cpp:
     20        (WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent): Write code in terms of
     21         WebCore::isDraggableLink().
     22        * rendering/HitTestResult.cpp:
     23        (WebCore::HitTestResult::isLiveLink): Deleted.
     24        * rendering/HitTestResult.h:
     25
    1262015-04-17  Commit Queue  <commit-queue@webkit.org>
    227
  • trunk/Source/WebCore/page/DragController.cpp

    r182748 r182957  
    2727#include "DragController.h"
    2828
     29#include "HTMLAnchorElement.h"
     30#include "SVGAElement.h"
     31
    2932#if ENABLE(DRAG_SUPPORT)
    30 
    3133#include "CachedImage.h"
    3234#include "CachedResourceLoader.h"
     
    4143#include "Editor.h"
    4244#include "EditorClient.h"
    43 #include "Element.h"
    4445#include "EventHandler.h"
    4546#include "ExceptionCodePlaceholder.h"
     
    4950#include "FrameSelection.h"
    5051#include "FrameView.h"
    51 #include "HTMLAnchorElement.h"
    5252#include "HTMLAttachmentElement.h"
    5353#include "HTMLImageElement.h"
     
    8181#include <wtf/CurrentTime.h>
    8282#include <wtf/RefPtr.h>
     83#endif
    8384
    8485namespace WebCore {
    8586
     87bool isDraggableLink(const Element& element)
     88{
     89    if (is<HTMLAnchorElement>(element))
     90        return downcast<HTMLAnchorElement>(element).isLiveLink();
     91    if (is<SVGAElement>(element))
     92        return element.isLink();
     93    return false;
     94}
     95
     96#if ENABLE(DRAG_SUPPORT)
     97   
    8698static PlatformMouseEvent createMouseEvent(DragData& dragData)
    8799{
     
    653665                return element;
    654666            }
    655             if ((m_dragSourceAction & DragSourceActionLink)
    656                 && is<HTMLAnchorElement>(*element)
    657                 && downcast<HTMLAnchorElement>(*element).isLiveLink()) {
     667            if ((m_dragSourceAction & DragSourceActionLink) && isDraggableLink(*element)) {
    658668                state.type = static_cast<DragSourceAction>(state.type | DragSourceActionLink);
    659669                return element;
     
    989999}
    9901000
     1001#endif // ENABLE(DRAG_SUPPORT)
     1002
    9911003} // namespace WebCore
    992 
    993 #endif // ENABLE(DRAG_SUPPORT)
  • trunk/Source/WebCore/page/DragController.h

    r181760 r182957  
    141141    };
    142142
     143    WEBCORE_EXPORT bool isDraggableLink(const Element&);
     144
    143145}
    144146
  • trunk/Source/WebCore/page/EventHandler.cpp

    r182956 r182957  
    599599void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults& result)
    600600{
    601     if (!result.hitTestResult().isLiveLink())
     601    Element* urlElement = result.hitTestResult().URLElement();
     602    if (!urlElement || !isDraggableLink(*urlElement))
    602603        return selectClosestWordFromMouseEvent(result);
    603604
     
    606607    if (targetNode && targetNode->renderer() && m_mouseDownMayStartSelect) {
    607608        VisibleSelection newSelection;
    608         Element* URLElement = result.hitTestResult().URLElement();
    609609        VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
    610         if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf(URLElement))
    611             newSelection = VisibleSelection::selectionFromContentsOfNode(URLElement);
     610        if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf(urlElement))
     611            newSelection = VisibleSelection::selectionFromContentsOfNode(urlElement);
    612612
    613613        updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
  • trunk/Source/WebCore/rendering/HitTestResult.cpp

    r182573 r182957  
    609609}
    610610
    611 bool HitTestResult::isLiveLink() const
    612 {
    613     if (!m_innerURLElement)
    614         return false;
    615 
    616     if (is<HTMLAnchorElement>(*m_innerURLElement))
    617         return downcast<HTMLAnchorElement>(*m_innerURLElement).isLiveLink();
    618 
    619     if (is<SVGAElement>(*m_innerURLElement))
    620         return m_innerURLElement->isLink();
    621 
    622     return false;
    623 }
    624 
    625611bool HitTestResult::isOverLink() const
    626612{
  • trunk/Source/WebCore/rendering/HitTestResult.h

    r182573 r182957  
    112112#endif
    113113    WEBCORE_EXPORT String textContent() const;
    114     WEBCORE_EXPORT bool isLiveLink() const;
    115114    bool isOverLink() const;
    116115    WEBCORE_EXPORT bool isContentEditable() const;
  • trunk/Source/WebKit/mac/ChangeLog

    r182928 r182957  
     12015-04-17  Daniel Bates  <dabates@apple.com>
     2
     3        REGRESSION: SVG does not support link dragging
     4        https://bugs.webkit.org/show_bug.cgi?id=141597
     5
     6        Reviewed by Darin Adler.
     7
     8        Write -[WebElementDictionary _isLiveLink] in terms of WebCore::isDraggableLink().
     9
     10        * Misc/WebElementDictionary.mm:
     11        (-[WebElementDictionary _isLiveLink]):
     12
    1132015-04-16  Sam Weinig  <sam@webkit.org>
    214
  • trunk/Source/WebKit/mac/Misc/WebElementDictionary.mm

    r173364 r182957  
    3737#import "WebView.h"
    3838#import "WebViewPrivate.h"
     39#import <WebCore/DragController.h>
    3940#import <WebCore/Frame.h>
    4041#import <WebCore/HitTestResult.h>
     
    266267- (NSNumber *)_isLiveLink
    267268{
    268     return [NSNumber numberWithBool:_result->isLiveLink()];
     269    Element* urlElement = _result->URLElement();
     270    return [NSNumber numberWithBool:(urlElement && isDraggableLink(*urlElement))];
    269271}
    270272
Note: See TracChangeset for help on using the changeset viewer.