r22970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22969‎ | r22970 | r22971 >
Date:20:08, 13 June 2007
Author:brion
Status:old
Tags:
Comment:
* (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 <div>s in table cells and change it to overflow: visible for an ugly but more-or-less-legible fallback behavior.
Modified paths:
  • /trunk/extensions/Oversight/HideRevision.php (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DifferenceEngine.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/skins/common/diff.css (modified) (history)
  • /trunk/phase3/skins/common/diff.js (added) (history)

Diff [purge]

Index: trunk/phase3/skins/common/diff.js
@@ -0,0 +1,20 @@
 2+/*
 3+Workaround for overflow bug in Mozilla 1.1 and earlier, where scrolling
 4+<div>s in <td> cells collapse their height to a single line.
 5+
 6+Known to be fixed in 1.2.1 (Gecko 20021130), but the CSS hacks I've tried
 7+with overflow-x disable the scrolling all the way until Mozilla 1.8 / FF 1.5
 8+and break Opera as well.
 9+
 10+So... we check for reaaaally old Gecko and hack in an alternate rule to let
 11+the wide cells spill instead of scrolling them. Not ideal as it won't work
 12+if JS is disabled, of course.
 13+*/
 14+
 15+if (navigator && navigator.product == "Gecko" && navigator.productSub < "20021130") {
 16+ var sheets = document.styleSheets;
 17+ var lastSheet = sheets[sheets.length-1];
 18+ lastSheet.insertRule(
 19+ "table.diff td div { overflow: visible; }",
 20+ lastSheet.cssRules.length);
 21+}
\ No newline at end of file
Property changes on: trunk/phase3/skins/common/diff.js
___________________________________________________________________
Name: svn:eol-style
122 + native
Index: trunk/phase3/skins/common/diff.css
@@ -62,4 +62,13 @@
6363 /* As fallback, scrollbars will be added for very wide cells
6464 instead of text overflowing or widening */
6565 overflow: auto;
 66+
 67+ /* The above rule breaks on very old versions of Mozilla due
 68+ to a bug which collapses the table cells to a single line.
 69+
 70+ In Mozilla 1.1 and below with JavaScript enabled, the rule
 71+ will be overridden with this by diff.js; wide cell contents
 72+ then spill horizontally without widening the rest of the
 73+ table: */
 74+ /* overflow: visible; */
6675 }
Index: trunk/phase3/includes/EditPage.php
@@ -1104,8 +1104,7 @@
11051105 }
11061106
11071107 if ( 'diff' == $this->formtype ) {
1108 - $wgOut->addStyle( 'common/diff.css' );
1109 - $wgOut->addHTML( $this->getDiff() );
 1108+ $this->showDiff();
11101109 }
11111110 }
11121111
@@ -1287,8 +1286,7 @@
12881287 }
12891288
12901289 if ( $this->formtype == 'diff') {
1291 - $wgOut->addStyle( 'common/diff.css' );
1292 - $wgOut->addHTML( $this->getDiff() );
 1290+ $this->showDiff();
12931291 }
12941292
12951293 }
@@ -1910,10 +1908,8 @@
19111909 *
19121910 * If this is a section edit, we'll replace the section as for final
19131911 * save and then make a comparison.
1914 - *
1915 - * @return string HTML
19161912 */
1917 - function getDiff() {
 1913+ function showDiff() {
19181914 $oldtext = $this->mArticle->fetchContent();
19191915 $newtext = $this->mArticle->replaceSection(
19201916 $this->section, $this->textbox1, $this->summary, $this->edittime );
@@ -1924,11 +1920,13 @@
19251921 $de = new DifferenceEngine( $this->mTitle );
19261922 $de->setText( $oldtext, $newtext );
19271923 $difftext = $de->getDiff( $oldtitle, $newtitle );
 1924+ $de->showDiffStyle();
19281925 } else {
19291926 $difftext = '';
19301927 }
19311928
1932 - return '<div id="wikiDiff">' . $difftext . '</div>';
 1929+ global $wgOut;
 1930+ $wgOut->addHtml( '<div id="wikiDiff">' . $difftext . '</div>' );
19331931 }
19341932
19351933 /**
Index: trunk/phase3/includes/DifferenceEngine.php
@@ -296,11 +296,22 @@
297297 $wgOut->addWikitext( wfMsg( 'missingarticle', "<nowiki>(fixme, bug)</nowiki>" ) );
298298 return false;
299299 } else {
300 - $wgOut->addStyle( 'common/diff.css' );
 300+ $this->showDiffStyle();
301301 $wgOut->addHTML( $diff );
302302 return true;
303303 }
304304 }
 305+
 306+ /**
 307+ * Add style sheets and supporting JS for diff display.
 308+ */
 309+ function showDiffStyle() {
 310+ global $wgStylePath, $wgStyleVersion, $wgOut;
 311+ $wgOut->addStyle( 'common/diff.css' );
 312+
 313+ // JS is needed to detect old versions of Mozilla to work around an annoyance bug.
 314+ $wgOut->addScript( "<script type=\"text/javascript\" src=\"$wgStylePath/common/diff.js?$wgStyleVersion\"></script>" );
 315+ }
305316
306317 /**
307318 * Get diff table, including header
Index: trunk/phase3/RELEASE-NOTES
@@ -164,6 +164,7 @@
165165 * (bug 10215) Show custom editing introduction when editing existing pages
166166 * (bug 10223) Fix edit link in noarticletext localizations for fr, oc
167167 * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
 168+* (bug 9948) Workaround for diff regression with old Mozilla versions
168169
169170
170171 == API changes since 1.10 ==
Index: trunk/extensions/Oversight/HideRevision.php
@@ -663,7 +663,8 @@
664664 }
665665 $ntext = strval( $rev->getText());
666666
667 - $wgOut->addStyle( 'common/diff.css' );
 667+ $diffEngine = new DifferenceEngine();
 668+ $diffEngine->showDiffStyle();
668669 $wgOut->addHtml(
669670 "<ul>" .
670671 $info .
@@ -683,7 +684,7 @@
684685 "<td colspan='2' width='50%' align='center' class='diff-otitle'>" . wfMsgHTML('oversight-prev') . " (#$prevId)" . "</td>" .
685686 "<td colspan='2' width='50%' align='center' class='diff-ntitle'>" . wfMsgHTML('oversight-hidden') . "</td>" .
686687 "</tr>" .
687 - DifferenceEngine::generateDiffBody( $otext, $ntext ) .
 688+ $diffEngine->generateDiffBody( $otext, $ntext ) .
688689 "</table>" .
689690 "</div>\n" );
690691 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r23039Merged revisions 22967-23037 via svnmerge from...david20:15, 16 June 2007

Status & tagging log