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

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: sigbjornf 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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"
haraken 2016/01/02 13:47:40 These #includes wouldn't be necessary.
szager1 2016/01/02 19:18:34 Done.
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 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 ContainerNode::insertedInto(insertionPoint); 1449 ContainerNode::insertedInto(insertionPoint);
1447 1450
1448 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement()) 1451 if (containsFullScreenElement() && parentElement() && !parentElement()->cont ainsFullScreenElement())
1449 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 1452 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
1450 1453
1451 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements()); 1454 ASSERT(!hasRareData() || !elementRareData()->hasPseudoElements());
1452 1455
1453 if (!insertionPoint->isInTreeScope()) 1456 if (!insertionPoint->isInTreeScope())
1454 return InsertionDone; 1457 return InsertionDone;
1455 1458
1456 if (hasRareData()) 1459 if (hasRareData()) {
1457 elementRareData()->clearClassListValueForQuirksMode(); 1460 ElementRareData* rareData = elementRareData();
1461 rareData->clearClassListValueForQuirksMode();
1462 if (rareData->intersectionObserverData())
1463 rareData->ensureIntersectionObserverData().activateValidIntersection Observers(*this);
haraken 2016/01/02 13:47:40 Nit: It looks a bit strange to call ensureXXX afte
szager1 2016/01/02 19:18:34 Fixed.
1464 }
1458 1465
1459 if (isUpgradedCustomElement() && inDocument()) 1466 if (isUpgradedCustomElement() && inDocument())
1460 CustomElement::didAttach(this, document()); 1467 CustomElement::didAttach(this, document());
1461 1468
1462 TreeScope& scope = insertionPoint->treeScope(); 1469 TreeScope& scope = insertionPoint->treeScope();
1463 if (scope != treeScope()) 1470 if (scope != treeScope())
1464 return InsertionDone; 1471 return InsertionDone;
1465 1472
1466 const AtomicString& idValue = getIdAttribute(); 1473 const AtomicString& idValue = getIdAttribute();
1467 if (!idValue.isNull()) 1474 if (!idValue.isNull())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1532
1526 clearElementFlag(IsInCanvasSubtree); 1533 clearElementFlag(IsInCanvasSubtree);
1527 1534
1528 if (hasRareData()) { 1535 if (hasRareData()) {
1529 ElementRareData* data = elementRareData(); 1536 ElementRareData* data = elementRareData();
1530 1537
1531 data->clearRestyleFlags(); 1538 data->clearRestyleFlags();
1532 1539
1533 if (ElementAnimations* elementAnimations = data->elementAnimations()) 1540 if (ElementAnimations* elementAnimations = data->elementAnimations())
1534 elementAnimations->cssAnimations().cancel(); 1541 elementAnimations->cssAnimations().cancel();
1542
1543 if (data->intersectionObserverData())
1544 data->ensureIntersectionObserverData().deactivateAllIntersectionObse rvers(*this);
haraken 2016/01/02 13:47:40 Ditto.
szager1 2016/01/02 19:18:34 Fixed.
1535 } 1545 }
1536 } 1546 }
1537 1547
1538 void Element::attach(const AttachContext& context) 1548 void Element::attach(const AttachContext& context)
1539 { 1549 {
1540 ASSERT(document().inStyleRecalc()); 1550 ASSERT(document().inStyleRecalc());
1541 1551
1542 // We've already been through detach when doing an attach, but we might 1552 // 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. 1553 // need to clear any state that's been added since then.
1544 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { 1554 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) {
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 if (!exceptionState.hadException()) 2585 if (!exceptionState.hadException())
2576 return newChild; 2586 return newChild;
2577 } 2587 }
2578 return nullptr; 2588 return nullptr;
2579 } 2589 }
2580 2590
2581 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ; 2591 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ;
2582 return nullptr; 2592 return nullptr;
2583 } 2593 }
2584 2594
2595 ElementIntersectionObserverData* Element::intersectionObserverData() const
2596 {
2597 if (elementRareData())
2598 return elementRareData()->intersectionObserverData();
2599 return nullptr;
2600 }
2601
2602 ElementIntersectionObserverData& Element::ensureIntersectionObserverData()
2603 {
2604 return ensureElementRareData().ensureIntersectionObserverData();
2605 }
2606
2585 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() 2607 // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml()
2586 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState) 2608 static Element* contextElementForInsertion(const String& where, Element* element , ExceptionState& exceptionState)
2587 { 2609 {
2588 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) { 2610 if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "aft erEnd")) {
2589 Element* parent = element->parentElement(); 2611 Element* parent = element->parentElement();
2590 if (!parent) { 2612 if (!parent) {
2591 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent."); 2613 exceptionState.throwDOMException(NoModificationAllowedError, "The el ement has no parent.");
2592 return nullptr; 2614 return nullptr;
2593 } 2615 }
2594 return parent; 2616 return parent;
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3620 { 3642 {
3621 #if ENABLE(OILPAN) 3643 #if ENABLE(OILPAN)
3622 if (hasRareData()) 3644 if (hasRareData())
3623 visitor->trace(elementRareData()); 3645 visitor->trace(elementRareData());
3624 visitor->trace(m_elementData); 3646 visitor->trace(m_elementData);
3625 #endif 3647 #endif
3626 ContainerNode::trace(visitor); 3648 ContainerNode::trace(visitor);
3627 } 3649 }
3628 3650
3629 } // namespace blink 3651 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698