зеркало из https://github.com/mozilla/pjs.git
Count U+000C as a whitespace character for separating class attributes. (Bug 437915) r=bzbarsky sr=sicking
This commit is contained in:
Родитель
862294af46
Коммит
f22aac5075
|
@ -369,6 +369,16 @@ public:
|
|||
*/
|
||||
static PRBool IsPunctuationMark(PRUnichar aChar);
|
||||
|
||||
/*
|
||||
* Is the character an HTML whitespace character?
|
||||
*
|
||||
* We define whitespace using the list in HTML5 and css3-selectors:
|
||||
* U+0009, U+000A, U+000C, U+000D, U+0020
|
||||
*
|
||||
* HTML 4.01 also lists U+200B (zero-width space).
|
||||
*/
|
||||
static PRBool IsHTMLWhitespace(PRUnichar aChar);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsTPtrArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsISVGValue.h"
|
||||
|
@ -733,7 +734,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
|||
aValue.EndReading(end);
|
||||
|
||||
// skip initial whitespace
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter)) {
|
||||
while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
|
@ -747,7 +748,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
|||
// get first - and often only - atom
|
||||
do {
|
||||
++iter;
|
||||
} while (iter != end && !nsCRT::IsAsciiSpace(*iter));
|
||||
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
||||
|
||||
nsCOMPtr<nsIAtom> classAtom = do_GetAtom(Substring(start, iter));
|
||||
if (!classAtom) {
|
||||
|
@ -756,7 +757,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
|||
}
|
||||
|
||||
// skip whitespace
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter)) {
|
||||
while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
|
@ -786,7 +787,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
|||
|
||||
do {
|
||||
++iter;
|
||||
} while (iter != end && !nsCRT::IsAsciiSpace(*iter));
|
||||
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
||||
|
||||
classAtom = do_GetAtom(Substring(start, iter));
|
||||
|
||||
|
@ -796,7 +797,7 @@ nsAttrValue::ParseAtomArray(const nsAString& aValue)
|
|||
}
|
||||
|
||||
// skip whitespace
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter)) {
|
||||
while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
|
||||
++iter;
|
||||
}
|
||||
} while (iter != end);
|
||||
|
|
|
@ -684,6 +684,18 @@ nsContentUtils::IsPunctuationMark(PRUnichar aChar)
|
|||
return CCMAP_HAS_CHAR(gPuncCharsCCMap, aChar);
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRBool
|
||||
nsContentUtils::IsHTMLWhitespace(PRUnichar aChar)
|
||||
{
|
||||
return aChar == PRUnichar(0x0009) ||
|
||||
aChar == PRUnichar(0x000A) ||
|
||||
aChar == PRUnichar(0x000C) ||
|
||||
aChar == PRUnichar(0x000D) ||
|
||||
aChar == PRUnichar(0x0020);
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsContentUtils::GetOfflineAppManifest(nsIDOMWindow *aWindow, nsIURI **aURI)
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static nsTArray< nsCOMPtr<nsIAtom> >* sSystemMetrics = 0;
|
||||
|
@ -1018,13 +1019,13 @@ static PRBool ValueIncludes(const nsSubstring& aValueList,
|
|||
|
||||
while (p < p_end) {
|
||||
// skip leading space
|
||||
while (p != p_end && nsCRT::IsAsciiSpace(*p))
|
||||
while (p != p_end && nsContentUtils::IsHTMLWhitespace(*p))
|
||||
++p;
|
||||
|
||||
const PRUnichar *val_start = p;
|
||||
|
||||
// look for space or end
|
||||
while (p != p_end && !nsCRT::IsAsciiSpace(*p))
|
||||
while (p != p_end && !nsContentUtils::IsHTMLWhitespace(*p))
|
||||
++p;
|
||||
|
||||
const PRUnichar *val_end = p;
|
||||
|
|
|
@ -93,6 +93,7 @@ _TEST_FILES = test_bug73586.html \
|
|||
test_bug401046.html \
|
||||
test_bug405818.html \
|
||||
test_bug412901.html \
|
||||
test_bug437915.html \
|
||||
test_compute_data_with_start_struct.html \
|
||||
test_dont_use_document_colors.html \
|
||||
test_inherit_storage.html \
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=437915
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 437915</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<style type="text/css">
|
||||
|
||||
div.classvalue { text-decoration: underline; }
|
||||
div[title~="titlevalue"] { visibility: hidden; }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=437915">Mozilla Bug 437915</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 437915 **/
|
||||
|
||||
var div = document.getElementById("content");
|
||||
var cs = document.defaultView.getComputedStyle(div, "");
|
||||
|
||||
var chars = {
|
||||
0x09: true, // tab
|
||||
0x0a: true, // newline
|
||||
0x0b: false, // vertical tab (MAY CHANGE IN FUTURE!)
|
||||
0x0c: true, // form feed
|
||||
0x0d: true, // carriage return
|
||||
0x0e: false,
|
||||
0x20: true, // space
|
||||
0x2003: false,
|
||||
0x200b: false,
|
||||
0x2028: false,
|
||||
0x2029: false,
|
||||
0x3000: false
|
||||
};
|
||||
|
||||
var wsmap = {
|
||||
false: { str: " NOT", "text-decoration": "none", "visibility": "visible" },
|
||||
true: { str: "", "text-decoration": "underline", "visibility": "hidden" }
|
||||
};
|
||||
|
||||
for (var char in chars) {
|
||||
var is_whitespace = chars[char];
|
||||
var mapent = wsmap[is_whitespace];
|
||||
div.setAttribute("class", "classvalue" + String.fromCharCode(char) + "b")
|
||||
div.setAttribute("title", "a" + String.fromCharCode(char) + "titlevalue")
|
||||
for each (var prop in ["text-decoration", "visibility"]) {
|
||||
is(cs.getPropertyValue(prop), mapent[prop],
|
||||
"Character " + char + " should" + mapent.str +
|
||||
" be treated as whitespace ("
|
||||
+ prop + " should be " + mapent[prop] + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче