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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutView.cpp

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Lost newline in merge Created 5 years, 2 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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/layout/LayoutView.h" 22 #include "core/layout/LayoutView.h"
23 23
24 #include "core/dom/Document.h" 24 #include "core/dom/Document.h"
25 #include "core/dom/Element.h" 25 #include "core/dom/Element.h"
26 #include "core/dom/IntersectionObserver.h"
26 #include "core/editing/FrameSelection.h" 27 #include "core/editing/FrameSelection.h"
27 #include "core/frame/LocalFrame.h" 28 #include "core/frame/LocalFrame.h"
28 #include "core/frame/Settings.h" 29 #include "core/frame/Settings.h"
29 #include "core/html/HTMLFrameOwnerElement.h" 30 #include "core/html/HTMLFrameOwnerElement.h"
30 #include "core/html/HTMLIFrameElement.h" 31 #include "core/html/HTMLIFrameElement.h"
31 #include "core/inspector/InspectorTraceEvents.h" 32 #include "core/inspector/InspectorTraceEvents.h"
32 #include "core/layout/HitTestResult.h" 33 #include "core/layout/HitTestResult.h"
33 #include "core/layout/LayoutFlowThread.h" 34 #include "core/layout/LayoutFlowThread.h"
34 #include "core/layout/LayoutGeometryMap.h" 35 #include "core/layout/LayoutGeometryMap.h"
35 #include "core/layout/LayoutPart.h" 36 #include "core/layout/LayoutPart.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 948 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
948 return viewHeight(IncludeScrollbars) / scale; 949 return viewHeight(IncludeScrollbars) / scale;
949 } 950 }
950 951
951 void LayoutView::willBeDestroyed() 952 void LayoutView::willBeDestroyed()
952 { 953 {
953 LayoutBlockFlow::willBeDestroyed(); 954 LayoutBlockFlow::willBeDestroyed();
954 m_compositor.clear(); 955 m_compositor.clear();
955 } 956 }
956 957
958 void LayoutView::addIntersectionObserverTarget(LayoutObject* obj)
959 {
960 m_intersectionObserverTargets.add(obj, IntRect());
961 }
962
963 void LayoutView::removeIntersectionObserverTarget(LayoutObject* obj)
964 {
965 m_intersectionObserverTargets.remove(obj);
966 }
967
968 void LayoutView::computeIntersectionObservations(const FloatRect& rootBounds)
969 {
970 for (auto& obj : m_intersectionObserverTargets) {
971 LayoutObject* layoutObject = obj.key;
972 Node* node = layoutObject->node();
973 if (!node || !node->isElementNode())
974 continue;
975 FloatRect bounds = layoutObject->absoluteBoundingBoxFloatRect();
976 FloatRect intersection(bounds);
977 intersection.intersect(rootBounds);
978 const FloatRect& oldIntersection = obj.value;
979 if (oldIntersection == intersection)
980 continue;
981 obj.value = intersection;
982 Element* element = toElement(node);
983 for (auto& observer : element->intersectionObservers()) {
984 observer->enqueueIntersectionObserverEntry(IntersectionObserverEntry ::create(0, bounds, rootBounds, intersection, element));
985 }
986 }
987 }
988
957 } // namespace blink 989 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.h ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698