| 
1180 | 1180 |           let tabSize = this.verticalMode ? tabHeight : tabWidth;  | 
1181 | 1181 |           let firstTab = tabs[0];  | 
1182 | 1182 |           let lastTab = tabs.at(-1);  | 
 | 1183 | +          let pinnedTabsStartEdge = this.pinnedDropIndicator[screenAxis];  | 
1183 | 1184 |           let pinnedTabsEndEdge =  | 
1184 | 1185 |             window.windowUtils.getBoundsWithoutFlushing(  | 
1185 | 1186 |               this.pinnedDropIndicator  | 
 | 
1206 | 1207 |             newTranslateX = RTL_UI  | 
1207 | 1208 |               ? Math.min(Math.max(oldTranslateX, lastBound), firstBound)  | 
1208 | 1209 |               : 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;  | 
1211 | 1213 |           }  | 
1212 | 1214 |         }  | 
1213 | 1215 | 
 
  | 
 | 
2688 | 2690 |       // Constrain the range over which the moving tabs can move between the pinned container and last tab  | 
2689 | 2691 |       let firstBound = pinnedTabsStartEdge - firstMovingTabScreen;  | 
2690 | 2692 |       // 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 | + | 
2697 | 2705 |       translate = this.#rtlMode  | 
2698 | 2706 |         ? Math.min(Math.max(translate, lastBound), firstBound)  | 
2699 | 2707 |         : 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 | +      );  | 
2711 | 2717 | 
 
  | 
2712 | 2718 |       for (let item of movingTabs) {  | 
2713 | 2719 |         if (isTabGroupLabel(item)) {  | 
 | 
3113 | 3119 |       }  | 
3114 | 3120 |     }  | 
3115 | 3121 | 
 
  | 
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", "");  | 
3124 | 3163 |         }  | 
3125 |  | -        this.pinnedDropIndicator.setAttribute("visible", "");  | 
3126 |  | -        this.pinnedDropIndicator.setAttribute("interactive", "");  | 
 | 3164 | +      } else if (!inPinnedRange) {  | 
 | 3165 | +        this.pinnedDropIndicator.removeAttribute("interactive");  | 
3127 | 3166 |       }  | 
3128 | 3167 |     }  | 
3129 | 3168 | 
 
  | 
 | 
0 commit comments