Bug 1123917 part 1 - Add line-relative direction mapping methods to writing modes. r=jfkthame

--HG--
extra : rebase_source : b560e4956cef826d5d7c55fd2c644aa52857dfca
extra : source : ae961e0f6c20b5a9bfec10a99568d0282e437c9e
This commit is contained in:
Xidorn Quan 2015-01-22 14:04:55 +11:00
Родитель 7498962b16
Коммит 4f9602615b
1 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -67,12 +67,23 @@ inline LogicalEdge GetEdge(LogicalSide aSide)
return IsEnd(aSide) ? eLogicalEdgeEnd : eLogicalEdgeStart;
}
inline LogicalEdge GetOppositeEdge(LogicalEdge aEdge)
{
// This relies on the only two LogicalEdge enum values being 0 and 1.
return LogicalEdge(1 - aEdge);
}
inline LogicalSide
MakeLogicalSide(LogicalAxis aAxis, LogicalEdge aEdge)
{
return LogicalSide((aAxis << 1) | aEdge);
}
inline LogicalSide GetOppositeSide(LogicalSide aSide)
{
return MakeLogicalSide(GetAxis(aSide), GetOppositeEdge(GetEdge(aSide)));
}
enum LogicalSideBits {
eLogicalSideBitsNone = 0,
eLogicalSideBitsBStart = 1 << eLogicalSideBStart,
@ -84,6 +95,13 @@ enum LogicalSideBits {
eLogicalSideBitsAll = eLogicalSideBitsBBoth | eLogicalSideBitsIBoth
};
enum LineRelativeDir {
eLineRelativeDirOver = eLogicalSideBStart,
eLineRelativeDirUnder = eLogicalSideBEnd,
eLineRelativeDirLeft = eLogicalSideIStart,
eLineRelativeDirRight = eLogicalSideIEnd
};
/**
* LogicalSides represents a set of logical sides.
*/
@ -350,6 +368,19 @@ public:
return PhysicalSideForInlineAxis(GetEdge(aSide));
}
/**
* Returns the physical side corresponding to the specified
* line-relative direction, given the current writing mode.
*/
mozilla::Side PhysicalSide(LineRelativeDir aDir) const
{
LogicalSide side = static_cast<LogicalSide>(aDir);
if (IsLineInverted()) {
side = GetOppositeSide(side);
}
return PhysicalSide(side);
}
/**
* Default constructor gives us a horizontal, LTR writing mode.
* XXX We will probably eliminate this and require explicit initialization