Changeset 232270 in webkit
- Timestamp:
- May 29, 2018 12:27:13 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r232269 r232270 1 2018-05-29 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [Win][MiniBrowser] Move WK1 specific code from Common.cpp to MiniBrowser.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=186029 5 6 Reviewed by Alex Christensen. 7 8 This is a sub task of Bug 184770. 9 10 * MiniBrowser/win/Common.cpp: 11 (ToggleMenuItem): Extracted WK1 specific code to MiniBrowser::setPreference. 12 (Caches): Call MiniBrowser::updateStatistics instead of updateStatistics. 13 (AbortProc): Moved to MiniBrowser.cpp. 14 (getPrinterDC): Ditto. 15 (initDocStruct): Ditto. 16 (PrintView): Ditto. 17 (ToggleMenuFlag): Ditto. 18 (setWindowText): Ditto. 19 (updateStatistics): Ditto. 20 * MiniBrowser/win/MainWindow.cpp: 21 (MainWindow::WndProc): Call MiniBrowser::print instead of PrintView. 22 * MiniBrowser/win/MiniBrowser.cpp: 23 (AbortProc): Moved from Common.cpp. 24 (getPrinterDC): Moved from Common.cpp. 25 (initDocStruct): Moved from Common.cpp. 26 (setWindowText): Moved from Common.cpp. 27 (MiniBrowser::print): Renamed from PrintView of Common.cpp. 28 (MiniBrowser::updateStatistics): Renamed from updateStatistics of Common.cpp. 29 (MiniBrowser::setPreference): Extracted from ToggleMenuItem of Common.cpp. 30 * MiniBrowser/win/MiniBrowser.h: Add method declarations. 31 * MiniBrowser/win/MiniBrowserWebHost.cpp: Removed duplicated IWebFramePtr typedef. 32 1 33 2018-05-29 Saam Barati <sbarati@apple.com> 2 34 -
trunk/Tools/MiniBrowser/win/Common.cpp
r232234 r232270 32 32 #include "MiniBrowserReplace.h" 33 33 #include <WebKitLegacy/WebKitCOMAPI.h> 34 #include <wtf/ExportMacros.h>35 #include <wtf/Platform.h>36 #include <wtf/text/CString.h>37 #include <wtf/text/WTFString.h>38 34 39 35 #if USE(CF) 40 36 #include <CoreFoundation/CFRunLoop.h> 41 #include <WebKitLegacy/CFDictionaryPropertyBag.h>42 37 #endif 43 38 … … 61 56 #endif 62 57 63 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;64 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;65 66 58 // Global Variables: 67 59 HINSTANCE hInst; … … 81 73 82 74 static void loadURL(BSTR urlBStr); 83 static void updateStatistics(HWND hDlg);84 75 85 76 namespace WebCore { … … 158 149 processCrashReport(fileName.c_str()); 159 150 } 160 }161 162 static BOOL CALLBACK AbortProc(HDC hDC, int Error)163 {164 MSG msg;165 while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {166 ::TranslateMessage(&msg);167 ::DispatchMessage(&msg);168 }169 170 return TRUE;171 }172 173 static HDC getPrinterDC()174 {175 PRINTDLG pdlg;176 memset(&pdlg, 0, sizeof(PRINTDLG));177 pdlg.lStructSize = sizeof(PRINTDLG);178 pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC;179 180 ::PrintDlg(&pdlg);181 182 return pdlg.hDC;183 }184 185 static void initDocStruct(DOCINFO* di, TCHAR* docname)186 {187 memset(di, 0, sizeof(DOCINFO));188 di->cbSize = sizeof(DOCINFO);189 di->lpszDocName = docname;190 }191 192 typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;193 194 void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)195 {196 HDC printDC = getPrinterDC();197 if (!printDC) {198 ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK);199 return;200 }201 202 if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) {203 ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK);204 return;205 }206 207 IWebFramePtr frame = gMiniBrowser->mainFrame();208 if (!frame)209 return;210 211 IWebFramePrivatePtr framePrivate;212 if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr())))213 return;214 215 framePrivate->setInPrintingMode(TRUE, printDC);216 217 UINT pageCount = 0;218 framePrivate->getPrintedPageCount(printDC, &pageCount);219 220 DOCINFO di;221 initDocStruct(&di, L"WebKit Doc");222 ::StartDoc(printDC, &di);223 224 // FIXME: Need CoreGraphics implementation225 void* graphicsContext = 0;226 for (size_t page = 1; page <= pageCount; ++page) {227 ::StartPage(printDC);228 framePrivate->spoolPages(printDC, page, page, graphicsContext);229 ::EndPage(printDC);230 }231 232 framePrivate->setInPrintingMode(FALSE, printDC);233 234 ::EndDoc(printDC);235 ::DeleteDC(printDC);236 }237 238 void ToggleMenuFlag(HWND hWnd, UINT menuID)239 {240 HMENU menu = ::GetMenu(hWnd);241 242 MENUITEMINFO info;243 ::memset(&info, 0x00, sizeof(info));244 info.cbSize = sizeof(info);245 info.fMask = MIIM_STATE;246 247 if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))248 return;249 250 BOOL newState = !(info.fState & MFS_CHECKED);251 info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED;252 253 ::SetMenuItemInfo(menu, menuID, FALSE, &info);254 151 } 255 152 … … 285 182 HMENU menu = ::GetMenu(hWnd); 286 183 287 MENUITEMINFO info;288 ::memset(&info, 0x00, sizeof(info));289 info.cbSize = sizeof(info);290 info.fMask = MIIM_STATE;291 292 if (!::GetMenuItemInfo(menu, menuID, FALSE, &info))293 return false;294 295 BOOL newState = !menuItemIsChecked(info);296 297 if (!gMiniBrowser->standardPreferences() || !gMiniBrowser->privatePreferences())298 return false;299 300 184 switch (menuID) { 301 case IDM_AVFOUNDATION:302 gMiniBrowser->standardPreferences()->setAVFoundationEnabled(newState);303 break;304 case IDM_ACC_COMPOSITING:305 gMiniBrowser->privatePreferences()->setAcceleratedCompositingEnabled(newState);306 break;307 case IDM_WK_FULLSCREEN:308 gMiniBrowser->privatePreferences()->setFullScreenEnabled(newState);309 break;310 case IDM_COMPOSITING_BORDERS:311 gMiniBrowser->privatePreferences()->setShowDebugBorders(newState);312 gMiniBrowser->privatePreferences()->setShowRepaintCounter(newState);313 break;314 case IDM_DEBUG_INFO_LAYER:315 gMiniBrowser->privatePreferences()->setShowTiledScrollingIndicator(newState);316 break;317 case IDM_INVERT_COLORS:318 gMiniBrowser->privatePreferences()->setShouldInvertColors(newState);319 break;320 case IDM_DISABLE_IMAGES:321 gMiniBrowser->standardPreferences()->setLoadsImagesAutomatically(!newState);322 break;323 case IDM_DISABLE_STYLES:324 gMiniBrowser->privatePreferences()->setAuthorAndUserStylesEnabled(!newState);325 break;326 case IDM_DISABLE_JAVASCRIPT:327 gMiniBrowser->standardPreferences()->setJavaScriptEnabled(!newState);328 break;329 case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS:330 gMiniBrowser->privatePreferences()->setAllowUniversalAccessFromFileURLs(newState);331 gMiniBrowser->privatePreferences()->setAllowFileAccessFromFileURLs(newState);332 break;333 185 case IDM_UA_DEFAULT: 334 186 case IDM_UA_SAFARI_8_0: … … 347 199 turnOffOtherUserAgents(menu); 348 200 break; 349 default: 201 } 202 203 MENUITEMINFO info = { }; 204 info.cbSize = sizeof(info); 205 info.fMask = MIIM_STATE; 206 207 if (!::GetMenuItemInfo(menu, menuID, FALSE, &info)) 350 208 return false; 351 } 352 209 210 BOOL newState = !menuItemIsChecked(info); 353 211 info.fState = (newState) ? MFS_CHECKED : MFS_UNCHECKED; 354 355 212 ::SetMenuItemInfo(menu, menuID, FALSE, &info); 213 214 gMiniBrowser->setPreference(menuID, newState); 356 215 357 216 return true; … … 438 297 439 298 case WM_PAINT: 440 updateStatistics(hDlg);299 gMiniBrowser->updateStatistics(hDlg); 441 300 break; 442 301 } … … 539 398 540 399 SetFocus(gMiniBrowser->hwnd()); 541 }542 543 static void setWindowText(HWND dialog, UINT field, _bstr_t value)544 {545 ::SetDlgItemText(dialog, field, value);546 }547 548 static void setWindowText(HWND dialog, UINT field, UINT value)549 {550 String valueStr = WTF::String::number(value);551 552 setWindowText(dialog, field, _bstr_t(valueStr.utf8().data()));553 }554 555 typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr;556 557 static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key)558 {559 _variant_t var;560 V_VT(&var) = VT_UI8;561 if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr)))562 return;563 564 unsigned long long value = V_UI8(&var);565 String valueStr = WTF::String::number(value);566 567 setWindowText(dialog, field, _bstr_t(valueStr.utf8().data()));568 }569 570 static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total)571 {572 CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key));573 if (!countNum)574 return;575 576 int count = 0;577 CFNumberGetValue(countNum, kCFNumberIntType, &count);578 579 setWindowText(dialog, field, static_cast<UINT>(count));580 total += count;581 }582 583 static void updateStatistics(HWND dialog)584 {585 if (!gMiniBrowser)586 return;587 588 IWebCoreStatisticsPtr webCoreStatistics = gMiniBrowser->statistics();589 if (!webCoreStatistics)590 return;591 592 IPropertyBagPtr statistics;593 HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr());594 if (FAILED(hr))595 return;596 597 // FastMalloc.598 setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes");599 setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes");600 setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes");601 602 // WebCore Cache.603 #if USE(CF)604 IWebCachePtr webCache = gMiniBrowser->webCache();605 606 int dictCount = 6;607 IPropertyBag* cacheDict[6] = { 0 };608 if (FAILED(webCache->statistics(&dictCount, cacheDict)))609 return;610 611 COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes;612 counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0]));613 sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1]));614 liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2]));615 decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3]));616 purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4]));617 618 static CFStringRef imagesKey = CFSTR("images");619 static CFStringRef stylesheetsKey = CFSTR("style sheets");620 static CFStringRef xslKey = CFSTR("xsl");621 static CFStringRef scriptsKey = CFSTR("scripts");622 623 if (counts) {624 UINT totalObjects = 0;625 setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects);626 setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects);627 setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects);628 setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects);629 setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects);630 }631 632 if (sizes) {633 UINT totalBytes = 0;634 setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes);635 setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes);636 setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes);637 setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes);638 setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes);639 }640 641 if (liveSizes) {642 UINT totalLiveBytes = 0;643 setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes);644 setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes);645 setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes);646 setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes);647 setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes);648 }649 650 if (decodedSizes) {651 UINT totalDecoded = 0;652 setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded);653 setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded);654 setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded);655 setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded);656 setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded);657 }658 659 if (purgableSizes) {660 UINT totalPurgable = 0;661 setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable);662 setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable);663 setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable);664 setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable);665 setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable);666 }667 #endif668 669 // JavaScript Heap.670 setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize");671 setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize");672 673 UINT count;674 if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count)))675 setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count);676 if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count)))677 setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count);678 if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count)))679 setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count);680 681 // Font and Glyph Caches.682 if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count)))683 setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count);684 if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count)))685 setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count);686 if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count)))687 setWindowText(dialog, IDC_GLYPH_PAGES, count);688 689 // Site Icon Database.690 if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count)))691 setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count);692 if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count)))693 setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count);694 if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count)))695 setWindowText(dialog, IDC_SITE_ICON_RECORDS, count);696 if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count)))697 setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count);698 400 } 699 401 -
trunk/Tools/MiniBrowser/win/MainWindow.cpp
r232234 r232270 50 50 INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); 51 51 INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); 52 void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);53 52 bool ToggleMenuItem(HWND hWnd, UINT menuID); 54 53 … … 167 166 break; 168 167 case IDM_PRINT: 169 PrintView(hWnd, message, wParam, lParam);168 gMiniBrowser->print(); 170 169 break; 171 170 case IDM_WEB_INSPECTOR: -
trunk/Tools/MiniBrowser/win/MiniBrowser.cpp
r232230 r232270 39 39 #include "ResourceLoadDelegate.h" 40 40 #include "WebDownloadDelegate.h" 41 #include <WebCore/COMPtr.h> 41 42 #include <WebKitLegacy/WebKitCOMAPI.h> 42 #include <wtf/ExportMacros.h>43 #include <wtf/Platform.h>44 45 #if USE(CF)46 #include <CoreFoundation/CFRunLoop.h>47 #endif48 49 43 #include <algorithm> 50 44 #include <cassert> … … 53 47 #include <string> 54 48 #include <vector> 49 #include <wtf/text/WTFString.h> 50 51 #if USE(CF) 52 #include <WebKitLegacy/CFDictionaryPropertyBag.h> 53 #endif 55 54 56 55 namespace WebCore { … … 626 625 generateFontForScaleFactor(m_deviceScaleFactor); 627 626 } 627 628 static BOOL CALLBACK AbortProc(HDC hDC, int Error) 629 { 630 MSG msg; 631 while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { 632 ::TranslateMessage(&msg); 633 ::DispatchMessage(&msg); 634 } 635 636 return TRUE; 637 } 638 639 static HDC getPrinterDC() 640 { 641 PRINTDLG pdlg; 642 memset(&pdlg, 0, sizeof(PRINTDLG)); 643 pdlg.lStructSize = sizeof(PRINTDLG); 644 pdlg.Flags = PD_PRINTSETUP | PD_RETURNDC; 645 646 ::PrintDlg(&pdlg); 647 648 return pdlg.hDC; 649 } 650 651 static void initDocStruct(DOCINFO* di, TCHAR* docname) 652 { 653 memset(di, 0, sizeof(DOCINFO)); 654 di->cbSize = sizeof(DOCINFO); 655 di->lpszDocName = docname; 656 } 657 658 void MiniBrowser::print() 659 { 660 HDC printDC = getPrinterDC(); 661 if (!printDC) { 662 ::MessageBox(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); 663 return; 664 } 665 666 if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { 667 ::MessageBox(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); 668 return; 669 } 670 671 IWebFramePtr frame = mainFrame(); 672 if (!frame) 673 return; 674 675 IWebFramePrivatePtr framePrivate; 676 if (FAILED(frame->QueryInterface(&framePrivate.GetInterfacePtr()))) 677 return; 678 679 framePrivate->setInPrintingMode(TRUE, printDC); 680 681 UINT pageCount = 0; 682 framePrivate->getPrintedPageCount(printDC, &pageCount); 683 684 DOCINFO di; 685 initDocStruct(&di, L"WebKit Doc"); 686 ::StartDoc(printDC, &di); 687 688 // FIXME: Need CoreGraphics implementation 689 void* graphicsContext = 0; 690 for (size_t page = 1; page <= pageCount; ++page) { 691 ::StartPage(printDC); 692 framePrivate->spoolPages(printDC, page, page, graphicsContext); 693 ::EndPage(printDC); 694 } 695 696 framePrivate->setInPrintingMode(FALSE, printDC); 697 698 ::EndDoc(printDC); 699 ::DeleteDC(printDC); 700 } 701 702 static void setWindowText(HWND dialog, UINT field, _bstr_t value) 703 { 704 ::SetDlgItemText(dialog, field, value); 705 } 706 707 static void setWindowText(HWND dialog, UINT field, UINT value) 708 { 709 String valueStr = WTF::String::number(value); 710 711 setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); 712 } 713 714 typedef _com_ptr_t<_com_IIID<IPropertyBag, &__uuidof(IPropertyBag)>> IPropertyBagPtr; 715 716 static void setWindowText(HWND dialog, UINT field, IPropertyBagPtr statistics, const _bstr_t& key) 717 { 718 _variant_t var; 719 V_VT(&var) = VT_UI8; 720 if (FAILED(statistics->Read(key, &var.GetVARIANT(), nullptr))) 721 return; 722 723 unsigned long long value = V_UI8(&var); 724 String valueStr = WTF::String::number(value); 725 726 setWindowText(dialog, field, _bstr_t(valueStr.utf8().data())); 727 } 728 729 static void setWindowText(HWND dialog, UINT field, CFDictionaryRef dictionary, CFStringRef key, UINT& total) 730 { 731 CFNumberRef countNum = static_cast<CFNumberRef>(CFDictionaryGetValue(dictionary, key)); 732 if (!countNum) 733 return; 734 735 int count = 0; 736 CFNumberGetValue(countNum, kCFNumberIntType, &count); 737 738 setWindowText(dialog, field, static_cast<UINT>(count)); 739 total += count; 740 } 741 742 void MiniBrowser::updateStatistics(HWND dialog) 743 { 744 IWebCoreStatisticsPtr webCoreStatistics = statistics(); 745 if (!webCoreStatistics) 746 return; 747 748 IPropertyBagPtr statistics; 749 HRESULT hr = webCoreStatistics->memoryStatistics(&statistics.GetInterfacePtr()); 750 if (FAILED(hr)) 751 return; 752 753 // FastMalloc. 754 setWindowText(dialog, IDC_RESERVED_VM, statistics, "FastMallocReservedVMBytes"); 755 setWindowText(dialog, IDC_COMMITTED_VM, statistics, "FastMallocCommittedVMBytes"); 756 setWindowText(dialog, IDC_FREE_LIST_BYTES, statistics, "FastMallocFreeListBytes"); 757 758 // WebCore Cache. 759 #if USE(CF) 760 IWebCachePtr webCache = this->webCache(); 761 762 int dictCount = 6; 763 IPropertyBag* cacheDict[6] = { 0 }; 764 if (FAILED(webCache->statistics(&dictCount, cacheDict))) 765 return; 766 767 COMPtr<CFDictionaryPropertyBag> counts, sizes, liveSizes, decodedSizes, purgableSizes; 768 counts.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[0])); 769 sizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[1])); 770 liveSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[2])); 771 decodedSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[3])); 772 purgableSizes.adoptRef(reinterpret_cast<CFDictionaryPropertyBag*>(cacheDict[4])); 773 774 static CFStringRef imagesKey = CFSTR("images"); 775 static CFStringRef stylesheetsKey = CFSTR("style sheets"); 776 static CFStringRef xslKey = CFSTR("xsl"); 777 static CFStringRef scriptsKey = CFSTR("scripts"); 778 779 if (counts) { 780 UINT totalObjects = 0; 781 setWindowText(dialog, IDC_IMAGES_OBJECT_COUNT, counts->dictionary(), imagesKey, totalObjects); 782 setWindowText(dialog, IDC_CSS_OBJECT_COUNT, counts->dictionary(), stylesheetsKey, totalObjects); 783 setWindowText(dialog, IDC_XSL_OBJECT_COUNT, counts->dictionary(), xslKey, totalObjects); 784 setWindowText(dialog, IDC_JSC_OBJECT_COUNT, counts->dictionary(), scriptsKey, totalObjects); 785 setWindowText(dialog, IDC_TOTAL_OBJECT_COUNT, totalObjects); 786 } 787 788 if (sizes) { 789 UINT totalBytes = 0; 790 setWindowText(dialog, IDC_IMAGES_BYTES, sizes->dictionary(), imagesKey, totalBytes); 791 setWindowText(dialog, IDC_CSS_BYTES, sizes->dictionary(), stylesheetsKey, totalBytes); 792 setWindowText(dialog, IDC_XSL_BYTES, sizes->dictionary(), xslKey, totalBytes); 793 setWindowText(dialog, IDC_JSC_BYTES, sizes->dictionary(), scriptsKey, totalBytes); 794 setWindowText(dialog, IDC_TOTAL_BYTES, totalBytes); 795 } 796 797 if (liveSizes) { 798 UINT totalLiveBytes = 0; 799 setWindowText(dialog, IDC_IMAGES_LIVE_COUNT, liveSizes->dictionary(), imagesKey, totalLiveBytes); 800 setWindowText(dialog, IDC_CSS_LIVE_COUNT, liveSizes->dictionary(), stylesheetsKey, totalLiveBytes); 801 setWindowText(dialog, IDC_XSL_LIVE_COUNT, liveSizes->dictionary(), xslKey, totalLiveBytes); 802 setWindowText(dialog, IDC_JSC_LIVE_COUNT, liveSizes->dictionary(), scriptsKey, totalLiveBytes); 803 setWindowText(dialog, IDC_TOTAL_LIVE_COUNT, totalLiveBytes); 804 } 805 806 if (decodedSizes) { 807 UINT totalDecoded = 0; 808 setWindowText(dialog, IDC_IMAGES_DECODED_COUNT, decodedSizes->dictionary(), imagesKey, totalDecoded); 809 setWindowText(dialog, IDC_CSS_DECODED_COUNT, decodedSizes->dictionary(), stylesheetsKey, totalDecoded); 810 setWindowText(dialog, IDC_XSL_DECODED_COUNT, decodedSizes->dictionary(), xslKey, totalDecoded); 811 setWindowText(dialog, IDC_JSC_DECODED_COUNT, decodedSizes->dictionary(), scriptsKey, totalDecoded); 812 setWindowText(dialog, IDC_TOTAL_DECODED, totalDecoded); 813 } 814 815 if (purgableSizes) { 816 UINT totalPurgable = 0; 817 setWindowText(dialog, IDC_IMAGES_PURGEABLE_COUNT, purgableSizes->dictionary(), imagesKey, totalPurgable); 818 setWindowText(dialog, IDC_CSS_PURGEABLE_COUNT, purgableSizes->dictionary(), stylesheetsKey, totalPurgable); 819 setWindowText(dialog, IDC_XSL_PURGEABLE_COUNT, purgableSizes->dictionary(), xslKey, totalPurgable); 820 setWindowText(dialog, IDC_JSC_PURGEABLE_COUNT, purgableSizes->dictionary(), scriptsKey, totalPurgable); 821 setWindowText(dialog, IDC_TOTAL_PURGEABLE, totalPurgable); 822 } 823 #endif 824 825 // JavaScript Heap. 826 setWindowText(dialog, IDC_JSC_HEAP_SIZE, statistics, "JavaScriptHeapSize"); 827 setWindowText(dialog, IDC_JSC_HEAP_FREE, statistics, "JavaScriptFreeSize"); 828 829 UINT count; 830 if (SUCCEEDED(webCoreStatistics->javaScriptObjectsCount(&count))) 831 setWindowText(dialog, IDC_TOTAL_JSC_HEAP_OBJECTS, count); 832 if (SUCCEEDED(webCoreStatistics->javaScriptGlobalObjectsCount(&count))) 833 setWindowText(dialog, IDC_GLOBAL_JSC_HEAP_OBJECTS, count); 834 if (SUCCEEDED(webCoreStatistics->javaScriptProtectedObjectsCount(&count))) 835 setWindowText(dialog, IDC_PROTECTED_JSC_HEAP_OBJECTS, count); 836 837 // Font and Glyph Caches. 838 if (SUCCEEDED(webCoreStatistics->cachedFontDataCount(&count))) 839 setWindowText(dialog, IDC_TOTAL_FONT_OBJECTS, count); 840 if (SUCCEEDED(webCoreStatistics->cachedFontDataInactiveCount(&count))) 841 setWindowText(dialog, IDC_INACTIVE_FONT_OBJECTS, count); 842 if (SUCCEEDED(webCoreStatistics->glyphPageCount(&count))) 843 setWindowText(dialog, IDC_GLYPH_PAGES, count); 844 845 // Site Icon Database. 846 if (SUCCEEDED(webCoreStatistics->iconPageURLMappingCount(&count))) 847 setWindowText(dialog, IDC_PAGE_URL_MAPPINGS, count); 848 if (SUCCEEDED(webCoreStatistics->iconRetainedPageURLCount(&count))) 849 setWindowText(dialog, IDC_RETAINED_PAGE_URLS, count); 850 if (SUCCEEDED(webCoreStatistics->iconRecordCount(&count))) 851 setWindowText(dialog, IDC_SITE_ICON_RECORDS, count); 852 if (SUCCEEDED(webCoreStatistics->iconsWithDataCount(&count))) 853 setWindowText(dialog, IDC_SITE_ICONS_WITH_DATA, count); 854 } 855 856 void MiniBrowser::setPreference(UINT menuID, bool enable) 857 { 858 if (!standardPreferences() || !privatePreferences()) 859 return; 860 861 switch (menuID) { 862 case IDM_AVFOUNDATION: 863 standardPreferences()->setAVFoundationEnabled(enable); 864 break; 865 case IDM_ACC_COMPOSITING: 866 privatePreferences()->setAcceleratedCompositingEnabled(enable); 867 break; 868 case IDM_WK_FULLSCREEN: 869 privatePreferences()->setFullScreenEnabled(enable); 870 break; 871 case IDM_COMPOSITING_BORDERS: 872 privatePreferences()->setShowDebugBorders(enable); 873 privatePreferences()->setShowRepaintCounter(enable); 874 break; 875 case IDM_DEBUG_INFO_LAYER: 876 privatePreferences()->setShowTiledScrollingIndicator(enable); 877 break; 878 case IDM_INVERT_COLORS: 879 privatePreferences()->setShouldInvertColors(enable); 880 break; 881 case IDM_DISABLE_IMAGES: 882 standardPreferences()->setLoadsImagesAutomatically(!enable); 883 break; 884 case IDM_DISABLE_STYLES: 885 privatePreferences()->setAuthorAndUserStylesEnabled(!enable); 886 break; 887 case IDM_DISABLE_JAVASCRIPT: 888 standardPreferences()->setJavaScriptEnabled(!enable); 889 break; 890 case IDM_DISABLE_LOCAL_FILE_RESTRICTIONS: 891 privatePreferences()->setAllowUniversalAccessFromFileURLs(enable); 892 privatePreferences()->setAllowFileAccessFromFileURLs(enable); 893 break; 894 } 895 } -
trunk/Tools/MiniBrowser/win/MiniBrowser.h
r232230 r232270 45 45 typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoadDelegate)>> IWebResourceLoadDelegatePtr; 46 46 typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; 47 typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; 47 48 48 49 class MiniBrowser { … … 101 102 HWND hwnd() { return m_viewWnd; } 102 103 104 void print(); 105 void updateStatistics(HWND dialog); 106 void setPreference(UINT menuID, bool enable); 107 103 108 private: 104 109 void subclassForLayeredWindow(); -
trunk/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp
r222194 r232270 56 56 }; 57 57 58 typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;59 58 typedef _com_ptr_t<_com_IIID<IWebDataSource, &__uuidof(IWebDataSource)>> IWebDataSourcePtr; 60 59 typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
Note: See TracChangeset
for help on using the changeset viewer.