Bug 261081. Support official 'pre-wrap' value for CSS 'white-space' since we already support it well as '-moz-pre-wrap'. r+sr=dbaron,a=schrep

This commit is contained in:
roytam1 2018-11-18 18:21:27 +08:00
parent 50d79f4b2e
commit aae6e2b7da
14 changed files with 21 additions and 22 deletions

View File

@ -340,7 +340,7 @@ nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent); nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
nsAutoString wsVal; nsAutoString wsVal;
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal); rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap")))) if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("pre-wrap"))))
{ {
*aIsPlainTextContext = PR_TRUE; *aIsPlainTextContext = PR_TRUE;
break; break;

View File

@ -1149,7 +1149,7 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent); nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
nsAutoString wsVal; nsAutoString wsVal;
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal); rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap")))) if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("pre-wrap"))))
{ {
mIsTextWidget = PR_TRUE; mIsTextWidget = PR_TRUE;
break; break;

View File

@ -677,7 +677,7 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag)
if(NS_SUCCEEDED(GetAttributeValue(aNode, nsHTMLAtoms::style, style)) && if(NS_SUCCEEDED(GetAttributeValue(aNode, nsHTMLAtoms::style, style)) &&
(kNotFound != (whitespace = style.Find("white-space:")))) { (kNotFound != (whitespace = style.Find("white-space:")))) {
if (kNotFound != style.Find("-moz-pre-wrap", PR_TRUE, whitespace)) { if (kNotFound != style.Find("pre-wrap", PR_TRUE, whitespace)) {
#ifdef DEBUG_preformatted #ifdef DEBUG_preformatted
printf("Set mPreFormatted based on style moz-pre-wrap\n"); printf("Set mPreFormatted based on style moz-pre-wrap\n");
#endif #endif

View File

@ -150,7 +150,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) { if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
// wrap: empty // wrap: empty
if (aAttributes->GetAttr(nsHTMLAtoms::wrap)) if (aAttributes->GetAttr(nsHTMLAtoms::wrap))
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated); aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
// width: int (html4 attribute == nav4 cols) // width: int (html4 attribute == nav4 cols)
const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width); const nsAttrValue* value = aAttributes->GetAttr(nsHTMLAtoms::width);
@ -162,7 +162,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
if (value && value->Type() == nsAttrValue::eInteger) { if (value && value->Type() == nsAttrValue::eInteger) {
// Force wrap property on since we want to wrap at a width // Force wrap property on since we want to wrap at a width
// boundary not just a newline. // boundary not just a newline.
aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSUnit_Enumerated); aData->mTextData->mWhiteSpace.SetIntValue(NS_STYLE_WHITESPACE_PRE_WRAP, eCSSUnit_Enumerated);
} }
} }
} }

View File

@ -4434,8 +4434,7 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, PRBool *aResult)
const nsStyleText* styleText = frame->GetStyleText(); const nsStyleText* styleText = frame->GetStyleText();
*aResult = NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace || *aResult = styleText->WhiteSpaceIsSignificant();
NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace;
return NS_OK; return NS_OK;
} }

View File

@ -1002,12 +1002,12 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
// and now we're ready to set the new whitespace/wrapping style. // and now we're ready to set the new whitespace/wrapping style.
if (aWrapColumn > 0 && !mWrapToWindow) // Wrap to a fixed column if (aWrapColumn > 0 && !mWrapToWindow) // Wrap to a fixed column
{ {
styleValue.AppendLiteral("white-space: -moz-pre-wrap; width: "); styleValue.AppendLiteral("white-space: pre-wrap; width: ");
styleValue.AppendInt(aWrapColumn); styleValue.AppendInt(aWrapColumn);
styleValue.AppendLiteral("ch;"); styleValue.AppendLiteral("ch;");
} }
else if (mWrapToWindow || aWrapColumn == 0) else if (mWrapToWindow || aWrapColumn == 0)
styleValue.AppendLiteral("white-space: -moz-pre-wrap;"); styleValue.AppendLiteral("white-space: pre-wrap;");
else else
styleValue.AppendLiteral("white-space: pre;"); styleValue.AppendLiteral("white-space: pre;");

View File

@ -569,7 +569,7 @@
#define NS_STYLE_WHITESPACE_NORMAL 0 #define NS_STYLE_WHITESPACE_NORMAL 0
#define NS_STYLE_WHITESPACE_PRE 1 #define NS_STYLE_WHITESPACE_PRE 1
#define NS_STYLE_WHITESPACE_NOWRAP 2 #define NS_STYLE_WHITESPACE_NOWRAP 2
#define NS_STYLE_WHITESPACE_MOZ_PRE_WRAP 3 #define NS_STYLE_WHITESPACE_PRE_WRAP 3
// See nsStyleText // See nsStyleText
#define NS_STYLE_UNICODE_BIDI_NORMAL 0 #define NS_STYLE_UNICODE_BIDI_NORMAL 0

View File

@ -1927,8 +1927,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
nsCOMPtr<nsIFontMetrics> fm; nsCOMPtr<nsIFontMetrics> fm;
rc->GetFontMetrics(*getter_AddRefs(fm)); rc->GetFontMetrics(*getter_AddRefs(fm));
PRBool preMode = (mStyleText->mWhiteSpace == NS_STYLE_WHITESPACE_PRE) || PRBool preMode = mStyleText->WhiteSpaceIsSignificant();
(mStyleText->mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP);
// See if the span is an empty continuation. It's an empty continuation iff: // See if the span is an empty continuation. It's an empty continuation iff:
// - it has a prev-in-flow // - it has a prev-in-flow

View File

@ -631,7 +631,7 @@ public:
mNumJustifiableCharacterReceivingExtraJot = 0; mNumJustifiableCharacterReceivingExtraJot = 0;
mExtraSpacePerJustifiableCharacter = 0; mExtraSpacePerJustifiableCharacter = 0;
mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) || mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) ||
(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == mText->mWhiteSpace); (NS_STYLE_WHITESPACE_PRE_WRAP == mText->mWhiteSpace);
mJustifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mText->mTextAlign) && mJustifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mText->mTextAlign) &&
!mPreformatted; !mPreformatted;
@ -5907,7 +5907,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
} }
PRBool wrapping = (NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace) || PRBool wrapping = (NS_STYLE_WHITESPACE_NORMAL == ts.mText->mWhiteSpace) ||
(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == ts.mText->mWhiteSpace); (NS_STYLE_WHITESPACE_PRE_WRAP == ts.mText->mWhiteSpace);
// Set whitespace skip flag // Set whitespace skip flag
PRBool skipWhitespace = PR_FALSE; PRBool skipWhitespace = PR_FALSE;
@ -6179,7 +6179,7 @@ nsTextFrame::TrimTrailingWhiteSpace(nsPresContext* aPresContext,
const nsStyleText* textStyle = GetStyleText(); const nsStyleText* textStyle = GetStyleText();
if (mContentLength && if (mContentLength &&
(NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) && (NS_STYLE_WHITESPACE_PRE != textStyle->mWhiteSpace) &&
(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP != textStyle->mWhiteSpace)) { (NS_STYLE_WHITESPACE_PRE_WRAP != textStyle->mWhiteSpace)) {
// Get the text fragments that make up our content // Get the text fragments that make up our content
nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent); nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent);

View File

@ -260,7 +260,7 @@ nsTextTransformer::Init(nsIFrame* aFrame,
if (NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) { if (NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) {
mMode = ePreformatted; mMode = ePreformatted;
} }
else if (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace) { else if (NS_STYLE_WHITESPACE_PRE_WRAP == styleText->mWhiteSpace) {
mMode = ePreWrap; mMode = ePreWrap;
} }
mTextTransform = styleText->mTextTransform; mTextTransform = styleText->mTextTransform;
@ -1569,7 +1569,7 @@ struct SelfTestData {
static PRUint8 preModeValue[NUM_MODES] = { static PRUint8 preModeValue[NUM_MODES] = {
NS_STYLE_WHITESPACE_NORMAL, NS_STYLE_WHITESPACE_NORMAL,
NS_STYLE_WHITESPACE_PRE, NS_STYLE_WHITESPACE_PRE,
NS_STYLE_WHITESPACE_MOZ_PRE_WRAP NS_STYLE_WHITESPACE_PRE_WRAP
}; };
static PRUnichar test1text[] = { static PRUnichar test1text[] = {
@ -1812,7 +1812,7 @@ nsTextTransformer::Init2(const nsTextFragment* aFrag,
if (NS_STYLE_WHITESPACE_PRE == aWhiteSpace) { if (NS_STYLE_WHITESPACE_PRE == aWhiteSpace) {
mMode = ePreformatted; mMode = ePreformatted;
} }
else if (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == aWhiteSpace) { else if (NS_STYLE_WHITESPACE_PRE_WRAP == aWhiteSpace) {
mMode = ePreWrap; mMode = ePreWrap;
} }
mTextTransform = aTextTransform; mTextTransform = aTextTransform;

View File

@ -108,8 +108,7 @@ inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode,
presShell->GetPrimaryFrameFor(content, &frame); presShell->GetPrimaryFrameFor(content, &frame);
if (frame) { if (frame) {
const nsStyleText* text = frame->GetStyleText(); const nsStyleText* text = frame->GetStyleText();
*aReturn = text->mWhiteSpace != NS_STYLE_WHITESPACE_PRE && *aReturn = !text->WhiteSpaceIsSignificant();
text->mWhiteSpace != NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
} }
else { else {
// empty inter-tag text node without frame, e.g., in between <table>\n<tr> // empty inter-tag text node without frame, e.g., in between <table>\n<tr>

View File

@ -355,6 +355,7 @@ CSS_KEY(physical, physical)
CSS_KEY(pointer, pointer) CSS_KEY(pointer, pointer)
CSS_KEY(portrait, portrait) CSS_KEY(portrait, portrait)
CSS_KEY(pre, pre) CSS_KEY(pre, pre)
CSS_KEY(pre-wrap, pre_wrap)
CSS_KEY(progress, progress) CSS_KEY(progress, progress)
CSS_KEY(pt, pt) CSS_KEY(pt, pt)
CSS_KEY(px, px) CSS_KEY(px, px)

View File

@ -928,7 +928,8 @@ const PRInt32 nsCSSProps::kVolumeKTable[] = {
const PRInt32 nsCSSProps::kWhitespaceKTable[] = { const PRInt32 nsCSSProps::kWhitespaceKTable[] = {
eCSSKeyword_pre, NS_STYLE_WHITESPACE_PRE, eCSSKeyword_pre, NS_STYLE_WHITESPACE_PRE,
eCSSKeyword_nowrap, NS_STYLE_WHITESPACE_NOWRAP, eCSSKeyword_nowrap, NS_STYLE_WHITESPACE_NOWRAP,
eCSSKeyword__moz_pre_wrap, NS_STYLE_WHITESPACE_MOZ_PRE_WRAP, eCSSKeyword_pre_wrap, NS_STYLE_WHITESPACE_PRE_WRAP,
eCSSKeyword__moz_pre_wrap, NS_STYLE_WHITESPACE_PRE_WRAP,
eCSSKeyword_UNKNOWN,-1 eCSSKeyword_UNKNOWN,-1
}; };

View File

@ -740,7 +740,7 @@ struct nsStyleText : public nsStyleStruct {
PRBool WhiteSpaceIsSignificant() const { PRBool WhiteSpaceIsSignificant() const {
return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
} }
}; };