@@ -379,7 +379,7 @@ class LinkHintsMode {
379
379
this . stableSortCount = 0 ;
380
380
this . hintMarkers = hintDescriptors . map ( ( desc ) => this . createMarkerFor ( desc ) ) ;
381
381
this . markerMatcher = Settings . get ( "filterLinkHints" ) ? new FilterHints ( ) : new AlphabetHints ( ) ;
382
- this . markerMatcher . fillInMarkers ( this . hintMarkers , this . getNextZIndex . bind ( this ) ) ;
382
+ this . markerMatcher . fillInMarkers ( this . hintMarkers ) ;
383
383
384
384
this . hintMode = new Mode ( ) ;
385
385
this . hintMode . init ( {
@@ -402,11 +402,16 @@ class LinkHintsMode {
402
402
}
403
403
} ) ;
404
404
405
+ this . renderHints ( ) ;
406
+ this . setIndicator ( ) ;
407
+ }
408
+
409
+ renderHints ( ) {
405
410
// Append these markers as top level children instead of as child nodes to the link itself,
406
411
// because some clickable elements cannot contain children, e.g. submit buttons.
407
412
this . hintMarkerContainingDiv = DomUtils . addElementsToPage (
408
413
this . hintMarkers . filter ( ( m ) => m . isLocalMarker ( ) ) . map ( ( m ) => m . element ) ,
409
- { id : "vimiumHintMarkerContainer" , className : "vimiumReset" } ,
414
+ { id : "vimiumHintMarkerContainer" , className : "vimiumReset" }
410
415
) ;
411
416
412
417
// TODO(philc): 2024-03-27 Remove this hasPopoverSupport check once Firefox has popover support.
@@ -431,16 +436,6 @@ class LinkHintsMode {
431
436
this . setIndicator ( ) ;
432
437
}
433
438
434
- // Increments and returns the Z index that should be used for the next hint marker on the page.
435
- getNextZIndex ( ) {
436
- if ( this . currentZIndex == null ) {
437
- // This is the starting z-index value; it produces z-index values which are greater than all
438
- // of the other z-index values used by Vimium.
439
- this . currentZIndex = 2140000000 ;
440
- }
441
- return ++ this . currentZIndex ;
442
- }
443
-
444
439
setOpenLinkMode ( mode , shouldPropagateToOtherFrames ) {
445
440
this . mode = mode ;
446
441
if ( shouldPropagateToOtherFrames == null ) {
@@ -476,7 +471,6 @@ class LinkHintsMode {
476
471
el . style . left = localHint . rect . left + "px" ;
477
472
el . style . top = localHint . rect . top + "px" ;
478
473
// Each hint marker is assigned a different z-index.
479
- el . style . zIndex = this . getNextZIndex ( ) ;
480
474
el . className = "vimiumReset internalVimiumHintMarker vimiumHintMarker" ;
481
475
Object . assign ( marker , {
482
476
element : el ,
@@ -589,7 +583,6 @@ class LinkHintsMode {
589
583
const { linksMatched, userMightOverType } = this . markerMatcher . getMatchingHints (
590
584
this . hintMarkers ,
591
585
tabCount ,
592
- this . getNextZIndex . bind ( this ) ,
593
586
) ;
594
587
if ( linksMatched . length === 0 ) {
595
588
this . deactivateMode ( ) ;
@@ -622,7 +615,6 @@ class LinkHintsMode {
622
615
const localHintMarkers = this . hintMarkers . filter ( ( m ) =>
623
616
m . isLocalMarker ( ) && ( m . element . style . display !== "none" )
624
617
) ;
625
-
626
618
// Fill in the markers' rects, if necessary.
627
619
for ( const marker of localHintMarkers ) {
628
620
if ( marker . markerRect == null ) {
@@ -659,17 +651,16 @@ class LinkHintsMode {
659
651
}
660
652
}
661
653
662
- // Rotate the z-indexes within each stack.
663
- for ( const stack of stacks ) {
654
+ const newMarkers = [ ]
655
+ for ( let stack of stacks ) {
664
656
if ( stack . length > 1 ) {
665
- const zIndexes = stack . map ( ( marker ) => marker . element . style . zIndex ) ;
666
- zIndexes . push ( zIndexes [ 0 ] ) ;
667
- for ( let index = 0 ; index < stack . length ; index ++ ) {
668
- const marker = stack [ index ] ;
669
- marker . element . style . zIndex = zIndexes [ index + 1 ] ;
670
- }
657
+ // Push the last element to the beginning.
658
+ stack = stack . splice ( - 1 , 1 ) . concat ( stack )
671
659
}
660
+ newMarkers . push ( ...stack )
672
661
}
662
+ this . hintMarkers = newMarkers ;
663
+ this . renderHints ( ) ;
673
664
}
674
665
675
666
// When only one hint remains, activate it in the appropriate way. The current frame may or may
@@ -877,7 +868,7 @@ class FilterHints {
877
868
marker . element . innerHTML = spanWrap ( caption ) ;
878
869
}
879
870
880
- fillInMarkers ( hintMarkers , getNextZIndex ) {
871
+ fillInMarkers ( hintMarkers ) {
881
872
for ( const marker of hintMarkers ) {
882
873
if ( marker . isLocalMarker ( ) ) {
883
874
this . renderMarker ( marker ) ;
@@ -886,10 +877,10 @@ class FilterHints {
886
877
887
878
// We use getMatchingHints() here (although we know that all of the hints will match) to get an
888
879
// order on the hints and highlight the first one.
889
- return this . getMatchingHints ( hintMarkers , 0 , getNextZIndex ) ;
880
+ return this . getMatchingHints ( hintMarkers , 0 ) ;
890
881
}
891
882
892
- getMatchingHints ( hintMarkers , tabCount , getNextZIndex ) {
883
+ getMatchingHints ( hintMarkers , tabCount ) {
893
884
// At this point, linkTextKeystrokeQueue and hintKeystrokeQueue have been updated to reflect the
894
885
// latest input. Use them to filter the link hints accordingly.
895
886
const matchString = this . hintKeystrokeQueue . join ( "" ) ;
@@ -910,7 +901,6 @@ class FilterHints {
910
901
911
902
if ( this . activeHintMarker ?. element ) {
912
903
this . activeHintMarker . element . classList . add ( "vimiumActiveHintMarker" ) ;
913
- this . activeHintMarker . element . style . zIndex = getNextZIndex ( ) ;
914
904
}
915
905
916
906
return {
0 commit comments