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)
Core
Layout: Text and Fonts
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a4
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
Attachments
(1 file, 5 obsolete files)
9.07 KB,
patch
|
Details | Diff | Splinter Review |
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.
Assignee | ||
Comment 1•15 years ago
|
||
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.
Assignee | ||
Comment 3•15 years ago
|
||
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)
Assignee | ||
Comment 4•15 years ago
|
||
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?
Assignee | ||
Comment 6•15 years ago
|
||
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+
Assignee | ||
Comment 9•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
Assignee | ||
Comment 10•15 years ago
|
||
backed-out the patch due to the patch cannot build with latest trunk.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 11•15 years ago
|
||
I implemented the nsIFrame::GetCaretColorAt() in #ifdef DEBUG. So, this patch doesn't change any meaning.
Attachment #436181 -
Attachment is obsolete: true
Assignee | ||
Comment 12•15 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•