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

Side by Side Diff: chrome/browser/resources/settings/device_page/layout_behavior.js

Issue 2787923002: [MD settings] small code health changes (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/resources/settings/people_page/sync_page.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * @fileoverview Behavior for handling display layout, specifically 6 * @fileoverview Behavior for handling display layout, specifically
7 * edge snapping and collisions. 7 * edge snapping and collisions.
8 */ 8 */
9 9
10 /** @polymerBehavior */ 10 /** @polymerBehavior */
(...skipping 18 matching lines...) Expand all
29 /** @private {!Map<string, chrome.system.display.DisplayLayout>} */ 29 /** @private {!Map<string, chrome.system.display.DisplayLayout>} */
30 displayLayoutMap_: new Map(), 30 displayLayoutMap_: new Map(),
31 31
32 /** 32 /**
33 * The calculated bounds used for generating the div bounds. 33 * The calculated bounds used for generating the div bounds.
34 * @private {!Map<string, chrome.system.display.Bounds>} 34 * @private {!Map<string, chrome.system.display.Bounds>}
35 */ 35 */
36 calculatedBoundsMap_: new Map(), 36 calculatedBoundsMap_: new Map(),
37 37
38 /** @private {string} */ 38 /** @private {string} */
39 dragLayoutId: '', 39 dragLayoutId_: '',
40 40
41 /** @private {string} */ 41 /** @private {string} */
42 dragParentId_: '', 42 dragParentId_: '',
43 43
44 /** @private {!chrome.system.display.Bounds|undefined} */ 44 /** @private {!chrome.system.display.Bounds|undefined} */
45 dragBounds_: undefined, 45 dragBounds_: undefined,
46 46
47 /** @private {!chrome.system.display.LayoutPosition|undefined} */ 47 /** @private {!chrome.system.display.LayoutPosition|undefined} */
48 dragLayoutPosition_: undefined, 48 dragLayoutPosition_: undefined,
49 49
50 /** 50 /**
51 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays 51 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays
52 * @param {!Array<!chrome.system.display.DisplayLayout>} layouts 52 * @param {!Array<!chrome.system.display.DisplayLayout>} layouts
53 */ 53 */
54 initializeDisplayLayout: function(displays, layouts) { 54 initializeDisplayLayout: function(displays, layouts) {
55 this.dragLayoutId = ''; 55 this.dragLayoutId_ = '';
56 this.dragParentId_ = ''; 56 this.dragParentId_ = '';
57 57
58 this.mirroring = displays.length > 0 && !!displays[0].mirroringSourceId; 58 this.mirroring = displays.length > 0 && !!displays[0].mirroringSourceId;
59 59
60 this.displayBoundsMap_.clear(); 60 this.displayBoundsMap_.clear();
61 for (var i = 0; i < displays.length; ++i) { 61 for (var i = 0; i < displays.length; ++i) {
62 var display = displays[i]; 62 var display = displays[i];
63 this.displayBoundsMap_.set(display.id, display.bounds); 63 this.displayBoundsMap_.set(display.id, display.bounds);
64 } 64 }
65 this.displayLayoutMap_.clear(); 65 this.displayLayoutMap_.clear();
(...skipping 12 matching lines...) Expand all
78 }, 78 },
79 79
80 /** 80 /**
81 * Called when a drag event occurs. Checks collisions and updates the layout. 81 * Called when a drag event occurs. Checks collisions and updates the layout.
82 * @param {string} id 82 * @param {string} id
83 * @param {!chrome.system.display.Bounds} newBounds The new calculated 83 * @param {!chrome.system.display.Bounds} newBounds The new calculated
84 * bounds for the display. 84 * bounds for the display.
85 * @return {!chrome.system.display.Bounds} 85 * @return {!chrome.system.display.Bounds}
86 */ 86 */
87 updateDisplayBounds: function(id, newBounds) { 87 updateDisplayBounds: function(id, newBounds) {
88 this.dragLayoutId = id; 88 this.dragLayoutId_ = id;
89 89
90 // Find the closest parent. 90 // Find the closest parent.
91 var closestId = this.findClosest_(id, newBounds); 91 var closestId = this.findClosest_(id, newBounds);
92 assert(closestId); 92 assert(closestId);
93 93
94 // Find the closest edge. 94 // Find the closest edge.
95 var closestBounds = this.getCalculatedDisplayBounds(closestId); 95 var closestBounds = this.getCalculatedDisplayBounds(closestId);
96 var layoutPosition = 96 var layoutPosition =
97 this.getLayoutPositionForBounds_(newBounds, closestBounds); 97 this.getLayoutPositionForBounds_(newBounds, closestBounds);
98 98
(...skipping 28 matching lines...) Expand all
127 127
128 return newBounds; 128 return newBounds;
129 }, 129 },
130 130
131 /** 131 /**
132 * Called when dragging ends. Sends the updated layout to chrome. 132 * Called when dragging ends. Sends the updated layout to chrome.
133 * @param {string} id 133 * @param {string} id
134 */ 134 */
135 finishUpdateDisplayBounds: function(id) { 135 finishUpdateDisplayBounds: function(id) {
136 this.highlightEdge_('', undefined); // Remove any highlights. 136 this.highlightEdge_('', undefined); // Remove any highlights.
137 if (id != this.dragLayoutId || !this.dragBounds_ || 137 if (id != this.dragLayoutId_ || !this.dragBounds_ ||
138 !this.dragLayoutPosition_) { 138 !this.dragLayoutPosition_) {
139 return; 139 return;
140 } 140 }
141 141
142 var layout = this.displayLayoutMap_.get(id); 142 var layout = this.displayLayoutMap_.get(id);
143 143
144 var orphanIds; 144 var orphanIds;
145 if (!layout || layout.parentId == '') { 145 if (!layout || layout.parentId == '') {
146 // Primary display. Set the calculated position to |dragBounds_|. 146 // Primary display. Set the calculated position to |dragBounds_|.
147 this.setCalculatedDisplayBounds_(id, this.dragBounds_); 147 this.setCalculatedDisplayBounds_(id, this.dragBounds_);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 highlight == chrome.system.display.LayoutPosition.LEFT); 705 highlight == chrome.system.display.LayoutPosition.LEFT);
706 div.classList.toggle( 706 div.classList.toggle(
707 'highlight-top', 707 'highlight-top',
708 highlight == chrome.system.display.LayoutPosition.TOP); 708 highlight == chrome.system.display.LayoutPosition.TOP);
709 div.classList.toggle( 709 div.classList.toggle(
710 'highlight-bottom', 710 'highlight-bottom',
711 highlight == chrome.system.display.LayoutPosition.BOTTOM); 711 highlight == chrome.system.display.LayoutPosition.BOTTOM);
712 } 712 }
713 }, 713 },
714 }; 714 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/people_page/sync_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698