Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Added dispose() methods for expicit cleanup Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/css/resolver/StyleResolver.h" 48 #include "core/css/resolver/StyleResolver.h"
49 #include "core/css/resolver/StyleResolverParentScope.h" 49 #include "core/css/resolver/StyleResolverParentScope.h"
50 #include "core/css/resolver/StyleResolverStats.h" 50 #include "core/css/resolver/StyleResolverStats.h"
51 #include "core/dom/AXObjectCache.h" 51 #include "core/dom/AXObjectCache.h"
52 #include "core/dom/Attr.h" 52 #include "core/dom/Attr.h"
53 #include "core/dom/CSSSelectorWatch.h" 53 #include "core/dom/CSSSelectorWatch.h"
54 #include "core/dom/ClientRect.h" 54 #include "core/dom/ClientRect.h"
55 #include "core/dom/ClientRectList.h" 55 #include "core/dom/ClientRectList.h"
56 #include "core/dom/DatasetDOMStringMap.h" 56 #include "core/dom/DatasetDOMStringMap.h"
57 #include "core/dom/ElementDataCache.h" 57 #include "core/dom/ElementDataCache.h"
58 #include "core/dom/ElementIntersectionObserverData.h"
58 #include "core/dom/ElementRareData.h" 59 #include "core/dom/ElementRareData.h"
59 #include "core/dom/ElementTraversal.h" 60 #include "core/dom/ElementTraversal.h"
60 #include "core/dom/ExceptionCode.h" 61 #include "core/dom/ExceptionCode.h"
61 #include "core/dom/FirstLetterPseudoElement.h" 62 #include "core/dom/FirstLetterPseudoElement.h"
62 #include "core/dom/Fullscreen.h" 63 #include "core/dom/Fullscreen.h"
63 #include "core/dom/LayoutTreeBuilder.h" 64 #include "core/dom/LayoutTreeBuilder.h"
64 #include "core/dom/MutationObserverInterestGroup.h" 65 #include "core/dom/MutationObserverInterestGroup.h"
65 #include "core/dom/MutationRecord.h" 66 #include "core/dom/MutationRecord.h"
66 #include "core/dom/NamedNodeMap.h" 67 #include "core/dom/NamedNodeMap.h"
67 #include "core/dom/NodeComputedStyle.h" 68 #include "core/dom/NodeComputedStyle.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "core/html/HTMLElement.h" 100 #include "core/html/HTMLElement.h"
100 #include "core/html/HTMLFormControlsCollection.h" 101 #include "core/html/HTMLFormControlsCollection.h"
101 #include "core/html/HTMLFrameElementBase.h" 102 #include "core/html/HTMLFrameElementBase.h"
102 #include "core/html/HTMLFrameOwnerElement.h" 103 #include "core/html/HTMLFrameOwnerElement.h"
103 #include "core/html/HTMLOptionsCollection.h" 104 #include "core/html/HTMLOptionsCollection.h"
104 #include "core/html/HTMLPlugInElement.h" 105 #include "core/html/HTMLPlugInElement.h"
105 #include "core/html/HTMLTableRowsCollection.h" 106 #include "core/html/HTMLTableRowsCollection.h"
106 #include "core/html/HTMLTemplateElement.h" 107 #include "core/html/HTMLTemplateElement.h"
107 #include "core/html/parser/HTMLParserIdioms.h" 108 #include "core/html/parser/HTMLParserIdioms.h"
108 #include "core/inspector/InspectorInstrumentation.h" 109 #include "core/inspector/InspectorInstrumentation.h"
110 #include "core/layout/LayoutInline.h"
111 #include "core/layout/LayoutPart.h"
109 #include "core/layout/LayoutTextFragment.h" 112 #include "core/layout/LayoutTextFragment.h"
110 #include "core/layout/LayoutView.h" 113 #include "core/layout/LayoutView.h"
111 #include "core/loader/DocumentLoader.h" 114 #include "core/loader/DocumentLoader.h"
112 #include "core/page/ChromeClient.h" 115 #include "core/page/ChromeClient.h"
113 #include "core/page/FocusController.h" 116 #include "core/page/FocusController.h"
114 #include "core/page/Page.h" 117 #include "core/page/Page.h"
115 #include "core/page/PointerLockController.h" 118 #include "core/page/PointerLockController.h"
116 #include "core/page/SpatialNavigation.h" 119 #include "core/page/SpatialNavigation.h"
117 #include "core/page/scrolling/ScrollCustomizationCallbacks.h" 120 #include "core/page/scrolling/ScrollCustomizationCallbacks.h"
118 #include "core/page/scrolling/ScrollState.h" 121 #include "core/page/scrolling/ScrollState.h"
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 ContainerNode::insertedInto(insertionPoint); 1464 ContainerNode::insertedInto(insertionPoint);
1462 1465
1463 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement()) 1466 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement())
1464 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 1467 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
1465 1468
1466 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1469 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements());
1467 1470
1468 if (!insertionPoint->isInTreeScope()) 1471 if (!insertionPoint->isInTreeScope())
1469 return InsertionDone; 1472 return InsertionDone;
1470 1473
1471 if (hasRareData()) 1474 if (hasRareData()) {
1472 elementRareData()->clearClassListValueForQuirksMode(); 1475 ElementRareData* rareData = elementRareData();
1476 rareData->clearClassListValueForQuirksMode();
1477 if (rareData->hasIntersectionObserverData())
1478 rareData->intersectionObserverData().activateValidIntersectionObserv ers(*this);
1479 }
1473 1480
1474 if (isUpgradedCustomElement() && inDocument()) 1481 if (isUpgradedCustomElement() && inDocument())
1475 CustomElement::didAttach(this, document()); 1482 CustomElement::didAttach(this, document());
1476 1483
1477 TreeScope& scope = insertionPoint->treeScope(); 1484 TreeScope& scope = insertionPoint->treeScope();
1478 if (scope != treeScope()) 1485 if (scope != treeScope())
1479 return InsertionDone; 1486 return InsertionDone;
1480 1487
1481 const AtomicString& idValue = getIdAttribute(); 1488 const AtomicString& idValue = getIdAttribute();
1482 if (!idValue.isNull()) 1489 if (!idValue.isNull())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 1547
1541 clearElementFlag(IsInCanvasSubtree); 1548 clearElementFlag(IsInCanvasSubtree);
1542 1549
1543 if (hasRareData()) { 1550 if (hasRareData()) {
1544 ElementRareData* data = elementRareData(); 1551 ElementRareData* data = elementRareData();
1545 1552
1546 data->clearRestyleFlags(); 1553 data->clearRestyleFlags();
1547 1554
1548 if (ElementAnimations* elementAnimations = data->elementAnimations()) 1555 if (ElementAnimations* elementAnimations = data->elementAnimations())
1549 elementAnimations->cssAnimations().cancel(); 1556 elementAnimations->cssAnimations().cancel();
1557
1558 if (data->hasIntersectionObserverData())
1559 data->intersectionObserverData().deactivateAllIntersectionObservers( *this);
1550 } 1560 }
1551 } 1561 }
1552 1562
1553 void Element::attach(const AttachContext& context) 1563 void Element::attach(const AttachContext& context)
1554 { 1564 {
1555 ASSERT(document().inStyleRecalc()); 1565 ASSERT(document().inStyleRecalc());
1556 1566
1557 // We've already been through detach when doing an attach, but we might 1567 // We've already been through detach when doing an attach, but we might
1558 // need to clear any state that's been added since then. 1568 // need to clear any state that's been added since then.
1559 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { 1569 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) {
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 if (!exceptionState.hadException()) 2602 if (!exceptionState.hadException())
2593 return newChild; 2603 return newChild;
2594 } 2604 }
2595 return nullptr; 2605 return nullptr;
2596 } 2606 }
2597 2607
2598 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ; 2608 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ;
2599 return nullptr; 2609 return nullptr;
2600 } 2610 }
2601 2611
2612 bool Element::hasIntersectionObserverData() const
2613 {
2614 return elementRareData() && elementRareData()->hasIntersectionObserverData() ;
2615 }
2616
2617 ElementIntersectionObserverData& Element::intersectionObserverData()
esprehn 2015/12/17 01:40:28 ensureIntersectionObserverData()
szager1 2015/12/17 20:27:25 Done.
2618 {
2619 return ensureElementRareData().intersectionObserverData();
esprehn 2015/12/17 01:40:28 ensure* for the method on ElementRareData too
szager1 2015/12/17 20:27:25 Done.
2620 }
2621
2602 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() 2622 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml()
2603 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState) 2623 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState)
2604 { 2624 {
2605 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) { 2625 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) {
2606 Element* parent = element->parentElement(); 2626 Element* parent = element->parentElement();
2607 if (!parent) { 2627 if (!parent) {
2608 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent."); 2628 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent.");
2609 return nullptr; 2629 return nullptr;
2610 } 2630 }
2611 return parent; 2631 return parent;
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 { 3659 {
3640 #if ENABLE(OILPAN) 3660 #if ENABLE(OILPAN)
3641 if (hasRareData()) 3661 if (hasRareData())
3642 visitor->trace(elementRareData()); 3662 visitor->trace(elementRareData());
3643 visitor->trace(m_elementData); 3663 visitor->trace(m_elementData);
3644 #endif 3664 #endif
3645 ContainerNode::trace(visitor); 3665 ContainerNode::trace(visitor);
3646 } 3666 }
3647 3667
3648 } // namespace blink 3668 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698