Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ios / web / public / web_state / page_scroll_state.h
blob9984019356ff6959ac933bd3225ee7fd2c4781fb
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.
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_
8 namespace web {
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();
23 // PageScrollStates cannot be applied until the scroll offset and zoom scale
24 // are both valid.
25 bool IsValid() const;
27 // The scroll offset is valid if its x and y values are both non-NAN.
28 bool IsScrollOffsetValid() const;
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;
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;
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;
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;
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;
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;
59 double zoom_scale() const { return zoom_scale_; }
60 void set_zoom_scale(double zoom_scale) { zoom_scale_ = zoom_scale; }
62 // Comparator operator.
63 bool operator==(const PageScrollState& other) const;
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_;
73 } // namespace web
75 #endif // IOS_WEB_PUBLIC_WEB_STATE_PAGE_SCROLL_STATE_H_