[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

pkasting at chromium.org pkasting at chromium.org
Wed Dec 22 13:18:54 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 35c5672409183b8c9e1a71d5bb807c348fadc94b
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 10 22:42:32 2010 +0000

    2010-09-109  Peter Kasting  <pkasting at google.com>
    
    Reviewed by Darin Adler.
    
    Cleanup and simplification in advance of making middle clicks not send a
    click event.
    https://bugs.webkit.org/show_bug.cgi?id=22382
    
    * editing/DeleteButton.cpp:
    (WebCore::DeleteButton::defaultEventHandler): Removed unneeded code to
    check if the event is a MouseEvent. Any click event will do.
    * html/HTMLAnchorElement.cpp:
    (WebCore::appendServerMapMousePosition): Added. Factors out the
    modifications to the URL to add the mouse position to make the default
    event handler function easier to read.
    (WebCore::HTMLAnchorElement::defaultEventHandler): Reorganized to make
    the enter key logic separate from the link clicking logic and simplify
    the function.  This makes minor functional changes like not calling
    FrameLoader::urlSelected() for fake "keydown" events constructed from
    JavaScript.
    (WebCore::HTMLAnchorElement::isLiveLink): Refactored to use new shared
    implementation in treatLinkAsLiveForEventType().
    (WebCore::eventType): Factors out event type calculation (for
    treatLinkAsLiveForEventType()) from the default event handler to make it
    easier to read.
    (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType):
    Implementation of the portions of isLiveLink() that are common with the
    checks defaultEventHandler() wants to do.
    (WebCore::isEnterKeyKeydownEvent): Added. Shared by the default
    event handlers for all three anchor elements.
    (WebCore::isMiddleMouseButtonEvent): Added. Shared by the isLinkClick
    function below and some code in SVG. Later we can make this private to
    this source file once we remove the unneeded SVG code.
    (WebCore::isLinkClick): Added. Shared by the default event handlers for
    all three anchor elements.
    (WebCore::handleLinkClick): Ditto.
    * html/HTMLAnchorElement.h: Added the new functions.
    * svg/SVGAElement.cpp:
    (WebCore::SVGAElement::defaultEventHandler): Removed lots of unneeded
    logic and streamlined the code to more closely match the
    HTMLAnchorElement code and share functions with it.
    * wml/WMLAElement.cpp:
    (WebCore::WMLAElement::defaultEventHandler): Ditto.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67246 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2e83c9a..1452c9d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-09-109  Peter Kasting  <pkasting at google.com>
+
+        Reviewed by Darin Adler.
+
+        Cleanup and simplification in advance of making middle clicks not send a
+        click event.
+        https://bugs.webkit.org/show_bug.cgi?id=22382
+
+        * editing/DeleteButton.cpp:
+        (WebCore::DeleteButton::defaultEventHandler): Removed unneeded code to
+        check if the event is a MouseEvent. Any click event will do.
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::appendServerMapMousePosition): Added. Factors out the
+        modifications to the URL to add the mouse position to make the default
+        event handler function easier to read.
+        (WebCore::HTMLAnchorElement::defaultEventHandler): Reorganized to make
+        the enter key logic separate from the link clicking logic and simplify
+        the function.  This makes minor functional changes like not calling
+        FrameLoader::urlSelected() for fake "keydown" events constructed from
+        JavaScript.
+        (WebCore::HTMLAnchorElement::isLiveLink): Refactored to use new shared
+        implementation in treatLinkAsLiveForEventType().
+        (WebCore::eventType): Factors out event type calculation (for
+        treatLinkAsLiveForEventType()) from the default event handler to make it
+        easier to read.
+        (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType):
+        Implementation of the portions of isLiveLink() that are common with the
+        checks defaultEventHandler() wants to do.
+        (WebCore::isEnterKeyKeydownEvent): Added. Shared by the default
+        event handlers for all three anchor elements.
+        (WebCore::isMiddleMouseButtonEvent): Added. Shared by the isLinkClick
+        function below and some code in SVG. Later we can make this private to
+        this source file once we remove the unneeded SVG code.
+        (WebCore::isLinkClick): Added. Shared by the default event handlers for
+        all three anchor elements.
+        (WebCore::handleLinkClick): Ditto.
+        * html/HTMLAnchorElement.h: Added the new functions.
+        * svg/SVGAElement.cpp:
+        (WebCore::SVGAElement::defaultEventHandler): Removed lots of unneeded
+        logic and streamlined the code to more closely match the
+        HTMLAnchorElement code and share functions with it.
+        * wml/WMLAElement.cpp:
+        (WebCore::WMLAElement::defaultEventHandler): Ditto.
+
 2010-09-10  Tony Gentilcore  <tonyg at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/editing/DeleteButton.cpp b/WebCore/editing/DeleteButton.cpp
index 91991cf..7f2fec0 100644
--- a/WebCore/editing/DeleteButton.cpp
+++ b/WebCore/editing/DeleteButton.cpp
@@ -50,14 +50,10 @@ PassRefPtr<DeleteButton> DeleteButton::create(Document* document)
 
 void DeleteButton::defaultEventHandler(Event* event)
 {
-    // FIXME: Is it really import to check the type of the event?
-    // Seems OK to respond to any event named click even if it does not have the correct type.
-    if (event->isMouseEvent()) {
-        if (event->type() == eventNames().clickEvent) {
-            document()->frame()->editor()->deleteButtonController()->deleteTarget();
-            event->setDefaultHandled();
-            // FIXME: Shouldn't we return here instead of falling through?
-        }
+    if (event->type() == eventNames().clickEvent) {
+        document()->frame()->editor()->deleteButtonController()->deleteTarget();
+        event->setDefaultHandled();
+        return;
     }
 
     HTMLImageElement::defaultEventHandler(event);
diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp
index e1ee86a..d1914fd 100644
--- a/WebCore/html/HTMLAnchorElement.cpp
+++ b/WebCore/html/HTMLAnchorElement.cpp
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2000 Simon Hausmann <hausmann at kde.org>
- * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *           (C) 2006 Graham Dennis (graham.dennis at gmail.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -105,117 +105,67 @@ bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
     return hasNonEmptyBoundingBox();
 }
 
-void HTMLAnchorElement::defaultEventHandler(Event* evt)
+static void appendServerMapMousePosition(String& url, Event* event)
 {
-    // React on clicks and on keypresses.
-    // Don't make this KEYUP_EVENT again, it makes khtml follow links it shouldn't,
-    // when pressing Enter in the combo.
-    if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) {
-        MouseEvent* e = 0;
-        if (evt->type() == eventNames().clickEvent && evt->isMouseEvent())
-            e = static_cast<MouseEvent*>(evt);
+    if (!event->isMouseEvent())
+        return;
 
-        KeyboardEvent* k = 0;
-        if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent())
-            k = static_cast<KeyboardEvent*>(evt);
+    ASSERT(event->target());
+    Node* target = event->target()->toNode();
+    ASSERT(target);
+    if (!target->hasTagName(imgTag))
+        return;
 
-        if (e && e->button() == RightButton) {
-            HTMLElement::defaultEventHandler(evt);
-            return;
-        }
+    HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(event->target()->toNode());
+    if (!imageElement || !imageElement->isServerMap())
+        return;
 
-        // If the link is editable, then we need to check the settings to see whether or not to follow the link
-        if (isContentEditable()) {
-            EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
-            if (Settings* settings = document()->settings())
-                editableLinkBehavior = settings->editableLinkBehavior();
-                
-            switch (editableLinkBehavior) {
-                // Always follow the link (Safari 2.0 behavior)
-                default:
-                case EditableLinkDefaultBehavior:
-                case EditableLinkAlwaysLive:
-                    break;
-
-                case EditableLinkNeverLive:
-                    HTMLElement::defaultEventHandler(evt);
-                    return;
+    RenderImage* renderer = toRenderImage(imageElement->renderer());
+    if (!renderer)
+        return;
 
-                // If the selection prior to clicking on this link resided in the same editable block as this link,
-                // and the shift key isn't pressed, we don't want to follow the link
-                case EditableLinkLiveWhenNotFocused:
-                    if (e && !e->shiftKey() && m_rootEditableElementForSelectionOnMouseDown == rootEditableElement()) {
-                        HTMLElement::defaultEventHandler(evt);
-                        return;
-                    }
-                    break;
-
-                // Only follow the link if the shift key is down (WinIE/Firefox behavior)
-                case EditableLinkOnlyLiveWithShiftKey:
-                    if (e && !e->shiftKey()) {
-                        HTMLElement::defaultEventHandler(evt);
-                        return;
-                    }
-                    break;
-            }
-        }
+    // FIXME: This should probably pass true for useTransforms.
+    FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(static_cast<MouseEvent*>(event)->pageX(), static_cast<MouseEvent*>(event)->pageY()));
+    int x = absolutePosition.x();
+    int y = absolutePosition.y();
+    url += "?";
+    url += String::number(x);
+    url += ",";
+    url += String::number(y);
+}
 
-        if (k) {
-            if (k->keyIdentifier() != "Enter") {
-                HTMLElement::defaultEventHandler(evt);
-                return;
-            }
-            evt->setDefaultHandled();
-            dispatchSimulatedClick(evt);
+void HTMLAnchorElement::defaultEventHandler(Event* event)
+{
+    if (isLink()) {
+        if (focused() && isEnterKeyKeydownEvent(event) && treatLinkAsLiveForEventType(NonMouseEvent)) {
+            event->setDefaultHandled();
+            dispatchSimulatedClick(event);
             return;
         }
 
-        String url = deprecatedParseURL(getAttribute(hrefAttr));
-
-        ASSERT(evt->target());
-        ASSERT(evt->target()->toNode());
-        if (evt->target()->toNode()->hasTagName(imgTag)) {
-            HTMLImageElement* img = static_cast<HTMLImageElement*>(evt->target()->toNode());
-            if (img && img->isServerMap()) {
-                RenderImage* r = toRenderImage(img->renderer());
-                if (r && e) {
-                    // FIXME: broken with transforms
-                    FloatPoint absPos = r->localToAbsolute();
-                    int x = e->pageX() - absPos.x();
-                    int y = e->pageY() - absPos.y();
-                    url += "?";
-                    url += String::number(x);
-                    url += ",";
-                    url += String::number(y);
-                } else {
-                    evt->setDefaultHandled();
-                    HTMLElement::defaultEventHandler(evt);
-                    return;
-                }
-            }
+        if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event))) {
+            String url = deprecatedParseURL(getAttribute(hrefAttr));
+            appendServerMapMousePosition(url, event);
+            handleLinkClick(event, document(), url, getAttribute(targetAttr), hasRel(RelationNoReferrer));
+            return;
         }
 
-        if (!evt->defaultPrevented() && document()->frame())
-            document()->frame()->loader()->urlSelected(document()->completeURL(url), getAttribute(targetAttr), evt, false, false, true, hasRel(RelationNoReferrer) ? NoReferrer : SendReferrer);
-
-        evt->setDefaultHandled();
-    } else if (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() == eventNames().mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
-            MouseEvent* e = static_cast<MouseEvent*>(evt);
-
-            m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selection()->rootEditableElement();
-            m_wasShiftKeyDownOnMouseDown = e && e->shiftKey();
-        } else if (evt->type() == eventNames().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;
+        if (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 (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()->frame() && document()->frame()->selection()) {
+                m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selection()->rootEditableElement();
+                m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->shiftKey();
+            } else if (event->type() == eventNames().mouseoverEvent) {
+                // These are cleared on mouseover and not mouseout because their values are needed for drag events,
+                // but drag events happen after mouse out events.
+                m_rootEditableElementForSelectionOnMouseDown = 0;
+                m_wasShiftKeyDownOnMouseDown = false;
+            }
         }
     }
 
-    HTMLElement::defaultEventHandler(evt);
+    HTMLElement::defaultEventHandler(event);
 }
 
 void HTMLAnchorElement::setActive(bool down, bool pause)
@@ -512,32 +462,69 @@ String HTMLAnchorElement::toString() const
 
 bool HTMLAnchorElement::isLiveLink() const
 {
-    if (!isLink())
-        return false;
+    return isLink() && treatLinkAsLiveForEventType(m_wasShiftKeyDownOnMouseDown ? MouseEventWithShiftKey : MouseEventWithoutShiftKey);
+}
+
+HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event)
+{
+    if (!event->isMouseEvent())
+        return NonMouseEvent;
+    return static_cast<MouseEvent*>(event)->shiftKey() ? MouseEventWithShiftKey : MouseEventWithoutShiftKey;
+}
+
+bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const
+{
     if (!isContentEditable())
         return true;
-    
-    EditableLinkBehavior editableLinkBehavior = EditableLinkDefaultBehavior;
-    if (Settings* settings = document()->settings())
-        editableLinkBehavior = settings->editableLinkBehavior();
-        
-    switch (editableLinkBehavior) {
-        default:
-        case EditableLinkDefaultBehavior:
-        case EditableLinkAlwaysLive:
-            return true;
-
-        case EditableLinkNeverLive:
-            return false;
-
-        // 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 EditableLinkLiveWhenNotFocused:
-            return m_wasShiftKeyDownOnMouseDown || m_rootEditableElementForSelectionOnMouseDown != rootEditableElement();
-            
-        case EditableLinkOnlyLiveWithShiftKey:
-            return m_wasShiftKeyDownOnMouseDown;
+
+    Settings* settings = document()->settings();
+    if (!settings)
+        return true;
+
+    switch (settings->editableLinkBehavior()) {
+    case EditableLinkDefaultBehavior:
+    case EditableLinkAlwaysLive:
+        return true;
+
+    case EditableLinkNeverLive:
+        return false;
+
+    // If the selection prior to clicking on this link resided in the same editable block as this link,
+    // and the shift key isn't pressed, we don't want to follow the link.
+    case EditableLinkLiveWhenNotFocused:
+        return eventType == MouseEventWithShiftKey || (eventType == MouseEventWithoutShiftKey && m_rootEditableElementForSelectionOnMouseDown != rootEditableElement());
+
+    case EditableLinkOnlyLiveWithShiftKey:
+        return eventType == MouseEventWithShiftKey;
     }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+bool isEnterKeyKeydownEvent(Event* event)
+{
+    return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter";
+}
+
+bool isMiddleMouseButtonEvent(Event* event)
+{
+    return event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == MiddleButton;
+}
+
+bool isLinkClick(Event* event)
+{
+    return event->type() == eventNames().clickEvent && (!event->isMouseEvent() || static_cast<MouseEvent*>(event)->button() != RightButton);
+}
+
+void handleLinkClick(Event* event, Document* document, const String& url, const String& target, bool hideReferrer)
+{
+    event->setDefaultHandled();
+
+    Frame* frame = document->frame();
+    if (!frame)
+        return;
+    frame->loader()->urlSelected(document->completeURL(url), target, event, false, false, true, hideReferrer ? NoReferrer : SendReferrer);
 }
 
 }
diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h
index a5ef167..16baff1 100644
--- a/WebCore/html/HTMLAnchorElement.h
+++ b/WebCore/html/HTMLAnchorElement.h
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2000 Simon Hausmann <hausmann at kde.org>
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -109,11 +109,26 @@ private:
     virtual short tabIndex() const;
     virtual bool draggable() const;
 
+    enum EventType {
+        MouseEventWithoutShiftKey,
+        MouseEventWithShiftKey,
+        NonMouseEvent,
+    };
+    static EventType eventType(Event*);
+    bool treatLinkAsLiveForEventType(EventType) const;
+
     RefPtr<Element> m_rootEditableElementForSelectionOnMouseDown;
     bool m_wasShiftKeyDownOnMouseDown;
     uint32_t m_linkRelations;
 };
 
+// Functions shared with the other anchor elements (SVG and WML).
+
+bool isEnterKeyKeydownEvent(Event*);
+bool isMiddleMouseButtonEvent(Event*);
+bool isLinkClick(Event*);
+void handleLinkClick(Event*, Document*, const String& url, const String& target, bool hideReferrer = false);
+
 } // namespace WebCore
 
 #endif // HTMLAnchorElement_h
diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp
index b0ffc74..d711a52 100644
--- a/WebCore/svg/SVGAElement.cpp
+++ b/WebCore/svg/SVGAElement.cpp
@@ -2,6 +2,7 @@
  * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann at kde.org>
  * Copyright (C) 2004, 2005, 2007 Rob Buis <buis at kde.org>
  * Copyright (C) 2007 Eric Seidel <eric at webkit.org>
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,6 +34,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderTypes.h"
+#include "HTMLAnchorElement.h"
 #include "KeyboardEvent.h"
 #include "MouseEvent.h"
 #include "PlatformMouseEvent.h"
@@ -125,60 +127,47 @@ RenderObject* SVGAElement::createRenderer(RenderArena* arena, RenderStyle*)
     return new (arena) RenderSVGTransformableContainer(this);
 }
 
-void SVGAElement::defaultEventHandler(Event* evt)
+void SVGAElement::defaultEventHandler(Event* event)
 {
-    if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) {
-        MouseEvent* e = 0;
-        if (evt->type() == eventNames().clickEvent && evt->isMouseEvent())
-            e = static_cast<MouseEvent*>(evt);
-        
-        KeyboardEvent* k = 0;
-        if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent())
-            k = static_cast<KeyboardEvent*>(evt);
-        
-        if (e && e->button() == RightButton) {
-            SVGStyledTransformableElement::defaultEventHandler(evt);
+    if (isLink()) {
+        if (focused() && isEnterKeyKeydownEvent(event)) {
+            event->setDefaultHandled();
+            dispatchSimulatedClick(event);
             return;
         }
-        
-        if (k) {
-            if (k->keyIdentifier() != "Enter") {
-                SVGStyledTransformableElement::defaultEventHandler(evt);
-                return;
-            }
-            evt->setDefaultHandled();
-            dispatchSimulatedClick(evt);
-            return;
-        }
-        
-        String target = this->target();
-        if (e && e->button() == MiddleButton)
-            target = "_blank";
-        else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set
-            target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self";
-
-        if (!evt->defaultPrevented()) {
+
+        if (isLinkClick(event)) {
             String url = deprecatedParseURL(href());
+
 #if ENABLE(SVG_ANIMATION)
-            if (url.startsWith("#")) {
+            if (url[0] == '#') {
                 Element* targetElement = document()->getElementById(url.substring(1));
                 if (SVGSMILElement::isSMILElement(targetElement)) {
-                    SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement);
-                    timed->beginByLinkActivation();
-                    evt->setDefaultHandled();
-                    SVGStyledTransformableElement::defaultEventHandler(evt);
+                    static_cast<SVGSMILElement*>(targetElement)->beginByLinkActivation();
+                    event->setDefaultHandled();
                     return;
                 }
             }
 #endif
-            if (document()->frame())
-                document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true, SendReferrer);
-        }
 
-        evt->setDefaultHandled();
+            // FIXME: Why does the SVG anchor element have this special logic
+            // for middle click that the HTML anchor element does not have?
+            // Making a middle click open a link in a new window or tab is
+            // properly handled at the client level, not inside WebKit; this
+            // code should be deleted.
+            String target = isMiddleMouseButtonEvent(event) ? "_blank" : this->target();
+
+            // FIXME: It's not clear why setting target to "_self" is ever
+            // helpful.
+            if (target.isEmpty())
+                target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self";
+
+            handleLinkClick(event, document(), url, target);
+            return;
+        }
     }
 
-    SVGStyledTransformableElement::defaultEventHandler(evt);
+    SVGStyledTransformableElement::defaultEventHandler(event);
 }
 
 bool SVGAElement::supportsFocus() const
diff --git a/WebCore/wml/WMLAElement.cpp b/WebCore/wml/WMLAElement.cpp
index 4d1bf95..8a4dc09 100644
--- a/WebCore/wml/WMLAElement.cpp
+++ b/WebCore/wml/WMLAElement.cpp
@@ -4,7 +4,7 @@
  * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2000 Simon Hausmann <hausmann at kde.org>
- * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
  *           (C) 2006 Graham Dennis (graham.dennis at gmail.com)
  *
  * This library is free software; you can redistribute it and/or
@@ -35,6 +35,7 @@
 #include "EventNames.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "HTMLAnchorElement.h"
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
 #include "MouseEvent.h"
@@ -119,37 +120,17 @@ bool WMLAElement::isKeyboardFocusable(KeyboardEvent* event) const
 
 void WMLAElement::defaultEventHandler(Event* event)
 {
-    if (isLink() && (event->type() == eventNames().clickEvent || (event->type() == eventNames().keydownEvent && focused()))) {
-        MouseEvent* e = 0;
-        if (event->type() == eventNames().clickEvent && event->isMouseEvent())
-            e = static_cast<MouseEvent*>(event);
-
-        KeyboardEvent* k = 0;
-        if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent())
-            k = static_cast<KeyboardEvent*>(event);
-
-        if (e && e->button() == RightButton) {
-            WMLElement::defaultEventHandler(event);
-            return;
-        }
-
-        if (k) {
-            if (k->keyIdentifier() != "Enter") {
-                WMLElement::defaultEventHandler(event);
-                return;
-            }
-
+    if (isLink()) {
+        if (focused() && isEnterKeyKeydownEvent(event)) {
             event->setDefaultHandled();
             dispatchSimulatedClick(event);
             return;
         }
- 
-        if (!event->defaultPrevented() && document()->frame()) {
-            KURL url = document()->completeURL(deprecatedParseURL(getAttribute(HTMLNames::hrefAttr)));
-            document()->frame()->loader()->urlSelected(url, target(), event, false, false, true, SendReferrer);
-        }
 
-        event->setDefaultHandled();
+        if (isLinkClick(event)) {
+            handleLinkClick(document(), deprecatedParseURL(getAttribute(HTMLNames::hrefAttr)), target(), event);
+            return;
+        }
     }
 
     WMLElement::defaultEventHandler(event);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list