Closed Bug 307532 Opened 19 years ago Closed 19 years ago

Selection colors should be saved in nsTextFrame::TextPaintStyle, not DrawSelectionIterator

Categories

(Core :: Layout: Text and Fonts, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(2 files, 6 obsolete files)

I'm working on bug 113161 and bug 170951.

In this work, I need selection colors in nsTextFrame::PaintTextDecorations. But
this function isn't using DrawSelectionIterator, but it has TextPaintStyle. I
think that DrawSelectionIterator should not have colors. It should refer
TextPaintStyle. And DrawSelectionIterator::GetSelectionColors should be moved to
TextPaintStyle. I think TextPaintStyle should be class, not struct.(struct can
have methods, but it is not beautiful. And I hate that the nsTextFrame
definition becomes long.)

I will create the patch tomorrow.
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla1.9alpha
Attached patch Patch rv1.0 (obsolete) — Splinter Review
Attachment #196357 - Flags: superreview?(roc)
Attachment #196357 - Flags: review?(roc)
diff:

changing name; TextStyle -> nsTextStyle, TextPaintStyle -> nsTextPaintStyle.
removing color related members from DrawSelectionIterator.
removing some parameter from constructor of DrawSelectionIterator.
moving EnsureDifferentColors to previous in the code.

This patch solves the selection colors only once at first time of getting color
by GetSelectionColors. If GetSelectionColors is called by two or more times,
GetSelectionColors returns cached colors. Therefore, memory usage and
performance are better than current code.
Comment on attachment 196357 [details] [diff] [review]
Patch rv1.0

nsTextFrame.cpp is updated by bug 306895. I will create new patch.
Attachment #196357 - Flags: superreview?(roc)
Attachment #196357 - Flags: review?(roc)
Attached patch Patch rv2.0 (obsolete) — Splinter Review
Attachment #196357 - Attachment is obsolete: true
Attachment #196358 - Attachment is obsolete: true
Attachment #196645 - Flags: superreview?(roc)
Attachment #196645 - Flags: review?(roc)
Attachment #196645 - Flags: superreview?(roc)
Attachment #196645 - Flags: review?(roc)
Attached patch Patch rv2.1 (obsolete) — Splinter Review
Update to latest code.
Attachment #196645 - Attachment is obsolete: true
Attachment #200212 - Flags: superreview?(roc)
Attachment #200212 - Flags: review?(roc)
Attached patch Patch rv2.1(-u8pw) (obsolete) — Splinter Review
Attachment #196646 - Attachment is obsolete: true
Comment on attachment 200212 [details] [diff] [review]
Patch rv2.1

+  PRBool GetTextColor(nscolor* aTextColor);
+  PRBool GetSelectionColors(nscolor* foreColor,
+                            nscolor* backColor,
+                            PRBool*  aBackIsTransparent);

These don't need to return PRBool; it's a programming error if they ever fail (right?). So just put the assertions inside these functions and don't check in the caller. Then GetTextColor should return the color directly.

+  PRBool ShouldExchangeColors(nscolor *aForeColor, nscolor *aBackColor);

ShouldExchangeColors is not a good name, since it actually does the exchange if necessary. "Should" suggests that the function just tests whether the exchange is necessary. Call it something else like "EnsureSufficientContrast".
Attachment #200212 - Flags: superreview?(roc)
Attachment #200212 - Flags: superreview+
Attachment #200212 - Flags: review?(roc)
Attachment #200212 - Flags: review+
Attachment #200212 - Attachment is obsolete: true
Attachment #200213 - Attachment is obsolete: true
checked-in.

Thanks.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Was this expected to affect Tp?  It improved by 2-4% or more on btek, luna, monkey (seamonkey tinderboxen, linux and mac), and got worse by about 20% on beast (Firefox tinderbox, windows, though there this patch is not the only one in the window).
Yeah, if so, this may improve.
Because this patch doesn't process the "getting selection colors" if it's not needed.
Also, this caused the orange on balsa.  This patch is managing to leak enough stuff that we're asserting on shutdown, and asserts are fatal on balsa.
Ah, ok.  We used to get the selection colors on every textframe paint?  And now we only get them if it's selected?
this leaks the selection controller

In +nsTextFrame::GetSelectionStatus:
+  nsISelectionController* selectionController;
+  nsresult rv = GetSelectionController(aPresContext, &selectionController);

This addrefs, and never releases. fix is probably to make that an nsCOMPtr.

reopening. this causes the orange on balsa and probably enormous leaks.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch leak patchSplinter Review
this should fix things, though I didn't test it.
Attachment #201265 - Flags: superreview?(bzbarsky)
Attachment #201265 - Flags: review?(bzbarsky)
Comment on attachment 201265 [details] [diff] [review]
leak patch

Looks good.
Attachment #201265 - Flags: superreview?(bzbarsky)
Attachment #201265 - Flags: superreview+
Attachment #201265 - Flags: review?(bzbarsky)
Attachment #201265 - Flags: review+
(In reply to comment #15)
> Ah, ok.  We used to get the selection colors on every textframe paint?  And now
> we only get them if it's selected?
> 

If there are useless DrawSelectionIterator(s), you're right.

Biesi:

Thanks, and Sorry.
Tinderbox is green, now.

-> FIXED.

Thanks!
Status: REOPENED → RESOLVED
Closed: 19 years ago19 years ago
Resolution: --- → FIXED
Ah, good.  Tp is also back where it should be with the leak fixed.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: