diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp
index 45090fcb5a0d09109348f916728d01c589fd9a22..a6a2c5dc614c3ef85384f03938383b0a9025d718 100644
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -350,7 +350,8 @@ class nsDisplaySelectionOverlay final : public nsPaintedDisplayItem {
       nsDisplayListBuilder* aDisplayListBuilder) override;
   NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY)
 
-  static DeviceColor ComputeColorFromSelectionStyle(const ComputedStyle&);
+  static DeviceColor ComputeColorFromSelectionStyle(const ComputedStyle&,
+                                                    const nsIFrame*);
   static DeviceColor ApplyTransparencyIfNecessary(nscolor);
 
  private:
@@ -372,9 +373,9 @@ DeviceColor nsDisplaySelectionOverlay::ApplyTransparencyIfNecessary(
 }
 
 DeviceColor nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(
-    const ComputedStyle& aStyle) {
-  return ApplyTransparencyIfNecessary(
-      aStyle.GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor));
+    const ComputedStyle& aStyle, const nsIFrame* aFrame) {
+  return ApplyTransparencyIfNecessary(aStyle.GetVisitedDependentColor(
+      &nsStyleBackground::mBackgroundColor, aFrame));
 }
 
 void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
@@ -473,7 +474,8 @@ void nsContainerFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
             ComputeHighlightSelectionStyle(sd->mHighlightData.mHighlightName)) {
       aList->AppendNewToTopWithIndex<nsDisplaySelectionOverlay>(
           aBuilder, this, index++,
-          nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style));
+          nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style,
+                                                                    this));
     }
   }
 
@@ -481,7 +483,8 @@ void nsContainerFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
   if (normal) {
     DeviceColor color;
     if (RefPtr<ComputedStyle> style = ComputeSelectionStyle(selectionValue)) {
-      color = nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style);
+      color = nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style,
+                                                                        this);
     } else {
       LookAndFeel::ColorID colorID;
       if (selectionValue == nsISelectionController::SELECTION_ON) {
