本文整理汇总了C++中COMPtr::MIMEType方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPtr::MIMEType方法的具体用法?C++ COMPtr::MIMEType怎么用?C++ COMPtr::MIMEType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPtr
的用法示例。
在下文中一共展示了COMPtr::MIMEType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump
void dump()
{
invalidateAnyPreviousWaitToDumpWatchdog();
COMPtr<IWebDataSource> dataSource;
if (SUCCEEDED(frame->dataSource(&dataSource))) {
COMPtr<IWebURLResponse> response;
if (SUCCEEDED(dataSource->response(&response)) && response) {
BSTR mimeType;
if (SUCCEEDED(response->MIMEType(&mimeType)))
::gLayoutTestController->setDumpAsText(::gLayoutTestController->dumpAsText() | !_tcscmp(mimeType, TEXT("text/plain")));
SysFreeString(mimeType);
}
}
BSTR resultString = 0;
if (dumpTree) {
if (::gLayoutTestController->dumpAsText()) {
::InvalidateRect(webViewWindow, 0, TRUE);
::SendMessage(webViewWindow, WM_PAINT, 0, 0);
wstring result = dumpFramesAsText(frame);
resultString = SysAllocStringLen(result.data(), result.size());
} else {
bool isSVGW3CTest = (gLayoutTestController->testPathOrURL().find("svg\\W3C-SVG-1.1") != string::npos);
unsigned width;
unsigned height;
if (isSVGW3CTest) {
width = 480;
height = 360;
} else {
width = LayoutTestController::maxViewWidth;
height = LayoutTestController::maxViewHeight;
}
::SetWindowPos(webViewWindow, 0, 0, 0, width, height, SWP_NOMOVE);
::InvalidateRect(webViewWindow, 0, TRUE);
::SendMessage(webViewWindow, WM_PAINT, 0, 0);
COMPtr<IWebFramePrivate> framePrivate;
if (FAILED(frame->QueryInterface(&framePrivate)))
goto fail;
framePrivate->renderTreeAsExternalRepresentation(&resultString);
}
if (!resultString)
printf("ERROR: nil result from %s", ::gLayoutTestController->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation");
else {
unsigned stringLength = SysStringLen(resultString);
int bufferSize = ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, 0, 0, 0, 0);
char* buffer = (char*)malloc(bufferSize + 1);
::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, buffer, bufferSize + 1, 0, 0);
fwrite(buffer, 1, bufferSize, stdout);
free(buffer);
if (!::gLayoutTestController->dumpAsText())
dumpFrameScrollPosition(frame);
}
if (::gLayoutTestController->dumpBackForwardList())
dumpBackForwardListForAllWindows();
}
if (printSeparators) {
puts("#EOF"); // terminate the content block
fputs("#EOF\n", stderr);
fflush(stdout);
fflush(stderr);
}
if (dumpPixels) {
if (!gLayoutTestController->dumpAsText() && !gLayoutTestController->dumpDOMAsWebArchive() && !gLayoutTestController->dumpSourceAsWebArchive())
dumpWebViewAsPixelsAndCompareWithExpected(gLayoutTestController->expectedPixelHash());
}
printf("#EOF\n"); // terminate the (possibly empty) pixels block
fflush(stdout);
fail:
SysFreeString(resultString);
// This will exit from our message loop.
PostQuitMessage(0);
done = true;
}
示例2: dump
void dump()
{
invalidateAnyPreviousWaitToDumpWatchdog();
COMPtr<IWebDataSource> dataSource;
if (SUCCEEDED(frame->dataSource(&dataSource))) {
COMPtr<IWebURLResponse> response;
if (SUCCEEDED(dataSource->response(&response)) && response) {
BSTR mimeType;
if (SUCCEEDED(response->MIMEType(&mimeType)) && !_tcscmp(mimeType, TEXT("text/plain"))) {
::gTestRunner->setDumpAsText(true);
::gTestRunner->setGeneratePixelResults(false);
}
SysFreeString(mimeType);
}
}
BSTR resultString = 0;
if (dumpTree) {
::InvalidateRect(webViewWindow, 0, TRUE);
::SendMessage(webViewWindow, WM_PAINT, 0, 0);
if (::gTestRunner->dumpAsText()) {
wstring result = dumpFramesAsText(frame);
resultString = SysAllocStringLen(result.data(), result.size());
} else {
COMPtr<IWebFramePrivate> framePrivate;
if (FAILED(frame->QueryInterface(&framePrivate)))
goto fail;
framePrivate->renderTreeAsExternalRepresentation(gTestRunner->isPrinting(), &resultString);
}
if (!resultString)
printf("ERROR: nil result from %s", ::gTestRunner->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation");
else {
unsigned stringLength = SysStringLen(resultString);
int bufferSize = ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, 0, 0, 0, 0);
char* buffer = (char*)malloc(bufferSize + 1);
::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, buffer, bufferSize + 1, 0, 0);
fwrite(buffer, 1, bufferSize, stdout);
free(buffer);
if (!::gTestRunner->dumpAsText())
dumpFrameScrollPosition(frame);
}
if (::gTestRunner->dumpBackForwardList())
dumpBackForwardListForAllWindows();
}
if (printSeparators) {
puts("#EOF"); // terminate the content block
fputs("#EOF\n", stderr);
fflush(stdout);
fflush(stderr);
}
if (dumpPixelsForCurrentTest
&& gTestRunner->generatePixelResults()
&& !gTestRunner->dumpDOMAsWebArchive()
&& !gTestRunner->dumpSourceAsWebArchive())
dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner->expectedPixelHash());
printf("#EOF\n"); // terminate the (possibly empty) pixels block
fflush(stdout);
fail:
SysFreeString(resultString);
// This will exit from our message loop.
PostQuitMessage(0);
done = true;
}