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

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: Observe content box, not clientWidth Created 4 years, 7 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 cff7ed8b8b6b51103211afe344474fb759590101..bc4b3d58da4f1174dd4cab5cd48058e3cb44a6bc 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -26,6 +26,7 @@
#include "core/frame/FrameView.h"
+#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
#include "core/HTMLNames.h"
#include "core/MediaTypeNames.h"
#include "core/css/FontFaceSet.h"
@@ -37,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"
@@ -71,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"
@@ -2408,6 +2411,35 @@ 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();
+
+ 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.
+ updateStyleAndLayoutIfNeededRecursive();
+
+ size_t resizeNotifyCount = 0;
+
+ 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
+ if (++resizeNotifyCount > ResizeObserverController::kRenderLoopLimit) {
+ // report the error and break
+ ErrorEvent * error = ErrorEvent::create("ResizeObserver loop limit exceeded.", "", 0, 0, nullptr);
+ m_frame->document()->reportException(error, 0, nullptr, NotSharableCrossOrigin);
+ 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)
{
@@ -2425,6 +2457,9 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases)
}
updateStyleAndLayoutIfNeededRecursive();
+
+ notifyResizeObserver();
+
ASSERT(lifecycle().state() >= DocumentLifecycle::LayoutClean);
if (phases == OnlyUpToLayoutClean) {

Powered by Google App Engine
This is Rietveld 408576698