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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 using namespace HTMLNames; | 45 using namespace HTMLNames; |
46 | 46 |
47 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc
ument) | 47 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc
ument) |
48 : HTMLElement(tagName, document) | 48 : HTMLElement(tagName, document) |
49 , m_linkRelations(0) | 49 , m_linkRelations(0) |
50 , m_cachedVisitedLinkHash(0) | 50 , m_cachedVisitedLinkHash(0) |
51 , m_wasFocusedByMouse(false) | 51 , m_wasFocusedByMouse(false) |
52 { | 52 { |
53 } | 53 } |
54 | 54 |
| 55 DEFINE_TRACE(HTMLAnchorElement) |
| 56 { |
| 57 visitor->trace(m_ping); |
| 58 HTMLElement::trace(visitor); |
| 59 DOMSettableTokenListObserver::trace(visitor); |
| 60 } |
| 61 |
55 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do
cument) | 62 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do
cument) |
56 { | 63 { |
57 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); | 64 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); |
58 } | 65 } |
59 | 66 |
60 HTMLAnchorElement::~HTMLAnchorElement() | 67 HTMLAnchorElement::~HTMLAnchorElement() |
61 { | 68 { |
| 69 #if !ENABLE(OILPAN) |
| 70 if (m_ping) |
| 71 m_ping->setObserver(nullptr); |
| 72 #endif |
62 } | 73 } |
63 | 74 |
64 bool HTMLAnchorElement::supportsFocus() const | 75 bool HTMLAnchorElement::supportsFocus() const |
65 { | 76 { |
66 if (hasEditableStyle()) | 77 if (hasEditableStyle()) |
67 return HTMLElement::supportsFocus(); | 78 return HTMLElement::supportsFocus(); |
68 // If not a link we should still be able to focus the element if it has tabI
ndex. | 79 // If not a link we should still be able to focus the element if it has tabI
ndex. |
69 return isLink() || HTMLElement::supportsFocus(); | 80 return isLink() || HTMLElement::supportsFocus(); |
70 } | 81 } |
71 | 82 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http
s") || parsedURL.startsWith("//")) | 208 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http
s") || parsedURL.startsWith("//")) |
198 prefetchDNS(document().completeURL(parsedURL).host()); | 209 prefetchDNS(document().completeURL(parsedURL).host()); |
199 } | 210 } |
200 } | 211 } |
201 invalidateCachedVisitedLinkHash(); | 212 invalidateCachedVisitedLinkHash(); |
202 logUpdateAttributeIfIsolatedWorldAndInDocument("a", hrefAttr, oldValue,
value); | 213 logUpdateAttributeIfIsolatedWorldAndInDocument("a", hrefAttr, oldValue,
value); |
203 } else if (name == nameAttr || name == titleAttr) { | 214 } else if (name == nameAttr || name == titleAttr) { |
204 // Do nothing. | 215 // Do nothing. |
205 } else if (name == relAttr) { | 216 } else if (name == relAttr) { |
206 setRel(value); | 217 setRel(value); |
| 218 } else if (name == pingAttr) { |
| 219 ping()->setValue(value); |
207 } else { | 220 } else { |
208 HTMLElement::parseAttribute(name, oldValue, value); | 221 HTMLElement::parseAttribute(name, oldValue, value); |
209 } | 222 } |
210 } | 223 } |
211 | 224 |
212 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) | 225 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) |
213 { | 226 { |
214 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv
ents); | 227 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv
ents); |
215 } | 228 } |
216 | 229 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 return Element::tabIndex(); | 312 return Element::tabIndex(); |
300 } | 313 } |
301 | 314 |
302 bool HTMLAnchorElement::isLiveLink() const | 315 bool HTMLAnchorElement::isLiveLink() const |
303 { | 316 { |
304 return isLink() && !hasEditableStyle(); | 317 return isLink() && !hasEditableStyle(); |
305 } | 318 } |
306 | 319 |
307 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const | 320 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const |
308 { | 321 { |
309 const AtomicString& pingValue = getAttribute(pingAttr); | 322 if (!m_ping || m_ping->value().isNull() || !document().settings() || !docume
nt().settings()->hyperlinkAuditingEnabled()) |
310 if (pingValue.isNull() || !document().settings() || !document().settings()->
hyperlinkAuditingEnabled()) | |
311 return; | 323 return; |
312 | 324 |
313 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); | 325 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); |
314 | 326 |
315 SpaceSplitString pingURLs(pingValue, SpaceSplitString::ShouldNotFoldCase); | 327 const SpaceSplitString& pingURLs = m_ping->tokens(); |
316 for (unsigned i = 0; i < pingURLs.size(); i++) | 328 for (unsigned i = 0; i < pingURLs.size(); i++) |
317 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL
(pingURLs[i]), destinationURL); | 329 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL
(pingURLs[i]), destinationURL); |
318 } | 330 } |
319 | 331 |
| 332 DOMSettableTokenList* HTMLAnchorElement::ping() |
| 333 { |
| 334 if (!m_ping) |
| 335 m_ping = DOMSettableTokenList::create(this); |
| 336 |
| 337 return m_ping.get(); |
| 338 } |
| 339 |
320 void HTMLAnchorElement::handleClick(Event* event) | 340 void HTMLAnchorElement::handleClick(Event* event) |
321 { | 341 { |
322 event->setDefaultHandled(); | 342 event->setDefaultHandled(); |
323 | 343 |
324 LocalFrame* frame = document().frame(); | 344 LocalFrame* frame = document().frame(); |
325 if (!frame) | 345 if (!frame) |
326 return; | 346 return; |
327 | 347 |
328 StringBuilder url; | 348 StringBuilder url; |
329 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); | 349 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); |
(...skipping 26 matching lines...) Expand all Loading... |
356 if (hasRel(RelationNoReferrer)) { | 376 if (hasRel(RelationNoReferrer)) { |
357 frameRequest.setShouldSendReferrer(NeverSendReferrer); | 377 frameRequest.setShouldSendReferrer(NeverSendReferrer); |
358 frameRequest.setShouldSetOpener(NeverSetOpener); | 378 frameRequest.setShouldSetOpener(NeverSetOpener); |
359 } | 379 } |
360 if (hasRel(RelationNoOpener)) | 380 if (hasRel(RelationNoOpener)) |
361 frameRequest.setShouldSetOpener(NeverSetOpener); | 381 frameRequest.setShouldSetOpener(NeverSetOpener); |
362 frame->loader().load(frameRequest); | 382 frame->loader().load(frameRequest); |
363 } | 383 } |
364 } | 384 } |
365 | 385 |
| 386 void HTMLAnchorElement::valueWasSet() |
| 387 { |
| 388 setSynchronizedLazyAttribute(pingAttr, m_ping->value()); |
| 389 } |
| 390 |
366 bool isEnterKeyKeydownEvent(Event* event) | 391 bool isEnterKeyKeydownEvent(Event* event) |
367 { | 392 { |
368 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent()
&& toKeyboardEvent(event)->keyIdentifier() == "Enter"; | 393 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent()
&& toKeyboardEvent(event)->keyIdentifier() == "Enter"; |
369 } | 394 } |
370 | 395 |
371 bool isLinkClick(Event* event) | 396 bool isLinkClick(Event* event) |
372 { | 397 { |
373 return event->type() == EventTypeNames::click && (!event->isMouseEvent() ||
toMouseEvent(event)->button() != RightButton); | 398 return event->type() == EventTypeNames::click && (!event->isMouseEvent() ||
toMouseEvent(event)->button() != RightButton); |
374 } | 399 } |
375 | 400 |
376 bool HTMLAnchorElement::willRespondToMouseClickEvents() | 401 bool HTMLAnchorElement::willRespondToMouseClickEvents() |
377 { | 402 { |
378 return isLink() || HTMLElement::willRespondToMouseClickEvents(); | 403 return isLink() || HTMLElement::willRespondToMouseClickEvents(); |
379 } | 404 } |
380 | 405 |
381 bool HTMLAnchorElement::isInteractiveContent() const | 406 bool HTMLAnchorElement::isInteractiveContent() const |
382 { | 407 { |
383 return isLink(); | 408 return isLink(); |
384 } | 409 } |
385 | 410 |
386 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode
* insertionPoint) | 411 Node::InsertionNotificationRequest HTMLAnchorElement::insertedInto(ContainerNode
* insertionPoint) |
387 { | 412 { |
388 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo
int); | 413 InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPo
int); |
389 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); | 414 logAddElementIfIsolatedWorldAndInDocument("a", hrefAttr); |
390 return request; | 415 return request; |
391 } | 416 } |
392 | 417 |
393 } // namespace blink | 418 } // namespace blink |
OLD | NEW |