r112458 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112457‎ | r112458 | r112459 >
Date:00:09, 27 February 2012
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
[CodeReview/DiffHighlighter] Restore inline wrapper for diff text
* Restore inline wrapper for diff text to allow styling of the diff text with the correct inline content width (style for td.ins/td.del styles the entire line rather than just the text)
* Use Html::element() consistently in both the top and bottom of formatLine() for the line-numbers. No need to allow raw html in td.linenumbers, and if it does it should be documented and also allowed in other parts of the code.
* main change:
- Html::Element( 'td', $classAttr, $content )
// $inlineWrapEl is span, ins or del
+ Html::rawElement( 'td', $classAttr, Html::element( $inlineWrapEl, array() , $content ) )
Modified paths:
  • /trunk/extensions/CodeReview/backend/DiffHighlighter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/DiffHighlighter.php
@@ -86,18 +86,19 @@
8787
8888 function formatLine( $content, $class = null ) {
8989
90 - if( is_null($class) ) {
 90+ if ( $class === null ) {
9191 return Html::rawElement( 'tr', $this->getLineIdAttr(),
92 - Html::Element( 'td', array( 'class'=>'linenumbers' ), $this->left )
93 - . Html::Element( 'td', array( 'class'=>'linenumbers' ), $this->right )
94 - . Html::Element( 'td', array() , $content )
 92+ Html::element( 'td', array( 'class' => 'linenumbers' ), $this->left )
 93+ . Html::element( 'td', array( 'class' => 'linenumbers' ), $this->right )
 94+ . Html::rawElement( 'td', array() , Html::element( 'span', array() , $content ) )
9595 );
9696 }
9797
9898 # Skip line number when they do not apply
9999 $left = $right = ' ';
 100+ $inlineWrapEl = 'span';
100101
101 - switch( $class ) {
 102+ switch ( $class ) {
102103 case 'chunkdelimiter':
103104 $left = $right = '—';
104105 break;
@@ -107,20 +108,22 @@
108109 break;
109110 case 'del':
110111 $left = $this->left;
 112+ $inlineWrapEl = 'del';
111113 break;
112114 case 'ins':
113115 $right = $this->right;
 116+ $inlineWrapEl = 'ins';
114117 break;
115118
116119 default:
117120 # Rely on $left, $right initialization above
118121 }
119122
120 - $classAttr = is_null($class) ? array() : array( 'class' => $class );
 123+ $classAttr = is_null( $class ) ? array() : array( 'class' => $class );
121124 return Html::rawElement( 'tr', $this->getLineIdAttr(),
122 - Html::rawElement( 'td', array( 'class'=>'linenumbers' ), $left )
123 - . Html::rawElement( 'td', array( 'class'=>'linenumbers' ), $right )
124 - . Html::Element( 'td', $classAttr, $content )
 125+ Html::element( 'td', array( 'class' => 'linenumbers' ), $left )
 126+ . Html::element( 'td', array( 'class' => 'linenumbers' ), $right )
 127+ . Html::rawElement( 'td', $classAttr , Html::element( $inlineWrapEl, array() , $content ) )
125128 );
126129 }
127130

Follow-up revisions

RevisionCommit summaryAuthorDate
r112459MFT r112458demon00:16, 27 February 2012
r112460Follow-up r112458: html entities were showing up literally on the page. the n...krinkle00:29, 27 February 2012

Comments

#Comment by Krinkle (talk | contribs)   00:10, 27 February 2012

This makes it possible to fix bug 27375.

Status & tagging log