# HG changeset patch # User Jonathan Kew # Date 1442855987 -3600 # Mon Sep 21 18:19:47 2015 +0100 # Node ID e98312efdc83b94b3474bc43609616b376fdd633 # Parent 039a8490891595736b16a3ccb17f025f4dcf13eb Bug 1099557 followup - Put the default setting for control-character visibility behind a runtime pref, and keep it off-by-default on release builds for now. r?dbaron diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -57,16 +57,17 @@ typedef nsCSSProps::KTableValue KTableVa // pref-backed bool values (hooked up in nsCSSParser::Startup) static bool sOpentypeSVGEnabled; static bool sUnprefixingServiceEnabled; #ifdef NIGHTLY_BUILD static bool sUnprefixingServiceGloballyWhitelisted; #endif static bool sMozGradientsEnabled; +static bool sControlCharVisibility; const uint32_t nsCSSProps::kParserVariantTable[eCSSProperty_COUNT_no_shorthands] = { #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \ stylestruct_, stylestructoffset_, animtype_) \ parsevariant_, #define CSS_PROP_LIST_INCLUDE_LOGICAL #include "nsCSSPropList.h" @@ -15705,16 +15706,18 @@ nsCSSParser::Startup() Preferences::AddBoolVarCache(&sUnprefixingServiceEnabled, "layout.css.unprefixing-service.enabled"); #ifdef NIGHTLY_BUILD Preferences::AddBoolVarCache(&sUnprefixingServiceGloballyWhitelisted, "layout.css.unprefixing-service.globally-whitelisted"); #endif Preferences::AddBoolVarCache(&sMozGradientsEnabled, "layout.css.prefixes.gradients"); + Preferences::AddBoolVarCache(&sControlCharVisibility, + "layout.css.control-characters.visible"); } nsCSSParser::nsCSSParser(mozilla::css::Loader* aLoader, CSSStyleSheet* aSheet) { CSSParserImpl *impl = gFreeList; if (impl) { gFreeList = impl->mNextFree; @@ -16036,8 +16039,17 @@ nsCSSParser::ParseFontFaceDescriptor(nsC bool nsCSSParser::IsValueValidForProperty(const nsCSSProperty aPropID, const nsAString& aPropValue) { return static_cast(mImpl)-> IsValueValidForProperty(aPropID, aPropValue); } + +/* static */ +uint8_t +nsCSSParser::ControlCharVisibilityDefault() +{ + return sControlCharVisibility + ? NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE + : NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN; +} diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h --- a/layout/style/nsCSSParser.h +++ b/layout/style/nsCSSParser.h @@ -304,16 +304,21 @@ public: nsIURI* aBaseURL, nsIPrincipal* aSheetPrincipal, nsCSSValue& aValue); // Check whether a given value can be applied to a property. bool IsValueValidForProperty(const nsCSSProperty aPropID, const nsAString& aPropValue); + // Return the default value to be used for -moz-control-character-visibility, + // from preferences (cached by our Startup(), so that both nsStyleText and + // nsRuleNode can have fast access to it). + static uint8_t ControlCharVisibilityDefault(); + protected: // This is a CSSParserImpl*, but if we expose that type name in this // header, we can't put the type definition (in nsCSSParser.cpp) in // the anonymous namespace. void* mImpl; }; #endif /* nsCSSParser_h___ */ diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4365,17 +4365,17 @@ nsRuleNode::ComputeTextData(void* aStart NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE, 0, 0, 0, 0); // -moz-control-character-visibility: enum, inherit, initial SetDiscrete(*aRuleData->ValueForControlCharacterVisibility(), text->mControlCharacterVisibility, conditions, SETDSC_ENUMERATED | SETDSC_UNSET_INHERIT, parentText->mControlCharacterVisibility, - NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE, 0, 0, 0, 0); + nsCSSParser::ControlCharVisibilityDefault(), 0, 0, 0, 0); COMPUTE_END_INHERITED(Text, text) } const void* nsRuleNode::ComputeTextResetData(void* aStartStruct, const nsRuleData* aRuleData, nsStyleContext* aContext, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -11,16 +11,17 @@ #include "nsStyleStruct.h" #include "nsStyleStructInlines.h" #include "nsStyleConsts.h" #include "nsThemeConstants.h" #include "nsString.h" #include "nsPresContext.h" #include "nsIWidget.h" #include "nsCRTGlue.h" +#include "nsCSSParser.h" #include "nsCSSProps.h" #include "nsCOMPtr.h" #include "nsBidiUtils.h" #include "nsLayoutUtils.h" #include "imgIRequest.h" @@ -3403,17 +3404,17 @@ nsStyleText::nsStyleText(void) mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL; mWordBreak = NS_STYLE_WORDBREAK_NORMAL; mWordWrap = NS_STYLE_WORDWRAP_NORMAL; mHyphens = NS_STYLE_HYPHENS_MANUAL; mRubyAlign = NS_STYLE_RUBY_ALIGN_SPACE_AROUND; mRubyPosition = NS_STYLE_RUBY_POSITION_OVER; mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO; mTextCombineUpright = NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE; - mControlCharacterVisibility = NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE; + mControlCharacterVisibility = nsCSSParser::ControlCharVisibilityDefault(); mLetterSpacing.SetNormalValue(); mLineHeight.SetNormalValue(); mTextIndent.SetCoordValue(0); mWordSpacing = 0; mTextShadow = nullptr; mTabSize = NS_STYLE_TABSIZE_INITIAL; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2377,16 +2377,23 @@ pref("layout.css.scroll-behavior.spring- pref("layout.css.scroll-behavior.damping-ratio", "1.0"); // Is support for scroll-snap enabled? pref("layout.css.scroll-snap.enabled", true); // Is support for document.fonts enabled? pref("layout.css.font-loading-api.enabled", true); +// Should stray control characters be rendered visibly? +#ifdef RELEASE_BUILD +pref("layout.css.control-characters.visible", false); +#else +pref("layout.css.control-characters.visible", true); +#endif + // Are the MouseEvent.offsetX/Y properties enabled? pref("dom.mouseEvent.offsetXY.enabled", true); // pref for which side vertical scrollbars should be on // 0 = end-side in UI direction // 1 = end-side in document/content direction // 2 = right // 3 = left