| 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 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/frame/DOMVisualViewport.h" | 26 #include "core/frame/DOMVisualViewport.h" |
| 27 | 27 |
| 28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 29 #include "core/dom/Element.h" | 29 #include "core/dom/Element.h" |
| 30 #include "core/frame/FrameHost.h" | 30 #include "core/frame/FrameHost.h" |
| 31 #include "core/frame/FrameView.h" |
| 31 #include "core/frame/LocalDOMWindow.h" | 32 #include "core/frame/LocalDOMWindow.h" |
| 32 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 33 #include "core/frame/VisualViewport.h" | 34 #include "core/frame/VisualViewport.h" |
| 34 #include "core/page/Page.h" | 35 #include "core/page/Page.h" |
| 35 #include "core/style/ComputedStyle.h" | 36 #include "core/style/ComputedStyle.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 DOMVisualViewport::DOMVisualViewport(LocalDOMWindow* window) | 40 DOMVisualViewport::DOMVisualViewport(LocalDOMWindow* window) |
| 40 : m_window(window) | 41 : m_window(window) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 LocalFrame* frame = m_window->frame(); | 79 LocalFrame* frame = m_window->frame(); |
| 79 if (!frame || !frame->isMainFrame()) | 80 if (!frame || !frame->isMainFrame()) |
| 80 return 0; | 81 return 0; |
| 81 | 82 |
| 82 if (FrameHost* host = frame->host()) | 83 if (FrameHost* host = frame->host()) |
| 83 return host->visualViewport().scrollTop(); | 84 return host->visualViewport().scrollTop(); |
| 84 | 85 |
| 85 return 0; | 86 return 0; |
| 86 } | 87 } |
| 87 | 88 |
| 89 double DOMVisualViewport::pageX() |
| 90 { |
| 91 LocalFrame* frame = m_window->frame(); |
| 92 if (!frame) |
| 93 return 0; |
| 94 |
| 95 FrameView* view = frame->view(); |
| 96 if (!view) |
| 97 return 0; |
| 98 |
| 99 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 100 double viewportX = view->getScrollableArea()->scrollPositionDouble().x(); |
| 101 return adjustScrollForAbsoluteZoom(viewportX, frame->pageZoomFactor()); |
| 102 } |
| 103 |
| 104 double DOMVisualViewport::pageY() |
| 105 { |
| 106 LocalFrame* frame = m_window->frame(); |
| 107 if (!frame) |
| 108 return 0; |
| 109 |
| 110 FrameView* view = frame->view(); |
| 111 if (!view) |
| 112 return 0; |
| 113 |
| 114 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 115 double viewportY = view->getScrollableArea()->scrollPositionDouble().y(); |
| 116 return adjustScrollForAbsoluteZoom(viewportY, frame->pageZoomFactor()); |
| 117 } |
| 118 |
| 88 double DOMVisualViewport::clientWidth() | 119 double DOMVisualViewport::clientWidth() |
| 89 { | 120 { |
| 90 LocalFrame* frame = m_window->frame(); | 121 LocalFrame* frame = m_window->frame(); |
| 91 if (!frame) | 122 if (!frame) |
| 92 return 0; | 123 return 0; |
| 93 | 124 |
| 94 if (!frame->isMainFrame()) { | 125 if (!frame->isMainFrame()) { |
| 95 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars); | 126 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars); |
| 96 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), fram
e->pageZoomFactor()); | 127 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), fram
e->pageZoomFactor()); |
| 97 } | 128 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 if (!frame->isMainFrame()) | 159 if (!frame->isMainFrame()) |
| 129 return 1; | 160 return 1; |
| 130 | 161 |
| 131 if (FrameHost* host = m_window->frame()->host()) | 162 if (FrameHost* host = m_window->frame()->host()) |
| 132 return host->visualViewport().pageScale(); | 163 return host->visualViewport().pageScale(); |
| 133 | 164 |
| 134 return 0; | 165 return 0; |
| 135 } | 166 } |
| 136 | 167 |
| 137 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |