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

Unified 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: Update to master: Vector<WeakMember> no longer ok. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index c62706460ec56341039e27ee288c1b63097793b0..5bc175fe1a86c581eb868922080103b0ac002f7b 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -37,6 +37,7 @@
#include "core/editing/FrameSelection.h"
#include "core/editing/RenderedPosition.h"
#include "core/editing/markers/DocumentMarkerController.h"
+#include "core/events/ErrorEvent.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameHost.h"
@@ -72,6 +73,7 @@
#include "core/layout/svg/LayoutSVGRoot.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
+#include "core/observer/ResizeObserverController.h"
#include "core/page/AutoscrollController.h"
#include "core/page/ChromeClient.h"
#include "core/page/FocusController.h"
@@ -2445,6 +2447,38 @@ void FrameView::scheduleVisualUpdateForPaintInvalidationIfNeeded()
// Otherwise the paint invalidation will be handled in paint invalidation phase of this cycle.
}
+void FrameView::notifyResizeObserver()
+{
+ if (!m_frame->document()->resizeObserverController())
+ return;
+
+ ResizeObserverController& resizeController = m_frame->document()->ensureResizeObserverController();
+
+ DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean);
+
+ size_t resizeNotifyCount = 0;
+
+ while (resizeController.gatherObservations()) {
szager1 2016/07/11 18:33:47 This is a much clearer organization of the loop, t
atotic1 2016/07/11 23:18:57 Done.
+ if (++resizeNotifyCount > ResizeObserverController::kRenderLoopLimit) {
+ resizeController.clearObservations();
+ // Report the error.
+ ErrorEvent * error = ErrorEvent::create("ResizeObserver loop limit exceeded", SourceLocation::capture(m_frame->document()), nullptr);
+ m_frame->document()->reportException(error, NotSharableCrossOrigin);
+ // Ensure notifications will get delivered in next cycle.
szager1 2016/07/11 18:33:47 This comment is obsolete, I think. Maybe just som
atotic1 2016/07/11 23:18:58 The comment is meaningful. Without scheduleAnimati
szager1 2016/07/11 23:33:34 But just a few lines up, you call resizeController
+ if (FrameView* frameView = m_frame->view())
+ frameView->scheduleAnimation();
+ break;
+ }
+
+ resizeController.deliverObservations();
+
+ if (lifecycle().state() < DocumentLifecycle::LayoutClean || layoutView()->needsLayout())
+ updateStyleAndLayoutIfNeededRecursive();
+ }
+
+ DCHECK(!layoutView()->needsLayout());
+}
+
// TODO(leviw): We don't assert lifecycle information from documents in child PluginViews.
void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
{
@@ -2462,13 +2496,16 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
}
updateStyleAndLayoutIfNeededRecursive();
- ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean);
if (phases == OnlyUpToLayoutClean) {
updateViewportIntersectionsForSubtree(phases);
return;
}
+ notifyResizeObserver();
szager1 2016/07/11 18:33:47 Are you sure we don't want to run this when (phase
atotic1 2016/07/11 23:18:57 I believe that ResizeObserver should not run if ph
szager1 2016/07/11 23:33:34 Good enough for me, I just wanted to make sure you
+
+ DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean);
+
if (LayoutViewItem view = layoutViewItem()) {
{
TRACE_EVENT1("devtools.timeline", "UpdateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get()));

Powered by Google App Engine
This is Rietveld 408576698