mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-23 21:03:08 +09:00
Issue #1970 - Part 2: Remove the extra padding on buttons
Extra padding was created for a prospective -moz-focus-inner ring. We now just size that ring the same as the content frame, inflated by its CSS padding.
This commit is contained in:
parent
8de47d99c4
commit
e54e8f61bb
6 changed files with 44 additions and 175 deletions
|
|
@ -241,10 +241,9 @@ void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
|
|||
!presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) {
|
||||
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
||||
|
||||
// Draw the focus and outline borders.
|
||||
// Draw the -moz-focus-inner border
|
||||
DrawResult result =
|
||||
mBFR->PaintOutlineAndFocusBorders(aBuilder, presContext, *aCtx,
|
||||
mVisibleRect, r);
|
||||
mBFR->PaintInnerFocusBorder(aBuilder, presContext, *aCtx, mVisibleRect, r);
|
||||
|
||||
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
||||
}
|
||||
|
|
@ -278,20 +277,29 @@ nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult)
|
||||
{
|
||||
GetButtonRect(aRect, aResult);
|
||||
aResult.Deflate(mFrame->GetUsedBorderAndPadding());
|
||||
|
||||
nsMargin innerFocusPadding(0,0,0,0);
|
||||
if (mInnerFocusStyle) {
|
||||
mInnerFocusStyle->StylePadding()->GetPadding(innerFocusPadding);
|
||||
}
|
||||
aResult.Inflate(innerFocusPadding);
|
||||
}
|
||||
|
||||
DrawResult
|
||||
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(
|
||||
nsButtonFrameRenderer::PaintInnerFocusBorder(
|
||||
nsDisplayListBuilder* aBuilder,
|
||||
nsPresContext* aPresContext,
|
||||
nsRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aRect)
|
||||
{
|
||||
// once we have all that we'll draw the focus if we have it. We will
|
||||
// need to draw 2 focuses, the inner and the outer. This is so we
|
||||
// can do any kind of look and feel. Some buttons have focus on the
|
||||
// outside like mac and motif. While others like windows have it
|
||||
// inside (dotted line). Usually only one will be specifed. But I
|
||||
// guess you could have both if you wanted to.
|
||||
// we draw the -moz-focus-inner border just inside the button's
|
||||
// normal border and padding, to match Windows themes.
|
||||
|
||||
nsRect rect;
|
||||
|
||||
|
|
@ -348,57 +356,6 @@ nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
|
||||
{
|
||||
GetButtonRect(aRect, focusRect);
|
||||
focusRect.Deflate(GetButtonBorderAndPadding());
|
||||
focusRect.Deflate(GetButtonInnerFocusMargin());
|
||||
}
|
||||
|
||||
|
||||
nsMargin
|
||||
nsButtonFrameRenderer::GetButtonBorderAndPadding()
|
||||
{
|
||||
return mFrame->GetUsedBorderAndPadding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the buttons border this is the union of the normal and disabled borders.
|
||||
*/
|
||||
nsMargin
|
||||
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
|
||||
{
|
||||
nsMargin innerFocusMargin(0,0,0,0);
|
||||
|
||||
if (mInnerFocusStyle) {
|
||||
const nsStyleMargin* margin = mInnerFocusStyle->StyleMargin();
|
||||
margin->GetMargin(innerFocusMargin);
|
||||
}
|
||||
|
||||
return innerFocusMargin;
|
||||
}
|
||||
|
||||
nsMargin
|
||||
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
|
||||
{
|
||||
nsMargin result(0,0,0,0);
|
||||
|
||||
if (mInnerFocusStyle) {
|
||||
mInnerFocusStyle->StylePadding()->GetPadding(result);
|
||||
result += mInnerFocusStyle->StyleBorder()->GetComputedBorder();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// gets all the focus borders and padding that will be added to the regular border
|
||||
nsMargin
|
||||
nsButtonFrameRenderer::GetAddedButtonBorderAndPadding()
|
||||
{
|
||||
return GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this when styles change
|
||||
*/
|
||||
|
|
@ -415,7 +372,7 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
|
|||
}
|
||||
#endif
|
||||
|
||||
// style for the inner such as a dotted line (Windows)
|
||||
// get styles assigned to -moz-inner-focus (ie dotted border on Windows)
|
||||
mInnerFocusStyle =
|
||||
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
||||
CSSPseudoElementType::mozFocusInner,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue