Bug 846688 - Move IsLTR() from nsHTMLInputElement.cpp to dom::Element. r=bz

This commit is contained in:
Mounir Lamouri 2013-08-13 12:21:05 +01:00
parent 66239a7ec2
commit 924122577c
3 changed files with 18 additions and 13 deletions

View File

@ -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

View File

@ -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()
{

View File

@ -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"