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

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: More review updates 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
59 , public PageWidgetEventHandler
60 , public RefCounted<WebFrameWidgetImpl> {
61 public:
62 static WebFrameWidgetImpl* create(WebWidgetClient*, WebView*);
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 float pageScaleDelta,
95 float topControlsDelta) override;
96 void mouseCaptureLost() override;
97 void setFocus(bool enable) override;
98 bool setComposition(
99 const WebString& text,
100 const WebVector<WebCompositionUnderline>& underlines,
101 int selectionStart, int selectionEnd) override;
102 bool confirmComposition() override;
103 bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) overri de;
104 bool confirmComposition(const WebString& text) override;
105 bool compositionRange(size_t* location, size_t* length) override;
106 WebTextInputInfo textInputInfo() override;
107 WebColor backgroundColor() const override;
108 bool selectionBounds(WebRect& anchor, WebRect& focus) const override;
109 bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const override;
110 bool isSelectionAnchorFirst() const override;
111 bool caretOrSelectionRange(size_t* location, size_t* length) override;
112 void setTextDirection(WebTextDirection) override;
113 bool isAcceleratedCompositingActive() const override;
114 void willCloseLayerTreeView() override;
115 void didChangeWindowResizerRect() override;
116
117 WebWidgetClient* client() const { return m_client; }
118
119 // WebFrameWidget functions:
120 void setLocalRoot(WebLocalFrame*) override;
121
122 Frame* focusedCoreFrame() const;
123
124 // Returns the currently focused Element or null if no element has focus.
125 Element* focusedElement() const;
126
127 void hasTouchEventHandlers(bool);
128
129 void scheduleAnimation();
130
131 RenderLayerCompositor* compositor() const;
132 void suppressInvalidations(bool enable);
133 void setRootGraphicsLayer(GraphicsLayer*);
134
135 // Exposed for the purpose of overriding device metrics.
136 void sendResizeEventAndRepaint();
137
138 void updateMainFrameLayoutSize();
139
140 // Returns the page object associated with this widget. This may be null whe n
141 // the page is shutting down, but will be valid at all other times.
142 Page* page() const
143 {
144 return m_page;
145 }
146
147 // Returns true if the event leads to scrolling.
148 static bool mapKeyCodeForScroll(
149 int keyCode,
150 ScrollDirection*,
151 ScrollGranularity*);
152
153 private:
154 friend class WebFrameWidget; // For WebFrameWidget::create.
155 friend class WTF::RefCounted<WebFrameWidgetImpl>;
156
157 explicit WebFrameWidgetImpl(WebWidgetClient*, WebView*);
158 ~WebFrameWidgetImpl();
159
160 // Returns true if the event was actually processed.
161 bool keyEventDefault(const WebKeyboardEvent&);
162
163 // Returns true if the view was scrolled.
164 bool scrollViewWithKeyboard(int keyCode, int modifiers);
165
166 void initializeLayerTreeView();
167
168 void setIsAcceleratedCompositingActive(bool);
169 void updateLayerTreeViewport();
170 void updateLayerTreeBackgroundColor();
171 void updateLayerTreeDeviceScaleFactor();
172
173 bool isTransparent() const;
174
175 // PageWidgetEventHandler functions
176 void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
177 void handleMouseDown(LocalFrame&, const WebMouseEvent&) override;
178 void handleMouseUp(LocalFrame&, const WebMouseEvent&) override;
179 bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) override;
180 bool handleGestureEvent(const WebGestureEvent&) override;
181 bool handleKeyEvent(const WebKeyboardEvent&) override;
182 bool handleCharEvent(const WebKeyboardEvent&) override;
183
184 WebWidgetClient* m_client;
185
186 // WebFrameWidget is associated with a subtree of the frame tree, correspond ing to a maximal
187 // connected tree of LocalFrames. This member points to the root of that sub tree.
188 WebLocalFrameImpl* m_localRoot;
189
190 WebSize m_size;
191
192 // If set, the (plugin) node which has mouse capture.
193 RefPtrWillBePersistent<Node> m_mouseCaptureNode;
194 RefPtr<UserGestureToken> m_mouseCaptureGestureToken;
195
196 WebLayerTreeView* m_layerTreeView;
197 WebLayer* m_rootLayer;
198 GraphicsLayer* m_rootGraphicsLayer;
199 bool m_isAcceleratedCompositingActive;
200 bool m_layerTreeViewClosed;
201
202 Page* m_page;
203 WebViewImpl* m_webView;
dcheng 2014/12/16 20:13:06 What's the story for lifetimes for Page/WebViewImp
kenrb 2014/12/16 22:04:12 I might not understand the lifetime issues here --
dcheng 2014/12/16 23:20:20 Well, today, WebView (and the WebWidget) own the p
kenrb 2014/12/17 14:52:31 This is fine, I can add FIXMEs for the open questi
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