1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be found
3 // in the LICENSE file.
5 #ifndef WebViewFrameWidget_h
6 #define WebViewFrameWidget_h
8 #include "platform/heap/Handle.h"
9 #include "public/web/WebFrameWidget.h"
10 #include "wtf/Noncopyable.h"
11 #include "wtf/RefPtr.h"
15 class WebLocalFrameImpl
;
17 class WebWidgetClient
;
19 // Shim class to help normalize the widget interfaces in the Blink public API.
20 // For OOPI, subframes have WebFrameWidgets for input and rendering.
21 // Unfortunately, the main frame still uses WebView's WebWidget for input and
22 // rendering. This results in complex code, since there are two different
23 // implementations of WebWidget and code needs to have branches to handle both
25 // This class allows a Blink embedder to create a WebFrameWidget that can be
26 // used for the main frame. Internally, it currently wraps WebView's WebWidget
27 // and just forwards almost everything to it.
28 // After the embedder starts using a WebFrameWidget for the main frame,
29 // WebView will be updated to no longer inherit WebWidget. The eventual goal is
30 // to unfork the widget code duplicated in WebFrameWidgetImpl and WebViewImpl
32 // A more detailed writeup of this transition can be read at
33 // https://goo.gl/7yVrnb.
34 class WebViewFrameWidget
: public WebFrameWidget
{
35 WTF_MAKE_NONCOPYABLE(WebViewFrameWidget
);
37 explicit WebViewFrameWidget(WebWidgetClient
*, WebViewImpl
&, WebLocalFrameImpl
&);
38 virtual ~WebViewFrameWidget();
40 // WebFrameWidget overrides:
41 void close() override
;
42 WebSize
size() override
;
43 void willStartLiveResize() override
;
44 void resize(const WebSize
&) override
;
45 void resizePinchViewport(const WebSize
&) override
;
46 void willEndLiveResize() override
;
47 void didEnterFullScreen() override
;
48 void didExitFullScreen() override
;
49 void beginFrame(const WebBeginFrameArgs
& frameTime
) override
;
50 void layout() override
;
51 void paint(WebCanvas
*, const WebRect
& viewPort
) override
;
52 void paintCompositedDeprecated(WebCanvas
*, const WebRect
&) override
;
53 void layoutAndPaintAsync(WebLayoutAndPaintAsyncCallback
*) override
;
54 void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback
*) override
;
55 void themeChanged() override
;
56 bool handleInputEvent(const WebInputEvent
&) override
;
57 void setCursorVisibilityState(bool isVisible
) override
;
58 bool hasTouchEventHandlersAt(const WebPoint
&) override
;
59 void applyViewportDeltas(
60 const WebFloatSize
& pinchViewportDelta
,
61 const WebFloatSize
& layoutViewportDelta
,
62 const WebFloatSize
& elasticOverscrollDelta
,
64 float topControlsShownRatioDelta
) override
;
65 void recordFrameTimingEvent(FrameTimingEventType
, int64_t rectId
, const WebVector
<WebFrameTimingEvent
>& events
) override
;
66 void mouseCaptureLost() override
;
67 void setFocus(bool) override
;
69 const WebString
& text
,
70 const WebVector
<WebCompositionUnderline
>& underlines
,
72 int selectionEnd
) override
;
73 bool confirmComposition() override
;
74 bool confirmComposition(ConfirmCompositionBehavior selectionBehavior
) override
;
75 bool confirmComposition(const WebString
& text
) override
;
76 bool compositionRange(size_t* location
, size_t* length
) override
;
77 WebTextInputInfo
textInputInfo() override
;
78 bool selectionBounds(WebRect
& anchor
, WebRect
& focus
) const override
;
79 bool selectionTextDirection(WebTextDirection
& start
, WebTextDirection
& end
) const override
;
80 bool isSelectionAnchorFirst() const override
;
81 bool caretOrSelectionRange(size_t* location
, size_t* length
) override
;
82 void setTextDirection(WebTextDirection
) override
;
83 bool isAcceleratedCompositingActive() const override
;
84 bool isWebView() const override
{ return false; }
85 bool isPagePopup() const override
{ return false; }
86 void willCloseLayerTreeView() override
;
87 void didAcquirePointerLock() override
;
88 void didNotAcquirePointerLock() override
;
89 void didLosePointerLock() override
;
90 void didChangeWindowResizerRect() override
;
91 WebColor
backgroundColor() const override
;
92 WebPagePopup
* pagePopup() const override
;
93 void setTopControlsHeight(float height
, bool topControlsShrinkLayoutSize
) override
;
94 void updateTopControlsState(WebTopControlsState constraints
, WebTopControlsState current
, bool animate
) override
;
95 void setVisibilityState(WebPageVisibilityState
, bool isInitialState
) override
;
96 bool forSubframe() const { return false; }
99 WebWidgetClient
* m_client
;
100 RefPtr
<WebViewImpl
> m_webView
;
101 RefPtrWillBePersistent
<WebLocalFrameImpl
> m_mainFrame
;
106 #endif // WebViewFrameWidget_h