Created attachment 34918[details]
Extended test case
Firefox behavior is rather strange: in cases A and B, the overflow section (blue) clears the float (yellow), but in case C it does not. Note that the only difference between case B and case C is that the container has a top border.

The layout difference between WebKit and Gecko is caused by <http://en.wikipedia.org/skins-1.5/monobook/KHTMLFixes.css>, which is loaded dynamically based on UA sniffing via JavaScript. The only rule in that style sheet is:
/* work around the horizontal scrollbars */
#column-content { margin-left: 0; }
which overrides the margin specific in main.css:
margin: 0 0 .6em -12.2em;
Using the Web Inspector to disable the 'margin-left: 0;' rule fixes the layout and does not cause a horizontal scroll bar to appear.

(In reply to comment #6)
> The layout difference between WebKit and Gecko is caused by
> <http://en.wikipedia.org/skins-1.5/monobook/KHTMLFixes.css>, which is loaded
> dynamically based on UA sniffing via JavaScript. The only rule in that style
> sheet is:
>
> /* work around the horizontal scrollbars */
> #column-content { margin-left: 0; }
>
> which overrides the margin specific in main.css:
>
> margin: 0 0 .6em -12.2em;
>
> Using the Web Inspector to disable the 'margin-left: 0;' rule fixes the layout
> and does not cause a horizontal scroll bar to appear.
Is that work around still required for the latest WebKit? i.e. will horizontal
scrollbars appear without it? If not, we can ask people in wikipedia to
disable that rule for the latest webkit.

> > Using the Web Inspector to disable the 'margin-left: 0;' rule fixes the layout
> > and does not cause a horizontal scroll bar to appear.
>
> Is that work around still required for the latest WebKit? i.e. will horizontal
> scrollbars appear without it?
No. Like I said, disabling the rule does not cause a horizontal scroll bar to appear.
> If not, we can ask people in wikipedia to
> disable that rule for the latest webkit.
I have moved the bug to the Evangelism component.

Ugh... I just noticed that this bug reproduces on other MediaWiki as well. We can't really force every site using MediaWiki to change their script. e.g. http://www.mediawiki.org/wiki/MediaWiki
I guess we need to preserve the old behavior or add work around for MediaWiki. But meanwhile, we should tell MediaWiki folks to modify the script so that it won't apply that style rule for the new versions of WebKit.

Created attachment 34922[details]
Proposed site-specific hack
The scope of this hack can be narrowed further by adding path components before /KHTMLFixes.css or widened by not requiring an exact string match. An alternative hack would be to bypass the UA detection, but I think would be more risky.

(In reply to comment #15)
> Extended test case appears to look the same pre-r47255 and post.
Because it has <!DOCTYPE html>. Without it, it looks different in WebKit. Anyway, both test cases are pretty much irrelevant to this bug.

(In reply to comment #5)
> Created an attachment (id=34918) [details]
> Extended test case
>
> Firefox behavior is rather strange: in cases A and B, the overflow section
> (blue) clears the float (yellow), but in case C it does not. Note that the only
> difference between case B and case C is that the container has a top border.
The rendering of this on WebKit and MSIE8 are identical.

(In reply to comment #5)
> Created an attachment (id=34918) [details]
> Extended test case
>
> Firefox behavior is rather strange: in cases A and B, the overflow section
> (blue) clears the float (yellow), but in case C it does not. Note that the only
> difference between case B and case C is that the container has a top border.
On MSIE8, width of the outer box is ignored. Yellow box appears on the right of screen, and blue box appears on the left with the same y.

I marked this as reviewed, because I think it's a great thing to do. We don't need a KHTML-specific style sheet that's working around a bug we no longer have.
Hyatt and other experts may wish to continue to debate other aspects of this, but it seems clear cut that we don't need this style rule.

(In reply to comment #23)
> I'm not a fan of this hack though. What incentive does Wikipedia have to fix
> the issue if we work around it like this? I am worried this hack will just
> stay in the code forever.
Yeah, that’s why I originally made this an evangelism bug. However, the problem here is that the buggy code is replicated in many websites that use the MediaWiki system, so this is more like the kind of workarounds we have for 3rd-party apps than a site-specific hack. Maybe the right thing to do is wait for Wikipedia to respond and if they do, re-evaluate the necessity of the hack.

I guess I don't mind this landing as long as we have a bug open and continue to evangelize, but you have a bigger stick to bargain with when you can actually say "This is broken now. Please fix."
If you approach Wikipedia with "Well this would be broken, but we worked around it, so you can work across old and new versions of WebKit without doing anything," then they have no incentive to change.

(In reply to comment #26)
> I guess I don't mind this landing as long as we have a bug open and continue to
> evangelize, but you have a bigger stick to bargain with when you can actually
> say "This is broken now. Please fix."
>
> If you approach Wikipedia with "Well this would be broken, but we worked around
> it, so you can work across old and new versions of WebKit without doing
> anything," then they have no incentive to change.
I agree. It's probably better for us to contact MediaWiki / Wikipedia before we add this work around.

(In reply to comment #25)
> I guess I'm just questioning what our site-specific-hack policy is. Do we have
> to immediately put the site-specific hack into the code, or can we give
> evangelism some time to work first?
When this kind of issue came up for Google Chrome, I proposed that we have a policy of not doing site-specific hacks until we had contacted the site author(s) and obtained an agreement from them to fix their site. At that point we could check in a temporary hack if fixing things was going to take time. I'm not sure we made this our official policy but it got general agreement from those to whom I proposed it. We used this pattern when dealing with a Hotmail problem (see http://googlechromereleases.blogspot.com/2009/01/stable-beta-update-yahoo-mail-and.html ).

(In reply to comment #30)
> This KHTML specific line for mediawiki is already removed upstream, but it will
> take a LONG while before all the mediawiki installations are going to be
> updated. As noted, not even Wikipedia itself has this deployed yet at this
> time.
>
> See: "* Remove five-year-old KHTMLFixes.css, which is unlikely to be relevant
> anymore and was causing problems."
>
> in
> http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/RELEASE-NOTES?revision=55124&view=markup
This is precisely the gist of the issue. We're not dealing with one site, but a widely used software. This hack has also been duplicated verbatim on many derivative projects, such as GForge and SpringWiki, which makes evangelism effort a bit daunting.
The site-specific hack patch looks pretty good to me atm.

This was due to ludicrously broken UA-sniffing on our part; sorry about that. For those who didn't catch it, in May 2004 someone committed a workaround to MediaWiki for a KHTML bug. Unfortunately, rather than using version-based sniffing, he just assumed all KHTML versions would have the bug forever -- KHTML was rather minor back then and it probably didn't seem important. So we ended up serving the fix to WebKit well over five years later.
It came to light when I was trying out a switch to HTML 5, and the strict doctype caused incorrect display in WebKit. When I figured out the problem I removed the check in r53141, which Derk-Jan linked to. The fix will be in MediaWiki 1.16 and should go live on Wikipedia within a few weeks, but you're going to have to handle it for other MediaWiki installs for years, sadly.

I got hold of the appropriate people just now, and Wikipedia is no longer serving the broken CSS:
http://en.wikipedia.org/skins-1.5/monobook/KHTMLFixes.css
The fix should also be in MediaWiki 1.16. That should theoretically be released in a month, but might take longer.
Needless to say, though, there are a *lot* of MediaWiki installs out there that don't keep up with updates. If you guys aren't willing to keep a site-specific hack in WebKit for a while, we could *maybe* backport the fix to old versions -- normally we only backport security fixes -- but we can't make people upgrade. The breakage is pretty ugly, with all content shoved down a large amount.
For future reference, the best place to reach us is wikitech-l: <https://lists.wikimedia.org/mailman/listinfo/wikitech-l>. Anything posted there will be read by most Wikimedia sysadmins and MediaWiki developers. For real-time response, you can also go to #mediawiki (for MediaWiki) or #wikimedia-tech (for Wikimedia site administration) on freenode, but of course you'll reach fewer people that way.
Sorry about the problems we've caused. Please let us know about any future difficulties. I've posted on wikitech-l to remind people to be careful about browser sniffing in the future:
http://lists.wikimedia.org/pipermail/wikitech-l/2009-August/044767.html

(In reply to comment #34)
> Needless to say, though, there are a *lot* of MediaWiki installs out there that
> don't keep up with updates.
My question would be whether these sites are high-profile enough that we should check in a site-specific hack for them, and whether not checking in would make it more likely that the site authors would update sooner.
To put it differently, if we do land this hack, what are the criteria we'll use to decide when to revert it, and how will we remember to check on them?

We chatted some more on #webkit and I believe the general consensus is that we don't to land this patch. Wikipedia is now serving the hack-free theme, which should serve as the right motivator for others to catch up.

The largest single user of MediaWiki other than Wikimedia is wikia.com, most likely. Some other large wikis are listed here:
http://s23.org/wikistats/largest_html.php
The problem is more lots of little sites than a few big ones, I'd think. MediaWiki is probably the most popular wiki software out there even if you don't count Wikipedia. For instance, my mother is an art historian and has sometimes used a wiki meant to track university job openings in 19th century art history, which runs MediaWiki. She was using Chrome for a while and would undoubtedly summon me and ask for an explanation if it randomly broke. There are zillions of little sites like that.
I don't what your/WebKit's attitude is on maintaining compatibility vs. cleaning out cruft, so I can't say what you should do. Not having a fix in place for, say, the next couple of years would certainly break a lot of sites, that's all I can say. We don't have a very good upgrade rate; there are still a remarkable number of sites running three-year-old copies of MediaWiki.

(In reply to comment #36)
> We chatted some more on #webkit and I believe the general consensus is that we
> don't to land this patch. Wikipedia is now serving the hack-free theme, which
> should serve as the right motivator for others to catch up.
We should publicize that version 1.16 or later is required. Or otherwise people think it's WebKit/Safari/Chrome's fault and we obviously don't want that.

Are there some sites that still have that older version of MediaWiki running? Clearly it will be straightforward to broaden the workaround to cover the other cases if there is a significant benefit to doing so and at least one site to test with.

Yes, it should be basically any MediaWiki site other than Wikipedia, due to the <link> issue. The change from @import to <link> only occurred in <http://www.mediawiki.org/wiki/Special:Code/MediaWiki/52886>, which is after the last stable release (1.15). So look at almost any non-Wikimedia, non-Wikia wiki that uses the default MonoBook skin, e.g., http://wikileaks.org/. Wikileaks makes some effort to hide their version, but it looks like it's based off 1.10, so they should exhibit both problems (extra newline for <= 1.11, and <link> for <= 1.15). I can confirm the problem is visible there.
For that matter, you could also check almost any wiki from this list that's not a Wikimedia or Wikia project:
http://s23.org/wikistats/largest_html.php?th=999&lines=999

(In reply to comment #42)
> Are there some sites that still have that older version of MediaWiki running?
> Clearly it will be straightforward to broaden the workaround to cover the other
> cases if there is a significant benefit to doing so and at least one site to
> test with.
<http://wikileaks.org/> is one such site.

Unfortunately, 47 out of 200 top WikiMedia users are still using the version 1.5 or older according to http://s23.org/wikistats/largest_html.php.
It appears that we'll need to wait for another couple of years before we can remove this work around.