Closed Bug 465928 Opened 16 years ago Closed 16 years ago

Avoid SetInvalidateTextRuns in nsBlockFrame::DoRemoveFrame

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.1b3

People

(Reporter: roc, Assigned: roc)

References

Details

(Keywords: fixed1.9.1)

Attachments

(2 files, 1 obsolete file)

Attached patch fix (obsolete) — Splinter Review
When a frame is complete and we delete its unnecessary (now empty) continuations, we don't need to call SetInvalidateTextRuns on the lines containing those continuations, because we're not removing any actual content. Fixing this requires propagating a flag through DeleteNextInFlowChild to indicate whether we're in that common case. This lets us reduce the amount of textrun reconstruction we do.
Attachment #349167 - Flags: superreview?(dbaron)
Attachment #349167 - Flags: review?(dbaron)
Comment on attachment 349167 [details] [diff] [review]
fix

> nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, PRBool aDestroyFrames,

>         static_cast<nsContainerFrame*>(nif->GetParent())
>-          ->nsContainerFrame::DeleteNextInFlowChild(presContext, nif);
>+          ->nsContainerFrame::DeleteNextInFlowChild(presContext, nif, aRemovingEmptyFrames);

you should wrap to another line rather than cross the 80th column

> nsBlockFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,

>+    nsContainerFrame::DeleteNextInFlowChild(aPresContext, aNextInFlow, aDeletingEmptyFrames);

Same here

>+    * @param aRemovingEmptyFrames all frames we're removing are empty
>+    * so lines do not need to be marked dirty

Do you mean text runs rather than lines?  Or is there something else here?

>   nsresult DoRemoveFrame(nsIFrame* aDeletedFrame, PRBool aDestroyFrames = PR_TRUE, 
>-                         PRBool aRemoveOnlyFluidContinuations = PR_TRUE);
>+                         PRBool aRemoveOnlyFluidContinuations = PR_TRUE,
>+                         PRBool aRemovingEmptyFrames = PR_FALSE);

Having three default parameters, two of which are true and one of which is false, seems very ugly and a bit dangerous.  How many callers depend on the default parameters?  Could the defaults be dropped?  Is it possible to rename your new one such that the default could be true (e.g., to aInvalidateTextRuns)?  (Do you think that would improve things?)


r+sr=dbaron
Attachment #349167 - Flags: superreview?(dbaron)
Attachment #349167 - Flags: superreview+
Attachment #349167 - Flags: review?(dbaron)
Attachment #349167 - Flags: review+
(In reply to comment #1)
> (From update of attachment 349167 [details] [diff] [review])
> > nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, PRBool aDestroyFrames,
> 
> >         static_cast<nsContainerFrame*>(nif->GetParent())
> >-          ->nsContainerFrame::DeleteNextInFlowChild(presContext, nif);
> >+          ->nsContainerFrame::DeleteNextInFlowChild(presContext, nif, aRemovingEmptyFrames);
> 
> you should wrap to another line rather than cross the 80th column
> 
> > nsBlockFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
> 
> >+    nsContainerFrame::DeleteNextInFlowChild(aPresContext, aNextInFlow, aDeletingEmptyFrames);
> 
> Same here

OK

> >+    * @param aRemovingEmptyFrames all frames we're removing are empty
> >+    * so lines do not need to be marked dirty
> 
> Do you mean text runs rather than lines?  Or is there something else here?

I guess just "text runs do not need to be invalidated".

> >   nsresult DoRemoveFrame(nsIFrame* aDeletedFrame, PRBool aDestroyFrames = PR_TRUE, 
> >-                         PRBool aRemoveOnlyFluidContinuations = PR_TRUE);
> >+                         PRBool aRemoveOnlyFluidContinuations = PR_TRUE,
> >+                         PRBool aRemovingEmptyFrames = PR_FALSE);
> 
> Having three default parameters, two of which are true and one of which is
> false, seems very ugly and a bit dangerous.  How many callers depend on the
> default parameters?  Could the defaults be dropped?  Is it possible to rename
> your new one such that the default could be true (e.g., to
> aInvalidateTextRuns)?  (Do you think that would improve things?)

Would it be better if I made them into a single flags word?
(In reply to comment #2)
> Would it be better if I made them into a single flags word?

It might, if you think that would come out cleanly (which it might, especially if the flag were always the uncommon case).  I'm mainly concerned about (a) readability and (b) the risk of bugs caused by omitting one of the parameters or getting them in the wrong order.
Attached patch with flagsSplinter Review
Attachment #349167 - Attachment is obsolete: true
Attachment #349550 - Flags: superreview?(dbaron)
Attachment #349550 - Flags: review?(dbaron)
Attachment #349550 - Flags: superreview?(dbaron)
Attachment #349550 - Flags: superreview+
Attachment #349550 - Flags: review?(dbaron)
Attachment #349550 - Flags: review+
Comment on attachment 349550 [details] [diff] [review]
with flags

>+   * PRESERVE_REMOVED_FRAMES does NOT work on out of flow frames so
>+   * always use PR_TRUE for out of flows.

s/always use PR_TRUE/it should not be passed/ or something like that

r+sr=dbaron
Needed for blocker bug 430332.
Flags: blocking1.9.1?
Whiteboard: [needs landing]
Flags: blocking1.9.1? → wanted1.9.1+
Priority: -- → P3
Pushed to trunk as fde162441213 and 2ad0cb394376
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing] → [needs 191 approval]
Comment on attachment 349550 [details] [diff] [review]
with flags

Avoids textrun reconstruction; performance win on bug 430332
Attachment #349550 - Flags: approval1.9.1?
Comment on attachment 349550 [details] [diff] [review]
with flags

a191=beltzner
Attachment #349550 - Flags: approval1.9.1? → approval1.9.1+
Whiteboard: [needs 191 approval] → [needs 191 landing]
Comment on attachment 349550 [details] [diff] [review]
with flags

>+   * PRESERVE_REMOVED_FRAMES does NOT work on out of flow frames so
[snip]
>+  enum {
>+    PERSERVE_REMOVED_FRAMES    = 0x01,

I just ran across this typo when perusing nsBlockFrame.cpp ("pERserve instead of pREserve in the enum value name).  It's spelled correctly in all the comments, and incorrectly in all the code.

Looks like this file just needs a s/PERSERVE/PRESERVE/.
Attachment #356784 - Attachment description: followup typo fix: s/PERSERVE/PRESERVE → followup typo fix: s/PERSERVE/PRESERVE/ in nsBlockFrame.*
Attachment #356784 - Flags: review?(roc)
Attachment #356784 - Flags: review?(roc) → review+
Depends on: 495875
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: