Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebViewFrameWidget.cpp
blobf0d8b8456823103c054bdc06ceb86ade1573e81d
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 #include "config.h"
6 #include "web/WebViewFrameWidget.h"
8 #include "web/WebLocalFrameImpl.h"
9 #include "web/WebViewImpl.h"
11 namespace blink {
13 WebViewFrameWidget::WebViewFrameWidget(WebWidgetClient* client, WebViewImpl& webView, WebLocalFrameImpl& mainFrame)
14 : m_client(client), m_webView(&webView), m_mainFrame(&mainFrame)
16 m_mainFrame->setFrameWidget(this);
19 WebViewFrameWidget::~WebViewFrameWidget()
23 void WebViewFrameWidget::close()
25 // Note: it's important to use the captured main frame pointer here. During
26 // a frame swap, the swapped frame is detached *after* the frame tree is
27 // updated. If the main frame is being swapped, then
28 // m_webView()->mainFrameImpl() will no longer point to the original frame.
29 m_mainFrame->setFrameWidget(nullptr);
30 m_mainFrame = nullptr;
31 m_webView = nullptr;
32 m_client = nullptr;
34 // Note: this intentionally does not forward to WebView::close(), to make it
35 // easier to untangle the cleanup logic later.
37 delete this;
40 WebSize WebViewFrameWidget::size()
42 return m_webView->size();
45 void WebViewFrameWidget::willStartLiveResize()
47 return m_webView->willStartLiveResize();
50 void WebViewFrameWidget::resize(const WebSize& size)
52 return m_webView->resize(size);
55 void WebViewFrameWidget::resizePinchViewport(const WebSize& size)
57 return m_webView->resizePinchViewport(size);
60 void WebViewFrameWidget::willEndLiveResize()
62 return m_webView->willEndLiveResize();
65 void WebViewFrameWidget::didEnterFullScreen()
67 return m_webView->didEnterFullScreen();
70 void WebViewFrameWidget::didExitFullScreen()
72 return m_webView->didExitFullScreen();
75 void WebViewFrameWidget::beginFrame(const WebBeginFrameArgs& frameTime)
77 return m_webView->beginFrame(frameTime);
80 void WebViewFrameWidget::layout()
82 return m_webView->layout();
85 void WebViewFrameWidget::paint(WebCanvas* canvas, const WebRect& viewPort)
87 return m_webView->paint(canvas, viewPort);
90 void WebViewFrameWidget::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& viewPort)
92 return m_webView->paintCompositedDeprecated(canvas, viewPort);
95 void WebViewFrameWidget::layoutAndPaintAsync(WebLayoutAndPaintAsyncCallback* callback)
97 return m_webView->layoutAndPaintAsync(callback);
100 void WebViewFrameWidget::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback* callback)
102 return m_webView->compositeAndReadbackAsync(callback);
105 void WebViewFrameWidget::themeChanged()
107 return m_webView->themeChanged();
110 bool WebViewFrameWidget::handleInputEvent(const WebInputEvent& event)
112 return m_webView->handleInputEvent(event);
115 void WebViewFrameWidget::setCursorVisibilityState(bool isVisible)
117 return m_webView->setCursorVisibilityState(isVisible);
120 bool WebViewFrameWidget::hasTouchEventHandlersAt(const WebPoint& point)
122 return m_webView->hasTouchEventHandlersAt(point);
125 void WebViewFrameWidget::applyViewportDeltas(
126 const WebFloatSize& pinchViewportDelta,
127 const WebFloatSize& layoutViewportDelta,
128 const WebFloatSize& elasticOverscrollDelta,
129 float scaleFactor,
130 float topControlsShownRatioDelta)
132 return m_webView->applyViewportDeltas(pinchViewportDelta, layoutViewportDelta, elasticOverscrollDelta, scaleFactor, topControlsShownRatioDelta);
135 void WebViewFrameWidget::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t rectId, const WebVector<WebFrameTimingEvent>& events)
137 return m_webView->recordFrameTimingEvent(eventType, rectId, events);
140 void WebViewFrameWidget::mouseCaptureLost()
142 return m_webView->mouseCaptureLost();
145 void WebViewFrameWidget::setFocus(bool enable)
147 return m_webView->setFocus(enable);
150 bool WebViewFrameWidget::setComposition(
151 const WebString& text,
152 const WebVector<WebCompositionUnderline>& underlines,
153 int selectionStart,
154 int selectionEnd)
156 return m_webView->setComposition(text, underlines, selectionStart, selectionEnd);
159 bool WebViewFrameWidget::confirmComposition()
161 return m_webView->confirmComposition();
164 bool WebViewFrameWidget::confirmComposition(ConfirmCompositionBehavior selectionBehavior)
166 return m_webView->confirmComposition(selectionBehavior);
169 bool WebViewFrameWidget::confirmComposition(const WebString& text)
171 return m_webView->confirmComposition(text);
174 bool WebViewFrameWidget::compositionRange(size_t* location, size_t* length)
176 return m_webView->compositionRange(location, length);
179 WebTextInputInfo WebViewFrameWidget::textInputInfo()
181 return m_webView->textInputInfo();
184 bool WebViewFrameWidget::selectionBounds(WebRect& anchor, WebRect& focus) const
186 return m_webView->selectionBounds(anchor, focus);
189 bool WebViewFrameWidget::selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const
191 return m_webView->selectionTextDirection(start, end);
194 bool WebViewFrameWidget::isSelectionAnchorFirst() const
196 return m_webView->isSelectionAnchorFirst();
199 bool WebViewFrameWidget::caretOrSelectionRange(size_t* location, size_t* length)
201 return m_webView->caretOrSelectionRange(location, length);
204 void WebViewFrameWidget::setTextDirection(WebTextDirection direction)
206 return m_webView->setTextDirection(direction);
209 bool WebViewFrameWidget::isAcceleratedCompositingActive() const
211 return m_webView->isAcceleratedCompositingActive();
214 void WebViewFrameWidget::willCloseLayerTreeView()
216 return m_webView->willCloseLayerTreeView();
219 void WebViewFrameWidget::didAcquirePointerLock()
221 return m_webView->didAcquirePointerLock();
224 void WebViewFrameWidget::didNotAcquirePointerLock()
226 return m_webView->didNotAcquirePointerLock();
229 void WebViewFrameWidget::didLosePointerLock()
231 return m_webView->didLosePointerLock();
234 void WebViewFrameWidget::didChangeWindowResizerRect()
236 return m_webView->didChangeWindowResizerRect();
239 WebColor WebViewFrameWidget::backgroundColor() const
241 return m_webView->backgroundColor();
244 WebPagePopup* WebViewFrameWidget::pagePopup() const
246 return m_webView->pagePopup();
249 void WebViewFrameWidget::setTopControlsHeight(float height, bool topControlsShrinkLayoutSize)
251 return m_webView->setTopControlsHeight(height, topControlsShrinkLayoutSize);
254 void WebViewFrameWidget::updateTopControlsState(WebTopControlsState constraints, WebTopControlsState current, bool animate)
256 return m_webView->updateTopControlsState(constraints, current, animate);
259 void WebViewFrameWidget::setVisibilityState(WebPageVisibilityState visibilityState, bool isInitialState)
261 return m_webView->setVisibilityState(visibilityState, isInitialState);
264 } // namespace blink