Changeset 102301 in webkit
- Timestamp:
- Dec 7, 2011 7:03:47 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r102300 r102301 1 2011-12-07 Fady Samuel <fsamuel@chromium.org> 2 3 [Chromium] Plumb DPI info into PlatformScreen 4 https://bugs.webkit.org/show_bug.cgi?id=70556 5 6 Reviewed by Darin Fisher. 7 8 Make DPI information accessible from WebKit through 9 PlatformScreen. This is useful when making scaling 10 computations on various devices (e.g. Viewport meta tag). 11 12 This patch adds DPI plumbing on Chromium Win/Mac/Linux 13 platforms. 14 15 * page/Screen.cpp: 16 (WebCore::Screen::horizontalDPI): 17 (WebCore::Screen::verticalDPI): 18 * page/Screen.h: 19 * platform/PlatformScreen.h: 20 * platform/chromium/PlatformScreenChromium.cpp: 21 (WebCore::screenHorizontalDPI): 22 (WebCore::screenVerticalDPI): 23 * platform/chromium/PlatformSupport.h: 24 * platform/efl/PlatformScreenEfl.cpp: 25 (WebCore::screenHorizontalDPI): 26 (WebCore::screenVerticalDPI): 27 * platform/gtk/PlatformScreenGtk.cpp: 28 (WebCore::screenHorizontalDPI): 29 (WebCore::screenVerticalDPI): 30 * platform/mac/PlatformScreenMac.mm: 31 (WebCore::screenHorizontalDPI): 32 (WebCore::screenVerticalDPI): 33 * platform/qt/PlatformScreenQt.cpp: 34 (WebCore::screenHorizontalDPI): 35 (WebCore::screenVerticalDPI): 36 * platform/win/PlatformScreenWin.cpp: 37 (WebCore::screenHorizontalDPI): 38 (WebCore::screenVerticalDPI): 39 1 40 2011-12-07 Aaron Colwell <acolwell@chromium.org> 2 41 -
trunk/Source/WebCore/page/Screen.cpp
r69599 r102301 52 52 { 53 53 m_frame = 0; 54 } 55 56 unsigned Screen::horizontalDPI() const 57 { 58 if (!m_frame) 59 return 0; 60 return static_cast<unsigned>(screenHorizontalDPI(m_frame->view())); 61 } 62 63 unsigned Screen::verticalDPI() const 64 { 65 if (!m_frame) 66 return 0; 67 return static_cast<unsigned>(screenVerticalDPI(m_frame->view())); 54 68 } 55 69 -
trunk/Source/WebCore/page/Screen.h
r69599 r102301 45 45 void disconnectFrame(); 46 46 47 unsigned horizontalDPI() const; 48 unsigned verticalDPI() const; 47 49 unsigned height() const; 48 50 unsigned width() const; -
trunk/Source/WebCore/platform/PlatformScreen.h
r100751 r102301 48 48 class Widget; 49 49 50 int screenHorizontalDPI(Widget*); 51 int screenVerticalDPI(Widget*); 50 52 int screenDepth(Widget*); 51 53 int screenDepthPerComponent(Widget*); -
trunk/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp
r100751 r102301 37 37 namespace WebCore { 38 38 39 int screenHorizontalDPI(Widget* widget) 40 { 41 return PlatformSupport::screenHorizontalDPI(widget); 42 } 43 44 int screenVerticalDPI(Widget* widget) 45 { 46 return PlatformSupport::screenVerticalDPI(widget); 47 } 48 39 49 int screenDepth(Widget* widget) 40 50 { -
trunk/Source/WebCore/platform/chromium/PlatformSupport.h
r101828 r102301 241 241 242 242 // Screen ------------------------------------------------------------- 243 static int screenHorizontalDPI(Widget*); 244 static int screenVerticalDPI(Widget*); 243 245 static int screenDepth(Widget*); 244 246 static int screenDepthPerComponent(Widget*); -
trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp
r95901 r102301 43 43 44 44 namespace WebCore { 45 46 int screenHorizontalDPI(Widget* widget) 47 { 48 notImplemented(); 49 return 0; 50 } 51 52 int screenVerticalDPI(Widget* widget) 53 { 54 notImplemented(); 55 return 0; 56 } 45 57 46 58 int screenDepth(Widget* widget) -
trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp
r89673 r102301 34 34 #include "GtkVersioning.h" 35 35 #include "HostWindow.h" 36 #include "NotImplemented.h" 36 37 #include "ScrollView.h" 37 38 #include "Widget.h" … … 66 67 container = getToplevel(container); 67 68 return container ? gdk_window_get_visual(gtk_widget_get_window(container)) : 0; 69 } 70 71 int screenHorizontalDPI(Widget* widget) 72 { 73 notImplemented(); 74 return 0; 75 } 76 77 int screenVerticalDPI(Widget* widget) 78 { 79 notImplemented(); 80 return 0; 68 81 } 69 82 -
trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm
r82398 r102301 31 31 #import "FrameView.h" 32 32 #import "Page.h" 33 #import "NotImplemented.h" 33 34 34 35 namespace WebCore { 36 37 int screenHorizontalDPI(Widget*) 38 { 39 notImplemented(); 40 return 0; 41 } 42 43 int screenVerticalDPI(Widget*) 44 { 45 notImplemented(); 46 return 0; 47 } 35 48 36 49 int screenDepth(Widget*) -
trunk/Source/WebCore/platform/qt/PlatformScreenQt.cpp
r91452 r102301 36 36 #include "FrameView.h" 37 37 #include "HostWindow.h" 38 #include "NotImplemented.h" 38 39 #include "Widget.h" 39 40 #include "QWebPageClient.h" … … 42 43 43 44 namespace WebCore { 45 46 int screenHorizontalDPI(Widget* widget) 47 { 48 notImplemented(); 49 return 0; 50 } 51 52 int screenVerticalDPI(Widget* widget) 53 { 54 notImplemented(); 55 return 0; 56 } 44 57 45 58 static int screenNumber(Widget* w) -
trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp
r68809 r102301 28 28 #include "PlatformScreen.h" 29 29 30 #include "HostWindow.h"31 #include "IntRect.h"32 30 #include "FloatRect.h" 33 31 #include "Frame.h" 34 32 #include "FrameView.h" 33 #include "HostWindow.h" 34 #include "IntRect.h" 35 #include "NotImplemented.h" 35 36 #include "Page.h" 36 37 #include <windows.h> … … 64 65 65 66 return deviceInfo; 67 } 68 69 int screenHorizontalDPI(Widget* widget) 70 { 71 notImplemented(); 72 return 0; 73 } 74 75 int screenVerticalDPI(Widget* widget) 76 { 77 notImplemented(); 78 return 0; 66 79 } 67 80 -
trunk/Source/WebKit/chromium/ChangeLog
r102292 r102301 1 2011-12-07 Fady Samuel <fsamuel@chromium.org> 2 3 [Chromium] Plumb DPI info into PlatformScreen 4 https://bugs.webkit.org/show_bug.cgi?id=70556 5 6 Reviewed by Darin Fisher. 7 8 Make DPI information accessible from WebKit through 9 PlatformScreen. This is useful when making scaling 10 computations on various devices (e.g. Viewport meta tag). 11 12 This patch adds DPI plumbing on Chromium Win/Mac/Linux 13 platforms. 14 15 * public/WebScreenInfo.h: 16 (WebKit::WebScreenInfo::WebScreenInfo): 17 * src/PlatformSupport.cpp: 18 (WebCore::PlatformSupport::screenHorizontalDPI): 19 (WebCore::PlatformSupport::screenVerticalDPI): 20 * src/mac/WebScreenInfoFactory.mm: 21 (WebKit::WebScreenInfoFactory::screenInfo): 22 * src/win/WebScreenInfoFactory.cpp: 23 (WebKit::WebScreenInfoFactory::screenInfo): 24 * src/x11/WebScreenInfoFactory.cpp: 25 (WebKit::WebScreenInfoFactory::screenInfo): 26 1 27 2011-12-07 Alexandre Elias <aelias@google.com> 2 28 -
trunk/Source/WebKit/chromium/public/WebScreenInfo.h
r101224 r102301 37 37 38 38 struct WebScreenInfo { 39 // The horizontal screen dpi. 40 int horizontalDPI; 41 42 // The vertical screen dpi. 43 int verticalDPI; 44 39 45 // The screen depth in bits per pixel 40 46 int depth; … … 68 74 69 75 WebScreenInfo() 70 : depth(0) 76 : horizontalDPI(0) 77 , verticalDPI(0) 78 , depth(0) 71 79 , depthPerComponent(0) 72 80 , isMonochrome(false) -
trunk/Source/WebKit/chromium/src/PlatformSupport.cpp
r102044 r102301 1053 1053 } 1054 1054 1055 int PlatformSupport::screenHorizontalDPI(Widget* widget) 1056 { 1057 WebWidgetClient* client = toWebWidgetClient(widget); 1058 if (!client) 1059 return 0; 1060 return client->screenInfo().horizontalDPI; 1061 } 1062 1063 int PlatformSupport::screenVerticalDPI(Widget* widget) 1064 { 1065 WebWidgetClient* client = toWebWidgetClient(widget); 1066 if (!client) 1067 return 0; 1068 return client->screenInfo().verticalDPI; 1069 } 1070 1055 1071 int PlatformSupport::screenDepth(Widget* widget) 1056 1072 { -
trunk/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm
r95901 r102301 77 77 78 78 WebScreenInfo results; 79 80 // FIXME: Currently Mac seems to always report 72dpi. Need to find a way to 81 // report the true screen dpi. 82 NSWindow* window = [view window]; 83 NSDictionary* deviceDescription = [window deviceDescription]; 84 NSSize deviceDPI = [[deviceDescription valueForKey:NSDeviceResolution] sizeValue]; 85 results.horizontalDPI = static_cast<int>(deviceDPI.width); 86 results.verticalDPI = static_cast<int>(deviceDPI.height); 87 79 88 results.depth = 80 89 NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]); -
trunk/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp
r95901 r102301 61 61 EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode); 62 62 63 HDC hdc = GetDC(0); 64 63 65 WebScreenInfo results; 66 results.horizontalDPI = GetDeviceCaps(hdc, LOGPIXELSX); 67 results.verticalDPI = GetDeviceCaps(hdc, LOGPIXELSY); 64 68 results.depth = devMode.dmBitsPerPel; 65 69 results.depthPerComponent = devMode.dmBitsPerPel / 3; // Assumes RGB -
trunk/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp
r95901 r102301 35 35 36 36 #include <X11/Xlib.h> 37 #include <stdio.h> 37 38 38 39 namespace WebKit { … … 44 45 WebScreenInfo WebScreenInfoFactory::screenInfo(Display* display, int screenNumber) 45 46 { 47 const float inchesPerMillimeter = 25.4; 46 48 // XDisplayWidth() and XDisplayHeight() return cached values. To ensure that 47 49 // we return the correct dimensions after the screen is resized, query the … … 55 57 56 58 WebScreenInfo results; 59 int displayWidth = DisplayWidth(display, screenNumber); 60 int displayWidthInMillimeters = DisplayWidthMM(display, screenNumber); 61 results.horizontalDPI = static_cast<int>(inchesPerMillimeter * displayWidth / displayWidthInMillimeters); 62 63 int displayHeight = DisplayHeight(display, screenNumber); 64 int displayHeightInMillimeters = DisplayHeightMM(display, screenNumber); 65 results.verticalDPI = static_cast<int>(inchesPerMillimeter * displayHeight / displayHeightInMillimeters); 66 57 67 // FIXME: Not all screens use 8bpp. 58 68 results.depthPerComponent = 8;
Note: See TracChangeset
for help on using the changeset viewer.