本文整理汇总了C++中WebView::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ WebView::resize方法的具体用法?C++ WebView::resize怎么用?C++ WebView::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView::resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerMockedHttpURLLoad
TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
{
registerMockedHttpURLLoad("no_viewport_tag.html");
int viewportWidth = 640;
int viewportHeight = 480;
FixedLayoutTestWebViewClient client;
client.m_screenInfo.horizontalDPI = 320;
client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
webView->settings()->setViewportEnabled(true);
webView->enableFixedLayoutMode(true);
webView->resize(WebSize(viewportWidth, viewportHeight));
webView->layout();
EXPECT_EQ(2, webView->deviceScaleFactor());
// Device scale factor should be a component of page scale factor in fixed-layout, so a scale of 1 becomes 2.
webView->setPageScaleFactorLimits(1, 2);
EXPECT_EQ(2, webView->pageScaleFactor());
// Force the layout to happen before leaving the test.
webView->mainFrame()->contentAsText(1024).utf8();
}
示例2: registerMockedHttpURLLoad
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);
}
示例3: ASSERT
TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_containing_page.html"));
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_containing_page.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
WebElement pluginElement = webView->mainFrame()->firstChild()->document().getElementById("translated-plugin");
RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImpl(pluginElement.pluginContainer());
ASSERT(pluginContainerImpl.get());
pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));
IntRect windowRect, clipRect, unobscuredRect;
Vector<IntRect> cutOutRects;
calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscuredRect, cutOutRects);
EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect);
EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect);
EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect);
// Cause the plugin's frame to be detached.
webViewHelper.reset();
}
示例4: platformKeyboardEventC
// Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
// the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
{
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("plugin_container.html"));
TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin"));
PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#if OS(MACOSX)
modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#endif
PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", "", "", 67, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventC.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
// Clearing |Clipboard::Buffer()|.
Platform::current()->clipboard()->writePlainText(WebString(""));
EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", "", "", 45, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventInsert.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
}
示例5: scheduleAdjustPage
void WebPage::scheduleAdjustPage()
{
WebView* webView = qobject_cast<WebView*>(view());
if (!webView) {
return;
}
if (webView->isLoading()) {
m_adjustingScheduled = true;
}
else {
const QSize &originalSize = webView->size();
QSize newSize(originalSize.width() - 1, originalSize.height() - 1);
webView->resize(newSize);
webView->resize(originalSize);
}
}
示例6: topmostRect
TEST_F(WebPluginContainerTest, TopmostAfterDetachTest)
{
static WebRect topmostRect(10, 10, 40, 40);
// Plugin that checks isRectTopmost in destroy().
class TopmostPlugin : public FakeWebPlugin {
public:
TopmostPlugin(WebFrame* frame, const WebPluginParams& params)
: FakeWebPlugin(frame, params) {}
bool isRectTopmost()
{
return container()->isRectTopmost(topmostRect);
}
void destroy() override
{
// In destroy, isRectTopmost is no longer valid.
EXPECT_FALSE(container()->isRectTopmost(topmostRect));
FakeWebPlugin::destroy();
}
};
class TopmostPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params) override
{
return new TopmostPlugin(frame, params);
}
};
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
TopmostPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
FrameTestHelpers::WebViewHelper webViewHelper;
WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
ASSERT(webView);
webView->settings()->setPluginsEnabled(true);
webView->resize(WebSize(300, 300));
webView->updateAllLifecyclePhases();
runPendingTasks();
RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl =
toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromUTF8("translated-plugin")));
pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));
EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect));
TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl->plugin());
EXPECT_TRUE(testPlugin->isRectTopmost());
// Cause the plugin's frame to be detached.
webViewHelper.reset();
EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect));
}
示例7: setupTest
WebView* TouchActionTest::setupTest(std::string file,
TouchActionTrackingWebViewClient& client) {
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file));
// Note that JavaScript must be enabled for shadow DOM tests.
WebView* webView =
m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client);
// Set size to enable hit testing, and avoid line wrapping for consistency
// with browser.
webView->resize(WebSize(800, 1200));
// Scroll to verify the code properly transforms windows to client co-ords.
const int kScrollOffset = 100;
Document* document = static_cast<Document*>(webView->mainFrame()->document());
document->frame()->view()->layoutViewportScrollableArea()->setScrollOffset(
ScrollOffset(0, kScrollOffset), ProgrammaticScroll);
return webView;
}
示例8: registerMockedHttpURLLoad
TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
{
registerMockedHttpURLLoad("no_viewport_tag.html");
int viewportWidth = 640;
int viewportHeight = 480;
FixedLayoutTestWebViewClient client;
client.m_screenInfo.horizontalDPI = 160;
client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
webView->resize(WebSize(viewportWidth, viewportHeight));
webView->settings()->setViewportEnabled(true);
webView->settings()->setDefaultDeviceScaleFactor(2);
webView->enableFixedLayoutMode(true);
webView->layout();
EXPECT_EQ(2, webView->deviceScaleFactor());
}