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

Side by Side Diff: ios/web/public/web_state/page_scroll_state.h

Issue 1028603004: Upstream ios/web/navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-testing
Patch Set: Rebase and resync Created 5 years, 9 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
« no previous file with comments | « ios/web/public/navigation_item.h ('k') | ios/web/public/web_state/page_scroll_state.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_
7
8 namespace web {
9
10 // Class used to represent the scrolling offset and the zoom scale of a webview.
11 class PageScrollState {
12 public:
13 // Default constructor. Initializes scroll offsets and zoom scales to NAN.
14 PageScrollState();
15 // Constructor with initial values.
16 PageScrollState(double scroll_offset_x,
17 double scroll_offset_y,
18 double minimum_zoom_scale,
19 double maximum_zoom_scale,
20 double zoom_scale);
21 ~PageScrollState();
22
23 // PageScrollStates cannot be applied until the scroll offset and zoom scale
24 // are both valid.
25 bool IsValid() const;
26
27 // The scroll offset is valid if its x and y values are both non-NAN.
28 bool IsScrollOffsetValid() const;
29
30 // Non-legacy zoom scales are valid if all three values are non-NAN and the
31 // zoom scale is within the minimum and maximum scales. Legacy-format
32 // PageScrollStates are considered valid if the minimum and maximum scales
33 // are NAN and the zoom scale is greater than zero.
34 bool IsZoomScaleValid() const;
35
36 // PageScrollStates restored from the legacy serialization format make
37 // assumptions about the web view's implementation of zooming, and contain a
38 // non-NAN zoom scale and a NAN minimum and maximum scale. Legacy zoom scales
39 // can only be applied to CRWUIWebViewWebControllers.
40 bool IsZoomScaleLegacyFormat() const;
41
42 // Accessors for scroll offsets and zoom scale.
43 double scroll_offset_x() const { return scroll_offset_x_; }
44 void set_scroll_offset_x(double scroll_offset_x) {
45 scroll_offset_x_ = scroll_offset_x;
46 }
47 double scroll_offset_y() const { return scroll_offset_y_; }
48 void set_scroll_offset_y(double scroll_offset_y) {
49 scroll_offset_y_ = scroll_offset_y;
50 }
51 double minimum_zoom_scale() const { return minimum_zoom_scale_; }
52 void set_minimum_zoom_scale(double minimum_zoom_scale) {
53 minimum_zoom_scale_ = minimum_zoom_scale;
54 }
55 double maximum_zoom_scale() const { return maximum_zoom_scale_; }
56 void set_maximum_zoom_scale(double maximum_zoom_scale) {
57 maximum_zoom_scale_ = maximum_zoom_scale;
58 }
59 double zoom_scale() const { return zoom_scale_; }
60 void set_zoom_scale(double zoom_scale) { zoom_scale_ = zoom_scale; }
61
62 // Comparator operator.
63 bool operator==(const PageScrollState& other) const;
64
65 private:
66 double scroll_offset_x_;
67 double scroll_offset_y_;
68 double minimum_zoom_scale_;
69 double maximum_zoom_scale_;
70 double zoom_scale_;
71 };
72
73 } // namespace web
74
75 #endif // IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_
OLDNEW
« no previous file with comments | « ios/web/public/navigation_item.h ('k') | ios/web/public/web_state/page_scroll_state.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698