Reviewed by mitz.
REGRESSION (r16122): min/max widths incorrectly calculated for contentEditable text
http://bugs.webkit.org/show_bug.cgi?id=11570
* rendering/RenderStyle.h:
(WebCore::RenderStyle::isSpace): Added.
* rendering/RenderText.cpp:
(WebCore::RenderText::calcMinMaxWidth): For the purposes of calculating the line widths,
treat non-breaking spaces the same as normal spaces if -webkit-nbsp-mode is 'space'
LayoutTests:
Reviewed by mitz.
REGRESSION (r16122): min/max widths incorrectly calculated for contentEditable text
http://bugs.webkit.org/show_bug.cgi?id=11570
* fast/text/whitespace/nbsp-mode-and-linewraps-expected.checksum: Added.
* fast/text/whitespace/nbsp-mode-and-linewraps-expected.png: Added.
* fast/text/whitespace/nbsp-mode-and-linewraps-expected.txt: Added.
* fast/text/whitespace/nbsp-mode-and-linewraps.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17724
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-11-11 Graham Dennis <graham.dennis@gmail.com>
+
+ Reviewed by mitz.
+
+ REGRESSION (r16122): min/max widths incorrectly calculated for contentEditable text
+ http://bugs.webkit.org/show_bug.cgi?id=11570
+
+ * fast/text/whitespace/nbsp-mode-and-linewraps-expected.checksum: Added.
+ * fast/text/whitespace/nbsp-mode-and-linewraps-expected.png: Added.
+ * fast/text/whitespace/nbsp-mode-and-linewraps-expected.txt: Added.
+ * fast/text/whitespace/nbsp-mode-and-linewraps.html: Added.
+
2006-11-10 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
--- /dev/null
+ab6fa35f9017684e764e580c22a79f4b
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+layer at (100,8) size 700x196
+ RenderBlock (positioned) {DIV} at (100,8) size 700x196 [border: (2px solid #FF0000)]
+ RenderText {#text} at (14,14) size 666x168
+ text run at (14,14) width 666: "This div is absolutely positioned to the left. All the spaces in this div"
+ text run at (14,42) width 643: "are replaced with non-breaking spaces, and the nbsp-mode for this"
+ text run at (14,70) width 615: "div is 'space', so when calculating line breaks, the non-breaking"
+ text run at (14,98) width 657: "spaces should be treated as normal spaces. If this isn't the case, then"
+ text run at (14,126) width 629: "all the text for this paragraph will be rendered in two lines, and a"
+ text run at (14,154) width 488: "horizontal scroll bar will appear along the bottom."
--- /dev/null
+<html>
+<head>
+
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 12px;
+ font-size: 24px;
+}
+</style>
+
+<title>-webkit-nbsp-mode and linewraps</title>
+</head>
+<body id="root">
+<div class="editing" style="position:absolute; left: 100px; -webkit-nbsp-mode: space;">
+This div is absolutely positioned to the left. All the spaces in this div are replaced with non-breaking spaces, and the nbsp-mode for this div is 'space', so when calculating line breaks, the non-breaking spaces should be treated as normal spaces. If this isn't the case, then all the text for this paragraph will be rendered in two lines, and a horizontal scroll bar will appear along the bottom.
+</div>
+
+</body>
+</html>
+2006-11-11 Graham Dennis <graham.dennis@gmail.com>
+
+ Reviewed by mitz.
+
+ REGRESSION (r16122): min/max widths incorrectly calculated for contentEditable text
+ http://bugs.webkit.org/show_bug.cgi?id=11570
+
+ * rendering/RenderStyle.h:
+ (WebCore::RenderStyle::isSpace): Added.
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::calcMinMaxWidth): For the purposes of calculating the line widths,
+ treat non-breaking spaces the same as normal spaces if -webkit-nbsp-mode is 'space'
+
2006-11-10 Zalan Bujtas <zalan.bujtas@nokia.com>
Reviewed by Maciej.
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
}
return false;
}
+ bool isSpace(UChar c) const { return c == ' ' || (c == 0xa0 && nbspMode() == SPACE); }
bool breakOnlyAfterWhiteSpace() const {
return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE;
}
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
* Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
bool firstWord = true;
bool firstLine = true;
int nextBreakable = -1;
+ bool breakNBSP = style()->autoWrap() && style()->nbspMode() == SPACE;
+
for (int i = 0; i < len; i++) {
UChar c = txt[i];
continue;
}
- bool hasBreak = isBreakable(txt, i, len, nextBreakable);
+ bool hasBreak = isBreakable(txt, i, len, nextBreakable, breakNBSP);
int j = i;
- while (c != '\n' && c != ' ' && c != '\t' && c != SOFT_HYPHEN) {
+ while (c != '\n' && !style()->isSpace(c) && c != '\t' && c != SOFT_HYPHEN) {
j++;
if (j == len)
break;
c = txt[j];
- if (isBreakable(txt, j, len, nextBreakable))
+ if (isBreakable(txt, j, len, nextBreakable, breakNBSP))
break;
}
currMinWidth += w;
currMaxWidth += w;
- bool isSpace = (j < len) && c == ' ';
+ bool isSpace = (j < len) && style()->isSpace(c);
bool isCollapsibleWhiteSpace = (j < len) && style()->isCollapsibleWhiteSpace(c);
if (j < len && style()->autoWrap())
m_hasBreakableChar = true;