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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2005593002: Initial ResizeObserver implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Observe content box, not clientWidth Created 4 years, 6 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
11 * This library is free software; you can redistribute it and/or 11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This library is distributed in the hope that it will be useful, 16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public License 21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to 22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA. 24 * Boston, MA 02110-1301, USA.
25 */ 25 */
26 26
27 #include "core/frame/FrameView.h" 27 #include "core/frame/FrameView.h"
28 28
29 #include "bindings/core/v8/ScriptCallStack.h"
szager1 2016/06/02 20:52:41 There should be a way to eliminate this. I still
atotic1 2016/06/08 18:59:21 Done. I've just pulled master, and the new API no
29 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
30 #include "core/MediaTypeNames.h" 31 #include "core/MediaTypeNames.h"
31 #include "core/css/FontFaceSet.h" 32 #include "core/css/FontFaceSet.h"
32 #include "core/css/resolver/StyleResolver.h" 33 #include "core/css/resolver/StyleResolver.h"
33 #include "core/dom/AXObjectCache.h" 34 #include "core/dom/AXObjectCache.h"
34 #include "core/dom/Fullscreen.h" 35 #include "core/dom/Fullscreen.h"
35 #include "core/dom/IntersectionObserverController.h" 36 #include "core/dom/IntersectionObserverController.h"
36 #include "core/editing/EditingUtilities.h" 37 #include "core/editing/EditingUtilities.h"
37 #include "core/editing/FrameSelection.h" 38 #include "core/editing/FrameSelection.h"
38 #include "core/editing/RenderedPosition.h" 39 #include "core/editing/RenderedPosition.h"
39 #include "core/editing/markers/DocumentMarkerController.h" 40 #include "core/editing/markers/DocumentMarkerController.h"
41 #include "core/events/ErrorEvent.h"
40 #include "core/fetch/ResourceFetcher.h" 42 #include "core/fetch/ResourceFetcher.h"
41 #include "core/frame/EventHandlerRegistry.h" 43 #include "core/frame/EventHandlerRegistry.h"
42 #include "core/frame/FrameHost.h" 44 #include "core/frame/FrameHost.h"
43 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
44 #include "core/frame/Location.h" 46 #include "core/frame/Location.h"
45 #include "core/frame/PageScaleConstraintsSet.h" 47 #include "core/frame/PageScaleConstraintsSet.h"
46 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
47 #include "core/frame/TopControls.h" 49 #include "core/frame/TopControls.h"
48 #include "core/html/HTMLFrameElement.h" 50 #include "core/html/HTMLFrameElement.h"
49 #include "core/html/HTMLPlugInElement.h" 51 #include "core/html/HTMLPlugInElement.h"
(...skipping 14 matching lines...) Expand all
64 #include "core/layout/TracedLayoutObject.h" 66 #include "core/layout/TracedLayoutObject.h"
65 #include "core/layout/api/LayoutBoxModel.h" 67 #include "core/layout/api/LayoutBoxModel.h"
66 #include "core/layout/api/LayoutItem.h" 68 #include "core/layout/api/LayoutItem.h"
67 #include "core/layout/api/LayoutViewItem.h" 69 #include "core/layout/api/LayoutViewItem.h"
68 #include "core/layout/compositing/CompositedLayerMapping.h" 70 #include "core/layout/compositing/CompositedLayerMapping.h"
69 #include "core/layout/compositing/CompositedSelection.h" 71 #include "core/layout/compositing/CompositedSelection.h"
70 #include "core/layout/compositing/PaintLayerCompositor.h" 72 #include "core/layout/compositing/PaintLayerCompositor.h"
71 #include "core/layout/svg/LayoutSVGRoot.h" 73 #include "core/layout/svg/LayoutSVGRoot.h"
72 #include "core/loader/FrameLoader.h" 74 #include "core/loader/FrameLoader.h"
73 #include "core/loader/FrameLoaderClient.h" 75 #include "core/loader/FrameLoaderClient.h"
76 #include "core/observer/ResizeObserverController.h"
74 #include "core/page/AutoscrollController.h" 77 #include "core/page/AutoscrollController.h"
75 #include "core/page/ChromeClient.h" 78 #include "core/page/ChromeClient.h"
76 #include "core/page/FocusController.h" 79 #include "core/page/FocusController.h"
77 #include "core/page/FrameTree.h" 80 #include "core/page/FrameTree.h"
78 #include "core/page/Page.h" 81 #include "core/page/Page.h"
79 #include "core/page/scrolling/ScrollingCoordinator.h" 82 #include "core/page/scrolling/ScrollingCoordinator.h"
80 #include "core/paint/FramePainter.h" 83 #include "core/paint/FramePainter.h"
81 #include "core/paint/PaintLayer.h" 84 #include "core/paint/PaintLayer.h"
82 #include "core/paint/PaintPropertyTreeBuilder.h" 85 #include "core/paint/PaintPropertyTreeBuilder.h"
83 #include "core/plugins/PluginView.h" 86 #include "core/plugins/PluginView.h"
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded() 2404 void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded()
2402 { 2405 {
2403 LocalFrame* localFrameRoot = frame().localFrameRoot(); 2406 LocalFrame* localFrameRoot = frame().localFrameRoot();
2404 if (!localFrameRoot->view()->m_isUpdatingAllLifecyclePhases || lifecycle().s tate() >= DocumentLifecycle::PaintInvalidationClean) { 2407 if (!localFrameRoot->view()->m_isUpdatingAllLifecyclePhases || lifecycle().s tate() >= DocumentLifecycle::PaintInvalidationClean) {
2405 // Schedule visual update to process the paint invalidation in the next cycle. 2408 // Schedule visual update to process the paint invalidation in the next cycle.
2406 localFrameRoot->scheduleVisualUpdateUnlessThrottled(); 2409 localFrameRoot->scheduleVisualUpdateUnlessThrottled();
2407 } 2410 }
2408 // Otherwise the paint invalidation will be handled in paint invalidation ph ase of this cycle. 2411 // Otherwise the paint invalidation will be handled in paint invalidation ph ase of this cycle.
2409 } 2412 }
2410 2413
2414 void FrameView::notifyResizeObserver()
2415 {
2416 if (!m_frame->document()->resizeObserverController())
2417 return;
2418
2419 ResizeObserverController& resizeController = m_frame->document()->ensureResi zeObserverController();
2420
2421 if (lifecycle().state() < DocumentLifecycle::LayoutClean)
szager1 2016/06/02 20:52:41 This makes me uneasy. If you're going to call upd
atotic1 2016/06/08 18:59:21 Done.
2422 updateStyleAndLayoutIfNeededRecursive();
2423
2424 size_t resizeNotifyCount = 0;
2425
2426 while (resizeController.gatherObservations()) {
szager1 2016/06/02 20:52:41 This still doesn't seem right. What happens to th
atotic1 2016/06/08 18:59:21 Done. I've added a clearObservations(). I was cle
2427 if (++resizeNotifyCount > ResizeObserverController::kRenderLoopLimit) {
2428 // report the error and break
2429 ErrorEvent * error = ErrorEvent::create("ResizeObserver loop limit e xceeded.", "", 0, 0, nullptr);
2430 m_frame->document()->reportException(error, 0, nullptr, NotSharableC rossOrigin);
2431 break;
2432 }
2433
2434 resizeController.deliverObservations();
2435
2436 if (lifecycle().state() < DocumentLifecycle::LayoutClean || layoutView() ->needsLayout())
2437 updateStyleAndLayoutIfNeededRecursive();
2438 }
2439
2440 DCHECK(!layoutView()->needsLayout());
2441 }
2442
2411 // TODO(leviw): We don't assert lifecycle information from documents in child Pl uginViews. 2443 // TODO(leviw): We don't assert lifecycle information from documents in child Pl uginViews.
2412 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases) 2444 void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
2413 { 2445 {
2414 Optional<TemporaryChange<bool>> isUpdatingAllLifecyclePhasesScope; 2446 Optional<TemporaryChange<bool>> isUpdatingAllLifecyclePhasesScope;
2415 if (phases == AllPhases) 2447 if (phases == AllPhases)
2416 isUpdatingAllLifecyclePhasesScope.emplace(m_isUpdatingAllLifecyclePhases , true); 2448 isUpdatingAllLifecyclePhasesScope.emplace(m_isUpdatingAllLifecyclePhases , true);
2417 2449
2418 // This must be called from the root frame, since it recurses down, not up. 2450 // This must be called from the root frame, since it recurses down, not up.
2419 // Otherwise the lifecycles of the frames might be out of sync. 2451 // Otherwise the lifecycles of the frames might be out of sync.
2420 ASSERT(m_frame->isLocalRoot()); 2452 ASSERT(m_frame->isLocalRoot());
2421 2453
2422 if (shouldThrottleRendering()) { 2454 if (shouldThrottleRendering()) {
2423 updateViewportIntersectionsForSubtree(std::min(phases, OnlyUpToCompositi ngCleanPlusScrolling)); 2455 updateViewportIntersectionsForSubtree(std::min(phases, OnlyUpToCompositi ngCleanPlusScrolling));
2424 return; 2456 return;
2425 } 2457 }
2426 2458
2427 updateStyleAndLayoutIfNeededRecursive(); 2459 updateStyleAndLayoutIfNeededRecursive();
2460
2461 notifyResizeObserver();
2462
2428 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean); 2463 ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean);
2429 2464
2430 if (phases == OnlyUpToLayoutClean) { 2465 if (phases == OnlyUpToLayoutClean) {
2431 updateViewportIntersectionsForSubtree(phases); 2466 updateViewportIntersectionsForSubtree(phases);
2432 return; 2467 return;
2433 } 2468 }
2434 2469
2435 if (LayoutViewItem view = layoutViewItem()) { 2470 if (LayoutViewItem view = layoutViewItem()) {
2436 { 2471 {
2437 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect orUpdateLayerTreeEvent::data(m_frame.get())); 2472 TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", Inspect orUpdateLayerTreeEvent::data(m_frame.get()));
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling); 4139 return m_subtreeThrottled || (m_hiddenForThrottling && m_crossOriginForThrot tling);
4105 } 4140 }
4106 4141
4107 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4142 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4108 { 4143 {
4109 ASSERT(layoutView()); 4144 ASSERT(layoutView());
4110 return *layoutView(); 4145 return *layoutView();
4111 } 4146 }
4112 4147
4113 } // namespace blink 4148 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698