summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 23:07:19 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 23:07:19 +0000
commit12456fac1b181983b7ce52789be16e7e436a0996 (patch)
treea5a3a92808d8e78d5d620e6f900db60adcb84197 /webkit/glue
parent31b882b2aac660139d1ea77b953e6c99ab184cb4 (diff)
downloadchromium_src-12456fac1b181983b7ce52789be16e7e436a0996.zip
chromium_src-12456fac1b181983b7ce52789be16e7e436a0996.tar.gz
chromium_src-12456fac1b181983b7ce52789be16e7e436a0996.tar.bz2
Replace webkit/glue/screen_info.h with WebKit/chromium/public/WebScreenInfo.h
This also eliminates webkit_glue::GetScreenInfo and webkit_glue::GetScreenInfoHelper. As part of this CL, I also extracted all of the ParamTraits for WebKit API types into chrome/common/webkit_param_traits.h. R=dglazkov Review URL: http://codereview.chromium.org/58008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12993 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/chromium_bridge_impl.cc42
-rw-r--r--webkit/glue/glue.vcproj4
-rw-r--r--webkit/glue/screen_info.h39
-rw-r--r--webkit/glue/webkit_glue.h9
-rw-r--r--webkit/glue/webkit_glue_gtk.cc33
-rw-r--r--webkit/glue/webkit_glue_mac.mm69
-rw-r--r--webkit/glue/webkit_glue_win.cc32
-rw-r--r--webkit/glue/webview_impl.cc2
-rw-r--r--webkit/glue/webwidget_delegate.h13
-rw-r--r--webkit/glue/webwidget_impl.cc2
10 files changed, 45 insertions, 200 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index 9dc8d96..c094d94 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -31,14 +31,14 @@
#include "build/build_config.h"
#include "googleurl/src/url_util.h"
#include "skia/ext/skia_utils_win.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h"
#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/plugins/plugin_instance.h"
-#include "webkit/glue/screen_info.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webplugin_impl.h"
-#include "webkit/glue/webview.h"
+#include "webkit/glue/webview_impl.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -72,6 +72,17 @@ ChromeClientImpl* ToChromeClient(WebCore::Widget* widget) {
return static_cast<ChromeClientImpl*>(page->chrome()->client());
}
+WebViewImpl* ToWebView(WebCore::Widget* widget) {
+ ChromeClientImpl* chrome_client = ToChromeClient(widget);
+ if (!chrome_client)
+ return NULL;
+ return chrome_client->webview();
+}
+
+WebCore::IntRect ToIntRect(const WebKit::WebRect& input) {
+ return WebCore::IntRect(input.x, input.y, input.width, input.height);
+}
+
} // namespace
namespace WebCore {
@@ -163,25 +174,38 @@ String ChromiumBridge::uiResourceProtocol() {
// Screen ---------------------------------------------------------------------
int ChromiumBridge::screenDepth(Widget* widget) {
- return webkit_glue::GetScreenInfo(ToNativeId(widget)).depth;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).depth;
}
int ChromiumBridge::screenDepthPerComponent(Widget* widget) {
- return webkit_glue::GetScreenInfo(ToNativeId(widget)).depth_per_component;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).depthPerComponent;
}
bool ChromiumBridge::screenIsMonochrome(Widget* widget) {
- return webkit_glue::GetScreenInfo(ToNativeId(widget)).is_monochrome;
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return NULL;
+ return view->delegate()->GetScreenInfo(view).isMonochrome;
}
IntRect ChromiumBridge::screenRect(Widget* widget) {
- return webkit_glue::ToIntRect(
- webkit_glue::GetScreenInfo(ToNativeId(widget)).rect);
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return IntRect();
+ return ToIntRect(view->delegate()->GetScreenInfo(view).rect);
}
IntRect ChromiumBridge::screenAvailableRect(Widget* widget) {
- return webkit_glue::ToIntRect(
- webkit_glue::GetScreenInfo(ToNativeId(widget)).available_rect);
+ WebViewImpl* view = ToWebView(widget);
+ if (!view || !view->delegate())
+ return IntRect();
+ return ToIntRect(view->delegate()->GetScreenInfo(view).availableRect);
}
// Widget ---------------------------------------------------------------------
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index 2db65ac..e66e415 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -666,10 +666,6 @@
>
</File>
<File
- RelativePath=".\webkit_glue_win.cc"
- >
- </File>
- <File
RelativePath=".\webkitclient_impl.cc"
>
</File>
diff --git a/webkit/glue/screen_info.h b/webkit/glue/screen_info.h
deleted file mode 100644
index 7dbc4e5..0000000
--- a/webkit/glue/screen_info.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#ifndef WEBKIT_GLUE_SCREEN_INFO_H_
-#define WEBKIT_GLUE_SCREEN_INFO_H_
-
-#include "base/gfx/rect.h"
-
-namespace webkit_glue {
-
-struct ScreenInfo {
- // The screen depth in bits per pixel
- int depth;
- // The bits per colour component. This assumes that the colours are balanced
- // equally.
- int depth_per_component;
- // This can be true for black and white printers
- bool is_monochrome;
- // This is set from the rcMonitor member of MONITORINFOEX, to whit:
- // "A RECT structure that specifies the display monitor rectangle,
- // expressed in virtual-screen coordinates. Note that if the monitor is not
- // the primary display monitor, some of the rectangle's coordinates may be
- // negative values."
- gfx::Rect rect;
- // This is set from the rcWork member of MONITORINFOEX, to whit:
- // "A RECT structure that specifies the work area rectangle of the display
- // monitor that can be used by applications, expressed in virtual-screen
- // coordinates. Windows uses this rectangle to maximize an application on
- // the monitor. The rest of the area in rcMonitor contains system windows
- // such as the task bar and side bars. Note that if the monitor is not the
- // primary display monitor, some of the rectangle's coordinates may be
- // negative values".
- gfx::Rect available_rect;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_GLUE_SCREEN_INFO_H_
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index ccaf847..db9e238 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -31,8 +31,6 @@ class WebString;
namespace webkit_glue {
-struct ScreenInfo;
-
//---- BEGIN FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE -----------------------------
@@ -41,10 +39,6 @@ void SetJavaScriptFlags(const std::wstring& flags);
// Turn on the logging for notImplemented() calls from WebCore.
void EnableWebCoreNotImplementedLogging();
-// Returns screen information corresponding to the given window. This is the
-// default implementation.
-ScreenInfo GetScreenInfoHelper(gfx::NativeView window);
-
// Returns the text of the document element.
std::wstring DumpDocumentText(WebFrame* web_frame);
@@ -193,9 +187,6 @@ bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
// false otherwise.
bool IsPluginRunningInRendererProcess();
-// Returns screen information corresponding to the given window.
-ScreenInfo GetScreenInfo(gfx::NativeViewId window);
-
// Returns a bool indicating if the Null plugin should be enabled or not.
bool IsDefaultPluginEnabled();
diff --git a/webkit/glue/webkit_glue_gtk.cc b/webkit/glue/webkit_glue_gtk.cc
deleted file mode 100644
index 8ceb35d..0000000
--- a/webkit/glue/webkit_glue_gtk.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "webkit/glue/webkit_glue.h"
-
-#include <gtk/gtk.h>
-
-#include "webkit/glue/screen_info.h"
-
-namespace webkit_glue {
-
-ScreenInfo GetScreenInfoHelper(gfx::NativeView window) {
- ScreenInfo results;
- results.depth = 32;
- results.depth_per_component = 8;
- results.is_monochrome = false;
-
- if (!window)
- return results;
-
- GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(window));
- results.rect.SetRect(0, 0, gdk_screen_get_width(screen),
- gdk_screen_get_height(screen));
- // I don't know of a way to query the "maximise" size of the window (e.g.
- // screen size less sidebars etc) since this is something which only the
- // window manager knows.
- results.available_rect = results.rect;
-
- return results;
-}
-
-} // namespace webkit_glue
diff --git a/webkit/glue/webkit_glue_mac.mm b/webkit/glue/webkit_glue_mac.mm
deleted file mode 100644
index 484b6f1..0000000
--- a/webkit/glue/webkit_glue_mac.mm
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "config.h"
-
-#include "webkit/glue/webkit_glue.h"
-
-#import <AppKit/AppKit.h>
-
-#include "webkit/glue/screen_info.h"
-
-namespace webkit_glue {
-
-static NSScreen *ScreenForWindow(NSWindow *window) {
- NSScreen *screen = [window screen]; // nil if the window is off-screen
- if (screen)
- return screen;
-
- NSArray *screens = [NSScreen screens];
- if ([screens count] > 0)
- return [screens objectAtIndex:0]; // screen containing the menubar
-
- return nil;
-}
-
-static gfx::Rect ToUserSpace(const NSRect& rect, NSWindow *destination) {
- CGRect user_rect = NSRectToCGRect(rect);
-
- user_rect.origin.y =
- NSMaxY([ScreenForWindow(destination) frame]) -
- (user_rect.origin.y + user_rect.size.height); // flip
-
- if (destination) {
- CGFloat scale = 1 / [destination userSpaceScaleFactor]; // scale down
- user_rect.origin.x *= scale;
- user_rect.origin.y *= scale;
- user_rect.size.width *= scale;
- user_rect.size.height *= scale;
- }
-
- return gfx::Rect(user_rect);
-}
-
-ScreenInfo GetScreenInfoHelper(gfx::NativeView view) {
- NSString *color_space = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]);
- bool monochrome = color_space == NSCalibratedWhiteColorSpace ||
- color_space == NSCalibratedBlackColorSpace ||
- color_space == NSDeviceWhiteColorSpace ||
- color_space == NSDeviceBlackColorSpace;
-
- ScreenInfo results;
- results.depth =
- NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
- results.depth_per_component =
- NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]);
- results.is_monochrome =
- color_space == NSCalibratedWhiteColorSpace ||
- color_space == NSCalibratedBlackColorSpace ||
- color_space == NSDeviceWhiteColorSpace ||
- color_space == NSDeviceBlackColorSpace;
- results.rect =
- ToUserSpace([ScreenForWindow([view window]) frame], [view window]);
- results.available_rect =
- ToUserSpace([ScreenForWindow([view window]) visibleFrame], [view window]);
- return results;
-}
-
-} // namespace webkit_glue
diff --git a/webkit/glue/webkit_glue_win.cc b/webkit/glue/webkit_glue_win.cc
deleted file mode 100644
index 82242f7..0000000
--- a/webkit/glue/webkit_glue_win.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-#include "webkit/glue/webkit_glue.h"
-
-#include "webkit/glue/screen_info.h"
-
-namespace webkit_glue {
-
-ScreenInfo GetScreenInfoHelper(gfx::NativeView window) {
- HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
-
- MONITORINFOEX monitor_info;
- monitor_info.cbSize = sizeof(MONITORINFOEX);
- GetMonitorInfo(monitor, &monitor_info);
-
- DEVMODE dev_mode;
- dev_mode.dmSize = sizeof(dev_mode);
- dev_mode.dmDriverExtra = 0;
- EnumDisplaySettings(monitor_info.szDevice, ENUM_CURRENT_SETTINGS, &dev_mode);
-
- ScreenInfo results;
- results.depth = dev_mode.dmBitsPerPel;
- results.depth_per_component = dev_mode.dmBitsPerPel / 3; // Assumes RGB
- results.is_monochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME;
- results.rect = gfx::Rect(monitor_info.rcMonitor);
- results.available_rect = gfx::Rect(monitor_info.rcWork);
- return results;
-}
-
-} // namespace webkit_glue
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 492d0c3..b2792b8 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -1742,7 +1742,7 @@ bool WebViewImpl::isHidden() {
if (!delegate_)
return true;
- return delegate_->IsHidden();
+ return delegate_->IsHidden(this);
}
#endif
diff --git a/webkit/glue/webwidget_delegate.h b/webkit/glue/webwidget_delegate.h
index 05ed760..37f3ff3 100644
--- a/webkit/glue/webwidget_delegate.h
+++ b/webkit/glue/webwidget_delegate.h
@@ -13,8 +13,12 @@
#include "webkit/glue/window_open_disposition.h"
namespace gfx {
- class Point;
- class Rect;
+class Point;
+class Rect;
+}
+
+namespace WebKit {
+struct WebScreenInfo;
}
class WebWidget;
@@ -121,7 +125,10 @@ class WebWidgetDelegate {
virtual void Release() = 0;
// Returns true if the widget is in a background tab.
- virtual bool IsHidden() = 0;
+ virtual bool IsHidden(WebWidget* webwidget) = 0;
+
+ // Returns information about the screen associated with this widget.
+ virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget) = 0;
WebWidgetDelegate() { }
virtual ~WebWidgetDelegate() { }
diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc
index 1ea7c1c..0c5f062 100644
--- a/webkit/glue/webwidget_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -300,6 +300,6 @@ bool WebWidgetImpl::isHidden() {
if (!delegate_)
return true;
- return delegate_->IsHidden();
+ return delegate_->IsHidden(this);
}
#endif