forked from lazyboy/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Istiaque Ahmed
committed
Jul 2, 2013
1 parent
25674da
commit 28f9ff5
Showing
1 changed file
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc | ||
index 947f639..5b40c55 100644 | ||
--- a/content/browser/web_contents/web_contents_view_aura.cc | ||
+++ b/content/browser/web_contents/web_contents_view_aura.cc | ||
@@ -1214,6 +1214,11 @@ void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { | ||
navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | ||
} | ||
|
||
+void WebContentsViewAura::OverrideOrigin(const gfx::Point& origin) { | ||
+ gfx::Rect new_bounds(origin, window_->bounds().size()); | ||
+ window_->SetBounds(new_bounds); | ||
+} | ||
+ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// WebContentsViewAura, RenderViewHostDelegateView implementation: | ||
|
||
diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h | ||
index 0ed09ef..24b113c 100644 | ||
--- a/content/browser/web_contents/web_contents_view_aura.h | ||
+++ b/content/browser/web_contents/web_contents_view_aura.h | ||
@@ -123,6 +123,7 @@ class CONTENT_EXPORT WebContentsViewAura | ||
virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; | ||
virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; | ||
virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; | ||
+ virtual void OverrideOrigin(const gfx::Point& origin) OVERRIDE; | ||
|
||
// Overridden from RenderViewHostDelegateView: | ||
virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; | ||
diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc | ||
index 5a2b81e..a5ab86f 100644 | ||
--- a/content/browser/web_contents/web_contents_view_guest.cc | ||
+++ b/content/browser/web_contents/web_contents_view_guest.cc | ||
@@ -21,6 +21,10 @@ | ||
#include "ui/gfx/rect.h" | ||
#include "ui/gfx/size.h" | ||
|
||
+#if defined(USE_AURA) | ||
+#include "ui/aura/window.h" | ||
+#endif | ||
+ | ||
using WebKit::WebDragOperation; | ||
using WebKit::WebDragOperationsMask; | ||
|
||
@@ -34,6 +38,7 @@ WebContentsViewGuest::WebContentsViewGuest( | ||
: web_contents_(web_contents), | ||
guest_(guest), | ||
platform_view_(platform_view), | ||
+ added_to_embedder_parent_view_hierarchy_(false), | ||
platform_view_delegate_view_(platform_view_delegate_view) { | ||
} | ||
|
||
@@ -109,6 +114,24 @@ RenderWidgetHostView* WebContentsViewGuest::CreateViewForWidget( | ||
RenderWidgetHostView* platform_widget = NULL; | ||
platform_widget = platform_view_->CreateViewForWidget(render_widget_host); | ||
|
||
+#if defined(USE_AURA) || defined(OS_WIN) | ||
+ // In aura and windows, ScreenPositionClient doesn't work properly if we do | ||
+ // not have the native view associated with this WebContentsViewGuest in the | ||
+ // view hierarchy. We add this view as embedder's child here. | ||
+ // This would go in WebContentsViewGuest::CreateView, but that is too early to | ||
+ // access embedder_web_contents(). Therefore, we do it here. | ||
+ if (!added_to_embedder_parent_view_hierarchy_) { | ||
+ added_to_embedder_parent_view_hierarchy_ = true; | ||
+ WebContentsView* parent = guest_->embedder_web_contents()->GetView(); | ||
+#if defined(USE_AURA) | ||
+ // This can be win aura or chromeos. | ||
+ parent->GetNativeView()->AddChild(platform_view_->GetNativeView()); | ||
+#elif defined(OS_WIN) | ||
+ SetParent(platform_view_->GetNativeView(), parent->GetNativeView()); | ||
+#endif | ||
+ } | ||
+#endif // defined(USE_AURA) || defined(OS_WIN) | ||
+ | ||
RenderWidgetHostView* view = new RenderWidgetHostViewGuest( | ||
render_widget_host, | ||
guest_, | ||
@@ -146,6 +169,12 @@ void WebContentsViewGuest::CloseTabAfterEventTracking() { | ||
} | ||
#endif | ||
|
||
+#if defined(USE_AURA) || defined(OS_WIN) | ||
+void WebContentsViewGuest::OverrideOrigin(const gfx::Point& origin) { | ||
+ platform_view_->OverrideOrigin(origin); | ||
+} | ||
+#endif // defined(USE_AURA) || defined(OS_WIN) | ||
+ | ||
WebContents* WebContentsViewGuest::web_contents() { | ||
return web_contents_; | ||
} | ||
@@ -189,7 +218,22 @@ void WebContentsViewGuest::TakeFocus(bool reverse) { | ||
} | ||
|
||
void WebContentsViewGuest::ShowContextMenu(const ContextMenuParams& params) { | ||
- platform_view_delegate_view_->ShowContextMenu(params); | ||
+#if defined(USE_AURA) || defined(OS_WIN) | ||
+ gfx::Rect embedder_bounds; | ||
+ guest_->embedder_web_contents()->GetView()->GetContainerBounds( | ||
+ &embedder_bounds); | ||
+ gfx::Rect guest_bounds; | ||
+ GetContainerBounds(&guest_bounds); | ||
+ | ||
+ gfx::Point origin = gfx::PointAtOffsetFromOrigin( | ||
+ guest_bounds.origin() - embedder_bounds.origin()); | ||
+ //OverrideOrigin(origin); | ||
+#endif // defined(USE_AURA) || defined(OS_WIN) | ||
+ ContextMenuParams new_params = params; | ||
+ new_params.x += origin.x(); | ||
+ new_params.y += origin.y(); | ||
+ | ||
+ platform_view_delegate_view_->ShowContextMenu(new_params); | ||
} | ||
|
||
void WebContentsViewGuest::ShowPopupMenu(const gfx::Rect& bounds, | ||
diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h | ||
index d080a9d..1a90d77 100644 | ||
--- a/content/browser/web_contents/web_contents_view_guest.h | ||
+++ b/content/browser/web_contents/web_contents_view_guest.h | ||
@@ -72,6 +72,10 @@ class CONTENT_EXPORT WebContentsViewGuest | ||
virtual void CloseTabAfterEventTracking() OVERRIDE; | ||
#endif | ||
|
||
+#if defined(USE_AURA) || defined(OS_WIN) | ||
+ virtual void OverrideOrigin(const gfx::Point& origin) OVERRIDE; | ||
+#endif | ||
+ | ||
// Backend implementation of RenderViewHostDelegateView. | ||
virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; | ||
virtual void ShowPopupMenu(const gfx::Rect& bounds, | ||
@@ -98,6 +102,7 @@ class CONTENT_EXPORT WebContentsViewGuest | ||
// Calls to this WebContentsViewGuest are forwarded to |platform_view_|. | ||
WebContentsViewPort* platform_view_; | ||
gfx::Size size_; | ||
+ bool added_to_embedder_parent_view_hierarchy_; | ||
|
||
// Delegate view for guest's platform view. | ||
RenderViewHostDelegateView* platform_view_delegate_view_; | ||
diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc | ||
index 59415ea..7c2995c 100644 | ||
--- a/content/browser/web_contents/web_contents_view_win.cc | ||
+++ b/content/browser/web_contents/web_contents_view_win.cc | ||
@@ -243,6 +243,13 @@ void WebContentsViewWin::RenderViewSwappedIn(RenderViewHost* host) { | ||
void WebContentsViewWin::SetOverscrollControllerEnabled(bool enabled) { | ||
} | ||
|
||
+void OverrideOrigin(const gfx::Point& origin) { | ||
+ printf("original size was: {%d X %d}\n", bounds().width(), bounds().height()); | ||
+ SetWindowPos(GetNativeView(), 0, origin.x(), origin.y(), | ||
+ bounds().width(), bounds.height(), | ||
+ SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | ||
+} | ||
+ | ||
void WebContentsViewWin::ShowContextMenu(const ContextMenuParams& params) { | ||
if (delegate_) | ||
delegate_->ShowContextMenu(params); | ||
diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h | ||
index cfb4ecd..d1289a0 100644 | ||
--- a/content/browser/web_contents/web_contents_view_win.h | ||
+++ b/content/browser/web_contents/web_contents_view_win.h | ||
@@ -77,6 +77,7 @@ class CONTENT_EXPORT WebContentsViewWin | ||
virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; | ||
virtual void RenderViewSwappedIn(RenderViewHost* host) OVERRIDE; | ||
virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; | ||
+ virtual void OverrideOrigin(const gfx::Point& origin) OVERRIDE; | ||
|
||
// Implementation of RenderViewHostDelegateView. | ||
virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; | ||
diff --git a/content/port/browser/web_contents_view_port.h b/content/port/browser/web_contents_view_port.h | ||
index 12c3083..86fca02 100644 | ||
--- a/content/port/browser/web_contents_view_port.h | ||
+++ b/content/port/browser/web_contents_view_port.h | ||
@@ -57,6 +57,10 @@ class CONTENT_EXPORT WebContentsViewPort : public WebContentsView { | ||
virtual bool IsEventTracking() const = 0; | ||
virtual void CloseTabAfterEventTracking() = 0; | ||
#endif | ||
+ | ||
+#if defined(USE_AURA) || defined(OS_WIN) | ||
+ virtual void OverrideOrigin(const gfx::Point& origin) = 0; | ||
+#endif | ||
}; | ||
|
||
} // namespace content |