diff options
23 files changed, 330 insertions, 273 deletions
diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc index 534e447..17c266b 100644 --- a/chrome/browser/resource_message_filter.cc +++ b/chrome/browser/resource_message_filter.cc @@ -25,57 +25,9 @@ #include "chrome/common/render_messages.h" #include "net/base/cookie_monster.h" #include "net/base/mime_util.h" +#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin.h" -void ResourceMessageFilter::OnGetMonitorInfoForWindow( - HWND window, MONITORINFOEX* monitor_info) { - HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY); - monitor_info->cbSize = sizeof(MONITORINFOEX); - GetMonitorInfo(monitor, monitor_info); -} - -void ResourceMessageFilter::OnLoadFont(LOGFONT font) { - // If renderer is running in a sandbox, GetTextMetrics - // can sometimes fail. If a font has not been loaded - // previously, GetTextMetrics will try to load the font - // from the font file. However, the sandboxed renderer does - // not have permissions to access any font files and - // the call fails. So we make the browser pre-load the - // font for us by using a dummy call to GetTextMetrics of - // the same font. - - // Maintain a circular queue for the fonts and DCs to be cached. - // font_index maintains next available location in the queue. - static const int kFontCacheSize = 32; - static HFONT fonts[kFontCacheSize] = {0}; - static HDC hdcs[kFontCacheSize] = {0}; - static size_t font_index = 0; - - UMA_HISTOGRAM_COUNTS_100(L"Memory.CachedFontAndDC", - fonts[kFontCacheSize-1] ? kFontCacheSize : static_cast<int>(font_index)); - - HDC hdc = GetDC(NULL); - HFONT font_handle = CreateFontIndirect(&font); - DCHECK(NULL != font_handle); - - HGDIOBJ old_font = SelectObject(hdc, font_handle); - DCHECK(NULL != old_font); - - TEXTMETRIC tm; - BOOL ret = GetTextMetrics(hdc, &tm); - DCHECK(ret); - - if (fonts[font_index] || hdcs[font_index]) { - // We already have too many fonts, we will delete one and take it's place. - DeleteObject(fonts[font_index]); - ReleaseDC(NULL, hdcs[font_index]); - } - - fonts[font_index] = font_handle; - hdcs[font_index] = hdc; - font_index = (font_index + 1) % kFontCacheSize; -} - ResourceMessageFilter::ResourceMessageFilter( ResourceDispatcherHost* resource_dispatcher_host, PluginService* plugin_service, @@ -161,8 +113,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(ViewHostMsg_PluginSyncMessage, OnPluginSyncMessage) IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) - IPC_MESSAGE_HANDLER(ViewHostMsg_GetMonitorInfoForWindow, - OnGetMonitorInfoForWindow) + IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnGetScreenInfo) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPlugins, OnGetPlugins) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginPath, OnGetPluginPath) IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) @@ -400,6 +351,53 @@ void ResourceMessageFilter::OnPluginSyncMessage(const std::wstring& dll_path, } } +void ResourceMessageFilter::OnLoadFont(LOGFONT font) { + // If renderer is running in a sandbox, GetTextMetrics + // can sometimes fail. If a font has not been loaded + // previously, GetTextMetrics will try to load the font + // from the font file. However, the sandboxed renderer does + // not have permissions to access any font files and + // the call fails. So we make the browser pre-load the + // font for us by using a dummy call to GetTextMetrics of + // the same font. + + // Maintain a circular queue for the fonts and DCs to be cached. + // font_index maintains next available location in the queue. + static const int kFontCacheSize = 32; + static HFONT fonts[kFontCacheSize] = {0}; + static HDC hdcs[kFontCacheSize] = {0}; + static size_t font_index = 0; + + UMA_HISTOGRAM_COUNTS_100(L"Memory.CachedFontAndDC", + fonts[kFontCacheSize-1] ? kFontCacheSize : static_cast<int>(font_index)); + + HDC hdc = GetDC(NULL); + HFONT font_handle = CreateFontIndirect(&font); + DCHECK(NULL != font_handle); + + HGDIOBJ old_font = SelectObject(hdc, font_handle); + DCHECK(NULL != old_font); + + TEXTMETRIC tm; + BOOL ret = GetTextMetrics(hdc, &tm); + DCHECK(ret); + + if (fonts[font_index] || hdcs[font_index]) { + // We already have too many fonts, we will delete one and take it's place. + DeleteObject(fonts[font_index]); + ReleaseDC(NULL, hdcs[font_index]); + } + + fonts[font_index] = font_handle; + hdcs[font_index] = hdc; + font_index = (font_index + 1) % kFontCacheSize; +} + +void ResourceMessageFilter::OnGetScreenInfo( + gfx::ViewHandle window, webkit_glue::ScreenInfo* results) { + *results = webkit_glue::GetScreenInfoHelper(window); +} + void ResourceMessageFilter::OnGetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { plugin_service_->GetPlugins(refresh, plugins); diff --git a/chrome/browser/resource_message_filter.h b/chrome/browser/resource_message_filter.h index 5cd9d11..1ac4c15 100644 --- a/chrome/browser/resource_message_filter.h +++ b/chrome/browser/resource_message_filter.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_RENDERER_RESOURCE_MSG_FILTER_H__ #include "base/gfx/rect.h" +#include "base/gfx/native_widget_types.h" #include "base/ref_counted.h" #include "chrome/browser/resource_dispatcher_host.h" #include "chrome/common/ipc_channel_proxy.h" @@ -23,6 +24,10 @@ class PrinterQuery; class PrintJobManager; } +namespace webkit_glue { +struct ScreenInfo; +} + // This class filters out incoming IPC messages for network requests and // processes them on the IPC thread. As a result, network requests are not // delayed by costly UI processing that may be occuring on the main thread of @@ -95,7 +100,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // Cache fonts for the renderer. See ResourceMessageFilter::OnLoadFont // implementation for more details void OnLoadFont(LOGFONT font); - void OnGetMonitorInfoForWindow(HWND window, MONITORINFOEX* monitor_info); + void OnGetScreenInfo(gfx::ViewHandle window, + webkit_glue::ScreenInfo* results); void OnGetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); void OnGetPluginPath(const GURL& url, const std::string& mime_type, diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 23a6f06..1a4c3b1 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -313,30 +313,6 @@ struct ParamTraits<SkBitmap> { }; template <> -struct ParamTraits<MONITORINFOEX> { - typedef MONITORINFOEX param_type; - static void Write(Message* m, const param_type& p) { - m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MONITORINFOEX)); - } - static bool Read(const Message* m, void** iter, param_type* r) { - const char *data; - int data_size = 0; - bool result = m->ReadData(iter, &data, &data_size); - if (result && data_size == sizeof(MONITORINFOEX)) { - memcpy(r, data, sizeof(MONITORINFOEX)); - } else { - result = false; - NOTREACHED(); - } - - return result; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"<MONITORINFOEX>")); - } -}; - -template <> struct ParamTraits<std::string> { typedef std::string param_type; static void Write(Message* m, const param_type& p) { diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index edbfaf8..fbc1798 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -24,6 +24,7 @@ #include "webkit/glue/password_form.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/resource_loader_bridge.h" +#include "webkit/glue/screen_info.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webpreferences.h" @@ -1649,6 +1650,30 @@ struct ParamTraits<WebDropData> { } }; +// Traits for ScreenInfo +template <> +struct ParamTraits<webkit_glue::ScreenInfo> { + typedef webkit_glue::ScreenInfo param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.depth); + WriteParam(m, p.depth_per_component); + WriteParam(m, p.is_monochrome); + WriteParam(m, p.rect); + WriteParam(m, p.available_rect); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->depth) && + ReadParam(m, iter, &p->depth_per_component) && + ReadParam(m, iter, &p->is_monochrome) && + ReadParam(m, iter, &p->rect) && + ReadParam(m, iter, &p->available_rect); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<webkit_glue::ScreenInfo>"); + } +}; + } // namespace IPC #endif // CHROME_COMMON_RENDER_MESSAGES_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index b191d41..61da8e7 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -15,6 +15,7 @@ #include "webkit/glue/dom_operations.h" #include "webkit/glue/console_message_level.h" #include "webkit/glue/context_node_types.h" +#include "webkit/glue/screen_info.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin.h" #include "webkit/glue/webinputevent.h" @@ -813,10 +814,10 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) IPC_SYNC_MESSAGE_CONTROL1_0(ViewHostMsg_LoadFont, LOGFONT /* font data */) - // Returns the monitor information corresponding to the HWND. - IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetMonitorInfoForWindow, - HWND /* In: Window handle */, - MONITORINFOEX /* Out: Monitor information */) + // Returns ScreenInfo corresponding to the given window. + IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetScreenInfo, + gfx::ViewHandle /* window */, + webkit_glue::ScreenInfo /* results */) // Send the tooltip text for the current mouse position to the browser. IPC_MESSAGE_ROUTED1(ViewHostMsg_SetTooltipText, diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 244646e..83e5b95 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -234,14 +234,13 @@ bool webkit_glue::EnsureFontLoaded(HFONT font) { return RenderThread::current()->Send(new ViewHostMsg_LoadFont(logfont)); } -MONITORINFOEX webkit_glue::GetMonitorInfoForWindow(HWND window) { - MONITORINFOEX monitor_info; +webkit_glue::ScreenInfo webkit_glue::GetScreenInfo(gfx::ViewHandle window) { + webkit_glue::ScreenInfo results; RenderThread::current()->Send( - new ViewHostMsg_GetMonitorInfoForWindow(window, &monitor_info)); - return monitor_info; + new ViewHostMsg_GetScreenInfo(window, &results)); + return results; } - #ifndef USING_SIMPLE_RESOURCE_LOADER_BRIDGE // Each RenderView has a ResourceDispatcher. In unit tests, this function may diff --git a/webkit/SConscript.port b/webkit/SConscript.port index ebe20dd..8443c3f 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -55,6 +55,7 @@ input_files = [ '$PORT_DIR/platform/chromium/Language.cpp', '$PORT_DIR/platform/chromium/MimeTypeRegistryChromium.cpp', '$PORT_DIR/platform/chromium/PlatformKeyboardEventChromium.cpp', + '$PORT_DIR/platform/chromium/PlatformScreenChromium.cpp', '$PORT_DIR/platform/chromium/PopupMenuChromium.cpp', '$PORT_DIR/platform/chromium/SearchPopupMenuChromium.cpp', '$PORT_DIR/platform/chromium/SharedTimerChromium.cpp', @@ -153,7 +154,6 @@ if env['PLATFORM'] == 'win32': '$PORT_DIR/platform/win/ClipboardWin.cpp', '$PORT_DIR/platform/win/EditorWin.cpp', '$PORT_DIR/platform/win/PasteboardWin.cpp', - '$PORT_DIR/platform/win/PlatformScreenWin.cpp', '$PORT_DIR/platform/win/SoundWin.cpp', '$PORT_DIR/platform/win/WCDataObject.cpp', '$PORT_DIR/platform/graphics/FontCacheWin.cpp', diff --git a/webkit/build/glue/glue.vcproj b/webkit/build/glue/glue.vcproj index 46e99cb..784de66 100644 --- a/webkit/build/glue/glue.vcproj +++ b/webkit/build/glue/glue.vcproj @@ -165,6 +165,10 @@ > </File> <File + RelativePath="..\..\glue\screen_info.h" + > + </File> + <File RelativePath="..\..\glue\webdatasource.h" > </File> @@ -285,6 +289,10 @@ > </File> <File + RelativePath="..\..\glue\chromium_bridge_impl.cc" + > + </File> + <File RelativePath="..\..\glue\context_menu_client_impl.cc" > </File> @@ -569,6 +577,10 @@ > </File> <File + RelativePath="..\..\glue\webkit_glue_win.cc" + > + </File> + <File RelativePath="..\..\glue\webplugin_impl.cc" > </File> diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj index 17e2ba0..c91d3ba 100644 --- a/webkit/build/port/port.vcproj +++ b/webkit/build/port/port.vcproj @@ -719,10 +719,6 @@ > </File> <File - RelativePath="..\..\port\platform\win\PlatformScreenWin.cpp" - > - </File> - <File RelativePath="..\..\port\platform\win\SoundWin.cpp" > </File> @@ -739,6 +735,10 @@ Name="chromium" > <File + RelativePath="..\..\port\platform\chromium\ChromiumBridge.h" + > + </File> + <File RelativePath="..\..\port\platform\chromium\ContextMenuChromium.cpp" > </File> @@ -791,6 +791,10 @@ > </File> <File + RelativePath="..\..\port\platform\chromium\PlatformScreenChromium.cpp" + > + </File> + <File RelativePath="..\..\port\platform\chromium\PopupMenuChromium.cpp" > </File> 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( diff --git a/webkit/port/platform/Language.cpp b/webkit/port/platform/Language.cpp deleted file mode 100644 index b21f7d4..0000000 --- a/webkit/port/platform/Language.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "Language.h" - -#include "CString.h" -#include "PlatformString.h" -#include "webkit/glue/glue_util.h" -#include "webkit/glue/webkit_glue.h" - - -namespace WebCore { - -String defaultLanguage() -{ - static String computedDefaultLanguage; - if (!computedDefaultLanguage.isEmpty()) - return computedDefaultLanguage; - - computedDefaultLanguage = - webkit_glue::StdWStringToString(webkit_glue::GetWebKitLocale()); - return computedDefaultLanguage; -} - -} diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h new file mode 100644 index 0000000..b7ff628 --- /dev/null +++ b/webkit/port/platform/chromium/ChromiumBridge.h @@ -0,0 +1,51 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef ChromiumBridge_h +#define ChromiumBridge_h + +namespace WebCore { + class IntRect; + class Widget; + + // An interface to the embedding layer, which has the ability to answer + // questions about the system and so on... + + class ChromiumBridge { + public: + // Screen information ------------------------------------------------- + static int screenDepth(Widget*); + static int screenDepthPerComponent(Widget*); + static bool screenIsMonochrome(Widget*); + static IntRect screenRect(Widget*); + static IntRect screenAvailableRect(Widget*); + }; +} + +#endif diff --git a/webkit/port/platform/chromium/PlatformScreenChromium.cpp b/webkit/port/platform/chromium/PlatformScreenChromium.cpp new file mode 100644 index 0000000..ad9eeb9 --- /dev/null +++ b/webkit/port/platform/chromium/PlatformScreenChromium.cpp @@ -0,0 +1,63 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "config.h" +#include "PlatformScreen.h" + +#include "ChromiumBridge.h" +#include "IntRect.h" + +namespace WebCore { + +int screenDepth(Widget* widget) +{ + return ChromiumBridge::screenDepth(widget); +} + +int screenDepthPerComponent(Widget* widget) +{ + return ChromiumBridge::screenDepthPerComponent(widget); +} + +bool screenIsMonochrome(Widget* widget) +{ + return ChromiumBridge::screenIsMonochrome(widget); +} + +FloatRect screenRect(Widget* widget) +{ + return ChromiumBridge::screenRect(widget); +} + +FloatRect screenAvailableRect(Widget* widget) +{ + return ChromiumBridge::screenAvailableRect(widget); +} + +} // namespace WebCore diff --git a/webkit/port/platform/win/PlatformScreenWin.cpp b/webkit/port/platform/win/PlatformScreenWin.cpp deleted file mode 100644 index 1c529d8..0000000 --- a/webkit/port/platform/win/PlatformScreenWin.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "PlatformScreen.h" - -#include "IntRect.h" -#include "FloatRect.h" -#include "Frame.h" -#include "FrameView.h" -#include "Page.h" -#include <windows.h> - -#include "webkit/glue/webkit_glue.h" - -namespace WebCore { - -static FloatRect ToFloatRect(const RECT& rect) { - return FloatRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); -} - -// Returns info for the default monitor if widget is NULL -static MONITORINFOEX monitorInfoForWidget(Widget* widget) -{ - // TODO(darin): We should not be dealing with native widgets here! - HWND window = widget ? widget->root()->hostWindow()->platformWindow() : 0; - return webkit_glue::GetMonitorInfoForWindow(window); -} - -static DEVMODE deviceInfoForWidget(Widget* widget) -{ - MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); - - DEVMODE deviceInfo; - deviceInfo.dmSize = sizeof(DEVMODE); - deviceInfo.dmDriverExtra = 0; - EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo); - - return deviceInfo; -} - -int screenDepth(Widget* widget) -{ - DEVMODE deviceInfo = deviceInfoForWidget(widget); - return deviceInfo.dmBitsPerPel; -} - -int screenDepthPerComponent(Widget* widget) -{ - // FIXME: Assumes RGB -- not sure if this is right. - DEVMODE deviceInfo = deviceInfoForWidget(widget); - return deviceInfo.dmBitsPerPel / 3; -} - -bool screenIsMonochrome(Widget* widget) -{ - DEVMODE deviceInfo = deviceInfoForWidget(widget); - return deviceInfo.dmColor == DMCOLOR_MONOCHROME; -} - -FloatRect screenRect(Widget* widget) -{ - MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); - return ToFloatRect(monitorInfo.rcMonitor); -} - -FloatRect screenAvailableRect(Widget* widget) -{ - MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); - return ToFloatRect(monitorInfo.rcWork); -} - -} // namespace WebCore |