WebKit Bugzilla
Attachment 341448 Details for
Bug 186029
: [Win][MiniBrowser] Move WK1 specific code from Common.cpp to MiniBrowser.cpp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186029-20180528145459.patch (text/plain), 29.88 KB, created by
Fujii Hironori
on 2018-05-27 22:55:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-05-27 22:55:00 PDT
Size:
29.88 KB
patch
obsolete
>Subversion Revision: 232234 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index c5b290c1b07d6474565b0432a25412fa9d4f4754..2ce7cca09a2cbd4055f9ea3042a92dce8914e957 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,35 @@ >+2018-05-27 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Move WK1 specific code from Common.cpp to MiniBrowser.cpp >+ https://bugs.webkit.org/show_bug.cgi?id=186029 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is a sub task of Bug 184770. >+ >+ * MiniBrowser/win/Common.cpp: >+ (ToggleMenuItem): Extracted WK1 specific code to MiniBrowser::setPreference. >+ (Caches): Call MiniBrowser::updateStatistics instead of updateStatistics. >+ (AbortProc): Moved to MiniBrowser.cpp. >+ (getPrinterDC): Ditto. >+ (initDocStruct): Ditto. >+ (PrintView): Ditto. >+ (ToggleMenuFlag): Ditto. >+ (setWindowText): Ditto. >+ (updateStatistics): Ditto. >+ * MiniBrowser/win/MainWindow.cpp: >+ (MainWindow::WndProc): Call MiniBrowser::print instead of PrintView. >+ * MiniBrowser/win/MiniBrowser.cpp: >+ (AbortProc): Moved from Common.cpp. >+ (getPrinterDC): Moved from Common.cpp. >+ (initDocStruct): Moved from Common.cpp. >+ (setWindowText): Moved from Common.cpp. >+ (MiniBrowser::print): Renamed from PrintView of Common.cpp. >+ (MiniBrowser::updateStatistics): Renamed from updateStatistics of Common.cpp. >+ (MiniBrowser::setPreference): Extracted from ToggleMenuItem of Common.cpp. >+ * MiniBrowser/win/MiniBrowser.h: Add method declarations. >+ * MiniBrowser/win/MiniBrowserWebHost.cpp: Removed duplicated IWebFramePtr typedef. >+ > 2018-05-27 Fujii Hironori <Hironori.Fujii@sony.com> > > [Win][MiniBrowser] Add MainWindow class >diff --git a/Tools/MiniBrowser/win/Common.cpp b/Tools/MiniBrowser/win/Common.cpp >index 3ed7e39e656bdeb85a305ea27198ddbf810ba7c3..2b825bcd64855446960618c55e511968adc02f66 100644 >--- a/Tools/MiniBrowser/win/Common.cpp >+++ b/Tools/MiniBrowser/win/Common.cpp >@@ -31,14 +31,9 @@ > #include "MiniBrowser.h" > #include "MiniBrowserReplace.h" > #include <WebKitLegacy/WebKitCOMAPI.h> >-#include <wtf/ExportMacros.h> >-#include <wtf/Platform.h> >-#include <wtf/text/CString.h> >-#include <wtf/text/WTFString.h> > > #if USE(CF) > #include <CoreFoundation/CFRunLoop.h> >-#include <WebKitLegacy/CFDictionaryPropertyBag.h> > #endif > > #include <cassert> >@@ -60,9 +55,6 @@ > #define WM_DPICHANGED 0x02E0 > #endif > >-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; >-typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; >- > // Global Variables: > HINSTANCE hInst; > HWND hCacheWnd; >@@ -80,7 +72,6 @@ SIZE s_windowSize = { 500, 200 }; > INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); > > static void loadURL(BSTR urlBStr); >-static void updateStatistics(HWND hDlg); > > namespace WebCore { > float deviceScaleFactorForWindow(HWND); >@@ -159,100 +150,6 @@ void createCrashReport(EXCEPTION_POINTERS* exceptionPointers) > } > } > >-static BOOL CALLBACK AbortProc(HDC hDC, int Error) >-{ >- MSG msg; >- while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { >- ::TranslateMessage(&msg); >- ::DispatchMessage(&msg); >- } >- >- return TRUE; >-} >- >-static HDC getPrinterDC() >-{ >- PRINTDLG pdlg; >- memset(&pdlg, 0, sizeof(PRINTDLG)); >- pdlg.lStructSize = sizeof(PRINTDLG); >- pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC; >- >- ::PrintDlg(&pdlg); >- >- return pdlg.hDC; >-} >- >-static void initDocStruct(DOCINFO* di, TCHAR* docname) >-{ >- memset(di, 0, sizeof(DOCINFO)); >- di->cbSize = sizeof(DOCINFO); >- di->lpszDocName = docname; >-} >- >-typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; >- >-void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- HDC printDC = getPrinterDC(); >- if (!printDC) { >- ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); >- return; >- } >- >- if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { >- ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); >- return; >- } >- >- IWebFramePtr frame = gMiniBrowser->mainFrame(); >- if (!frame) >- return; >- >- IWebFramePrivatePtr framePrivate; >- if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr()))) >- return; >- >- framePrivate->setInPrintingMode(TRUE, printDC); >- >- UINT pageCount = 0; >- framePrivate->getPrintedPageCount(printDC, &pageCount); >- >- DOCINFO di; >- initDocStruct(&di, L"WebKit Doc"); >- ::StartDoc(printDC, &di); >- >- // FIXME: Need CoreGraphics implementation >- void* graphicsContext = 0; >- for (size_t page = 1; page <= pageCount; ++page) { >- ::StartPage(printDC); >- framePrivate->spoolPages(printDC, page, page, graphicsContext); >- ::EndPage(printDC); >- } >- >- framePrivate->setInPrintingMode(FALSE, printDC); >- >- ::EndDoc(printDC); >- ::DeleteDC(printDC); >-} >- >-void ToggleMenuFlag(HWND hWnd, UINT menuID) >-{ >- HMENU menu = ::GetMenu(hWnd); >- >- MENUITEMINFO info; >- ::memset(&info, 0x00, sizeof(info)); >- info.cbSize = sizeof(info); >- info.fMask = MIIM_STATE; >- >- if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) >- return; >- >- BOOL newState = !(info.fState & MFS_CHECKED); >- info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; >- >- ::SetMenuItemInfo(menu, menuID, FALSE, &info); >-} >- > static bool menuItemIsChecked(const MENUITEMINFO& info) > { > return info.fState & MFS_CHECKED; >@@ -284,52 +181,7 @@ bool ToggleMenuItem(HWND hWnd, UINT menuID) > > HMENU menu = ::GetMenu(hWnd); > >- MENUITEMINFO info; >- ::memset(&info, 0x00, sizeof(info)); >- info.cbSize = sizeof(info); >- info.fMask = MIIM_STATE; >- >- if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) >- return false; >- >- BOOL newState = !menuItemIsChecked(info); >- >- if (!gMiniBrowser->standardPreferences() || !gMiniBrowser->privatePreferences()) >- return false; >- > switch (menuID) { >- case IDM_AVFOUNDATION: >- gMiniBrowser->standardPreferences()->setAVFoundationEnabled(newState); >- break; >- case IDM_ACC_COMPOSITING: >- gMiniBrowser->privatePreferences()->setAcceleratedCompositingEnabled(newState); >- break; >- case IDM_WK_FULLSCREEN: >- gMiniBrowser->privatePreferences()->setFullScreenEnabled(newState); >- break; >- case IDM_COMPOSITING_BORDERS: >- gMiniBrowser->privatePreferences()->setShowDebugBorders(newState); >- gMiniBrowser->privatePreferences()->setShowRepaintCounter(newState); >- break; >- case IDM_DEBUG_INFO_LAYER: >- gMiniBrowser->privatePreferences()->setShowTiledScrollingIndicator(newState); >- break; >- case IDM_INVERT_COLORS: >- gMiniBrowser->privatePreferences()->setShouldInvertColors(newState); >- break; >- case IDM_DISABLE_IMAGES: >- gMiniBrowser->standardPreferences()->setLoadsImagesAutomatically(!newState); >- break; >- case IDM_DISABLE_STYLES: >- gMiniBrowser->privatePreferences()->setAuthorAndUserStylesEnabled(!newState); >- break; >- case IDM_DISABLE_JAVASCRIPT: >- gMiniBrowser->standardPreferences()->setJavaScriptEnabled(!newState); >- break; >- case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS: >- gMiniBrowser->privatePreferences()->setAllowUniversalAccessFromFileURLs(newState); >- gMiniBrowser->privatePreferences()->setAllowFileAccessFromFileURLs(newState); >- break; > case IDM_UA_DEFAULT: > case IDM_UA_SAFARI_8_0: > case IDM_UA_SAFARI_IOS_8_IPHONE: >@@ -346,14 +198,21 @@ bool ToggleMenuItem(HWND hWnd, UINT menuID) > // The actual user agent string will be set by the custom user agent dialog > turnOffOtherUserAgents(menu); > break; >- default: >- return false; > } > >- info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; >+ MENUITEMINFO info = { }; >+ info.cbSize = sizeof(info); >+ info.fMask = MIIM_STATE; > >+ if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) >+ return false; >+ >+ BOOL newState = !menuItemIsChecked(info); >+ info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; > ::SetMenuItemInfo(menu, menuID, FALSE, &info); > >+ gMiniBrowser->setPreference(menuID, newState); >+ > return true; > } > >@@ -437,7 +296,7 @@ INT_PTR CALLBACK Caches(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) > return (INT_PTR)TRUE; > > case WM_PAINT: >- updateStatistics(hDlg); >+ gMiniBrowser->updateStatistics(hDlg); > break; > } > >@@ -540,163 +399,6 @@ static void loadURL(BSTR passedURL) > SetFocus(gMiniBrowser->hwnd()); > } > >-static void setWindowText(HWND dialog, UINT field, _bstr_t value) >-{ >- ::SetDlgItemText(dialog, field, value); >-} >- >-static void setWindowText(HWND dialog, UINT field, UINT value) >-{ >- String valueStr = WTF::String::number(value); >- >- setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >-} >- >-typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr; >- >-static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key) >-{ >- _variant_t var; >- V_VT(&var) = VT_UI8; >- if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr))) >- return; >- >- unsigned long long value = V_UI8(&var); >- String valueStr = WTF::String::number(value); >- >- setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >-} >- >-static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total) >-{ >- CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key)); >- if (!countNum) >- return; >- >- int count = 0; >- CFNumberGetValue(countNum, kCFNumberIntType, &count); >- >- setWindowText(dialog, field, static_cast<UINT>(count)); >- total += count; >-} >- >-static void updateStatistics(HWND dialog) >-{ >- if (!gMiniBrowser) >- return; >- >- IWebCoreStatisticsPtr webCoreStatistics = gMiniBrowser->statistics(); >- if (!webCoreStatistics) >- return; >- >- IPropertyBagPtr statistics; >- HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr()); >- if (FAILED(hr)) >- return; >- >- // FastMalloc. >- setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes"); >- setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes"); >- setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes"); >- >- // WebCore Cache. >-#if USE(CF) >- IWebCachePtr webCache = gMiniBrowser->webCache(); >- >- int dictCount = 6; >- IPropertyBag* cacheDict[6] = { 0 }; >- if (FAILED(webCache->statistics(&dictCount, cacheDict))) >- return; >- >- COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes; >- counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0])); >- sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1])); >- liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2])); >- decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3])); >- purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4])); >- >- static CFStringRef imagesKey = CFSTR("images"); >- static CFStringRef stylesheetsKey = CFSTR("style sheets"); >- static CFStringRef xslKey = CFSTR("xsl"); >- static CFStringRef scriptsKey = CFSTR("scripts"); >- >- if (counts) { >- UINT totalObjects = 0; >- setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects); >- setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects); >- setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects); >- setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects); >- setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects); >- } >- >- if (sizes) { >- UINT totalBytes = 0; >- setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes); >- setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes); >- setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes); >- setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes); >- setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes); >- } >- >- if (liveSizes) { >- UINT totalLiveBytes = 0; >- setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes); >- setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes); >- setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes); >- setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes); >- setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes); >- } >- >- if (decodedSizes) { >- UINT totalDecoded = 0; >- setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded); >- setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded); >- setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded); >- setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded); >- setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded); >- } >- >- if (purgableSizes) { >- UINT totalPurgable = 0; >- setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable); >- setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable); >- setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable); >- setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable); >- setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable); >- } >-#endif >- >- // JavaScript Heap. >- setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize"); >- setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize"); >- >- UINT count; >- if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count))) >- setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count))) >- setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count))) >- setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count); >- >- // Font and Glyph Caches. >- if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count))) >- setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count))) >- setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count); >- if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count))) >- setWindowText(dialog, IDC_GLYPH_PAGES, count); >- >- // Site Icon Database. >- if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count))) >- setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count); >- if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count))) >- setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count); >- if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count))) >- setWindowText(dialog, IDC_SITE_ICON_RECORDS, count); >- if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count))) >- setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count); >-} >- > static void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL) > { > usesLayeredWebView = false; >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >index 7bfc6dfe98a9ad99142b22c629599399c7100ecb..a8de0c66ba65091a37c942d01df7486ef68ecc73 100644 >--- a/Tools/MiniBrowser/win/MainWindow.cpp >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -49,7 +49,6 @@ INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); > INT_PTR CALLBACK CustomUserAgent(HWND, UINT, WPARAM, LPARAM); > INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); > INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); >-void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); > bool ToggleMenuItem(HWND hWnd, UINT menuID); > > std::wstring MainWindow::s_windowClass; >@@ -166,7 +165,7 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > DestroyWindow(hWnd); > break; > case IDM_PRINT: >- PrintView(hWnd, message, wParam, lParam); >+ gMiniBrowser->print(); > break; > case IDM_WEB_INSPECTOR: > if (gMiniBrowser) >diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp >index 276ae7d3004701231704a46e80467588779fe6fd..96ec3eac5fb28848fa1755c8350bc15a9241faef 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp >@@ -38,20 +38,19 @@ > #include "PrintWebUIDelegate.h" > #include "ResourceLoadDelegate.h" > #include "WebDownloadDelegate.h" >+#include <WebCore/COMPtr.h> > #include <WebKitLegacy/WebKitCOMAPI.h> >-#include <wtf/ExportMacros.h> >-#include <wtf/Platform.h> >- >-#if USE(CF) >-#include <CoreFoundation/CFRunLoop.h> >-#endif >- > #include <algorithm> > #include <cassert> > #include <functional> > #include <memory> > #include <string> > #include <vector> >+#include <wtf/text/WTFString.h> >+ >+#if USE(CF) >+#include <WebKitLegacy/CFDictionaryPropertyBag.h> >+#endif > > namespace WebCore { > float deviceScaleFactorForWindow(HWND); >@@ -625,3 +624,272 @@ void MiniBrowser::updateDeviceScaleFactor() > m_deviceScaleFactor = WebCore::deviceScaleFactorForWindow(m_hMainWnd); > generateFontForScaleFactor(m_deviceScaleFactor); > } >+ >+static BOOL CALLBACK AbortProc(HDC hDC, int Error) >+{ >+ MSG msg; >+ while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { >+ ::TranslateMessage(&msg); >+ ::DispatchMessage(&msg); >+ } >+ >+ return TRUE; >+} >+ >+static HDC getPrinterDC() >+{ >+ PRINTDLG pdlg; >+ memset(&pdlg, 0, sizeof(PRINTDLG)); >+ pdlg.lStructSize = sizeof(PRINTDLG); >+ pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC; >+ >+ ::PrintDlg(&pdlg); >+ >+ return pdlg.hDC; >+} >+ >+static void initDocStruct(DOCINFO* di, TCHAR* docname) >+{ >+ memset(di, 0, sizeof(DOCINFO)); >+ di->cbSize = sizeof(DOCINFO); >+ di->lpszDocName = docname; >+} >+ >+void MiniBrowser::print() >+{ >+ HDC printDC = getPrinterDC(); >+ if (!printDC) { >+ ::MessageBox(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); >+ return; >+ } >+ >+ if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { >+ ::MessageBox(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); >+ return; >+ } >+ >+ IWebFramePtr frame = mainFrame(); >+ if (!frame) >+ return; >+ >+ IWebFramePrivatePtr framePrivate; >+ if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr()))) >+ return; >+ >+ framePrivate->setInPrintingMode(TRUE, printDC); >+ >+ UINT pageCount = 0; >+ framePrivate->getPrintedPageCount(printDC, &pageCount); >+ >+ DOCINFO di; >+ initDocStruct(&di, L"WebKit Doc"); >+ ::StartDoc(printDC, &di); >+ >+ // FIXME: Need CoreGraphics implementation >+ void* graphicsContext = 0; >+ for (size_t page = 1; page <= pageCount; ++page) { >+ ::StartPage(printDC); >+ framePrivate->spoolPages(printDC, page, page, graphicsContext); >+ ::EndPage(printDC); >+ } >+ >+ framePrivate->setInPrintingMode(FALSE, printDC); >+ >+ ::EndDoc(printDC); >+ ::DeleteDC(printDC); >+} >+ >+static void setWindowText(HWND dialog, UINT field, _bstr_t value) >+{ >+ ::SetDlgItemText(dialog, field, value); >+} >+ >+static void setWindowText(HWND dialog, UINT field, UINT value) >+{ >+ String valueStr = WTF::String::number(value); >+ >+ setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >+} >+ >+typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr; >+ >+static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key) >+{ >+ _variant_t var; >+ V_VT(&var) = VT_UI8; >+ if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr))) >+ return; >+ >+ unsigned long long value = V_UI8(&var); >+ String valueStr = WTF::String::number(value); >+ >+ setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); >+} >+ >+static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total) >+{ >+ CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key)); >+ if (!countNum) >+ return; >+ >+ int count = 0; >+ CFNumberGetValue(countNum, kCFNumberIntType, &count); >+ >+ setWindowText(dialog, field, static_cast<UINT>(count)); >+ total += count; >+} >+ >+void MiniBrowser::updateStatistics(HWND dialog) >+{ >+ IWebCoreStatisticsPtr webCoreStatistics = statistics(); >+ if (!webCoreStatistics) >+ return; >+ >+ IPropertyBagPtr statistics; >+ HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return; >+ >+ // FastMalloc. >+ setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes"); >+ setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes"); >+ setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes"); >+ >+ // WebCore Cache. >+#if USE(CF) >+ IWebCachePtr webCache = this->webCache(); >+ >+ int dictCount = 6; >+ IPropertyBag* cacheDict[6] = { 0 }; >+ if (FAILED(webCache->statistics(&dictCount, cacheDict))) >+ return; >+ >+ COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes; >+ counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0])); >+ sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1])); >+ liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2])); >+ decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3])); >+ purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4])); >+ >+ static CFStringRef imagesKey = CFSTR("images"); >+ static CFStringRef stylesheetsKey = CFSTR("style sheets"); >+ static CFStringRef xslKey = CFSTR("xsl"); >+ static CFStringRef scriptsKey = CFSTR("scripts"); >+ >+ if (counts) { >+ UINT totalObjects = 0; >+ setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects); >+ setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects); >+ setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects); >+ setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects); >+ setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects); >+ } >+ >+ if (sizes) { >+ UINT totalBytes = 0; >+ setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes); >+ setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes); >+ setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes); >+ setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes); >+ setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes); >+ } >+ >+ if (liveSizes) { >+ UINT totalLiveBytes = 0; >+ setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes); >+ setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes); >+ setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes); >+ setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes); >+ setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes); >+ } >+ >+ if (decodedSizes) { >+ UINT totalDecoded = 0; >+ setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded); >+ setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded); >+ setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded); >+ setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded); >+ setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded); >+ } >+ >+ if (purgableSizes) { >+ UINT totalPurgable = 0; >+ setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable); >+ setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable); >+ setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable); >+ setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable); >+ setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable); >+ } >+#endif >+ >+ // JavaScript Heap. >+ setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize"); >+ setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize"); >+ >+ UINT count; >+ if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count))) >+ setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count))) >+ setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count))) >+ setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count); >+ >+ // Font and Glyph Caches. >+ if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count))) >+ setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count))) >+ setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count); >+ if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count))) >+ setWindowText(dialog, IDC_GLYPH_PAGES, count); >+ >+ // Site Icon Database. >+ if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count))) >+ setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count); >+ if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count))) >+ setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count); >+ if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count))) >+ setWindowText(dialog, IDC_SITE_ICON_RECORDS, count); >+ if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count))) >+ setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count); >+} >+ >+void MiniBrowser::setPreference(UINT menuID, bool enable) >+{ >+ if (!standardPreferences() || !privatePreferences()) >+ return; >+ >+ switch (menuID) { >+ case IDM_AVFOUNDATION: >+ standardPreferences()->setAVFoundationEnabled(enable); >+ break; >+ case IDM_ACC_COMPOSITING: >+ privatePreferences()->setAcceleratedCompositingEnabled(enable); >+ break; >+ case IDM_WK_FULLSCREEN: >+ privatePreferences()->setFullScreenEnabled(enable); >+ break; >+ case IDM_COMPOSITING_BORDERS: >+ privatePreferences()->setShowDebugBorders(enable); >+ privatePreferences()->setShowRepaintCounter(enable); >+ break; >+ case IDM_DEBUG_INFO_LAYER: >+ privatePreferences()->setShowTiledScrollingIndicator(enable); >+ break; >+ case IDM_INVERT_COLORS: >+ privatePreferences()->setShouldInvertColors(enable); >+ break; >+ case IDM_DISABLE_IMAGES: >+ standardPreferences()->setLoadsImagesAutomatically(!enable); >+ break; >+ case IDM_DISABLE_STYLES: >+ privatePreferences()->setAuthorAndUserStylesEnabled(!enable); >+ break; >+ case IDM_DISABLE_JAVASCRIPT: >+ standardPreferences()->setJavaScriptEnabled(!enable); >+ break; >+ case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS: >+ privatePreferences()->setAllowUniversalAccessFromFileURLs(enable); >+ privatePreferences()->setAllowFileAccessFromFileURLs(enable); >+ break; >+ } >+} >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >index dae9da902d1f31ba2aefbcf2abf7c058b8feafb7..f5969191c3b1e0fb1895a0c7915e306840c4a4ac 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ b/Tools/MiniBrowser/win/MiniBrowser.h >@@ -44,6 +44,7 @@ typedef _com_ptr_t<_com_IIID<IWebCoreStatistics, &__uuidof(IWebCoreStatistics)>> > typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr; > typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoadDelegate)>> IWebResourceLoadDelegatePtr; > typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; >+typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; > > class MiniBrowser { > public: >@@ -100,6 +101,10 @@ public: > HGDIOBJ urlBarFont() { return m_hURLBarFont; } > HWND hwnd() { return m_viewWnd; } > >+ void print(); >+ void updateStatistics(HWND dialog); >+ void setPreference(UINT menuID, bool enable); >+ > private: > void subclassForLayeredWindow(); > void generateFontForScaleFactor(float); >diff --git a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >index 16a87c0cb64f6cafa16cb30c697ddd527ae4fddc..115e7a467a72aab9503d30a2da2f07297ba4d453 100644 >--- a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >@@ -55,7 +55,6 @@ private: > wchar_t m_eventType[100]; > }; > >-typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; > typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr; > typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186029
: 341448