[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:51:43 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 34929959563204303e85a6d94db76bf3d484b94c
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Aug 14 06:44:24 2003 +0000
Fix for 3372896, spaces left at ends of lines. Patch the selection code
to be smarter about detecting ends of lines and adding in spaces.
Reviewed by gramps
* khtml/khtml_part.cpp:
(KHTMLPart::selectedText):
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::attributedString):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5367b71..b6bd179 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,15 @@
+2003-08-13 David Hyatt <hyatt at apple.com>
+
+ Fix for 3372896, spaces left at ends of lines. Patch the selection code
+ to be smarter about detecting ends of lines and adding in spaces.
+
+ Reviewed by gramps
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::selectedText):
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::attributedString):
+
2003-08-12 Maciej Stachowiak <mjs at apple.com>
Reviewed by Ken Kocienda.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5367b71..b6bd179 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2003-08-13 David Hyatt <hyatt at apple.com>
+
+ Fix for 3372896, spaces left at ends of lines. Patch the selection code
+ to be smarter about detecting ends of lines and adding in spaces.
+
+ Reviewed by gramps
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::selectedText):
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::attributedString):
+
2003-08-12 Maciej Stachowiak <mjs at apple.com>
Reviewed by Ken Kocienda.
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 2a858ee..cacda85 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -2208,28 +2208,58 @@ QString KHTMLPart::selectedText() const
// 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;
+ bool addedSpace = true;
QString text;
DOM::Node n = d->m_selectionStart;
while(!n.isNull()) {
if(n.nodeType() == DOM::Node::TEXT_NODE) {
- hasNewLine = false;
+ if (hasNewLine) {
+ addedSpace = true;
+ 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;
+ RenderObject* renderer = n.handle()->renderer();
+ if (renderer && renderer->isText()) {
+ if (renderer->style()->whiteSpace() == khtml::PRE) {
+ int runStart = (start == -1) ? 0 : start;
+ int runEnd = (end == -1) ? str.length() : end;
+ text += str.mid(runStart, runEnd-runStart);
+ addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ }
+ else {
+ RenderText* textObj = static_cast<RenderText*>(n.handle()->renderer());
+ TextRunArray runs = textObj->textRuns();
+ if (runs.count() == 0 && str.length() > 0 && !addedSpace) {
+ // We have no runs, but we do have a length. This means we must be
+ // whitespace that collapsed away at the end of a line.
+ text += " ";
+ addedSpace = true;
+ }
+ else {
+ addedSpace = false;
+ 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);
+ bool spaceBetweenRuns = false;
+ if (runStart >= runs[i]->m_start &&
+ runStart < runs[i]->m_start + runs[i]->m_len) {
+ text += str.mid(runStart, runEnd - runStart);
+ start = -1;
+ spaceBetweenRuns = i+1 < runs.count() && runs[i+1]->m_start > runEnd;
+ addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ }
+ if (end != -1 && runEnd >= end)
+ break;
+
+ if (spaceBetweenRuns && !addedSpace) {
+ text += " ";
+ addedSpace = true;
+ }
+ }
}
- if (end != -1 && runEnd >= end)
- break;
}
}
}
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index ad3b863..d08d020 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1865,6 +1865,7 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
NSMutableAttributedString *result = [[[NSMutableAttributedString alloc] init] autorelease];
bool hasNewLine = true;
+ bool addedSpace = true;
bool hasParagraphBreak = true;
const DOM::ElementImpl *linkStartNode = 0;
unsigned linkStartLocation = 0;
@@ -1890,32 +1891,59 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
RenderStyle *style = renderer->style();
NSFont *font = style->font().getNSFont();
if (n.nodeType() == Node::TEXT_NODE) {
+ if (hasNewLine) {
+ addedSpace = true;
+ hasNewLine = false;
+ }
QString text;
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 (renderer->style()->whiteSpace() == khtml::PRE) {
+ int runStart = (start == -1) ? 0 : start;
+ int runEnd = (end == -1) ? str.length() : end;
+ text += str.mid(runStart, runEnd-runStart);
+ addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ }
+ else {
+ RenderText* textObj = static_cast<RenderText*>(renderer);
+ TextRunArray runs = textObj->textRuns();
+ if (runs.count() == 0 && str.length() > 0 && !addedSpace) {
+ // We have no runs, but we do have a length. This means we must be
+ // whitespace that collapsed away at the end of a line.
+ text += " ";
+ addedSpace = true;
+ }
+ else {
+ addedSpace = false;
+ 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);
+ bool spaceBetweenRuns = false;
+ if (runStart >= runs[i]->m_start &&
+ runStart < runs[i]->m_start + runs[i]->m_len) {
+ text += str.mid(runStart, runEnd - runStart);
+ start = -1;
+ spaceBetweenRuns = i+1 < runs.count() && runs[i+1]->m_start > runEnd;
+ addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ }
+ if (end != -1 && runEnd >= end)
+ break;
+
+ if (spaceBetweenRuns && !addedSpace) {
+ text += " ";
+ addedSpace = true;
+ }
+ }
}
- if (end != -1 && runEnd >= end)
- break;
}
}
- text = text.stripWhiteSpace();
text.replace('\\', renderer->backslashAsCurrencySymbol());
if (text.length() > 0) {
- hasNewLine = false;
hasParagraphBreak = false;
NSMutableDictionary *attrs;
@@ -2033,9 +2061,10 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
case ID_H6:
if (!hasNewLine)
text += '\n';
- if (!hasParagraphBreak)
+ if (!hasParagraphBreak) {
text += '\n';
hasParagraphBreak = true;
+ }
hasNewLine = true;
break;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list