bug 1046950 pt 1 - additional/modified APIs on LogicalSize. r=smontagu

This commit is contained in:
Jonathan Kew 2014-08-24 15:34:21 +01:00
parent 9e47fdce62
commit 3c5139d9bf
2 changed files with 45 additions and 18 deletions

View File

@ -269,9 +269,9 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
extraleft = std::min(extraleft, aButtonReflowState.ComputedPhysicalPadding().left);
extraright = std::min(extraright, aButtonReflowState.ComputedPhysicalPadding().right);
xoffset -= extraleft;
availSize.SetWidth(wm, availSize.Width(wm) + extraleft + extraright);
availSize.Width(wm) = availSize.Width(wm) + extraleft + extraright;
}
availSize.SetWidth(wm, std::max(availSize.Width(wm), 0));
availSize.Width(wm) = std::max(availSize.Width(wm), 0);
// Give child a clone of the button's reflow state, with height/width reduced
// by focusPadding, so that descendants with height:100% don't protrude.

View File

@ -631,7 +631,7 @@ public:
}
/**
* Writable references to the logical dimensions
* Writable references to the logical and physical dimensions
*/
nscoord& ISize(WritingMode aWritingMode) // inline-size
{
@ -644,26 +644,15 @@ public:
return mSize.height;
}
/**
* Setters for the physical dimensions
*/
void SetWidth(WritingMode aWritingMode, nscoord aWidth)
nscoord& Width(WritingMode aWritingMode)
{
CHECK_WRITING_MODE(aWritingMode);
if (aWritingMode.IsVertical()) {
BSize() = aWidth;
} else {
ISize() = aWidth;
}
return aWritingMode.IsVertical() ? BSize() : ISize();
}
void SetHeight(WritingMode aWritingMode, nscoord aHeight)
nscoord& Height(WritingMode aWritingMode)
{
CHECK_WRITING_MODE(aWritingMode);
if (aWritingMode.IsVertical()) {
ISize() = aHeight;
} else {
BSize() = aHeight;
}
return aWritingMode.IsVertical() ? ISize() : BSize();
}
/**
@ -696,6 +685,34 @@ public:
return mWritingMode != aOther.mWritingMode || mSize != aOther.mSize;
}
LogicalSize operator+(const LogicalSize& aOther) const
{
CHECK_WRITING_MODE(aOther.GetWritingMode());
return LogicalSize(mWritingMode, ISize() + aOther.ISize(),
BSize() + aOther.BSize());
}
LogicalSize& operator+=(const LogicalSize& aOther)
{
CHECK_WRITING_MODE(aOther.GetWritingMode());
ISize() += aOther.ISize();
BSize() += aOther.BSize();
return *this;
}
LogicalSize operator-(const LogicalSize& aOther) const
{
CHECK_WRITING_MODE(aOther.GetWritingMode());
return LogicalSize(mWritingMode, ISize() - aOther.ISize(),
BSize() - aOther.BSize());
}
LogicalSize& operator-=(const LogicalSize& aOther)
{
CHECK_WRITING_MODE(aOther.GetWritingMode());
ISize() -= aOther.ISize();
BSize() -= aOther.BSize();
return *this;
}
private:
friend class LogicalRect;
@ -838,6 +855,16 @@ public:
return mMargin.TopBottom();
}
/**
* Return a LogicalSize representing the total size of the inline-
* and block-dimension margins.
*/
LogicalSize Size(WritingMode aWritingMode) const
{
CHECK_WRITING_MODE(aWritingMode);
return LogicalSize(aWritingMode, IStartEnd(), BStartEnd());
}
/**
* Accessors for physical margins, using our writing mode to convert from
* logical values.