Closed
Bug 201974
Opened 22 years ago
Closed 22 years ago
Caret partially/completely visible with initial <p> </p>
Categories
(Core :: DOM: Editor, defect)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
People
(Reporter: KaiE, Assigned: KaiE)
References
(Blocks 1 open bug)
Details
(Keywords: topembed+, Whiteboard: editorbase, edt_x3)
Attachments
(2 files, 2 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
patch
|
KaiE
:
review+
sfraser_bugs
:
superreview+
|
Details | Diff | Splinter Review |
Prepare a HTML document with a plain text editor.
Make the HTML document contain this:
<body>
<p> </p>
x
</body>
Open the file in composer.
Expected behaviour
==================
I think the editor should display two visible lines.
A blank line at the top.
A second line showing the "x".
The caret should be placed on top of the file, on the blank line.
Actual behaviour
================
There is no initial blank line shown.
The first fully visible line contains the "x".
The caret is only halfways visible, placed "in the off" above the "x"!
This misplacement is the bug.
It can be shown the caret is really placed in the off:
Type cursor down. The cursor goes down and is now in front of the x.
Type cursor up and nothing happens. The cursor does not go back to "the off".
Slightly modified testcase with even worse behaviour
====================================================
Modify the initial HTML document, remove the space between <p> and </p>, i.e.:
<body>
<p></p>
x
</body>
When you open this document editor, the caret is not visible at all!
Assignee | ||
Comment 1•22 years ago
|
||
Assignee | ||
Comment 3•22 years ago
|
||
After asking on irc, it seems the rendered display is correct, only the caret
placement is incorrect.
Assignee | ||
Comment 4•22 years ago
|
||
I'll try to change nsHTMLEditor::BeginningOfDocument() to skip any empty initial
<p> elements.
Comment 5•22 years ago
|
||
Discussed in edt. Plussing. Seen in embedding customer product. Please make
sure fix gets rolled back to their branches.
Assignee | ||
Comment 6•22 years ago
|
||
First attempt of a patch.
This patch fixes the testcase. I have not yet done much additional testing.
The idea of the bug is: nsWSRunObject terminates its search for more whitespace
as soon as it finds a block node. However, as in our example, a block can be
completely invisble.
This patch extends the handling for block elements. When a block element is
found, it does another check whether the block contains anything visible. If
not, it skips the block and continues searching for visible things.
While this patch seems to work at first sight, there are three things I would
like to check more, and I'd be happy to get advice from you.
First, I'm making use of the special return value "eThisBlock", I'm using it as
the indicator whether the search for more whitespace failed. Is this really
correct?
Second, I need to understand better whether
end.SetPoint(nextNode,1);
is indeed the correct way to skip the block element.
Third, I think we should do the same handling when searching for previous
whitespace? If you agree, additional code for the backwards direction must be
written.
Assignee | ||
Comment 7•22 years ago
|
||
Assigning to myself, since I seem to be close to a fix.
Assignee: jfrancis → kaie
Updated•22 years ago
|
Attachment #120488 -
Flags: review-
Comment 8•22 years ago
|
||
This patch is not the right approach. Although the empty block may not be
visible, it still does end any whitespace run before it (and start any run after
it, and contain any run in it, etc). So we don't want to change the definition
of the whitespace run in this case.
Also, note that some blocks are visible even if they are empty (for instance:
td, li). I think the correct appraoch here is to write a new routine which
makes use of the existing tools (NextVisibleNode, IsEmptyBlock) to traverse from
a point and find the next piece of visible content. The
nsWSRUnObject::NextVisibleNode method is perhaps misnamed since it really will
find the next visible content, or the end of the whitespace run, whichever it
encounters first.
Comment 9•22 years ago
|
||
Even better would be if we could simply have a method on selection that let us
get back the translated node/offset that corresponds to the first visible frame.
In general we cant take the approach of asking layout about frmaes data in the
editor, since the editor often needs to figure out things on the fly when the
dom has been touched by editor but not yet reflowed. However the case of
placing selection at the front of the document is a special case: when we want
that we are never in the middle of an operation (I think).
Assignee | ||
Comment 10•22 years ago
|
||
Thanks a lot for your comments, very helpful!
With your explanation, I agree we must not change the current general behaviour
of the WSRunObject.
I like your suggestion to make use of IsEmptyBlock, I had not seen that method
before.
I also like your suggestion to use special handling for the BeginningOfDocument
case (you are suggesting that indirectly, by expressing your hope, that
selection/layout frames will be "in synch" in the special case when calling
BeginningOfDocument).
But your second proposal to query selection still sounds more risky, since we
might not be able to predict all situations when BeginningOfDocument gets
called?
Therefore I'd like to try a simpler approach first.
I'm attaching a new patch that also seems to work in the simple cases I have
tested so far. My simple test included a document that starts with a table,
having whitespace only in its first cell. This works with and without the
patch.
The idea of the new patch is, and hopefully my assumptions are correct:
- only modify the BeginningOfDocument function, since that is the only area we
currently see the problem
- when nsWSRunObject terminated its search for whitespace, because it found a
block boundary, it returns eOtherBlock (I could not find other situations where
it would return eOtherBlock)
- if BeginningOfDocument of NextVisibleNode detects the return value
eOtherBlock, it will test whether the returned node is empty
- if the node returned with eOtherBlock is empty, BeginningOfDocument will skip
the block and continue the search
Attachment #120488 -
Attachment is obsolete: true
Assignee | ||
Updated•22 years ago
|
Attachment #120594 -
Flags: review?(jfrancis)
Assignee | ||
Comment 11•22 years ago
|
||
I found another way to make the editor place the caret on the invalid position.
That other bug 202166 is not fixed by this patch (as expected).
However, the logic of the fix we choose here could get reused for bug 202166.
Blocks: 202166
Comment 12•22 years ago
|
||
Comment on attachment 120594 [details] [diff] [review]
Patch v1
This looks like a good solution. One thing to try would be to make a document
that has an hr as the first element inside the body, and see how this code
works then. I'm worried that we will try to put the selection "inside" the
<hr>. This would be a bug with the existing code rather than introduced by
your patch, but we shoudl still fix it while we are here. You may want to make
your else clause something like "else if (IsContainer(visNode))", and then have
a final else that skips over the node if it isn't a container.
Attachment #120594 -
Flags: review?(jfrancis) → review+
Assignee | ||
Comment 13•22 years ago
|
||
You are right. With a <hr> only document, the selection is indeed logically
inside the <hr>, and typing doesn't work. The patch doesn't fix it, as you
suspect. I tried your suggestion (if I have understood correctly), but now the
position is placed after the <hr>!
I extended the patch to handle this case specially, and to not continue looping,
and not skip the object, but instead place the caret in front of that object.
However, this exposes a new bug, most likely in GetNodeLocation?
If we try to obtain the location of the initial only <hr> node, and place the
caret at that position, the caret again appears only half visible!
But as we discussed on IRC, this seems to be a separate bug. We'll do the
modification anyways, since it doesn't make the situation worse and only affects
the special <hr> only document, and by making the change we have a testcase for
the other problem.
Assignee | ||
Comment 14•22 years ago
|
||
Addressed comment as discussed on IRC.
Attachment #120594 -
Attachment is obsolete: true
Assignee | ||
Comment 15•22 years ago
|
||
Comment on attachment 120647 [details] [diff] [review]
Patch v2
carrying forward review
Attachment #120647 -
Flags: review+
Assignee | ||
Comment 16•22 years ago
|
||
Comment on attachment 120647 [details] [diff] [review]
Patch v2
Peter, can you please review?
Attachment #120647 -
Flags: superreview?(peterv)
Updated•22 years ago
|
Attachment #120647 -
Flags: superreview?(peterv) → superreview+
Assignee | ||
Comment 17•22 years ago
|
||
fixed on trunk
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 18•22 years ago
|
||
using today's build (2003.04.23) with the attached test case, this is what i see
after i load it in composer:
a. there's no blank line at the top, only the "x" --expected per comment 3.
b. the caret is to the left of the "x" (again, expected).
c. hitting the right or down arrow will move the caret to the right of the "x"
(expected).
d. hitting the left arrow (when the caret is to the right of the "x") will move
the caret to the left of the "x" (expected).
e. hitting the up arrow (when the caret is to the right of the "x") does NOT
move the caret to the left of the "x", as i would expect.
is there another bug covering (e)? if not, should i reopen this one or spin off
another bug?
You need to log in
before you can comment on or make changes to this bug.
Description
•