mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1574463: remove unused nsIDocumentEncoder::OutputNonTextContentAsPlaceholder
. r=hsivonen
Doesn't seem to be used by comm-central/Thunderbird. Differential Revision: https://phabricator.services.mozilla.com/D42302 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
881f30fe67
commit
5e6d66382d
@ -740,8 +740,7 @@ nsresult nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
|
||||
nsINode* maybeFixedNode =
|
||||
&fixupNodeDeterminer.GetFixupNodeFallBackToOriginalNode();
|
||||
|
||||
if ((mFlags & SkipInvisibleContent) &&
|
||||
!(mFlags & OutputNonTextContentAsPlaceholder)) {
|
||||
if (mFlags & SkipInvisibleContent) {
|
||||
if (aNode->IsContent()) {
|
||||
if (nsIFrame* frame = aNode->AsContent()->GetPrimaryFrame()) {
|
||||
if (!frame->IsSelectable(nullptr)) {
|
||||
|
@ -191,12 +191,6 @@ interface nsIDocumentEncoder : nsISupports
|
||||
*/
|
||||
const unsigned long OutputIgnoreMozDirty = (1 << 22);
|
||||
|
||||
/**
|
||||
* Output the content of non-text elements as the placehodler character
|
||||
* U+FFFC (OBJECT REPLACEMENT CHARACTER, only for serializing to plaintext).
|
||||
*/
|
||||
const unsigned long OutputNonTextContentAsPlaceholder = (1 << 23);
|
||||
|
||||
/**
|
||||
* Serialize in a way that is suitable for copying a plaintext version of the
|
||||
* document to the clipboard. This can for example cause line endings to be
|
||||
|
@ -242,21 +242,6 @@ bool nsPlainTextSerializer::PopBool(nsTArray<bool>& aStack) {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool nsPlainTextSerializer::ShouldReplaceContainerWithPlaceholder(
|
||||
nsAtom* aTag) {
|
||||
// If nsIDocumentEncoder::OutputNonTextContentAsPlaceholder is set,
|
||||
// non-textual container element should be serialized as placeholder
|
||||
// character and its child nodes should be ignored. See bug 895239.
|
||||
if (!(mFlags & nsIDocumentEncoder::OutputNonTextContentAsPlaceholder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (aTag == nsGkAtoms::audio) || (aTag == nsGkAtoms::canvas) ||
|
||||
(aTag == nsGkAtoms::iframe) || (aTag == nsGkAtoms::meter) ||
|
||||
(aTag == nsGkAtoms::progress) || (aTag == nsGkAtoms::object) ||
|
||||
(aTag == nsGkAtoms::svg) || (aTag == nsGkAtoms::video);
|
||||
}
|
||||
|
||||
bool nsPlainTextSerializer::IsIgnorableRubyAnnotation(nsAtom* aTag) {
|
||||
if (mWithRubyAnnotation) {
|
||||
return false;
|
||||
@ -453,17 +438,6 @@ nsPlainTextSerializer::AppendDocumentStart(Document* aDocument,
|
||||
}
|
||||
|
||||
nsresult nsPlainTextSerializer::DoOpenContainer(nsAtom* aTag) {
|
||||
// Check if we need output current node as placeholder character and ignore
|
||||
// child nodes.
|
||||
if (ShouldReplaceContainerWithPlaceholder(mElement->NodeInfo()->NameAtom())) {
|
||||
if (mIgnoredChildNodeLevel == 0) {
|
||||
// Serialize current node as placeholder character
|
||||
Write(NS_LITERAL_STRING(u"\xFFFC"));
|
||||
}
|
||||
// Ignore child nodes.
|
||||
mIgnoredChildNodeLevel++;
|
||||
return NS_OK;
|
||||
}
|
||||
if (IsIgnorableRubyAnnotation(aTag)) {
|
||||
// Ignorable ruby annotation shouldn't be replaced by a placeholder
|
||||
// character, neither any of its descendants.
|
||||
@ -774,10 +748,6 @@ nsresult nsPlainTextSerializer::DoOpenContainer(nsAtom* aTag) {
|
||||
}
|
||||
|
||||
nsresult nsPlainTextSerializer::DoCloseContainer(nsAtom* aTag) {
|
||||
if (ShouldReplaceContainerWithPlaceholder(mElement->NodeInfo()->NameAtom())) {
|
||||
mIgnoredChildNodeLevel--;
|
||||
return NS_OK;
|
||||
}
|
||||
if (IsIgnorableRubyAnnotation(aTag)) {
|
||||
mIgnoredChildNodeLevel--;
|
||||
return NS_OK;
|
||||
@ -1062,8 +1032,6 @@ nsresult nsPlainTextSerializer::DoAddLeaf(nsAtom* aTag) {
|
||||
Write(line);
|
||||
|
||||
EnsureVerticalSpace(0);
|
||||
} else if (mFlags & nsIDocumentEncoder::OutputNonTextContentAsPlaceholder) {
|
||||
Write(NS_LITERAL_STRING(u"\xFFFC"));
|
||||
} else if (aTag == nsGkAtoms::img) {
|
||||
/* Output (in decreasing order of preference)
|
||||
alt, title or nothing */
|
||||
|
@ -126,7 +126,6 @@ class nsPlainTextSerializer final : public nsIContentSerializer {
|
||||
void PushBool(nsTArray<bool>& aStack, bool aValue);
|
||||
bool PopBool(nsTArray<bool>& aStack);
|
||||
|
||||
bool ShouldReplaceContainerWithPlaceholder(nsAtom* aTag);
|
||||
bool IsIgnorableRubyAnnotation(nsAtom* aTag);
|
||||
|
||||
bool IsElementPreformatted(mozilla::dom::Element* aElement);
|
||||
@ -234,8 +233,6 @@ class nsPlainTextSerializer final : public nsIContentSerializer {
|
||||
// variable, but that causes issues with OpenBSD and module unloading.
|
||||
const nsString kSpace;
|
||||
|
||||
// If nsIDocumentEncoder::OutputNonTextContentAsPlaceholder is set, the child
|
||||
// nodes of specific nodes - <iframe>, <canvas>, etc. should be ignored.
|
||||
// mIgnoredChildNodeLevel is used to tell if current node is an ignorable
|
||||
// child node. The initial value of mIgnoredChildNodeLevel is 0. When
|
||||
// serializer enters those specific nodes, mIgnoredChildNodeLevel increases
|
||||
|
@ -578,10 +578,8 @@ skip-if = fission # Crashes: @ mozilla::dom::ContentParent::RecvDetachBrowsingCo
|
||||
[test_bug869002.html]
|
||||
[test_bug869006.html]
|
||||
[test_bug876282.html]
|
||||
[test_bug890580.html]
|
||||
[test_bug891952.html]
|
||||
[test_bug894874.html]
|
||||
[test_bug895239.html]
|
||||
[test_bug895974.html]
|
||||
[test_bug907892.html]
|
||||
fail-if = fission
|
||||
|
@ -1,57 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=890580
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 883129</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
function testPaintextSerializerWithPlaceHolder() {
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
|
||||
// Create a plaintext encoder with the flag OutputNonTextContentAsPlaceholder.
|
||||
var encoder = SpecialPowers.Cu.createDocumentEncoder("text/plain");
|
||||
var flags = de.OutputRaw |
|
||||
de.OutputNonTextContentAsPlaceholder;
|
||||
encoder.init(document, "text/plain", flags);
|
||||
|
||||
function toPlaintext(id) {
|
||||
var element = document.getElementById(id);
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
encoder.setRange(range);
|
||||
return encoder.encodeToString();
|
||||
}
|
||||
|
||||
// The follows are test cases.
|
||||
is(toPlaintext("case1"), "This is a button. Hello!", "test with <button>");
|
||||
is(toPlaintext("case2"), "There is an\uFFFCimage.", "test with <img>");
|
||||
is(toPlaintext("case3"), "\uFFFC with text.", "test with <input>");
|
||||
is(toPlaintext("case4"), "There is an\uFFFCimage and a \uFFFC.",
|
||||
"test with <img> and <input>");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(testPaintextSerializerWithPlaceHolder);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=890580">Mozilla Bug 890580</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<span id="case1"><button id="b">This is a button.</button> Hello!</span>
|
||||
<span id="case2">There is an<img>image.</span>
|
||||
<span id="case3"><input type="button" value="Input button"> with text.</span>
|
||||
<span id="case4" contenteditable="true">There is an<img>image and
|
||||
a <input type="button" value="button">.</span>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,122 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=895239
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 895239</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
function testPaintextSerializerWithPlaceHolder() {
|
||||
|
||||
const de = SpecialPowers.Ci.nsIDocumentEncoder;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
|
||||
// Create a plaintext encoder with the flag OutputNonTextContentAsPlaceholder.
|
||||
var encoder = SpecialPowers.Cu.createDocumentEncoder("text/plain");
|
||||
var flags = de.OutputRaw |
|
||||
de.OutputNonTextContentAsPlaceholder;
|
||||
encoder.init(document, "text/plain", flags);
|
||||
|
||||
function toPlaintext(id) {
|
||||
var element = document.getElementById(id);
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
encoder.setRange(range);
|
||||
return encoder.encodeToString();
|
||||
}
|
||||
|
||||
// Test cases to serialize all nodes including invisible nodes.
|
||||
is(toPlaintext("case1"), "This is an audio \uFFFC! ", "test with <audio>");
|
||||
is(toPlaintext("case2"), "This is a canvas \uFFFC! ", "test with <canvas>");
|
||||
is(toPlaintext("case3"), "This is an iframe \uFFFC! ", "test with one <iframe>");
|
||||
is(toPlaintext("case4"), "One iframe \uFFFC with another iframe \uFFFC. ", "test with two <iframes>");
|
||||
is(toPlaintext("case5"), "This is a meter \uFFFC! ", "test with <meter>");
|
||||
is(toPlaintext("case6"), "This is a progress \uFFFC! ", "test with <progress>");
|
||||
is(toPlaintext("case7"), "This is an object \uFFFC! ", "test with <object>");
|
||||
is(toPlaintext("case8"), "This is a svg \uFFFC! ", "test with <svg>");
|
||||
is(toPlaintext("case9"), "This is a video \uFFFC! ", "test with <video>");
|
||||
is(toPlaintext("case10"), "This is a video \uFFFC! ", "test with nested tags");
|
||||
|
||||
// Test cases to serialize visible nodes only.
|
||||
encoder.init(document, "text/plain", flags | de.SkipInvisibleContent);
|
||||
is(toPlaintext("case1"), "This is an audio \uFFFC! ", "test with <audio> for visible nodes");
|
||||
is(toPlaintext("case2"), "This is a canvas \uFFFC! ", "test with <canvas> for visible nodes");
|
||||
is(toPlaintext("case3"), "This is an iframe \uFFFC! ", "test with one <iframe> for visible nodes");
|
||||
is(toPlaintext("case4"), "One iframe \uFFFC with another iframe . ", "test with two <iframes> for visible nodes");
|
||||
is(toPlaintext("case5"), "This is a meter \uFFFC! ", "test with <meter> for visible nodes");
|
||||
is(toPlaintext("case6"), "This is a progress \uFFFC! ", "test with <progress> for visible nodes");
|
||||
is(toPlaintext("case7"), "This is an object \uFFFC! ", "test with <object> for visible nodes");
|
||||
is(toPlaintext("case8"), "This is a svg \uFFFC! ", "test with <svg> for visible nodes");
|
||||
is(toPlaintext("case9"), "This is a video \uFFFC! ", "test with <video> for visible nodes");
|
||||
is(toPlaintext("case10"), "This is a video \uFFFC! ", "test with nested tags for visible nodes");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(testPaintextSerializerWithPlaceHolder);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=895239">Mozilla Bug 895239</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<span id="case1">This is an audio
|
||||
<audio controls="controls">
|
||||
Your browser does not support <code>audio</code> element.
|
||||
</audio>!
|
||||
</span>
|
||||
<span id="case2">This is a canvas
|
||||
<canvas height="100" width="100">
|
||||
Your browser does not support canvas element.
|
||||
</canvas>!
|
||||
</span>
|
||||
<span id="case3">This is an iframe
|
||||
<iframe src="about:blank">
|
||||
Your browser does not support iframes.
|
||||
</iframe>!
|
||||
</span>
|
||||
<span id="case4">One iframe
|
||||
<iframe src="about:blank">
|
||||
Your browser does not support iframes.
|
||||
</iframe> with another iframe
|
||||
<iframe src="about:blank" style="display: none"></iframe>.
|
||||
</span>
|
||||
<span id="case5">This is a meter
|
||||
<meter min="0" max="100" value="50">
|
||||
50%
|
||||
</meter>!
|
||||
</span>
|
||||
<span id="case6">This is a progress
|
||||
<progress max="100" value="70">
|
||||
70%
|
||||
</progress>!
|
||||
</span>
|
||||
<span id="case7">This is an object
|
||||
<object type="application/x-shockware-flash">
|
||||
<a href="#">Download the plugin.</a>
|
||||
</object>!
|
||||
</span>
|
||||
<span id="case8">This is a svg
|
||||
<svg height="100" width="100">
|
||||
Your browser does not support svg.
|
||||
<circle cx="100" cy="100" r="80" fill="green"></circle>
|
||||
</svg>!
|
||||
</span>
|
||||
<span id="case9">This is a video
|
||||
<video>
|
||||
Your browser does not support videos.
|
||||
</video>!
|
||||
</span>
|
||||
<span id="case10">This is a video
|
||||
<video>
|
||||
Your browser does not support videos.<iframe src="about:blank"></iframe>
|
||||
</video>!
|
||||
</span>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user