Open Bug 145736 Opened 18 years ago Updated 6 years ago

whitespace in source interferes with caret in mtable

Categories

(Core :: MathML, defect)

x86
Windows 2000
defect
Not set

Tracking

()

People

(Reporter: steve.swanson, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

If the <mtd> in the <mtable> contains whitespace, you can select the <mtd> 
using selectAllChildren(), but if you try to just show the caret using 
collapseToStart(), no caret appears (and the L/R arrow keys don't restore it).

In the testcase, use the links to select various cells.  Type a key to call 
collapseToStart() on the selection.  The first <mtable> contains blank lines 
and extra spaces, the second doesn't.

I tried to reproduce this behavior in an XHTML table, but couldn't.
I traced this to a problem with the inter-tag whitespace nodes as shown below:

<mtd> 
 [...WHITESPACE...]
 <mn>1</mn>
 [...WHITESPACE...]
</mtd>

In MathML, inter-tag whitespace doesn't count, and no frames are created for these empty whitespace nodes to begin with. See (bug 68411):

http://lxr.mozilla.org/seamonkey/source/layout/mathml/base/src/nsMathMLmtableFrame.cpp#697

(If you were to disable line 697 in nsMathMLmtableFrame.cpp, you will get what the XHTML table does.)

Digging further down the problem, it appeared that the crux of the matter is in
nsSelection::GetFrameForNodeOffset().

When nsCaret.cpp is looking for the frame where to draw the caret, it ends up calling that function, and since the selection is considering the focusNode to set for the selection as the dummy inter-tag WHITESPACE node, it looks for the primary frame associated to that node, it doesn't find anything and returns NS_ERROR_UNEXPECTED, and from there on the caret doesn't bother doing anything else.

nsSelection::GetFrameForNodeOffset()
[...]
  result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame);
  if (NS_FAILED(result))
    return result;
	
  if (!*aReturnFrame)
    return NS_ERROR_UNEXPECTED;
[...]
}

Not sure what to do with this bug.
[Resending... I used Opera, and see what the "fatest browser on earth" did...]
=========================

I traced this to a problem with the inter-tag whitespace nodes as shown below:

<mtd> 
 [...WHITESPACE...]
 <mn>1</mn>
 [...WHITESPACE...]
</mtd>

In MathML, inter-tag whitespace doesn't count, and no frames are created for 
these empty whitespace nodes to begin with. See (bug 68411):

http://lxr.mozilla.org/seamonkey/source/layout/mathml/base/src/nsMathMLmtableFra
me.cpp#697

(If you were to disable line 697 in nsMathMLmtableFrame.cpp, you will get what 
the XHTML table does.)

Digging further down the problem, it appeared that the crux of the matter is in
nsSelection::GetFrameForNodeOffset().

When nsCaret.cpp is looking for the frame where to draw the caret, it ends up 
calling that function, and since the selection is considering the focusNode to 
set for the selection as the dummy inter-tag WHITESPACE node, it looks for the 
primary frame associated to that node, it doesn't find anything and returns 
NS_ERROR_UNEXPECTED, and from there on the caret doesn't bother doing anything 
else.

nsSelection::GetFrameForNodeOffset()
[...]
  result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame);
  if (NS_FAILED(result))
    return result;
	
  if (!*aReturnFrame)
    return NS_ERROR_UNEXPECTED;
[...]
}

Not sure what to do with this bug.

Cc:ing mjudge for any clues.

[Also noted that nsSelection.cpp does straight testing of tag names vs. |tr|td|, 
this makes some parts of that code very HTML specific.]
QA Contact: ian → mathml
Assignee: rbs → nobody
We need to test if this bug is still valid.
Blocks: 78128
You need to log in before you can comment on or make changes to this bug.