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

Unified Diff: third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.h

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing file, fix forbidden include. Created 4 years, 6 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/ScrollAndScaleEmulator.h
diff --git a/third_party/WebKit/Source/core/events/ScopedEventQueue.h b/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.h
similarity index 51%
copy from third_party/WebKit/Source/core/events/ScopedEventQueue.h
copy to third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.h
index 62fa23532d7f788cfbcfd222a6ee587d931581cc..02ea77cd9565e305131819216bdd729c185166da 100644
--- a/third_party/WebKit/Source/core/events/ScopedEventQueue.h
+++ b/third_party/WebKit/Source/core/frame/ScrollAndScaleEmulator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,52 +28,52 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ScopedEventQueue_h
-#define ScopedEventQueue_h
+#ifndef ScrollAndScaleEmulator_h
+#define ScrollAndScaleEmulator_h
#include "core/CoreExport.h"
-#include "platform/heap/Handle.h"
+#include "platform/geometry/DoublePoint.h"
#include "wtf/Noncopyable.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefPtr.h"
-#include "wtf/Vector.h"
+#include "wtf/RefCounted.h"
namespace blink {
-class EventDispatchMediator;
+struct PageScaleConstraints;
-class CORE_EXPORT ScopedEventQueue {
- WTF_MAKE_NONCOPYABLE(ScopedEventQueue); USING_FAST_MALLOC(ScopedEventQueue);
+// Overrides the scroll positions of frame and visual viewport and the page
+// scale with fixed values.
+//
+// TODO(eseckler): description of impl
+class CORE_EXPORT ScrollAndScaleEmulator final : public RefCounted<ScrollAndScaleEmulator> {
+ WTF_MAKE_NONCOPYABLE(ScrollAndScaleEmulator);
public:
- ~ScopedEventQueue();
+ static PassRefPtr<ScrollAndScaleEmulator> create();
- void enqueueEventDispatchMediator(EventDispatchMediator*);
- void dispatchAllEvents();
- static ScopedEventQueue* instance();
+ virtual ~ScrollAndScaleEmulator() {}
- void incrementScopingLevel();
- void decrementScopingLevel();
- bool shouldQueueEvents() const { return m_scopingLevel > 0; }
+ // Update override values. Returns |true| if values changed.
+ bool update(const IntPoint& framePosition, const DoublePoint& visualViewportPosition, float pageScale);
+
+ IntPoint applyFramePositionOverride(const IntPoint&);
+ DoublePoint applyVisualViewportPositionOverride(const DoublePoint&);
+ PageScaleConstraints pageScaleConstraints();
private:
- ScopedEventQueue();
- static void initialize();
- void dispatchEvent(EventDispatchMediator*) const;
+ ScrollAndScaleEmulator();
- PersistentHeapVector<Member<EventDispatchMediator>> m_queuedEventDispatchMediators;
- unsigned m_scopingLevel;
+ template <typename Point>
+ Point applyPositionOverride(const Point& position, const Point& override);
- static ScopedEventQueue* s_instance;
-};
+ // Scroll position of frame. |x < 0| or |y < 0| disables the override for the respective coordinate.
+ IntPoint m_framePosition;
-class EventQueueScope {
- WTF_MAKE_NONCOPYABLE(EventQueueScope);
- STACK_ALLOCATED();
-public:
- EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); }
- ~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); }
+ // Scroll position of visual viewport. |x < 0| or |y < 0| disables the override for the respective coordinate.
+ DoublePoint m_visualViewportPosition;
+
+ // Simulates visual viewport pinch zoom. |pageScale == 0| disables the override.
+ double m_pageScale;
};
} // namespace blink
-#endif // ScopedEventQueue_h
+#endif // ScrollAndScaleEmulator_h

Powered by Google App Engine
This is Rietveld 408576698