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

Side by Side Diff: mojo/services/view_manager/public/cpp/lib/view.cc

Issue 880743002: Plumb ViewportMetrics change notifications around the world and back. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Now without skydb changes Created 5 years, 10 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 "view_manager/public/cpp/view.h" 5 #include "view_manager/public/cpp/view.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 void View::Embed(const String& url, 375 void View::Embed(const String& url,
376 InterfaceRequest<ServiceProvider> services, 376 InterfaceRequest<ServiceProvider> services,
377 ServiceProviderPtr exposed_services) { 377 ServiceProviderPtr exposed_services) {
378 static_cast<ViewManagerClientImpl*>(manager_) 378 static_cast<ViewManagerClientImpl*>(manager_)
379 ->Embed(url, id_, services.Pass(), exposed_services.Pass()); 379 ->Embed(url, id_, services.Pass(), exposed_services.Pass());
380 } 380 }
381 381
382 //////////////////////////////////////////////////////////////////////////////// 382 ////////////////////////////////////////////////////////////////////////////////
383 // View, protected: 383 // View, protected:
384 384
385 namespace {
386
387 ViewportMetricsPtr CreateEmptyViewportMetrics() {
eseidel 2015/01/27 22:46:58 This is unfortunate, but makes it so the caller ne
388 ViewportMetricsPtr metrics = ViewportMetrics::New();
389 metrics->size = Size::New();
390 return metrics;
391 }
392 }
393
385 View::View() 394 View::View()
386 : manager_(NULL), 395 : manager_(NULL),
387 id_(static_cast<Id>(-1)), 396 id_(static_cast<Id>(-1)),
388 parent_(NULL), 397 parent_(NULL),
398 viewport_metrics_(CreateEmptyViewportMetrics()),
389 visible_(true), 399 visible_(true),
390 drawn_(false) { 400 drawn_(false) {
391 } 401 }
392 402
393 View::~View() { 403 View::~View() {
394 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this)); 404 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this));
395 if (parent_) 405 if (parent_)
396 parent_->LocalRemoveChild(this); 406 parent_->LocalRemoveChild(this);
397 407
398 // We may still have children. This can happen if the embedder destroys the 408 // We may still have children. This can happen if the embedder destroys the
(...skipping 19 matching lines...) Expand all
418 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroyed(this)); 428 FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroyed(this));
419 } 429 }
420 430
421 //////////////////////////////////////////////////////////////////////////////// 431 ////////////////////////////////////////////////////////////////////////////////
422 // View, private: 432 // View, private:
423 433
424 View::View(ViewManager* manager, Id id) 434 View::View(ViewManager* manager, Id id)
425 : manager_(manager), 435 : manager_(manager),
426 id_(id), 436 id_(id),
427 parent_(nullptr), 437 parent_(nullptr),
438 viewport_metrics_(CreateEmptyViewportMetrics()),
428 visible_(false), 439 visible_(false),
429 drawn_(false) { 440 drawn_(false) {
430 } 441 }
431 442
432 int64 View::SetLocalPropertyInternal(const void* key, 443 int64 View::SetLocalPropertyInternal(const void* key,
433 const char* name, 444 const char* name,
434 PropertyDeallocator deallocator, 445 PropertyDeallocator deallocator,
435 int64 value, 446 int64 value,
436 int64 default_value) { 447 int64 default_value) {
437 int64 old = GetLocalPropertyInternal(key, default_value); 448 int64 old = GetLocalPropertyInternal(key, default_value);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 void View::LocalSetBounds(const Rect& old_bounds, 493 void View::LocalSetBounds(const Rect& old_bounds,
483 const Rect& new_bounds) { 494 const Rect& new_bounds) {
484 DCHECK(old_bounds.x == bounds_.x); 495 DCHECK(old_bounds.x == bounds_.x);
485 DCHECK(old_bounds.y == bounds_.y); 496 DCHECK(old_bounds.y == bounds_.y);
486 DCHECK(old_bounds.width == bounds_.width); 497 DCHECK(old_bounds.width == bounds_.width);
487 DCHECK(old_bounds.height == bounds_.height); 498 DCHECK(old_bounds.height == bounds_.height);
488 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); 499 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds);
489 bounds_ = new_bounds; 500 bounds_ = new_bounds;
490 } 501 }
491 502
503 void View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics,
504 const ViewportMetrics& new_metrics) {
505 // TODO(eseidel): We could check old_metrics against viewport_metrics_.
eseidel 2015/01/27 22:46:58 I tried, but wasn't able to get them to pass.
506 viewport_metrics_ = new_metrics.Clone();
507 FOR_EACH_OBSERVER(
508 ViewObserver, observers_,
509 OnViewViewportMetricsChanged(this, old_metrics, new_metrics));
510 }
511
492 void View::LocalSetDrawn(bool value) { 512 void View::LocalSetDrawn(bool value) {
493 if (drawn_ == value) 513 if (drawn_ == value)
494 return; 514 return;
495 515
496 // As IsDrawn() is derived from |visible_| and |drawn_|, only send drawn 516 // As IsDrawn() is derived from |visible_| and |drawn_|, only send drawn
497 // notification is the value of IsDrawn() is really changing. 517 // notification is the value of IsDrawn() is really changing.
498 if (IsDrawn() == value) { 518 if (IsDrawn() == value) {
499 drawn_ = value; 519 drawn_ = value;
500 return; 520 return;
501 } 521 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 void View::NotifyViewVisibilityChangedUp(View* target) { 566 void View::NotifyViewVisibilityChangedUp(View* target) {
547 // Start with the parent as we already notified |this| 567 // Start with the parent as we already notified |this|
548 // in NotifyViewVisibilityChangedDown. 568 // in NotifyViewVisibilityChangedDown.
549 for (View* view = parent(); view; view = view->parent()) { 569 for (View* view = parent(); view; view = view->parent()) {
550 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target); 570 bool ret = view->NotifyViewVisibilityChangedAtReceiver(target);
551 DCHECK(ret); 571 DCHECK(ret);
552 } 572 }
553 } 573 }
554 574
555 } // namespace mojo 575 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698