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

Unified Diff: third_party/WebKit/Source/core/observer/ResizeObservation.cpp

Issue 2005593002: Initial ResizeObserver implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/observer/ResizeObservation.cpp
diff --git a/third_party/WebKit/Source/core/observer/ResizeObservation.cpp b/third_party/WebKit/Source/core/observer/ResizeObservation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57e8f9c99f460b409edc1c039df25316093eb576
--- /dev/null
+++ b/third_party/WebKit/Source/core/observer/ResizeObservation.cpp
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/observer/ResizeObservation.h"
+
+#include "core/observer/ResizeObserver.h"
+
+namespace blink {
+
+ResizeObservation::ResizeObservation(Element * target, ResizeObserver * observer) :
szager1 2016/05/23 19:49:10 Colon goes on next line; refer to existing class d
atotic1 2016/05/25 00:15:52 Done.
+ m_target(target),
szager1 2016/05/23 19:49:10 Comma goes at the beginning of the next line, for
atotic1 2016/05/25 00:15:52 Done.
+ m_observer(observer),
+ m_broadcastWidth(target->clientWidth()),
+ m_broadcastHeight(target->clientHeight())
+{
+ m_target->ensureResizeObserverData().add(this);
+}
+
+bool ResizeObservation::hasResized() const
+{
+ if (!m_target)
+ return false;
+ return (m_target->clientWidth() != m_broadcastWidth
+ || m_target->clientHeight() != m_broadcastHeight);
+}
+
+void ResizeObservation::setBroadcastSize(int width, int height)
+{
+ m_broadcastWidth = width;
+ m_broadcastHeight = height;
+}
+
+DEFINE_TRACE(ResizeObservation)
+{
+ visitor->trace(m_target);
+ visitor->trace(m_observer);
+}
+
+void ResizeObservationSet::add(ResizeObservation* obs)
+{
+ m_observations.add(obs);
+}
+
+void ResizeObservationSet::remove(ResizeObservation* obs)
+{
+ m_observations.remove(obs);
+}
+
+DEFINE_TRACE(ResizeObservationSet)
+{
+ visitor->trace(m_observations);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698