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

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMVisualViewport.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 years, 2 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) 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 const AtomicString& DOMVisualViewport::interfaceName() const { 50 const AtomicString& DOMVisualViewport::interfaceName() const {
51 return EventTargetNames::DOMVisualViewport; 51 return EventTargetNames::DOMVisualViewport;
52 } 52 }
53 53
54 ExecutionContext* DOMVisualViewport::getExecutionContext() const { 54 ExecutionContext* DOMVisualViewport::getExecutionContext() const {
55 return m_window->getExecutionContext(); 55 return m_window->getExecutionContext();
56 } 56 }
57 57
58 double DOMVisualViewport::scrollLeft() { 58 float DOMVisualViewport::scrollLeft() {
59 LocalFrame* frame = m_window->frame(); 59 LocalFrame* frame = m_window->frame();
60 if (!frame || !frame->isMainFrame()) 60 if (!frame || !frame->isMainFrame())
61 return 0; 61 return 0;
62 62
63 if (FrameHost* host = frame->host()) 63 if (FrameHost* host = frame->host())
64 return host->visualViewport().scrollLeft(); 64 return host->visualViewport().scrollLeft();
65 65
66 return 0; 66 return 0;
67 } 67 }
68 68
69 double DOMVisualViewport::scrollTop() { 69 float DOMVisualViewport::scrollTop() {
70 LocalFrame* frame = m_window->frame(); 70 LocalFrame* frame = m_window->frame();
71 if (!frame || !frame->isMainFrame()) 71 if (!frame || !frame->isMainFrame())
72 return 0; 72 return 0;
73 73
74 if (FrameHost* host = frame->host()) 74 if (FrameHost* host = frame->host())
75 return host->visualViewport().scrollTop(); 75 return host->visualViewport().scrollTop();
76 76
77 return 0; 77 return 0;
78 } 78 }
79 79
80 double DOMVisualViewport::pageX() { 80 float DOMVisualViewport::pageX() {
81 LocalFrame* frame = m_window->frame(); 81 LocalFrame* frame = m_window->frame();
82 if (!frame) 82 if (!frame)
83 return 0; 83 return 0;
84 84
85 FrameView* view = frame->view(); 85 FrameView* view = frame->view();
86 if (!view) 86 if (!view)
87 return 0; 87 return 0;
88 88
89 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 89 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
90 double viewportX = view->getScrollableArea()->scrollPositionDouble().x(); 90 float viewportX = view->getScrollableArea()->scrollOffset().width();
91 return adjustScrollForAbsoluteZoom(viewportX, frame->pageZoomFactor()); 91 return adjustScrollForAbsoluteZoom(viewportX, frame->pageZoomFactor());
92 } 92 }
93 93
94 double DOMVisualViewport::pageY() { 94 float DOMVisualViewport::pageY() {
95 LocalFrame* frame = m_window->frame(); 95 LocalFrame* frame = m_window->frame();
96 if (!frame) 96 if (!frame)
97 return 0; 97 return 0;
98 98
99 FrameView* view = frame->view(); 99 FrameView* view = frame->view();
100 if (!view) 100 if (!view)
101 return 0; 101 return 0;
102 102
103 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 103 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
104 double viewportY = view->getScrollableArea()->scrollPositionDouble().y(); 104 float viewportY = view->getScrollableArea()->scrollOffset().height();
105 return adjustScrollForAbsoluteZoom(viewportY, frame->pageZoomFactor()); 105 return adjustScrollForAbsoluteZoom(viewportY, frame->pageZoomFactor());
106 } 106 }
107 107
108 double DOMVisualViewport::clientWidth() { 108 double DOMVisualViewport::clientWidth() {
109 LocalFrame* frame = m_window->frame(); 109 LocalFrame* frame = m_window->frame();
110 if (!frame) 110 if (!frame)
111 return 0; 111 return 0;
112 112
113 if (!frame->isMainFrame()) { 113 if (!frame->isMainFrame()) {
114 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars); 114 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (!frame->isMainFrame()) 147 if (!frame->isMainFrame())
148 return 1; 148 return 1;
149 149
150 if (FrameHost* host = m_window->frame()->host()) 150 if (FrameHost* host = m_window->frame()->host())
151 return host->visualViewport().pageScale(); 151 return host->visualViewport().pageScale();
152 152
153 return 0; 153 return 0;
154 } 154 }
155 155
156 } // namespace blink 156 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMVisualViewport.h ('k') | third_party/WebKit/Source/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698