Closed Bug 119786 Opened 23 years ago Closed 22 years ago

table created with dom methods is not displayed when a caption is inserted

Categories

(Core :: DOM: Core & HTML, defect, P4)

defect

Tracking

()

RESOLVED FIXED
mozilla1.3beta

People

(Reporter: martin.honnen, Assigned: karnaze)

References

Details

(Keywords: testcase, Whiteboard: PATCH)

Attachments

(2 files, 1 obsolete file)

The following test page creates two tables with DOM methods, the only difference
being that for the first table a caption is created while for the second no
caption is created. Mozilla 0.9.7 for the first table only displays the caption
but not the table itself while the second table displays fine.

<html>
<head>
<title>
table creation
</title>
<style type="text/css">
caption { color: green; background-color: lightyellow; }
</style>
<script type="text/javascript">
function createTable (caption) {
  var table = document.createElement('table');
  table.border = 1;
  document.body.appendChild(table);
  if (caption) {
    table.createCaption();
    table.caption.appendChild(document.createTextNode(caption));
  }
  table.createTHead();
  var row = table.tHead.insertRow(table.tHead.rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Header'));

  table.appendChild(document.createElement('tbody'));
  row = table.tBodies[0].insertRow(table.tBodies[0].rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Kibology'));
}
</script>
</head>
<body>
<script type="text/javascript">
createTable('Where is the table?');
document.body.appendChild(document.createElement('hr'));
createTable();
</script>
</body>
</html>

The problem doesn't occur if you first construct the whole table and then append
it to the document.body but I think the Mozilla DOM implementation should by now
be mature enough to not require the scripter to check which order of calls
Mozilla works with and which not.

<html>
<head>
<title>
table creation
</title>
<style type="text/css">
caption { color: green; background-color: lightyellow; }
</style>
<script type="text/javascript">
function createTable (caption) {
  var table = document.createElement('table');
  table.border = 1;
  document.body.appendChild(table);
  if (caption) {
    table.createCaption();
    table.caption.appendChild(document.createTextNode(caption));
  }
  table.createTHead();
  var row = table.tHead.insertRow(table.tHead.rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Header'));

  table.appendChild(document.createElement('tbody'));
  row = table.tBodies[0].insertRow(table.tBodies[0].rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Kibology'));
}
function createTable1 (caption) {
  var table = document.createElement('table');
  table.border = 1;
  if (caption) {
    table.createCaption();
    table.caption.appendChild(document.createTextNode(caption));
  }
  table.createTHead();
  var row = table.tHead.insertRow(table.tHead.rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Header'));

  table.appendChild(document.createElement('tbody'));
  row = table.tBodies[0].insertRow(table.tBodies[0].rows.length);
  row.insertCell(0).appendChild(document.createTextNode('Kibology'));
  document.body.appendChild(table);

}</script>
</head>
<body>
<script type="text/javascript">
createTable('Where is the table?');
document.body.appendChild(document.createElement('hr'));
createTable();
document.body.appendChild(document.createElement('hr'));
createTable1('Here is the table');
</script>
</body>
</html>
The page contains both the code not working and the workaround (which changes
the time at which the table is inserted into the document.body)
Keywords: testcase
Seeing this on Linux too. We create an invalid DOM (THEAD before CAPTION) but
that's not the issue here -- I fixed that in my tree and it did not help.  It
looks like calling InsertBefore on a table that's already in the DOM does not
lead to frames getting created...  I switched createCaption to use InsertBefore
instead of AppendChildTo and the caption disappeared as well.  Note that the
elements _are_ in the DOM.  They are just not shown.
OS: Windows XP → All
Hardware: PC → All
And loading the testcase in a debug build gives me:

###!!! ASSERTION: unexpected child frame type: 'PR_FALSE', file
nsTableOuterFrame.cpp, line 271
###!!! Break: at file nsTableOuterFrame.cpp, line 271
###!!! ASSERTION: invalid previous frame: '!aPrevFrame', file
nsTableOuterFrame.cpp, line 285
###!!! Break: at file nsTableOuterFrame.cpp, line 285
###!!! ASSERTION: unexpected child frame type: 'PR_FALSE', file
nsTableOuterFrame.cpp, line 271
###!!! Break: at file nsTableOuterFrame.cpp, line 271

are we constructing the wrong types of frames?  Or is the outer frame confused?
these assertions show that CSSFrameConstructor is trying to insert a
rowgroupframe into a outertableframe instead of innertableframe.
nsCSSFrameConstructor::ContentInserted seems to be very long and difficult to
understand ( the russian saying for this is: without a half litre you won't
understand)
Priority: -- → P5
*** Bug 149190 has been marked as a duplicate of this bug. ***
taking the bug.
Assignee: jst → karnaze
Priority: P5 → P4
Target Milestone: --- → mozilla1.3beta
Attached patch patch to fix the bug (obsolete) — Splinter Review
Comment on attachment 104654 [details] [diff] [review]
patch to fix the bug

r=bernd

the patch works great, it also improves the situation at the composer bug,
while I can't enter there anything because a bunch of assertions fire before
Attachment #104654 - Flags: review+
Status: NEW → ASSIGNED
Whiteboard: PATCH
Comment on attachment 104654 [details] [diff] [review]
patch to fix the bug

sr=kin@netscape.com ... though the following comment threw me off a bit:

+    // A caption has no siblings

Can we change the comment to say something to the effect that caption is  not a
valid sibling in the context that the IsValidSibling() method is used in?
Attachment #104654 - Flags: superreview+
Attachment #104654 - Attachment is obsolete: true
Attachment #105938 - Flags: superreview+
Attachment #105938 - Flags: review+
*** Bug 132628 has been marked as a duplicate of this bug. ***
The patch was checked in on 11/12/2.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: