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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2016 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 16 * this software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ScopedEventQueue_h 31 #ifndef ScrollAndScaleEmulator_h
32 #define ScopedEventQueue_h 32 #define ScrollAndScaleEmulator_h
33 33
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include "platform/heap/Handle.h" 35 #include "platform/geometry/DoublePoint.h"
36 #include "wtf/Noncopyable.h" 36 #include "wtf/Noncopyable.h"
37 #include "wtf/PassRefPtr.h" 37 #include "wtf/RefCounted.h"
38 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h"
40 38
41 namespace blink { 39 namespace blink {
42 40
43 class EventDispatchMediator; 41 struct PageScaleConstraints;
44 42
45 class CORE_EXPORT ScopedEventQueue { 43 // Overrides the scroll positions of frame and visual viewport and the page
46 WTF_MAKE_NONCOPYABLE(ScopedEventQueue); USING_FAST_MALLOC(ScopedEventQueue); 44 // scale with fixed values.
45 //
46 // TODO(eseckler): description of impl
47 class CORE_EXPORT ScrollAndScaleEmulator final : public RefCounted<ScrollAndScal eEmulator> {
48 WTF_MAKE_NONCOPYABLE(ScrollAndScaleEmulator);
47 public: 49 public:
48 ~ScopedEventQueue(); 50 static PassRefPtr<ScrollAndScaleEmulator> create();
49 51
50 void enqueueEventDispatchMediator(EventDispatchMediator*); 52 virtual ~ScrollAndScaleEmulator() {}
51 void dispatchAllEvents();
52 static ScopedEventQueue* instance();
53 53
54 void incrementScopingLevel(); 54 // Update override values. Returns |true| if values changed.
55 void decrementScopingLevel(); 55 bool update(const IntPoint& framePosition, const DoublePoint& visualViewport Position, float pageScale);
56 bool shouldQueueEvents() const { return m_scopingLevel > 0; } 56
57 IntPoint applyFramePositionOverride(const IntPoint&);
58 DoublePoint applyVisualViewportPositionOverride(const DoublePoint&);
59 PageScaleConstraints pageScaleConstraints();
57 60
58 private: 61 private:
59 ScopedEventQueue(); 62 ScrollAndScaleEmulator();
60 static void initialize();
61 void dispatchEvent(EventDispatchMediator*) const;
62 63
63 PersistentHeapVector<Member<EventDispatchMediator>> m_queuedEventDispatchMed iators; 64 template <typename Point>
64 unsigned m_scopingLevel; 65 Point applyPositionOverride(const Point& position, const Point& override);
65 66
66 static ScopedEventQueue* s_instance; 67 // Scroll position of frame. |x < 0| or |y < 0| disables the override for th e respective coordinate.
67 }; 68 IntPoint m_framePosition;
68 69
69 class EventQueueScope { 70 // Scroll position of visual viewport. |x < 0| or |y < 0| disables the overr ide for the respective coordinate.
70 WTF_MAKE_NONCOPYABLE(EventQueueScope); 71 DoublePoint m_visualViewportPosition;
71 STACK_ALLOCATED(); 72
72 public: 73 // Simulates visual viewport pinch zoom. |pageScale == 0| disables the overr ide.
73 EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); } 74 double m_pageScale;
74 ~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); }
75 }; 75 };
76 76
77 } // namespace blink 77 } // namespace blink
78 78
79 #endif // ScopedEventQueue_h 79 #endif // ScrollAndScaleEmulator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698