Skip to content

Commit

Permalink
Bug 1923651 - implement "move group to new window" in tabgroup edit m…
Browse files Browse the repository at this point in the history
…enu. r=dao,tabbrowser-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D226325

UltraBlame original commit: bcfcf33d929969655a57da5176bc247c4c9ba982
  • Loading branch information
marco-c committed Nov 1, 2024
1 parent d8324e4 commit 845fac6
Show file tree
Hide file tree
Showing 4 changed files with 916 additions and 12 deletions.
292 changes: 291 additions & 1 deletion browser/components/tabbrowser/content/tabbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16162,6 +16162,9 @@ addTabGroup
(
tabs
{
id
=
null
color
=
null
Expand Down Expand Up @@ -16218,7 +16221,12 @@ tabGroupMenu
nextUnusedColor
;
}
let
if
(
!
id
)
{
id
=
{
Expand All @@ -16244,6 +16252,7 @@ random
)
}
;
}
let
group
=
Expand Down Expand Up @@ -30317,6 +30326,287 @@ return
win
;
}
/
*
*
*
Moves
group
to
a
new
window
.
*
*
param
{
MozTabbrowserTabGroup
}
group
*
The
tab
group
to
move
.
*
/
replaceGroupWithWindow
(
group
)
{
/
/
The
first
tab
added
to
the
new
window
will
be
selected
.
/
/
If
a
tab
in
the
group
is
selected
adopt
it
first
.
let
selectedIndex
=
group
.
tabs
.
indexOf
(
gBrowser
.
selectedTab
)
;
if
(
selectedIndex
<
0
)
{
/
/
Otherwise
we
'
ll
first
adopt
the
first
tab
in
the
group
selectedIndex
=
0
;
}
let
firstTab
=
group
.
tabs
[
selectedIndex
]
;
let
newWindow
=
this
.
replaceTabWithWindow
(
firstTab
)
;
newWindow
.
addEventListener
(
"
before
-
initial
-
tab
-
adopted
"
(
)
=
>
{
let
tabsToGroup
=
group
.
tabs
.
map
(
(
tab
i
)
=
>
{
/
/
addtabGroup
will
handle
adopting
the
other
tabs
but
we
already
/
/
started
adopting
the
tab
at
selectedIndex
so
we
need
to
swap
/
/
the
old
tab
out
for
the
new
one
.
if
(
i
=
=
selectedIndex
)
{
return
newWindow
.
gBrowser
.
visibleTabs
[
0
]
;
}
return
tab
;
}
)
;
/
/
The
initial
tab
isn
'
t
fully
adopted
yet
but
the
tab
object
has
been
/
/
instantiated
so
we
can
make
a
group
now
.
newWindow
.
gBrowser
.
addTabGroup
(
tabsToGroup
{
color
:
group
.
color
label
:
group
.
label
id
:
group
.
id
}
)
;
}
{
once
:
true
}
)
;
return
newWindow
;
}
_updateTabsAfterInsert
(
)
Expand Down
Loading

0 comments on commit 845fac6

Please sign in to comment.