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

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: 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/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..1cd8d7ab0cda09bc56c4b2974efe95496dae59ca
--- /dev/null
+++ b/third_party/WebKit/Source/core/observer/ResizeObserver.h
@@ -0,0 +1,62 @@
+// 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"
+#include "core/dom/Element.h"
szager1 2016/06/02 20:52:41 Move this to .cpp file.
atotic1 2016/06/08 18:59:22 Done.
+#include "core/observer/ResizeObserverEntry.h"
szager1 2016/06/02 20:52:41 ditto
atotic1 2016/06/08 18:59:22 Done. What was I thinking here?
+#include "platform/heap/Handle.h"
+
+namespace blink {
+
+class Document;
+class Element;
+class ResizeObserverCallback;
+class ResizeObserverEntry;
+class ResizeObservation;
+
+// ResizeObserver represents ResizeObserver javascript api:
+// https://github.com/WICG/ResizeObserver/
+class ResizeObserver final : public GarbageCollectedFinalized<ResizeObserver>, public ScriptWrappable {
szager1 2016/06/02 20:52:41 No Finalized, no destructors; see previous comment
atotic1 2016/06/08 18:59:22 This one has to be finalized because HeapLinkedHas
+ DEFINE_WRAPPERTYPEINFO();
+
+public:
+ static ResizeObserver* create(Document&, ResizeObserverCallback*);
+
+ virtual ~ResizeObserver() {};
+
+ // API methods
+ void observe(Element*);
+ void unobserve(Element*);
+ void disconnect();
+
+ DECLARE_TRACE();
+
+ // returns true if observations were found.
+ bool gatherObservations();
+
+ void deliverObservations();
+
+private:
+
+ using ObservationList = HeapLinkedHashSet<WeakMember<ResizeObservation>>;
+
+ 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