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

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:06:09 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 192ad32a1abd0cdb8f66e778abd2a6f7737e36b5
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 22 00:22:25 2002 +0000

            Fixed from SK's copy/paste whitespace issue.
            This fixes 3076236 and a regression due to additional whitespace
            in the DOM.
    
            * kwq/WebCoreBridge.mm:
            (attributedString):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2809 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 920d4f4..e7e7639 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,12 @@
+2002-11-21  Richard Williamson   <rjw at apple.com>
+
+        Fixed from SK's copy/paste whitespace issue.
+        This fixes 3076236 and a regression due to additional whitespace
+        in the DOM.
+        
+        * kwq/WebCoreBridge.mm:
+        (attributedString):
+
 === Alexander-33 ===
 
 2002-11-21  David Hyatt  <hyatt at apple.com>
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 920d4f4..e7e7639 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,12 @@
+2002-11-21  Richard Williamson   <rjw at apple.com>
+
+        Fixed from SK's copy/paste whitespace issue.
+        This fixes 3076236 and a regression due to additional whitespace
+        in the DOM.
+        
+        * kwq/WebCoreBridge.mm:
+        (attributedString):
+
 === Alexander-33 ===
 
 2002-11-21  David Hyatt  <hyatt at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 920d4f4..e7e7639 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,12 @@
+2002-11-21  Richard Williamson   <rjw at apple.com>
+
+        Fixed from SK's copy/paste whitespace issue.
+        This fixes 3076236 and a regression due to additional whitespace
+        in the DOM.
+        
+        * kwq/WebCoreBridge.mm:
+        (attributedString):
+
 === Alexander-33 ===
 
 2002-11-21  David Hyatt  <hyatt at apple.com>
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 7100c80..02dd6b5 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -583,26 +583,26 @@ using khtml::RenderPart;
 static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int startOffset, DOM::NodeImpl *endNode, int endOffset)
 {
     bool hasNewLine = true;
-    DOM::Node n = _startNode;
-    khtml::RenderObject *renderer;
+    bool hasParagraphBreak = true;
+DOM::Node n = _startNode;
+khtml::RenderObject *renderer;
     NSFont *font;
     NSMutableAttributedString *result = [[[NSMutableAttributedString alloc] init] autorelease];
     NSAttributedString *partialString;
-    
+
     while(!n.isNull()) {
         renderer = n.handle()->renderer();
         if (n.nodeType() == DOM::Node::TEXT_NODE && renderer) {
             QString text;
             QString str = n.nodeValue().string();
-            khtml::RenderStyle *style = 0;
-            
+khtml::RenderStyle *style = 0;
+
             font = nil;
             style = renderer->style();
             if (style) {
                 font = style->font().getNSFont();
             }
-            
-            hasNewLine = false;            
+
             if(n == _startNode && n == endNode && startOffset >=0 && endOffset >= 0)
                 text = str.mid(startOffset, endOffset - startOffset);
             else if(n == _startNode && startOffset >= 0)
@@ -611,21 +611,28 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                 text = str.left(endOffset);
             else
                 text = str;
-                
-            if (font){
-                NSMutableDictionary *attrs = [[[NSMutableDictionary alloc] init] autorelease];
-                [attrs setObject:font forKey:NSFontAttributeName];
-                if (style && style->color().isValid())
-                    [attrs setObject:style->color().getNSColor() forKey:NSForegroundColorAttributeName];
-                if (style && style->backgroundColor().isValid())
-                    [attrs setObject:style->backgroundColor().getNSColor() forKey:NSBackgroundColorAttributeName];
-                partialString = [[NSAttributedString alloc] initWithString: text.getNSString() attributes: attrs];
+
+            text = text.stripWhiteSpace();
+            if (text.length() > 1)
+                text += ' ';
+
+            if (text.length() > 0){
+                hasNewLine = false;
+                hasParagraphBreak = false;
+                if (font){
+                    NSMutableDictionary *attrs = [[[NSMutableDictionary alloc] init] autorelease];
+                    [attrs setObject:font forKey:NSFontAttributeName];
+                    if (style && style->color().isValid())
+                        [attrs setObject:style->color().getNSColor() forKey:NSForegroundColorAttributeName];
+                    if (style && style->backgroundColor().isValid())
+                        [attrs setObject:style->backgroundColor().getNSColor() forKey:NSBackgroundColorAttributeName];
+                    partialString = [[[NSAttributedString alloc] initWithString: text.getNSString() attributes: attrs] autorelease];
+                }
+                else
+                    partialString = [[[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil] autorelease];
+
+                [result appendAttributedString: partialString];
             }
-            else
-                partialString = [[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil];
-                
-            [result appendAttributedString: partialString];
-            [partialString release];
         }
         else if (renderer != 0){
             // This is our simple HTML -> ASCII transformation:
@@ -635,8 +642,8 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                 case ID_BR:
                     text += "\n";
                     hasNewLine = true;
-                break;
-        
+                    break;
+
                 case ID_TD:
                 case ID_TH:
                 case ID_HR:
@@ -652,7 +659,7 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                     if (!hasNewLine)
                         text += "\n";
                     hasNewLine = true;
-                break;
+                    break;
                 case ID_P:
                 case ID_TR:
                 case ID_H1:
@@ -663,26 +670,28 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                 case ID_H6:
                     if (!hasNewLine)
                         text += "\n";
-                    text += "\n";
+                    if (!hasParagraphBreak)
+                        text += "\n";
+                        hasParagraphBreak = true;
                     hasNewLine = true;
-                break;
+                    break;
             }
-            partialString = [[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil];
+            partialString = [[[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil] autorelease];
             [result appendAttributedString: partialString];
-            [partialString release];
         }
-        
+
         if(n == endNode)
             break;
-        
-        DOM::Node next = n.firstChild();
+
+DOM::Node next = n.firstChild();
         if(next.isNull())
             next = n.nextSibling();
+
         while( next.isNull() && !n.parentNode().isNull() ) {
             QString text;
             n = n.parentNode();
             next = n.nextSibling();
-            
+
             unsigned short _id = n.elementId();
             switch(_id) {
                 case ID_TD:
@@ -697,10 +706,10 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                 case ID_PRE:
                 case ID_BLOCKQUOTE:
                 case ID_DIV:
-                if (!hasNewLine)
-                    text += "\n";
-                hasNewLine = true;
-                break;
+                    if (!hasNewLine)
+                        text += "\n";
+                    hasNewLine = true;
+                    break;
                 case ID_P:
                 case ID_TR:
                 case ID_H1:
@@ -709,34 +718,20 @@ static NSAttributedString *attributedString(DOM::NodeImpl *_startNode, int start
                 case ID_H4:
                 case ID_H5:
                 case ID_H6:
-                if (!hasNewLine)
-                    text += "\n";
-                // An extra newline is needed at the start, not the end, of these types of tags,
-                // so don't add another here.
-                hasNewLine = true;
-                break;
+                    if (!hasNewLine)
+                        text += "\n";
+                    // An extra newline is needed at the start, not the end, of these types of tags,
+                    // so don't add another here.
+                    hasNewLine = true;
+                    break;
             }
-            partialString = [[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil];
+            partialString = [[[NSAttributedString alloc] initWithString: text.getNSString() attributes: nil] autorelease];
             [result appendAttributedString: partialString];
-            [partialString release];
         }
-    
+
         n = next;
     }
-/*    
-    int start = 0;
-    int end = text.length();
-    
-    // Strip leading LFs
-    while ((start < end) && (text[start] == '\n'))
-        start++;
-    
-    // Strip excessive trailing LFs
-    while ((start < (end-1)) && (text[end-1] == '\n') && (text[end-2] == '\n'))
-        end--;
-        
-    text.mid(start, end-start);
-*/    
+
     return result;
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list