[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 07:50:13 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c623a3262226c044dd736cb2925b208bab666128
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 5 21:16:27 2003 +0000

    	Fix for 3127909, copied text matched the document source instead of the
    	rendered HTML.  This patch makes sure that the TextRuns are walked instead
    	of just blindly pulling the text out of the DOM node.
    
            Reviewed by rjw
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::selectedText):
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::attributedString):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4770 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index de97d42..b857d51 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,16 @@
+2003-08-04  Dave Hyatt  <hyatt at apple.com>
+
+	Fix for 3127909, copied text matched the document source instead of the
+	rendered HTML.  This patch makes sure that the TextRuns are walked instead
+	of just blindly pulling the text out of the DOM node.
+	
+        Reviewed by rjw
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::selectedText):
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::attributedString):
+
 2003-08-05  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin and Dave.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index de97d42..b857d51 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,16 @@
+2003-08-04  Dave Hyatt  <hyatt at apple.com>
+
+	Fix for 3127909, copied text matched the document source instead of the
+	rendered HTML.  This patch makes sure that the TextRuns are walked instead
+	of just blindly pulling the text out of the DOM node.
+	
+        Reviewed by rjw
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::selectedText):
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::attributedString):
+
 2003-08-05  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin and Dave.
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index fc6ca93..ce8fb71 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -2198,21 +2198,35 @@ bool KHTMLPart::findTextNext( const QString &str, bool forward, bool caseSensiti
 
 QString KHTMLPart::selectedText() const
 {
+    // FIXME: This whole function should use the render tree and not the DOM tree, since elements could
+    // be hidden using CSS, or additional generated content could be added.  For now, we just make sure
+    // text objects walk their renderers' TextRuns, so that we at least get the whitespace stripped out properly
+    // and obey CSS visibility for text runs.
   bool hasNewLine = true;
   QString text;
   DOM::Node n = d->m_selectionStart;
   while(!n.isNull()) {
       if(n.nodeType() == DOM::Node::TEXT_NODE) {
-        QString str = n.nodeValue().string();
-        hasNewLine = false;
-        if(n == d->m_selectionStart && n == d->m_selectionEnd)
-          text = str.mid(d->m_startOffset, d->m_endOffset - d->m_startOffset);
-        else if(n == d->m_selectionStart)
-          text = str.mid(d->m_startOffset);
-        else if(n == d->m_selectionEnd)
-          text += str.left(d->m_endOffset);
-        else
-          text += str;
+          hasNewLine = false;
+          QString str = n.nodeValue().string();
+          int start = (n == d->m_selectionStart) ? d->m_startOffset : -1;
+          int end = (n == d->m_selectionEnd) ? d->m_endOffset : -1;
+          if (n.handle()->renderer() && n.handle()->renderer()->isText()) {
+              RenderText* textObj = static_cast<RenderText*>(n.handle()->renderer());
+              TextRunArray runs = textObj->textRuns();
+              for (unsigned i = 0; i < runs.count(); i++) {
+                  int runStart = (start == -1) ? runs[i]->m_start : start;
+                  int runEnd = (end == -1) ? runs[i]->m_start + runs[i]->m_len : end;
+                  runEnd = QMIN(runEnd, runs[i]->m_start + runs[i]->m_len);
+                  if (runStart >= runs[i]->m_start &&
+                      runStart < runs[i]->m_start + runs[i]->m_len) {
+                      text += str.mid(runStart, runEnd - runStart);
+                      start = -1;
+                  }
+                  if (end != -1 && runEnd >= end)
+                      break;
+              }
+          }
       }
       else {
         // This is our simple HTML -> ASCII transformation:
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index cba570c..3374206 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -63,6 +63,8 @@ using DOM::ElementImpl;
 using DOM::EventImpl;
 using DOM::Node;
 
+using khtml::TextRunArray;
+
 using khtml::Cache;
 using khtml::ChildFrame;
 using khtml::Decoder;
@@ -1867,23 +1869,29 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
             RenderStyle *style = renderer->style();
             NSFont *font = style->font().getNSFont();
             if (n.nodeType() == Node::TEXT_NODE) {
-    
-                QString str = n.nodeValue().string();
-    
                 QString text;
-                if(n == _startNode && n == endNode && startOffset >=0 && endOffset >= 0)
-                    text = str.mid(startOffset, endOffset - startOffset);
-                else if(n == _startNode && startOffset >= 0)
-                    text = str.mid(startOffset);
-                else if(n == endNode && endOffset >= 0)
-                    text = str.left(endOffset);
-                else
-                    text = str;
-    
+                QString str = n.nodeValue().string();
+                int start = (n == _startNode) ? startOffset : -1;
+                int end = (n == endNode) ? endOffset : -1;
+                if (renderer->isText()) {
+                    RenderText* textObj = static_cast<RenderText*>(renderer);
+                    TextRunArray runs = textObj->textRuns();
+                    for (unsigned i = 0; i < runs.count(); i++) {
+                        int runStart = (start == -1) ? runs[i]->m_start : start;
+                        int runEnd = (end == -1) ? runs[i]->m_start + runs[i]->m_len : end;
+                        runEnd = QMIN(runEnd, runs[i]->m_start + runs[i]->m_len);
+                        if (runStart >= runs[i]->m_start &&
+                            runStart < runs[i]->m_start + runs[i]->m_len) {
+                            text += str.mid(runStart, runEnd - runStart);
+                            start = -1;
+                        }
+                        if (end != -1 && runEnd >= end)
+                            break;
+                    }
+                }
+                
                 text = text.stripWhiteSpace();
                 text.replace('\\', renderer->backslashAsCurrencySymbol());
-                if (text.length() > 1)
-                    text += ' ';
     
                 if (text.length() > 0) {
                     hasNewLine = false;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list