diff --git a/widget/nsNativeBasicTheme.cpp b/widget/nsNativeBasicTheme.cpp index 6cac2bc744d1..9c86ffa03f6c 100644 --- a/widget/nsNativeBasicTheme.cpp +++ b/widget/nsNativeBasicTheme.cpp @@ -107,6 +107,7 @@ static void ComputeCheckColors(const EventStates& aState, bool isPressed = !isDisabled && aState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE); bool isHovered = !isDisabled && aState.HasState(NS_EVENT_STATE_HOVER); + bool isFocused = aState.HasState(NS_EVENT_STATE_FOCUS); bool isChecked = aState.HasState(NS_EVENT_STATE_CHECKED); sRGBColor fillColor = sBackgroundColor; @@ -130,6 +131,9 @@ static void ComputeCheckColors(const EventStates& aState, } else if (isPressed) { fillColor = sBackgroundActiveColor; borderColor = sBorderHoverColor; + } else if (isFocused) { + fillColor = sBackgroundActiveColor; + borderColor = sBorderFocusColor; } else if (isHovered) { fillColor = sBackgroundColor; borderColor = sBorderHoverColor; @@ -298,14 +302,25 @@ static void PaintCheckedRadioButton(DrawTarget* aDrawTarget, const Rect& aRect, aDrawTarget->Fill(ellipse, ColorPattern(ToDeviceColor(sBackgroundColor))); } +static sRGBColor ComputeBorderColor(const EventStates& aState) { + bool isDisabled = aState.HasState(NS_EVENT_STATE_DISABLED); + bool isHovered = !isDisabled && aState.HasState(NS_EVENT_STATE_HOVER); + bool isFocused = aState.HasState(NS_EVENT_STATE_FOCUS); + if (isFocused) { + return sBorderFocusColor; + } + if (isHovered) { + return sBorderHoverColor; + } + return sBorderColor; +} + static void PaintTextField(DrawTarget* aDrawTarget, const Rect& aRect, const EventStates& aState, uint32_t aDpi) { bool isDisabled = aState.HasState(NS_EVENT_STATE_DISABLED); - bool isHovered = !isDisabled && aState.HasState(NS_EVENT_STATE_HOVER); - const sRGBColor& backgroundColor = isDisabled ? sDisabledColor : sBackgroundColor; - const sRGBColor& borderColor = isHovered ? sBorderHoverColor : sBorderColor; + const sRGBColor borderColor = ComputeBorderColor(aState); const CSSCoord kRadius = 4.0f; @@ -336,7 +351,7 @@ std::pair ComputeButtonColors( return sButtonColor; }(); - const sRGBColor& borderColor = isHovered ? sBorderHoverColor : sBorderColor; + const sRGBColor borderColor = ComputeBorderColor(aState); return std::make_pair(backgroundColor, borderColor); }