本文整理汇总了C++中WebViewImpl::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ WebViewImpl::resize方法的具体用法?C++ WebViewImpl::resize怎么用?C++ WebViewImpl::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebViewImpl
的用法示例。
在下文中一共展示了WebViewImpl::resize方法的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(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());
}
示例3: baseURL
TEST(LinkHighlightImplTest, verifyWebViewImplIntegration)
{
FrameTestHelpers::UseMockScrollbarSettings mockScrollbarSettings;
const std::string baseURL("http://www.test.com/");
const std::string fileName("test_touch_link_highlight.html");
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("test_touch_link_highlight.html"));
FrameTestHelpers::WebViewHelper webViewHelper;
WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileName, true);
int pageWidth = 640;
int pageHeight = 480;
webViewImpl->resize(WebSize(pageWidth, pageHeight));
webViewImpl->updateAllLifecyclePhases();
WebGestureEvent touchEvent;
touchEvent.type = WebInputEvent::GestureShowPress;
touchEvent.sourceDevice = WebGestureDeviceTouchscreen;
// The coordinates below are linked to absolute positions in the referenced .html file.
touchEvent.x = 20;
touchEvent.y = 20;
ASSERT_TRUE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
touchEvent.y = 40;
EXPECT_FALSE(webViewImpl->bestTapNode(getTargetedEvent(webViewImpl, touchEvent)));
touchEvent.y = 20;
// Shouldn't crash.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
EXPECT_TRUE(webViewImpl->linkHighlight(0));
EXPECT_TRUE(webViewImpl->linkHighlight(0)->contentLayer());
EXPECT_TRUE(webViewImpl->linkHighlight(0)->clipLayer());
// Find a target inside a scrollable div
touchEvent.y = 100;
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_TRUE(webViewImpl->linkHighlight(0));
// Don't highlight if no "hand cursor"
touchEvent.y = 220; // An A-link with cross-hair cursor.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
touchEvent.y = 260; // A text input box.
webViewImpl->enableTapHighlightAtPoint(getTargetedEvent(webViewImpl, touchEvent));
ASSERT_EQ(0U, webViewImpl->numLinkHighlights());
Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
}
示例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: doubleTapPoint
TEST_F(WebFrameTest, DivAutoZoomParamsTest)
{
registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html", true));
int pageWidth = 640;
int pageHeight = 480;
int divPosX = 200;
int divPosY = 200;
int divWidth = 200;
int divHeight = 150;
WebRect doubleTapPoint(250, 250, 0, 0);
webViewImpl->resize(WebSize(pageWidth, pageHeight));
float scale;
WebPoint scroll;
// Test for Doubletap scaling
// Tests for zooming in and out without clamping.
// Set device scale and scale limits so we dont get clamped.
webViewImpl->setDeviceScaleFactor(4);
webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor());
// Test zooming into div.
webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
float scaledDivWidth = divWidth * scale;
float scaledDivHeight = divHeight * scale;
int hScroll = ((divPosX * scale) - ((pageWidth - scaledDivWidth) / 2)) / scale;
int vScroll = ((divPosY * scale) - ((pageHeight - scaledDivHeight) / 2)) / scale;
EXPECT_NEAR(pageWidth / divWidth, scale, 0.1);
EXPECT_EQ(hScroll, scroll.x);
EXPECT_EQ(vScroll, scroll.y);
// Test zoom out to overview scale.
webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
EXPECT_FLOAT_EQ(1, scale);
EXPECT_EQ(WebPoint(0, 0), scroll);
// Tests for clamped scaling.
// Test clamp to device scale:
webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
webViewImpl->setDeviceScaleFactor(2.5);
webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
EXPECT_FLOAT_EQ(2.5, scale);
// Test clamp to minimum scale:
webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
webViewImpl->setPageScaleFactorLimits(1.5 / webViewImpl->deviceScaleFactor(), 4 / webViewImpl->deviceScaleFactor());
webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
EXPECT_FLOAT_EQ(1.5, scale);
EXPECT_EQ(WebPoint(0, 0), scroll);
// Test clamp to maximum scale:
webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
webViewImpl->setDeviceScaleFactor(4);
webViewImpl->setPageScaleFactorLimits(0, 3 / webViewImpl->deviceScaleFactor());
webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
EXPECT_FLOAT_EQ(3, scale);
// Test for Non-doubletap scaling
webViewImpl->setPageScaleFactor(1, WebPoint(0, 0));
webViewImpl->setDeviceScaleFactor(4);
webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor());
// Test zooming into div.
webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll);
EXPECT_NEAR(pageWidth / divWidth, scale, 0.1);
// Drop any pending fake mouse events from zooming before leaving the test.
webViewImpl->page()->mainFrame()->eventHandler()->clear();
}