diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 10ee69a8c77..f94f8850b17 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -338,6 +338,8 @@ public: (HasValidDir() || IsHTML(nsGkAtoms::bdi))); } + Directionality GetComputedDirectionality() const; + protected: /** * Method to get the _intrinsic_ content state of this element. This is the diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 6e52fe6e41c..1206848b3eb 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -3419,6 +3419,18 @@ Element::SetBoolAttr(nsIAtom* aAttr, bool aValue) return UnsetAttr(kNameSpaceID_None, aAttr, true); } +Directionality +Element::GetComputedDirectionality() const +{ + nsIFrame* frame = GetPrimaryFrame(); + if (frame) { + return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR + ? eDir_LTR : eDir_RTL; + } + + return GetDirectionality(); +} + float Element::FontSizeInflation() { diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index 40c205e6a8b..91340235ddb 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -2839,17 +2839,6 @@ SelectTextFieldOnFocus() return gSelectTextFieldOnFocus == 1; } -static bool -IsLTR(Element* aElement) -{ - nsIFrame* frame = aElement->GetPrimaryFrame(); - if (frame) { - return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR; - } - // at least for HTML, directionality is exclusively LTR or RTL - return aElement->GetDirectionality() == eDir_LTR; -} - bool HTMLInputElement::ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget) { @@ -3180,10 +3169,12 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) Decimal newValue; switch (keyEvent->keyCode) { case NS_VK_LEFT: - newValue = value + (IsLTR(this) ? -step : step); + newValue = value + (GetComputedDirectionality() == eDir_RTL + ? step : -step); break; case NS_VK_RIGHT: - newValue = value + (IsLTR(this) ? step : -step); + newValue = value + (GetComputedDirectionality() == eDir_RTL + ? -step : step); break; case NS_VK_UP: // Even for horizontal range, "up" means "increase"