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(); |