Add some logical setters/getters to nsIFrame.h. Bug 735577, r=jfkthame

This commit is contained in:
Simon Montagu 2014-02-12 23:55:06 -08:00
parent b5a3a27830
commit c4fb327c6a

View File

@ -686,6 +686,15 @@ public:
nsRect GetRectRelativeToSelf() const {
return nsRect(nsPoint(0, 0), mRect.Size());
}
/**
* Rect and position in logical coordinates in the frame's writing mode
*/
mozilla::LogicalRect GetLogicalRect(nscoord aContainerWidth) const {
return mozilla::LogicalRect(GetWritingMode(), GetRect(), aContainerWidth);
}
mozilla::LogicalPoint GetLogicalPosition(nscoord aContainerWidth) const {
return GetLogicalRect(aContainerWidth).Origin(GetWritingMode());
}
/**
* When we change the size of the frame's border-box rect, we may need to
@ -703,6 +712,22 @@ public:
mRect = aRect;
}
}
/**
* Set this frame's rect from a logical rect in its own writing direction
*/
void SetRectFromLogicalRect(const mozilla::LogicalRect& aRect,
nscoord aContainerWidth) {
SetRectFromLogicalRect(GetWritingMode(), aRect, aContainerWidth);
}
/**
* Set this frame's rect from a logical rect in a different writing direction
* (GetPhysicalRect will assert if the writing mode doesn't match)
*/
void SetRectFromLogicalRect(mozilla::WritingMode aWritingMode,
const mozilla::LogicalRect& aRect,
nscoord aContainerWidth) {
SetRect(aRect.GetPhysicalRect(aWritingMode, aContainerWidth));
}
void SetSize(const nsSize& aSize) {
SetRect(nsRect(mRect.TopLeft(), aSize));
}