Merge "CSSJanus: Account for attribute selectors in brace lookahead"
[lhc/web/wiklou.git] / includes / diff / DairikiDiff.php
index cc2b4c5..c47eced 100644 (file)
@@ -35,7 +35,7 @@ abstract class DiffOp {
        public $orig;
        public $closing;
 
-       public abstract function reverse();
+       abstract public function reverse();
 
        /**
         * @return int
@@ -384,6 +384,8 @@ class DiffEngine {
                                if ( empty( $ymatches[$line] ) ) {
                                        continue;
                                }
+
+                               $k = 0;
                                $matches = $ymatches[$line];
                                reset( $matches );
                                while ( list( , $y ) = each( $matches ) ) {
@@ -394,6 +396,7 @@ class DiffEngine {
                                                break;
                                        }
                                }
+
                                while ( list( , $y ) = each( $matches ) ) {
                                        if ( $y > $this->seq[$k - 1] ) {
                                                assert( '$y < $this->seq[$k]' );
@@ -669,7 +672,6 @@ class Diff {
        function __construct( $from_lines, $to_lines ) {
                $eng = new DiffEngine;
                $this->edits = $eng->diff( $from_lines, $to_lines );
-               // $this->check($from_lines, $to_lines);
        }
 
        /**
@@ -765,43 +767,6 @@ class Diff {
 
                return $lines;
        }
-
-       /**
-        * Check a Diff for validity.
-        *
-        * This is here only for debugging purposes.
-        * @param $from_lines
-        * @param $to_lines
-        */
-       private function check( $from_lines, $to_lines ) {
-               wfProfileIn( __METHOD__ );
-               if ( serialize( $from_lines ) != serialize( $this->orig() ) ) {
-                       trigger_error( "Reconstructed original doesn't match", E_USER_ERROR );
-               }
-               if ( serialize( $to_lines ) != serialize( $this->closing() ) ) {
-                       trigger_error( "Reconstructed closing doesn't match", E_USER_ERROR );
-               }
-
-               $rev = $this->reverse();
-               if ( serialize( $to_lines ) != serialize( $rev->orig() ) ) {
-                       trigger_error( "Reversed original doesn't match", E_USER_ERROR );
-               }
-               if ( serialize( $from_lines ) != serialize( $rev->closing() ) ) {
-                       trigger_error( "Reversed closing doesn't match", E_USER_ERROR );
-               }
-
-               $prevtype = 'none';
-               foreach ( $this->edits as $edit ) {
-                       if ( $prevtype == $edit->type ) {
-                               trigger_error( 'Edit sequence is non-optimal', E_USER_ERROR );
-                       }
-                       $prevtype = $edit->type;
-               }
-
-               $lcs = $this->lcs();
-               trigger_error( 'Diff okay: LCS = ' . $lcs, E_USER_NOTICE );
-               wfProfileOut( __METHOD__ );
-       }
 }
 
 /**
@@ -871,6 +836,9 @@ class MappedDiff extends Diff {
  * @ingroup DifferenceEngine
  */
 class HWLDFWordAccumulator {
+       public $insClass = ' class="diffchange diffchange-inline"';
+       public $delClass = ' class="diffchange diffchange-inline"';
+
        private $lines = array();
        private $line = '';
        private $group = '';
@@ -882,10 +850,10 @@ class HWLDFWordAccumulator {
        private function flushGroup( $new_tag ) {
                if ( $this->group !== '' ) {
                        if ( $this->tag == 'ins' ) {
-                               $this->line .= '<ins class="diffchange diffchange-inline">' .
+                               $this->line .= "<ins{$this->insClass}>" .
                                        htmlspecialchars( $this->group ) . '</ins>';
                        } elseif ( $this->tag == 'del' ) {
-                               $this->line .= '<del class="diffchange diffchange-inline">' .
+                               $this->line .= "<del{$this->delClass}>" .
                                        htmlspecialchars( $this->group ) . '</del>';
                        } else {
                                $this->line .= htmlspecialchars( $this->group );