| 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..f6d3ceaa20baca2b813705065ad283ae5f28ad86 100644
|
| --- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
|
| @@ -50,19 +50,22 @@ void IntersectionObservation::computeIntersectionObservations(
|
| // intersection to have "crossed" a zero threshold, but not crossed
|
| // any non-zero threshold.
|
| unsigned newThresholdIndex;
|
| - float newVisibleRatio = 0;
|
| - if (geometry.targetRect().isEmpty()) {
|
| - newThresholdIndex = geometry.doesIntersect() ? 1 : 0;
|
| - } else if (!geometry.doesIntersect()) {
|
| - newThresholdIndex = 0;
|
| - } else {
|
| - float intersectionArea =
|
| - geometry.intersectionRect().size().width().toFloat() *
|
| - geometry.intersectionRect().size().height().toFloat();
|
| - float targetArea = geometry.targetRect().size().width().toFloat() *
|
| - geometry.targetRect().size().height().toFloat();
|
| - newVisibleRatio = intersectionArea / targetArea;
|
| + float newVisibleRatio;
|
| + if (geometry.doesIntersect()) {
|
| + if (geometry.targetRect().isEmpty()) {
|
| + newVisibleRatio = 1;
|
| + } else {
|
| + float intersectionArea =
|
| + geometry.intersectionRect().size().width().toFloat() *
|
| + geometry.intersectionRect().size().height().toFloat();
|
| + float targetArea = geometry.targetRect().size().width().toFloat() *
|
| + geometry.targetRect().size().height().toFloat();
|
| + newVisibleRatio = intersectionArea / targetArea;
|
| + }
|
| newThresholdIndex = observer().firstThresholdGreaterThan(newVisibleRatio);
|
| + } else {
|
| + newVisibleRatio = 0;
|
| + newThresholdIndex = 0;
|
| }
|
| if (m_lastThresholdIndex != newThresholdIndex) {
|
| IntRect snappedRootBounds = geometry.rootIntRect();
|
|
|