Closed Bug 108035 Opened 23 years ago Closed 22 years ago

Content out of order when making list of Divs and Table elements

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: kinmoz, Assigned: mozeditor)

References

Details

(Whiteboard: EDITORBASE+ 1 day [adt2 RTM]; fixinhand)

Attachments

(2 files)

So if I have the following content in composer:


  This<div>Is</div><div>Some</div><div>List</div>Fun!


it appears on screen like this:


  This

  Is

  Some

  List

  Fun!


If I select all of the content and hit the list button, I get one list item that 
looks like this:


  * ThisFun!ListSomeIs


Some peculiar things about this:

  1. Why are we not treating divs as blocks and giving them their own
     list item? It looks like we are pulling out the div and table
     element contents and putting them directly in the list of nodes
     we are operating on in WillMakeList().

  2. It seems that GetListActionNodes() can actually cause the reordering
     of content in the array of nodes when they are divs or table elements,
     because it always appends them to the end of the array after they've
     stripped off the div/table element container.
Attached file Test Case
Whoops I didn't mean to put empty lines between each of the words above in the 
section "it appears on screen like this:" it should look like this:

  This
  Is
  Some
  List
  Fun!
kin: you want to work on this?
Assignee: jfrancis → kin
Status: NEW → ASSIGNED
Priority: -- → P3
Whiteboard: EDITORBASE 1 day
Target Milestone: --- → mozilla0.9.6
--> mozilla0.9.7
Target Milestone: mozilla0.9.6 → mozilla0.9.7
--> mozilla0.9.8
Target Milestone: mozilla0.9.7 → mozilla0.9.8
--> 0.9.9 (Load balancing)
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Target Milestone: mozilla0.9.9 → mozilla1.0
plussing
Whiteboard: EDITORBASE 1 day → EDITORBASE+ 1 day
Keywords: nsbeta1+
Reassigning to Daniel, since Kin is overloaded with EDITORBASE+ bugs.
Assignee: kin → glazman
Status: ASSIGNED → NEW
Looks like the ordering problem is fixed .. we're still putting everything in a
single list item though.
accepting bug
Status: NEW → ASSIGNED
strange... i never received the bugmails relative to this bug, including
reassignment.
Ok I see. The root of the problem is in
http://lxr.mozilla.org/seamonkey/source/editor/libeditor/html/nsHTMLEditRules.cpp#5286

We just cannot remove the nsHTMLEditUtils::IsDiv(testNode) test because of the
following example :

    <div>a first line of text
      <ul>
        <li>first item</li>
        <li>second item</li>
      </ul>
     </div>

select all and click on ordered list button. You want the whole thing to
become a single ordered list. If I remove the test above, the whole DIV
will be inserted into the first item of an ordered list.

This issue is trickier than we thought, I am afraid.
I think I found the cleanest way to solve the bug... If the last node of a div
we trying to put into a list is a text node, append a br after it. It should
solve all problems.
why am i not surprised.  hmmm.  

One possibility is to change the loop that daniel indicates to append a null 
element to the list everytime we call GetInnerContent().  Then we could change 
WillMakeList(), etc, to interpret null elements in the list as a signal to create 
a new block {list item, etc} for further content.

Hackish, yes, but fairly simple.
adt2 for the partial fix
Whiteboard: EDITORBASE+ 1 day → EDITORBASE+ 1 day [adt2]
assigning to me at daniels request
Assignee: glazman → jfrancis
Status: ASSIGNED → NEW
This should fix it.
Status: NEW → ASSIGNED
Whiteboard: EDITORBASE+ 1 day [adt2] → EDITORBASE+ 1 day [adt2]; fixinhand; need r=sr=
Comment on attachment 82424 [details] [diff] [review]
patch to nsHTMLEditRules.cpp

sr=kin@netscape.com
Attachment #82424 - Flags: superreview+
Whiteboard: EDITORBASE+ 1 day [adt2]; fixinhand; need r=sr= → EDITORBASE+ 1 day [adt2]; fixinhand; need r=
fixed on trunk
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified on the 05-14 trunk build.
Status: RESOLVED → VERIFIED
adt1.0.0
Keywords: adt1.0.0
sorry, its late, and i am tired. but, did i miss something here. who r= this bug
before it went into the trunk?

Removing adt1.0.0, for now, until there is a r=.
Blocks: 143047
Keywords: adt1.0.0
Whiteboard: EDITORBASE+ 1 day [adt2]; fixinhand; need r= → EDITORBASE+ 1 day [adt2 RTM]; fixinhand; need r=
I can't remember who r'd.  Daniel, can you r= this?
I confirm that I told r=glazman *before* this fix was checked in during an IRC
conversation with Joe.
Comment on attachment 82424 [details] [diff] [review]
patch to nsHTMLEditRules.cpp

r=glazman, as said a month ago during an IRC discussion with Joe
Attachment #82424 - Flags: review+
Whiteboard: EDITORBASE+ 1 day [adt2 RTM]; fixinhand; need r= → EDITORBASE+ 1 day [adt2 RTM]; fixinhand
nsbeta1-. The fix is too risky for the 1.0 branch.
Keywords: nsbeta1+nsbeta1-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: