OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "core/dom/CSSSelectorWatch.h" | 52 #include "core/dom/CSSSelectorWatch.h" |
53 #include "core/dom/ClientRect.h" | 53 #include "core/dom/ClientRect.h" |
54 #include "core/dom/ClientRectList.h" | 54 #include "core/dom/ClientRectList.h" |
55 #include "core/dom/DatasetDOMStringMap.h" | 55 #include "core/dom/DatasetDOMStringMap.h" |
56 #include "core/dom/ElementDataCache.h" | 56 #include "core/dom/ElementDataCache.h" |
57 #include "core/dom/ElementRareData.h" | 57 #include "core/dom/ElementRareData.h" |
58 #include "core/dom/ElementTraversal.h" | 58 #include "core/dom/ElementTraversal.h" |
59 #include "core/dom/ExceptionCode.h" | 59 #include "core/dom/ExceptionCode.h" |
60 #include "core/dom/FirstLetterPseudoElement.h" | 60 #include "core/dom/FirstLetterPseudoElement.h" |
61 #include "core/dom/Fullscreen.h" | 61 #include "core/dom/Fullscreen.h" |
| 62 #include "core/dom/IntersectionObserver.h" |
62 #include "core/dom/LayoutTreeBuilder.h" | 63 #include "core/dom/LayoutTreeBuilder.h" |
63 #include "core/dom/MutationObserverInterestGroup.h" | 64 #include "core/dom/MutationObserverInterestGroup.h" |
64 #include "core/dom/MutationRecord.h" | 65 #include "core/dom/MutationRecord.h" |
65 #include "core/dom/NamedNodeMap.h" | 66 #include "core/dom/NamedNodeMap.h" |
66 #include "core/dom/NodeComputedStyle.h" | 67 #include "core/dom/NodeComputedStyle.h" |
67 #include "core/dom/PresentationAttributeStyle.h" | 68 #include "core/dom/PresentationAttributeStyle.h" |
68 #include "core/dom/PseudoElement.h" | 69 #include "core/dom/PseudoElement.h" |
69 #include "core/dom/ScriptableDocumentParser.h" | 70 #include "core/dom/ScriptableDocumentParser.h" |
70 #include "core/dom/SelectorQuery.h" | 71 #include "core/dom/SelectorQuery.h" |
71 #include "core/dom/StyleChangeReason.h" | 72 #include "core/dom/StyleChangeReason.h" |
(...skipping 26 matching lines...) Expand all Loading... |
98 #include "core/html/HTMLElement.h" | 99 #include "core/html/HTMLElement.h" |
99 #include "core/html/HTMLFormControlsCollection.h" | 100 #include "core/html/HTMLFormControlsCollection.h" |
100 #include "core/html/HTMLFrameElementBase.h" | 101 #include "core/html/HTMLFrameElementBase.h" |
101 #include "core/html/HTMLFrameOwnerElement.h" | 102 #include "core/html/HTMLFrameOwnerElement.h" |
102 #include "core/html/HTMLOptionsCollection.h" | 103 #include "core/html/HTMLOptionsCollection.h" |
103 #include "core/html/HTMLPlugInElement.h" | 104 #include "core/html/HTMLPlugInElement.h" |
104 #include "core/html/HTMLTableRowsCollection.h" | 105 #include "core/html/HTMLTableRowsCollection.h" |
105 #include "core/html/HTMLTemplateElement.h" | 106 #include "core/html/HTMLTemplateElement.h" |
106 #include "core/html/parser/HTMLParserIdioms.h" | 107 #include "core/html/parser/HTMLParserIdioms.h" |
107 #include "core/inspector/InspectorInstrumentation.h" | 108 #include "core/inspector/InspectorInstrumentation.h" |
| 109 #include "core/layout/LayoutInline.h" |
| 110 #include "core/layout/LayoutPart.h" |
108 #include "core/layout/LayoutTextFragment.h" | 111 #include "core/layout/LayoutTextFragment.h" |
109 #include "core/layout/LayoutView.h" | 112 #include "core/layout/LayoutView.h" |
110 #include "core/loader/DocumentLoader.h" | 113 #include "core/loader/DocumentLoader.h" |
111 #include "core/page/ChromeClient.h" | 114 #include "core/page/ChromeClient.h" |
112 #include "core/page/FocusController.h" | 115 #include "core/page/FocusController.h" |
113 #include "core/page/Page.h" | 116 #include "core/page/Page.h" |
114 #include "core/page/PointerLockController.h" | 117 #include "core/page/PointerLockController.h" |
115 #include "core/page/SpatialNavigation.h" | 118 #include "core/page/SpatialNavigation.h" |
116 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" | 119 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" |
117 #include "core/page/scrolling/ScrollState.h" | 120 #include "core/page/scrolling/ScrollState.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT
ype type) | 166 Element::Element(const QualifiedName& tagName, Document* document, ConstructionT
ype type) |
164 : ContainerNode(document, type) | 167 : ContainerNode(document, type) |
165 , m_tagName(tagName) | 168 , m_tagName(tagName) |
166 { | 169 { |
167 } | 170 } |
168 | 171 |
169 Element::~Element() | 172 Element::~Element() |
170 { | 173 { |
171 ASSERT(needsAttach()); | 174 ASSERT(needsAttach()); |
172 | 175 |
| 176 disconnectIntersectionObservations(); |
| 177 |
173 #if !ENABLE(OILPAN) | 178 #if !ENABLE(OILPAN) |
174 if (hasRareData()) { | 179 if (hasRareData()) { |
175 elementRareData()->clearShadow(); | 180 elementRareData()->clearShadow(); |
176 detachAllAttrNodesFromElement(); | 181 detachAllAttrNodesFromElement(); |
177 } | 182 } |
178 | 183 |
179 if (isCustomElement()) | 184 if (isCustomElement()) |
180 CustomElement::wasDestroyed(this); | 185 CustomElement::wasDestroyed(this); |
181 | 186 |
182 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 187 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 ContainerNode::insertedInto(insertionPoint); | 1447 ContainerNode::insertedInto(insertionPoint); |
1443 | 1448 |
1444 if (containsFullScreenElement() && parentElement() && !parentElement()->cont
ainsFullScreenElement()) | 1449 if (containsFullScreenElement() && parentElement() && !parentElement()->cont
ainsFullScreenElement()) |
1445 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); | 1450 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); |
1446 | 1451 |
1447 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); | 1452 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); |
1448 | 1453 |
1449 if (!insertionPoint->isInTreeScope()) | 1454 if (!insertionPoint->isInTreeScope()) |
1450 return InsertionDone; | 1455 return InsertionDone; |
1451 | 1456 |
1452 if (hasRareData()) | 1457 if (hasRareData()) { |
1453 elementRareData()->clearClassListValueForQuirksMode(); | 1458 ElementRareData* rareData = elementRareData(); |
| 1459 rareData->clearClassListValueForQuirksMode(); |
| 1460 if (rareData->hasIntersectionObservation()) { |
| 1461 for (auto& observation: rareData->intersectionObservations()) |
| 1462 observation->setActive(observation->observer()->isDescendantOfRo
ot(this)); |
| 1463 } |
| 1464 } |
1454 | 1465 |
1455 if (isUpgradedCustomElement() && inDocument()) | 1466 if (isUpgradedCustomElement() && inDocument()) |
1456 CustomElement::didAttach(this, document()); | 1467 CustomElement::didAttach(this, document()); |
1457 | 1468 |
1458 TreeScope& scope = insertionPoint->treeScope(); | 1469 TreeScope& scope = insertionPoint->treeScope(); |
1459 if (scope != treeScope()) | 1470 if (scope != treeScope()) |
1460 return InsertionDone; | 1471 return InsertionDone; |
1461 | 1472 |
1462 const AtomicString& idValue = getIdAttribute(); | 1473 const AtomicString& idValue = getIdAttribute(); |
1463 if (!idValue.isNull()) | 1474 if (!idValue.isNull()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 | 1532 |
1522 clearElementFlag(IsInCanvasSubtree); | 1533 clearElementFlag(IsInCanvasSubtree); |
1523 | 1534 |
1524 if (hasRareData()) { | 1535 if (hasRareData()) { |
1525 ElementRareData* data = elementRareData(); | 1536 ElementRareData* data = elementRareData(); |
1526 | 1537 |
1527 data->clearRestyleFlags(); | 1538 data->clearRestyleFlags(); |
1528 | 1539 |
1529 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1540 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
1530 elementAnimations->cssAnimations().cancel(); | 1541 elementAnimations->cssAnimations().cancel(); |
| 1542 |
| 1543 data->deactivateAllIntersectionObservations(); |
1531 } | 1544 } |
1532 } | 1545 } |
1533 | 1546 |
1534 void Element::attach(const AttachContext& context) | 1547 void Element::attach(const AttachContext& context) |
1535 { | 1548 { |
1536 ASSERT(document().inStyleRecalc()); | 1549 ASSERT(document().inStyleRecalc()); |
1537 | 1550 |
1538 // We've already been through detach when doing an attach, but we might | 1551 // We've already been through detach when doing an attach, but we might |
1539 // need to clear any state that's been added since then. | 1552 // need to clear any state that's been added since then. |
1540 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { | 1553 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3562 return false; | 3575 return false; |
3563 if (isHTMLElement() && toHTMLElement(this)->hasDirectionAuto()) | 3576 if (isHTMLElement() && toHTMLElement(this)->hasDirectionAuto()) |
3564 return false; | 3577 return false; |
3565 if (hasAnimations()) | 3578 if (hasAnimations()) |
3566 return false; | 3579 return false; |
3567 if (Fullscreen::isActiveFullScreenElement(*this)) | 3580 if (Fullscreen::isActiveFullScreenElement(*this)) |
3568 return false; | 3581 return false; |
3569 return true; | 3582 return true; |
3570 } | 3583 } |
3571 | 3584 |
| 3585 WeakPtr<Element> Element::createWeakPtr() |
| 3586 { |
| 3587 return ensureElementRareData().createWeakPtr(this); |
| 3588 } |
| 3589 |
| 3590 void Element::addIntersectionObservation(IntersectionObservation& observation) |
| 3591 { |
| 3592 ensureElementRareData().intersectionObservations().add(&observation); |
| 3593 } |
| 3594 |
| 3595 void Element::removeIntersectionObservation(IntersectionObservation& observation
) |
| 3596 { |
| 3597 if (!hasRareData() || !elementRareData()->hasIntersectionObservation()) |
| 3598 return; |
| 3599 elementRareData()->intersectionObservations().remove(&observation); |
| 3600 } |
| 3601 |
| 3602 void Element::disconnectIntersectionObservations() |
| 3603 { |
| 3604 if (!hasRareData() || !elementRareData()->hasIntersectionObservation()) |
| 3605 return; |
| 3606 HeapVector<Member<IntersectionObservation>> toRemove; |
| 3607 for (auto& observation: elementRareData()->intersectionObservations()) |
| 3608 toRemove.append(observation); |
| 3609 for (auto& observation: toRemove) { |
| 3610 if (observation->observer()->root() == this) |
| 3611 observation->observer()->disconnect(); |
| 3612 else |
| 3613 observation->disconnect(); |
| 3614 } |
| 3615 } |
| 3616 |
| 3617 bool Element::computeIntersection(Element* root, LayoutRect& targetRect, LayoutR
ect& rootRect, LayoutRect& intersectionRect) |
| 3618 { |
| 3619 // TODO: support zero-size targetRect |
| 3620 intersectionRect = targetRect = toLayoutBoxModelObject(layoutObject())->visu
alOverflowRect(); |
| 3621 |
| 3622 if (root) { |
| 3623 ASSERT(root->isInTreeScope()); |
| 3624 ASSERT(isDescendantOf(root)); |
| 3625 // TODO: Support SVG |
| 3626 if (!root->layoutObject()->isBoxModelObject()) |
| 3627 return false; |
| 3628 rootRect = toLayoutBoxModelObject(root->layoutObject())->visualOverflowR
ect(); |
| 3629 layoutObject()->mapRectToPaintInvalidationBacking(toLayoutBoxModelObject
(root->layoutObject()), intersectionRect, nullptr); |
| 3630 |
| 3631 // Convert rects to frame coordinates. |
| 3632 targetRect.moveBy(LayoutPoint(layoutObject()->localToAbsolute())); |
| 3633 LayoutPoint rootOffset = LayoutPoint(root->layoutObject()->localToAbsolu
te()); |
| 3634 intersectionRect.moveBy(rootOffset); |
| 3635 rootRect.moveBy(rootOffset); |
| 3636 } else { |
| 3637 Element* target = this; |
| 3638 LocalFrame* frame = document().frame(); |
| 3639 while (target) { |
| 3640 targetRect.moveBy(LayoutPoint(target->layoutObject()->localToAbsolut
e())); |
| 3641 Document& document = target->document(); |
| 3642 LayoutView* layoutView = document.layoutView(); |
| 3643 ASSERT(layoutView); |
| 3644 // TODO: mapRectToPaintInvalidationBacking probably doesn't do exact
ly the clipping we want, |
| 3645 // and it doesn't support rootMargin at all. |
| 3646 target->layoutObject()->mapRectToPaintInvalidationBacking(layoutView
, intersectionRect, nullptr); |
| 3647 frame = document.frame(); |
| 3648 ASSERT(frame); |
| 3649 target = toElement(frame->ownerLayoutObject()->node()); |
| 3650 } |
| 3651 rootRect = LayoutRect(frame->view()->scrollableArea()->visibleContentRec
t()); |
| 3652 intersectionRect = intersection(intersectionRect, rootRect); |
| 3653 } |
| 3654 |
| 3655 return true; |
| 3656 } |
| 3657 |
3572 DEFINE_TRACE(Element) | 3658 DEFINE_TRACE(Element) |
3573 { | 3659 { |
3574 #if ENABLE(OILPAN) | 3660 #if ENABLE(OILPAN) |
3575 if (hasRareData()) | 3661 if (hasRareData()) |
3576 visitor->trace(elementRareData()); | 3662 visitor->trace(elementRareData()); |
3577 visitor->trace(m_elementData); | 3663 visitor->trace(m_elementData); |
3578 #endif | 3664 #endif |
3579 ContainerNode::trace(visitor); | 3665 ContainerNode::trace(visitor); |
3580 } | 3666 } |
3581 | 3667 |
3582 } // namespace blink | 3668 } // namespace blink |
OLD | NEW |