OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2016 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 const AtomicString& DOMVisualViewport::InterfaceName() const { | 49 const AtomicString& DOMVisualViewport::InterfaceName() const { |
50 return EventTargetNames::DOMVisualViewport; | 50 return EventTargetNames::DOMVisualViewport; |
51 } | 51 } |
52 | 52 |
53 ExecutionContext* DOMVisualViewport::GetExecutionContext() const { | 53 ExecutionContext* DOMVisualViewport::GetExecutionContext() const { |
54 return window_->GetExecutionContext(); | 54 return window_->GetExecutionContext(); |
55 } | 55 } |
56 | 56 |
57 float DOMVisualViewport::scrollLeft() { | 57 float DOMVisualViewport::offsetLeft() const { |
58 LocalFrame* frame = window_->GetFrame(); | 58 LocalFrame* frame = window_->GetFrame(); |
59 if (!frame || !frame->IsMainFrame()) | 59 if (!frame || !frame->IsMainFrame()) |
60 return 0; | 60 return 0; |
61 | 61 |
62 if (Page* page = frame->GetPage()) | 62 if (Page* page = frame->GetPage()) |
63 return page->GetVisualViewport().ScrollLeft(); | 63 return page->GetVisualViewport().OffsetLeft(); |
64 | 64 |
65 return 0; | 65 return 0; |
66 } | 66 } |
67 | 67 |
68 float DOMVisualViewport::scrollTop() { | 68 float DOMVisualViewport::offsetTop() const { |
69 LocalFrame* frame = window_->GetFrame(); | 69 LocalFrame* frame = window_->GetFrame(); |
70 if (!frame || !frame->IsMainFrame()) | 70 if (!frame || !frame->IsMainFrame()) |
71 return 0; | 71 return 0; |
72 | 72 |
73 if (Page* page = frame->GetPage()) | 73 if (Page* page = frame->GetPage()) |
74 return page->GetVisualViewport().ScrollTop(); | 74 return page->GetVisualViewport().OffsetTop(); |
75 | 75 |
76 return 0; | 76 return 0; |
77 } | 77 } |
78 | 78 |
79 float DOMVisualViewport::pageX() { | 79 float DOMVisualViewport::pageLeft() const { |
80 LocalFrame* frame = window_->GetFrame(); | 80 LocalFrame* frame = window_->GetFrame(); |
81 if (!frame) | 81 if (!frame) |
82 return 0; | 82 return 0; |
83 | 83 |
84 FrameView* view = frame->View(); | 84 FrameView* view = frame->View(); |
85 if (!view) | 85 if (!view) |
86 return 0; | 86 return 0; |
87 | 87 |
88 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 88 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
89 float viewport_x = view->GetScrollableArea()->GetScrollOffset().Width(); | 89 float viewport_x = view->GetScrollableArea()->GetScrollOffset().Width(); |
90 return AdjustScrollForAbsoluteZoom(viewport_x, frame->PageZoomFactor()); | 90 return AdjustScrollForAbsoluteZoom(viewport_x, frame->PageZoomFactor()); |
91 } | 91 } |
92 | 92 |
93 float DOMVisualViewport::pageY() { | 93 float DOMVisualViewport::pageTop() const { |
94 LocalFrame* frame = window_->GetFrame(); | 94 LocalFrame* frame = window_->GetFrame(); |
95 if (!frame) | 95 if (!frame) |
96 return 0; | 96 return 0; |
97 | 97 |
98 FrameView* view = frame->View(); | 98 FrameView* view = frame->View(); |
99 if (!view) | 99 if (!view) |
100 return 0; | 100 return 0; |
101 | 101 |
102 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 102 frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
103 float viewport_y = view->GetScrollableArea()->GetScrollOffset().Height(); | 103 float viewport_y = view->GetScrollableArea()->GetScrollOffset().Height(); |
104 return AdjustScrollForAbsoluteZoom(viewport_y, frame->PageZoomFactor()); | 104 return AdjustScrollForAbsoluteZoom(viewport_y, frame->PageZoomFactor()); |
105 } | 105 } |
106 | 106 |
107 double DOMVisualViewport::clientWidth() { | 107 double DOMVisualViewport::width() const { |
108 LocalFrame* frame = window_->GetFrame(); | 108 LocalFrame* frame = window_->GetFrame(); |
109 if (!frame) | 109 if (!frame) |
110 return 0; | 110 return 0; |
111 | 111 |
112 if (!frame->IsMainFrame()) { | 112 if (!frame->IsMainFrame()) { |
113 FloatSize viewport_size = window_->GetViewportSize(kExcludeScrollbars); | 113 FloatSize viewport_size = window_->GetViewportSize(kExcludeScrollbars); |
114 return AdjustForAbsoluteZoom(ExpandedIntSize(viewport_size).Width(), | 114 return AdjustForAbsoluteZoom(ExpandedIntSize(viewport_size).Width(), |
115 frame->PageZoomFactor()); | 115 frame->PageZoomFactor()); |
116 } | 116 } |
117 | 117 |
118 if (Page* page = frame->GetPage()) | 118 if (Page* page = frame->GetPage()) |
119 return page->GetVisualViewport().ClientWidth(); | 119 return page->GetVisualViewport().Width(); |
120 | 120 |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 | 123 |
124 double DOMVisualViewport::clientHeight() { | 124 double DOMVisualViewport::height() const { |
125 LocalFrame* frame = window_->GetFrame(); | 125 LocalFrame* frame = window_->GetFrame(); |
126 if (!frame) | 126 if (!frame) |
127 return 0; | 127 return 0; |
128 | 128 |
129 if (!frame->IsMainFrame()) { | 129 if (!frame->IsMainFrame()) { |
130 FloatSize viewport_size = window_->GetViewportSize(kExcludeScrollbars); | 130 FloatSize viewport_size = window_->GetViewportSize(kExcludeScrollbars); |
131 return AdjustForAbsoluteZoom(ExpandedIntSize(viewport_size).Height(), | 131 return AdjustForAbsoluteZoom(ExpandedIntSize(viewport_size).Height(), |
132 frame->PageZoomFactor()); | 132 frame->PageZoomFactor()); |
133 } | 133 } |
134 | 134 |
135 if (Page* page = frame->GetPage()) | 135 if (Page* page = frame->GetPage()) |
136 return page->GetVisualViewport().ClientHeight(); | 136 return page->GetVisualViewport().Height(); |
137 | 137 |
138 return 0; | 138 return 0; |
139 } | 139 } |
140 | 140 |
141 double DOMVisualViewport::scale() { | 141 double DOMVisualViewport::scale() const { |
142 LocalFrame* frame = window_->GetFrame(); | 142 LocalFrame* frame = window_->GetFrame(); |
143 if (!frame) | 143 if (!frame) |
144 return 0; | 144 return 0; |
145 | 145 |
146 if (!frame->IsMainFrame()) | 146 if (!frame->IsMainFrame()) |
147 return 1; | 147 return 1; |
148 | 148 |
149 if (Page* page = window_->GetFrame()->GetPage()) | 149 if (Page* page = window_->GetFrame()->GetPage()) |
150 return page->GetVisualViewport().PageScale(); | 150 return page->GetVisualViewport().ScaleForVisualViewport(); |
151 | 151 |
152 return 0; | 152 return 0; |
153 } | 153 } |
154 | 154 |
155 } // namespace blink | 155 } // namespace blink |
OLD | NEW |