Skip to content

Commit baccd9e

Browse files
committed
Bug 1978083 - Increase pinned tab interaction cue size and display when within a pinned tab's distance r=desktop-theme-reviewers,tabbrowser-reviewers,dao
- show the pinned tab interaction cue earlier - within a pinned tab's width distance of the edge of the tab strip - increase the height of the interaction cue so that the outline is more visible underneath the dragged tab - double the width of the interaction cue so that it is more visible under dragged tabs Differential Revision: https://phabricator.services.mozilla.com/D257861
1 parent fb9addd commit baccd9e

File tree

2 files changed

+72
-33
lines changed
  • browser

2 files changed

+72
-33
lines changed

browser/components/tabbrowser/content/tabs.js

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@
11801180
let tabSize = this.verticalMode ? tabHeight : tabWidth;
11811181
let firstTab = tabs[0];
11821182
let lastTab = tabs.at(-1);
1183+
let pinnedTabsStartEdge = this.pinnedDropIndicator[screenAxis];
11831184
let pinnedTabsEndEdge =
11841185
window.windowUtils.getBoundsWithoutFlushing(
11851186
this.pinnedDropIndicator
@@ -1206,8 +1207,9 @@
12061207
newTranslateX = RTL_UI
12071208
? Math.min(Math.max(oldTranslateX, lastBound), firstBound)
12081209
: Math.min(Math.max(oldTranslateX, firstBound), lastBound);
1209-
withinPinnedBounds =
1210-
firstMovingTabScreen + oldTranslateX <= pinnedTabsEndEdge;
1210+
withinPinnedBounds = RTL_UI
1211+
? lastMovingTabScreen + oldTranslateX >= pinnedTabsStartEdge
1212+
: firstMovingTabScreen + oldTranslateX <= pinnedTabsEndEdge;
12111213
}
12121214
}
12131215

@@ -2688,26 +2690,30 @@
26882690
// Constrain the range over which the moving tabs can move between the pinned container and last tab
26892691
let firstBound = pinnedTabsStartEdge - firstMovingTabScreen;
26902692
// Use periphery when the lastBound would otherwise be the dragged tab.
2691-
let lastBound =
2692-
!numPinned && lastTab == draggedTab
2693-
? periphery[screenAxis] -
2694-
lastMovingTabScreen +
2695-
bounds(draggedTab)[size]
2696-
: endEdge(lastTab) - lastMovingTabScreen;
2693+
let lastBound;
2694+
if (!numPinned && lastTab == draggedTab) {
2695+
lastBound =
2696+
periphery[screenAxis] -
2697+
lastMovingTabScreen +
2698+
// Use periphery width only in horizontal rtl mode since we are moving the other direction.
2699+
// (tab width results in a bounds that falls short, whilst periphery width is accurate)
2700+
(this.#rtlMode ? bounds(periphery).width : bounds(draggedTab)[size]);
2701+
} else {
2702+
lastBound = endEdge(lastTab) - lastMovingTabScreen;
2703+
}
2704+
26972705
translate = this.#rtlMode
26982706
? Math.min(Math.max(translate, lastBound), firstBound)
26992707
: Math.min(Math.max(translate, firstBound), lastBound);
2700-
if (
2701-
isTab(draggedTab) &&
2702-
((!this.#rtlMode &&
2703-
firstMovingTabScreen + translate <= pinnedTabsEndEdge) ||
2704-
(this.#rtlMode &&
2705-
lastMovingTabScreen + translate >= pinnedTabsStartEdge))
2706-
) {
2707-
this.#onDragIntoPinnedContainer();
2708-
} else {
2709-
this.pinnedDropIndicator.removeAttribute("interactive");
2710-
}
2708+
2709+
this.#checkWithinPinnedContainerBounds(
2710+
firstMovingTabScreen,
2711+
lastMovingTabScreen,
2712+
pinnedTabsStartEdge,
2713+
pinnedTabsEndEdge,
2714+
translate,
2715+
draggedTab
2716+
);
27112717

27122718
for (let item of movingTabs) {
27132719
if (isTabGroupLabel(item)) {
@@ -3113,17 +3119,50 @@
31133119
}
31143120
}
31153121

3116-
#onDragIntoPinnedContainer() {
3117-
if (!gBrowser.pinnedTabCount) {
3118-
let tabbrowserTabsRect =
3119-
window.windowUtils.getBoundsWithoutFlushing(this);
3120-
if (!this.verticalMode) {
3121-
// The tabbrowser container expands with the expansion of the
3122-
// drop indicator - prevent that by setting maxWidth first.
3123-
this.style.maxWidth = tabbrowserTabsRect.width + "px";
3122+
#checkWithinPinnedContainerBounds(
3123+
firstMovingTabScreen,
3124+
lastMovingTabScreen,
3125+
pinnedTabsStartEdge,
3126+
pinnedTabsEndEdge,
3127+
translate,
3128+
draggedTab
3129+
) {
3130+
// Display the pinned drop indicator based on the position of the moving tabs
3131+
// If the indicator is not yet shown, display once we are within a pinned tab width/height
3132+
// distance
3133+
let firstMovingTabPosition = firstMovingTabScreen + translate;
3134+
let lastMovingTabPosition = lastMovingTabScreen + translate;
3135+
// Approximation of pinned tabs width and height in horizontal or grid mode (40) is sufficient
3136+
// distance to display the pinned drop indicator slightly before dragging over it. Exact
3137+
// value is not necessary.
3138+
let pinnedTabSize = 40;
3139+
let inPinnedRange = this.#rtlMode
3140+
? lastMovingTabPosition >= pinnedTabsStartEdge
3141+
: firstMovingTabPosition <= pinnedTabsEndEdge;
3142+
let inVisibleRange = this.#rtlMode
3143+
? lastMovingTabPosition >= pinnedTabsStartEdge - pinnedTabSize
3144+
: firstMovingTabPosition <= pinnedTabsEndEdge + pinnedTabSize;
3145+
if (
3146+
isTab(draggedTab) &&
3147+
((inVisibleRange &&
3148+
!this.pinnedDropIndicator.hasAttribute("visible")) ||
3149+
(inPinnedRange &&
3150+
!this.pinnedDropIndicator.hasAttribute("interactive")))
3151+
) {
3152+
// On drag into pinned container
3153+
if (!gBrowser.pinnedTabCount) {
3154+
let tabbrowserTabsRect =
3155+
window.windowUtils.getBoundsWithoutFlushing(this);
3156+
if (!this.verticalMode) {
3157+
// The tabbrowser container expands with the expansion of the
3158+
// drop indicator - prevent that by setting maxWidth first.
3159+
this.style.maxWidth = tabbrowserTabsRect.width + "px";
3160+
}
3161+
this.pinnedDropIndicator.setAttribute("visible", "");
3162+
this.pinnedDropIndicator.setAttribute("interactive", "");
31243163
}
3125-
this.pinnedDropIndicator.setAttribute("visible", "");
3126-
this.pinnedDropIndicator.setAttribute("interactive", "");
3164+
} else if (!inPinnedRange) {
3165+
this.pinnedDropIndicator.removeAttribute("interactive");
31273166
}
31283167
}
31293168

browser/themes/shared/tabbrowser/tabs.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,6 @@
957957

958958
&[visible] {
959959
display: flex;
960-
align-items: center;
961-
justify-content: center;
962960
border-radius: var(--border-radius-small);
963961
background: color-mix(in srgb, currentColor 12%, transparent);
964962

@@ -1018,8 +1016,10 @@
10181016
&[visible] {
10191017
margin-inline: var(--space-small);
10201018
align-self: center;
1021-
width: var(--size-item-large);
1022-
height: var(--size-item-large);
1019+
align-items: flex-start;
1020+
width: calc(2 * var(--size-item-large));
1021+
height: var(--tab-min-height);
1022+
padding-inline-start: var(--space-small);
10231023

10241024
> #pinned-drop-indicator-text {
10251025
display: none;

0 commit comments

Comments
 (0)