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

Unified Diff: third_party/WebKit/Source/core/observer/ResizeObserver.h

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/ResizeObserver.h
diff --git a/third_party/WebKit/Source/core/observer/ResizeObserver.h b/third_party/WebKit/Source/core/observer/ResizeObserver.h
new file mode 100644
index 0000000000000000000000000000000000000000..87b1157b11f2d00b94035306ba5a2667386aed82
--- /dev/null
+++ b/third_party/WebKit/Source/core/observer/ResizeObserver.h
@@ -0,0 +1,66 @@
+// 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.
+
+#ifndef ResizeObserver_h
+#define ResizeObserver_h
+
+#include "bindings/core/v8/ScriptWrappable.h"
szager1 2016/05/23 19:49:11 I don't think you use this.
+#include "core/dom/Element.h"
szager1 2016/05/23 19:49:12 You shouldn't need this, the forward class declara
+#include "core/observer/ResizeObserverEntry.h"
szager1 2016/05/23 19:49:12 I don't think you use this.
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+class Element;
+class ResizeObserverCallback;
+class ResizeObserverEntry;
szager1 2016/05/23 19:49:11 I don't think you use this.
+class ResizeObservation;
+
+// ResizeObserver represents ResizeObserver javascript api:
+// https://github.com/WICG/ResizeObserver/
+class ResizeObserver final : public GarbageCollectedFinalized<ResizeObserver>, public ScriptWrappable {
+ DEFINE_WRAPPERTYPEINFO();
+
+public:
+ static ResizeObserver* create(Document&, ResizeObserverCallback*);
+
+ virtual ~ResizeObserver() {};
szager1 2016/05/23 19:49:12 No unnecessary destructors, switch class to Garbag
+
+ // API methods
+ void observe(Element*);
+ void unobserve(Element*);
+ void disconnect();
+
+ DECLARE_TRACE();
+
+ void gatherObservations();
szager1 2016/05/23 19:49:12 Too much whitespace.
+
+ bool hasObservations() const { return !m_activeObservations.isEmpty(); }
+
+ void deliverObservations();
+
+private:
+
+ // FIXME(atotic): for GC, I need an ordered list of WeakMembers here.
+ using ObservationList = HeapVector<Member<ResizeObservation>>;
szager1 2016/05/23 19:49:11 No typedef's or "using", just use full type everyw
+
+ ObservationList::iterator find(Element*);
+
+ explicit ResizeObserver(ResizeObserverCallback*);
+
+ Member<ResizeObserverCallback> m_callback;
+
+ // List of elements we are observing
+ ObservationList m_observations;
+
+ // List of elements that have changes
+ HeapVector<Member<ResizeObservation>> m_activeObservations;
+
+};
+
+
+} // namespace blink
+
+#endif // ResizeObserver_h

Powered by Google App Engine
This is Rietveld 408576698