Bug 37944 - last-child of a list are not styled correctly when the entire list is replaced at once
Summary: last-child of a list are not styled correctly when the entire list is replace...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://media.rawdod.com/webkit_last_c...
Keywords:
: 37129 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-21 12:57 PDT by David Richards
Modified: 2010-07-13 03:28 PDT (History)
8 users (show)

See Also:


Attachments
Proposed Patch (6.46 KB, patch)
2010-05-12 03:07 PDT, Yoshiki Hayashi
no flags Details | Formatted Diff | Diff
Proposed Patch (6.30 KB, patch)
2010-07-13 00:43 PDT, Yoshiki Hayashi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Richards 2010-04-21 12:57:34 PDT
Here is a link to a demo:

http://media.rawdod.com/webkit_last_child_regen_bug.html

This is a hacked up copy and paste of the source of: http://www.quirksmode.org/css/firstchild.html

I have confirmed this bug happens on the latest chromium for linux and also the latest safari for windows.

I have confirmed this works fine on the latest firefox for linux.   

I expect nothing platform specific about this bug from that...


From what I am told, webkit should know to reparse the list and style it correctly when you replace the whole list, but it does not. 

This also happens when styling based on the last child of a class, thats how I found it, for example, if I replace this entire admin menu at once, I loose the border-right property being 0 on the last navigation class:

Example of structure:

	ul.navigation {
	
	float: left;
	display: block;
	height: 75px;
	margin: 0 12px 0 2px;
	border-right: 1px dotted #9a9a9a;
	padding: 0 14px 0 0;
	list-style-image: none;	
	list-style-type: none;	
	line-height: 25px;

	}
	
	ul.navigation:last-child {
	
	border-right: 0;
	
	}


<ul class="navigation">
 <li><%= link_to "Realtor Appointments", :controller => "admin/realtorappointments/list" %></li>
 <li><%= link_to "Lender Appointments", :controller => "admin/mortgagelenderappointments/list" %></li>
 <li><%= link_to "Moving Appointments", :controller => "admin/moving_and_storage_appointments/list" %></li>
</ul>
<ul class="navigation">
 <li><%= link_to "Messages", :controller => "admin/messages", :action => "list" %></li>	
 <li><%= link_to "Reports", :controller => "admin/reports", :action => "list" %></li>	
 <li><%= link_to "Recent Logins", :controller => "admin/logs", :action => "recent_logins" %></li>	
</ul>
<ul class="navigation">
 <li><%= link_to "Logs", :controller => "admin/logs", :action => "view" %></li>
 <li><%= link_to "Console", :controller => "admin/logs", :action => "console" %></li>
 <li><%= link_to "Imports", :controller => "admin/imports", :action => "view" %></li>
</ul>
<ul class="navigation">
 <li><%= link_to "Marketing Material Orders", :controller => "admin/logs/material_orders" %></li>
</ul>
Comment 1 David Richards 2010-04-21 13:16:14 PDT
I found some workarounds:

http://media.rawdod.com/webkit_last_child_regen_bug_with_workarounds.html
Comment 2 David Richards 2010-04-21 13:19:40 PDT
This bug is related to 37129  but expands upon it because it also affects other things besides just whats in a list.
Comment 3 Yoshiki Hayashi 2010-05-12 03:07:47 PDT
Created attachment 55823 [details]
Proposed Patch
Comment 4 Yuzo Fujishima 2010-05-12 18:17:35 PDT
Reviewers,

I've uploaded a different patch to:
https://bugs.webkit.org/show_bug.cgi?id=37129

I think we only need either one of the patches. So please review both and pick the one you like. :)
Comment 5 Kent Tamura 2010-07-12 08:08:20 PDT
I read the attachment #55823 [details] (this bug) and #55830 (Bug#37129), and I think the approach of #55823 is better because
 - #55830 uses a parsing flag for non-parsing process
 - #55823 covers not only innerHTML case but also replaceChild(fragment-with-children, node) case

Any other comments?
Comment 6 Kent Tamura 2010-07-12 21:23:41 PDT
Comment on attachment 55823 [details]
Proposed Patch

LayoutTests/fast/css/last-child-innerhtml-expected.txt:6
 +  1
Leaving "1 2 3 1 2 3" in the test expectation makes no much sense.
I recommend to clear children of "threeChildren" and "oneChild" before finishing the test.


WebCore/dom/ContainerNode.cpp:241
 +  
We don't need two blank lines.  Remove one.
Comment 7 Yoshiki Hayashi 2010-07-13 00:43:23 PDT
Created attachment 61341 [details]
Proposed Patch
Comment 8 Yoshiki Hayashi 2010-07-13 00:45:01 PDT
(In reply to comment #6)

Thank you for review.  I've modified the patch accordingly.  Could you take another look?

Thanks,
Comment 9 Kent Tamura 2010-07-13 01:52:10 PDT
Comment on attachment 61341 [details]
Proposed Patch

Looks good.
Comment 10 WebKit Commit Bot 2010-07-13 03:25:39 PDT
Comment on attachment 61341 [details]
Proposed Patch

Clearing flags on attachment: 61341

Committed r63190: <http://trac.webkit.org/changeset/63190>
Comment 11 WebKit Commit Bot 2010-07-13 03:25:44 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Kent Tamura 2010-07-13 03:28:33 PDT
*** Bug 37129 has been marked as a duplicate of this bug. ***