summaryrefslogtreecommitdiffstats
path: root/components/guest_view/browser
diff options
context:
space:
mode:
authorlazyboy <lazyboy@chromium.org>2015-07-21 03:12:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-21 10:12:57 +0000
commit87a98e428afa9dff6d02ff37d1504411d40fda3d (patch)
treed55359ccb440c1ec9cd34b6c59e8145eb59756b4 /components/guest_view/browser
parentbe38b7a2c60c18dd2b3697a80241561f048d5260 (diff)
downloadchromium_src-87a98e428afa9dff6d02ff37d1504411d40fda3d.zip
chromium_src-87a98e428afa9dff6d02ff37d1504411d40fda3d.tar.gz
chromium_src-87a98e428afa9dff6d02ff37d1504411d40fda3d.tar.bz2
Fix nested GuestView's container bounds calculation.
This results in incorrect context menu positioning in pdf in webview or webview inside appview. If a guest A is nested within an embedder B, which in turn is nested inside an embedder C, then we used to add offset twice to calculate the bounds of A because BrowserPluginGuest::GetScreenCoordinates would add: 1. offset of C from A and 2. offset of B from A. This CL removes step #2. From logs, it seems to be there from the beginning of appview implementation. BUG=507223 Test=Load a PDF inside <webview> and check context menu inside the PDF. Easier to test with the browser sample: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/webview-samples/browser You should observe the context menu is shown in the right place instead of it being shifted. Review URL: https://codereview.chromium.org/1237343002 Cr-Commit-Position: refs/heads/master@{#339635}
Diffstat (limited to 'components/guest_view/browser')
-rw-r--r--components/guest_view/browser/test_guest_view_manager.cc32
-rw-r--r--components/guest_view/browser/test_guest_view_manager.h14
2 files changed, 35 insertions, 11 deletions
diff --git a/components/guest_view/browser/test_guest_view_manager.cc b/components/guest_view/browser/test_guest_view_manager.cc
index 78458ef..c23399a 100644
--- a/components/guest_view/browser/test_guest_view_manager.cc
+++ b/components/guest_view/browser/test_guest_view_manager.cc
@@ -15,7 +15,9 @@ TestGuestViewManager::TestGuestViewManager(
: GuestViewManager(context, delegate.Pass()),
num_embedder_processes_destroyed_(0),
num_guests_created_(0),
- num_views_garbage_collected_(0) {
+ expected_num_guests_created_(0),
+ num_views_garbage_collected_(0),
+ waiting_for_guests_created_(false) {
}
TestGuestViewManager::~TestGuestViewManager() {
@@ -51,22 +53,28 @@ void TestGuestViewManager::WaitForLastGuestDeleted() {
guest_web_contents_watchers_.back()->Wait();
};
-void TestGuestViewManager::WaitForGuestCreated() {
- created_message_loop_runner_ = new content::MessageLoopRunner;
- created_message_loop_runner_->Run();
-}
-
content::WebContents* TestGuestViewManager::WaitForSingleGuestCreated() {
if (!GetNumGuestsActive()) {
// Guests have been created and subsequently destroyed.
if (num_guests_created() > 0)
return nullptr;
- WaitForGuestCreated();
+ WaitForNumGuestsCreated(1u);
}
return GetLastGuestCreated();
}
+void TestGuestViewManager::WaitForNumGuestsCreated(size_t count) {
+ if (count == num_guests_created_)
+ return;
+
+ waiting_for_guests_created_ = true;
+ expected_num_guests_created_ = count;
+
+ created_message_loop_runner_ = new content::MessageLoopRunner;
+ created_message_loop_runner_->Run();
+}
+
void TestGuestViewManager::WaitForViewGarbageCollected() {
gc_message_loop_runner_ = new content::MessageLoopRunner;
gc_message_loop_runner_->Run();
@@ -86,11 +94,21 @@ void TestGuestViewManager::AddGuest(int guest_instance_id,
new content::WebContentsDestroyedWatcher(guest_web_contents)));
++num_guests_created_;
+ if (!waiting_for_guests_created_ &&
+ num_guests_created_ != expected_num_guests_created_) {
+ return;
+ }
if (created_message_loop_runner_.get())
created_message_loop_runner_->Quit();
}
+void TestGuestViewManager::GetGuestWebContentsList(
+ std::vector<content::WebContents*>* guest_web_contents_list) {
+ for (auto& watcher : guest_web_contents_watchers_)
+ guest_web_contents_list->push_back(watcher->web_contents());
+}
+
void TestGuestViewManager::RemoveGuest(int guest_instance_id) {
GuestViewManager::RemoveGuest(guest_instance_id);
}
diff --git a/components/guest_view/browser/test_guest_view_manager.h b/components/guest_view/browser/test_guest_view_manager.h
index 76f0cd7..5367737 100644
--- a/components/guest_view/browser/test_guest_view_manager.h
+++ b/components/guest_view/browser/test_guest_view_manager.h
@@ -25,6 +25,7 @@ class TestGuestViewManager : public GuestViewManager {
void WaitForLastGuestDeleted();
content::WebContents* WaitForSingleGuestCreated();
+ void WaitForNumGuestsCreated(size_t count);
void WaitForSingleViewGarbageCollected();
@@ -56,7 +57,7 @@ class TestGuestViewManager : public GuestViewManager {
// Returns the number of guests that have been created since the creation of
// this GuestViewManager.
- int num_guests_created() const { return num_guests_created_; }
+ size_t num_guests_created() const { return num_guests_created_; }
// Returns the number of GuestViews that have been garbage collected in
// JavaScript since the creation of this GuestViewManager.
@@ -67,6 +68,11 @@ class TestGuestViewManager : public GuestViewManager {
// Returns the last guest instance ID removed from the manager.
int last_instance_id_removed() const { return last_instance_id_removed_; }
+ // Returns the list of guests WebContentses that were created by this
+ // manager.
+ void GetGuestWebContentsList(
+ std::vector<content::WebContents*>* guest_web_contents_list);
+
private:
FRIEND_TEST_ALL_PREFIXES(GuestViewManagerTest, AddRemove);
@@ -78,16 +84,16 @@ class TestGuestViewManager : public GuestViewManager {
void ViewGarbageCollected(int embedder_process_id,
int view_instance_id) override;
- void WaitForGuestCreated();
-
void WaitForViewGarbageCollected();
using GuestViewManager::last_instance_id_removed_;
using GuestViewManager::removed_instance_ids_;
int num_embedder_processes_destroyed_;
- int num_guests_created_;
+ size_t num_guests_created_;
+ size_t expected_num_guests_created_;
int num_views_garbage_collected_;
+ bool waiting_for_guests_created_;
std::vector<linked_ptr<content::WebContentsDestroyedWatcher>>
guest_web_contents_watchers_;