[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/khtml/rendering
From:       Allan Sandfeld Jensen <kde () carewolf ! com>
Date:       2004-12-02 13:25:12
Message-ID: 20041202132512.EBFFB1BAB0 () office ! kde ! org
[Download RAW message or body]

CVS commit by carewolf: 

Some minor WebCore merge of trimmedWidth.


  M +16 -12    render_text.cpp   1.255


--- kdelibs/khtml/rendering/render_text.cpp  #1.254:1.255
@@ -1080,5 +1080,5 @@ void RenderText::calcMinMaxWidth()
         else {
             // Nowrap can never be broken, so don't bother setting the
-            // breakable character boolean.
+            // breakable character boolean. Pre can only be broken if we encounter a newline.
             if (style()->whiteSpace() == NORMAL || isNewline)
                 m_hasBreakableChar = true;
@@ -1087,5 +1087,5 @@ void RenderText::calcMinMaxWidth()
             currMinWidth = 0;
 
-            if (isNewline)
+            if (isNewline) // Only set if isPre was true and we saw a newline.
             {
                 if ( firstLine ) {
@@ -1337,14 +1337,19 @@ void RenderText::trimmedMinMaxWidth(shor
                                     short& minW, short& maxW, bool& stripFrontSpaces)
 {
-    int len = str->l;
     bool isPre = style()->whiteSpace() == PRE;
     if (isPre)
         stripFrontSpaces = false;
 
+    int len = str->l;
+    if (len == 0 || (stripFrontSpaces && str->containsOnlyWhitespace())) {
+        maxW = 0;
+        hasBreak = false;
+        return;
+    }
+
     minW = m_minWidth;
     maxW = m_maxWidth;
     beginWS = stripFrontSpaces ? false : m_hasBeginWS;
-    // Handle the case where all space got stripped.
-    endWS = stripFrontSpaces && len > 0 && str->containsOnlyWhitespace() ? false : m_hasEndWS;
+    endWS = m_hasEndWS;
 
     beginMinW = m_beginMinWidth;
@@ -1354,8 +1359,5 @@ void RenderText::trimmedMinMaxWidth(shor
     hasBreak = m_hasBreak;
 
-    if (len == 0)
-        return;
-
-    if (stripFrontSpaces && str->s[0].direction() == QChar::DirWS) {
+    if (stripFrontSpaces && (str->s[0].direction() == QChar::DirWS || (!isPre && str->s[0] == '\n'))) {
         const Font *f = htmlFont( false );
         QChar space[1]; space[0] = ' ';
@@ -1364,5 +1366,5 @@ void RenderText::trimmedMinMaxWidth(shor
     }
 
-    stripFrontSpaces = !isPre && endWS;
+    stripFrontSpaces = !isPre && m_hasEndWS;
 
     if (style()->whiteSpace() == NOWRAP)
@@ -1394,6 +1396,4 @@ void RenderText::trimmedMinMaxWidth(shor
                 }
                 i += linelen;
-                if (i == len-1)
-                    endMaxW = 0;
             }
             else if (firstLine) {
@@ -1401,4 +1401,8 @@ void RenderText::trimmedMinMaxWidth(shor
                 firstLine = false;
             }
+            if (i == len-1)
+                // A <pre> run that ends with a newline, as in, e.g.,
+                // <pre>Some text\n\n<span>More text</pre>
+                endMaxW = 0;
         }
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic