summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 22:28:40 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 22:28:40 +0000
commit5299356524f2e169ec97db351c44fe6da701984e (patch)
tree6aeb51a22c6d3c101fce0f17ea1e65a659232507 /webkit/glue
parent9c8108d9356604eec57bf3c880f1580eb41fd1c3 (diff)
downloadchromium_src-5299356524f2e169ec97db351c44fe6da701984e.zip
chromium_src-5299356524f2e169ec97db351c44fe6da701984e.tar.gz
chromium_src-5299356524f2e169ec97db351c44fe6da701984e.tar.bz2
Takes steps to make our PlatformScreen implementation more portable.
Introduces ChromiumBridge as a means for our WebCore port to depend on the embedder indirectly. This will be extended to support the rest of our port. WebWidgetImpl and ChromeClientImpl both needed to have their platformWindow getter implemented. This fixes a regression related to the most recent merge. Removes the orphaned Language.cpp (see the real one in the platform/chromium directory. Changed webkit_glue::GetMonitorInfoForWindow to webkit_glue::GetScreenInfo. This resulted in a varied amount of plumbing changes. It also pushes the platform specific bits up into the browser where they belong. ScreenInfo is a struct that is part of the webkit/glue API. R=dglazkov,eseidel Review URL: http://codereview.chromium.org/8761 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/SConscript6
-rw-r--r--webkit/glue/chrome_client_impl.cc4
-rw-r--r--webkit/glue/chromium_bridge_impl.cc46
-rw-r--r--webkit/glue/webkit_glue.cc8
-rw-r--r--webkit/glue/webkit_glue.h37
-rw-r--r--webkit/glue/webkit_glue_win.cc30
-rw-r--r--webkit/glue/webview_impl.cc4
-rw-r--r--webkit/glue/webview_impl.h1
-rw-r--r--webkit/glue/webwidget_impl.cc8
-rw-r--r--webkit/glue/webwidget_impl.h1
10 files changed, 105 insertions, 40 deletions
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript
index e8275ef..0edb2f2 100644
--- a/webkit/glue/SConscript
+++ b/webkit/glue/SConscript
@@ -23,6 +23,7 @@ input_files = [
'autocomplete_input_listener.cc',
'cache_manager.cc',
'chrome_client_impl.cc',
+ 'chromium_bridge_impl.cc',
'context_menu_client_impl.cc',
'cpp_binding_example.cc',
'cpp_bound_class.cc',
@@ -98,7 +99,10 @@ if env['PLATFORM'] == 'win32':
])
if env['PLATFORM'] == 'win32':
- input_files.append('webinputevent_win.cc')
+ input_files.extend([
+ 'webinputevent_win.cc',
+ 'webkit_glue_win.cc',
+ [)
elif env['PLATFORM'] == 'posix':
input_files.append('webinputevent_linux.cc')
diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc
index 24cbb7c..b0eaf95 100644
--- a/webkit/glue/chrome_client_impl.cc
+++ b/webkit/glue/chrome_client_impl.cc
@@ -398,8 +398,8 @@ WebCore::IntRect ChromeClientImpl::windowToScreen(
}
PlatformWidget ChromeClientImpl::platformWindow() const {
- // We have no native widget.
- return NULL;
+ WebViewDelegate* d = webview_->delegate();
+ return d ? d->GetContainingWindow(webview_) : NULL;
}
void ChromeClientImpl::mouseDidMoveOverElement(
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
new file mode 100644
index 0000000..c936b30
--- /dev/null
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -0,0 +1,46 @@
+// 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 "ChromiumBridge.h"
+
+#include "HostWindow.h"
+#include "PlatformWidget.h"
+#include "ScrollView.h"
+#include "Widget.h"
+
+#include "webkit/glue/glue_util.h"
+#include "webkit/glue/webkit_glue.h"
+
+namespace WebCore {
+
+static PlatformWidget ToPlatform(Widget* widget) {
+ return widget ? widget->root()->hostWindow()->platformWindow() : 0;
+}
+
+// Screen ---------------------------------------------------------------------
+
+int ChromiumBridge::screenDepth(Widget* widget) {
+ return webkit_glue::GetScreenInfo(ToPlatform(widget)).depth;
+}
+
+int ChromiumBridge::screenDepthPerComponent(Widget* widget) {
+ return webkit_glue::GetScreenInfo(ToPlatform(widget)).depth_per_component;
+}
+
+bool ChromiumBridge::screenIsMonochrome(Widget* widget) {
+ return webkit_glue::GetScreenInfo(ToPlatform(widget)).is_monochrome;
+}
+
+IntRect ChromiumBridge::screenRect(Widget* widget) {
+ return webkit_glue::ToIntRect(
+ webkit_glue::GetScreenInfo(ToPlatform(widget)).rect);
+}
+
+IntRect ChromiumBridge::screenAvailableRect(Widget* widget) {
+ return webkit_glue::ToIntRect(
+ webkit_glue::GetScreenInfo(ToPlatform(widget)).available_rect);
+}
+
+} // namespace WebCore
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 1c5d0fd..07b7057 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -75,14 +75,6 @@ bool IsLayoutTestMode() {
}
#if defined(OS_WIN)
-MONITORINFOEX GetMonitorInfoForWindowHelper(HWND window) {
- HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFOEX monitorInfo;
- monitorInfo.cbSize = sizeof(MONITORINFOEX);
- GetMonitorInfo(monitor, &monitorInfo);
- return monitorInfo;
-}
-
IMLangFontLink2* GetLangFontLinkHelper() {
// TODO(hbono): http://b/1072298 Experimentally disabled this code to
// prevent registry leaks caused by this IMLangFontLink2 interface.
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 71b1c68..b8b2156 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_H__
-#define WEBKIT_GLUE_H__
+#ifndef WEBKIT_GLUE_WEBKIT_GLUE_H_
+#define WEBKIT_GLUE_WEBKIT_GLUE_H_
#include "base/basictypes.h"
@@ -14,7 +14,9 @@
#include <string>
#include <vector>
+#include "base/gfx/native_widget_types.h"
#include "base/string16.h"
+#include "webkit/glue/screen_info.h"
#include "webkit/glue/webplugin.h"
// We do not include the header files for these interfaces since this header
@@ -29,16 +31,15 @@ class GURL;
struct _NPNetscapeFuncs;
typedef _NPNetscapeFuncs NPNetscapeFuncs;
-#ifdef _WIN32
+#if defined(OS_WIN)
struct IMLangFontLink2;
#endif
+// TODO(darin): This file should not be dealing in WebCore types!!
namespace WebCore {
-
class Document;
class Frame;
-
-} // namespace WebCore
+}
class SkBitmap;
@@ -69,12 +70,12 @@ bool IsLayoutTestMode();
// default way to do this operation. It can be called directly from
// GetLangFontLink.
IMLangFontLink2* GetLangFontLinkHelper();
-
-// Returns the monitor information corresponding to the window.
-// This is the default implementation.
-MONITORINFOEX GetMonitorInfoForWindowHelper(HWND window);
#endif
+// Returns screen information corresponding to the given window. This is the
+// default implementation.
+ScreenInfo GetScreenInfoHelper(gfx::ViewHandle window);
+
// Returns the text of the document element.
std::wstring DumpDocumentText(WebFrame* web_frame);
@@ -151,7 +152,7 @@ bool GetMimeTypeFromFile(const std::wstring& file_path, std::string* mime_type);
bool GetPreferredExtensionForMimeType(const std::string& mime_type,
std::wstring* ext);
-#ifdef _WIN32
+#if defined(OS_WIN)
// Returns the com object pointer for the FontLink interface
IMLangFontLink2* GetLangFontLink();
#endif
@@ -186,7 +187,7 @@ std::string GetDataResource(int resource_id);
// specified as BINDATA in the relevant .rc file.
GlueBitmap GetBitmapResource(int resource_id);
-#ifdef _WIN32
+#if defined(OS_WIN)
// Loads and returns a cursor.
HCURSOR LoadCursor(int cursor_id);
#endif
@@ -252,14 +253,14 @@ bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
// false otherwise.
bool IsPluginRunningInRendererProcess();
-#ifdef _WIN32
+#if defined(OS_WIN)
// Asks the browser to load the font.
bool EnsureFontLoaded(HFONT font);
-
-// Returns the monitor information corresponding to the window.
-MONITORINFOEX GetMonitorInfoForWindow(HWND window);
#endif
+// Returns screen information corresponding to the given window.
+ScreenInfo GetScreenInfo(gfx::ViewHandle window);
+
// Functions implemented by webkit_glue for WebKit ----------------------------
// Notifies the embedder that a form element value has changed. The document
@@ -270,7 +271,7 @@ void NotifyFormStateChanged(const WebCore::Document* document);
// Returns a bool indicating if the Null plugin should be enabled or not.
bool IsDefaultPluginEnabled();
-#ifdef _WIN32
+#if defined(OS_WIN)
// Downloads the file specified by the URL. On sucess a WM_COPYDATA message
// will be sent to the caller_window.
bool DownloadUrl(const std::string& url, HWND caller_window);
@@ -296,4 +297,4 @@ bool ShouldForcefullyTerminatePluginProcess();
} // namespace webkit_glue
-#endif // WEBKIT_GLUE_H__
+#endif // WEBKIT_GLUE_WEBKIT_GLUE_H_
diff --git a/webkit/glue/webkit_glue_win.cc b/webkit/glue/webkit_glue_win.cc
new file mode 100644
index 0000000..107a569
--- /dev/null
+++ b/webkit/glue/webkit_glue_win.cc
@@ -0,0 +1,30 @@
+// 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"
+
+namespace webkit_glue {
+
+ScreenInfo GetScreenInfoHelper(gfx::ViewHandle 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 7c5ecac..9816773 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -1377,10 +1377,6 @@ void WebViewImpl::ImageResourceDownloadDone(ImageResourceFetcher* fetcher,
// TODO(darin): Figure out what to do with these methods.
#if 0
-gfx::ViewHandle WebViewImpl::containingWindow() {
- return delegate_ ? delegate_->GetContainingWindow(this) : NULL;
-}
-
const SkBitmap* WebViewImpl::getPreloadedResourceBitmap(int resource_id) {
if (!delegate_)
return NULL;
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index e4ec4b4..96efd28 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -189,7 +189,6 @@ class WebViewImpl : public WebView, public WebCore::BackForwardListClient {
// TODO(darin): Figure out what happens to these methods.
#if 0
// WebCore::WidgetClientWin
- virtual gfx::ViewHandle containingWindow();
virtual const SkBitmap* getPreloadedResourceBitmap(int resource_id);
virtual void onScrollPositionChanged(WebCore::Widget* widget);
virtual const WTF::Vector<RefPtr<WebCore::Range> >* getTickmarks(
diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc
index c04bedb..fd04639 100644
--- a/webkit/glue/webwidget_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -230,7 +230,9 @@ WebCore::IntRect WebWidgetImpl::windowToScreen(
}
PlatformWidget WebWidgetImpl::platformWindow() const {
- return NULL;
+ if (!delegate_)
+ return NULL;
+ return delegate_->GetContainingWindow(const_cast<WebWidgetImpl*>(this));
}
//-----------------------------------------------------------------------------
@@ -250,10 +252,6 @@ void WebWidgetImpl::popupClosed(WebCore::FramelessScrollView* widget) {
// TODO(darin): Figure out what happens to these methods.
#if 0
-gfx::ViewHandle WebWidgetImpl::containingWindow() {
- return delegate_ ? delegate_->GetContainingWindow(this) : NULL;
-}
-
const SkBitmap* WebWidgetImpl::getPreloadedResourceBitmap(int resource_id) {
return NULL;
}
diff --git a/webkit/glue/webwidget_impl.h b/webkit/glue/webwidget_impl.h
index 288485f..1c8a9a2 100644
--- a/webkit/glue/webwidget_impl.h
+++ b/webkit/glue/webwidget_impl.h
@@ -89,7 +89,6 @@ class WebWidgetImpl : public WebWidget,
// TODO(darin): Figure out what happens to these methods.
#if 0
// WebCore::WidgetClientWin
- virtual gfx::ViewHandle containingWindow();
virtual const SkBitmap* getPreloadedResourceBitmap(int resource_id);
virtual void onScrollPositionChanged(WebCore::Widget* widget);
virtual const WTF::Vector<RefPtr<WebCore::Range> >* getTickmarks(