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

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 7889002: Normalizing .dropEffect across platforms (specifically Windows). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: incorporating csilv's changes Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/ntp4/drag_wrapper.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('ntp4', function() { 5 cr.define('ntp4', function() {
6 'use strict'; 6 'use strict';
7 7
8 // We can't pass the currently dragging tile via dataTransfer because of 8 // We can't pass the currently dragging tile via dataTransfer because of
9 // http://crbug.com/31037 9 // http://crbug.com/31037
10 var currentlyDraggingTile = null; 10 var currentlyDraggingTile = null;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 * @param {Event} e The event for the drag. 144 * @param {Event} e The event for the drag.
145 * @private 145 * @private
146 */ 146 */
147 onDragEnd_: function(e) { 147 onDragEnd_: function(e) {
148 this.dragClone.hidden = false; 148 this.dragClone.hidden = false;
149 this.dragClone.classList.add('placing'); 149 this.dragClone.classList.add('placing');
150 150
151 setCurrentlyDraggingTile(null); 151 setCurrentlyDraggingTile(null);
152 152
153 // tilePage will be null if we've already been removed. 153 // tilePage will be null if we've already been removed.
154 if (this.tilePage) 154 var tilePage = this.tilePage;
155 this.tilePage.positionTile_(this.index); 155 if (tilePage)
156 tilePage.positionTile_(this.index);
156 157
157 // Take an appropriate action with the drag clone. 158 // Take an appropriate action with the drag clone.
158 if (this.landedOnTrash) { 159 if (this.landedOnTrash) {
159 this.dragClone.classList.add('deleting'); 160 this.dragClone.classList.add('deleting');
160 } else if (this.tilePage) { 161 } else if (tilePage) {
161 if (this.tilePage.selected && e.dataTransfer.dropEffect != 'copy') { 162 // TODO(dbeam): Until we fix dropEffect to the correct behavior it will
163 // differ on windows - crbug.com/39399. That's why we use the custom
164 // tilePage.lastDropEffect_ instead of e.dataTransfer.dropEffect.
165 if (tilePage.selected && tilePage.lastDropEffect_ != 'copy') {
162 // The drag clone can still be hidden from the last drag move event. 166 // The drag clone can still be hidden from the last drag move event.
163 this.dragClone.hidden = false; 167 this.dragClone.hidden = false;
164 // The tile's contents may have moved following the respositioning; 168 // The tile's contents may have moved following the respositioning;
165 // adjust for that. 169 // adjust for that.
166 var contentDiffX = this.dragClone.firstChild.offsetLeft - 170 var contentDiffX = this.dragClone.firstChild.offsetLeft -
167 this.firstChild.offsetLeft; 171 this.firstChild.offsetLeft;
168 var contentDiffY = this.dragClone.firstChild.offsetTop - 172 var contentDiffY = this.dragClone.firstChild.offsetTop -
169 this.firstChild.offsetTop; 173 this.firstChild.offsetTop;
170 this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft - 174 this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft -
171 contentDiffX) + 'px'; 175 contentDiffX) + 'px';
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 * @param {Event} e A mouseover event for the drag over. 924 * @param {Event} e A mouseover event for the drag over.
921 */ 925 */
922 doDragOver: function(e) { 926 doDragOver: function(e) {
923 e.preventDefault(); 927 e.preventDefault();
924 928
925 this.setDropEffect(e.dataTransfer); 929 this.setDropEffect(e.dataTransfer);
926 var newDragIndex = this.getWouldBeIndexForPoint_(e.pageX, e.pageY); 930 var newDragIndex = this.getWouldBeIndexForPoint_(e.pageX, e.pageY);
927 if (newDragIndex < 0 || newDragIndex >= this.tileElements_.length) 931 if (newDragIndex < 0 || newDragIndex >= this.tileElements_.length)
928 newDragIndex = this.dragItemIndex_; 932 newDragIndex = this.dragItemIndex_;
929 this.updateDropIndicator_(newDragIndex); 933 this.updateDropIndicator_(newDragIndex);
934
935 this.lastDropEffect_ = e.dataTransfer.dropEffect;
930 }, 936 },
931 937
932 /** 938 /**
933 * Performs all actions necessary when the user completes a drop. 939 * Performs all actions necessary when the user completes a drop.
934 * @param {Event} e A mouseover event for the drag drop. 940 * @param {Event} e A mouseover event for the drag drop.
935 */ 941 */
936 doDrop: function(e) { 942 doDrop: function(e) {
937 e.stopPropagation(); 943 e.stopPropagation();
938 944
939 var index = this.currentDropIndex_; 945 var index = this.currentDropIndex_;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 setDropEffect: function(dataTransfer) { 1067 setDropEffect: function(dataTransfer) {
1062 assert(false); 1068 assert(false);
1063 }, 1069 },
1064 }; 1070 };
1065 1071
1066 return { 1072 return {
1067 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1073 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1068 TilePage: TilePage, 1074 TilePage: TilePage,
1069 }; 1075 };
1070 }); 1076 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/drag_wrapper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698