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

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: rebase 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void Window::Reorder(Window* relative, mojom::OrderDirection direction) { 301 void Window::Reorder(Window* relative, mojom::OrderDirection direction) {
302 if (!LocalReorder(relative, direction)) 302 if (!LocalReorder(relative, direction))
303 return; 303 return;
304 if (connection_) 304 if (connection_)
305 tree_client()->Reorder(this, relative->id(), direction); 305 tree_client()->Reorder(this, relative->id(), direction);
306 } 306 }
307 307
308 void Window::MoveToFront() { 308 void Window::MoveToFront() {
309 if (!parent_ || parent_->children_.back() == this) 309 if (!parent_ || parent_->children_.back() == this)
310 return; 310 return;
311 Reorder(parent_->children_.back(), mojom::ORDER_DIRECTION_ABOVE); 311 Reorder(parent_->children_.back(), mojom::OrderDirection::ABOVE);
312 } 312 }
313 313
314 void Window::MoveToBack() { 314 void Window::MoveToBack() {
315 if (!parent_ || parent_->children_.front() == this) 315 if (!parent_ || parent_->children_.front() == this)
316 return; 316 return;
317 Reorder(parent_->children_.front(), mojom::ORDER_DIRECTION_BELOW); 317 Reorder(parent_->children_.front(), mojom::OrderDirection::BELOW);
318 } 318 }
319 319
320 bool Window::Contains(Window* child) const { 320 bool Window::Contains(Window* child) const {
321 if (!child) 321 if (!child)
322 return false; 322 return false;
323 if (child == this) 323 if (child == this)
324 return true; 324 return true;
325 if (connection_) 325 if (connection_)
326 CHECK_EQ(child->connection(), connection_); 326 CHECK_EQ(child->connection(), connection_);
327 for (Window* p = child->parent(); p; p = p->parent()) { 327 for (Window* p = child->parent(); p; p = p->parent()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return nullptr; 361 return nullptr;
362 } 362 }
363 363
364 void Window::SetTextInputState(mojo::TextInputStatePtr state) { 364 void Window::SetTextInputState(mojo::TextInputStatePtr state) {
365 if (connection_) 365 if (connection_)
366 tree_client()->SetWindowTextInputState(id_, std::move(state)); 366 tree_client()->SetWindowTextInputState(id_, std::move(state));
367 } 367 }
368 368
369 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { 369 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) {
370 // SetImeVisibility() shouldn't be used if the window is not editable. 370 // SetImeVisibility() shouldn't be used if the window is not editable.
371 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); 371 DCHECK(state.is_null() || state->type != mojo::TextInputType::NONE);
372 if (connection_) 372 if (connection_)
373 tree_client()->SetImeVisibility(id_, visible, std::move(state)); 373 tree_client()->SetImeVisibility(id_, visible, std::move(state));
374 } 374 }
375 375
376 void Window::SetFocus() { 376 void Window::SetFocus() {
377 if (connection_ && IsDrawn()) 377 if (connection_ && IsDrawn())
378 tree_client()->SetFocus(this); 378 tree_client()->SetFocus(this);
379 } 379 }
380 380
381 bool Window::HasFocus() const { 381 bool Window::HasFocus() const {
382 return connection_ && connection_->GetFocusedWindow() == this; 382 return connection_ && connection_->GetFocusedWindow() == this;
383 } 383 }
384 384
385 void Window::SetCanFocus(bool can_focus) { 385 void Window::SetCanFocus(bool can_focus) {
386 if (connection_) 386 if (connection_)
387 tree_client()->SetCanFocus(id_, can_focus); 387 tree_client()->SetCanFocus(id_, can_focus);
388 } 388 }
389 389
390 void Window::Embed(mus::mojom::WindowTreeClientPtr client) { 390 void Window::Embed(mus::mojom::WindowTreeClientPtr client) {
391 Embed(std::move(client), mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT, 391 Embed(std::move(client), mus::mojom::WindowTree::kAccessPolicyDefault,
392 base::Bind(&EmptyEmbedCallback)); 392 base::Bind(&EmptyEmbedCallback));
393 } 393 }
394 394
395 void Window::Embed(mus::mojom::WindowTreeClientPtr client, 395 void Window::Embed(mus::mojom::WindowTreeClientPtr client,
396 uint32_t policy_bitmask, 396 uint32_t policy_bitmask,
397 const EmbedCallback& callback) { 397 const EmbedCallback& callback) {
398 if (PrepareForEmbed()) 398 if (PrepareForEmbed())
399 tree_client()->Embed(id_, std::move(client), policy_bitmask, callback); 399 tree_client()->Embed(id_, std::move(client), policy_bitmask, callback);
400 else 400 else
401 callback.Run(false, 0); 401 callback.Run(false, 0);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 Window::Window(WindowTreeConnection* connection, Id id) 477 Window::Window(WindowTreeConnection* connection, Id id)
478 : connection_(connection), 478 : connection_(connection),
479 id_(id), 479 id_(id),
480 parent_(nullptr), 480 parent_(nullptr),
481 stacking_target_(nullptr), 481 stacking_target_(nullptr),
482 transient_parent_(nullptr), 482 transient_parent_(nullptr),
483 input_event_handler_(nullptr), 483 input_event_handler_(nullptr),
484 viewport_metrics_(CreateEmptyViewportMetrics()), 484 viewport_metrics_(CreateEmptyViewportMetrics()),
485 visible_(false), 485 visible_(false),
486 cursor_id_(mojom::CURSOR_NULL), 486 cursor_id_(mojom::Cursor::CURSOR_NULL),
487 drawn_(false) {} 487 drawn_(false) {}
488 488
489 WindowTreeClientImpl* Window::tree_client() { 489 WindowTreeClientImpl* Window::tree_client() {
490 return static_cast<WindowTreeClientImpl*>(connection_); 490 return static_cast<WindowTreeClientImpl*>(connection_);
491 } 491 }
492 492
493 void Window::SetSharedPropertyInternal(const std::string& name, 493 void Window::SetSharedPropertyInternal(const std::string& name,
494 const std::vector<uint8_t>* value) { 494 const std::vector<uint8_t>* value) {
495 if (!OwnsWindowOrIsRoot(this)) 495 if (!OwnsWindowOrIsRoot(this))
496 return; 496 return;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 window->stacking_target_)) 784 window->stacking_target_))
785 return false; 785 return false;
786 786
787 const size_t child_i = std::find(window->parent_->children_.begin(), 787 const size_t child_i = std::find(window->parent_->children_.begin(),
788 window->parent_->children_.end(), window) - 788 window->parent_->children_.end(), window) -
789 window->parent_->children_.begin(); 789 window->parent_->children_.begin();
790 const size_t target_i = 790 const size_t target_i =
791 std::find(window->parent_->children_.begin(), 791 std::find(window->parent_->children_.begin(),
792 window->parent_->children_.end(), relative) - 792 window->parent_->children_.end(), relative) -
793 window->parent_->children_.begin(); 793 window->parent_->children_.begin();
794 if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || 794 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) ||
795 (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { 795 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) {
796 return false; 796 return false;
797 } 797 }
798 798
799 if (notifier) 799 if (notifier)
800 notifier->NotifyWindowReordering(); 800 notifier->NotifyWindowReordering();
801 801
802 const size_t dest_i = direction == mojom::ORDER_DIRECTION_ABOVE 802 const size_t dest_i = direction == mojom::OrderDirection::ABOVE
803 ? (child_i < target_i ? target_i : target_i + 1) 803 ? (child_i < target_i ? target_i : target_i + 1)
804 : (child_i < target_i ? target_i - 1 : target_i); 804 : (child_i < target_i ? target_i - 1 : target_i);
805 window->parent_->children_.erase(window->parent_->children_.begin() + 805 window->parent_->children_.erase(window->parent_->children_.begin() +
806 child_i); 806 child_i);
807 window->parent_->children_.insert(window->parent_->children_.begin() + dest_i, 807 window->parent_->children_.insert(window->parent_->children_.begin() + dest_i,
808 window); 808 window);
809 809
810 window->NotifyWindowStackingChanged(); 810 window->NotifyWindowStackingChanged();
811 811
812 if (notifier) 812 if (notifier)
813 notifier->NotifyWindowReordered(); 813 notifier->NotifyWindowReordered();
814 814
815 return true; 815 return true;
816 } 816 }
817 817
818 // static 818 // static
819 Window** Window::GetStackingTarget(Window* window) { 819 Window** Window::GetStackingTarget(Window* window) {
820 return &window->stacking_target_; 820 return &window->stacking_target_;
821 } 821 }
822 } // namespace mus 822 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/in_flight_change.h ('k') | components/mus/public/cpp/lib/window_tree_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698