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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
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 , m_ping(DOMSettableTokenList::create(this)) | |
philipj_slow
2015/10/01 12:54:10
This should mean a new heap-allocated object for e
| |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
57 DEFINE_TRACE(HTMLAnchorElement) | |
58 { | |
59 visitor->trace(m_ping); | |
60 HTMLElement::trace(visitor); | |
61 DOMSettableTokenListObserver::trace(visitor); | |
62 } | |
63 | |
56 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) | 64 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) |
57 { | 65 { |
58 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); | 66 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); |
59 } | 67 } |
60 | 68 |
61 HTMLAnchorElement::~HTMLAnchorElement() | 69 HTMLAnchorElement::~HTMLAnchorElement() |
62 { | 70 { |
71 #if !ENABLE(OILPAN) | |
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 m_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->value().isNull() || !document().settings() || !document().settin gs()->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() const | |
347 { | |
348 return m_ping.get(); | |
349 } | |
350 | |
334 void HTMLAnchorElement::handleClick(Event* event) | 351 void HTMLAnchorElement::handleClick(Event* event) |
335 { | 352 { |
336 event->setDefaultHandled(); | 353 event->setDefaultHandled(); |
337 | 354 |
338 LocalFrame* frame = document().frame(); | 355 LocalFrame* frame = document().frame(); |
339 if (!frame) | 356 if (!frame) |
340 return; | 357 return; |
341 | 358 |
342 StringBuilder url; | 359 StringBuilder url; |
343 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); | 360 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); |
(...skipping 22 matching lines...) Expand all Loading... | |
366 } else { | 383 } else { |
367 request.setRequestContext(WebURLRequest::RequestContextHyperlink); | 384 request.setRequestContext(WebURLRequest::RequestContextHyperlink); |
368 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); | 385 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); |
369 frameRequest.setTriggeringEvent(event); | 386 frameRequest.setTriggeringEvent(event); |
370 if (hasRel(RelationNoReferrer)) | 387 if (hasRel(RelationNoReferrer)) |
371 frameRequest.setShouldSendReferrer(NeverSendReferrer); | 388 frameRequest.setShouldSendReferrer(NeverSendReferrer); |
372 frame->loader().load(frameRequest); | 389 frame->loader().load(frameRequest); |
373 } | 390 } |
374 } | 391 } |
375 | 392 |
393 void HTMLAnchorElement::valueChanged() | |
394 { | |
395 setSynchronizedLazyAttribute(pingAttr, m_ping->value()); | |
396 } | |
397 | |
376 bool isEnterKeyKeydownEvent(Event* event) | 398 bool isEnterKeyKeydownEvent(Event* event) |
377 { | 399 { |
378 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; | 400 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; |
379 } | 401 } |
380 | 402 |
381 bool isLinkClick(Event* event) | 403 bool isLinkClick(Event* event) |
382 { | 404 { |
383 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); | 405 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); |
384 } | 406 } |
385 | 407 |
(...skipping 15 matching lines...) Expand all Loading... | |
401 Vector<String> argv; | 423 Vector<String> argv; |
402 argv.append("a"); | 424 argv.append("a"); |
403 argv.append(fastGetAttribute(hrefAttr)); | 425 argv.append(fastGetAttribute(hrefAttr)); |
404 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); | 426 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); |
405 } | 427 } |
406 } | 428 } |
407 return HTMLElement::insertedInto(insertionPoint); | 429 return HTMLElement::insertedInto(insertionPoint); |
408 } | 430 } |
409 | 431 |
410 } // namespace blink | 432 } // namespace blink |
OLD | NEW |