Diff
Modified: trunk/Source/WebCore/ChangeLog (102300 => 102301)
--- trunk/Source/WebCore/ChangeLog 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/ChangeLog 2011-12-08 03:03:47 UTC (rev 102301)
@@ -1,3 +1,42 @@
+2011-12-07 Fady Samuel <fsam...@chromium.org>
+
+ [Chromium] Plumb DPI info into PlatformScreen
+ https://bugs.webkit.org/show_bug.cgi?id=70556
+
+ Reviewed by Darin Fisher.
+
+ Make DPI information accessible from WebKit through
+ PlatformScreen. This is useful when making scaling
+ computations on various devices (e.g. Viewport meta tag).
+
+ This patch adds DPI plumbing on Chromium Win/Mac/Linux
+ platforms.
+
+ * page/Screen.cpp:
+ (WebCore::Screen::horizontalDPI):
+ (WebCore::Screen::verticalDPI):
+ * page/Screen.h:
+ * platform/PlatformScreen.h:
+ * platform/chromium/PlatformScreenChromium.cpp:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+ * platform/chromium/PlatformSupport.h:
+ * platform/efl/PlatformScreenEfl.cpp:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+ * platform/gtk/PlatformScreenGtk.cpp:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+ * platform/mac/PlatformScreenMac.mm:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+ * platform/qt/PlatformScreenQt.cpp:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+ * platform/win/PlatformScreenWin.cpp:
+ (WebCore::screenHorizontalDPI):
+ (WebCore::screenVerticalDPI):
+
2011-12-07 Aaron Colwell <acolw...@chromium.org>
Revert mixed content handling for video fix and follow-up test expectations & Skipped changes.
Modified: trunk/Source/WebCore/page/Screen.cpp (102300 => 102301)
--- trunk/Source/WebCore/page/Screen.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/page/Screen.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -53,6 +53,20 @@
m_frame = 0;
}
+unsigned Screen::horizontalDPI() const
+{
+ if (!m_frame)
+ return 0;
+ return static_cast<unsigned>(screenHorizontalDPI(m_frame->view()));
+}
+
+unsigned Screen::verticalDPI() const
+{
+ if (!m_frame)
+ return 0;
+ return static_cast<unsigned>(screenVerticalDPI(m_frame->view()));
+}
+
unsigned Screen::height() const
{
if (!m_frame)
Modified: trunk/Source/WebCore/page/Screen.h (102300 => 102301)
--- trunk/Source/WebCore/page/Screen.h 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/page/Screen.h 2011-12-08 03:03:47 UTC (rev 102301)
@@ -44,6 +44,8 @@
Frame* frame() const;
void disconnectFrame();
+ unsigned horizontalDPI() const;
+ unsigned verticalDPI() const;
unsigned height() const;
unsigned width() const;
unsigned colorDepth() const;
Modified: trunk/Source/WebCore/platform/PlatformScreen.h (102300 => 102301)
--- trunk/Source/WebCore/platform/PlatformScreen.h 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/PlatformScreen.h 2011-12-08 03:03:47 UTC (rev 102301)
@@ -47,6 +47,8 @@
class FloatRect;
class Widget;
+ int screenHorizontalDPI(Widget*);
+ int screenVerticalDPI(Widget*);
int screenDepth(Widget*);
int screenDepthPerComponent(Widget*);
bool screenIsMonochrome(Widget*);
Modified: trunk/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp (102300 => 102301)
--- trunk/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -36,6 +36,16 @@
namespace WebCore {
+int screenHorizontalDPI(Widget* widget)
+{
+ return PlatformSupport::screenHorizontalDPI(widget);
+}
+
+int screenVerticalDPI(Widget* widget)
+{
+ return PlatformSupport::screenVerticalDPI(widget);
+}
+
int screenDepth(Widget* widget)
{
return PlatformSupport::screenDepth(widget);
Modified: trunk/Source/WebCore/platform/chromium/PlatformSupport.h (102300 => 102301)
--- trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-12-08 03:03:47 UTC (rev 102301)
@@ -240,6 +240,8 @@
static bool sandboxEnabled();
// Screen -------------------------------------------------------------
+ static int screenHorizontalDPI(Widget*);
+ static int screenVerticalDPI(Widget*);
static int screenDepth(Widget*);
static int screenDepthPerComponent(Widget*);
static bool screenIsMonochrome(Widget*);
Modified: trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp (102300 => 102301)
--- trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -42,7 +42,19 @@
#include <wtf/text/CString.h>
namespace WebCore {
+
+int screenHorizontalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+int screenVerticalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
int screenDepth(Widget* widget)
{
notImplemented();
Modified: trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp (102300 => 102301)
--- trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -33,6 +33,7 @@
#include "GtkVersioning.h"
#include "HostWindow.h"
+#include "NotImplemented.h"
#include "ScrollView.h"
#include "Widget.h"
@@ -67,6 +68,18 @@
return container ? gdk_window_get_visual(gtk_widget_get_window(container)) : 0;
}
+int screenHorizontalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
+int screenVerticalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
int screenDepth(Widget* widget)
{
GdkVisual* visual = getVisual(widget);
Modified: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (102300 => 102301)
--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2011-12-08 03:03:47 UTC (rev 102301)
@@ -30,9 +30,22 @@
#import "Frame.h"
#import "FrameView.h"
#import "Page.h"
+#import "NotImplemented.h"
namespace WebCore {
+int screenHorizontalDPI(Widget*)
+{
+ notImplemented();
+ return 0;
+}
+
+int screenVerticalDPI(Widget*)
+{
+ notImplemented();
+ return 0;
+}
+
int screenDepth(Widget*)
{
return NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
Modified: trunk/Source/WebCore/platform/qt/PlatformScreenQt.cpp (102300 => 102301)
--- trunk/Source/WebCore/platform/qt/PlatformScreenQt.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/qt/PlatformScreenQt.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -35,6 +35,7 @@
#include "Frame.h"
#include "FrameView.h"
#include "HostWindow.h"
+#include "NotImplemented.h"
#include "Widget.h"
#include "QWebPageClient.h"
#include <QApplication>
@@ -42,6 +43,18 @@
namespace WebCore {
+int screenHorizontalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
+int screenVerticalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
static int screenNumber(Widget* w)
{
if (!w)
Modified: trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp (102300 => 102301)
--- trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -27,11 +27,12 @@
#include "config.h"
#include "PlatformScreen.h"
-#include "HostWindow.h"
-#include "IntRect.h"
#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
+#include "HostWindow.h"
+#include "IntRect.h"
+#include "NotImplemented.h"
#include "Page.h"
#include <windows.h>
@@ -65,6 +66,18 @@
return deviceInfo;
}
+int screenHorizontalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
+int screenVerticalDPI(Widget* widget)
+{
+ notImplemented();
+ return 0;
+}
+
int screenDepth(Widget* widget)
{
DEVMODE deviceInfo = deviceInfoForWidget(widget);
Modified: trunk/Source/WebKit/chromium/ChangeLog (102300 => 102301)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-12-08 03:03:47 UTC (rev 102301)
@@ -1,3 +1,29 @@
+2011-12-07 Fady Samuel <fsam...@chromium.org>
+
+ [Chromium] Plumb DPI info into PlatformScreen
+ https://bugs.webkit.org/show_bug.cgi?id=70556
+
+ Reviewed by Darin Fisher.
+
+ Make DPI information accessible from WebKit through
+ PlatformScreen. This is useful when making scaling
+ computations on various devices (e.g. Viewport meta tag).
+
+ This patch adds DPI plumbing on Chromium Win/Mac/Linux
+ platforms.
+
+ * public/WebScreenInfo.h:
+ (WebKit::WebScreenInfo::WebScreenInfo):
+ * src/PlatformSupport.cpp:
+ (WebCore::PlatformSupport::screenHorizontalDPI):
+ (WebCore::PlatformSupport::screenVerticalDPI):
+ * src/mac/WebScreenInfoFactory.mm:
+ (WebKit::WebScreenInfoFactory::screenInfo):
+ * src/win/WebScreenInfoFactory.cpp:
+ (WebKit::WebScreenInfoFactory::screenInfo):
+ * src/x11/WebScreenInfoFactory.cpp:
+ (WebKit::WebScreenInfoFactory::screenInfo):
+
2011-12-07 Alexandre Elias <ael...@google.com>
[chromium] Preserve original pageScale limits in WebViewImpl
Modified: trunk/Source/WebKit/chromium/public/WebScreenInfo.h (102300 => 102301)
--- trunk/Source/WebKit/chromium/public/WebScreenInfo.h 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/public/WebScreenInfo.h 2011-12-08 03:03:47 UTC (rev 102301)
@@ -36,6 +36,12 @@
namespace WebKit {
struct WebScreenInfo {
+ // The horizontal screen dpi.
+ int horizontalDPI;
+
+ // The vertical screen dpi.
+ int verticalDPI;
+
// The screen depth in bits per pixel
int depth;
@@ -67,7 +73,9 @@
double refreshRate;
WebScreenInfo()
- : depth(0)
+ : horizontalDPI(0)
+ , verticalDPI(0)
+ , depth(0)
, depthPerComponent(0)
, isMonochrome(false)
, refreshRate(0) { }
Modified: trunk/Source/WebKit/chromium/src/PlatformSupport.cpp (102300 => 102301)
--- trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -1052,6 +1052,22 @@
return static_cast<int>(webKitPlatformSupport()->highUsageDeltaMB());
}
+int PlatformSupport::screenHorizontalDPI(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return 0;
+ return client->screenInfo().horizontalDPI;
+}
+
+int PlatformSupport::screenVerticalDPI(Widget* widget)
+{
+ WebWidgetClient* client = toWebWidgetClient(widget);
+ if (!client)
+ return 0;
+ return client->screenInfo().verticalDPI;
+}
+
int PlatformSupport::screenDepth(Widget* widget)
{
WebWidgetClient* client = toWebWidgetClient(widget);
Modified: trunk/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm (102300 => 102301)
--- trunk/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/src/mac/WebScreenInfoFactory.mm 2011-12-08 03:03:47 UTC (rev 102301)
@@ -76,6 +76,15 @@
NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]);
WebScreenInfo results;
+
+ // FIXME: Currently Mac seems to always report 72dpi. Need to find a way to
+ // report the true screen dpi.
+ NSWindow* window = [view window];
+ NSDictionary* deviceDescription = [window deviceDescription];
+ NSSize deviceDPI = [[deviceDescription valueForKey:NSDeviceResolution] sizeValue];
+ results.horizontalDPI = static_cast<int>(deviceDPI.width);
+ results.verticalDPI = static_cast<int>(deviceDPI.height);
+
results.depth =
NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
results.depthPerComponent =
Modified: trunk/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp (102300 => 102301)
--- trunk/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/src/win/WebScreenInfoFactory.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -60,7 +60,11 @@
devMode.dmDriverExtra = 0;
EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode);
+ HDC hdc = GetDC(0);
+
WebScreenInfo results;
+ results.horizontalDPI = GetDeviceCaps(hdc, LOGPIXELSX);
+ results.verticalDPI = GetDeviceCaps(hdc, LOGPIXELSY);
results.depth = devMode.dmBitsPerPel;
results.depthPerComponent = devMode.dmBitsPerPel / 3; // Assumes RGB
results.isMonochrome = devMode.dmColor == DMCOLOR_MONOCHROME;
Modified: trunk/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp (102300 => 102301)
--- trunk/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp 2011-12-08 02:45:00 UTC (rev 102300)
+++ trunk/Source/WebKit/chromium/src/x11/WebScreenInfoFactory.cpp 2011-12-08 03:03:47 UTC (rev 102301)
@@ -34,6 +34,7 @@
#include "WebScreenInfo.h"
#include <X11/Xlib.h>
+#include <stdio.h>
namespace WebKit {
@@ -43,6 +44,7 @@
// function, but it appears to return stale data after the screen is resized.
WebScreenInfo WebScreenInfoFactory::screenInfo(Display* display, int screenNumber)
{
+ const float inchesPerMillimeter = 25.4;
// XDisplayWidth() and XDisplayHeight() return cached values. To ensure that
// we return the correct dimensions after the screen is resized, query the
// root window's geometry each time.
@@ -54,6 +56,14 @@
display, root, &rootRet, &x, &y, &width, &height, &border, &depth);
WebScreenInfo results;
+ int displayWidth = DisplayWidth(display, screenNumber);
+ int displayWidthInMillimeters = DisplayWidthMM(display, screenNumber);
+ results.horizontalDPI = static_cast<int>(inchesPerMillimeter * displayWidth / displayWidthInMillimeters);
+
+ int displayHeight = DisplayHeight(display, screenNumber);
+ int displayHeightInMillimeters = DisplayHeightMM(display, screenNumber);
+ results.verticalDPI = static_cast<int>(inchesPerMillimeter * displayHeight / displayHeightInMillimeters);
+
// FIXME: Not all screens use 8bpp.
results.depthPerComponent = 8;
results.depth = depth;