diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index db6ea81d6aa..acf4566cb5b 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -49,6 +49,18 @@ class nsXPCClassInfo; namespace mozilla { namespace dom { +/** + * @return true if aChar is what the DOM spec defines as 'space character'. + * http://dom.spec.whatwg.org/#space-character + */ +inline bool IsSpaceCharacter(PRUnichar aChar) { + return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' || + aChar == '\f'; +} +inline bool IsSpaceCharacter(char aChar) { + return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' || + aChar == '\f'; +} class Element; class EventHandlerNonNull; class OnErrorEventHandlerNonNull; diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 34e5b285201..163700ad889 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -844,6 +844,7 @@ nsGenericDOMDataNode::AppendText(const PRUnichar* aBuffer, bool nsGenericDOMDataNode::TextIsOnlyWhitespace() { + // FIXME: should this method take content language into account? if (mText.Is2b()) { // The fragment contains non-8bit characters and such characters // are never considered whitespace. @@ -856,7 +857,7 @@ nsGenericDOMDataNode::TextIsOnlyWhitespace() while (cp < end) { char ch = *cp; - if (!XP_IS_SPACE(ch)) { + if (!dom::IsSpaceCharacter(ch)) { return false; } diff --git a/content/base/src/nsTextFragment.h b/content/base/src/nsTextFragment.h index 46d06156a99..1a9d74429bd 100644 --- a/content/base/src/nsTextFragment.h +++ b/content/base/src/nsTextFragment.h @@ -24,22 +24,6 @@ class nsCString; // XXX nsTextFragmentPool? -// XXX these need I18N spankage -#define XP_IS_SPACE(_ch) \ - (((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n') || ((_ch) == '\r')) - -#define XP_IS_UPPERCASE(_ch) \ - (((_ch) >= 'A') && ((_ch) <= 'Z')) - -#define XP_IS_LOWERCASE(_ch) \ - (((_ch) >= 'a') && ((_ch) <= 'z')) - -#define XP_TO_LOWER(_ch) ((_ch) | 32) - -#define XP_TO_UPPER(_ch) ((_ch) & ~32) - -#define XP_IS_SPACE_W XP_IS_SPACE - /** * A fragment of text. If mIs2b is 1 then the m2b pointer is valid * otherwise the m1b pointer is valid. If m1b is used then each byte diff --git a/content/xbl/src/nsXBLContentSink.cpp b/content/xbl/src/nsXBLContentSink.cpp index b4f5d73fa4c..9cb22a5a23f 100644 --- a/content/xbl/src/nsXBLContentSink.cpp +++ b/content/xbl/src/nsXBLContentSink.cpp @@ -150,7 +150,7 @@ nsXBLContentSink::FlushText(bool aReleaseTextNode) const PRUnichar* end = mText + mTextLength; while (cp < end) { PRUnichar ch = *cp++; - if (!XP_IS_SPACE(ch)) { + if (!dom::IsSpaceCharacter(ch)) { isWS = false; break; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 77a49c3cb0c..ac5d4fd3245 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -10337,7 +10337,8 @@ FirstLetterCount(const nsTextFragment* aFragment) int32_t i, n = aFragment->GetLength(); for (i = 0; i < n; i++) { PRUnichar ch = aFragment->CharAt(i); - if (XP_IS_SPACE(ch)) { + // FIXME: take content language into account when deciding whitespace. + if (dom::IsSpaceCharacter(ch)) { if (firstLetterLength) { break; } diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index e4d7586d428..a716e45e1d2 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -937,7 +937,7 @@ nsImageFrame::MeasureString(const PRUnichar* aString, uint32_t len = aLength; bool trailingSpace = false; for (int32_t i = 0; i < aLength; i++) { - if (XP_IS_SPACE(aString[i]) && (i > 0)) { + if (dom::IsSpaceCharacter(aString[i]) && (i > 0)) { len = i; // don't include the space when measuring trailingSpace = true; break; diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 5d43adec78e..215a0286cc8 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -638,7 +638,7 @@ int32_t nsTextFrame::GetInFlowContentLength() { return endFlow - mContentOffset; } -// Smarter versions of XP_IS_SPACE. +// Smarter versions of dom::IsSpaceCharacter. // Unicode is really annoying; sometimes a space character isn't whitespace --- // when it combines with another character // So we have several versions of IsSpace for use in different contexts. diff --git a/layout/reftests/bugs/814677-ref.html b/layout/reftests/bugs/814677-ref.html new file mode 100644 index 00000000000..2a9ab492f51 --- /dev/null +++ b/layout/reftests/bugs/814677-ref.html @@ -0,0 +1,35 @@ + +
+ +