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
authorroc+@cs.cmu.edu
Tue, 19 Feb 2008 18:07:48 -0800
changeset 11894 98ee5e860f2079fb8904abd50d07c852466bce0c
parent 11893 b8474ffff10280e0dc87f195d23f94a45014dd68
child 11895 f292e9dbe43777135c5c3bb024df5cba9894d504
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersschrep
bugs261081
milestone1.9b4pre
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
content/base/src/nsCopySupport.cpp
content/base/src/nsDocumentEncoder.cpp
content/base/src/nsPlainTextSerializer.cpp
content/html/content/src/nsHTMLPreElement.cpp
editor/libeditor/base/nsEditor.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
layout/base/nsStyleConsts.h
layout/generic/nsLineLayout.cpp
layout/inspector/src/inDOMUtils.cpp
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
layout/style/nsStyleStruct.h
layout/style/test/property_database.js
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -339,17 +339,17 @@ nsresult nsCopySupport::IsPlainTextConte
     if (atom == nsGkAtoms::body)
     {
       // check for moz prewrap style on body.  If it's there we are 
       // in a plaintext editor.  This is pretty cheezy but I haven't 
       // found a good way to tell if we are in a plaintext editor.
       nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
       nsAutoString 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;
         break;
       }
     }
   }
   
   // also consider ourselves in a text widget if we can't find an html
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -1146,17 +1146,17 @@ nsHTMLCopyEncoder::SetSelection(nsISelec
     else if (atom == nsGkAtoms::body)
     {
       // check for moz prewrap style on body.  If it's there we are 
       // in a plaintext editor.  This is pretty cheezy but I haven't 
       // found a good way to tell if we are in a plaintext editor.
       nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
       nsAutoString 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;
         break;
       }
     }
   }
   
   // also consider ourselves in a text widget if we can't find an html document
--- a/content/base/src/nsPlainTextSerializer.cpp
+++ b/content/base/src/nsPlainTextSerializer.cpp
@@ -598,17 +598,17 @@ nsPlainTextSerializer::DoOpenContainer(c
     // it, but better than nothing.
     // Also set mWrapColumn to the value given there
     // (which arguably we should only do if told to do so).
     nsAutoString style;
     PRInt32 whitespace;
     if(NS_SUCCEEDED(GetAttributeValue(aNode, nsGkAtoms::style, style)) &&
        (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
         printf("Set mPreFormatted based on style moz-pre-wrap\n");
 #endif
         mPreFormatted = PR_TRUE;
         PRInt32 widthOffset = style.Find("width:");
         if (widthOffset >= 0) {
           // We have to search for the ch before the semicolon,
           // not for the semicolon itself, because nsString::ToInteger()
--- a/content/html/content/src/nsHTMLPreElement.cpp
+++ b/content/html/content/src/nsHTMLPreElement.cpp
@@ -151,29 +151,29 @@ MapAttributesIntoRule(const nsMappedAttr
       if (value && value->Type() == nsAttrValue::eInteger)
         aData->mPositionData->mWidth.SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Char);
     }
   }
   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
     if (aData->mTextData->mWhiteSpace.GetUnit() == eCSSUnit_Null) {
       // wrap: empty
       if (aAttributes->GetAttr(nsGkAtoms::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)
       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
       if (!value || value->Type() != nsAttrValue::eInteger) {
         // cols: int (nav4 attribute)
         value = aAttributes->GetAttr(nsGkAtoms::cols);
       }
 
       if (value && value->Type() == nsAttrValue::eInteger) {
         // Force wrap property on since we want to wrap at a width
         // 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);
       }
     }
   }
 
   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
 }
 
 NS_IMETHODIMP_(PRBool)
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -4163,18 +4163,17 @@ nsEditor::IsPreformatted(nsIDOMNode *aNo
     // For instance, this is true of JS tags inside the body (which show
     // up as #text nodes but have no style context).
     *aResult = PR_FALSE;
     return NS_OK;
   }
 
   const nsStyleText* styleText = frame->GetStyleText();
 
-  *aResult = NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace ||
-             NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace;
+  *aResult = styleText->WhiteSpaceIsSignificant();
   return NS_OK;
 }
 
 
 ///////////////////////////////////////////////////////////////////////////
 // SplitNodeDeep: this splits a node "deeply", splitting children as 
 //                appropriate.  The place to split is represented by
 //                a dom point at {splitPointParent, splitPointOffset}.
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1034,22 +1034,22 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 
     if (NS_SUCCEEDED(rv))
       prefBranch->GetBoolPref("mail.compose.wrap_to_window_width",
                               &mWrapToWindow);
   }
 
   // and now we're ready to set the new whitespace/wrapping style.
   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.AppendLiteral("ch;");
   }
   else if (mWrapToWindow || aWrapColumn == 0)
-    styleValue.AppendLiteral("white-space: -moz-pre-wrap;");
+    styleValue.AppendLiteral("white-space: pre-wrap;");
   else
     styleValue.AppendLiteral("white-space: pre;");
 
   return rootElement->SetAttribute(styleName, styleValue);
 }
 
 NS_IMETHODIMP 
 nsPlaintextEditor::SetWrapColumn(PRInt32 aWrapColumn)
--- a/layout/base/nsStyleConsts.h
+++ b/layout/base/nsStyleConsts.h
@@ -589,17 +589,17 @@
 #define NS_STYLE_VISIBILITY_HIDDEN              0
 #define NS_STYLE_VISIBILITY_VISIBLE             1
 #define NS_STYLE_VISIBILITY_COLLAPSE            2
 
 // See nsStyleText
 #define NS_STYLE_WHITESPACE_NORMAL              0
 #define NS_STYLE_WHITESPACE_PRE                 1
 #define NS_STYLE_WHITESPACE_NOWRAP              2
-#define NS_STYLE_WHITESPACE_MOZ_PRE_WRAP        3
+#define NS_STYLE_WHITESPACE_PRE_WRAP            3
 
 // See nsStyleText
 #define NS_STYLE_UNICODE_BIDI_NORMAL            0
 #define NS_STYLE_UNICODE_BIDI_EMBED             1
 #define NS_STYLE_UNICODE_BIDI_OVERRIDE          2
 
 // See nsStyleTable (here for HTML 4.0 for now, should probably change to side flags)
 #define NS_STYLE_TABLE_FRAME_NONE               0
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -1587,18 +1587,17 @@ nsLineLayout::VerticalAlignFrames(PerSpa
 
   // Get the parent frame's font for all of the frames in this span
   nsStyleContext* styleContext = spanFrame->GetStyleContext();
   nsIRenderingContext* rc = mBlockReflowState->rendContext;
   nsLayoutUtils::SetFontFromStyle(mBlockReflowState->rendContext, styleContext);
   nsCOMPtr<nsIFontMetrics> fm;
   rc->GetFontMetrics(*getter_AddRefs(fm));
 
-  PRBool preMode = (mStyleText->mWhiteSpace == NS_STYLE_WHITESPACE_PRE) ||
-    (mStyleText->mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP);
+  PRBool preMode = mStyleText->WhiteSpaceIsSignificant();
 
   // See if the span is an empty continuation. It's an empty continuation iff:
   // - it has a prev-in-flow
   // - it has no next in flow
   // - it's zero sized
   nsIFrame* spanNextInFlow = spanFrame->GetNextInFlow();
   nsIFrame* spanPrevInFlow = spanFrame->GetPrevInFlow();
   PRBool emptyContinuation = spanPrevInFlow && !spanNextInFlow &&
--- a/layout/inspector/src/inDOMUtils.cpp
+++ b/layout/inspector/src/inDOMUtils.cpp
@@ -99,18 +99,17 @@ inDOMUtils::IsIgnorableWhitespace(nsIDOM
   if (!presShell) {
     // Display:none iframe or something... Bail out
     return NS_OK;
   }
 
   nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
   if (frame) {
     const nsStyleText* text = frame->GetStyleText();
-    *aReturn = text->mWhiteSpace != NS_STYLE_WHITESPACE_PRE &&
-               text->mWhiteSpace != NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
+    *aReturn = !text->WhiteSpaceIsSignificant();
   }
   else {
     // empty inter-tag text node without frame, e.g., in between <table>\n<tr>
     *aReturn = PR_TRUE;
   }
 
   return NS_OK;
 }
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -362,16 +362,17 @@ CSS_KEY(outside, outside)
 CSS_KEY(overline, overline)
 CSS_KEY(padding, padding)
 CSS_KEY(padding-box, padding_box)
 CSS_KEY(pc, pc)
 CSS_KEY(physical, physical)
 CSS_KEY(pointer, pointer)
 CSS_KEY(portrait, portrait)
 CSS_KEY(pre, pre)
+CSS_KEY(pre-wrap, pre_wrap)
 CSS_KEY(progress, progress)
 CSS_KEY(pt, pt)
 CSS_KEY(px, px)
 CSS_KEY(rad, rad)
 CSS_KEY(read-only, read_only)
 CSS_KEY(read-write, read_write)
 CSS_KEY(relative, relative)
 CSS_KEY(repeat, repeat)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -952,17 +952,18 @@ const PRInt32 nsCSSProps::kVolumeKTable[
   eCSSKeyword_loud, NS_STYLE_VOLUME_LOUD,
   eCSSKeyword_x_loud, NS_STYLE_VOLUME_X_LOUD,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const PRInt32 nsCSSProps::kWhitespaceKTable[] = {
   eCSSKeyword_pre, NS_STYLE_WHITESPACE_PRE,
   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
 };
 
 const PRInt32 nsCSSProps::kWidthKTable[] = {
   eCSSKeyword__moz_max_content, NS_STYLE_WIDTH_MAX_CONTENT,
   eCSSKeyword__moz_min_content, NS_STYLE_WIDTH_MIN_CONTENT,
   eCSSKeyword__moz_fit_content, NS_STYLE_WIDTH_FIT_CONTENT,
   eCSSKeyword__moz_available, NS_STYLE_WIDTH_AVAILABLE,
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -692,22 +692,22 @@ struct nsStyleText {
 
   nsStyleCoord  mLetterSpacing;         // [inherited] 
   nsStyleCoord  mLineHeight;            // [inherited] 
   nsStyleCoord  mTextIndent;            // [inherited] 
   nsStyleCoord  mWordSpacing;           // [inherited] 
   
   PRBool WhiteSpaceIsSignificant() const {
     return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
-           mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
+           mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
   }
 
   PRBool WhiteSpaceCanWrap() const {
     return mWhiteSpace == NS_STYLE_WHITESPACE_NORMAL ||
-           mWhiteSpace == NS_STYLE_WHITESPACE_MOZ_PRE_WRAP;
+           mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
   }
 };
 
 struct nsStyleVisibility {
   nsStyleVisibility(nsPresContext* aPresContext);
   nsStyleVisibility(const nsStyleVisibility& aVisibility);
   ~nsStyleVisibility() {}
 
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -1558,17 +1558,17 @@ var gCSSProperties = {
 		other_values: [ "0", "100.0", "99.7", "47", "3.2", "silent", "x-soft", "soft", "loud", "x-loud" ],
 		invalid_values: [" -0.01", "100.2", "108", "-3" ]
 	},
 	"white-space": {
 		domProp: "whiteSpace",
 		inherited: true,
 		type: CSS_TYPE_LONGHAND,
 		initial_values: [ "normal" ],
-		other_values: [ "pre", "nowrap" ],
+		other_values: [ "pre", "nowrap", "pre-wrap" ],
 		invalid_values: []
 	},
 	"widows": {
 		domProp: "widows",
 		inherited: true,
 		backend_only: true,
 		type: CSS_TYPE_LONGHAND,
 		// XXX requires display:block