| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Simon Hausmann <hausmann@kde.org> | 4 * (C) 2000 Simon Hausmann <hausmann@kde.org> |
| 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 #include "HTMLAnchorElement.h" | 25 #include "HTMLAnchorElement.h" |
| 26 | 26 |
| 27 #include "Attribute.h" | 27 #include "Attribute.h" |
| 28 #include "EventNames.h" | 28 #include "EventNames.h" |
| 29 #include "Frame.h" | 29 #include "Frame.h" |
| 30 #include "FrameLoaderClient.h" |
| 30 #include "FrameLoaderTypes.h" | 31 #include "FrameLoaderTypes.h" |
| 31 #include "HTMLImageElement.h" | 32 #include "HTMLImageElement.h" |
| 32 #include "HTMLNames.h" | 33 #include "HTMLNames.h" |
| 33 #include "HTMLParserIdioms.h" | 34 #include "HTMLParserIdioms.h" |
| 34 #include "KeyboardEvent.h" | 35 #include "KeyboardEvent.h" |
| 35 #include "MouseEvent.h" | 36 #include "MouseEvent.h" |
| 36 #include "Page.h" | 37 #include "Page.h" |
| 37 #include "PingLoader.h" | 38 #include "PingLoader.h" |
| 38 #include "RenderImage.h" | 39 #include "RenderImage.h" |
| 39 #include "ResourceHandle.h" | 40 #include "ResourceHandle.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void HTMLAnchorElement::defaultEventHandler(Event* event) | 141 void HTMLAnchorElement::defaultEventHandler(Event* event) |
| 141 { | 142 { |
| 142 if (isLink()) { | 143 if (isLink()) { |
| 143 if (focused() && isEnterKeyKeydownEvent(event) && treatLinkAsLiveForEven
tType(NonMouseEvent)) { | 144 if (focused() && isEnterKeyKeydownEvent(event) && treatLinkAsLiveForEven
tType(NonMouseEvent)) { |
| 144 event->setDefaultHandled(); | 145 event->setDefaultHandled(); |
| 145 dispatchSimulatedClick(event); | 146 dispatchSimulatedClick(event); |
| 146 return; | 147 return; |
| 147 } | 148 } |
| 148 | 149 |
| 149 if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event)))
{ | 150 if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event)))
{ |
| 150 String url = stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr
)); | 151 handleClick(event); |
| 151 appendServerMapMousePosition(url, event); | |
| 152 handleLinkClick(event, document(), url, getAttribute(targetAttr), ha
sRel(RelationNoReferrer)); | |
| 153 sendPings(document()->completeURL(url)); | |
| 154 return; | 152 return; |
| 155 } | 153 } |
| 156 | 154 |
| 157 if (rendererIsEditable()) { | 155 if (rendererIsEditable()) { |
| 158 // This keeps track of the editable block that the selection was in
(if it was in one) just before the link was clicked | 156 // This keeps track of the editable block that the selection was in
(if it was in one) just before the link was clicked |
| 159 // for the LiveWhenNotFocused editable link behavior | 157 // for the LiveWhenNotFocused editable link behavior |
| 160 if (event->type() == eventNames().mousedownEvent && event->isMouseEv
ent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()-
>frame() && document()->frame()->selection()) { | 158 if (event->type() == eventNames().mousedownEvent && event->isMouseEv
ent() && static_cast<MouseEvent*>(event)->button() != RightButton && document()-
>frame() && document()->frame()->selection()) { |
| 161 m_rootEditableElementForSelectionOnMouseDown = document()->frame
()->selection()->rootEditableElement(); | 159 m_rootEditableElementForSelectionOnMouseDown = document()->frame
()->selection()->rootEditableElement(); |
| 162 m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->
shiftKey(); | 160 m_wasShiftKeyDownOnMouseDown = static_cast<MouseEvent*>(event)->
shiftKey(); |
| 163 } else if (event->type() == eventNames().mouseoverEvent) { | 161 } else if (event->type() == eventNames().mouseoverEvent) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 void HTMLAnchorElement::sendPings(const KURL& destinationURL) | 483 void HTMLAnchorElement::sendPings(const KURL& destinationURL) |
| 486 { | 484 { |
| 487 if (!hasAttribute(pingAttr) || !document()->settings()->hyperlinkAuditingEna
bled()) | 485 if (!hasAttribute(pingAttr) || !document()->settings()->hyperlinkAuditingEna
bled()) |
| 488 return; | 486 return; |
| 489 | 487 |
| 490 SpaceSplitString pingURLs(getAttribute(pingAttr), true); | 488 SpaceSplitString pingURLs(getAttribute(pingAttr), true); |
| 491 for (unsigned i = 0; i < pingURLs.size(); i++) | 489 for (unsigned i = 0; i < pingURLs.size(); i++) |
| 492 PingLoader::sendPing(document()->frame(), document()->completeURL(pingUR
Ls[i]), destinationURL); | 490 PingLoader::sendPing(document()->frame(), document()->completeURL(pingUR
Ls[i]), destinationURL); |
| 493 } | 491 } |
| 494 | 492 |
| 493 void HTMLAnchorElement::handleClick(Event* event) |
| 494 { |
| 495 event->setDefaultHandled(); |
| 496 |
| 497 Frame* frame = document()->frame(); |
| 498 if (!frame) |
| 499 return; |
| 500 |
| 501 String url = stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr)); |
| 502 appendServerMapMousePosition(url, event); |
| 503 KURL kurl = document()->completeURL(url); |
| 504 |
| 505 #if ENABLE(DOWNLOAD_ATTRIBUTE) |
| 506 if (hasAttribute(downloadAttr)) { |
| 507 ResourceRequest request(kurl); |
| 508 |
| 509 if (!hasRel(RelationNoReferrer)) { |
| 510 String referrer = frame->loader()->outgoingReferrer(); |
| 511 if (!referrer.isEmpty() && !SecurityOrigin::shouldHideReferrer(kurl,
referrer)) |
| 512 request.setHTTPReferrer(referrer); |
| 513 frame->loader()->addExtraFieldsToMainResourceRequest(request); |
| 514 } |
| 515 |
| 516 frame->loader()->client()->startDownload(request, fastGetAttribute(downl
oadAttr)); |
| 517 } else |
| 518 #endif |
| 519 frame->loader()->urlSelected(kurl, target(), event, false, false, hasRel
(RelationNoReferrer) ? NoReferrer : SendReferrer); |
| 520 |
| 521 sendPings(kurl); |
| 522 } |
| 523 |
| 495 HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event) | 524 HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event) |
| 496 { | 525 { |
| 497 if (!event->isMouseEvent()) | 526 if (!event->isMouseEvent()) |
| 498 return NonMouseEvent; | 527 return NonMouseEvent; |
| 499 return static_cast<MouseEvent*>(event)->shiftKey() ? MouseEventWithShiftKey
: MouseEventWithoutShiftKey; | 528 return static_cast<MouseEvent*>(event)->shiftKey() ? MouseEventWithShiftKey
: MouseEventWithoutShiftKey; |
| 500 } | 529 } |
| 501 | 530 |
| 502 bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const | 531 bool HTMLAnchorElement::treatLinkAsLiveForEventType(EventType eventType) const |
| 503 { | 532 { |
| 504 if (!rendererIsEditable()) | 533 if (!rendererIsEditable()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 { | 577 { |
| 549 event->setDefaultHandled(); | 578 event->setDefaultHandled(); |
| 550 | 579 |
| 551 Frame* frame = document->frame(); | 580 Frame* frame = document->frame(); |
| 552 if (!frame) | 581 if (!frame) |
| 553 return; | 582 return; |
| 554 frame->loader()->urlSelected(document->completeURL(url), target, event, fals
e, false, hideReferrer ? NoReferrer : SendReferrer); | 583 frame->loader()->urlSelected(document->completeURL(url), target, event, fals
e, false, hideReferrer ? NoReferrer : SendReferrer); |
| 555 } | 584 } |
| 556 | 585 |
| 557 } | 586 } |
| OLD | NEW |