зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1225864 - New flag OutputDisallowLineBreaking to disallow line breaking. r=masayuki.
This commit is contained in:
Родитель
b366fdfc09
Коммит
6b710fa7ee
|
@ -35,7 +35,7 @@ interface nsIDocumentEncoderNodeFixup : nsISupports
|
|||
nsIDOMNode fixupNode(in nsIDOMNode aNode, out boolean aSerializeCloneKids);
|
||||
};
|
||||
|
||||
[scriptable, uuid(e5ec69d7-eaa7-4de7-986b-455e17c7f71a)]
|
||||
[scriptable, uuid(21f112df-d96f-47da-bfcb-5331273003d1)]
|
||||
interface nsIDocumentEncoder : nsISupports
|
||||
{
|
||||
// Output methods flag bits. There are a frightening number of these,
|
||||
|
@ -240,6 +240,13 @@ interface nsIDocumentEncoder : nsISupports
|
|||
*/
|
||||
const unsigned long OutputRubyAnnotation = (1 << 26);
|
||||
|
||||
/**
|
||||
* Disallow breaking of long character strings. This is important
|
||||
* for serializing e-mail which contains CJK strings. These must
|
||||
* not be broken just as "normal" longs strings aren't broken.
|
||||
*/
|
||||
const unsigned long OutputDisallowLineBreaking = (1 << 27);
|
||||
|
||||
/**
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
* @param aDocument Document to encode.
|
||||
|
|
|
@ -144,7 +144,7 @@ nsPlainTextSerializer::Init(uint32_t aFlags, uint32_t aWrapColumn,
|
|||
mWrapColumn = aWrapColumn;
|
||||
|
||||
// Only create a linebreaker if we will handle wrapping.
|
||||
if (MayWrap()) {
|
||||
if (MayWrap() && MayBreakLines()) {
|
||||
mLineBreaker = nsContentUtils::LineBreaker();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,10 @@ private:
|
|||
((mFlags & nsIDocumentEncoder::OutputFormatted) ||
|
||||
(mFlags & nsIDocumentEncoder::OutputWrap));
|
||||
}
|
||||
inline bool MayBreakLines()
|
||||
{
|
||||
return !(mFlags & nsIDocumentEncoder::OutputDisallowLineBreaking);
|
||||
}
|
||||
|
||||
inline bool DoOutput()
|
||||
{
|
||||
|
|
|
@ -112,6 +112,8 @@ nsXMLContentSerializer::Init(uint32_t aFlags, uint32_t aWrapColumn,
|
|||
|
||||
mDoWrap = (mFlags & nsIDocumentEncoder::OutputWrap && !mDoRaw);
|
||||
|
||||
mAllowLineBreaking = !(mFlags & nsIDocumentEncoder::OutputDisallowLineBreaking);
|
||||
|
||||
if (!aWrapColumn) {
|
||||
mMaxColumn = 72;
|
||||
}
|
||||
|
@ -1539,23 +1541,25 @@ nsXMLContentSerializer::AppendWrapped_NonWhitespaceSequence(
|
|||
// we must wrap
|
||||
onceAgainBecauseWeAddedBreakInFront = false;
|
||||
bool foundWrapPosition = false;
|
||||
int32_t wrapPosition;
|
||||
int32_t wrapPosition = 0;
|
||||
|
||||
nsILineBreaker *lineBreaker = nsContentUtils::LineBreaker();
|
||||
if (mAllowLineBreaking) {
|
||||
nsILineBreaker *lineBreaker = nsContentUtils::LineBreaker();
|
||||
|
||||
wrapPosition = lineBreaker->Prev(aSequenceStart,
|
||||
(aEnd - aSequenceStart),
|
||||
(aPos - aSequenceStart) + 1);
|
||||
if (wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
foundWrapPosition = true;
|
||||
}
|
||||
else {
|
||||
wrapPosition = lineBreaker->Next(aSequenceStart,
|
||||
wrapPosition = lineBreaker->Prev(aSequenceStart,
|
||||
(aEnd - aSequenceStart),
|
||||
(aPos - aSequenceStart));
|
||||
(aPos - aSequenceStart) + 1);
|
||||
if (wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
foundWrapPosition = true;
|
||||
}
|
||||
else {
|
||||
wrapPosition = lineBreaker->Next(aSequenceStart,
|
||||
(aEnd - aSequenceStart),
|
||||
(aPos - aSequenceStart));
|
||||
if (wrapPosition != NS_LINEBREAKER_NEED_MORE_TEXT) {
|
||||
foundWrapPosition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundWrapPosition) {
|
||||
|
|
|
@ -355,6 +355,9 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
// true = wrapping should be done (OutputWrap flag)
|
||||
bool mDoWrap;
|
||||
|
||||
// true = we can break lines (OutputDisallowLineBreaking flag)
|
||||
bool mAllowLineBreaking;
|
||||
|
||||
// number of maximum column in a line, in the wrap mode
|
||||
uint32_t mMaxColumn;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче