Closed Bug 554822 Opened 15 years ago Closed 15 years ago

Caret should refer the actual text color instead of the value of CSS color property

Categories

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

defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9.3a4

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(1 file, 5 obsolete files)

spinning out from bug 553975. nsCaret uses CSS text color of the reference frame. However, if the IME selection background color is same as the text color, the caret is never visible. Even if we fix bug 553975. I think that nsTextFrame should set the color to nsCaret at painting the selection.
Attached patch Patch v1.0 (obsolete) — Splinter Review
The caret is always painted by the actual foreground color of the character which is the caret position. This patch uses (n+1)th character's color when aOffset is (n) because caret is painted over the (n+1)th character. I have another idea for this patch. It might be better that I create nsIFrame::PaintCaretAt(nsRect &aRect). Then, nsTextFrame can paint caret with clipped character glyph whose color is background color. If so, we can support wide caret (needed for Korean IME) and we can fix the CJK caret issue (bug 335359) completely. However, seems I need more complex code for that, so, this patch is better for now.
Attachment #435875 - Flags: review?(roc)
+ foregroundColor = aForFrame->GetCaretColorAt(mLastContentOffset - start); GetCaretColorAt should just take the real content offset, instead of an offset "relative to the frame's start offset". + NS_WARNING("nsIFrame::GetOffsets() failed"); + foregroundColor = aForFrame->GetStyleColor()->mColor; This shouldn't happen, so just return instead of handling it. + if (!IsSelected()) { + return nsFrame::GetCaretColorAt(aOffset); + } I don't think we need this code. + if (start < end && start <= aOffset && aOffset < end && You don't need to check start < end here.
Attached patch Patch v2.0 (obsolete) — Splinter Review
Thank you for your review. And I found a bug. mLastContentOffset sometimes isn't in the text content. E.g., when I clicked right space of a line which is broken by <br>, mLastContentOffset value is the <br>'s offset in its parent node. I added mLastFrameOffset for the bug.
Attachment #435875 - Attachment is obsolete: true
Attachment #436142 - Flags: review?(roc)
Attachment #435875 - Flags: review?(roc)
Attached patch Patch v2.0.1 (obsolete) — Splinter Review
Sorry, the previous patch has a debug printf().
Attachment #436142 - Attachment is obsolete: true
Attachment #436143 - Flags: review?(roc)
Attachment #436142 - Flags: review?(roc)
Instead of storing mLastFrameOffset I think we can call GetCaretFrameForNodeOffset to get it. Or maybe GetCaretFrame should pass the frame offset as an out parameter, and then we can ensure the caller of GetCaretFrame eventually passes the offset to nsCaret::PaintCaret?
Attached patch Patch v3.0 (obsolete) — Splinter Review
Attachment #436143 - Attachment is obsolete: true
Attachment #436150 - Flags: review?(roc)
Attachment #436143 - Flags: review?(roc)
Comment on attachment 436150 [details] [diff] [review] Patch v3.0 + if (frame != aForFrame) { + return; + } This should be an assertion that frame == aForFrame.
Attachment #436150 - Flags: review?(roc) → review+
Attached patch Patch v3.1 (obsolete) — Splinter Review
thank you, roc.
Attachment #436150 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
backed-out the patch due to the patch cannot build with latest trunk.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch Patch v3.2Splinter Review
I implemented the nsIFrame::GetCaretColorAt() in #ifdef DEBUG. So, this patch doesn't change any meaning.
Attachment #436181 - Attachment is obsolete: true
Status: REOPENED → RESOLVED
Closed: 15 years ago15 years ago
Resolution: --- → FIXED
Depends on: 574244
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: