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

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: 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/LocalFrame.h"
32 #include "core/frame/VisualViewport.h"
33 #include "core/page/Page.h"
34
35 namespace blink {
36
37 DOMVisualViewport::DOMVisualViewport(LocalDOMWindow* window)
38 : m_window(window) {}
39
40 DEFINE_TRACE(DOMVisualViewport)
41 {
42 visitor->trace(m_window);
43 }
44
45 bool DOMVisualViewport::isMainFrame() const
46 {
47 LocalFrame* frame = m_window->frame();
48 if (!frame)
49 return false;
50 return frame->isMainFrame();
51 }
52
53 double DOMVisualViewport::scrollLeft()
54 {
55 if (!isMainFrame())
56 return 0;
57
58 if (FrameHost* host = m_window->frame()->host())
59 return host->visualViewport().scrollLeft();
60
61 return 0;
62 }
63
64 double DOMVisualViewport::scrollTop()
65 {
66 if (!isMainFrame())
67 return 0;
68
69 if (FrameHost* host = m_window->frame()->host())
70 return host->visualViewport().scrollTop();
71
72 return 0;
73 }
74
75 void DOMVisualViewport::setScrollLeft(double x)
76 {
77 if (!isMainFrame())
78 return;
79
80 if (FrameHost* host = m_window->frame()->host())
81 host->visualViewport().setScrollLeft(x);
82 }
83
84 void DOMVisualViewport::setScrollTop(double y)
85 {
86 if (!isMainFrame())
87 return;
88
89 if (FrameHost* host = m_window->frame()->host())
90 host->visualViewport().setScrollTop(y);
91 }
92
93 double DOMVisualViewport::clientWidth()
94 {
95 if (!isMainFrame())
96 return m_window->document()->documentElement()->clientWidth();
bokan 2016/06/16 07:22:43 This is wrong, it should be the window's FrameView
ymalik 2016/06/20 15:52:56 Done.
97
98 if (FrameHost* host = m_window->frame()->host())
99 return host->visualViewport().clientWidth();
100
101 return 0;
102 }
103
104 double DOMVisualViewport::clientHeight()
105 {
106 if (!isMainFrame())
107 return m_window->document()->documentElement()->clientHeight();
108
109 if (FrameHost* host = m_window->frame()->host())
110 return host->visualViewport().clientHeight();
111
112 return 0;
113 }
114
115 double DOMVisualViewport::pageScale()
116 {
117 if (!isMainFrame())
118 return 1;
119
120 if (FrameHost* host = m_window->frame()->host())
121 return host->visualViewport().pageScale();
122
123 return 1;
124 }
125
126 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698