From 21f9cc6065c0228760431261efe45c1546f61ce0 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 5 Feb 2014 23:08:48 +1300 Subject: [PATCH] Bug 947588. Part 1: Add "-moz-control-character-visibility" property to the style system. r=heycam Ideally we'd make this property inaccessible to Web content style sheets, but that seems hard since view-source and plain text documents seem to load in a context that's very similar to Web content as far as the style system is concerned. It doesn't matter much since it's quite safe and unlikely to be discovered or used by anyone. --HG-- extra : rebase_source : 009aafc992afd07fd76a9026afe0f6994b4b214a --- layout/style/nsCSSPropList.h | 12 ++++++++++++ layout/style/nsCSSProps.cpp | 6 ++++++ layout/style/nsCSSProps.h | 1 + layout/style/nsRuleNode.cpp | 8 ++++++++ layout/style/nsStyleConsts.h | 4 ++++ layout/style/nsStyleStruct.cpp | 5 ++++- layout/style/nsStyleStruct.h | 1 + layout/style/test/ListCSSProperties.cpp | 1 + 8 files changed, 37 insertions(+), 1 deletion(-) diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 6e42707371ad..f19241c243bd 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1534,6 +1534,18 @@ CSS_PROP_CONTENT( kContentKTable, CSS_PROP_NO_OFFSET, eStyleAnimType_None) +#ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL +CSS_PROP_TEXT( + -moz-control-character-visibility, + _moz_control_character_visibility, + CSS_PROP_DOMPROP_PREFIXED(ControlCharacterVisibility), + CSS_PROPERTY_PARSE_VALUE, + "", + VARIANT_HK, + kControlCharacterVisibilityKTable, + CSS_PROP_NO_OFFSET, + eStyleAnimType_None) +#endif CSS_PROP_CONTENT( counter-increment, counter_increment, diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 5c5048551c7b..2a6e3ad4d35c 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -914,6 +914,12 @@ const KTableValue nsCSSProps::kContentKTable[] = { eCSSKeyword_UNKNOWN,-1 }; +const KTableValue nsCSSProps::kControlCharacterVisibilityKTable[] = { + eCSSKeyword_hidden, NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN, + eCSSKeyword_visible, NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE, + eCSSKeyword_UNKNOWN,-1 +}; + const KTableValue nsCSSProps::kCursorKTable[] = { // CSS 2.0 eCSSKeyword_auto, NS_STYLE_CURSOR_AUTO, diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 4d1d749b0bda..038efe768b2d 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -491,6 +491,7 @@ public: static const KTableValue kClearKTable[]; static const KTableValue kColorKTable[]; static const KTableValue kContentKTable[]; + static const KTableValue kControlCharacterVisibilityKTable[]; static const KTableValue kCursorKTable[]; static const KTableValue kDirectionKTable[]; static const KTableValue kDisplayKTable[]; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 079daa271546..42af06ced594 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4219,6 +4219,14 @@ nsRuleNode::ComputeTextData(void* aStartStruct, NS_STYLE_TEXT_SIZE_ADJUST_NONE, // none value 0, 0); + // -moz-text-discard: enum, inherit, initial + SetDiscrete(*aRuleData->ValueForControlCharacterVisibility(), + text->mControlCharacterVisibility, + canStoreInRuleTree, + SETDSC_ENUMERATED | SETDSC_UNSET_INHERIT, + parentText->mControlCharacterVisibility, + NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN, 0, 0, 0, 0); + // text-orientation: enum, inherit, initial SetDiscrete(*aRuleData->ValueForTextOrientation(), text->mTextOrientation, canStoreInRuleTree, diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 9b6cf6cac345..94da4dd04e2a 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -1025,6 +1025,10 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) { #define NS_STYLE_BLEND_COLOR 14 #define NS_STYLE_BLEND_LUMINOSITY 15 +// See nsStyleText::mControlCharacterVisibility +#define NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN 0 +#define NS_STYLE_CONTROL_CHARACTER_VISIBILITY_VISIBLE 1 + /***************************************************************************** * Constants for media features. * *****************************************************************************/ diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index fff90571d615..6eafb5103eae 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2970,6 +2970,7 @@ nsStyleText::nsStyleText(void) mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO; mTextOrientation = NS_STYLE_TEXT_ORIENTATION_AUTO; mTextCombineHorizontal = NS_STYLE_TEXT_COMBINE_HORIZ_NONE; + mControlCharacterVisibility = NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN; mLetterSpacing.SetNormalValue(); mLineHeight.SetNormalValue(); @@ -2993,6 +2994,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource) mTextSizeAdjust(aSource.mTextSizeAdjust), mTextOrientation(aSource.mTextOrientation), mTextCombineHorizontal(aSource.mTextCombineHorizontal), + mControlCharacterVisibility(aSource.mControlCharacterVisibility), mTabSize(aSource.mTabSize), mWordSpacing(aSource.mWordSpacing), mLetterSpacing(aSource.mLetterSpacing), @@ -3016,7 +3018,8 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const return NS_STYLE_HINT_FRAMECHANGE; } - if (mTextCombineHorizontal != aOther.mTextCombineHorizontal) { + if (mTextCombineHorizontal != aOther.mTextCombineHorizontal || + mControlCharacterVisibility != aOther.mControlCharacterVisibility) { return nsChangeHint_ReconstructFrame; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 3fdb92d452a6..f72a66365579 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1395,6 +1395,7 @@ struct nsStyleText { uint8_t mTextSizeAdjust; // [inherited] see nsStyleConsts.h uint8_t mTextOrientation; // [inherited] see nsStyleConsts.h uint8_t mTextCombineHorizontal; // [inherited] see nsStyleConsts.h + uint8_t mControlCharacterVisibility; // [inherited] see nsStyleConsts.h int32_t mTabSize; // [inherited] see nsStyleConsts.h nscoord mWordSpacing; // [inherited] diff --git a/layout/style/test/ListCSSProperties.cpp b/layout/style/test/ListCSSProperties.cpp index 531ecf4b6cfe..e213e25377df 100644 --- a/layout/style/test/ListCSSProperties.cpp +++ b/layout/style/test/ListCSSProperties.cpp @@ -144,6 +144,7 @@ const char *gInaccessibleProperties[] = { "padding-left-rtl-source", "padding-right-ltr-source", "padding-right-rtl-source", + "-moz-control-character-visibility", "-moz-script-level", // parsed by UA sheets only "-moz-script-size-multiplier", "-moz-script-min-size",