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

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: Fix global-interface-listing test Created 4 years, 5 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 fa8b38802cb6b0846b7f5ea4280e7666a3efba79..33256b34f42345a69c458b3163eee423aae1cd11 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -38,6 +38,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"
@@ -73,6 +74,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"
@@ -2505,6 +2507,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())
eae 2016/07/13 23:39:47 When would notifyResizeObserver ever be called if
atotic1 2016/07/15 01:43:17 Controller is allocated only if ResizeObserver is
+ return;
+
+ ResizeObserverController& resizeController = m_frame->document()->ensureResizeObserverController();
+
+ DCHECK(lifecycle().state() >= DocumentLifecycle::LayoutClean);
+
+ size_t resizeNotifyCount = 0;
+
+ while (resizeController.gatherObservations()) {
+ if (++resizeNotifyCount > ResizeObserverController::kRenderLoopLimit) {
+ resizeController.clearObservations();
+ // Report the error.
eae 2016/07/13 23:39:47 Please remove redundant comment.
atotic1 2016/07/15 01:43:17 Done.
+ 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.
+ 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(DocumentLifecycle::LifecycleState targetState)
{
@@ -2533,6 +2567,8 @@ void FrameView::updateLifecyclePhasesInternal(DocumentLifecycle::LifecycleState
return;
}
+ notifyResizeObserver();
+
if (LayoutViewItem view = layoutViewItem()) {
forAllNonThrottledFrameViews([](FrameView& frameView) {
frameView.checkDoesNotNeedLayout();

Powered by Google App Engine
This is Rietveld 408576698