From 04b9bd21f888d9976d10f8c1613e72d26e4cc4ab Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 7 Nov 2013 14:02:35 -0600 Subject: [PATCH 01/21] WIP: builds (but displys nothing) on Linux --- brightray/.gitignore | 6 +++ brightray/brightray.gyp | 12 +++++ .../inspectable_web_contents_view_linux.cc | 47 +++++++++++++++++++ .../inspectable_web_contents_view_linux.h | 33 +++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 brightray/browser/linux/inspectable_web_contents_view_linux.cc create mode 100644 brightray/browser/linux/inspectable_web_contents_view_linux.h diff --git a/brightray/.gitignore b/brightray/.gitignore index 4ee8ba8eacf..3f04a5e2f1b 100644 --- a/brightray/.gitignore +++ b/brightray/.gitignore @@ -7,3 +7,9 @@ # Vim *.swp + +# Linux +Makefile +*.Makefile +*.mk +out/ diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index b576b273ec7..7b5f88a3e98 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -46,6 +46,8 @@ 'browser/inspectable_web_contents_view.h', 'browser/inspectable_web_contents_view_mac.h', 'browser/inspectable_web_contents_view_mac.mm', + 'browser/linux/inspectable_web_contents_view_linux.h', + 'browser/linux/inspectable_web_contents_view_linux.cc', 'browser/mac/bry_application.h', 'browser/mac/bry_application.mm', 'browser/mac/bry_inspectable_web_contents_view.h', @@ -79,6 +81,16 @@ 'common/main_delegate_mac.mm', ], 'conditions': [ + ['OS=="linux"', { + 'cflags': [ + '-fno-rtti', + ], + 'link_settings': { + 'libraries': [ + '<(brightray_source_root)/<(libchromiumcontent_library_dir)/libchromiumcontent.so', + ], + }, + }], ['OS=="mac"', { 'link_settings': { 'libraries': [ diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc new file mode 100644 index 00000000000..2eda56fa33c --- /dev/null +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -0,0 +1,47 @@ +#include "inspectable_web_contents_view_linux.h" + +#include "browser/browser_client.h" +#include "browser/inspectable_web_contents_impl.h" + +#include "content/public/browser/web_contents_view.h" + +namespace brightray { + +InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) { + return new InspectableWebContentsViewLinux(inspectable_web_contents); +} + +InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents) + : inspectable_web_contents_(inspectable_web_contents) { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::InspectableWebContentsViewLinux\n"); +} + +InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux\n"); +} + +gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::~GetNativeView\n"); + return NULL; +} + +void InspectableWebContentsViewLinux::ShowDevTools() { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::ShowDevTools\n"); +} + +void InspectableWebContentsViewLinux::CloseDevTools() { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::CloseDevTools\n"); +} + +bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::SetDockSide\n"); + return false; +} + +} diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.h b/brightray/browser/linux/inspectable_web_contents_view_linux.h new file mode 100644 index 00000000000..832481a0572 --- /dev/null +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.h @@ -0,0 +1,33 @@ +#ifndef BRIGHTRAY_BROWSER_LINUX_INSPECTABLE_WEB_CONTENTS_VIEW_LINUX_H_ +#define BRIGHTRAY_BROWSER_LINUX_INSPECTABLE_WEB_CONTENTS_VIEW_LINUX_H_ + +#include "browser/inspectable_web_contents_view.h" + +#include "base/compiler_specific.h" + +namespace brightray { + +class InspectableWebContentsImpl; + +class InspectableWebContentsViewLinux : public InspectableWebContentsView { +public: + InspectableWebContentsViewLinux(InspectableWebContentsImpl*); + ~InspectableWebContentsViewLinux(); + + virtual gfx::NativeView GetNativeView() const OVERRIDE; + virtual void ShowDevTools() OVERRIDE; + virtual void CloseDevTools() OVERRIDE; + virtual bool SetDockSide(const std::string& side) OVERRIDE; + + InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } + +private: + // Owns us. + InspectableWebContentsImpl* inspectable_web_contents_; + + DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux); +}; + +} + +#endif From 90e619a6d9eaa40d73a8f08ffc5ffc24701e88e0 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 7 Nov 2013 17:25:51 -0600 Subject: [PATCH 02/21] fix typo --- brightray/browser/linux/inspectable_web_contents_view_linux.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index 2eda56fa33c..f4c3331016c 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -24,7 +24,7 @@ InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::~GetNativeView\n"); + fprintf(stderr, "InspectableWebContentsViewLinux::GetNativeView\n"); return NULL; } From c6ce51863a51ff71e09fd0a1cab13292c2458435 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 7 Nov 2013 23:42:15 -0600 Subject: [PATCH 03/21] implement GetNativeView --- .../inspectable_web_contents_view_linux.cc | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index f4c3331016c..2ef27e4fb09 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -13,34 +13,32 @@ InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContents InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents) : inspectable_web_contents_(inspectable_web_contents) { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::InspectableWebContentsViewLinux\n"); + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::InspectableWebContentsViewLinux\n"); } InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux\n"); + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux\n"); } gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::GetNativeView\n"); - return NULL; + return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView(); } void InspectableWebContentsViewLinux::ShowDevTools() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::ShowDevTools\n"); + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::ShowDevTools\n"); } void InspectableWebContentsViewLinux::CloseDevTools() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::CloseDevTools\n"); + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::CloseDevTools\n"); } bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::SetDockSide\n"); + // TODO + fprintf(stderr, "InspectableWebContentsViewLinux::SetDockSide\n"); return false; } From 90db457258b2fc9adffc5b27a256849db7dbc731 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Sat, 9 Nov 2013 01:03:46 -0600 Subject: [PATCH 04/21] move -fno-rtti into brightray.gypi target_defaults --- brightray/brightray.gypi | 1 + 1 file changed, 1 insertion(+) diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index ad18976fd3f..ad824d6d749 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -177,6 +177,7 @@ ['OS=="linux"', { 'cflags_cc': [ '-std=gnu++11', + '-fno-rtti', ], }], ], From 7ebb19b9b115501e780dbab09a8fdf53d811675f Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Mon, 11 Nov 2013 16:34:27 -0600 Subject: [PATCH 05/21] use linux branch of libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 21d99bd412d..87c197cfd79 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 21d99bd412dda76aca6bcc722134d24d8ea17746 +Subproject commit 87c197cfd79e34baf8b666d552add2bedd01d43c From 72b41ed31b0f8057dd5dd81cadd31555634707bd Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Mon, 11 Nov 2013 18:15:22 -0600 Subject: [PATCH 06/21] pick up chrome_sandbox changes --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 87c197cfd79..58d63bfde11 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 87c197cfd79e34baf8b666d552add2bedd01d43c +Subproject commit 58d63bfde11b47a83fe014f9589865c1f6352566 From f6784a18016543163d46c72a6036b261166b8f1e Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Tue, 12 Nov 2013 10:19:42 -0600 Subject: [PATCH 07/21] move gtk dependency to brightray --- brightray/brightray.gypi | 1 + 1 file changed, 1 insertion(+) diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index ad824d6d749..911bdc30904 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -178,6 +178,7 @@ 'cflags_cc': [ '-std=gnu++11', '-fno-rtti', + ' Date: Tue, 12 Nov 2013 11:43:29 -0600 Subject: [PATCH 08/21] use merged master of libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 58d63bfde11..430d2991ce0 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 58d63bfde11b47a83fe014f9589865c1f6352566 +Subproject commit 430d2991ce0371f60eaea220c0272bacc8a58860 From 5e7359bc5aaf69d6970f90d60e0b5819d272d659 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Tue, 12 Nov 2013 11:51:25 -0600 Subject: [PATCH 09/21] don't build Linux sources on other platforms --- brightray/brightray.gypi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index 911bdc30904..5587c5dd724 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -180,6 +180,11 @@ '-fno-rtti', ' Date: Wed, 13 Nov 2013 00:42:14 -0600 Subject: [PATCH 10/21] link libencryptor --- brightray/brightray.gyp | 1 + 1 file changed, 1 insertion(+) diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index b40bcd8006b..a4ba5f7861c 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -90,6 +90,7 @@ 'link_settings': { 'libraries': [ '<(brightray_source_root)/<(libchromiumcontent_library_dir)/libchromiumcontent.so', + '<(brightray_source_root)/<(libchromiumcontent_library_dir)/libencryptor.a', ], }, }], From 236e993ac5dabbd56beec184dd45bb205a9afb7e Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 13 Nov 2013 01:45:08 -0600 Subject: [PATCH 11/21] use linux branch of libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 430d2991ce0..0799fdd0347 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 430d2991ce0371f60eaea220c0272bacc8a58860 +Subproject commit 0799fdd034742d6d746c64940d52c599986f7179 From 616cb8212d075a243a7961386a4b2a590685f49e Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 13 Nov 2013 15:34:07 -0600 Subject: [PATCH 12/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 0799fdd0347..593a0574a00 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 0799fdd034742d6d746c64940d52c599986f7179 +Subproject commit 593a0574a00c962ca8d2484e2f44fab1405c5a2a From cbb00f77c2897a3879c10635b9ee29fe821103ff Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 13 Nov 2013 23:22:50 -0600 Subject: [PATCH 13/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 593a0574a00..804a3fb837e 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 593a0574a00c962ca8d2484e2f44fab1405c5a2a +Subproject commit 804a3fb837e22060067e01f46f0d92708d8c3cbc From 3b3d6b2938f512c76e344bb5a2bdf9ae34aa57ff Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 13 Nov 2013 23:48:06 -0600 Subject: [PATCH 14/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 804a3fb837e..593a0574a00 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 804a3fb837e22060067e01f46f0d92708d8c3cbc +Subproject commit 593a0574a00c962ca8d2484e2f44fab1405c5a2a From 85a86a96213951dd615ba2962cc0bcef381c35a1 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 13 Nov 2013 23:50:23 -0600 Subject: [PATCH 15/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 593a0574a00..804a3fb837e 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 593a0574a00c962ca8d2484e2f44fab1405c5a2a +Subproject commit 804a3fb837e22060067e01f46f0d92708d8c3cbc From 282639a79aba67c3b51aa14041776b1cffce7186 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Fri, 15 Nov 2013 14:23:52 -0600 Subject: [PATCH 16/21] implement dev tools --- .../inspectable_web_contents_view_linux.cc | 216 +++++++++++++++++- .../inspectable_web_contents_view_linux.h | 21 ++ 2 files changed, 225 insertions(+), 12 deletions(-) diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index 2ef27e4fb09..3a8428217c4 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -1,5 +1,8 @@ #include "inspectable_web_contents_view_linux.h" +#include +#include +#include "base/strings/stringprintf.h" #include "browser/browser_client.h" #include "browser/inspectable_web_contents_impl.h" @@ -12,34 +15,223 @@ InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContents } InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents) - : inspectable_web_contents_(inspectable_web_contents) { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::InspectableWebContentsViewLinux\n"); + : inspectable_web_contents_(inspectable_web_contents), devtools_window(NULL) { } InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux\n"); + if (devtools_window) gtk_widget_destroy(devtools_window); } +#if 0 // some utility functions to debug GTK window hierarchies +static void dump_one(GtkWidget *wat, int indent) { + GtkAllocation alloc; + gtk_widget_get_allocation(wat, &alloc); + fprintf(stderr, "%*s[%p] %s @%d,%d %dx%d", + indent, "", wat, + g_type_name_from_instance((GTypeInstance*)wat), + alloc.x, alloc.y, alloc.width, alloc.height); + if (GTK_IS_WINDOW(wat)) fprintf(stderr, " - \"%s\"", gtk_window_get_title(GTK_WINDOW(wat))); + fputc('\n', stderr); +} + +static void dump_the_whole_tree(GtkWidget *wat, int indent) { + if (!wat) { + fprintf(stderr, "(nil)\n"); + return; + } + dump_one(wat, indent); + GList *kids = gtk_container_get_children(GTK_CONTAINER(wat)); + for (GList *p=kids; p; p=p->next) { + dump_the_whole_tree(GTK_WIDGET(p->data), indent+2); + } +} + +static void dump_parents(GtkWidget *wat) { + fprintf(stderr, "Parents:\n"); + for (GtkWidget *p=gtk_widget_get_parent(wat); p; p=gtk_widget_get_parent(p)) { + dump_one(p, 2); + } +} +#endif + gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView(); } + +/* This code is a little bit hairy. + The dev tools can be in any one of five places: + 1. Unassigned and invisible. This is the default state until someone asks + to 'inspect element' for the first time. In this case, devtools->parent is + NULL. + 2. In an onscreen window, visible. + 3. In the bottom half of a GtkVPaned. + 4. In the right half of a GtkHPaned. + 5. In an offscreen window, invisible. This is where they go once they have + been displayed and the user asks to "close" them. They can't be put back + into the unassigned state. + ShowDevTools() and is responsible for transitioning from any one of these + states to the three visible states, 2-4, as indicated by the contents of the + 'dockside' variable. The helper functions ShowDevToolsInWindow and + ShowDevToolsInPane focus on transitioning to states 2 and 3+4, respectively. + These helper functions are responsible for the entire transition, including + cleaning up any extraneous containers from the old state. + + Hiding the dev tools is taken care of by CloseDevTools (from paned states + 3+4 to invisible state 5) or by the "delete-event" signal on the + devtools_window (from window state 2 to 5). + + Remember that GTK does reference counting, so a view with no refs and no + parent will be freed. Views that have a ref but no parents will lose their + dimensions. So it's best to move the devtools view from place to place with + gtk_widget_reparent whenever possible. Unfortunately, one cannot reparent + things into a GtkPaned, so fairly brittle use of g_object_[un]ref and + gtk_container_remove happens. +*/ + void InspectableWebContentsViewLinux::ShowDevTools() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::ShowDevTools\n"); + GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + GtkWidget *parent = gtk_widget_get_parent(devtools); + + DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::ShowDevTools - parent=%s@%p window=%p dockside=\"%s\"", + g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window, dockside.c_str()); + + if (!parent || GTK_IS_PANED(parent)) { + if (dockside == "undocked") ShowDevToolsInWindow(); + else if (dockside == "bottom") ShowDevToolsInPane(true); + else if (dockside == "right") ShowDevToolsInPane(false); + } + else { + DCHECK(parent == devtools_window); + if (dockside == "undocked") gtk_widget_show_all(parent); + else if (dockside == "bottom") ShowDevToolsInPane(true); + else if (dockside == "right") ShowDevToolsInPane(false); + } } void InspectableWebContentsViewLinux::CloseDevTools() { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::CloseDevTools\n"); + GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + GtkWidget *parent = gtk_widget_get_parent(devtools); + + DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::CloseDevTools - parent=%s@%p window=%p dockside=\"%s\"", + g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window, dockside.c_str()); + + if (!parent) { + return; // Not visible -> nothing to do + } + else if (GTK_IS_PANED(parent)) { + GtkWidget *browser = GetBrowserWindow(); + GtkWidget *view = GetNativeView(); + + if (!devtools_window) MakeDevToolsWindow(); + gtk_widget_reparent(devtools, devtools_window); + g_object_ref(parent); + gtk_container_remove(GTK_CONTAINER(browser), parent); + gtk_widget_reparent(view, browser); + g_object_unref(parent); + } + else { + DCHECK(parent == devtools_window); + gtk_widget_hide(parent); + } } bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { - // TODO - fprintf(stderr, "InspectableWebContentsViewLinux::SetDockSide\n"); - return false; + DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\""; + if (side != "undocked" && side != "bottom" && side != "right") return false; // unsupported display location + if (dockside == side) return true; // no change from current location + + dockside = side; + + // If devtools already has a parent, then we're being asked to move it. + GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + if (gtk_widget_get_parent(devtools)) { + ShowDevTools(); + } + + return true; +} + +void InspectableWebContentsViewLinux::ShowDevToolsInWindow() { + GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + GtkWidget *parent = gtk_widget_get_parent(devtools); + + if (!devtools_window) MakeDevToolsWindow(); + if (!parent) { + gtk_container_add(GTK_CONTAINER(devtools_window), devtools); + } + else if (parent != devtools_window) { + DCHECK(GTK_IS_PANED(parent)); + gtk_widget_reparent(devtools, devtools_window); + + // Remove the pane. + GtkWidget *view = GetNativeView(); + GtkWidget *browser = GetBrowserWindow(); + g_object_ref(view); + gtk_container_remove(GTK_CONTAINER(parent), view); + gtk_container_remove(GTK_CONTAINER(browser), parent); + gtk_container_add(GTK_CONTAINER(browser), view); + g_object_unref(view); + } + gtk_widget_show_all(devtools_window); +} + +void InspectableWebContentsViewLinux::MakeDevToolsWindow() { + DCHECK(!devtools_window); + devtools_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(devtools_window), "Developer Tools"); + gtk_window_set_default_size(GTK_WINDOW(devtools_window), 800, 600); + g_signal_connect(GTK_OBJECT(devtools_window), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this); +} + +void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { + GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); + GtkWidget *parent = gtk_widget_get_parent(devtools); + GtkWidget *pane = on_bottom ? gtk_vpaned_new() : gtk_hpaned_new(); + GtkWidget *view = GetNativeView(); + GtkWidget *browser = GetBrowserWindow(); + + GtkAllocation alloc; + gtk_widget_get_allocation(browser, &alloc); + gtk_paned_set_position(GTK_PANED(pane), on_bottom ? alloc.height*2/3 : alloc.width/2); + if (!parent) { + g_object_ref(view); + gtk_container_remove(GTK_CONTAINER(browser), view); + gtk_paned_add1(GTK_PANED(pane), view); + gtk_paned_add2(GTK_PANED(pane), devtools); + g_object_unref(view); + } + else if (GTK_IS_PANED(parent)) { + g_object_ref(view); + g_object_ref(devtools); + gtk_container_remove(GTK_CONTAINER(parent), view); + gtk_container_remove(GTK_CONTAINER(parent), devtools); + gtk_paned_add1(GTK_PANED(pane), view); + gtk_paned_add2(GTK_PANED(pane), devtools); + g_object_unref(view); + g_object_unref(devtools); + gtk_container_remove(GTK_CONTAINER(browser), parent); + } + else { + DCHECK(parent == devtools_window); + g_object_ref(view); + gtk_container_remove(GTK_CONTAINER(devtools_window), devtools); + gtk_container_remove(GTK_CONTAINER(browser), view); + gtk_paned_add1(GTK_PANED(pane), view); + gtk_paned_add2(GTK_PANED(pane), devtools); + g_object_unref(view); + gtk_widget_hide(devtools_window); + } + gtk_container_add(GTK_CONTAINER(browser), pane); + gtk_widget_show_all(pane); +} + +GtkWidget *InspectableWebContentsViewLinux::GetBrowserWindow() { + GtkWidget *view = GetNativeView(); + GtkWidget *parent = gtk_widget_get_parent(view); + GtkWidget *browser = GTK_IS_PANED(parent) ? gtk_widget_get_parent(parent) : parent; + DCHECK(GTK_IS_WINDOW(browser)); + return browser; } } diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.h b/brightray/browser/linux/inspectable_web_contents_view_linux.h index 832481a0572..f0b89929804 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.h +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.h @@ -25,6 +25,27 @@ private: // Owns us. InspectableWebContentsImpl* inspectable_web_contents_; + std::string dockside; + GtkWidget *devtools_window; + + // Show the dev tools in their own window. If they're already shown + // somewhere else, remove them cleanly and take any GtkPaned out of the + // window. + void ShowDevToolsInWindow(); + + // Show the dev tools in a vpaned (on the bottom) or hpaned (on the + // right). If they're already shown in a pane, move them and remove the + // old pane. If they're already shown in a window, hide (don't delete) + // that window. + void ShowDevToolsInPane(bool on_bottom); + + // Create a new window for dev tools. This function doesn't actually + // put the dev tools in the window or show the window. + void MakeDevToolsWindow(); + + // Get the GtkWindow* that contains this object. + GtkWidget *GetBrowserWindow(); + DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux); }; From 7e1a4003df70b5eb044bb4cad0166ac4ec60233d Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Fri, 15 Nov 2013 22:18:59 -0600 Subject: [PATCH 17/21] don't force all applications to link libencryptor.a --- brightray/brightray.gyp | 1 - 1 file changed, 1 deletion(-) diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index a4ba5f7861c..b40bcd8006b 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -90,7 +90,6 @@ 'link_settings': { 'libraries': [ '<(brightray_source_root)/<(libchromiumcontent_library_dir)/libchromiumcontent.so', - '<(brightray_source_root)/<(libchromiumcontent_library_dir)/libencryptor.a', ], }, }], From a18842de1a913f2f40daa14ef9c9ea5f7b98fc65 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Fri, 15 Nov 2013 22:22:25 -0600 Subject: [PATCH 18/21] give member variables trailing _ - also, reorder member variables to come after methods --- .../inspectable_web_contents_view_linux.cc | 62 +++++++++---------- .../inspectable_web_contents_view_linux.h | 40 ++++++------ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index 3a8428217c4..eb792aa69d8 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -15,11 +15,11 @@ InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContents } InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents) - : inspectable_web_contents_(inspectable_web_contents), devtools_window(NULL) { + : inspectable_web_contents_(inspectable_web_contents), devtools_window_(NULL) { } InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() { - if (devtools_window) gtk_widget_destroy(devtools_window); + if (devtools_window_) gtk_widget_destroy(devtools_window_); } #if 0 // some utility functions to debug GTK window hierarchies @@ -72,14 +72,14 @@ gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const { into the unassigned state. ShowDevTools() and is responsible for transitioning from any one of these states to the three visible states, 2-4, as indicated by the contents of the - 'dockside' variable. The helper functions ShowDevToolsInWindow and + 'dockside_' variable. The helper functions ShowDevToolsInWindow and ShowDevToolsInPane focus on transitioning to states 2 and 3+4, respectively. These helper functions are responsible for the entire transition, including cleaning up any extraneous containers from the old state. Hiding the dev tools is taken care of by CloseDevTools (from paned states 3+4 to invisible state 5) or by the "delete-event" signal on the - devtools_window (from window state 2 to 5). + devtools_window_ (from window state 2 to 5). Remember that GTK does reference counting, so a view with no refs and no parent will be freed. Views that have a ref but no parents will lose their @@ -94,18 +94,18 @@ void InspectableWebContentsViewLinux::ShowDevTools() { GtkWidget *parent = gtk_widget_get_parent(devtools); DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::ShowDevTools - parent=%s@%p window=%p dockside=\"%s\"", - g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window, dockside.c_str()); + g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str()); if (!parent || GTK_IS_PANED(parent)) { - if (dockside == "undocked") ShowDevToolsInWindow(); - else if (dockside == "bottom") ShowDevToolsInPane(true); - else if (dockside == "right") ShowDevToolsInPane(false); + if (dockside_ == "undocked") ShowDevToolsInWindow(); + else if (dockside_ == "bottom") ShowDevToolsInPane(true); + else if (dockside_ == "right") ShowDevToolsInPane(false); } else { - DCHECK(parent == devtools_window); - if (dockside == "undocked") gtk_widget_show_all(parent); - else if (dockside == "bottom") ShowDevToolsInPane(true); - else if (dockside == "right") ShowDevToolsInPane(false); + DCHECK(parent == devtools_window_); + if (dockside_ == "undocked") gtk_widget_show_all(parent); + else if (dockside_ == "bottom") ShowDevToolsInPane(true); + else if (dockside_ == "right") ShowDevToolsInPane(false); } } @@ -114,7 +114,7 @@ void InspectableWebContentsViewLinux::CloseDevTools() { GtkWidget *parent = gtk_widget_get_parent(devtools); DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::CloseDevTools - parent=%s@%p window=%p dockside=\"%s\"", - g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window, dockside.c_str()); + g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str()); if (!parent) { return; // Not visible -> nothing to do @@ -123,15 +123,15 @@ void InspectableWebContentsViewLinux::CloseDevTools() { GtkWidget *browser = GetBrowserWindow(); GtkWidget *view = GetNativeView(); - if (!devtools_window) MakeDevToolsWindow(); - gtk_widget_reparent(devtools, devtools_window); + if (!devtools_window_) MakeDevToolsWindow(); + gtk_widget_reparent(devtools, devtools_window_); g_object_ref(parent); gtk_container_remove(GTK_CONTAINER(browser), parent); gtk_widget_reparent(view, browser); g_object_unref(parent); } else { - DCHECK(parent == devtools_window); + DCHECK(parent == devtools_window_); gtk_widget_hide(parent); } } @@ -139,9 +139,9 @@ void InspectableWebContentsViewLinux::CloseDevTools() { bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\""; if (side != "undocked" && side != "bottom" && side != "right") return false; // unsupported display location - if (dockside == side) return true; // no change from current location + if (dockside_ == side) return true; // no change from current location - dockside = side; + dockside_ = side; // If devtools already has a parent, then we're being asked to move it. GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); @@ -156,13 +156,13 @@ void InspectableWebContentsViewLinux::ShowDevToolsInWindow() { GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(); GtkWidget *parent = gtk_widget_get_parent(devtools); - if (!devtools_window) MakeDevToolsWindow(); + if (!devtools_window_) MakeDevToolsWindow(); if (!parent) { - gtk_container_add(GTK_CONTAINER(devtools_window), devtools); + gtk_container_add(GTK_CONTAINER(devtools_window_), devtools); } - else if (parent != devtools_window) { + else if (parent != devtools_window_) { DCHECK(GTK_IS_PANED(parent)); - gtk_widget_reparent(devtools, devtools_window); + gtk_widget_reparent(devtools, devtools_window_); // Remove the pane. GtkWidget *view = GetNativeView(); @@ -173,15 +173,15 @@ void InspectableWebContentsViewLinux::ShowDevToolsInWindow() { gtk_container_add(GTK_CONTAINER(browser), view); g_object_unref(view); } - gtk_widget_show_all(devtools_window); + gtk_widget_show_all(devtools_window_); } void InspectableWebContentsViewLinux::MakeDevToolsWindow() { - DCHECK(!devtools_window); - devtools_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(devtools_window), "Developer Tools"); - gtk_window_set_default_size(GTK_WINDOW(devtools_window), 800, 600); - g_signal_connect(GTK_OBJECT(devtools_window), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this); + DCHECK(!devtools_window_); + devtools_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(devtools_window_), "Developer Tools"); + gtk_window_set_default_size(GTK_WINDOW(devtools_window_), 800, 600); + g_signal_connect(GTK_OBJECT(devtools_window_), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this); } void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { @@ -213,14 +213,14 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) { gtk_container_remove(GTK_CONTAINER(browser), parent); } else { - DCHECK(parent == devtools_window); + DCHECK(parent == devtools_window_); g_object_ref(view); - gtk_container_remove(GTK_CONTAINER(devtools_window), devtools); + gtk_container_remove(GTK_CONTAINER(devtools_window_), devtools); gtk_container_remove(GTK_CONTAINER(browser), view); gtk_paned_add1(GTK_PANED(pane), view); gtk_paned_add2(GTK_PANED(pane), devtools); g_object_unref(view); - gtk_widget_hide(devtools_window); + gtk_widget_hide(devtools_window_); } gtk_container_add(GTK_CONTAINER(browser), pane); gtk_widget_show_all(pane); diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.h b/brightray/browser/linux/inspectable_web_contents_view_linux.h index f0b89929804..f82de0a54cd 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.h +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.h @@ -22,29 +22,29 @@ public: InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } private: + // Show the dev tools in their own window. If they're already shown + // somewhere else, remove them cleanly and take any GtkPaned out of the + // window. + void ShowDevToolsInWindow(); + + // Show the dev tools in a vpaned (on the bottom) or hpaned (on the + // right). If they're already shown in a pane, move them and remove the + // old pane. If they're already shown in a window, hide (don't delete) + // that window. + void ShowDevToolsInPane(bool on_bottom); + + // Create a new window for dev tools. This function doesn't actually + // put the dev tools in the window or show the window. + void MakeDevToolsWindow(); + + // Get the GtkWindow* that contains this object. + GtkWidget *GetBrowserWindow(); + // Owns us. InspectableWebContentsImpl* inspectable_web_contents_; - std::string dockside; - GtkWidget *devtools_window; - - // Show the dev tools in their own window. If they're already shown - // somewhere else, remove them cleanly and take any GtkPaned out of the - // window. - void ShowDevToolsInWindow(); - - // Show the dev tools in a vpaned (on the bottom) or hpaned (on the - // right). If they're already shown in a pane, move them and remove the - // old pane. If they're already shown in a window, hide (don't delete) - // that window. - void ShowDevToolsInPane(bool on_bottom); - - // Create a new window for dev tools. This function doesn't actually - // put the dev tools in the window or show the window. - void MakeDevToolsWindow(); - - // Get the GtkWindow* that contains this object. - GtkWidget *GetBrowserWindow(); + std::string dockside_; + GtkWidget *devtools_window_; DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux); }; From c0543d9b465c8c900d8a096a7e43ea5ce5157c96 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Fri, 15 Nov 2013 23:04:02 -0600 Subject: [PATCH 19/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 804a3fb837e..f8c75f2bc74 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 804a3fb837e22060067e01f46f0d92708d8c3cbc +Subproject commit f8c75f2bc74500e5f24574e22e289b329b5a9a5e From 5ae0b3094c160d81b12e719ccfaa383b3d9bfa03 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Sat, 16 Nov 2013 00:49:53 -0600 Subject: [PATCH 20/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index f8c75f2bc74..8fe70e336bc 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit f8c75f2bc74500e5f24574e22e289b329b5a9a5e +Subproject commit 8fe70e336bc8ebde82225d692ef254999defe243 From ceb8113ca68603fa0c02cd52f14f710f06741580 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Sat, 16 Nov 2013 01:14:51 -0600 Subject: [PATCH 21/21] current libchromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 8fe70e336bc..7ddba388364 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 8fe70e336bc8ebde82225d692ef254999defe243 +Subproject commit 7ddba388364ee0b429a2b72555daa55e3270876f