Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-29062009...
[qt-netbsd.git] / src / 3rdparty / webkit / WebCore / wml / WMLAnchorElement.cpp
blobaac99db02a10ea9a9ed65b6d16f35381d4445ac2
1 /**
2 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "config.h"
23 #if ENABLE(WML)
24 #include "WMLAnchorElement.h"
26 #include "EventNames.h"
27 #include "KeyboardEvent.h"
28 #include "WMLTaskElement.h"
29 #include "HTMLNames.h"
31 namespace WebCore {
33 WMLAnchorElement::WMLAnchorElement(const QualifiedName& tagName, Document* doc)
34 : WMLAElement(tagName, doc)
35 , m_task(0)
37 // Calling setIsLink(true), and returning a non-null value on CSSStyleSelectors' linkAttribute
38 // method, makes it possible to 'appear as link' (just like <a href="..">) without the need to
39 // actually set the href value to an empty value in the DOM tree.
40 setIsLink(true);
43 WMLAnchorElement::~WMLAnchorElement()
47 void WMLAnchorElement::defaultEventHandler(Event* event)
49 bool shouldHandle = false;
51 if (event->type() == eventNames().clickEvent)
52 shouldHandle = true;
53 else if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && focused())
54 shouldHandle = static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter";
56 if (shouldHandle && m_task) {
57 m_task->executeTask(event);
58 event->setDefaultHandled();
59 return;
62 // Skip WMLAElement::defaultEventHandler, we don't own a href attribute, that needs to be handled.
63 WMLElement::defaultEventHandler(event);
68 #endif