From: Brion Vibber Date: Wed, 13 Jun 2007 20:08:19 +0000 (+0000) Subject: * (bug 9948) Workaround for diff regression with old Mozilla versions X-Git-Tag: 1.31.0-rc.0~52554 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=ccb2a064fc87c0d41232e5154caf70a780c1be06;p=lhc%2Fweb%2Fwiklou.git * (bug 9948) Workaround for diff regression with old Mozilla versions Use JS to detect old Gecko versions known to have bogus implementation of overflow: auto for vertical sizing
s in table cells and change it to overflow: visible for an ugly but more-or-less-legible fallback behavior. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8160300c63..223f155b46 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -164,6 +164,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10215) Show custom editing introduction when editing existing pages * (bug 10223) Fix edit link in noarticletext localizations for fr, oc * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches +* (bug 9948) Workaround for diff regression with old Mozilla versions == API changes since 1.10 == diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 8d96e3d476..98847b9d54 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -296,11 +296,22 @@ CONTROL; $wgOut->addWikitext( wfMsg( 'missingarticle', "(fixme, bug)" ) ); return false; } else { - $wgOut->addStyle( 'common/diff.css' ); + $this->showDiffStyle(); $wgOut->addHTML( $diff ); return true; } } + + /** + * Add style sheets and supporting JS for diff display. + */ + function showDiffStyle() { + global $wgStylePath, $wgStyleVersion, $wgOut; + $wgOut->addStyle( 'common/diff.css' ); + + // JS is needed to detect old versions of Mozilla to work around an annoyance bug. + $wgOut->addScript( "" ); + } /** * Get diff table, including header diff --git a/includes/EditPage.php b/includes/EditPage.php index b67189f771..3a8038a680 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1104,8 +1104,7 @@ class EditPage { } if ( 'diff' == $this->formtype ) { - $wgOut->addStyle( 'common/diff.css' ); - $wgOut->addHTML( $this->getDiff() ); + $this->showDiff(); } } @@ -1287,8 +1286,7 @@ END } if ( $this->formtype == 'diff') { - $wgOut->addStyle( 'common/diff.css' ); - $wgOut->addHTML( $this->getDiff() ); + $this->showDiff(); } } @@ -1910,10 +1908,8 @@ END * * If this is a section edit, we'll replace the section as for final * save and then make a comparison. - * - * @return string HTML */ - function getDiff() { + function showDiff() { $oldtext = $this->mArticle->fetchContent(); $newtext = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime ); @@ -1924,11 +1920,13 @@ END $de = new DifferenceEngine( $this->mTitle ); $de->setText( $oldtext, $newtext ); $difftext = $de->getDiff( $oldtitle, $newtitle ); + $de->showDiffStyle(); } else { $difftext = ''; } - return '
' . $difftext . '
'; + global $wgOut; + $wgOut->addHtml( '
' . $difftext . '
' ); } /** diff --git a/skins/common/diff.css b/skins/common/diff.css index f8825a39e5..6a1f23b5d5 100644 --- a/skins/common/diff.css +++ b/skins/common/diff.css @@ -62,4 +62,13 @@ table.diff td div { /* As fallback, scrollbars will be added for very wide cells instead of text overflowing or widening */ overflow: auto; + + /* The above rule breaks on very old versions of Mozilla due + to a bug which collapses the table cells to a single line. + + In Mozilla 1.1 and below with JavaScript enabled, the rule + will be overridden with this by diff.js; wide cell contents + then spill horizontally without widening the rest of the + table: */ + /* overflow: visible; */ } diff --git a/skins/common/diff.js b/skins/common/diff.js new file mode 100644 index 0000000000..e80a895c0b --- /dev/null +++ b/skins/common/diff.js @@ -0,0 +1,20 @@ +/* +Workaround for overflow bug in Mozilla 1.1 and earlier, where scrolling +
s in cells collapse their height to a single line. + +Known to be fixed in 1.2.1 (Gecko 20021130), but the CSS hacks I've tried +with overflow-x disable the scrolling all the way until Mozilla 1.8 / FF 1.5 +and break Opera as well. + +So... we check for reaaaally old Gecko and hack in an alternate rule to let +the wide cells spill instead of scrolling them. Not ideal as it won't work +if JS is disabled, of course. +*/ + +if (navigator && navigator.product == "Gecko" && navigator.productSub < "20021130") { + var sheets = document.styleSheets; + var lastSheet = sheets[sheets.length-1]; + lastSheet.insertRule( + "table.diff td div { overflow: visible; }", + lastSheet.cssRules.length); +} \ No newline at end of file