From 69fbd973a0c16869dd4f92be9c2a139be6b6981f Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Fri, 8 Oct 1999 22:04:31 +0000 Subject: [PATCH] Fix for blocker #15839. r=kipp@netscape.com,kin@netscape.com Typing into a text area wasn't working properly. Problem was that when the text changed we were reflowing the text frames with a resize reflow command and we thought we could optimize the reflow. So I changed ContentChanged() to mark each text frame dirty so we would know not to do the optimization git-svn-id: svn://10.0.0.236/trunk@50261 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsTextFrame.cpp | 28 +++++++++++++++----- mozilla/layout/html/base/src/nsTextFrame.cpp | 28 +++++++++++++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 9962eaa52b1..c793df2539a 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -664,6 +664,14 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { + // Mark this frame and all the next-in-flow frames as dirty + // XXX Unfortunately we don't know what actually changed... + nsTextFrame* textFrame = this; + while (textFrame) { + textFrame->mState |= NS_FRAME_IS_DIRTY; + textFrame = (nsTextFrame*)textFrame->mNextInFlow; + } + // Generate a reflow command with this frame as the target frame nsIReflowCommand* cmd; nsresult rv; @@ -2518,23 +2526,29 @@ nsTextFrame::Reflow(nsIPresContext& aPresContext, // We can avoid actually measuring the text if: // - this is a resize reflow + // - we're not dirty (see ContentChanged() function) // - we don't have a next in flow // - the previous reflow successfully reflowed all text in the // available space - // - the available width is at least as big as our current frame width // - we aren't computing the max element size (that requires we measure // text) - // - we're not preformatted text or we're at the same column as before (this - // is an issue for tabbed text) - if (eReflowReason_Resize == aReflowState.reason) { + // - skipping leading whitespace is the same as it was the last time + // - we're wrapping text and the available width is at least as big as our + // current frame width -or- + // we're not wrapping text and we're at the same column as before (this is + // an issue for preformatted tabbed text only) + if ((eReflowReason_Resize == aReflowState.reason) && + (0 == (mState & NS_FRAME_IS_DIRTY))) { + nscoord realWidth = mRect.width; if (mState & TEXT_TRIMMED_WS) { realWidth += ts.mSpaceWidth; } - if (!mNextInFlow && (mState & TEXT_OPTIMIZE_RESIZE) && - (maxWidth >= realWidth) && !aMetrics.maxElementSize && + if (!mNextInFlow && + (mState & TEXT_OPTIMIZE_RESIZE) && + !aMetrics.maxElementSize && (lastTimeWeSkippedLeadingWS == skipWhitespace) && - (!ts.mPreformatted || (prevColumn == column))) { + ((wrapping && (maxWidth >= realWidth)) || (prevColumn == column))) { // We can skip measuring of text and use the value from our // previous reflow measureText = PR_FALSE; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 9962eaa52b1..c793df2539a 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -664,6 +664,14 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { + // Mark this frame and all the next-in-flow frames as dirty + // XXX Unfortunately we don't know what actually changed... + nsTextFrame* textFrame = this; + while (textFrame) { + textFrame->mState |= NS_FRAME_IS_DIRTY; + textFrame = (nsTextFrame*)textFrame->mNextInFlow; + } + // Generate a reflow command with this frame as the target frame nsIReflowCommand* cmd; nsresult rv; @@ -2518,23 +2526,29 @@ nsTextFrame::Reflow(nsIPresContext& aPresContext, // We can avoid actually measuring the text if: // - this is a resize reflow + // - we're not dirty (see ContentChanged() function) // - we don't have a next in flow // - the previous reflow successfully reflowed all text in the // available space - // - the available width is at least as big as our current frame width // - we aren't computing the max element size (that requires we measure // text) - // - we're not preformatted text or we're at the same column as before (this - // is an issue for tabbed text) - if (eReflowReason_Resize == aReflowState.reason) { + // - skipping leading whitespace is the same as it was the last time + // - we're wrapping text and the available width is at least as big as our + // current frame width -or- + // we're not wrapping text and we're at the same column as before (this is + // an issue for preformatted tabbed text only) + if ((eReflowReason_Resize == aReflowState.reason) && + (0 == (mState & NS_FRAME_IS_DIRTY))) { + nscoord realWidth = mRect.width; if (mState & TEXT_TRIMMED_WS) { realWidth += ts.mSpaceWidth; } - if (!mNextInFlow && (mState & TEXT_OPTIMIZE_RESIZE) && - (maxWidth >= realWidth) && !aMetrics.maxElementSize && + if (!mNextInFlow && + (mState & TEXT_OPTIMIZE_RESIZE) && + !aMetrics.maxElementSize && (lastTimeWeSkippedLeadingWS == skipWhitespace) && - (!ts.mPreformatted || (prevColumn == column))) { + ((wrapping && (maxWidth >= realWidth)) || (prevColumn == column))) { // We can skip measuring of text and use the value from our // previous reflow measureText = PR_FALSE;