[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:20:23 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit e145d1777838c8df65d280aef369ceacb5a936d2
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 22 17:42:56 2003 +0000
Reviewed by John.
- fixed 3467919: REGRESSION (91-92): space missing when copying text with link at start or end of line
* khtml/khtml_part.cpp: (KHTMLPart::text):
* kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::attributedString):
Changed both "turn HTML into text" code paths to generate spaces in a different way.
First, corrected the logic so it notices spaces left out at the end of a RenderText object.
Second, don't emit the space until we are emitting more text, to prevent emitting trailing
spaces. To get this completely right for the attributed string case, I had to add code to
adjust the offset used to mark links.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5844 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index b5c9567..07344fe 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -2,6 +2,20 @@
Reviewed by John.
+ - fixed 3467919: REGRESSION (91-92): space missing when copying text with link at start or end of line
+
+ * khtml/khtml_part.cpp: (KHTMLPart::text):
+ * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::attributedString):
+ Changed both "turn HTML into text" code paths to generate spaces in a different way.
+ First, corrected the logic so it notices spaces left out at the end of a RenderText object.
+ Second, don't emit the space until we are emitting more text, to prevent emitting trailing
+ spaces. To get this completely right for the attributed string case, I had to add code to
+ adjust the offset used to mark links.
+
+2003-12-21 Darin Adler <darin at apple.com>
+
+ Reviewed by John.
+
- fixed 3477453: nowrap in a fixed-width TD is ignored on screen but not when printed (Williams-Sonoma)
* khtml/rendering/render_table.cpp: (RenderTableCell::setStyle):
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 68a74c8..8809d54 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -2274,6 +2274,7 @@ QString KHTMLPart::text(const DOM::Range &r) const
bool hasNewLine = true;
bool addedSpace = true;
+ bool needSpace = false;
QString text;
DOM::Node startNode = r.startContainer();
DOM::Node endNode = r.endContainer();
@@ -2305,43 +2306,41 @@ QString KHTMLPart::text(const DOM::Range &r) const
RenderObject* renderer = n.handle()->renderer();
if (renderer && renderer->isText()) {
if (renderer->style()->whiteSpace() == khtml::PRE) {
+ if (needSpace && !addedSpace)
+ text += ' ';
int runStart = (start == -1) ? 0 : start;
int runEnd = (end == -1) ? str.length() : end;
text += str.mid(runStart, runEnd-runStart);
+ needSpace = false;
addedSpace = str[runEnd-1].direction() == QChar::DirWS;
}
else {
RenderText* textObj = static_cast<RenderText*>(n.handle()->renderer());
InlineTextBoxArray runs = textObj->inlineTextBoxes();
- if (runs.count() == 0 && str.length() > 0 && !addedSpace) {
+ if (runs.count() == 0 && str.length() > 0) {
// 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;
+ needSpace = 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) {
+ if (needSpace && !addedSpace)
+ text += ' ';
QString runText = str.mid(runStart, runEnd - runStart);
runText.replace('\n', ' ');
text += runText;
- start = -1;
- spaceBetweenRuns = i+1 < runs.count() && runs[i+1]->m_start > runEnd;
+ int nextRunStart = (i+1 < runs.count()) ? runs[i+1]->m_start : str.length();
+ needSpace = nextRunStart > runEnd;
addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ start = -1;
}
if (end != -1 && runEnd >= end)
break;
-
- if (spaceBetweenRuns && !addedSpace) {
- text += " ";
- addedSpace = true;
- }
}
}
}
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 3ce1116..a66d899 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -2222,6 +2222,7 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_start, int startOf
bool hasNewLine = true;
bool addedSpace = true;
+ bool needSpace = false;
bool hasParagraphBreak = true;
const ElementImpl *linkStartNode = 0;
unsigned linkStartLocation = 0;
@@ -2257,9 +2258,16 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_start, int startOf
int end = (n == endNode) ? endOffset : -1;
if (renderer->isText()) {
if (renderer->style()->whiteSpace() == PRE) {
+ if (needSpace && !addedSpace) {
+ if (text.isEmpty() && linkStartLocation == [result length]) {
+ ++linkStartLocation;
+ }
+ text += ' ';
+ }
int runStart = (start == -1) ? 0 : start;
int runEnd = (end == -1) ? str.length() : end;
text += str.mid(runStart, runEnd-runStart);
+ needSpace = false;
addedSpace = str[runEnd-1].direction() == QChar::DirWS;
}
else {
@@ -2277,23 +2285,24 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_start, int startOf
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) {
+ if (needSpace && !addedSpace) {
+ if (text.isEmpty() && linkStartLocation == [result length]) {
+ ++linkStartLocation;
+ }
+ text += ' ';
+ }
QString runText = str.mid(runStart, runEnd - runStart);
runText.replace('\n', ' ');
text += runText;
- start = -1;
- spaceBetweenRuns = i+1 < runs.count() && runs[i+1]->m_start > runEnd;
+ int nextRunStart = (i+1 < runs.count()) ? runs[i+1]->m_start : str.length();
+ needSpace = nextRunStart > runEnd;
addedSpace = str[runEnd-1].direction() == QChar::DirWS;
+ start = -1;
}
if (end != -1 && runEnd >= end)
break;
-
- if (spaceBetweenRuns && !addedSpace) {
- text += " ";
- addedSpace = true;
- }
}
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list