Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1491)

Unified Diff: mojo/aura/window_tree_host_mojo.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/aura/window_tree_host_mojo.cc
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc
index 9aba1d8af859db89c3f4d1907e2ab3a356056f23..c84623c91956011258b6a95942c7befbe9ac6d12 100644
--- a/mojo/aura/window_tree_host_mojo.cc
+++ b/mojo/aura/window_tree_host_mojo.cc
@@ -6,7 +6,6 @@
#include "mojo/aura/context_factory_mojo.h"
#include "mojo/public/c/gles2/gles2.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/services/native_viewport/geometry_conversions.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
@@ -33,9 +32,7 @@ WindowTreeHostMojo::WindowTreeHostMojo(
compositor_created_callback_(compositor_created_callback),
bounds_(bounds) {
native_viewport_->SetClient(this);
-
- AllocationScope scope;
- native_viewport_->Create(bounds);
+ native_viewport_->Create(Rect::From(bounds));
ScopedMessagePipeHandle gles2_handle, gles2_client_handle;
CreateMessagePipe(&gles2_handle, &gles2_client_handle);
@@ -85,8 +82,7 @@ gfx::Rect WindowTreeHostMojo::GetBounds() const {
}
void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) {
- AllocationScope scope;
- native_viewport_->SetBounds(bounds);
+ native_viewport_->SetBounds(Rect::From(bounds));
}
gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const {
@@ -137,9 +133,9 @@ void WindowTreeHostMojo::OnCreated() {
compositor_created_callback_.Run();
}
-void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) {
- bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(),
- bounds.size().width(), bounds.size().height());
+void WindowTreeHostMojo::OnBoundsChanged(RectPtr bounds) {
+ bounds_ = gfx::Rect(bounds->position->x, bounds->position->y,
+ bounds->size->width, bounds->size->height);
window()->SetBounds(gfx::Rect(bounds_.size()));
OnHostResized(bounds_.size());
}
@@ -148,27 +144,27 @@ void WindowTreeHostMojo::OnDestroyed() {
base::MessageLoop::current()->Quit();
}
-void WindowTreeHostMojo::OnEvent(const Event& event,
+void WindowTreeHostMojo::OnEvent(EventPtr event,
const mojo::Callback<void()>& callback) {
- switch (event.action()) {
+ switch (event->action) {
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_DRAGGED:
case ui::ET_MOUSE_RELEASED:
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_ENTERED:
case ui::ET_MOUSE_EXITED: {
- gfx::Point location(event.location().x(), event.location().y());
- ui::MouseEvent ev(static_cast<ui::EventType>(event.action()), location,
- location, event.flags(), 0);
+ gfx::Point location(event->location->x, event->location->y);
+ ui::MouseEvent ev(static_cast<ui::EventType>(event->action), location,
+ location, event->flags, 0);
SendEventToProcessor(&ev);
break;
}
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED: {
ui::KeyEvent ev(
- static_cast<ui::EventType>(event.action()),
- static_cast<ui::KeyboardCode>(event.key_data().key_code()),
- event.flags(), event.key_data().is_char());
+ static_cast<ui::EventType>(event->action),
+ static_cast<ui::KeyboardCode>(event->key_data->key_code),
+ event->flags, event->key_data->is_char);
SendEventToProcessor(&ev);
break;
}

Powered by Google App Engine
This is Rietveld 408576698