зеркало из https://github.com/mozilla/pjs.git
Bug 482921 part 8 - Start a new <pre> occasionally in View Source refixing bug 86355. r=bzbarsky.
This commit is contained in:
Родитель
bf66821602
Коммит
d82c23bb7c
|
@ -45,6 +45,10 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
// The old code had a limit of 16 tokens. 1300 is a number picked my measuring
|
||||
// the size of 16 tokens on cnn.com.
|
||||
#define NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD 1300
|
||||
|
||||
PRUnichar nsHtml5Highlighter::sComment[] =
|
||||
{ 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 };
|
||||
|
||||
|
@ -78,6 +82,7 @@ nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
|
|||
, mCStart(PR_INT32_MAX)
|
||||
, mPos(0)
|
||||
, mLineNumber(1)
|
||||
, mUnicharsInThisPre(0)
|
||||
, mInlinesOpen(0)
|
||||
, mInCharacters(false)
|
||||
, mBuffer(nsnull)
|
||||
|
@ -619,10 +624,25 @@ nsHtml5Highlighter::FlushChars()
|
|||
case '\n': {
|
||||
++i;
|
||||
if (mCStart < i) {
|
||||
AppendCharacters(buf, mCStart, i - mCStart);
|
||||
PRInt32 len = i - mCStart;
|
||||
AppendCharacters(buf, mCStart, len);
|
||||
mCStart = i;
|
||||
mUnicharsInThisPre += len;
|
||||
}
|
||||
++mLineNumber;
|
||||
if (mUnicharsInThisPre > NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD &&
|
||||
!mInlinesOpen && mInCharacters) {
|
||||
mUnicharsInThisPre = 0;
|
||||
// Split the pre. See bug 86355.
|
||||
Pop(); // span
|
||||
Pop(); // pre
|
||||
Push(nsGkAtoms::pre, nsnull);
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->InitAddLineNumberId(CurrentNode(), mLineNumber);
|
||||
Push(nsGkAtoms::span, nsnull);
|
||||
break;
|
||||
}
|
||||
Push(nsGkAtoms::span, nsnull);
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
|
@ -636,8 +656,10 @@ nsHtml5Highlighter::FlushChars()
|
|||
}
|
||||
}
|
||||
if (mCStart < mPos) {
|
||||
AppendCharacters(buf, mCStart, mPos - mCStart);
|
||||
PRInt32 len = mPos - mCStart;
|
||||
AppendCharacters(buf, mCStart, len);
|
||||
mCStart = mPos;
|
||||
mUnicharsInThisPre += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,6 +316,12 @@ class nsHtml5Highlighter
|
|||
*/
|
||||
PRInt32 mLineNumber;
|
||||
|
||||
/**
|
||||
* The number of PRUnichars flushed since the start of the current pre
|
||||
* block.
|
||||
*/
|
||||
PRInt32 mUnicharsInThisPre;
|
||||
|
||||
/**
|
||||
* The number of inline elements open inside the <pre> excluding the
|
||||
* span potentially wrapping a run of characters.
|
||||
|
|
Загрузка…
Ссылка в новой задаче