[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:31:13 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 78b851340383f071b51bfef4a14ed38e74bfade9
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Mar 29 20:07:45 2004 +0000

    	Fix for 3604154, support soft hyphens when rendering.  This patch implements soft hyphen support that
    	matches IE6 on Windows and Opera 7.  Soft hyphens that don't break lines end up getting collapsed away.
    	Only if the hyphen breaks a line does it render.
    
            Reviewed by kocienda
    
            * khtml/rendering/bidi.cpp:
            (khtml::chopMidpointsAt):
            (khtml::appendRunsForObject):
            (khtml::RenderBlock::findNextLineBreak):
            * khtml/rendering/render_text.cpp:
            (RenderText::calcMinMaxWidth):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 4701421..69e5681 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2004-03-29  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3604154, support soft hyphens when rendering.  This patch implements soft hyphen support that
+	matches IE6 on Windows and Opera 7.  Soft hyphens that don't break lines end up getting collapsed away.
+	Only if the hyphen breaks a line does it render.
+	
+        Reviewed by kocienda
+
+        * khtml/rendering/bidi.cpp:
+        (khtml::chopMidpointsAt):
+        (khtml::appendRunsForObject):
+        (khtml::RenderBlock::findNextLineBreak):
+        * khtml/rendering/render_text.cpp:
+        (RenderText::calcMinMaxWidth):
+
 2004-03-29  John Sullivan  <sullivan at apple.com>
 
         Made menu shortcuts work again when editing HTML
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index 3ceb121..7dc8090 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -433,6 +433,19 @@ static void reverseRuns(int start, int end)
         sLastBidiRun = startRun;
 }
 
+static void chopMidpointsAt(RenderObject* obj, uint pos)
+{
+    if (!sNumMidpoints) return;
+    BidiIterator* midpoints = smidpoints->data();
+    for (uint i = 0; i < sNumMidpoints; i++) {
+        const BidiIterator& point = midpoints[i];
+        if (point.obj == obj && point.pos == pos) {
+            sNumMidpoints = i;
+            break;
+        }
+    }
+}
+
 static void checkMidpoints(BidiIterator& lBreak, BidiState &bidi)
 {
     // Check to see if our last midpoint is a start point beyond the line break.  If so,
@@ -493,7 +506,7 @@ static void appendRunsForObject(int start, int end, RenderObject* obj, BidiState
             return;
         }
         
-        // An end midpoint has been encounted within our object.  We
+        // An end midpoint has been encountered within our object.  We
         // need to go ahead and append a run with our endpoint.
         if (int(nextMidpoint.pos+1) <= end) {
             betweenMidpoints = true;
@@ -1871,6 +1884,31 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
                 if (isPre || !currentCharacterIsSpace)
                     isLineEmpty = false;
                 
+                // Check for soft hyphens.  Go ahead and ignore them.
+                if (c.unicode() == SOFT_HYPHEN && pos > 0) {
+                    if (!ignoringSpaces) {
+                        // Ignore soft hyphens
+                        BidiIterator endMid(0, o, pos-1);
+                        addMidpoint(endMid);
+                        
+                        // Add the width up to but not including the hyphen.
+                        tmpW += t->width(lastSpace, pos - lastSpace, f);
+                        
+                        // For whitespace normal only, include the hyphen.  We need to ensure it will fit
+                        // on the line if it shows when we break.
+                        if (o->style()->whiteSpace() == NORMAL)
+                            tmpW += t->width(pos, 1, f);
+                        
+                        BidiIterator startMid(0, o, pos+1);
+                        addMidpoint(startMid);
+                    }
+                    
+                    pos++;
+                    len--;
+                    lastSpace = pos; // Cheesy hack to prevent adding in widths of the run twice.
+                    continue;
+                }
+                
                 bool applyWordSpacing = false;
                 if ( (isPre && c == '\n') || (!isPre && isBreakable( str, pos, strlen )) ) {
                     if (ignoringSpaces) {
@@ -1926,8 +1964,12 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
                         }
                     }
         
-                    if (w + tmpW > width && o->style()->whiteSpace() == NORMAL){
-                        goto end;
+                    if (o->style()->whiteSpace() == NORMAL) {
+                        if (w + tmpW > width)
+                            goto end; // Didn't fit. Jump to the end.
+                        else if (pos > 1 && str[pos-1].unicode() == SOFT_HYPHEN)
+                            // Subtract the width of the soft hyphen out since we fit on a line.
+                            tmpW -= t->width(pos-1, 1, f);
                     }
 
                     if( *(str+pos) == '\n' && isPre) {
@@ -2159,6 +2201,14 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
 	lBreak.increment(bidi);
     }
 
+    if (lBreak.obj && lBreak.pos >= 2 && lBreak.obj->isText()) {
+        // For soft hyphens on line breaks, we have to chop out the midpoints that made us
+        // ignore the hyphen so that it will render at the end of the line.
+        QChar c = static_cast<RenderText*>(lBreak.obj)->text()[lBreak.pos-1];
+        if (c.unicode() == SOFT_HYPHEN)
+            chopMidpointsAt(lBreak.obj, lBreak.pos-2);
+    }
+    
     return lBreak;
 }
 
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index f5d7651..8e647b0 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -1060,11 +1060,12 @@ void RenderText::calcMinMaxWidth()
         if (ignoringSpaces && !isSpace)
             ignoringSpaces = false;
             
-        if (ignoringSpaces)
+        if (ignoringSpaces || (i > 0 && c.unicode() == SOFT_HYPHEN)) // Ignore spaces and soft hyphens
             continue;
         
         int wordlen = 0;
         while (i+wordlen < len && str->s[i+wordlen] != '\n' && str->s[i+wordlen] != ' ' &&
+               (i+wordlen == 0 || str->s[i+wordlen].unicode() != SOFT_HYPHEN) && // Skip soft hyphens
                (wordlen == 0 || !isBreakable( str->s, i+wordlen, str->l)))
             wordlen++;
             
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 3f92db1..9b62137 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -36,6 +36,9 @@
 class QPainter;
 class QFontMetrics;
 
+// Define a constant for soft hyphen's unicode value.
+#define SOFT_HYPHEN 173
+
 namespace khtml
 {
     class RenderText;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list