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