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

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: haraken nits Created 4 years, 11 months 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/css/resolver/StyleResolver.h" 47 #include "core/css/resolver/StyleResolver.h"
48 #include "core/css/resolver/StyleResolverParentScope.h" 48 #include "core/css/resolver/StyleResolverParentScope.h"
49 #include "core/css/resolver/StyleResolverStats.h" 49 #include "core/css/resolver/StyleResolverStats.h"
50 #include "core/dom/AXObjectCache.h" 50 #include "core/dom/AXObjectCache.h"
51 #include "core/dom/Attr.h" 51 #include "core/dom/Attr.h"
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/ElementIntersectionObserverData.h"
57 #include "core/dom/ElementRareData.h" 58 #include "core/dom/ElementRareData.h"
58 #include "core/dom/ElementTraversal.h" 59 #include "core/dom/ElementTraversal.h"
59 #include "core/dom/ExceptionCode.h" 60 #include "core/dom/ExceptionCode.h"
60 #include "core/dom/FirstLetterPseudoElement.h" 61 #include "core/dom/FirstLetterPseudoElement.h"
61 #include "core/dom/Fullscreen.h" 62 #include "core/dom/Fullscreen.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"
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 ContainerNode::insertedInto(insertionPoint); 1447 ContainerNode::insertedInto(insertionPoint);
1447 1448
1448 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement()) 1449 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement())
1449 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 1450 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
1450 1451
1451 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1452 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements());
1452 1453
1453 if (!insertionPoint->isInTreeScope()) 1454 if (!insertionPoint->isInTreeScope())
1454 return InsertionDone; 1455 return InsertionDone;
1455 1456
1456 if (hasRareData()) 1457 if (hasRareData()) {
1457 elementRareData()->clearClassListValueForQuirksMode(); 1458 ElementRareData* rareData = elementRareData();
1459 rareData->clearClassListValueForQuirksMode();
1460 if (rareData->intersectionObserverData())
1461 rareData->intersectionObserverData()->activateValidIntersectionObser vers(*this);
1462 }
1458 1463
1459 if (isUpgradedCustomElement() && inDocument()) 1464 if (isUpgradedCustomElement() && inDocument())
1460 CustomElement::didAttach(this, document()); 1465 CustomElement::didAttach(this, document());
1461 1466
1462 TreeScope& scope = insertionPoint->treeScope(); 1467 TreeScope& scope = insertionPoint->treeScope();
1463 if (scope != treeScope()) 1468 if (scope != treeScope())
1464 return InsertionDone; 1469 return InsertionDone;
1465 1470
1466 const AtomicString& idValue = getIdAttribute(); 1471 const AtomicString& idValue = getIdAttribute();
1467 if (!idValue.isNull()) 1472 if (!idValue.isNull())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1530
1526 clearElementFlag(IsInCanvasSubtree); 1531 clearElementFlag(IsInCanvasSubtree);
1527 1532
1528 if (hasRareData()) { 1533 if (hasRareData()) {
1529 ElementRareData* data = elementRareData(); 1534 ElementRareData* data = elementRareData();
1530 1535
1531 data->clearRestyleFlags(); 1536 data->clearRestyleFlags();
1532 1537
1533 if (ElementAnimations* elementAnimations = data->elementAnimations()) 1538 if (ElementAnimations* elementAnimations = data->elementAnimations())
1534 elementAnimations->cssAnimations().cancel(); 1539 elementAnimations->cssAnimations().cancel();
1540
1541 if (data->intersectionObserverData())
1542 data->intersectionObserverData()->deactivateAllIntersectionObservers (*this);
1535 } 1543 }
1536 } 1544 }
1537 1545
1538 void Element::attach(const AttachContext& context) 1546 void Element::attach(const AttachContext& context)
1539 { 1547 {
1540 ASSERT(document().inStyleRecalc()); 1548 ASSERT(document().inStyleRecalc());
1541 1549
1542 // We've already been through detach when doing an attach, but we might 1550 // We've already been through detach when doing an attach, but we might
1543 // need to clear any state that's been added since then. 1551 // need to clear any state that's been added since then.
1544 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { 1552 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) {
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 if (!exceptionState.hadException()) 2583 if (!exceptionState.hadException())
2576 return newChild; 2584 return newChild;
2577 } 2585 }
2578 return nullptr; 2586 return nullptr;
2579 } 2587 }
2580 2588
2581 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ; 2589 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ;
2582 return nullptr; 2590 return nullptr;
2583 } 2591 }
2584 2592
2593 ElementIntersectionObserverData* Element::intersectionObserverData() const
2594 {
2595 if (elementRareData())
2596 return elementRareData()->intersectionObserverData();
2597 return nullptr;
2598 }
2599
2600 ElementIntersectionObserverData& Element::ensureIntersectionObserverData()
2601 {
2602 return ensureElementRareData().ensureIntersectionObserverData();
2603 }
2604
2585 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() 2605 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml()
2586 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState) 2606 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState)
2587 { 2607 {
2588 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) { 2608 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) {
2589 Element* parent = element->parentElement(); 2609 Element* parent = element->parentElement();
2590 if (!parent) { 2610 if (!parent) {
2591 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent."); 2611 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent.");
2592 return nullptr; 2612 return nullptr;
2593 } 2613 }
2594 return parent; 2614 return parent;
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3620 { 3640 {
3621 #if ENABLE(OILPAN) 3641 #if ENABLE(OILPAN)
3622 if (hasRareData()) 3642 if (hasRareData())
3623 visitor->trace(elementRareData()); 3643 visitor->trace(elementRareData());
3624 visitor->trace(m_elementData); 3644 visitor->trace(m_elementData);
3625 #endif 3645 #endif
3626 ContainerNode::trace(visitor); 3646 ContainerNode::trace(visitor);
3627 } 3647 }
3628 3648
3629 } // namespace blink 3649 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698