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

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

Powered by Google App Engine
This is Rietveld 408576698