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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 | 266 |
267 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) | 267 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) |
268 { | 268 { |
269 if (forAttributeValue.isEmpty()) | 269 if (forAttributeValue.isEmpty()) |
270 return 0; | 270 return 0; |
271 | 271 |
272 if (!m_labelsByForAttribute) { | 272 if (!m_labelsByForAttribute) { |
273 // Populate the map on first access. | 273 // Populate the map on first access. |
274 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); | 274 m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap); |
275 for (Element* element = ElementTraversal::firstWithin(rootNode()); eleme
nt; element = ElementTraversal::next(*element)) { | 275 for (HTMLLabelElement* label = Traversal<HTMLLabelElement>::firstWithin(
rootNode()); label; label = Traversal<HTMLLabelElement>::next(*label)) { |
276 if (element->hasTagName(labelTag)) { | 276 const AtomicString& forValue = label->fastGetAttribute(forAttr); |
277 HTMLLabelElement* label = toHTMLLabelElement(element); | 277 if (!forValue.isEmpty()) |
278 const AtomicString& forValue = label->fastGetAttribute(forAttr); | 278 addLabel(forValue, label); |
279 if (!forValue.isEmpty()) | |
280 addLabel(forValue, label); | |
281 } | |
282 } | 279 } |
283 } | 280 } |
284 | 281 |
285 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); | 282 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue.impl(), this)); |
286 } | 283 } |
287 | 284 |
288 DOMSelection* TreeScope::getSelection() const | 285 DOMSelection* TreeScope::getSelection() const |
289 { | 286 { |
290 if (!rootNode().document().frame()) | 287 if (!rootNode().document().frame()) |
291 return 0; | 288 return 0; |
292 | 289 |
293 if (m_selection) | 290 if (m_selection) |
294 return m_selection.get(); | 291 return m_selection.get(); |
295 | 292 |
296 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot | 293 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot |
297 // as a container. | 294 // as a container. |
298 // See https://bugs.webkit.org/show_bug.cgi?id=82697 | 295 // See https://bugs.webkit.org/show_bug.cgi?id=82697 |
299 m_selection = DOMSelection::create(this); | 296 m_selection = DOMSelection::create(this); |
300 return m_selection.get(); | 297 return m_selection.get(); |
301 } | 298 } |
302 | 299 |
303 Element* TreeScope::findAnchor(const String& name) | 300 Element* TreeScope::findAnchor(const String& name) |
304 { | 301 { |
305 if (name.isEmpty()) | 302 if (name.isEmpty()) |
306 return 0; | 303 return 0; |
307 if (Element* element = getElementById(AtomicString(name))) | 304 if (Element* element = getElementById(AtomicString(name))) |
308 return element; | 305 return element; |
309 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::next(*element)) { | 306 for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(r
ootNode()); anchor; anchor = Traversal<HTMLAnchorElement>::next(*anchor)) { |
310 if (element->hasTagName(aTag)) { | 307 if (rootNode().document().inQuirksMode()) { |
311 HTMLAnchorElement* anchor = toHTMLAnchorElement(element); | 308 // Quirks mode, case insensitive comparison of names. |
312 if (rootNode().document().inQuirksMode()) { | 309 if (equalIgnoringCase(anchor->name(), name)) |
313 // Quirks mode, case insensitive comparison of names. | 310 return anchor; |
314 if (equalIgnoringCase(anchor->name(), name)) | 311 } else { |
315 return anchor; | 312 // Strict mode, names need to match exactly. |
316 } else { | 313 if (anchor->name() == name) |
317 // Strict mode, names need to match exactly. | 314 return anchor; |
318 if (anchor->name() == name) | |
319 return anchor; | |
320 } | |
321 } | 315 } |
322 } | 316 } |
323 return 0; | 317 return 0; |
324 } | 318 } |
325 | 319 |
326 bool TreeScope::applyAuthorStyles() const | 320 bool TreeScope::applyAuthorStyles() const |
327 { | 321 { |
328 return !rootNode().isShadowRoot() || toShadowRoot(rootNode()).applyAuthorSty
les(); | 322 return !rootNode().isShadowRoot() || toShadowRoot(rootNode()).applyAuthorSty
les(); |
329 } | 323 } |
330 | 324 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::nextIncludingPseudo(*element)) { | 487 for (Element* element = ElementTraversal::firstWithin(rootNode()); element;
element = ElementTraversal::nextIncludingPseudo(*element)) { |
494 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root
->olderShadowRoot()) | 488 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root
->olderShadowRoot()) |
495 root->setNeedsStyleRecalcForViewportUnits(); | 489 root->setNeedsStyleRecalcForViewportUnits(); |
496 RenderStyle* style = element->renderStyle(); | 490 RenderStyle* style = element->renderStyle(); |
497 if (style && style->hasViewportUnits()) | 491 if (style && style->hasViewportUnits()) |
498 element->setNeedsStyleRecalc(LocalStyleChange); | 492 element->setNeedsStyleRecalc(LocalStyleChange); |
499 } | 493 } |
500 } | 494 } |
501 | 495 |
502 } // namespace WebCore | 496 } // namespace WebCore |
OLD | NEW |