diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-01 23:07:19 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-01 23:07:19 +0000 |
commit | 12456fac1b181983b7ce52789be16e7e436a0996 (patch) | |
tree | a5a3a92808d8e78d5d620e6f900db60adcb84197 | |
parent | 31b882b2aac660139d1ea77b953e6c99ab184cb4 (diff) | |
download | chromium_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
31 files changed, 437 insertions, 481 deletions
@@ -19,7 +19,7 @@ deps = { "http://googletest.googlecode.com/svn/trunk@214", "src/third_party/WebKit": - "/trunk/deps/third_party/WebKit@12957", + "/trunk/deps/third_party/WebKit@12992", "src/third_party/icu38": "/trunk/deps/third_party/icu38@12390", diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 92faa44..b7c59af 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -42,7 +42,17 @@ #include "chrome/common/temp_scaffolding_stubs.h" #endif +#if defined(OS_WIN) +#include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h" +#elif defined(OS_MACOSX) +#include "third_party/WebKit/WebKit/chromium/public/mac/WebScreenInfoFactory.h" +#elif defined(OS_LINUX) +#include "third_party/WebKit/WebKit/chromium/public/gtk/WebScreenInfoFactory.h" +#endif + using WebKit::WebCache; +using WebKit::WebScreenInfo; +using WebKit::WebScreenInfoFactory; namespace { @@ -442,9 +452,11 @@ void ResourceMessageFilter::OnLoadFont(LOGFONT font) { } #endif -void ResourceMessageFilter::OnGetScreenInfo( - gfx::NativeViewId window, webkit_glue::ScreenInfo* results) { - *results = webkit_glue::GetScreenInfoHelper(gfx::NativeViewFromId(window)); +void ResourceMessageFilter::OnGetScreenInfo(gfx::NativeViewId view, + WebScreenInfo* results) { + // TODO(darin): Change this into a routed message so that we can eliminate + // the NativeViewId parameter. + *results = WebScreenInfoFactory::screenInfo(gfx::NativeViewFromId(view)); } void ResourceMessageFilter::OnGetPlugins(bool refresh, diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 42650f2..64a10ba 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -45,8 +45,8 @@ class PrinterQuery; class PrintJobManager; } -namespace webkit_glue { -struct ScreenInfo; +namespace WebKit { +struct WebScreenInfo; } // This class filters out incoming IPC messages for network requests and @@ -128,7 +128,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, #endif void OnGetScreenInfo(gfx::NativeViewId window, - webkit_glue::ScreenInfo* results); + WebKit::WebScreenInfo* results); void OnGetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); void OnGetPluginPath(const GURL& url, const std::string& mime_type, diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d0ca8a0..d6c0d81 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -292,6 +292,7 @@ 'common/url_constants.h', 'common/visitedlink_common.cc', 'common/visitedlink_common.h', + 'common/webkit_param_traits.h', 'common/win_safe_util.cc', 'common/win_safe_util.h', 'common/win_util.cc', diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index 1a99f60..f392f7d 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -818,6 +818,10 @@ > </File> <File + RelativePath=".\webkit_param_traits.h" + > + </File> + <File RelativePath=".\win_safe_util.cc" > </File> diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 717303b..38af203 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -19,15 +19,12 @@ #include "chrome/common/modal_dialog_event.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/transport_dib.h" +#include "chrome/common/webkit_param_traits.h" #include "googleurl/src/gurl.h" #include "media/audio/audio_output.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request_status.h" -#include "third_party/WebKit/WebKit/chromium/public/WebCache.h" -#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" -#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/context_menu.h" #include "webkit/glue/feed.h" @@ -35,7 +32,6 @@ #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/webaccessibility.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webplugin.h" @@ -372,66 +368,6 @@ struct ViewHostMsg_Audio_CreateStream { namespace IPC { template <> -struct ParamTraits<WebKit::WebString> { - typedef WebKit::WebString param_type; - static void Write(Message* m, const param_type& p) { - m->WriteData(reinterpret_cast<const char*>(p.data()), - static_cast<int>(p.length() * sizeof(WebKit::WebUChar))); - } - static bool Read(const Message* m, void** iter, param_type* p) { - const char* data; - int data_len; - if (!m->ReadData(iter, &data, &data_len)) - return false; - p->assign(reinterpret_cast<const WebKit::WebUChar*>(data), - static_cast<size_t>(data_len / sizeof(WebKit::WebUChar))); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(UTF16ToWideHack(p)); - } -}; - -template <> -struct ParamTraits<WebKit::WebConsoleMessage::Level> { - typedef WebKit::WebConsoleMessage::Level param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, static_cast<int>(p)); - } - static bool Read(const Message* m, void** iter, param_type* r) { - int value; - if (!ReadParam(m, iter, &value)) - return false; - *r = static_cast<param_type>(value); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - LogParam(static_cast<int>(p), l); - } -}; - -template <> -struct ParamTraits<WebKit::WebConsoleMessage> { - typedef WebKit::WebConsoleMessage param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.level); - WriteParam(m, p.text); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ReadParam(m, iter, &r->level) && - ReadParam(m, iter, &r->text); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.level, l); - l->append(L", "); - LogParam(p.text, l); - l->append(L")"); - } -}; - -template <> struct ParamTraits<ResourceType::Type> { typedef ResourceType::Type param_type; static void Write(Message* m, const param_type& p) { @@ -546,58 +482,6 @@ struct ParamTraits<ContextNode> { } }; -template <> -struct ParamTraits<WebKit::WebInputEvent::Type> { - typedef WebKit::WebInputEvent::Type param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p); - } - static bool Read(const Message* m, void** iter, param_type* p) { - int type; - if (!m->ReadInt(iter, &type)) - return false; - *p = static_cast<WebKit::WebInputEvent::Type>(type); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - std::wstring type; - switch (p) { - case WebKit::WebInputEvent::MouseDown: - type = L"MouseDown"; - break; - case WebKit::WebInputEvent::MouseUp: - type = L"MouseUp"; - break; - case WebKit::WebInputEvent::MouseMove: - type = L"MouseMove"; - break; - case WebKit::WebInputEvent::MouseLeave: - type = L"MouseLeave"; - break; - case WebKit::WebInputEvent::MouseDoubleClick: - type = L"MouseDoubleClick"; - break; - case WebKit::WebInputEvent::MouseWheel: - type = L"MouseWheel"; - break; - case WebKit::WebInputEvent::RawKeyDown: - type = L"RawKeyDown"; - break; - case WebKit::WebInputEvent::KeyDown: - type = L"KeyDown"; - break; - case WebKit::WebInputEvent::KeyUp: - type = L"KeyUp"; - break; - default: - type = L"None"; - break; - } - - LogParam(type, l); - } -}; - // Traits for ViewHostMsg_UpdateFeedList_Params structure to pack/unpack. template <> struct ParamTraits<ViewHostMsg_UpdateFeedList_Params> { @@ -1260,83 +1144,6 @@ struct ParamTraits<scoped_refptr<net::UploadData> > { } }; -// Traits for WebKit::WebCache::UsageStats -template <> -struct ParamTraits<WebKit::WebCache::UsageStats> { - typedef WebKit::WebCache::UsageStats param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.minDeadCapacity); - WriteParam(m, p.maxDeadCapacity); - WriteParam(m, p.capacity); - WriteParam(m, p.liveSize); - WriteParam(m, p.deadSize); - } - static bool Read(const Message* m, void** iter, param_type* r) { - return - ReadParam(m, iter, &r->minDeadCapacity) && - ReadParam(m, iter, &r->maxDeadCapacity) && - ReadParam(m, iter, &r->capacity) && - ReadParam(m, iter, &r->liveSize) && - ReadParam(m, iter, &r->deadSize); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<WebCache::UsageStats>"); - } -}; - -template <> -struct ParamTraits<WebKit::WebCache::ResourceTypeStat> { - typedef WebKit::WebCache::ResourceTypeStat param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.count); - WriteParam(m, p.size); - WriteParam(m, p.liveSize); - WriteParam(m, p.decodedSize); - } - static bool Read(const Message* m, void** iter, param_type* r) { - bool result = - ReadParam(m, iter, &r->count) && - ReadParam(m, iter, &r->size) && - ReadParam(m, iter, &r->liveSize) && - ReadParam(m, iter, &r->decodedSize); - return result; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(StringPrintf(L"%d %d %d %d", p.count, p.size, p.liveSize, - p.decodedSize)); - } -}; - -template <> -struct ParamTraits<WebKit::WebCache::ResourceTypeStats> { - typedef WebKit::WebCache::ResourceTypeStats param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.images); - WriteParam(m, p.cssStyleSheets); - WriteParam(m, p.scripts); - WriteParam(m, p.xslStyleSheets); - WriteParam(m, p.fonts); - } - static bool Read(const Message* m, void** iter, param_type* r) { - bool result = - ReadParam(m, iter, &r->images) && - ReadParam(m, iter, &r->cssStyleSheets) && - ReadParam(m, iter, &r->scripts) && - ReadParam(m, iter, &r->xslStyleSheets) && - ReadParam(m, iter, &r->fonts); - return result; - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<WebCoreStats>"); - LogParam(p.images, l); - LogParam(p.cssStyleSheets, l); - LogParam(p.scripts, l); - LogParam(p.xslStyleSheets, l); - LogParam(p.fonts, l); - l->append(L"</WebCoreStats>"); - } -}; - // Traits for PasswordFormDomManager::FillData. template <> struct ParamTraits<PasswordFormDomManager::FillData> { @@ -1810,30 +1617,6 @@ 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>"); - } -}; - template<> struct ParamTraits<ModalDialogEvent> { typedef ModalDialogEvent param_type; @@ -1985,29 +1768,6 @@ struct ParamTraits<AudioOutputStream::State> { } }; -template <> -struct ParamTraits<WebKit::WebFindInPageRequest> { - typedef WebKit::WebFindInPageRequest param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.identifier); - WriteParam(m, p.text); - WriteParam(m, p.forward); - WriteParam(m, p.matchCase); - WriteParam(m, p.findNext); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->identifier) && - ReadParam(m, iter, &p->text) && - ReadParam(m, iter, &p->forward) && - ReadParam(m, iter, &p->matchCase) && - ReadParam(m, iter, &p->findNext); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"<FindInPageRequest>"); - } -}; - } // namespace IPC diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index ff0217d..5a32a0b 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -19,7 +19,6 @@ #include "chrome/common/transport_dib.h" #include "skia/include/SkBitmap.h" #include "webkit/glue/dom_operations.h" -#include "webkit/glue/screen_info.h" #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin.h" @@ -882,10 +881,12 @@ IPC_BEGIN_MESSAGES(ViewHost) LOGFONT /* font data */) #endif // defined(OS_WIN) - // Returns ScreenInfo corresponding to the given window. + // Returns WebScreenInfo corresponding to the view. + // TODO(darin): Change this to be a routed message so we don't need to pass + // the view id. IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetScreenInfo, - gfx::NativeViewId /* window */, - webkit_glue::ScreenInfo /* results */) + gfx::NativeViewId /* native view id */, + WebKit::WebScreenInfo /* results */) // Send the tooltip text for the current mouse position to the browser. IPC_MESSAGE_ROUTED1(ViewHostMsg_SetTooltipText, diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h new file mode 100644 index 0000000..d41bccc --- /dev/null +++ b/chrome/common/webkit_param_traits.h @@ -0,0 +1,295 @@ +// Copyright (c) 2009 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. +// +// This file contains ParamTraits templates to support serialization of WebKit +// data types over IPC. + +#ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ +#define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ + +#include "chrome/common/ipc_message_utils.h" +#include "third_party/WebKit/WebKit/chromium/public/WebCache.h" +#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" + +namespace IPC { + +template <> +struct ParamTraits<WebKit::WebRect> { + typedef WebKit::WebRect param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.x); + WriteParam(m, p.y); + WriteParam(m, p.width); + WriteParam(m, p.height); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->x) && + ReadParam(m, iter, &p->y) && + ReadParam(m, iter, &p->width) && + ReadParam(m, iter, &p->height); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.x, l); + l->append(L", "); + LogParam(p.y, l); + l->append(L", "); + LogParam(p.width, l); + l->append(L", "); + LogParam(p.height, l); + l->append(L")"); + } +}; + +template <> +struct ParamTraits<WebKit::WebScreenInfo> { + typedef WebKit::WebScreenInfo param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.depth); + WriteParam(m, p.depthPerComponent); + WriteParam(m, p.isMonochrome); + WriteParam(m, p.rect); + WriteParam(m, p.availableRect); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->depth) && + ReadParam(m, iter, &p->depthPerComponent) && + ReadParam(m, iter, &p->isMonochrome) && + ReadParam(m, iter, &p->rect) && + ReadParam(m, iter, &p->availableRect); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.depth, l); + l->append(L", "); + LogParam(p.depthPerComponent, l); + l->append(L", "); + LogParam(p.isMonochrome, l); + l->append(L", "); + LogParam(p.rect, l); + l->append(L", "); + LogParam(p.availableRect, l); + l->append(L")"); + } +}; + +template <> +struct ParamTraits<WebKit::WebString> { + typedef WebKit::WebString param_type; + static void Write(Message* m, const param_type& p) { + m->WriteData(reinterpret_cast<const char*>(p.data()), + static_cast<int>(p.length() * sizeof(WebKit::WebUChar))); + } + static bool Read(const Message* m, void** iter, param_type* p) { + const char* data; + int data_len; + if (!m->ReadData(iter, &data, &data_len)) + return false; + p->assign(reinterpret_cast<const WebKit::WebUChar*>(data), + static_cast<size_t>(data_len / sizeof(WebKit::WebUChar))); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(UTF16ToWideHack(p)); + } +}; + +template <> +struct ParamTraits<WebKit::WebConsoleMessage::Level> { + typedef WebKit::WebConsoleMessage::Level param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p)); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int value; + if (!ReadParam(m, iter, &value)) + return false; + *r = static_cast<param_type>(value); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + LogParam(static_cast<int>(p), l); + } +}; + +template <> +struct ParamTraits<WebKit::WebConsoleMessage> { + typedef WebKit::WebConsoleMessage param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.level); + WriteParam(m, p.text); + } + static bool Read(const Message* m, void** iter, param_type* r) { + return + ReadParam(m, iter, &r->level) && + ReadParam(m, iter, &r->text); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.level, l); + l->append(L", "); + LogParam(p.text, l); + l->append(L")"); + } +}; + +template <> +struct ParamTraits<WebKit::WebFindInPageRequest> { + typedef WebKit::WebFindInPageRequest param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.identifier); + WriteParam(m, p.text); + WriteParam(m, p.forward); + WriteParam(m, p.matchCase); + WriteParam(m, p.findNext); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return + ReadParam(m, iter, &p->identifier) && + ReadParam(m, iter, &p->text) && + ReadParam(m, iter, &p->forward) && + ReadParam(m, iter, &p->matchCase) && + ReadParam(m, iter, &p->findNext); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<FindInPageRequest>"); + } +}; + +template <> +struct ParamTraits<WebKit::WebInputEvent::Type> { + typedef WebKit::WebInputEvent::Type param_type; + static void Write(Message* m, const param_type& p) { + m->WriteInt(p); + } + static bool Read(const Message* m, void** iter, param_type* p) { + int type; + if (!m->ReadInt(iter, &type)) + return false; + *p = static_cast<WebKit::WebInputEvent::Type>(type); + return true; + } + static void Log(const param_type& p, std::wstring* l) { + std::wstring type; + switch (p) { + case WebKit::WebInputEvent::MouseDown: + type = L"MouseDown"; + break; + case WebKit::WebInputEvent::MouseUp: + type = L"MouseUp"; + break; + case WebKit::WebInputEvent::MouseMove: + type = L"MouseMove"; + break; + case WebKit::WebInputEvent::MouseLeave: + type = L"MouseLeave"; + break; + case WebKit::WebInputEvent::MouseDoubleClick: + type = L"MouseDoubleClick"; + break; + case WebKit::WebInputEvent::MouseWheel: + type = L"MouseWheel"; + break; + case WebKit::WebInputEvent::RawKeyDown: + type = L"RawKeyDown"; + break; + case WebKit::WebInputEvent::KeyDown: + type = L"KeyDown"; + break; + case WebKit::WebInputEvent::KeyUp: + type = L"KeyUp"; + break; + default: + type = L"None"; + break; + } + LogParam(type, l); + } +}; + +// Traits for WebKit::WebCache::UsageStats +template <> +struct ParamTraits<WebKit::WebCache::UsageStats> { + typedef WebKit::WebCache::UsageStats param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.minDeadCapacity); + WriteParam(m, p.maxDeadCapacity); + WriteParam(m, p.capacity); + WriteParam(m, p.liveSize); + WriteParam(m, p.deadSize); + } + static bool Read(const Message* m, void** iter, param_type* r) { + return + ReadParam(m, iter, &r->minDeadCapacity) && + ReadParam(m, iter, &r->maxDeadCapacity) && + ReadParam(m, iter, &r->capacity) && + ReadParam(m, iter, &r->liveSize) && + ReadParam(m, iter, &r->deadSize); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<WebCache::UsageStats>"); + } +}; + +template <> +struct ParamTraits<WebKit::WebCache::ResourceTypeStat> { + typedef WebKit::WebCache::ResourceTypeStat param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.count); + WriteParam(m, p.size); + WriteParam(m, p.liveSize); + WriteParam(m, p.decodedSize); + } + static bool Read(const Message* m, void** iter, param_type* r) { + bool result = + ReadParam(m, iter, &r->count) && + ReadParam(m, iter, &r->size) && + ReadParam(m, iter, &r->liveSize) && + ReadParam(m, iter, &r->decodedSize); + return result; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(StringPrintf(L"%d %d %d %d", p.count, p.size, p.liveSize, + p.decodedSize)); + } +}; + +template <> +struct ParamTraits<WebKit::WebCache::ResourceTypeStats> { + typedef WebKit::WebCache::ResourceTypeStats param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.images); + WriteParam(m, p.cssStyleSheets); + WriteParam(m, p.scripts); + WriteParam(m, p.xslStyleSheets); + WriteParam(m, p.fonts); + } + static bool Read(const Message* m, void** iter, param_type* r) { + bool result = + ReadParam(m, iter, &r->images) && + ReadParam(m, iter, &r->cssStyleSheets) && + ReadParam(m, iter, &r->scripts) && + ReadParam(m, iter, &r->xslStyleSheets) && + ReadParam(m, iter, &r->fonts); + return result; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<WebCoreStats>"); + LogParam(p.images, l); + LogParam(p.cssStyleSheets, l); + LogParam(p.scripts, l); + LogParam(p.xslStyleSheets, l); + LogParam(p.fonts, l); + l->append(L"</WebCoreStats>"); + } +}; + +} // namespace IPC + +#endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index 12d2315..9b05e19 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -14,6 +14,7 @@ #include "chrome/common/transport_dib.h" #include "chrome/renderer/render_process.h" #include "skia/ext/platform_canvas.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #if defined(OS_POSIX) #include "skia/include/SkPixelRef.h" @@ -24,6 +25,7 @@ #include "webkit/glue/webwidget.h" using WebKit::WebInputEvent; +using WebKit::WebScreenInfo; RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) : routing_id_(MSG_ROUTING_NONE), @@ -765,3 +767,10 @@ void RenderWidget::DidMove(WebWidget* webwidget, if (i == plugin_window_moves_.size()) plugin_window_moves_.push_back(move); } + +WebScreenInfo RenderWidget::GetScreenInfo(WebWidget* webwidget) { + WebScreenInfo results; + RenderThread::current()->Send( + new ViewHostMsg_GetScreenInfo(host_window_, &results)); + return results; +} diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index d7e28fa..7ee2c04 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -70,6 +70,11 @@ class RenderWidget : public IPC::Channel::Listener, const gfx::Rect& clip_rect); virtual void SetCursor(WebWidget* webwidget, const WebCursor& cursor); virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition); + virtual void ShowWithItems(WebWidget* webwidget, + const gfx::Rect& bounds, + int item_height, + int selected_index, + const std::vector<MenuItem>& items); virtual void CloseWidgetSoon(WebWidget* webwidget); virtual void Focus(WebWidget* webwidget); virtual void Blur(WebWidget* webwidget); @@ -79,12 +84,8 @@ class RenderWidget : public IPC::Channel::Listener, virtual void GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect); virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); virtual void RunModal(WebWidget* webwidget) {} - virtual bool IsHidden() { return is_hidden_; } - virtual void ShowWithItems(WebWidget* webwidget, - const gfx::Rect& bounds, - int item_height, - int selected_index, - const std::vector<MenuItem>& items); + virtual bool IsHidden(WebWidget* webwidget) { return is_hidden_; } + virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); // Close the underlying WebWidget. void Close(); diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index e8d3c53..09f6676 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -219,13 +219,6 @@ bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { new ViewHostMsg_GetPlugins(refresh, plugins)); } -webkit_glue::ScreenInfo GetScreenInfo(gfx::NativeViewId window) { - webkit_glue::ScreenInfo results; - RenderThread::current()->Send( - new ViewHostMsg_GetScreenInfo(window, &results)); - return results; -} - // static factory function ResourceLoaderBridge* ResourceLoaderBridge::Create( const std::string& method, diff --git a/chrome/test/worker/test_worker_main.cc b/chrome/test/worker/test_worker_main.cc index e3a7f89..f1e7817 100644 --- a/chrome/test/worker/test_worker_main.cc +++ b/chrome/test/worker/test_worker_main.cc @@ -14,7 +14,6 @@ #include "googleurl/src/gurl.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/screen_info.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webworker.h" #include "webkit/glue/webworkerclient.h" @@ -108,10 +107,6 @@ bool SpellCheckWord(const wchar_t* word, int word_len, return true; } -ScreenInfo GetScreenInfo(gfx::NativeViewId window) { - return GetScreenInfoHelper(gfx::NativeViewFromId(window)); -} - bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { return false; } diff --git a/webkit/build/WebKit/WebKit.vcproj b/webkit/build/WebKit/WebKit.vcproj index ccef31b..b225b74 100644 --- a/webkit/build/WebKit/WebKit.vcproj +++ b/webkit/build/WebKit/WebKit.vcproj @@ -211,6 +211,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\win\WebScreenInfoFactory.h" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\win\WebThemeEngine.h" > </File> @@ -270,6 +274,10 @@ RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\src\win\WebInputEventFactory.cpp" > </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\src\win\WebScreenInfoFactory.cpp" + > + </File> </Filter> </Filter> </Filter> 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 diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm index f992141..bccb584 100644 --- a/webkit/tools/test_shell/mac/webwidget_host.mm +++ b/webkit/tools/test_shell/mac/webwidget_host.mm @@ -11,7 +11,9 @@ #include "base/gfx/size.h" #include "base/logging.h" #include "third_party/WebKit/WebKit/chromium/public/mac/WebInputEventFactory.h" +#include "third_party/WebKit/WebKit/chromium/public/mac/WebScreenInfoFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" @@ -20,6 +22,8 @@ using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; +using WebKit::WebScreenInfo; +using WebKit::WebScreenInfoFactory; /*static*/ WebWidgetHost* WebWidgetHost::Create(NSView* parent_view, @@ -214,6 +218,10 @@ void WebWidgetHost::Paint() { } } +WebScreenInfo WebWidgetHost::GetScreenInfo() { + return WebScreenInfoFactory::screenInfo(view_); +} + void WebWidgetHost::Resize(const gfx::Rect& rect) { // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. DiscardBackingStore(); diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 089ef9d..42193e8 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -31,7 +31,6 @@ #include "net/url_request/url_request_filter.h" #include "skia/ext/bitmap_platform_device.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/screen_info.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" @@ -589,10 +588,6 @@ bool SpellCheckWord(const wchar_t* word, int word_len, return true; } -ScreenInfo GetScreenInfo(gfx::NativeViewId window) { - return GetScreenInfoHelper(gfx::NativeViewFromId(window)); -} - bool IsPluginRunningInRendererProcess() { return true; } diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index a2cf6c0..40c1c89 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -18,6 +18,7 @@ #include "base/trace_event.h" #include "net/base/net_errors.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/weberror.h" @@ -39,6 +40,8 @@ #include "webkit/tools/test_shell/drop_delegate.h" #endif +using WebKit::WebScreenInfo; + namespace { // WebNavigationType debugging strings taken from PolicyDelegate.mm. @@ -724,10 +727,17 @@ void TestWebViewDelegate::Blur(WebWidget* webwidget) { shell_->SetFocus(host, false); } -bool TestWebViewDelegate::IsHidden() { +bool TestWebViewDelegate::IsHidden(WebWidget* webwidget) { return false; } +WebScreenInfo TestWebViewDelegate::GetScreenInfo(WebWidget* webwidget) { + if (WebWidgetHost* host = GetHostForWidget(webwidget)) + return host->GetScreenInfo(); + + return WebScreenInfo(); +} + void TestWebViewDelegate::RegisterDragDrop() { #if defined(OS_WIN) // TODO(port): add me once drag and drop works. diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 1204ded..c11186f 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -231,7 +231,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect); virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); virtual void RunModal(WebWidget* webwidget); - virtual bool IsHidden(); + virtual bool IsHidden(WebWidget* webwidget); + virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); virtual void AddRef() { base::RefCounted<TestWebViewDelegate>::AddRef(); } diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h index c35661b..1fd02c1 100644 --- a/webkit/tools/test_shell/webwidget_host.h +++ b/webkit/tools/test_shell/webwidget_host.h @@ -18,6 +18,10 @@ namespace gfx { class Size; } +namespace WebKit { +struct WebScreenInfo; +} + #if defined(OS_MACOSX) #ifdef __OBJC__ @class NSEvent; @@ -54,6 +58,8 @@ class WebWidgetHost { void UpdatePaintRect(const gfx::Rect& rect); void Paint(); + WebKit::WebScreenInfo GetScreenInfo(); + protected: WebWidgetHost(); ~WebWidgetHost(); diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc index 599d580..08dd9bc 100644 --- a/webkit/tools/test_shell/webwidget_host_gtk.cc +++ b/webkit/tools/test_shell/webwidget_host_gtk.cc @@ -13,7 +13,9 @@ #include "skia/ext/platform_canvas_linux.h" #include "skia/ext/platform_device_linux.h" #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" +#include "third_party/WebKit/WebKit/chromium/public/gtk/WebScreenInfoFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" @@ -21,6 +23,8 @@ using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; +using WebKit::WebScreenInfo; +using WebKit::WebScreenInfoFactory; namespace { @@ -361,6 +365,10 @@ void WebWidgetHost::Paint() { gdk_window_end_paint(window); } +WebScreenInfo WebWidgetHost::GetScreenInfo() { + return WebScreenInfoFactory::screenInfo(view_); +} + void WebWidgetHost::ResetScrollRect() { // This method is only needed for optimized scroll painting, which we don't // care about in the test shell, yet. diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc index 8ea5ca0..9db06c0 100644 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ b/webkit/tools/test_shell/webwidget_host_win.cc @@ -10,7 +10,9 @@ #include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas_win.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" +#include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/test_shell.h" @@ -19,6 +21,8 @@ using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; +using WebKit::WebScreenInfo; +using WebKit::WebScreenInfoFactory; static const wchar_t kWindowClassName[] = L"WebWidgetHost"; @@ -273,6 +277,10 @@ void WebWidgetHost::Paint() { UpdateWindow(view_); } +WebScreenInfo WebWidgetHost::GetScreenInfo() { + return WebScreenInfoFactory::screenInfo(view_); +} + void WebWidgetHost::Resize(LPARAM lparam) { // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. DiscardBackingStore(); diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 7a16249..06c0809 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4342,7 +4342,6 @@ 'glue/resource_loader_bridge.h', 'glue/resource_type.h', 'glue/scoped_clipboard_writer_glue.h', - 'glue/screen_info.h', 'glue/searchable_form_data.cc', 'glue/searchable_form_data.h', 'glue/simple_clipboard_impl.cc', @@ -4384,9 +4383,6 @@ 'glue/webhistoryitem_impl.h', 'glue/webkit_glue.cc', 'glue/webkit_glue.h', - 'glue/webkit_glue_gtk.cc', - 'glue/webkit_glue_mac.mm', - 'glue/webkit_glue_win.cc', 'glue/webkitclient_impl.cc', 'glue/webkitclient_impl.h', 'glue/webmediaplayer.h', |