Chromium Code Reviews| 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 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 ASSERT(document().isActive()); | 99 ASSERT(document().isActive()); |
| 100 | 100 |
| 101 if (isFocusable() && Element::supportsFocus()) | 101 if (isFocusable() && Element::supportsFocus()) |
| 102 return HTMLElement::isKeyboardFocusable(); | 102 return HTMLElement::isKeyboardFocusable(); |
| 103 | 103 |
| 104 if (isLink() && !document().frameHost()->chromeClient().tabsToLinks()) | 104 if (isLink() && !document().frameHost()->chromeClient().tabsToLinks()) |
| 105 return false; | 105 return false; |
| 106 return HTMLElement::isKeyboardFocusable(); | 106 return HTMLElement::isKeyboardFocusable(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 static void appendServerMapMousePosition(StringBuilder& url, Event* event) | 109 bool HTMLAnchorElement::getClampedPointFromEvent(IntPoint& clampedPoint, const E vent* event) |
| 110 { | 110 { |
| 111 if (!event) | |
| 112 return false; | |
| 113 | |
| 111 if (!event->isMouseEvent()) | 114 if (!event->isMouseEvent()) |
| 112 return; | 115 return false; |
| 113 | 116 |
| 114 ASSERT(event->target()); | 117 if (!event->target()) |
| 118 return false; | |
| 119 | |
| 115 Node* target = event->target()->toNode(); | 120 Node* target = event->target()->toNode(); |
| 116 ASSERT(target); | 121 if (!target) |
| 122 return false; | |
| 123 | |
| 117 if (!isHTMLImageElement(*target)) | 124 if (!isHTMLImageElement(*target)) |
| 118 return; | 125 return false; |
| 119 | 126 |
| 120 HTMLImageElement& imageElement = toHTMLImageElement(*target); | 127 HTMLImageElement& imageElement = toHTMLImageElement(*target); |
| 121 if (!imageElement.isServerMap()) | 128 if (!imageElement.isServerMap()) |
| 122 return; | 129 return false; |
| 123 | 130 |
| 124 LayoutObject* layoutObject = imageElement.layoutObject(); | 131 LayoutObject* layoutObject = imageElement.layoutObject(); |
| 125 if (!layoutObject || !layoutObject->isBox()) | 132 if (!layoutObject || !layoutObject->isBox()) |
| 126 return; | 133 return false; |
| 127 | 134 |
| 128 // The coordinates sent in the query string are relative to the height and | 135 // The coordinates sent in the query string are relative to the height and |
| 129 // width of the image element, ignoring CSS transform/zoom. | 136 // width of the image element, ignoring CSS transform/zoom. |
| 130 LayoutPoint mapPoint(layoutObject->absoluteToLocal(FloatPoint(toMouseEvent(e vent)->absoluteLocation()), UseTransforms)); | 137 LayoutPoint mapPoint(layoutObject->absoluteToLocal(FloatPoint(toMouseEvent(e vent)->absoluteLocation()), UseTransforms)); |
| 131 | 138 |
| 132 // The origin (0,0) is at the upper left of the content area, inside the | 139 // The origin (0,0) is at the upper left of the content area, inside the |
| 133 // padding and border. | 140 // padding and border. |
| 134 mapPoint -= toLayoutBox(layoutObject)->contentBoxOffset(); | 141 mapPoint -= toLayoutBox(layoutObject)->contentBoxOffset(); |
| 135 | 142 |
| 136 // CSS zoom is not reflected in the map coordinates. | 143 // CSS zoom is not reflected in the map coordinates. |
| 137 float scaleFactor = 1 / layoutObject->style()->effectiveZoom(); | 144 float scaleFactor = 1 / layoutObject->style()->effectiveZoom(); |
| 138 mapPoint.scale(scaleFactor, scaleFactor); | 145 mapPoint.scale(scaleFactor, scaleFactor); |
| 139 | 146 |
| 140 // Negative coordinates are clamped to 0 such that clicks in the left and | 147 // Negative coordinates are clamped to 0 such that clicks in the left and |
| 141 // top padding/border areas receive an X or Y coordinate of 0. | 148 // top padding/border areas receive an X or Y coordinate of 0. |
| 142 IntPoint clampedPoint(roundedIntPoint(mapPoint)); | 149 clampedPoint = IntPoint(roundedIntPoint(mapPoint)); |
| 143 clampedPoint.clampNegativeToZero(); | 150 clampedPoint.clampNegativeToZero(); |
| 144 | 151 |
| 152 return true; | |
| 153 } | |
| 154 | |
| 155 void HTMLAnchorElement::appendServerMapMousePosition(StringBuilder& url, IntPoin t& clampedPoint) | |
|
tkent
2016/03/14 00:06:33
IntPoint& -> const IntPoint&
| |
| 156 { | |
| 145 url.append('?'); | 157 url.append('?'); |
| 146 url.appendNumber(clampedPoint.x()); | 158 url.appendNumber(clampedPoint.x()); |
| 147 url.append(','); | 159 url.append(','); |
| 148 url.appendNumber(clampedPoint.y()); | 160 url.appendNumber(clampedPoint.y()); |
| 149 } | 161 } |
| 150 | 162 |
| 151 void HTMLAnchorElement::defaultEventHandler(Event* event) | 163 void HTMLAnchorElement::defaultEventHandler(Event* event) |
| 152 { | 164 { |
| 153 if (isLink()) { | 165 if (isLink()) { |
| 154 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { | 166 if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 void HTMLAnchorElement::handleClick(Event* event) | 330 void HTMLAnchorElement::handleClick(Event* event) |
| 319 { | 331 { |
| 320 event->setDefaultHandled(); | 332 event->setDefaultHandled(); |
| 321 | 333 |
| 322 LocalFrame* frame = document().frame(); | 334 LocalFrame* frame = document().frame(); |
| 323 if (!frame) | 335 if (!frame) |
| 324 return; | 336 return; |
| 325 | 337 |
| 326 StringBuilder url; | 338 StringBuilder url; |
| 327 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); | 339 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); |
| 328 appendServerMapMousePosition(url, event); | 340 IntPoint clampedPoint; |
| 341 bool success = getClampedPointFromEvent(clampedPoint, event); | |
| 342 if (success) { | |
| 343 appendServerMapMousePosition(url, clampedPoint); | |
| 344 } | |
| 329 KURL completedURL = document().completeURL(url.toString()); | 345 KURL completedURL = document().completeURL(url.toString()); |
| 330 | 346 |
| 331 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is | 347 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is |
| 332 // sent out. | 348 // sent out. |
| 333 sendPings(completedURL); | 349 sendPings(completedURL); |
| 334 | 350 |
| 335 ResourceRequest request(completedURL); | 351 ResourceRequest request(completedURL); |
| 336 request.setUIStartTime(event->platformTimeStamp()); | 352 request.setUIStartTime(event->platformTimeStamp()); |
| 337 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink); | 353 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink); |
| 338 | 354 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 } | 398 } |
| 383 | 399 |
| 384 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) | 400 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode * insertionPoint) |
| 385 { | 401 { |
| 386 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); | 402 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo int); |
| 387 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 403 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
| 388 return request; | 404 return request; |
| 389 } | 405 } |
| 390 | 406 |
| 391 } // namespace blink | 407 } // namespace blink |
| OLD | NEW |