diff --git a/closure/goog/deps.js b/closure/goog/deps.js index a08dc3a144..680f5f67ad 100644 --- a/closure/goog/deps.js +++ b/closure/goog/deps.js @@ -414,7 +414,7 @@ goog.addDependency('fs/url_test.js', ['goog.urlTest'], ['goog.fs.url', 'goog.tes goog.addDependency('functions/functions.js', ['goog.functions'], [], false); goog.addDependency('functions/functions_test.js', ['goog.functionsTest'], ['goog.array', 'goog.functions', 'goog.testing.MockClock', 'goog.testing.PropertyReplacer', 'goog.testing.jsunit', 'goog.testing.recordFunction'], false); goog.addDependency('fx/abstractdragdrop.js', ['goog.fx.AbstractDragDrop', 'goog.fx.AbstractDragDrop.EventType', 'goog.fx.DragDropEvent', 'goog.fx.DragDropItem'], ['goog.asserts', 'goog.dom', 'goog.dom.classlist', 'goog.events', 'goog.events.Event', 'goog.events.EventHandler', 'goog.events.EventTarget', 'goog.events.EventType', 'goog.fx.Dragger', 'goog.math.Box', 'goog.math.Coordinate', 'goog.style'], false); -goog.addDependency('fx/abstractdragdrop_test.js', ['goog.fx.AbstractDragDropTest'], ['goog.array', 'goog.dom.TagName', 'goog.events', 'goog.events.EventType', 'goog.functions', 'goog.fx.AbstractDragDrop', 'goog.fx.DragDropItem', 'goog.math.Box', 'goog.math.Coordinate', 'goog.style', 'goog.testing.events', 'goog.testing.jsunit'], false); +goog.addDependency('fx/abstractdragdrop_test.js', ['goog.fx.AbstractDragDropTest'], ['goog.array', 'goog.dom.TagName', 'goog.events', 'goog.events.EventType', 'goog.functions', 'goog.fx.AbstractDragDrop', 'goog.fx.DragDropItem', 'goog.math.Box', 'goog.math.Coordinate', 'goog.style', 'goog.testing.events', 'goog.testing.events.Event', 'goog.testing.jsunit'], false); goog.addDependency('fx/anim/anim.js', ['goog.fx.anim', 'goog.fx.anim.Animated'], ['goog.async.AnimationDelay', 'goog.async.Delay', 'goog.object'], false); goog.addDependency('fx/anim/anim_test.js', ['goog.fx.animTest'], ['goog.async.AnimationDelay', 'goog.async.Delay', 'goog.events', 'goog.functions', 'goog.fx.Animation', 'goog.fx.anim', 'goog.object', 'goog.testing.MockClock', 'goog.testing.PropertyReplacer', 'goog.testing.jsunit', 'goog.testing.recordFunction', 'goog.userAgent'], false); goog.addDependency('fx/animation.js', ['goog.fx.Animation', 'goog.fx.Animation.EventType', 'goog.fx.Animation.State', 'goog.fx.AnimationEvent'], ['goog.array', 'goog.events.Event', 'goog.fx.Transition', 'goog.fx.TransitionBase', 'goog.fx.anim', 'goog.fx.anim.Animated'], false); diff --git a/closure/goog/fx/abstractdragdrop.js b/closure/goog/fx/abstractdragdrop.js index b77ecfa997..5108ec71c2 100644 --- a/closure/goog/fx/abstractdragdrop.js +++ b/closure/goog/fx/abstractdragdrop.js @@ -1404,8 +1404,6 @@ goog.fx.DragDropItem.prototype.maybeStartDrag_ = function(event, element) { this.startPosition_ = new goog.math.Coordinate( event.clientX, event.clientY); - - event.preventDefault(); }; @@ -1432,6 +1430,9 @@ goog.fx.DragDropItem.prototype.mouseMove_ = function(event) { this.eventHandler_.removeAll(); this.parent_.startDrag(event, this); } + + // Prevent text selection while dragging an element. + event.preventDefault(); }; diff --git a/closure/goog/fx/abstractdragdrop_test.js b/closure/goog/fx/abstractdragdrop_test.js index 37f5254ca7..97b4a230da 100644 --- a/closure/goog/fx/abstractdragdrop_test.js +++ b/closure/goog/fx/abstractdragdrop_test.js @@ -26,6 +26,7 @@ goog.require('goog.math.Box'); goog.require('goog.math.Coordinate'); goog.require('goog.style'); goog.require('goog.testing.events'); +goog.require('goog.testing.events.Event'); goog.require('goog.testing.jsunit'); var targets = [ @@ -507,6 +508,22 @@ function testScrollableContainersCalculation() { assertEquals(container, group.targetList_[1].scrollableContainer_); } +function testMouseDownEventDefaultAction() { + var group = new goog.fx.AbstractDragDrop(); + var target = new goog.fx.AbstractDragDrop(); + group.addTarget(target); + var item1 = new goog.fx.DragDropItem(document.getElementById('child1')); + group.items_.push(item1); + item1.setParent(group); + group.init(); + + var mousedownDefaultPrevented = + !goog.testing.events.fireMouseDownEvent(item1.element); + + assertFalse('Default action of mousedown event should not be cancelled.', + mousedownDefaultPrevented); +} + // See http://b/7494613. function testMouseUpOutsideElement() { var group = new goog.fx.AbstractDragDrop(); @@ -583,14 +600,20 @@ function testMouseMove_mouseOutBeforeThreshold() { draggedItem = item; }; - var event = {'clientX': 8, 'clientY': 10, // Drag distance is only 2 - 'type': goog.events.EventType.MOUSEOUT, 'target': childEl}; + var event = new goog.testing.events.Event(goog.events.EventType.MOUSEOUT, + childEl); + // Drag distance is only 2. + event.clientX = 8; + event.clientY = 10; item.mouseMove_(event); assertEquals('DragStart should not be fired for mouseout on child element.', null, draggedItem); - var event = {'clientX': 8, 'clientY': 10, // Drag distance is only 2 - 'type': goog.events.EventType.MOUSEOUT, 'target': itemEl}; + var event = new goog.testing.events.Event(goog.events.EventType.MOUSEOUT, + itemEl); + // Drag distance is only 2. + event.clientX = 8; + event.clientY = 10; item.mouseMove_(event); assertEquals('DragStart should be fired for mouseout on main element.', item, draggedItem);