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

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

Issue 2522103002: MD Settings: Display: Fix runtime error (Closed)
Patch Set: Move test to display_layout.js Created 4 years 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 /** 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 }, 75 },
76 76
77 /** 77 /**
78 * Called when a drag event occurs. Checks collisions and updates the layout. 78 * Called when a drag event occurs. Checks collisions and updates the layout.
79 * @param {string} id 79 * @param {string} id
80 * @param {!chrome.system.display.Bounds} newBounds The new calculated 80 * @param {!chrome.system.display.Bounds} newBounds The new calculated
81 * bounds for the display. 81 * bounds for the display.
82 * @return {!chrome.system.display.Bounds} 82 * @return {!chrome.system.display.Bounds}
83 */ 83 */
84 updateDisplayBounds(id, newBounds) { 84 updateDisplayBounds: function(id, newBounds) {
85 this.dragLayoutId = id; 85 this.dragLayoutId = id;
86 86
87 // Find the closest parent. 87 // Find the closest parent.
88 var closestId = this.findClosest_(id, newBounds); 88 var closestId = this.findClosest_(id, newBounds);
dpapad 2016/11/23 18:18:43 Nit (optional): var closestId = assert(this.findCl
stevenjb 2016/11/23 18:44:32 Personal nit: I'm not a huge fan of wrapping essen
Dan Beam 2016/11/23 20:46:55 JS != C++
89 assert(closestId);
89 90
90 // Find the closest edge. 91 // Find the closest edge.
91 var closestBounds = this.getCalculatedDisplayBounds(closestId); 92 var closestBounds = this.getCalculatedDisplayBounds(closestId);
92 var layoutPosition = 93 var layoutPosition =
93 this.getLayoutPositionForBounds_(newBounds, closestBounds); 94 this.getLayoutPositionForBounds_(newBounds, closestBounds);
94 95
95 // Snap to the closest edge. 96 // Snap to the closest edge.
96 var snapPos = this.snapBounds_(newBounds, closestId, layoutPosition); 97 var snapPos = this.snapBounds_(newBounds, closestId, layoutPosition);
97 newBounds.left = snapPos.x; 98 newBounds.left = snapPos.x;
98 newBounds.top = snapPos.y; 99 newBounds.top = snapPos.y;
(...skipping 22 matching lines...) Expand all
121 122
122 this.dragBounds_ = newBounds; 123 this.dragBounds_ = newBounds;
123 124
124 return newBounds; 125 return newBounds;
125 }, 126 },
126 127
127 /** 128 /**
128 * Called when dragging ends. Sends the updated layout to chrome. 129 * Called when dragging ends. Sends the updated layout to chrome.
129 * @param {string} id 130 * @param {string} id
130 */ 131 */
131 finishUpdateDisplayBounds(id) { 132 finishUpdateDisplayBounds: function(id) {
132 this.highlightEdge_('', undefined); // Remove any highlights. 133 this.highlightEdge_('', undefined); // Remove any highlights.
133 if (id != this.dragLayoutId || !this.dragBounds_ || 134 if (id != this.dragLayoutId || !this.dragBounds_ ||
134 !this.dragLayoutPosition_) { 135 !this.dragLayoutPosition_) {
135 return; 136 return;
136 } 137 }
137 138
138 var layout = this.displayLayoutMap_.get(id); 139 var layout = this.displayLayoutMap_.get(id);
139 140
140 var orphanIds; 141 var orphanIds;
141 if (!layout || layout.parentId == '') { 142 if (!layout || layout.parentId == '') {
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 highlight == chrome.system.display.LayoutPosition.LEFT); 699 highlight == chrome.system.display.LayoutPosition.LEFT);
699 div.classList.toggle( 700 div.classList.toggle(
700 'highlight-top', 701 'highlight-top',
701 highlight == chrome.system.display.LayoutPosition.TOP); 702 highlight == chrome.system.display.LayoutPosition.TOP);
702 div.classList.toggle( 703 div.classList.toggle(
703 'highlight-bottom', 704 'highlight-bottom',
704 highlight == chrome.system.display.LayoutPosition.BOTTOM); 705 highlight == chrome.system.display.LayoutPosition.BOTTOM);
705 } 706 }
706 }, 707 },
707 }; 708 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698