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

Side by Side Diff: Source/core/dom/TreeScope.cpp

Issue 18259016: Introduce isHTMLLabelElement and toHTMLLabelElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Took tkent's comment into consideration Created 7 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
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/html/HTMLLabelElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV alue) 261 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV alue)
262 { 262 {
263 if (forAttributeValue.isEmpty()) 263 if (forAttributeValue.isEmpty())
264 return 0; 264 return 0;
265 265
266 if (!m_labelsByForAttribute) { 266 if (!m_labelsByForAttribute) {
267 // Populate the map on first access. 267 // Populate the map on first access.
268 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); 268 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
269 for (Element* element = ElementTraversal::firstWithin(rootNode()); eleme nt; element = ElementTraversal::next(element)) { 269 for (Element* element = ElementTraversal::firstWithin(rootNode()); eleme nt; element = ElementTraversal::next(element)) {
270 if (element->hasTagName(labelTag)) { 270 if (isHTMLLabelElement(element)) {
271 HTMLLabelElement* label = static_cast<HTMLLabelElement*>(element ); 271 HTMLLabelElement* label = toHTMLLabelElement(element);
272 const AtomicString& forValue = label->fastGetAttribute(forAttr); 272 const AtomicString& forValue = label->fastGetAttribute(forAttr);
273 if (!forValue.isEmpty()) 273 if (!forValue.isEmpty())
274 addLabel(forValue, label); 274 addLabel(forValue, label);
275 } 275 }
276 } 276 }
277 } 277 }
278 278
279 return static_cast<HTMLLabelElement*>(m_labelsByForAttribute->getElementByLa belForAttribute(forAttributeValue.impl(), this)); 279 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib ute(forAttributeValue.impl(), this));
280 } 280 }
281 281
282 DOMSelection* TreeScope::getSelection() const 282 DOMSelection* TreeScope::getSelection() const
283 { 283 {
284 if (!rootNode()->document()->frame()) 284 if (!rootNode()->document()->frame())
285 return 0; 285 return 0;
286 286
287 if (m_selection) 287 if (m_selection)
288 return m_selection.get(); 288 return m_selection.get();
289 289
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 { 488 {
489 ASSERT(scope); 489 ASSERT(scope);
490 for (; scope; scope = scope->parentTreeScope()) { 490 for (; scope; scope = scope->parentTreeScope()) {
491 if (scope == this) 491 if (scope == this)
492 return true; 492 return true;
493 } 493 }
494 return false; 494 return false;
495 } 495 }
496 496
497 } // namespace WebCore 497 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/html/HTMLLabelElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698