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

Side by Side Diff: components/mus/public/cpp/lib/window.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/mus/public/cpp/window.h" 5 #include "components/mus/public/cpp/window.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 void Window::Reorder(Window* relative, mojom::OrderDirection direction) { 291 void Window::Reorder(Window* relative, mojom::OrderDirection direction) {
292 if (!LocalReorder(relative, direction)) 292 if (!LocalReorder(relative, direction))
293 return; 293 return;
294 if (connection_) 294 if (connection_)
295 tree_client()->Reorder(this, relative->id(), direction); 295 tree_client()->Reorder(this, relative->id(), direction);
296 } 296 }
297 297
298 void Window::MoveToFront() { 298 void Window::MoveToFront() {
299 if (!parent_ || parent_->children_.back() == this) 299 if (!parent_ || parent_->children_.back() == this)
300 return; 300 return;
301 Reorder(parent_->children_.back(), mojom::ORDER_DIRECTION_ABOVE); 301 Reorder(parent_->children_.back(), mojom::OrderDirection::ABOVE);
302 } 302 }
303 303
304 void Window::MoveToBack() { 304 void Window::MoveToBack() {
305 if (!parent_ || parent_->children_.front() == this) 305 if (!parent_ || parent_->children_.front() == this)
306 return; 306 return;
307 Reorder(parent_->children_.front(), mojom::ORDER_DIRECTION_BELOW); 307 Reorder(parent_->children_.front(), mojom::OrderDirection::BELOW);
308 } 308 }
309 309
310 bool Window::Contains(Window* child) const { 310 bool Window::Contains(Window* child) const {
311 if (!child) 311 if (!child)
312 return false; 312 return false;
313 if (child == this) 313 if (child == this)
314 return true; 314 return true;
315 if (connection_) 315 if (connection_)
316 CHECK_EQ(child->connection(), connection_); 316 CHECK_EQ(child->connection(), connection_);
317 for (Window* p = child->parent(); p; p = p->parent()) { 317 for (Window* p = child->parent(); p; p = p->parent()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return nullptr; 351 return nullptr;
352 } 352 }
353 353
354 void Window::SetTextInputState(mojo::TextInputStatePtr state) { 354 void Window::SetTextInputState(mojo::TextInputStatePtr state) {
355 if (connection_) 355 if (connection_)
356 tree_client()->SetWindowTextInputState(id_, std::move(state)); 356 tree_client()->SetWindowTextInputState(id_, std::move(state));
357 } 357 }
358 358
359 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { 359 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) {
360 // SetImeVisibility() shouldn't be used if the window is not editable. 360 // SetImeVisibility() shouldn't be used if the window is not editable.
361 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); 361 DCHECK(state.is_null() || state->type != mojo::TextInputType::NONE);
362 if (connection_) 362 if (connection_)
363 tree_client()->SetImeVisibility(id_, visible, std::move(state)); 363 tree_client()->SetImeVisibility(id_, visible, std::move(state));
364 } 364 }
365 365
366 void Window::SetFocus() { 366 void Window::SetFocus() {
367 if (connection_ && IsDrawn()) 367 if (connection_ && IsDrawn())
368 tree_client()->SetFocus(this); 368 tree_client()->SetFocus(this);
369 } 369 }
370 370
371 bool Window::HasFocus() const { 371 bool Window::HasFocus() const {
372 return connection_ && connection_->GetFocusedWindow() == this; 372 return connection_ && connection_->GetFocusedWindow() == this;
373 } 373 }
374 374
375 void Window::SetCanFocus(bool can_focus) { 375 void Window::SetCanFocus(bool can_focus) {
376 if (connection_) 376 if (connection_)
377 tree_client()->SetCanFocus(id_, can_focus); 377 tree_client()->SetCanFocus(id_, can_focus);
378 } 378 }
379 379
380 void Window::Embed(mus::mojom::WindowTreeClientPtr client) { 380 void Window::Embed(mus::mojom::WindowTreeClientPtr client) {
381 Embed(std::move(client), mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, 381 Embed(std::move(client), mus::mojom::WindowTree::kAccessPolicyDefault,
382 base::Bind(&EmptyEmbedCallback)); 382 base::Bind(&EmptyEmbedCallback));
383 } 383 }
384 384
385 void Window::Embed(mus::mojom::WindowTreeClientPtr client, 385 void Window::Embed(mus::mojom::WindowTreeClientPtr client,
386 uint32_t policy_bitmask, 386 uint32_t policy_bitmask,
387 const EmbedCallback& callback) { 387 const EmbedCallback& callback) {
388 if (PrepareForEmbed()) 388 if (PrepareForEmbed())
389 tree_client()->Embed(id_, std::move(client), policy_bitmask, callback); 389 tree_client()->Embed(id_, std::move(client), policy_bitmask, callback);
390 else 390 else
391 callback.Run(false, 0); 391 callback.Run(false, 0);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 Window::Window(WindowTreeConnection* connection, Id id) 467 Window::Window(WindowTreeConnection* connection, Id id)
468 : connection_(connection), 468 : connection_(connection),
469 id_(id), 469 id_(id),
470 parent_(nullptr), 470 parent_(nullptr),
471 stacking_target_(nullptr), 471 stacking_target_(nullptr),
472 transient_parent_(nullptr), 472 transient_parent_(nullptr),
473 input_event_handler_(nullptr), 473 input_event_handler_(nullptr),
474 viewport_metrics_(CreateEmptyViewportMetrics()), 474 viewport_metrics_(CreateEmptyViewportMetrics()),
475 visible_(false), 475 visible_(false),
476 cursor_id_(mojom::CURSOR_NULL), 476 cursor_id_(mojom::Cursor::CURSOR_NULL),
477 drawn_(false) {} 477 drawn_(false) {}
478 478
479 WindowTreeClientImpl* Window::tree_client() { 479 WindowTreeClientImpl* Window::tree_client() {
480 return static_cast<WindowTreeClientImpl*>(connection_); 480 return static_cast<WindowTreeClientImpl*>(connection_);
481 } 481 }
482 482
483 void Window::SetSharedPropertyInternal(const std::string& name, 483 void Window::SetSharedPropertyInternal(const std::string& name,
484 const std::vector<uint8_t>* value) { 484 const std::vector<uint8_t>* value) {
485 if (!OwnsWindowOrIsRoot(this)) 485 if (!OwnsWindowOrIsRoot(this))
486 return; 486 return;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 window->stacking_target_)) 773 window->stacking_target_))
774 return false; 774 return false;
775 775
776 const size_t child_i = std::find(window->parent_->children_.begin(), 776 const size_t child_i = std::find(window->parent_->children_.begin(),
777 window->parent_->children_.end(), window) - 777 window->parent_->children_.end(), window) -
778 window->parent_->children_.begin(); 778 window->parent_->children_.begin();
779 const size_t target_i = 779 const size_t target_i =
780 std::find(window->parent_->children_.begin(), 780 std::find(window->parent_->children_.begin(),
781 window->parent_->children_.end(), relative) - 781 window->parent_->children_.end(), relative) -
782 window->parent_->children_.begin(); 782 window->parent_->children_.begin();
783 if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || 783 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) ||
784 (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { 784 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) {
785 return false; 785 return false;
786 } 786 }
787 787
788 if (notifier) 788 if (notifier)
789 notifier->NotifyWindowReordering(); 789 notifier->NotifyWindowReordering();
790 790
791 const size_t dest_i = direction == mojom::ORDER_DIRECTION_ABOVE 791 const size_t dest_i = direction == mojom::OrderDirection::ABOVE
792 ? (child_i < target_i ? target_i : target_i + 1) 792 ? (child_i < target_i ? target_i : target_i + 1)
793 : (child_i < target_i ? target_i - 1 : target_i); 793 : (child_i < target_i ? target_i - 1 : target_i);
794 window->parent_->children_.erase(window->parent_->children_.begin() + 794 window->parent_->children_.erase(window->parent_->children_.begin() +
795 child_i); 795 child_i);
796 window->parent_->children_.insert(window->parent_->children_.begin() + dest_i, 796 window->parent_->children_.insert(window->parent_->children_.begin() + dest_i,
797 window); 797 window);
798 798
799 window->NotifyWindowStackingChanged(); 799 window->NotifyWindowStackingChanged();
800 800
801 if (notifier) 801 if (notifier)
802 notifier->NotifyWindowReordered(); 802 notifier->NotifyWindowReordered();
803 803
804 return true; 804 return true;
805 } 805 }
806 806
807 // static 807 // static
808 Window** Window::GetStackingTarget(Window* window) { 808 Window** Window::GetStackingTarget(Window* window) {
809 return &window->stacking_target_; 809 return &window->stacking_target_;
810 } 810 }
811 } // namespace mus 811 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698