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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 using namespace HTMLNames; | 46 using namespace HTMLNames; |
47 | 47 |
48 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) | 48 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) |
49 : HTMLElement(tagName, document) | 49 : HTMLElement(tagName, document) |
50 , m_linkRelations(0) | 50 , m_linkRelations(0) |
51 , m_cachedVisitedLinkHash(0) | 51 , m_cachedVisitedLinkHash(0) |
52 , m_wasFocusedByMouse(false) | 52 , m_wasFocusedByMouse(false) |
53 { | 53 { |
54 } | 54 } |
55 | 55 |
56 DEFINE_TRACE(HTMLAnchorElement) | |
57 { | |
58 visitor->trace(m_ping); | |
59 HTMLElement::trace(visitor); | |
60 DOMSettableTokenListObserver::trace(visitor); | |
61 } | |
62 | |
56 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) | 63 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) |
57 { | 64 { |
58 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); | 65 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); |
59 } | 66 } |
60 | 67 |
61 HTMLAnchorElement::~HTMLAnchorElement() | 68 HTMLAnchorElement::~HTMLAnchorElement() |
62 { | 69 { |
70 #if !ENABLE(OILPAN) | |
71 if (m_ping) | |
72 m_ping->setObserver(nullptr); | |
73 #endif | |
63 } | 74 } |
64 | 75 |
65 bool HTMLAnchorElement::supportsFocus() const | 76 bool HTMLAnchorElement::supportsFocus() const |
66 { | 77 { |
67 if (hasEditableStyle()) | 78 if (hasEditableStyle()) |
68 return HTMLElement::supportsFocus(); | 79 return HTMLElement::supportsFocus(); |
69 // If not a link we should still be able to focus the element if it has tabI ndex. | 80 // If not a link we should still be able to focus the element if it has tabI ndex. |
70 return isLink() || HTMLElement::supportsFocus(); | 81 return isLink() || HTMLElement::supportsFocus(); |
71 } | 82 } |
72 | 83 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 if (document().isDNSPrefetchEnabled()) { | 224 if (document().isDNSPrefetchEnabled()) { |
214 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http s") || parsedURL.startsWith("//")) | 225 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http s") || parsedURL.startsWith("//")) |
215 prefetchDNS(document().completeURL(parsedURL).host()); | 226 prefetchDNS(document().completeURL(parsedURL).host()); |
216 } | 227 } |
217 } | 228 } |
218 invalidateCachedVisitedLinkHash(); | 229 invalidateCachedVisitedLinkHash(); |
219 } else if (name == nameAttr || name == titleAttr) { | 230 } else if (name == nameAttr || name == titleAttr) { |
220 // Do nothing. | 231 // Do nothing. |
221 } else if (name == relAttr) { | 232 } else if (name == relAttr) { |
222 setRel(value); | 233 setRel(value); |
234 } else if (name == pingAttr) { | |
235 ping()->setValue(value); | |
223 } else { | 236 } else { |
224 HTMLElement::parseAttribute(name, value); | 237 HTMLElement::parseAttribute(name, value); |
225 } | 238 } |
226 } | 239 } |
227 | 240 |
228 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) | 241 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) |
229 { | 242 { |
230 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents); | 243 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents); |
231 } | 244 } |
232 | 245 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 return Element::tabIndex(); | 326 return Element::tabIndex(); |
314 } | 327 } |
315 | 328 |
316 bool HTMLAnchorElement::isLiveLink() const | 329 bool HTMLAnchorElement::isLiveLink() const |
317 { | 330 { |
318 return isLink() && !hasEditableStyle(); | 331 return isLink() && !hasEditableStyle(); |
319 } | 332 } |
320 | 333 |
321 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const | 334 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const |
322 { | 335 { |
323 const AtomicString& pingValue = getAttribute(pingAttr); | 336 if (!m_ping || m_ping->value().isNull() || !document().settings() || !docume nt().settings()->hyperlinkAuditingEnabled()) |
324 if (pingValue.isNull() || !document().settings() || !document().settings()-> hyperlinkAuditingEnabled()) | |
325 return; | 337 return; |
326 | 338 |
327 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); | 339 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); |
328 | 340 |
329 SpaceSplitString pingURLs(pingValue, SpaceSplitString::ShouldNotFoldCase); | 341 const SpaceSplitString& pingURLs = m_ping->tokens(); |
330 for (unsigned i = 0; i < pingURLs.size(); i++) | 342 for (unsigned i = 0; i < pingURLs.size(); i++) |
331 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL); | 343 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL); |
332 } | 344 } |
333 | 345 |
346 DOMSettableTokenList* HTMLAnchorElement::ping() | |
347 { | |
348 if (!m_ping) | |
349 m_ping = DOMSettableTokenList::create(this); | |
350 | |
351 return m_ping.get(); | |
352 } | |
353 | |
334 void HTMLAnchorElement::handleClick(Event* event) | 354 void HTMLAnchorElement::handleClick(Event* event) |
335 { | 355 { |
336 event->setDefaultHandled(); | 356 event->setDefaultHandled(); |
337 | 357 |
338 LocalFrame* frame = document().frame(); | 358 LocalFrame* frame = document().frame(); |
339 if (!frame) | 359 if (!frame) |
340 return; | 360 return; |
341 | 361 |
342 StringBuilder url; | 362 StringBuilder url; |
343 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); | 363 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); |
(...skipping 22 matching lines...) Expand all Loading... | |
366 } else { | 386 } else { |
367 request.setRequestContext(WebURLRequest::RequestContextHyperlink); | 387 request.setRequestContext(WebURLRequest::RequestContextHyperlink); |
368 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); | 388 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); |
369 frameRequest.setTriggeringEvent(event); | 389 frameRequest.setTriggeringEvent(event); |
370 if (hasRel(RelationNoReferrer)) | 390 if (hasRel(RelationNoReferrer)) |
371 frameRequest.setShouldSendReferrer(NeverSendReferrer); | 391 frameRequest.setShouldSendReferrer(NeverSendReferrer); |
372 frame->loader().load(frameRequest); | 392 frame->loader().load(frameRequest); |
373 } | 393 } |
374 } | 394 } |
375 | 395 |
396 void HTMLAnchorElement::valueChanged() | |
397 { | |
398 setSynchronizedLazyAttribute(pingAttr, m_ping->value()); | |
sof
2015/10/06 08:16:15
m_ping is guaranteed to be non-null?
philipj_slow
2015/10/06 09:01:00
I think so, because valueChanged() is called from
| |
399 } | |
400 | |
376 bool isEnterKeyKeydownEvent(Event* event) | 401 bool isEnterKeyKeydownEvent(Event* event) |
377 { | 402 { |
378 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; | 403 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; |
379 } | 404 } |
380 | 405 |
381 bool isLinkClick(Event* event) | 406 bool isLinkClick(Event* event) |
382 { | 407 { |
383 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); | 408 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); |
384 } | 409 } |
385 | 410 |
(...skipping 15 matching lines...) Expand all Loading... | |
401 Vector<String> argv; | 426 Vector<String> argv; |
402 argv.append("a"); | 427 argv.append("a"); |
403 argv.append(fastGetAttribute(hrefAttr)); | 428 argv.append(fastGetAttribute(hrefAttr)); |
404 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); | 429 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); |
405 } | 430 } |
406 } | 431 } |
407 return HTMLElement::insertedInto(insertionPoint); | 432 return HTMLElement::insertedInto(insertionPoint); |
408 } | 433 } |
409 | 434 |
410 } // namespace blink | 435 } // namespace blink |
OLD | NEW |