mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 814677 - Replace XP_IS_SPACE with dom::IsSpaceCharacter and add form-feed to match DOM spec. r=bz
This commit is contained in:
parent
c298a0ce6f
commit
0bae59cdf1
@ -49,6 +49,18 @@ class nsXPCClassInfo;
|
|||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
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 Element;
|
||||||
class EventHandlerNonNull;
|
class EventHandlerNonNull;
|
||||||
class OnErrorEventHandlerNonNull;
|
class OnErrorEventHandlerNonNull;
|
||||||
|
@ -844,6 +844,7 @@ nsGenericDOMDataNode::AppendText(const PRUnichar* aBuffer,
|
|||||||
bool
|
bool
|
||||||
nsGenericDOMDataNode::TextIsOnlyWhitespace()
|
nsGenericDOMDataNode::TextIsOnlyWhitespace()
|
||||||
{
|
{
|
||||||
|
// FIXME: should this method take content language into account?
|
||||||
if (mText.Is2b()) {
|
if (mText.Is2b()) {
|
||||||
// The fragment contains non-8bit characters and such characters
|
// The fragment contains non-8bit characters and such characters
|
||||||
// are never considered whitespace.
|
// are never considered whitespace.
|
||||||
@ -856,7 +857,7 @@ nsGenericDOMDataNode::TextIsOnlyWhitespace()
|
|||||||
while (cp < end) {
|
while (cp < end) {
|
||||||
char ch = *cp;
|
char ch = *cp;
|
||||||
|
|
||||||
if (!XP_IS_SPACE(ch)) {
|
if (!dom::IsSpaceCharacter(ch)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,22 +24,6 @@ class nsCString;
|
|||||||
|
|
||||||
// XXX nsTextFragmentPool?
|
// 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
|
* 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
|
* otherwise the m1b pointer is valid. If m1b is used then each byte
|
||||||
|
@ -150,7 +150,7 @@ nsXBLContentSink::FlushText(bool aReleaseTextNode)
|
|||||||
const PRUnichar* end = mText + mTextLength;
|
const PRUnichar* end = mText + mTextLength;
|
||||||
while (cp < end) {
|
while (cp < end) {
|
||||||
PRUnichar ch = *cp++;
|
PRUnichar ch = *cp++;
|
||||||
if (!XP_IS_SPACE(ch)) {
|
if (!dom::IsSpaceCharacter(ch)) {
|
||||||
isWS = false;
|
isWS = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -10337,7 +10337,8 @@ FirstLetterCount(const nsTextFragment* aFragment)
|
|||||||
int32_t i, n = aFragment->GetLength();
|
int32_t i, n = aFragment->GetLength();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
PRUnichar ch = aFragment->CharAt(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) {
|
if (firstLetterLength) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -937,7 +937,7 @@ nsImageFrame::MeasureString(const PRUnichar* aString,
|
|||||||
uint32_t len = aLength;
|
uint32_t len = aLength;
|
||||||
bool trailingSpace = false;
|
bool trailingSpace = false;
|
||||||
for (int32_t i = 0; i < aLength; i++) {
|
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
|
len = i; // don't include the space when measuring
|
||||||
trailingSpace = true;
|
trailingSpace = true;
|
||||||
break;
|
break;
|
||||||
|
@ -638,7 +638,7 @@ int32_t nsTextFrame::GetInFlowContentLength() {
|
|||||||
return endFlow - mContentOffset;
|
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 ---
|
// Unicode is really annoying; sometimes a space character isn't whitespace ---
|
||||||
// when it combines with another character
|
// when it combines with another character
|
||||||
// So we have several versions of IsSpace for use in different contexts.
|
// So we have several versions of IsSpace for use in different contexts.
|
||||||
|
35
layout/reftests/bugs/814677-ref.html
Normal file
35
layout/reftests/bugs/814677-ref.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html><head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Testcase for bug 814677</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
html,body {
|
||||||
|
color:black; background-color:white; font-size:16px; padding:0; margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span { display: table-cell; }
|
||||||
|
.t { display:table; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div class="t"><span>A</span></div><div class="t"><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div class="t"><span>A</span></div> <div class="t"><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div class="t"><span>A</span></div><div class="t"><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div class="t"><span>A</span></div> <div class="t"><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
34
layout/reftests/bugs/814677.html
Normal file
34
layout/reftests/bugs/814677.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html><head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Testcase for bug 814677</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
html,body {
|
||||||
|
color:black; background-color:white; font-size:16px; padding:0; margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span { display: table-cell; }
|
||||||
|
.pre { white-space:pre; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div><span>A</span>	<span>B</span></div>
|
||||||
|
<div><span>A</span>
<span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span><span>B</span></div>
|
||||||
|
<div><span>A</span>
<span>B</span></div>
|
||||||
|
<div><span>A</span> <span>B</span></div>
|
||||||
|
<div><span>A</span> <span>B</span></div>
|
||||||
|
|
||||||
|
<div class="pre"><span>A</span>	<span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span>
<span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span><span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span><span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span>
<span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span> <span>B</span></div>
|
||||||
|
<div class="pre"><span>A</span> <span>B</span></div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1732,4 +1732,5 @@ fuzzy(40,800) == 797797-2.html 797797-2-ref.html # 'opacity:N' and rgba(,,,N) te
|
|||||||
== 804323-1.html 804323-1-ref.html
|
== 804323-1.html 804323-1-ref.html
|
||||||
== 811301-1.html 811301-1-ref.html
|
== 811301-1.html 811301-1-ref.html
|
||||||
== 812824-1.html 812824-1-ref.html
|
== 812824-1.html 812824-1-ref.html
|
||||||
|
== 814677.html 814677-ref.html
|
||||||
== 815593-1.html 815593-1-ref.html
|
== 815593-1.html 815593-1-ref.html
|
||||||
|
@ -1169,11 +1169,11 @@ CompressIndex(int index, const nsTextFragment*fragment)
|
|||||||
if (fragment->Is2b()) {
|
if (fragment->Is2b()) {
|
||||||
const PRUnichar *data=fragment->Get2b();
|
const PRUnichar *data=fragment->Get2b();
|
||||||
while(*data && index) {
|
while(*data && index) {
|
||||||
if (XP_IS_SPACE_W(*data)){
|
if (dom::IsSpaceCharacter(*data)){
|
||||||
do {
|
do {
|
||||||
++data;
|
++data;
|
||||||
--index;
|
--index;
|
||||||
}while(XP_IS_SPACE_W(*data) && index);
|
}while(dom::IsSpaceCharacter(*data) && index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++data;
|
++data;
|
||||||
@ -1185,11 +1185,11 @@ CompressIndex(int index, const nsTextFragment*fragment)
|
|||||||
else {
|
else {
|
||||||
const char *data=fragment->Get1b();
|
const char *data=fragment->Get1b();
|
||||||
while(*data && index) {
|
while(*data && index) {
|
||||||
if (XP_IS_SPACE_W(*data)){
|
if (dom::IsSpaceCharacter(*data)){
|
||||||
do {
|
do {
|
||||||
++data;
|
++data;
|
||||||
--index;
|
--index;
|
||||||
}while(XP_IS_SPACE_W(*data) && index);
|
}while(dom::IsSpaceCharacter(*data) && index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++data;
|
++data;
|
||||||
|
@ -803,7 +803,8 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange,
|
|||||||
if (textFrag) {
|
if (textFrag) {
|
||||||
// look for non whitespace character before start offset
|
// look for non whitespace character before start offset
|
||||||
for (int32_t index = 0; index < startOffset; index++) {
|
for (int32_t index = 0; index < startOffset; index++) {
|
||||||
if (!XP_IS_SPACE(textFrag->CharAt(index))) {
|
// FIXME: take content language into account when deciding whitespace.
|
||||||
|
if (!mozilla::dom::IsSpaceCharacter(textFrag->CharAt(index))) {
|
||||||
*aIsStartingLink = false; // not at start of a node
|
*aIsStartingLink = false; // not at start of a node
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user