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

Unified Diff: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp

Issue 2553103004: Refactor IntersectionGeometry class and move it to core/layout. (Closed)
Patch Set: Simplify isContainingBlockChainDescendant Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
index 2ae1556fc10ddca7a031867902c3f74dde19c9c3..724c4312e55bd32fe530d9023a8e2c4d92af009c 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
@@ -6,18 +6,16 @@
#include "core/dom/ElementRareData.h"
#include "core/dom/IntersectionObserver.h"
+#include "core/layout/IntersectionGeometry.h"
namespace blink {
-IntersectionObservation::IntersectionObservation(
- IntersectionObserver& observer,
- Element& target,
- IntersectionGeometry::ReportRootBounds shouldReportRootBounds)
+IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
+ Element& target,
+ bool shouldReportRootBounds)
: m_observer(observer),
m_target(&target),
- m_shouldReportRootBounds(
- shouldReportRootBounds ==
- IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds),
+ m_shouldReportRootBounds(shouldReportRootBounds),
m_lastThresholdIndex(0) {}
void IntersectionObservation::computeIntersectionObservations(
@@ -29,11 +27,10 @@ void IntersectionObservation::computeIntersectionObservations(
rootMargin[1] = m_observer->rightMargin();
rootMargin[2] = m_observer->bottomMargin();
rootMargin[3] = m_observer->leftMargin();
+ Node* rootNode = m_observer->rootNode();
IntersectionGeometry geometry(
- m_observer->rootNode(), target(), rootMargin,
- m_shouldReportRootBounds
- ? IntersectionGeometry::ReportRootBounds::kShouldReportRootBounds
- : IntersectionGeometry::ReportRootBounds::kShouldNotReportRootBounds);
+ rootNode && !rootNode->isDocumentNode() ? toElement(rootNode) : nullptr,
+ *target(), rootMargin, m_shouldReportRootBounds);
geometry.computeGeometry();
// Some corner cases for threshold index:

Powered by Google App Engine
This is Rietveld 408576698