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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 270 } |
271 | 271 |
272 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) | 272 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) |
273 { | 273 { |
274 if (forAttributeValue.isEmpty()) | 274 if (forAttributeValue.isEmpty()) |
275 return 0; | 275 return 0; |
276 | 276 |
277 if (!m_labelsByForAttribute) { | 277 if (!m_labelsByForAttribute) { |
278 // Populate the map on first access. | 278 // Populate the map on first access. |
279 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); | 279 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); |
280 for (Element* element = ElementTraversal::firstWithin(rootNode()); eleme
nt; element = ElementTraversal::next(element)) { | 280 for (Element* element = ElementTraversal::firstWithin(rootNode()); eleme
nt; element = ElementTraversal::next(*element)) { |
281 if (isHTMLLabelElement(element)) { | 281 if (isHTMLLabelElement(element)) { |
282 HTMLLabelElement* label = toHTMLLabelElement(element); | 282 HTMLLabelElement* label = toHTMLLabelElement(element); |
283 const AtomicString& forValue = label->fastGetAttribute(forAttr); | 283 const AtomicString& forValue = label->fastGetAttribute(forAttr); |
284 if (!forValue.isEmpty()) | 284 if (!forValue.isEmpty()) |
285 addLabel(forValue, label); | 285 addLabel(forValue, label); |
286 } | 286 } |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
290 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); | 290 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); |
(...skipping 13 matching lines...) Expand all Loading... |
304 m_selection = DOMSelection::create(this); | 304 m_selection = DOMSelection::create(this); |
305 return m_selection.get(); | 305 return m_selection.get(); |
306 } | 306 } |
307 | 307 |
308 Element* TreeScope::findAnchor(const String& name) | 308 Element* TreeScope::findAnchor(const String& name) |
309 { | 309 { |
310 if (name.isEmpty()) | 310 if (name.isEmpty()) |
311 return 0; | 311 return 0; |
312 if (Element* element = getElementById(name)) | 312 if (Element* element = getElementById(name)) |
313 return element; | 313 return element; |
314 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::next(element)) { | 314 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::next(*element)) { |
315 if (isHTMLAnchorElement(element)) { | 315 if (isHTMLAnchorElement(element)) { |
316 HTMLAnchorElement* anchor = toHTMLAnchorElement(element); | 316 HTMLAnchorElement* anchor = toHTMLAnchorElement(element); |
317 if (rootNode()->document().inQuirksMode()) { | 317 if (rootNode()->document().inQuirksMode()) { |
318 // Quirks mode, case insensitive comparison of names. | 318 // Quirks mode, case insensitive comparison of names. |
319 if (equalIgnoringCase(anchor->name(), name)) | 319 if (equalIgnoringCase(anchor->name(), name)) |
320 return anchor; | 320 return anchor; |
321 } else { | 321 } else { |
322 // Strict mode, names need to match exactly. | 322 // Strict mode, names need to match exactly. |
323 if (anchor->name() == name) | 323 if (anchor->name() == name) |
324 return anchor; | 324 return anchor; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 return false; | 479 return false; |
480 } | 480 } |
481 | 481 |
482 Element* TreeScope::getElementByAccessKey(const String& key) const | 482 Element* TreeScope::getElementByAccessKey(const String& key) const |
483 { | 483 { |
484 if (key.isEmpty()) | 484 if (key.isEmpty()) |
485 return 0; | 485 return 0; |
486 Element* result = 0; | 486 Element* result = 0; |
487 Node* root = rootNode(); | 487 Node* root = rootNode(); |
488 for (Element* element = ElementTraversal::firstWithin(root); element; elemen
t = ElementTraversal::next(element, root)) { | 488 for (Element* element = ElementTraversal::firstWithin(root); element; elemen
t = ElementTraversal::next(*element, root)) { |
489 if (equalIgnoringCase(element->fastGetAttribute(accesskeyAttr), key)) | 489 if (equalIgnoringCase(element->fastGetAttribute(accesskeyAttr), key)) |
490 result = element; | 490 result = element; |
491 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { | 491 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { |
492 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) | 492 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) |
493 result = shadowResult; | 493 result = shadowResult; |
494 } | 494 } |
495 } | 495 } |
496 return result; | 496 return result; |
497 } | 497 } |
498 | 498 |
499 } // namespace WebCore | 499 } // namespace WebCore |
OLD | NEW |