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

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

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix segfault on null input. Created 5 years, 3 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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1; 1006 float scale = m_frameView ? m_frameView->frame().pageZoomFactor() : 1;
1006 return viewHeight(IncludeScrollbars) / scale; 1007 return viewHeight(IncludeScrollbars) / scale;
1007 } 1008 }
1008 1009
1009 void LayoutView::willBeDestroyed() 1010 void LayoutView::willBeDestroyed()
1010 { 1011 {
1011 LayoutBlockFlow::willBeDestroyed(); 1012 LayoutBlockFlow::willBeDestroyed();
1012 m_compositor.clear(); 1013 m_compositor.clear();
1013 } 1014 }
1014 1015
1016 void LayoutView::addIntersectionObserverTarget(LayoutObject* obj)
1017 {
1018 m_intersectionObserverTargets.add(obj, IntRect());
1019 }
1020
1021 void LayoutView::removeIntersectionObserverTarget(LayoutObject* obj)
1022 {
1023 m_intersectionObserverTargets.remove(obj);
1024 }
1025
1026 void LayoutView::computeIntersectionObservations(const FloatRect& viewport)
1027 {
1028 for (auto& obj : m_intersectionObserverTargets) {
1029 LayoutObject* layoutObect = obj.key;
ojan 2015/09/21 03:49:09 Typo: layoutObect
MikeB 2015/09/24 19:04:04 Done.
1030 Node* node = layoutObect->node();
1031 if (!node || !node->isElementNode())
1032 continue;
1033 FloatRect bounds = layoutObect->absoluteBoundingBoxFloatRect();
ojan 2015/09/21 03:49:09 I don't think this handles clipping from ancestor
1034 bounds.intersect(viewport);
1035 const FloatRect& oldBounds = obj.value;
1036 if (oldBounds == bounds)
1037 continue;
1038 obj.value = bounds;
1039 Element* element = toElement(node);
1040 Vector<FloatRect> quads;
1041 quads.append(bounds);
1042 for (auto& observer : element->intersectionObservers()) {
1043 observer->enqueueIntersectionObserverEntry(IntersectionObserverEntry ::create(0, quads, viewport, element));
1044 }
1045 }
1046 }
1047
1015 } // namespace blink 1048 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698