Bug 1026641 - Put outline-style:auto rendering behind a pref and disable it by default. r=roc

This commit is contained in:
Mats Palmgren 2014-06-26 12:48:05 +00:00
parent 1a6848ddaa
commit 8f40519109
6 changed files with 50 additions and 25 deletions

View File

@ -814,20 +814,22 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
gfxCornerSizes outlineRadii;
ComputePixelRadii(twipsRadii, twipsPerPixel, &outlineRadii);
if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) {
nsITheme* theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame,
NS_THEME_FOCUS_OUTLINE)) {
theme->DrawWidgetBackground(&aRenderingContext, aForFrame,
NS_THEME_FOCUS_OUTLINE, innerRect,
aDirtyRect);
return;
} else if (width == 0) {
return; // empty outline
if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) {
nsITheme* theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame,
NS_THEME_FOCUS_OUTLINE)) {
theme->DrawWidgetBackground(&aRenderingContext, aForFrame,
NS_THEME_FOCUS_OUTLINE, innerRect,
aDirtyRect);
return;
} else if (width == 0) {
return; // empty outline
}
// http://dev.w3.org/csswg/css-ui/#outline
// "User agents may treat 'auto' as 'solid'."
outlineStyle = NS_STYLE_BORDER_STYLE_SOLID;
}
// http://dev.w3.org/csswg/css-ui/#outline
// "User agents may treat 'auto' as 'solid'."
outlineStyle = NS_STYLE_BORDER_STYLE_SOLID;
}
uint8_t outlineStyles[4] = { outlineStyle, outlineStyle,

View File

@ -6795,3 +6795,18 @@ MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager, nsView* aView)
}
}
/* static */ bool
nsLayoutUtils::IsOutlineStyleAutoEnabled()
{
static bool sOutlineStyleAutoEnabled;
static bool sOutlineStyleAutoPrefCached = false;
if (!sOutlineStyleAutoPrefCached) {
sOutlineStyleAutoPrefCached = true;
Preferences::AddBoolVarCache(&sOutlineStyleAutoEnabled,
"layout.css.outline-style-auto.enabled",
false);
}
return sOutlineStyleAutoEnabled;
}

View File

@ -2278,6 +2278,8 @@ public:
nsRect aDisplayPortBase,
nsRect* aOutDisplayport);
static bool IsOutlineStyleAutoEnabled();
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;

View File

@ -7147,17 +7147,20 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas,
new nsRect(innerRect));
const nscoord offset = outline->mOutlineOffset;
nsRect outerRect(innerRect);
bool useOutlineAuto = outlineStyle == NS_STYLE_BORDER_STYLE_AUTO;
if (MOZ_UNLIKELY(useOutlineAuto)) {
nsPresContext* presContext = aFrame->PresContext();
nsITheme* theme = presContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(presContext, aFrame,
NS_THEME_FOCUS_OUTLINE)) {
outerRect.Inflate(offset);
theme->GetWidgetOverflow(presContext->DeviceContext(), aFrame,
NS_THEME_FOCUS_OUTLINE, &outerRect);
} else {
useOutlineAuto = false;
bool useOutlineAuto = false;
if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
useOutlineAuto = outlineStyle == NS_STYLE_BORDER_STYLE_AUTO;
if (MOZ_UNLIKELY(useOutlineAuto)) {
nsPresContext* presContext = aFrame->PresContext();
nsITheme* theme = presContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(presContext, aFrame,
NS_THEME_FOCUS_OUTLINE)) {
outerRect.Inflate(offset);
theme->GetWidgetOverflow(presContext->DeviceContext(), aFrame,
NS_THEME_FOCUS_OUTLINE, &outerRect);
} else {
useOutlineAuto = false;
}
}
}
if (MOZ_LIKELY(!useOutlineAuto)) {

View File

@ -6,4 +6,4 @@
== outline-overflow-block-float.html outline-overflow-block-ref.html
== outline-overflow-inlineblock-abspos.html outline-overflow-inlineblock-ref.html
== outline-overflow-inlineblock-float.html outline-overflow-inlineblock-ref.html
skip-if(!gtk2Widget&&!winWidget&&!cocoaWidget) == outline-auto-001.html outline-auto-001-ref.html # only works on platforms that supports NS_THEME_FOCUS_OUTLINE
pref(layout.css.outline-style-auto.enabled,true) skip-if(!gtk2Widget&&!winWidget&&!cocoaWidget) == outline-auto-001.html outline-auto-001-ref.html # only works on platforms that supports NS_THEME_FOCUS_OUTLINE

View File

@ -1967,6 +1967,9 @@ pref("layout.css.grid.enabled", false);
// Is support for CSS box-decoration-break enabled?
pref("layout.css.box-decoration-break.enabled", false);
// Is layout of CSS outline-style:auto enabled?
pref("layout.css.outline-style-auto.enabled", false);
// pref for which side vertical scrollbars should be on
// 0 = end-side in UI direction
// 1 = end-side in document/content direction