Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: Source/core/html/HTMLAnchorElement.cpp

Issue 1235603003: Use DOMSettableTokenList for {HTMLAnchorElement, HTMLAreaElement}.ping. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 40
41 namespace blink { 41 namespace blink {
42 42
43 using namespace HTMLNames; 43 using namespace HTMLNames;
44 44
45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) 45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument)
46 : HTMLElement(tagName, document) 46 : HTMLElement(tagName, document)
47 , m_linkRelations(0) 47 , m_linkRelations(0)
48 , m_cachedVisitedLinkHash(0) 48 , m_cachedVisitedLinkHash(0)
49 , m_wasFocusedByMouse(false) 49 , m_wasFocusedByMouse(false)
50 , m_ping(DOMSettableTokenList::create(this))
50 { 51 {
51 } 52 }
52 53
54 DEFINE_TRACE(HTMLAnchorElement)
55 {
56 visitor->trace(m_ping);
57 HTMLElement::trace(visitor);
58 DOMSettableTokenListObserver::trace(visitor);
59 }
60
53 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument) 61 PassRefPtrWillBeRawPtr<HTMLAnchorElement> HTMLAnchorElement::create(Document& do cument)
54 { 62 {
55 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document)); 63 return adoptRefWillBeNoop(new HTMLAnchorElement(aTag, document));
56 } 64 }
57 65
58 HTMLAnchorElement::~HTMLAnchorElement() 66 HTMLAnchorElement::~HTMLAnchorElement()
59 { 67 {
68 m_ping->setObserver(nullptr);
tkent 2015/07/14 00:29:44 This doesn't work on Oilpan because m_ping can be
60 } 69 }
61 70
62 bool HTMLAnchorElement::supportsFocus() const 71 bool HTMLAnchorElement::supportsFocus() const
63 { 72 {
64 if (hasEditableStyle()) 73 if (hasEditableStyle())
65 return HTMLElement::supportsFocus(); 74 return HTMLElement::supportsFocus();
66 // If not a link we should still be able to focus the element if it has tabI ndex. 75 // If not a link we should still be able to focus the element if it has tabI ndex.
67 return isLink() || HTMLElement::supportsFocus(); 76 return isLink() || HTMLElement::supportsFocus();
68 } 77 }
69 78
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (document().isDNSPrefetchEnabled()) { 219 if (document().isDNSPrefetchEnabled()) {
211 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http s") || parsedURL.startsWith("//")) 220 if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "http s") || parsedURL.startsWith("//"))
212 prefetchDNS(document().completeURL(parsedURL).host()); 221 prefetchDNS(document().completeURL(parsedURL).host());
213 } 222 }
214 } 223 }
215 invalidateCachedVisitedLinkHash(); 224 invalidateCachedVisitedLinkHash();
216 } else if (name == nameAttr || name == titleAttr) { 225 } else if (name == nameAttr || name == titleAttr) {
217 // Do nothing. 226 // Do nothing.
218 } else if (name == relAttr) { 227 } else if (name == relAttr) {
219 setRel(value); 228 setRel(value);
229 } else if (name == pingAttr) {
230 m_ping->setValue(value);
220 } else { 231 } else {
221 HTMLElement::parseAttribute(name, value); 232 HTMLElement::parseAttribute(name, value);
222 } 233 }
223 } 234 }
224 235
225 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) 236 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents)
226 { 237 {
227 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents); 238 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents);
228 } 239 }
229 240
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 return Element::tabIndex(); 321 return Element::tabIndex();
311 } 322 }
312 323
313 bool HTMLAnchorElement::isLiveLink() const 324 bool HTMLAnchorElement::isLiveLink() const
314 { 325 {
315 return isLink() && !hasEditableStyle(); 326 return isLink() && !hasEditableStyle();
316 } 327 }
317 328
318 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const 329 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const
319 { 330 {
320 const AtomicString& pingValue = getAttribute(pingAttr); 331 if (m_ping->value().isNull() || !document().settings() || !document().settin gs()->hyperlinkAuditingEnabled())
321 if (pingValue.isNull() || !document().settings() || !document().settings()-> hyperlinkAuditingEnabled())
322 return; 332 return;
323 333
324 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); 334 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute);
325 335
326 SpaceSplitString pingURLs(pingValue, SpaceSplitString::ShouldNotFoldCase); 336 SpaceSplitString pingURLs = m_ping->tokens();
tkent 2015/07/14 00:29:44 should be |const SpaceSplitString&|.
327 for (unsigned i = 0; i < pingURLs.size(); i++) 337 for (unsigned i = 0; i < pingURLs.size(); i++)
328 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL); 338 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL);
329 } 339 }
330 340
341 DOMSettableTokenList* HTMLAnchorElement::ping() const
342 {
343 return m_ping.get();
344 }
345
331 void HTMLAnchorElement::handleClick(Event* event) 346 void HTMLAnchorElement::handleClick(Event* event)
332 { 347 {
333 event->setDefaultHandled(); 348 event->setDefaultHandled();
334 349
335 LocalFrame* frame = document().frame(); 350 LocalFrame* frame = document().frame();
336 if (!frame) 351 if (!frame)
337 return; 352 return;
338 353
339 StringBuilder url; 354 StringBuilder url;
340 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); 355 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr)));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (activityLogger) { 406 if (activityLogger) {
392 Vector<String> argv; 407 Vector<String> argv;
393 argv.append("a"); 408 argv.append("a");
394 argv.append(fastGetAttribute(hrefAttr)); 409 argv.append(fastGetAttribute(hrefAttr));
395 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 410 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
396 } 411 }
397 } 412 }
398 return HTMLElement::insertedInto(insertionPoint); 413 return HTMLElement::insertedInto(insertionPoint);
399 } 414 }
400 415
416 void HTMLAnchorElement::valueChanged()
417 {
418 setSynchronizedLazyAttribute(pingAttr, m_ping->value());
419 }
420
401 } // namespace blink 421 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698