Bug 983465. Disable collapsing-text frame construction optimization on a per-document basis. r=bz

--HG--
extra : rebase_source : fc2059ac826e001660fb7233d775f8a046467f6b
This commit is contained in:
Robert O'Callahan 2014-04-03 03:48:51 -04:00
Родитель 579e0bc4c5
Коммит 458a675e16
4 изменённых файлов: 13 добавлений и 14 удалений

Просмотреть файл

@ -51,10 +51,6 @@ enum {
// bit is set, and if so it indicates whether we're only whitespace or
// not.
NS_TEXT_IS_ONLY_WHITESPACE = DATA_NODE_FLAG_BIT(3),
// This bit is set to indicate that we must create frames for this text node
// even if it's only whitespace next to a block boundary.
NS_CREATE_FRAME_FOR_IGNORABLE_WHITESPACE = DATA_NODE_FLAG_BIT(4)
};
// Make sure we have enough space for those bits

Просмотреть файл

@ -2751,8 +2751,10 @@ GetTextFrameForContent(nsIContent* aContent)
{
nsIPresShell* presShell = aContent->OwnerDoc()->GetShell();
if (presShell) {
nsIFrame* frame = presShell->FrameConstructor()->EnsureFrameForTextNode(
presShell->FrameConstructor()->EnsureFrameForTextNode(
static_cast<nsGenericDOMDataNode*>(aContent));
aContent->OwnerDoc()->FlushPendingNotifications(Flush_Layout);
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame && frame->GetType() == nsGkAtoms::textFrame) {
return static_cast<nsTextFrame*>(frame);
}
@ -2804,7 +2806,7 @@ static void CollectClientRects(nsLayoutUtils::RectCallback* aCollector,
return;
}
aStartParent->GetCurrentDoc()->FlushPendingNotifications(Flush_Layout);
aStartParent->OwnerDoc()->FlushPendingNotifications(Flush_Layout);
// Recheck whether we're still in the document
if (!aStartParent->IsInDoc()) {

Просмотреть файл

@ -1425,6 +1425,7 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument,
, mCountersDirty(false)
, mIsDestroyingFrameTree(false)
, mHasRootAbsPosContainingBlock(false)
, mAlwaysCreateFramesForIgnorableWhitespace(false)
{
#ifdef DEBUG
static bool gFirstTime = true;
@ -5552,16 +5553,13 @@ nsCSSFrameConstructor::ConstructFramesFromItem(nsFrameConstructorState& aState,
// due to dynamic changes.
// We don't do it for SVG text, since we might need to position and
// measure the white space glyphs due to x/y/dx/dy attributes.
// We check that NS_CREATE_FRAME_FOR_IGNORABLE_WHITESPACE is not set on
// the node. This lets us disable this optimization for specific nodes
// (e.g. nodes whose geometry is being queried via DOM APIs).
if (AtLineBoundary(aIter) &&
!styleContext->StyleText()->WhiteSpaceOrNewlineIsSignificant() &&
aIter.List()->ParentHasNoXBLChildren() &&
!(aState.mAdditionalStateBits & NS_FRAME_GENERATED_CONTENT) &&
(item.mFCData->mBits & FCDATA_IS_LINE_PARTICIPANT) &&
!(item.mFCData->mBits & FCDATA_IS_SVG_TEXT) &&
!item.mContent->HasFlag(NS_CREATE_FRAME_FOR_IGNORABLE_WHITESPACE) &&
!mAlwaysCreateFramesForIgnorableWhitespace &&
item.IsWhitespace(aState))
return;
@ -7784,13 +7782,15 @@ nsIFrame*
nsCSSFrameConstructor::EnsureFrameForTextNode(nsGenericDOMDataNode* aContent)
{
if (aContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) &&
!aContent->HasFlag(NS_CREATE_FRAME_FOR_IGNORABLE_WHITESPACE)) {
!mAlwaysCreateFramesForIgnorableWhitespace) {
// Text frame may have been suppressed. Disable suppression and signal
// that a flush should be performed.
aContent->SetFlags(NS_CREATE_FRAME_FOR_IGNORABLE_WHITESPACE);
// that a flush should be performed. We do this on a document-wide
// basis so that pages that repeatedly query metrics for
// collapsed-whitespace text nodes don't trigger pathological behavior.
mAlwaysCreateFramesForIgnorableWhitespace = true;
nsAutoScriptBlocker blocker;
BeginUpdate();
RecreateFramesForContent(aContent, false);
ReconstructDocElementHierarchy();
EndUpdate();
}
return aContent->GetPrimaryFrame();

Просмотреть файл

@ -1801,6 +1801,7 @@ private:
bool mIsDestroyingFrameTree : 1;
// This is true if mDocElementContainingBlock supports absolute positioning
bool mHasRootAbsPosContainingBlock : 1;
bool mAlwaysCreateFramesForIgnorableWhitespace : 1;
nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
};