本文整理汇总了C++中WebViewImpl::mainFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ WebViewImpl::mainFrame方法的具体用法?C++ WebViewImpl::mainFrame怎么用?C++ WebViewImpl::mainFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebViewImpl
的用法示例。
在下文中一共展示了WebViewImpl::mainFrame方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runImeOnFocusTest
void ImeOnFocusTest::runImeOnFocusTest(std::string fileName, int expectedImeRequestCount, IntPoint tapPoint, const AtomicString& focusElement, std::string frame)
{
ImeRequestTrackingWebViewClient client;
registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(fileName));
WebViewImpl* webView = m_webViewHelper.initialize(true, 0, &client);
webView->resize(WebSize(800, 1200));
loadFrame(webView->mainFrame(), m_baseURL + fileName);
m_document = m_webViewHelper.webViewImpl()->mainFrameImpl()->document().unwrap<Document>();
if (!focusElement.isNull())
focus(focusElement);
EXPECT_EQ(0, client.imeRequestCount());
if (tapPoint.x() >= 0 && tapPoint.y() >= 0)
sendGestureTap(webView, tapPoint);
if (!frame.empty()) {
registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(frame));
WebFrame* childFrame = webView->mainFrame()->firstChild();
loadFrame(childFrame, m_baseURL + frame);
}
if (!focusElement.isNull())
focus(focusElement);
EXPECT_EQ(expectedImeRequestCount, client.imeRequestCount());
m_webViewHelper.reset();
}
示例2: registerMockedHttpURLLoad
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);
}
示例3: registerMockedHttpURLLoad
TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
{
const std::string firstURL = "find.html";
const std::string secondURL = "form.html";
const std::string thirdURL = "history.html";
const float pageScaleFactor = 1.1684f;
const int pageWidth = 640;
const int pageHeight = 480;
registerMockedHttpURLLoad(firstURL);
registerMockedHttpURLLoad(secondURL);
registerMockedHttpURLLoad(thirdURL);
WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + firstURL, true));
webViewImpl->resize(WebSize(pageWidth, pageHeight));
webViewImpl->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4));
webViewImpl->setPageScaleFactorPreservingScrollOffset(pageScaleFactor);
WebSize previousOffset = webViewImpl->mainFrame()->scrollOffset();
float previousScale = webViewImpl->pageScaleFactor();
// Reload the page using the cache.
webViewImpl->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + secondURL), false);
webkit_support::ServeAsynchronousMockedRequests();
ASSERT_EQ(previousOffset, webViewImpl->mainFrame()->scrollOffset());
ASSERT_EQ(previousScale, webViewImpl->pageScaleFactor());
// Reload the page while ignoring the cache.
webViewImpl->mainFrame()->reloadWithOverrideURL(toKURL(m_baseURL + thirdURL), true);
webkit_support::ServeAsynchronousMockedRequests();
ASSERT_EQ(previousOffset, webViewImpl->mainFrame()->scrollOffset());
ASSERT_EQ(previousScale, webViewImpl->pageScaleFactor());
}
示例4: baseURL
TEST(RemoteFrameThrottlingTest, ThrottledLocalRoot)
{
FrameTestHelpers::TestWebViewClient viewClient;
WebViewImpl* webView = WebViewImpl::create(&viewClient);
webView->resize(WebSize(640, 480));
// Create a remote root frame with a local child frame.
FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
webView->setMainFrame(remoteClient.frame());
remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createUnique());
WebFrameOwnerProperties properties;
FrameTestHelpers::TestWebFrameClient localFrameClient;
WebRemoteFrame* rootFrame = webView->mainFrame()->toWebRemoteFrame();
WebLocalFrame* localFrame = rootFrame->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &localFrameClient, nullptr, properties);
WebString baseURL("http://internal.test/");
URLTestHelpers::registerMockedURLFromBaseURL(baseURL, "simple_div.html");
FrameTestHelpers::loadFrame(localFrame, baseURL.utf8() + "simple_div.html");
FrameView* frameView = toWebLocalFrameImpl(localFrame)->frameView();
EXPECT_TRUE(frameView->frame().isLocalRoot());
// Enable throttling for the child frame.
frameView->setFrameRect(IntRect(0, 480, frameView->width(), frameView->height()));
frameView->frame().securityContext()->setSecurityOrigin(SecurityOrigin::createUnique());
frameView->updateAllLifecyclePhases();
testing::runPendingTasks();
EXPECT_TRUE(frameView->shouldThrottleRendering());
Document* frameDocument = frameView->frame().document();
if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled())
EXPECT_EQ(DocumentLifecycle::PaintClean, frameDocument->lifecycle().state());
else
EXPECT_EQ(DocumentLifecycle::PaintInvalidationClean, frameDocument->lifecycle().state());
// Mutate the local child frame contents.
auto* divElement = frameDocument->getElementById("div");
divElement->setAttribute(styleAttr, "width: 50px");
EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state());
// Update the lifecycle again. The frame's lifecycle should not advance
// because of throttling even though it is the local root.
frameView->updateAllLifecyclePhases();
testing::runPendingTasks();
EXPECT_EQ(DocumentLifecycle::VisualUpdatePending, frameDocument->lifecycle().state());
webView->close();
}
示例5: createWindow
Page* ChromeClientImpl::createWindow(
Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features)
{
if (!m_webView->client())
return 0;
WebViewImpl* newView = static_cast<WebViewImpl*>(
m_webView->client()->createView(WebFrameImpl::fromFrame(frame), features, r.frameName()));
if (!newView)
return 0;
// The request is empty when we are just being asked to open a blank window.
// This corresponds to window.open(""), for example.
if (!r.resourceRequest().isEmpty()) {
WrappedResourceRequest request(r.resourceRequest());
newView->mainFrame()->loadRequest(request);
}
return newView->page();
}