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 26 matching lines...) Expand all Loading... |
37 #include "core/dom/StyleChangeReason.h" | 37 #include "core/dom/StyleChangeReason.h" |
38 #include "core/dom/TreeScopeAdopter.h" | 38 #include "core/dom/TreeScopeAdopter.h" |
39 #include "core/dom/shadow/ElementShadow.h" | 39 #include "core/dom/shadow/ElementShadow.h" |
40 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
41 #include "core/editing/DOMSelection.h" | 41 #include "core/editing/DOMSelection.h" |
42 #include "core/events/EventPath.h" | 42 #include "core/events/EventPath.h" |
43 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
44 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
45 #include "core/html/HTMLAnchorElement.h" | 45 #include "core/html/HTMLAnchorElement.h" |
46 #include "core/html/HTMLFrameOwnerElement.h" | 46 #include "core/html/HTMLFrameOwnerElement.h" |
47 #include "core/html/HTMLLabelElement.h" | |
48 #include "core/html/HTMLMapElement.h" | 47 #include "core/html/HTMLMapElement.h" |
49 #include "core/layout/HitTestResult.h" | 48 #include "core/layout/HitTestResult.h" |
50 #include "core/layout/api/LayoutViewItem.h" | 49 #include "core/layout/api/LayoutViewItem.h" |
51 #include "core/page/FocusController.h" | 50 #include "core/page/FocusController.h" |
52 #include "core/page/Page.h" | 51 #include "core/page/Page.h" |
53 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
54 | 53 |
55 namespace blink { | 54 namespace blink { |
56 | 55 |
57 using namespace HTMLNames; | 56 using namespace HTMLNames; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 if (!pointWithScrollAndZoomIfPossible(document, hitPoint)) | 295 if (!pointWithScrollAndZoomIfPossible(document, hitPoint)) |
297 return HeapVector<Member<Element>>(); | 296 return HeapVector<Member<Element>>(); |
298 | 297 |
299 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::ListBased | HitTestRequest::PenetratingList); | 298 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::ListBased | HitTestRequest::PenetratingList); |
300 HitTestResult result(request, hitPoint); | 299 HitTestResult result(request, hitPoint); |
301 document.layoutViewItem().hitTest(result); | 300 document.layoutViewItem().hitTest(result); |
302 | 301 |
303 return elementsFromHitTestResult(result); | 302 return elementsFromHitTestResult(result); |
304 } | 303 } |
305 | 304 |
306 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement
* element) | |
307 { | |
308 DCHECK(m_labelsByForAttribute); | |
309 m_labelsByForAttribute->add(forAttributeValue, element); | |
310 } | |
311 | |
312 void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElem
ent* element) | |
313 { | |
314 DCHECK(m_labelsByForAttribute); | |
315 m_labelsByForAttribute->remove(forAttributeValue, element); | |
316 } | |
317 | |
318 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
alue) | |
319 { | |
320 if (forAttributeValue.isEmpty()) | |
321 return nullptr; | |
322 | |
323 if (!m_labelsByForAttribute) { | |
324 // Populate the map on first access. | |
325 m_labelsByForAttribute = DocumentOrderedMap::create(); | |
326 for (HTMLLabelElement& label : Traversal<HTMLLabelElement>::startsAfter(
rootNode())) { | |
327 const AtomicString& forValue = label.fastGetAttribute(forAttr); | |
328 if (!forValue.isEmpty()) | |
329 addLabel(forValue, &label); | |
330 } | |
331 } | |
332 | |
333 return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttrib
ute(forAttributeValue, this)); | |
334 } | |
335 | |
336 DOMSelection* TreeScope::getSelection() const | 305 DOMSelection* TreeScope::getSelection() const |
337 { | 306 { |
338 if (!rootNode().document().frame()) | 307 if (!rootNode().document().frame()) |
339 return nullptr; | 308 return nullptr; |
340 | 309 |
341 if (m_selection) | 310 if (m_selection) |
342 return m_selection.get(); | 311 return m_selection.get(); |
343 | 312 |
344 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot | 313 // FIXME: The correct selection in Shadow DOM requires that Position can hav
e a ShadowRoot |
345 // as a container. | 314 // as a container. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 496 |
528 DEFINE_TRACE(TreeScope) | 497 DEFINE_TRACE(TreeScope) |
529 { | 498 { |
530 visitor->trace(m_rootNode); | 499 visitor->trace(m_rootNode); |
531 visitor->trace(m_document); | 500 visitor->trace(m_document); |
532 visitor->trace(m_parentTreeScope); | 501 visitor->trace(m_parentTreeScope); |
533 visitor->trace(m_idTargetObserverRegistry); | 502 visitor->trace(m_idTargetObserverRegistry); |
534 visitor->trace(m_selection); | 503 visitor->trace(m_selection); |
535 visitor->trace(m_elementsById); | 504 visitor->trace(m_elementsById); |
536 visitor->trace(m_imageMapsByName); | 505 visitor->trace(m_imageMapsByName); |
537 visitor->trace(m_labelsByForAttribute); | |
538 visitor->trace(m_scopedStyleResolver); | 506 visitor->trace(m_scopedStyleResolver); |
539 visitor->trace(m_radioButtonGroupScope); | 507 visitor->trace(m_radioButtonGroupScope); |
540 } | 508 } |
541 | 509 |
542 } // namespace blink | 510 } // namespace blink |
OLD | NEW |