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

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

Issue 1377163002: Use DOMSettableTokenList for {HTMLAnchorElement, HTMLAreaElement}.ping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lazy3 Created 5 years, 2 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 if (!m_ping)
236 m_ping = DOMSettableTokenList::create((DOMSettableTokenListObserver* )this);
philipj_slow 2015/10/05 15:03:17 It looks like you could use ping()->setValue(value
hyunjunekim2 2015/10/05 15:30:25 When call |anchor.setAttribute('ping', 'p1');|, if
philipj_slow 2015/10/05 16:36:43 It will segfault if you use use m_ping->, but why
237 m_ping->setValue(value);
223 } else { 238 } else {
224 HTMLElement::parseAttribute(name, value); 239 HTMLElement::parseAttribute(name, value);
225 } 240 }
226 } 241 }
227 242
228 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents) 243 void HTMLAnchorElement::accessKeyAction(bool sendMouseEvents)
229 { 244 {
230 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents); 245 dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEv ents);
231 } 246 }
232 247
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return Element::tabIndex(); 328 return Element::tabIndex();
314 } 329 }
315 330
316 bool HTMLAnchorElement::isLiveLink() const 331 bool HTMLAnchorElement::isLiveLink() const
317 { 332 {
318 return isLink() && !hasEditableStyle(); 333 return isLink() && !hasEditableStyle();
319 } 334 }
320 335
321 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const 336 void HTMLAnchorElement::sendPings(const KURL& destinationURL) const
322 { 337 {
323 const AtomicString& pingValue = getAttribute(pingAttr); 338 if (!m_ping || m_ping->value().isNull() || !document().settings() || !docume nt().settings()->hyperlinkAuditingEnabled())
324 if (pingValue.isNull() || !document().settings() || !document().settings()-> hyperlinkAuditingEnabled())
325 return; 339 return;
326 340
327 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute); 341 UseCounter::count(document(), UseCounter::HTMLAnchorElementPingAttribute);
328 342
329 SpaceSplitString pingURLs(pingValue, SpaceSplitString::ShouldNotFoldCase); 343 const SpaceSplitString& pingURLs = m_ping->tokens();
330 for (unsigned i = 0; i < pingURLs.size(); i++) 344 for (unsigned i = 0; i < pingURLs.size(); i++)
331 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL); 345 PingLoader::sendLinkAuditPing(document().frame(), document().completeURL (pingURLs[i]), destinationURL);
332 } 346 }
333 347
348 DOMSettableTokenList* HTMLAnchorElement::ping() const
349 {
350 if (!m_ping)
351 m_ping = DOMSettableTokenList::create((DOMSettableTokenListObserver*)thi s);
philipj_slow 2015/10/05 15:03:17 Why is the case needed? If it is needed, it should
hyunjunekim2 2015/10/05 15:30:25 currently lazily it did make. If there is'n this c
philipj_slow 2015/10/05 16:36:43 It seems like just making ping() not const would b
352
353 return m_ping.get();
354 }
355
334 void HTMLAnchorElement::handleClick(Event* event) 356 void HTMLAnchorElement::handleClick(Event* event)
335 { 357 {
336 event->setDefaultHandled(); 358 event->setDefaultHandled();
337 359
338 LocalFrame* frame = document().frame(); 360 LocalFrame* frame = document().frame();
339 if (!frame) 361 if (!frame)
340 return; 362 return;
341 363
342 StringBuilder url; 364 StringBuilder url;
343 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr))); 365 url.append(stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr)));
(...skipping 22 matching lines...) Expand all
366 } else { 388 } else {
367 request.setRequestContext(WebURLRequest::RequestContextHyperlink); 389 request.setRequestContext(WebURLRequest::RequestContextHyperlink);
368 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 390 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
369 frameRequest.setTriggeringEvent(event); 391 frameRequest.setTriggeringEvent(event);
370 if (hasRel(RelationNoReferrer)) 392 if (hasRel(RelationNoReferrer))
371 frameRequest.setShouldSendReferrer(NeverSendReferrer); 393 frameRequest.setShouldSendReferrer(NeverSendReferrer);
372 frame->loader().load(frameRequest); 394 frame->loader().load(frameRequest);
373 } 395 }
374 } 396 }
375 397
398 void HTMLAnchorElement::valueChanged()
399 {
400 setSynchronizedLazyAttribute(pingAttr, m_ping->value());
401 }
402
376 bool isEnterKeyKeydownEvent(Event* event) 403 bool isEnterKeyKeydownEvent(Event* event)
377 { 404 {
378 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; 405 return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter";
379 } 406 }
380 407
381 bool isLinkClick(Event* event) 408 bool isLinkClick(Event* event)
382 { 409 {
383 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton); 410 return event->type() == EventTypeNames::click && (!event->isMouseEvent() || toMouseEvent(event)->button() != RightButton);
384 } 411 }
385 412
(...skipping 15 matching lines...) Expand all
401 Vector<String> argv; 428 Vector<String> argv;
402 argv.append("a"); 429 argv.append("a");
403 argv.append(fastGetAttribute(hrefAttr)); 430 argv.append(fastGetAttribute(hrefAttr));
404 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 431 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
405 } 432 }
406 } 433 }
407 return HTMLElement::insertedInto(insertionPoint); 434 return HTMLElement::insertedInto(insertionPoint);
408 } 435 }
409 436
410 } // namespace blink 437 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLAnchorElement.h ('k') | third_party/WebKit/Source/core/html/HTMLAnchorElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698