changeset 107645:6e29ba4351e0

Fix glyph_row reversed_p flag in empty lines between paragraphs. bidi.c (bidi_get_next_char_visually): Improve commentary. dispextern.h (PRODUCE_GLYPHS): Set the reversed_p flag in the iterator's glyph_row here. xdisp.c (handle_invisible_prop, set_iterator_to_next) (next_element_from_buffer): Don't set the reversed_p flag in the iterator's glyph_row here.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 28 Mar 2010 11:18:10 -0400
parents 1d298baf84b9
children dfdf14a6f5a0
files src/ChangeLog.bidi src/bidi.c src/dispextern.h src/xdisp.c
diffstat 4 files changed, 23 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog.bidi	Sun Mar 28 09:04:11 2010 -0400
+++ b/src/ChangeLog.bidi	Sun Mar 28 11:18:10 2010 -0400
@@ -1,3 +1,14 @@
+2010-03-28  Eli Zaretskii  <eliz@gnu.org>
+
+	* bidi.c (bidi_get_next_char_visually): Improve commentary.
+
+	* dispextern.h (PRODUCE_GLYPHS): Set the reversed_p flag in the
+	iterator's glyph_row here.
+
+	* xdisp.c (handle_invisible_prop, set_iterator_to_next)
+	(next_element_from_buffer): Don't set the reversed_p flag in the
+	iterator's glyph_row here.
+
 2010-03-20  Eli Zaretskii  <eliz@gnu.org>
 
 	* xdisp.c (set_cursor_from_row): Don't miss a candidate row whose
--- a/src/bidi.c	Sun Mar 28 09:04:11 2010 -0400
+++ b/src/bidi.c	Sun Mar 28 11:18:10 2010 -0400
@@ -1901,7 +1901,7 @@
 
   /* Reordering of resolved levels (clause L2) is implemented by
      jumping to the other edge of the level and flipping direction of
-     scanning the buffer whenever we find a level change.  */
+     scanning the text whenever we find a level change.  */
   if (new_level != old_level)
     {
       int ascending = new_level > old_level;
@@ -1959,7 +1959,9 @@
      paragraph direction, if needed.  We do this at the newline before
      the paragraph separator, because the next character might not be
      the first character of the next paragraph, due to the bidi
-     reordering.  */
+     reordering, whereas we _must_ know the paragraph base direction
+     _before_ we process the paragraph's text, since the base
+     direction affects the reordering.  */
   if (bidi_it->scan_dir == 1
       && bidi_it->orig_type == NEUTRAL_B
       && bidi_it->bytepos < ZV_BYTE)
--- a/src/dispextern.h	Sun Mar 28 09:04:11 2010 -0400
+++ b/src/dispextern.h	Sun Mar 28 11:18:10 2010 -0400
@@ -2399,6 +2399,13 @@
 #define PRODUCE_GLYPHS(IT)                              \
   do {                                                  \
     extern int inhibit_free_realized_faces;             \
+    if ((IT)->glyph_row != NULL && (IT)->bidi_p)	\
+      {							\
+        if ((IT)->bidi_it.paragraph_dir == R2L)		\
+	  (IT)->glyph_row->reversed_p = 1;		\
+	else						\
+	  (IT)->glyph_row->reversed_p = 0;		\
+      }							\
     if (FRAME_RIF ((IT)->f) != NULL)                    \
       FRAME_RIF ((IT)->f)->produce_glyphs ((IT));       \
     else                                                \
--- a/src/xdisp.c	Sun Mar 28 09:04:11 2010 -0400
+++ b/src/xdisp.c	Sun Mar 28 11:18:10 2010 -0400
@@ -3869,15 +3869,6 @@
 		     skip any text at the beginning, which resets the
 		     FIRST_ELT flag.  */
 		  bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
-		  /* If the paragraph base direction is R2L, its
-		     glyphs should be reversed.  */
-		  if (it->glyph_row)
-		    {
-		      if (it->bidi_it.paragraph_dir == R2L)
-			it->glyph_row->reversed_p = 1;
-		      else
-			it->glyph_row->reversed_p = 0;
-		    }
 		}
 	      do
 		{
@@ -6235,16 +6226,7 @@
 	      /* If this is a new paragraph, determine its base
 		 direction (a.k.a. its base embedding level).  */
 	      if (it->bidi_it.new_paragraph)
-		{
-		  bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
-		  if (it->glyph_row)
-		    {
-		      if (it->bidi_it.paragraph_dir == R2L)
-			it->glyph_row->reversed_p = 1;
-		      else
-			it->glyph_row->reversed_p = 0;
-		    }
-		}
+		bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
 	      bidi_get_next_char_visually (&it->bidi_it);
 	      IT_BYTEPOS (*it) = it->bidi_it.bytepos;
 	      IT_CHARPOS (*it) = it->bidi_it.charpos;
@@ -6705,15 +6687,6 @@
 	  || FETCH_CHAR (it->bidi_it.bytepos) == '\n')
 	{
 	  bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
-	  /* If the paragraph base direction is R2L, its glyphs should
-	     be reversed.  */
-	  if (it->glyph_row)
-	    {
-	      if (it->bidi_it.paragraph_dir == R2L)
-		it->glyph_row->reversed_p = 1;
-	      else
-		it->glyph_row->reversed_p = 0;
-	    }
 	  bidi_get_next_char_visually (&it->bidi_it);
 	}
       else
@@ -6728,13 +6701,6 @@
 	  it->bidi_it.charpos = IT_CHARPOS (*it);
 	  it->bidi_it.bytepos = IT_BYTEPOS (*it);
 	  bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it);
-	  if (it->glyph_row)
-	    {
-	      if (it->bidi_it.paragraph_dir == R2L)
-		it->glyph_row->reversed_p = 1;
-	      else
-		it->glyph_row->reversed_p = 0;
-	    }
 	  do
 	    {
 	      /* Now return to buffer position where we were asked to