OLD | NEW |
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 291 } |
292 | 292 |
293 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) | 293 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) |
294 { | 294 { |
295 if (forAttributeValue.isEmpty()) | 295 if (forAttributeValue.isEmpty()) |
296 return 0; | 296 return 0; |
297 | 297 |
298 if (!m_labelsByForAttribute) { | 298 if (!m_labelsByForAttribute) { |
299 // Populate the map on first access. | 299 // Populate the map on first access. |
300 m_labelsByForAttribute = DocumentOrderedMap::create(); | 300 m_labelsByForAttribute = DocumentOrderedMap::create(); |
301 for (HTMLLabelElement& label : Traversal<HTMLLabelElement>::fromNext(roo
tNode())) { | 301 for (HTMLLabelElement& label : Traversal<HTMLLabelElement>::startsAfter(
rootNode())) { |
302 const AtomicString& forValue = label.fastGetAttribute(forAttr); | 302 const AtomicString& forValue = label.fastGetAttribute(forAttr); |
303 if (!forValue.isEmpty()) | 303 if (!forValue.isEmpty()) |
304 addLabel(forValue, &label); | 304 addLabel(forValue, &label); |
305 } | 305 } |
306 } | 306 } |
307 | 307 |
308 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue, this)); | 308 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue, this)); |
309 } | 309 } |
310 | 310 |
311 DOMSelection* TreeScope::getSelection() const | 311 DOMSelection* TreeScope::getSelection() const |
(...skipping 10 matching lines...) Expand all Loading... |
322 m_selection = DOMSelection::create(this); | 322 m_selection = DOMSelection::create(this); |
323 return m_selection.get(); | 323 return m_selection.get(); |
324 } | 324 } |
325 | 325 |
326 Element* TreeScope::findAnchor(const String& name) | 326 Element* TreeScope::findAnchor(const String& name) |
327 { | 327 { |
328 if (name.isEmpty()) | 328 if (name.isEmpty()) |
329 return 0; | 329 return 0; |
330 if (Element* element = getElementById(AtomicString(name))) | 330 if (Element* element = getElementById(AtomicString(name))) |
331 return element; | 331 return element; |
332 for (HTMLAnchorElement& anchor : Traversal<HTMLAnchorElement>::fromNext(root
Node())) { | 332 for (HTMLAnchorElement& anchor : Traversal<HTMLAnchorElement>::startsAfter(r
ootNode())) { |
333 if (rootNode().document().inQuirksMode()) { | 333 if (rootNode().document().inQuirksMode()) { |
334 // Quirks mode, case insensitive comparison of names. | 334 // Quirks mode, case insensitive comparison of names. |
335 if (equalIgnoringCase(anchor.name(), name)) | 335 if (equalIgnoringCase(anchor.name(), name)) |
336 return &anchor; | 336 return &anchor; |
337 } else { | 337 } else { |
338 // Strict mode, names need to match exactly. | 338 // Strict mode, names need to match exactly. |
339 if (anchor.name() == name) | 339 if (anchor.name() == name) |
340 return &anchor; | 340 return &anchor; |
341 } | 341 } |
342 } | 342 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 visitor->trace(m_parentTreeScope); | 553 visitor->trace(m_parentTreeScope); |
554 visitor->trace(m_idTargetObserverRegistry); | 554 visitor->trace(m_idTargetObserverRegistry); |
555 visitor->trace(m_selection); | 555 visitor->trace(m_selection); |
556 visitor->trace(m_elementsById); | 556 visitor->trace(m_elementsById); |
557 visitor->trace(m_imageMapsByName); | 557 visitor->trace(m_imageMapsByName); |
558 visitor->trace(m_labelsByForAttribute); | 558 visitor->trace(m_labelsByForAttribute); |
559 visitor->trace(m_scopedStyleResolver); | 559 visitor->trace(m_scopedStyleResolver); |
560 } | 560 } |
561 | 561 |
562 } // namespace blink | 562 } // namespace blink |
OLD | NEW |