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

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

Issue 2070563002: Seperate DOMVisualViewport from Blink's VisualViewport class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 6 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
(Empty)
1 /*
2 * Copyright (C) 2016 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
24 */
25
26 #include "core/frame/DOMVisualViewport.h"
27
28 #include "core/dom/Document.h"
29 #include "core/dom/Element.h"
30 #include "core/frame/FrameHost.h"
31 #include "core/frame/LocalDOMWindow.h"
32 #include "core/frame/LocalFrame.h"
33 #include "core/frame/VisualViewport.h"
34 #include "core/page/Page.h"
35 #include "core/style/ComputedStyle.h"
36
37 namespace blink {
38
39 DOMVisualViewport::DOMVisualViewport(LocalDOMWindow* window)
40 : m_window(window) {}
41
42 DEFINE_TRACE(DOMVisualViewport)
43 {
44 visitor->trace(m_window);
45 }
46
47 double DOMVisualViewport::scrollLeft()
48 {
49 LocalFrame* frame = m_window->frame();
50 if (!frame || !frame->isMainFrame())
51 return 0;
52
53 if (FrameHost* host = frame->host())
54 return host->visualViewport().scrollLeft();
55
56 return 0;
57 }
58
59 double DOMVisualViewport::scrollTop()
60 {
61 LocalFrame* frame = m_window->frame();
62 if (!frame || !frame->isMainFrame())
63 return 0;
64
65 if (FrameHost* host = frame->host())
66 return host->visualViewport().scrollTop();
67
68 return 0;
69 }
70
71 void DOMVisualViewport::setScrollLeft(double x)
72 {
73 LocalFrame* frame = m_window->frame();
74 if (!frame || !frame->isMainFrame())
75 return;
76
77 if (FrameHost* host = frame->host())
78 host->visualViewport().setScrollLeft(x);
79 }
80
81 void DOMVisualViewport::setScrollTop(double y)
82 {
83 LocalFrame* frame = m_window->frame();
84 if (!frame || !frame->isMainFrame())
85 return;
86
87 if (FrameHost* host = frame->host())
88 host->visualViewport().setScrollTop(y);
89 }
90
91 double DOMVisualViewport::clientWidth()
92 {
93 LocalFrame* frame = m_window->frame();
94 if (!frame)
95 return 0;
96
97 if (!frame->isMainFrame()) {
98 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars);
99 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), fram e->pageZoomFactor());
100 }
101
102 if (FrameHost* host = frame->host())
103 return host->visualViewport().clientWidth();
104
105 return 0;
106 }
107
108 double DOMVisualViewport::clientHeight()
109 {
110 LocalFrame* frame = m_window->frame();
111 if (!frame)
112 return 0;
113
114 if (!frame->isMainFrame()) {
115 FloatSize viewportSize = m_window->getViewportSize(ExcludeScrollbars);
116 return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), fra me->pageZoomFactor());
117 }
118
119 if (FrameHost* host = frame->host())
120 return host->visualViewport().clientHeight();
121
122 return 0;
123 }
124
125 double DOMVisualViewport::pageScale()
126 {
127 LocalFrame* frame = m_window->frame();
128 if (!frame)
129 return 0;
130
131 if (!frame->isMainFrame())
132 return 1;
133
134 if (FrameHost* host = m_window->frame()->host())
135 return host->visualViewport().pageScale();
136
137 return 0;
138 }
139
140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698