TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) { registerMockedHttpURLLoad("long_scroll.html"); FrameTestHelpers::WebViewHelper webViewHelper; WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, 0); webView->resize(WebSize(1000, 1000)); webView->updateAllLifecyclePhases(); WebViewImpl* webViewImpl = toWebViewImpl(webView); FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); loader.setLoadType(FrameLoadTypeBackForward); webViewImpl->setPageScaleFactor(3.0f); webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.currentItem()->setPageScaleFactor(0); loader.currentItem()->setScrollPoint(WebPoint(0, 400)); // FrameLoader::restoreScrollPositionAndViewState flows differently if scale is zero. loader.restoreScrollPositionAndViewState(); // Expect that only the scroll position was restored. EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); }
WebDevToolsFrontend* WebDevToolsFrontend::create( WebView* view, WebDevToolsFrontendClient* client, const WebString& applicationLocale) { return new WebDevToolsFrontendImpl(toWebViewImpl(view), client); }
TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) { registerMockedHttpURLLoad("long_scroll.html"); FrameTestHelpers::WebViewHelper webViewHelper; WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, 0); webView->resize(WebSize(1000, 1000)); webView->updateAllLifecyclePhases(); WebViewImpl* webViewImpl = toWebViewImpl(webView); FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); loader.setLoadType(FrameLoadTypeBackForward); webViewImpl->setPageScaleFactor(3.0f); webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.currentItem()->setPageScaleFactor(2); loader.currentItem()->setScrollPoint(WebPoint(0, 200)); // Flip back the wasScrolledByUser flag which was set to true by setPageScaleFactor // because otherwise FrameLoader::restoreScrollPositionAndViewState does nothing. loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.restoreScrollPositionAndViewState(); // Expect that both scroll and scale were restored. EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); }
Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, NavigationPolicy navigationPolicy, ShouldSetOpener shouldSetOpener) { if (!m_webView->client()) return nullptr; WebNavigationPolicy policy = effectiveNavigationPolicy(navigationPolicy, features); ASSERT(frame->document()); Fullscreen::fullyExitFullscreen(*frame->document()); WebViewImpl* newView = toWebViewImpl( m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSetOpener == NeverSetOpener)); if (!newView) return nullptr; return newView->page(); }
void WebPageSerializer::serialize(WebView* view, WebVector<WebPageSerializer::Resource>* resourcesParam) { Vector<SerializedResource> resources; PageSerializer serializer(&resources); serializer.serialize(toWebViewImpl(view)->page()); Vector<Resource> result; for (Vector<SerializedResource>::const_iterator iter = resources.begin(); iter != resources.end(); ++iter) { Resource resource; resource.url = iter->url; resource.mimeType = iter->mimeType.ascii(); // FIXME: we are copying all the resource data here. Idealy we would have a WebSharedData(). resource.data = WebCString(iter->data->data(), iter->data->size()); result.append(resource); } *resourcesParam = result; }
WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginType, WebFrame* frame) { ASSERT(!m_helperPlugin); m_helperPlugin = toWebViewImpl(frame->view())->createHelperPlugin(pluginType, frame->document()); if (!m_helperPlugin) return 0; WebPlugin* plugin = m_helperPlugin->getPlugin(); if (!plugin) { // There is no need to keep the helper plugin around and the caller // should not be expected to call close after a failure (null pointer). closeHelperPluginSoon(frame); return 0; } return plugin; }
Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) { if (!m_webView->client()) return 0; WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy); if (policy == WebNavigationPolicyIgnore) policy = getNavigationPolicy(); ASSERT(frame->document()); DocumentFullscreen::webkitCancelFullScreen(*frame->document()); WebViewImpl* newView = toWebViewImpl( m_webView->client()->createView(WebFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer)); if (!newView) return 0; return newView->page(); }
Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) { if (!m_webView->client()) return nullptr; WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPolicy); if (policy == WebNavigationPolicyIgnore) policy = getNavigationPolicy(features); else if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolicy(m_windowFeatures) != WebNavigationPolicyNewBackgroundTab && !UIEventWithKeyState::newTabModifierSetFromIsolatedWorld()) policy = WebNavigationPolicyNewForegroundTab; ASSERT(frame->document()); Fullscreen::fullyExitFullscreen(*frame->document()); WebViewImpl* newView = toWebViewImpl( m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer)); if (!newView) return nullptr; return newView->page(); }
WebFrameWidget* WebFrameWidget::create(WebWidgetClient* client, WebView* webView, WebLocalFrame* mainFrame) { return new WebViewFrameWidget(client, toWebViewImpl(*webView), toWebLocalFrameImpl(*mainFrame)); }
WebCString WebPageSerializer::serializeToMHTMLUsingBinaryEncoding(WebView* view) { RefPtr<SharedBuffer> mhtml = serializePageToMHTML(toWebViewImpl(view)->page(), MHTMLArchive::UseBinaryEncoding); // FIXME: we are copying all the data here. Idealy we would have a WebSharedData(). return WebCString(mhtml->data(), mhtml->size()); }
void WebMediaPlayerClientImpl::closeHelperPluginSoon(WebFrame* frame) { ASSERT(m_helperPlugin); toWebViewImpl(frame->view())->closeHelperPluginSoon(m_helperPlugin.release()); }