зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1355507 - Releasing a tab while dragging through the tabstrip on the same window should show a transition to its final resting place. r=dao
MozReview-Commit-ID: Lb7D1wnifBp --HG-- extra : rebase_source : e0ff3800b5536681afcd79d0e105008049d346ef
This commit is contained in:
Родитель
44c4d43ecf
Коммит
8fef752ced
|
@ -12,6 +12,7 @@
|
|||
--lwt-additional-images: none;
|
||||
--lwt-background-alignment: right top;
|
||||
--lwt-background-tiling: no-repeat;
|
||||
--animation-easing-function: cubic-bezier(.07, .95, 0, 1);
|
||||
}
|
||||
|
||||
:root:-moz-lwtheme {
|
||||
|
@ -193,8 +194,9 @@ tabbrowser {
|
|||
pointer-events: none; /* avoid blocking dragover events on scroll buttons */
|
||||
}
|
||||
|
||||
.tabbrowser-tab[tabdrop-samewindow],
|
||||
.tabbrowser-tabs[movingtab] > .tabbrowser-tab[fadein]:not([selected]) {
|
||||
transition: transform 200ms ease-out;
|
||||
transition: transform 200ms var(--animation-easing-function);
|
||||
}
|
||||
|
||||
.new-tab-popup,
|
||||
|
|
|
@ -6196,6 +6196,7 @@
|
|||
if (rtl)
|
||||
tabs.reverse();
|
||||
let tabWidth = draggedTab.getBoundingClientRect().width;
|
||||
draggedTab._dragData.tabWidth = tabWidth;
|
||||
|
||||
// Move the dragged tab based on the mouse position.
|
||||
|
||||
|
@ -6211,6 +6212,7 @@
|
|||
translateX = Math.max(translateX, leftBound);
|
||||
translateX = Math.min(translateX, rightBound);
|
||||
draggedTab.style.transform = "translateX(" + translateX + "px)";
|
||||
draggedTab._dragData.translateX = translateX;
|
||||
|
||||
// Determine what tab we're dragging over.
|
||||
// * Point of reference is the center of the dragged tab. If that
|
||||
|
@ -6882,14 +6884,42 @@
|
|||
if (draggedTab.parentNode != this || event.shiftKey)
|
||||
this.selectedItem = newTab;
|
||||
} else if (draggedTab && draggedTab.parentNode == this) {
|
||||
this._finishAnimateTabMove();
|
||||
let oldTranslateX = draggedTab._dragData.translateX;
|
||||
let tabWidth = draggedTab._dragData.tabWidth;
|
||||
let translateOffset = oldTranslateX % tabWidth;
|
||||
let newTranslateX = oldTranslateX - translateOffset;
|
||||
if (oldTranslateX > 0 && translateOffset > tabWidth / 2) {
|
||||
newTranslateX += tabWidth;
|
||||
} else if (oldTranslateX < 0 && -translateOffset > tabWidth / 2) {
|
||||
newTranslateX -= tabWidth;
|
||||
}
|
||||
|
||||
// actually move the dragged tab
|
||||
if ("animDropIndex" in draggedTab._dragData) {
|
||||
let newIndex = draggedTab._dragData.animDropIndex;
|
||||
if (newIndex > draggedTab._tPos)
|
||||
newIndex--;
|
||||
this.tabbrowser.moveTabTo(draggedTab, newIndex);
|
||||
let dropIndex = "animDropIndex" in draggedTab._dragData &&
|
||||
draggedTab._dragData.animDropIndex;
|
||||
if (dropIndex && dropIndex > draggedTab._tPos)
|
||||
dropIndex--;
|
||||
|
||||
if (oldTranslateX && oldTranslateX != newTranslateX) {
|
||||
draggedTab.setAttribute("tabdrop-samewindow", "true");
|
||||
draggedTab.style.transform = "translateX(" + newTranslateX + "px)";
|
||||
let onTransitionEnd = transitionendEvent => {
|
||||
if (transitionendEvent.propertyName != "transform" ||
|
||||
transitionendEvent.originalTarget != draggedTab) {
|
||||
return;
|
||||
}
|
||||
draggedTab.removeEventListener("transitionend", onTransitionEnd);
|
||||
|
||||
draggedTab.removeAttribute("tabdrop-samewindow");
|
||||
|
||||
this._finishAnimateTabMove();
|
||||
if (dropIndex !== false)
|
||||
this.tabbrowser.moveTabTo(draggedTab, dropIndex);
|
||||
}
|
||||
draggedTab.addEventListener("transitionend", onTransitionEnd);
|
||||
} else {
|
||||
this._finishAnimateTabMove();
|
||||
if (dropIndex !== false)
|
||||
this.tabbrowser.moveTabTo(draggedTab, dropIndex);
|
||||
}
|
||||
} else if (draggedTab) {
|
||||
let newIndex = this._getDropIndex(event, false);
|
||||
|
@ -6930,14 +6960,17 @@
|
|||
]]></handler>
|
||||
|
||||
<handler event="dragend"><![CDATA[
|
||||
// Note: while this case is correctly handled here, this event
|
||||
// isn't dispatched when the tab is moved within the tabstrip,
|
||||
// see bug 460801.
|
||||
var dt = event.dataTransfer;
|
||||
var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||
|
||||
// Prevent this code from running if a tabdrop animation is
|
||||
// running since calling _finishAnimateTabMove would clear
|
||||
// any CSS transition that is running.
|
||||
if (draggedTab.hasAttribute("tabdrop-samewindow"))
|
||||
return;
|
||||
|
||||
this._finishAnimateTabMove();
|
||||
|
||||
var dt = event.dataTransfer;
|
||||
var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||
if (dt.mozUserCancelled || dt.dropEffect != "none" || this._isCustomizing) {
|
||||
delete draggedTab._dragData;
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
add_task(function*() {
|
||||
let initialTabsLength = gBrowser.tabs.length;
|
||||
|
||||
let newTab1 = gBrowser.selectedTab = gBrowser.addTab("about:robots", {skipAnimation: true});
|
||||
|
@ -23,7 +23,7 @@ function test() {
|
|||
let EventUtils = {};
|
||||
scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
|
||||
|
||||
function dragAndDrop(tab1, tab2, copy) {
|
||||
function* dragAndDrop(tab1, tab2, copy) {
|
||||
let rect = tab2.getBoundingClientRect();
|
||||
let event = {
|
||||
ctrlKey: copy,
|
||||
|
@ -32,18 +32,23 @@ function test() {
|
|||
clientY: rect.top + rect.height / 2,
|
||||
};
|
||||
|
||||
let originalTPos = tab1._tPos;
|
||||
EventUtils.synthesizeDrop(tab1, tab2, null, copy ? "copy" : "move", window, window, event);
|
||||
if (!copy) {
|
||||
yield BrowserTestUtils.waitForCondition(() => tab1._tPos != originalTPos,
|
||||
"Waiting for tab position to be updated");
|
||||
}
|
||||
}
|
||||
|
||||
dragAndDrop(newTab1, newTab2, false);
|
||||
yield dragAndDrop(newTab1, newTab2, false);
|
||||
is(gBrowser.tabs.length, initialTabsLength + 3, "tabs are still there");
|
||||
is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 and newTab1 are swapped");
|
||||
is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 and newTab2 are swapped");
|
||||
is(gBrowser.tabs[initialTabsLength + 2], newTab3, "newTab3 stays same place");
|
||||
|
||||
dragAndDrop(newTab2, newTab1, true);
|
||||
yield dragAndDrop(newTab2, newTab1, true);
|
||||
is(gBrowser.tabs.length, initialTabsLength + 4, "a tab is duplicated");
|
||||
is(gBrowser.tabs[initialTabsLength], newTab2, "newTab2 stays same place");
|
||||
is(gBrowser.tabs[initialTabsLength + 1], newTab1, "newTab1 stays same place");
|
||||
is(gBrowser.tabs[initialTabsLength + 3], newTab3, "a new tab is inserted before newTab3");
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче