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

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

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