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

Side by Side Diff: Source/web/WebFrameWidgetImpl.h

Issue 638003004: Introduce WebFrameWidget to Blink (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WebFrameWidget to take a WebLocalFrame on creation Created 6 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 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 are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef WebFrameWidgetImpl_h
32 #define WebFrameWidgetImpl_h
33
34 #include "platform/graphics/GraphicsLayer.h"
35 #include "platform/scroll/ScrollTypes.h"
36 #include "public/platform/WebPoint.h"
37 #include "public/platform/WebSize.h"
38 #include "public/web/WebFrameWidget.h"
39 #include "public/web/WebInputEvent.h"
40 #include "web/PageWidgetDelegate.h"
41 #include "wtf/OwnPtr.h"
42 #include "wtf/RefCounted.h"
43
44 namespace blink {
45 class Frame;
46 class Element;
47 class LocalFrame;
48 class Page;
49 class RenderLayerCompositor;
50 class UserGestureToken;
51 class WebLayer;
52 class WebLayerTreeView;
53 class WebLocalFrameImpl;
54 class WebMouseEvent;
55 class WebMouseWheelEvent;
56 class WebViewImpl;
57
58 class WebFrameWidgetImpl : public WebFrameWidget
dcheng 2014/12/17 23:22:53 class WebFrameWidgetImpl final
kenrb 2014/12/18 18:46:29 Done.
59 , public PageWidgetEventHandler
60 , public RefCounted<WebFrameWidgetImpl> {
61 public:
62 static WebFrameWidgetImpl* create(WebWidgetClient*, WebLocalFrame*);
63
64 // WebWidget functions:
65 void close() override;
66 WebSize size() override;
67 void willStartLiveResize() override;
68 void resize(const WebSize&) override;
69 void resizePinchViewport(const WebSize&) override;
70 void willEndLiveResize() override;
71 void willEnterFullScreen() override;
72 void didEnterFullScreen() override;
73 void willExitFullScreen() override;
74 void didExitFullScreen() override;
75 void beginFrame(const WebBeginFrameArgs&) override;
76 void layout() override;
77 void paint(WebCanvas*, const WebRect&) override;
78 void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) overri de;
79 bool isTrackingRepaints() const override;
80 void themeChanged() override;
81 bool handleInputEvent(const WebInputEvent&) override;
82 void setCursorVisibilityState(bool isVisible) override;
83 bool hasTouchEventHandlersAt(const WebPoint&) override;
84
85 // FIXME(bokan): Old pinch path only - This should be removed once old pinch
86 // is removed.
87 void applyViewportDeltas(
88 const WebSize& scrollDelta,
89 float pageScaleDelta,
90 float topControlsDelta) override;
91 void applyViewportDeltas(
92 const WebSize& pinchViewportDelta,
93 const WebSize& mainFrameDelta,
94 const WebFloatSize& elasticOverscrollDelta,
95 float pageScaleDelta,
96 float topControlsDelta) override;
97 void mouseCaptureLost() override;
98 void setFocus(bool enable) override;
99 bool setComposition(
100 const WebString& text,
101 const WebVector<WebCompositionUnderline>& underlines,
102 int selectionStart, int selectionEnd) override;
103 bool confirmComposition() override;
104 bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) overri de;
105 bool confirmComposition(const WebString& text) override;
106 bool compositionRange(size_t* location, size_t* length) override;
107 WebTextInputInfo textInputInfo() override;
108 WebColor backgroundColor() const override;
109 bool selectionBounds(WebRect& anchor, WebRect& focus) const override;
110 bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const override;
111 bool isSelectionAnchorFirst() const override;
112 bool caretOrSelectionRange(size_t* location, size_t* length) override;
113 void setTextDirection(WebTextDirection) override;
114 bool isAcceleratedCompositingActive() const override;
115 void willCloseLayerTreeView() override;
116 void didChangeWindowResizerRect() override;
117
118 WebWidgetClient* client() const { return m_client; }
119
120 Frame* focusedCoreFrame() const;
121
122 // Returns the currently focused Element or null if no element has focus.
123 Element* focusedElement() const;
124
125 void hasTouchEventHandlers(bool);
dcheng 2014/12/17 23:22:53 Nit: setHasTouchEventHandlers()
kenrb 2014/12/18 18:46:29 I removed it instead. That was from WebViewImpl bu
126
127 void scheduleAnimation();
128
129 RenderLayerCompositor* compositor() const;
130 void suppressInvalidations(bool enable);
131 void setRootGraphicsLayer(GraphicsLayer*);
132
133 // Exposed for the purpose of overriding device metrics.
134 void sendResizeEventAndRepaint();
135
136 void updateMainFrameLayoutSize();
137
138 // Returns the page object associated with this widget. This may be null whe n
139 // the page is shutting down, but will be valid at all other times.
140 Page* page() const
dcheng 2014/12/17 23:22:53 Nit: collapse this into one line.
kenrb 2014/12/18 18:46:29 Done.
141 {
142 return m_page;
143 }
144
145 // Returns true if the event leads to scrolling.
146 static bool mapKeyCodeForScroll(
147 int keyCode,
148 ScrollDirection*,
149 ScrollGranularity*);
150
151 private:
152 friend class WebFrameWidget; // For WebFrameWidget::create.
153 friend class WTF::RefCounted<WebFrameWidgetImpl>;
154
155 explicit WebFrameWidgetImpl(WebWidgetClient*, WebLocalFrame*);
156 ~WebFrameWidgetImpl();
157
158 // Returns true if the event was actually processed.
159 bool keyEventDefault(const WebKeyboardEvent&);
160
161 // Returns true if the view was scrolled.
162 bool scrollViewWithKeyboard(int keyCode, int modifiers);
163
164 void initializeLayerTreeView();
165
166 void setIsAcceleratedCompositingActive(bool);
167 void updateLayerTreeViewport();
168 void updateLayerTreeBackgroundColor();
169 void updateLayerTreeDeviceScaleFactor();
170
171 bool isTransparent() const;
172
173 // PageWidgetEventHandler functions
174 void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
175 void handleMouseDown(LocalFrame&, const WebMouseEvent&) override;
176 void handleMouseUp(LocalFrame&, const WebMouseEvent&) override;
177 bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) override;
178 bool handleGestureEvent(const WebGestureEvent&) override;
179 bool handleKeyEvent(const WebKeyboardEvent&) override;
180 bool handleCharEvent(const WebKeyboardEvent&) override;
181
182 WebWidgetClient* m_client;
183
184 // WebFrameWidget is associated with a subtree of the frame tree, correspond ing to a maximal
185 // connected tree of LocalFrames. This member points to the root of that sub tree.
186 WebLocalFrameImpl* m_localRoot;
187
188 WebSize m_size;
189
190 // If set, the (plugin) node which has mouse capture.
191 RefPtrWillBePersistent<Node> m_mouseCaptureNode;
192 RefPtr<UserGestureToken> m_mouseCaptureGestureToken;
193
194 WebLayerTreeView* m_layerTreeView;
195 WebLayer* m_rootLayer;
196 GraphicsLayer* m_rootGraphicsLayer;
197 bool m_isAcceleratedCompositingActive;
198 bool m_layerTreeViewClosed;
199
200 // FIXME: The lifetimes of these objects relative to the WebFrameWidget are not clear,
201 // and it might be better to replace them with lookups based on the localRoo t.
202 WebViewImpl* m_webView;
203 Page* m_page;
204
205 bool m_suppressNextKeypressEvent;
206
207 bool m_ignoreInputEvents;
208
209 static const WebInputEvent* m_currentInputEvent;
210
211 WebColor m_baseBackgroundColor;
212 WebColor m_backgroundColorOverride;
213 };
214
215 } // namespace blink
216
217 #endif
218
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698