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

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: 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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (this.tilePage)
155 this.tilePage.positionTile_(this.index); 155 this.tilePage.positionTile_(this.index);
156 156
157 // Take an appropriate action with the drag clone. 157 // Take an appropriate action with the drag clone.
158 if (this.landedOnTrash) { 158 if (this.landedOnTrash) {
159 this.dragClone.classList.add('deleting'); 159 this.dragClone.classList.add('deleting');
160 } else if (this.tilePage) { 160 } else if (this.tilePage) {
161 if (this.tilePage.selected && e.dataTransfer.dropEffect != 'copy') { 161 // HACK(dbeam): Until we fix dropEffect to the correct behavior it will
csilv 2011/09/13 18:57:24 Change this to a TODO comment instead.
Dan Beam 2011/09/13 22:19:13 Done.
162 // differ on windows - crbug.com/39399. That's why we use the custom
163 // .tilePage.lastDropEffect_ instead of e.dataTransfer.dropEffect.
164 if (this.tilePage.selected && this.tilePage.lastDropEffect_ != 'copy') {
162 // The drag clone can still be hidden from the last drag move event. 165 // The drag clone can still be hidden from the last drag move event.
163 this.dragClone.hidden = false; 166 this.dragClone.hidden = false;
164 // The tile's contents may have moved following the respositioning; 167 // The tile's contents may have moved following the respositioning;
165 // adjust for that. 168 // adjust for that.
166 var contentDiffX = this.dragClone.firstChild.offsetLeft - 169 var contentDiffX = this.dragClone.firstChild.offsetLeft -
167 this.firstChild.offsetLeft; 170 this.firstChild.offsetLeft;
168 var contentDiffY = this.dragClone.firstChild.offsetTop - 171 var contentDiffY = this.dragClone.firstChild.offsetTop -
169 this.firstChild.offsetTop; 172 this.firstChild.offsetTop;
170 this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft - 173 this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft -
171 contentDiffX) + 'px'; 174 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. 923 * @param {Event} e A mouseover event for the drag over.
921 */ 924 */
922 doDragOver: function(e) { 925 doDragOver: function(e) {
923 e.preventDefault(); 926 e.preventDefault();
924 927
925 this.setDropEffect(e.dataTransfer); 928 this.setDropEffect(e.dataTransfer);
926 var newDragIndex = this.getWouldBeIndexForPoint_(e.pageX, e.pageY); 929 var newDragIndex = this.getWouldBeIndexForPoint_(e.pageX, e.pageY);
927 if (newDragIndex < 0 || newDragIndex >= this.tileElements_.length) 930 if (newDragIndex < 0 || newDragIndex >= this.tileElements_.length)
928 newDragIndex = this.dragItemIndex_; 931 newDragIndex = this.dragItemIndex_;
929 this.updateDropIndicator_(newDragIndex); 932 this.updateDropIndicator_(newDragIndex);
933
934 this.lastDropEffect_ = e.dataTransfer.dropEffect;
930 }, 935 },
931 936
932 /** 937 /**
938 * Normalizing dropEffect until all platform's implementations agree. Right
939 * now Windows resets the dropEffect on a 'drop' back to 'copy' (and
940 * disregards the previous state), so we're making a temporary shim to keep
941 * our own state for now based on each dragover.
942 */
943 lastDropEffect_: null,
csilv 2011/09/13 18:57:24 Is it necessary to do this? (ie, wont the default
Dan Beam 2011/09/13 22:19:13 Done.
944
945 /**
933 * Performs all actions necessary when the user completes a drop. 946 * Performs all actions necessary when the user completes a drop.
934 * @param {Event} e A mouseover event for the drag drop. 947 * @param {Event} e A mouseover event for the drag drop.
935 */ 948 */
936 doDrop: function(e) { 949 doDrop: function(e) {
937 e.stopPropagation(); 950 e.stopPropagation();
938 951
939 var index = this.currentDropIndex_; 952 var index = this.currentDropIndex_;
940 // Only change data if this was not a 'null drag'. 953 // Only change data if this was not a 'null drag'.
941 if (!((index == this.dragItemIndex_) && this.withinPageDrag_)) { 954 if (!((index == this.dragItemIndex_) && this.withinPageDrag_)) {
942 var adjustedIndex = this.currentDropIndex_ + 955 var adjustedIndex = this.currentDropIndex_ +
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 setDropEffect: function(dataTransfer) { 1074 setDropEffect: function(dataTransfer) {
1062 assert(false); 1075 assert(false);
1063 }, 1076 },
1064 }; 1077 };
1065 1078
1066 return { 1079 return {
1067 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1080 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1068 TilePage: TilePage, 1081 TilePage: TilePage,
1069 }; 1082 };
1070 }); 1083 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698