Skip to content

Commit

Permalink
bsds: views/ and webkit/ support for FreeBSD/OpenBSD
Browse files Browse the repository at this point in the history
- add a TOOLKIT_USES_GTK #define to catch GTK and Views+GTK
- lots of ifdef twiddling

Review URL: http://codereview.chromium.org/519030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35402 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
evan@chromium.org committed Dec 31, 2009
1 parent b7b412a commit 10a6e77
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 74 deletions.
6 changes: 6 additions & 0 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
#error Please add support for your platform in build/build_config.h
#endif

// A flag derived from the above flags, used to cover GTK code in
// both TOOLKIT_GTK and TOOLKIT_VIEWS.
#if defined(TOOLKIT_GTK) || (defined(TOOLKIT_VIEWS) && !defined(OS_WIN))
#define TOOLKIT_USES_GTK 1
#endif

#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
#define USE_NSS 1 // Use NSS for crypto.
#define USE_X11 1 // Use X for graphics.
Expand Down
2 changes: 1 addition & 1 deletion views/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ bool View::HitTest(const gfx::Point& l) const {
// TODO: can this use SkRegion's contains instead?
#if defined(OS_WIN)
return !!PtInRegion(rgn, l.x(), l.y());
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
return gdk_region_point_in(rgn.Get(), l.x(), l.y());
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions views/views.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
['exclude', '/(gtk|win|x11)_[^/]*\\.cc$'],
],
'conditions': [
['OS=="linux"', {'sources/': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {'sources/': [
['include', '/gtk/'],
['include', '_(gtk|linux|posix|skia|x)\\.cc$'],
['include', '/(gtk|x11)_[^/]*\\.cc$'],
Expand Down Expand Up @@ -297,7 +297,7 @@
'../chrome/third_party/wtl/include',
],
'conditions': [
['OS=="linux"', {
['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'dependencies': [
'../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:x11',
Expand Down Expand Up @@ -375,7 +375,7 @@
'<(SHARED_INTERMEDIATE_DIR)/app/app_resources/app_resources.rc',
],
'conditions': [
['OS=="linux"', {
['OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'dependencies': [
'../build/linux/system.gyp:gtk',
'../chrome/chrome.gyp:packed_resources',
Expand Down
4 changes: 2 additions & 2 deletions webkit/default_plugin/plugin_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#if defined(OS_WIN)
#include "webkit/default_plugin/plugin_impl_win.h"
#elif defined (OS_MACOSX)
#elif defined(OS_MACOSX)
#include "webkit/default_plugin/plugin_impl_mac.h"
#elif defined (OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
#include "webkit/default_plugin/plugin_impl_gtk.h"
#endif
2 changes: 1 addition & 1 deletion webkit/glue/plugins/nphostapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ typedef struct _NPNetscapeFuncs {
//
// NPAPI library entry points
//
#if defined(OS_LINUX) || defined(OS_FREEBSD)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
typedef NPError (API_CALL * NP_InitializeFunc)(NPNetscapeFuncs* pNFuncs,
NPPluginFuncs* pPFuncs);
#else
Expand Down
9 changes: 3 additions & 6 deletions webkit/glue/plugins/plugin_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,32 +705,29 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) {
}
break;
}
#if !defined(OS_MACOSX) // OS X doesn't have windowed plugins.
case NPNVnetscapeWindow: {
#if defined(OS_WIN) || defined(OS_LINUX)
scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
gfx::PluginWindowHandle handle = plugin->window_handle();
*((void**)value) = (void*)handle;
rv = NPERR_NO_ERROR;
#else
NOTIMPLEMENTED();
#endif
break;
}
#endif
case NPNVjavascriptEnabledBool: {
// yes, JS is enabled.
*((void**)value) = (void*)1;
rv = NPERR_NO_ERROR;
break;
}
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
case NPNVToolkit:
// Tell them we are GTK2. (The alternative is GTK 1.2.)
*reinterpret_cast<int*>(value) = NPNVGtk2;
rv = NPERR_NO_ERROR;
break;

case NPNVSupportsXEmbedBool:
// Yes, we support XEmbed.
*reinterpret_cast<NPBool*>(value) = TRUE;
rv = NPERR_NO_ERROR;
break;
Expand Down
6 changes: 3 additions & 3 deletions webkit/glue/plugins/plugin_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ NPError PluginLib::NP_Initialize() {
if (host == 0)
return NPERR_GENERIC_ERROR;

#if defined(OS_LINUX) || defined(OS_FREEBSD)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
NPError rv = entry_points_.np_initialize(host->host_functions(),
&plugin_funcs_);
#else
Expand Down Expand Up @@ -176,7 +176,7 @@ bool PluginLib::Load() {
if (entry_points_.np_initialize == 0)
rv = false;

#if !defined(OS_LINUX) && !defined(OS_FREEBSD)
#if defined(OS_WIN) || defined(OS_MACOSX)
entry_points_.np_getentrypoints =
(NP_GetEntryPointsFunc)base::GetFunctionPointerFromNativeLibrary(
library, "NP_GetEntryPoints");
Expand All @@ -196,7 +196,7 @@ bool PluginLib::Load() {
if (rv) {
plugin_funcs_.size = sizeof(plugin_funcs_);
plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
#if !defined(OS_LINUX) && !defined(OS_FREEBSD) && !defined(OS_MACOSX)
#if !defined(OS_POSIX)
if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR)
rv = false;
#else
Expand Down
4 changes: 2 additions & 2 deletions webkit/glue/plugins/plugin_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class PluginLib : public base::RefCounted<PluginLib> {
// Returns false if the library couldn't be found, or if it's not a plugin.
static bool ReadWebPluginInfo(const FilePath& filename, WebPluginInfo* info);

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Parse the result of an NP_GetMIMEDescription() call.
// This API is only used on Linux, and is exposed here for testing.
// This API is only used on Unixes, and is exposed here for testing.
static void ParseMIMEDescription(const std::string& description,
std::vector<WebPluginMimeType>* mime_types);
#endif
Expand Down
4 changes: 2 additions & 2 deletions webkit/glue/plugins/plugin_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace NPAPI {
class PluginInstance;

// This struct holds entry points into a plugin. The entry points are
// slightly different between Linux and other platforms.
// slightly different between Win/Mac and Unixes.
struct PluginEntryPoints {
#if !defined(OS_LINUX) && !defined(OS_FREEBSD)
#if !defined(OS_POSIX) || defined(OS_MACOSX)
NP_GetEntryPointsFunc np_getentrypoints;
#endif
NP_InitializeFunc np_initialize;
Expand Down
4 changes: 2 additions & 2 deletions webkit/glue/plugins/test/plugin_javascript_open_popup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "build/build_config.h"
#include "webkit/glue/plugins/test/plugin_javascript_open_popup.h"

#if defined(OS_LINUX)
#if defined(USE_X11)
#include "third_party/npapi/bindings/npapi_x11.h"
#endif
#include "webkit/glue/plugins/test/plugin_client.h"
Expand Down Expand Up @@ -63,7 +63,7 @@ bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
return false;
}

#elif defined(OS_LINUX)
#elif defined(USE_X11)
// This code blindly follows the same sorts of verifications done on
// the Windows side. Does it make sense on X? Maybe not really, but
// it can't hurt to do extra validations.
Expand Down
17 changes: 9 additions & 8 deletions webkit/glue/resource_fetcher_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if defined(OS_LINUX)
#include <gtk/gtk.h>
#endif
#include "webkit/glue/resource_fetcher.h"

#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/unittest_test_server.h"
#include "webkit/glue/resource_fetcher.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_shell_test.h"

#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif

using WebKit::WebFrame;
using WebKit::WebURLResponse;
using webkit_glue::ResourceFetcher;
Expand Down Expand Up @@ -76,7 +77,7 @@ class FetcherDelegate {
#if defined(OS_WIN)
timer_id_ = ::SetTimer(NULL, NULL, interval,
&FetcherDelegate::TimerCallback);
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
timer_id_ = g_timeout_add(interval, &FetcherDelegate::TimerCallback, NULL);
#elif defined(OS_MACOSX)
// CFAbsoluteTime is in seconds and |interval| is in ms, so make sure we
Expand All @@ -93,7 +94,7 @@ class FetcherDelegate {
void DestroyTimer() {
#if defined(OS_WIN)
::KillTimer(NULL, timer_id_);
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
g_source_remove(timer_id_);
#elif defined(OS_MACOSX)
CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), timer_id_,
Expand All @@ -108,7 +109,7 @@ class FetcherDelegate {
DWORD ms) {
instance_->TimerFired();
}
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
static gboolean TimerCallback(gpointer data) {
instance_->TimerFired();
return true;
Expand Down Expand Up @@ -137,7 +138,7 @@ class FetcherDelegate {
private:
#if defined(OS_WIN)
UINT_PTR timer_id_;
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
guint timer_id_;
#elif defined(OS_MACOSX)
CFRunLoopTimerRef timer_id_;
Expand Down
2 changes: 1 addition & 1 deletion webkit/glue/webclipboard_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool WebClipboardImpl::ConvertBufferType(Buffer buffer,
*result = Clipboard::BUFFER_STANDARD;
break;
case BufferSelection:
#if defined(OS_LINUX)
#if defined(USE_X11)
*result = Clipboard::BUFFER_SELECTION;
break;
#endif
Expand Down
10 changes: 7 additions & 3 deletions webkit/glue/webdevtoolsfrontend_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,15 @@ v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsLoaded(
// static
v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsPlatform(
const v8::Arguments& args) {
#if defined OS_MACOSX
#if defined(OS_MACOSX)
return v8String("mac-leopard");
#elif defined OS_LINUX
#elif defined(OS_LINUX)
return v8String("linux");
#else
#elif defined(OS_FREEBSD)
return v8String("freebsd");
#elif defined(OS_OPENBSD)
return v8String("openbsd");
#elif defined(OS_WIN)
return v8String("windows");
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions webkit/glue/webkit_glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#if defined(OS_WIN)
#include <objidl.h>
#include <mlang.h>
#elif defined(OS_LINUX) || defined(OS_FREEBSD)
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
#include <sys/utsname.h>
#endif

Expand Down Expand Up @@ -368,7 +368,7 @@ std::string BuildOSCpuInfo() {
&os_minor_version,
&os_bugfix_version);
#endif
#if !defined(OS_WIN) && !defined(OS_MACOSX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Should work on any Posix system.
struct utsname unixinfo;
uname(&unixinfo);
Expand Down Expand Up @@ -421,7 +421,7 @@ void BuildUserAgent(bool mimic_chrome1, bool mimic_windows,
"Windows";
#elif defined(OS_MACOSX)
"Macintosh";
#elif defined(OS_LINUX)
#elif defined(USE_X11)
"X11"; // strange, but that's what Firefox uses
#else
"?";
Expand Down Expand Up @@ -499,7 +499,7 @@ const std::string& GetUserAgent(const GURL& url) {
BuildUserAgent(true, false, &g_user_agent->mimic_chrome1_user_agent);
return g_user_agent->mimic_chrome1_user_agent;
}
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
else if (MatchPatternASCII(url.host(), "*.mail.yahoo.com")) {
// mail.yahoo.com is ok with Windows Chrome but not Linux Chrome.
// http://bugs.chromium.org/11136
Expand Down
2 changes: 1 addition & 1 deletion webkit/glue/webkit_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<include name="IDR_MEDIA_SLIDER_THUMB" file="resources\media_slider_thumb.png" type="BINDATA" />
<include name="IDR_MEDIA_VOLUME_SLIDER_THUMB" file="resources\media_volume_slider_thumb.png" type="BINDATA" />

<if expr="os == 'linux2'">
<if expr="os == 'linux2' or os == 'freebsd7' or os == 'openbsd4'">
<include name="IDR_LINUX_CHECKBOX_OFF" file="resources\linux-checkbox-off.png" type="BINDATA" />
<include name="IDR_LINUX_CHECKBOX_ON" file="resources\linux-checkbox-on.png" type="BINDATA" />
<include name="IDR_LINUX_CHECKBOX_DISABLED_OFF" file="resources\linux-checkbox-disabled-off.png" type="BINDATA" />
Expand Down
3 changes: 2 additions & 1 deletion webkit/glue/webkitclient_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ WebData WebKitClientImpl::loadResource(const char* name) {
{ "mediaSoundDisabled", IDR_MEDIA_SOUND_DISABLED },
{ "mediaSliderThumb", IDR_MEDIA_SLIDER_THUMB },
{ "mediaVolumeSliderThumb", IDR_MEDIA_VOLUME_SLIDER_THUMB },
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// TODO(port): rename these to "skia" instead of "Linux".
{ "linuxCheckboxOff", IDR_LINUX_CHECKBOX_OFF },
{ "linuxCheckboxOn", IDR_LINUX_CHECKBOX_ON },
{ "linuxCheckboxDisabledOff", IDR_LINUX_CHECKBOX_DISABLED_OFF },
Expand Down
2 changes: 1 addition & 1 deletion webkit/tools/layout_tests/layout_package/platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
from platform_utils_win import *
elif sys.platform == 'darwin':
from platform_utils_mac import *
elif sys.platform in ('linux', 'linux2'):
elif sys.platform in ('linux', 'linux2', 'freebsd7', 'openbsd4'):
from platform_utils_linux import *
16 changes: 8 additions & 8 deletions webkit/tools/npapi_layout_test_plugin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@
#define EXPORT
#endif

#if defined(OS_LINUX)
#if defined(USE_X11)
#include <X11/Xlib.h>
#endif

// Plugin entry points
extern "C" {
EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
, NPPluginFuncs *pluginFuncs
#endif
);
EXPORT NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
EXPORT void NPAPI NP_Shutdown(void);

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
EXPORT NPError NPAPI NP_GetValue(NPP instance, NPPVariable variable, void *value);
EXPORT const char* NPAPI NP_GetMIMEDescription(void);
#endif
}

// Plugin entry points
EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
, NPPluginFuncs *pluginFuncs
#endif
)
{
browser = browserFuncs;
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
return NP_GetEntryPoints(pluginFuncs);
#else
return NPERR_NO_ERROR;
Expand Down Expand Up @@ -318,7 +318,7 @@ int16 NPP_HandleEvent(NPP instance, void *event)

fflush(stdout);

#elif defined(OS_LINUX)
#elif defined(USE_X11)
XEvent* evt = static_cast<XEvent*>(event);
XButtonPressedEvent* bpress_evt = reinterpret_cast<XButtonPressedEvent*>(evt);
XButtonReleasedEvent* brelease_evt = reinterpret_cast<XButtonReleasedEvent*>(evt);
Expand Down Expand Up @@ -445,7 +445,7 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
NPError err = NPERR_NO_ERROR;

switch (variable) {
#if defined(OS_LINUX)
#if defined(USE_X11)
case NPPVpluginNameString:
*((const char **)value) = "WebKit Test PlugIn";
break;
Expand Down Expand Up @@ -478,7 +478,7 @@ NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
return NPERR_GENERIC_ERROR;
}

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
EXPORT NPError NPAPI NP_GetValue(NPP instance, NPPVariable variable, void *value)
{
return NPP_GetValue(instance, variable, value);
Expand Down
Loading

0 comments on commit 10a6e77

Please sign in to comment.