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

Side by Side Diff: ui/display/display_layout.cc

Issue 2661663002: Add DisplayPlacement/Layout mojoms + StructTraits. (Closed)
Patch Set: Fixes. Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/display/display_layout.h" 5 #include "ui/display/display_layout.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 DCHECK_GE(kMaxValidOffset, abs(offset)); 346 DCHECK_GE(kMaxValidOffset, abs(offset));
347 } 347 }
348 348
349 DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement) 349 DisplayPlacement::DisplayPlacement(const DisplayPlacement& placement)
350 : display_id(placement.display_id), 350 : display_id(placement.display_id),
351 parent_display_id(placement.parent_display_id), 351 parent_display_id(placement.parent_display_id),
352 position(placement.position), 352 position(placement.position),
353 offset(placement.offset), 353 offset(placement.offset),
354 offset_reference(placement.offset_reference) {} 354 offset_reference(placement.offset_reference) {}
355 355
356 bool DisplayPlacement::operator==(const DisplayPlacement& other) const {
357 return display_id == other.display_id && //
Daniel Erat 2017/02/01 23:06:37 what are all these empty trailing comments for?
kylechar 2017/02/02 14:40:48 Just to keep the statements one per line after run
Daniel Erat 2017/02/02 16:55:13 ah, i didn't know that one could do this (or that
kylechar 2017/02/02 21:17:18 On second though, for consistency with existing co
358 parent_display_id == other.parent_display_id && //
359 position == other.position && //
360 offset == other.offset && //
361 offset_reference == other.offset_reference; //
362 }
363
364 bool DisplayPlacement::operator!=(const DisplayPlacement& other) const {
365 return !operator==(other);
366 }
367
356 DisplayPlacement& DisplayPlacement::Swap() { 368 DisplayPlacement& DisplayPlacement::Swap() {
357 switch (position) { 369 switch (position) {
358 case TOP: 370 case TOP:
359 position = BOTTOM; 371 position = BOTTOM;
360 break; 372 break;
361 case BOTTOM: 373 case BOTTOM:
362 position = TOP; 374 position = TOP;
363 break; 375 break;
364 case RIGHT: 376 case RIGHT:
365 position = LEFT; 377 position = LEFT;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 std::unique_ptr<DisplayLayout> copy(new DisplayLayout); 545 std::unique_ptr<DisplayLayout> copy(new DisplayLayout);
534 for (const auto& placement : placement_list) 546 for (const auto& placement : placement_list)
535 copy->placement_list.push_back(placement); 547 copy->placement_list.push_back(placement);
536 copy->mirrored = mirrored; 548 copy->mirrored = mirrored;
537 copy->default_unified = default_unified; 549 copy->default_unified = default_unified;
538 copy->primary_id = primary_id; 550 copy->primary_id = primary_id;
539 return copy; 551 return copy;
540 } 552 }
541 553
542 bool DisplayLayout::HasSamePlacementList(const DisplayLayout& layout) const { 554 bool DisplayLayout::HasSamePlacementList(const DisplayLayout& layout) const {
543 if (placement_list.size() != layout.placement_list.size()) 555 return placement_list == layout.placement_list;
544 return false;
545 for (size_t index = 0; index < placement_list.size(); index++) {
546 const DisplayPlacement& placement1 = placement_list[index];
547 const DisplayPlacement& placement2 = layout.placement_list[index];
548 if (placement1.position != placement2.position ||
549 placement1.offset != placement2.offset ||
550 placement1.display_id != placement2.display_id ||
551 placement1.parent_display_id != placement2.parent_display_id) {
552 return false;
553 }
554 }
555 return true;
556 } 556 }
557 557
558 std::string DisplayLayout::ToString() const { 558 std::string DisplayLayout::ToString() const {
559 std::stringstream s; 559 std::stringstream s;
560 s << "primary=" << primary_id; 560 s << "primary=" << primary_id;
561 if (mirrored) 561 if (mirrored)
562 s << ", mirrored"; 562 s << ", mirrored";
563 if (default_unified) 563 if (default_unified)
564 s << ", default_unified"; 564 s << ", default_unified";
565 bool added = false; 565 bool added = false;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 gfx::Insets insets = target_display->GetWorkAreaInsets(); 635 gfx::Insets insets = target_display->GetWorkAreaInsets();
636 target_display->set_bounds( 636 target_display->set_bounds(
637 gfx::Rect(new_target_origin, target_bounds.size())); 637 gfx::Rect(new_target_origin, target_bounds.size()));
638 target_display->UpdateWorkAreaFromInsets(insets); 638 target_display->UpdateWorkAreaFromInsets(insets);
639 639
640 return old_bounds != target_display->bounds(); 640 return old_bounds != target_display->bounds();
641 } 641 }
642 642
643 } // namespace display 643 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698