[webkit-changes] cvs commit: WebCore/kwq KWQKHTMLPart.mm
David
hyatt at opensource.apple.com
Wed Nov 2 00:52:53 PST 2005
hyatt 05/11/02 00:52:52
Modified: . ChangeLog
khtml/css css_computedstyle.cpp cssparser.cpp
cssstyleselector.cpp cssvalues.in html4.css
khtml/ecma kjs_html.cpp kjs_html.h
khtml/editing visible_text.cpp visible_units.cpp
khtml/html html_blockimpl.cpp html_blockimpl.h
khtml/rendering bidi.cpp render_block.cpp render_block.h
render_layer.h render_line.cpp render_object.cpp
render_style.h render_table.cpp render_text.cpp
khtml/xml dom_elementimpl.h dom_textimpl.cpp
kwq KWQKHTMLPart.mm
Log:
Fix for 5587, implement pre-wrap and pre-line white-space values.
Reviewed by mjs
Tests Added in fast/text/whitespace
* khtml/css/css_computedstyle.cpp:
(DOM::CSSComputedStyleDeclarationImpl::getPropertyCSSValue):
* khtml/css/cssparser.cpp:
(CSSParser::parseValue):
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::applyProperty):
* khtml/css/cssvalues.in:
* khtml/css/html4.css:
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLElement::preGetter):
(KJS::HTMLElement::preSetter):
* khtml/ecma/kjs_html.h:
(KJS::HTMLElement::):
* khtml/editing/visible_text.cpp:
(khtml::TextIterator::handleTextNode):
* khtml/editing/visible_units.cpp:
(khtml::startOfParagraph):
(khtml::endOfParagraph):
* khtml/html/html_blockimpl.cpp:
(HTMLPreElementImpl::mapToEntry):
(HTMLPreElementImpl::parseMappedAttribute):
(HTMLPreElementImpl::wrap):
(HTMLPreElementImpl::setWrap):
* khtml/html/html_blockimpl.h:
* khtml/rendering/bidi.cpp:
(khtml::checkMidpoints):
(khtml::RenderBlock::computeHorizontalPositionsForLine):
(khtml::RenderBlock::layoutInlineChildren):
(khtml::RenderBlock::skipNonBreakingSpace):
(khtml::RenderBlock::skipWhitespace):
(khtml::RenderBlock::findNextLineBreak):
* khtml/rendering/render_block.cpp:
(khtml:::RenderFlow):
(khtml::RenderBlock::setStyle):
(khtml::RenderBlock::calcMinMaxWidth):
(khtml::stripTrailingSpace):
(khtml::RenderBlock::calcInlineMinMaxWidth):
(khtml::RenderBlock::dump):
* khtml/rendering/render_block.h:
* khtml/rendering/render_layer.h:
(khtml::):
* khtml/rendering/render_line.cpp:
(khtml::shouldDrawDecoration):
* khtml/rendering/render_object.cpp:
(RenderObject::tabWidth):
* khtml/rendering/render_style.h:
(khtml::):
(khtml::RenderStyle::autoWrap):
(khtml::RenderStyle::preserveNewline):
(khtml::RenderStyle::collapseWhiteSpace):
(khtml::RenderStyle::isCollapsibleWhiteSpace):
(khtml::RenderStyle::breakOnlyAfterWhiteSpace):
* khtml/rendering/render_table.cpp:
(RenderTableCell::calcMinMaxWidth):
* khtml/rendering/render_text.cpp:
(RenderText::caretRect):
(RenderText::trimmedMinMaxWidth):
(RenderText::calcMinMaxWidth):
(RenderText::width):
* khtml/xml/dom_elementimpl.h:
(DOM::):
* khtml/xml/dom_textimpl.cpp:
(TextImpl::rendererIsNeeded):
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::attributedString):
Revision Changes Path
1.327 +74 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.326
retrieving revision 1.327
diff -u -r1.326 -r1.327
--- ChangeLog 2 Nov 2005 00:49:15 -0000 1.326
+++ ChangeLog 2 Nov 2005 08:52:35 -0000 1.327
@@ -1,3 +1,77 @@
+2005-11-02 David Hyatt <hyatt at apple.com>
+
+ Fix for 5587, implement pre-wrap and pre-line white-space values.
+
+ Reviewed by mjs
+
+ Tests Added in fast/text/whitespace
+
+ * khtml/css/css_computedstyle.cpp:
+ (DOM::CSSComputedStyleDeclarationImpl::getPropertyCSSValue):
+ * khtml/css/cssparser.cpp:
+ (CSSParser::parseValue):
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::applyProperty):
+ * khtml/css/cssvalues.in:
+ * khtml/css/html4.css:
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLElement::preGetter):
+ (KJS::HTMLElement::preSetter):
+ * khtml/ecma/kjs_html.h:
+ (KJS::HTMLElement::):
+ * khtml/editing/visible_text.cpp:
+ (khtml::TextIterator::handleTextNode):
+ * khtml/editing/visible_units.cpp:
+ (khtml::startOfParagraph):
+ (khtml::endOfParagraph):
+ * khtml/html/html_blockimpl.cpp:
+ (HTMLPreElementImpl::mapToEntry):
+ (HTMLPreElementImpl::parseMappedAttribute):
+ (HTMLPreElementImpl::wrap):
+ (HTMLPreElementImpl::setWrap):
+ * khtml/html/html_blockimpl.h:
+ * khtml/rendering/bidi.cpp:
+ (khtml::checkMidpoints):
+ (khtml::RenderBlock::computeHorizontalPositionsForLine):
+ (khtml::RenderBlock::layoutInlineChildren):
+ (khtml::RenderBlock::skipNonBreakingSpace):
+ (khtml::RenderBlock::skipWhitespace):
+ (khtml::RenderBlock::findNextLineBreak):
+ * khtml/rendering/render_block.cpp:
+ (khtml:::RenderFlow):
+ (khtml::RenderBlock::setStyle):
+ (khtml::RenderBlock::calcMinMaxWidth):
+ (khtml::stripTrailingSpace):
+ (khtml::RenderBlock::calcInlineMinMaxWidth):
+ (khtml::RenderBlock::dump):
+ * khtml/rendering/render_block.h:
+ * khtml/rendering/render_layer.h:
+ (khtml::):
+ * khtml/rendering/render_line.cpp:
+ (khtml::shouldDrawDecoration):
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::tabWidth):
+ * khtml/rendering/render_style.h:
+ (khtml::):
+ (khtml::RenderStyle::autoWrap):
+ (khtml::RenderStyle::preserveNewline):
+ (khtml::RenderStyle::collapseWhiteSpace):
+ (khtml::RenderStyle::isCollapsibleWhiteSpace):
+ (khtml::RenderStyle::breakOnlyAfterWhiteSpace):
+ * khtml/rendering/render_table.cpp:
+ (RenderTableCell::calcMinMaxWidth):
+ * khtml/rendering/render_text.cpp:
+ (RenderText::caretRect):
+ (RenderText::trimmedMinMaxWidth):
+ (RenderText::calcMinMaxWidth):
+ (RenderText::width):
+ * khtml/xml/dom_elementimpl.h:
+ (DOM::):
+ * khtml/xml/dom_textimpl.cpp:
+ (TextImpl::rendererIsNeeded):
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::attributedString):
+
2005-11-01 David Hyatt <hyatt at apple.com>
Fix for bug 5580, slashdot regression with percentage height
1.39 +4 -0 WebCore/khtml/css/css_computedstyle.cpp
Index: css_computedstyle.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_computedstyle.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- css_computedstyle.cpp 3 Oct 2005 21:12:06 -0000 1.38
+++ css_computedstyle.cpp 2 Nov 2005 08:52:39 -0000 1.39
@@ -1090,6 +1090,10 @@
return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
case khtml::PRE:
return new CSSPrimitiveValueImpl(CSS_VAL_PRE);
+ case khtml::PRE_WRAP:
+ return new CSSPrimitiveValueImpl(CSS_VAL_PRE_WRAP);
+ case khtml::PRE_LINE:
+ return new CSSPrimitiveValueImpl(CSS_VAL_PRE_LINE);
case khtml::NOWRAP:
return new CSSPrimitiveValueImpl(CSS_VAL_NOWRAP);
case khtml::KHTML_NOWRAP:
1.109 +5 -3 WebCore/khtml/css/cssparser.cpp
Index: cssparser.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssparser.cpp,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- cssparser.cpp 3 Oct 2005 21:12:07 -0000 1.108
+++ cssparser.cpp 2 Nov 2005 08:52:39 -0000 1.109
@@ -499,9 +499,11 @@
break;
case CSS_PROP_WHITE_SPACE: // normal | pre | nowrap | inherit
- if ( id == CSS_VAL_NORMAL ||
- id == CSS_VAL_PRE ||
- id == CSS_VAL_NOWRAP )
+ if (id == CSS_VAL_NORMAL ||
+ id == CSS_VAL_PRE ||
+ id == CSS_VAL_PRE_WRAP ||
+ id == CSS_VAL_PRE_LINE ||
+ id == CSS_VAL_NOWRAP)
valid_primitive = true;
break;
1.220 +6 -0 WebCore/khtml/css/cssstyleselector.cpp
Index: cssstyleselector.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -r1.219 -r1.220
--- cssstyleselector.cpp 30 Oct 2005 05:26:25 -0000 1.219
+++ cssstyleselector.cpp 2 Nov 2005 08:52:40 -0000 1.220
@@ -2395,6 +2395,12 @@
case CSS_VAL_PRE:
s = PRE;
break;
+ case CSS_VAL_PRE_WRAP:
+ s = PRE_WRAP;
+ break;
+ case CSS_VAL_PRE_LINE:
+ s = PRE_LINE;
+ break;
case CSS_VAL_NORMAL:
default:
s = NORMAL;
1.35 +2 -0 WebCore/khtml/css/cssvalues.in
Index: cssvalues.in
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/cssvalues.in,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- cssvalues.in 21 Oct 2005 21:27:44 -0000 1.34
+++ cssvalues.in 2 Nov 2005 08:52:40 -0000 1.35
@@ -308,6 +308,8 @@
overline
portrait
pre
+pre-line
+pre-wrap
relative
scroll
separate
1.82 +1 -1 WebCore/khtml/css/html4.css
Index: html4.css
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/html4.css,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- html4.css 28 Oct 2005 07:03:25 -0000 1.81
+++ html4.css 2 Nov 2005 08:52:40 -0000 1.82
@@ -374,7 +374,7 @@
white-space: pre;
margin: 1__qem 0
}
-
+
big {
font-size: larger;
}
1.144 +4 -1 WebCore/khtml/ecma/kjs_html.cpp
Index: kjs_html.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -r1.143 -r1.144
--- kjs_html.cpp 27 Oct 2005 23:14:59 -0000 1.143
+++ kjs_html.cpp 2 Nov 2005 08:52:42 -0000 1.144
@@ -1840,6 +1840,8 @@
HTMLPreElementImpl& pre = *static_cast<HTMLPreElementImpl*>(impl());
if (token == PreWidth)
return Number(pre.width());
+ if (token == PreWrap)
+ return Boolean(pre.wrap());
return Undefined();
}
@@ -2902,10 +2904,11 @@
void HTMLElement::preSetter(ExecState *exec, int token, ValueImp *value, const DOM::DOMString& str)
{
- // FIXME: Add support for 'wrap' when white-space: pre-wrap is implemented.
HTMLPreElementImpl& pre = *static_cast<HTMLPreElementImpl*>(impl());
if (token == PreWidth)
pre.setWidth(value->toInt32(exec));
+ else if (token == PreWrap)
+ pre.setWrap(value->toBoolean(exec));
}
void HTMLElement::brSetter(ExecState *exec, int token, ValueImp *value, const DOM::DOMString& str)
1.58 +1 -1 WebCore/khtml/ecma/kjs_html.h
Index: kjs_html.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- kjs_html.h 26 Oct 2005 19:44:05 -0000 1.57
+++ kjs_html.h 2 Nov 2005 08:52:42 -0000 1.58
@@ -240,7 +240,7 @@
LegendAlign, LegendFocus, UListType, UListCompact, OListStart, OListCompact,
OListType, DListCompact, DirectoryCompact, MenuCompact, LIType,
LIValue, DivAlign, ParagraphAlign, HeadingAlign, BlockQuoteCite,
- QuoteCite, PreWidth, BRClear, BaseFontColor, BaseFontSize,
+ QuoteCite, PreWidth, PreWrap, BRClear, BaseFontColor, BaseFontSize,
BaseFontFace, FontColor, FontSize, FontFace, HRWidth, HRNoShade,
HRAlign, HRSize, ModCite, ModDateTime, AnchorShape, AnchorRel,
AnchorAccessKey, AnchorCoords, AnchorHref, AnchorProtocol, AnchorHost,
1.39 +1 -1 WebCore/khtml/editing/visible_text.cpp
Index: visible_text.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_text.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- visible_text.cpp 3 Oct 2005 21:12:21 -0000 1.38
+++ visible_text.cpp 2 Nov 2005 08:52:43 -0000 1.39
@@ -221,7 +221,7 @@
DOMString str = renderer->string();
// handle pre-formatted text
- if (renderer->style()->whiteSpace() == khtml::PRE) {
+ if (!renderer->style()->collapseWhiteSpace()) {
int runStart = m_offset;
if (m_lastTextNodeEndedWithCollapsedSpace) {
emitCharacter(' ', m_node, 0, runStart, runStart);
1.42 +2 -0 WebCore/khtml/editing/visible_units.cpp
Index: visible_units.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_units.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- visible_units.cpp 3 Oct 2005 21:12:21 -0000 1.41
+++ visible_units.cpp 2 Nov 2005 08:52:43 -0000 1.42
@@ -565,6 +565,7 @@
if (r->isBR() || r->isBlockFlow())
break;
if (r->isText()) {
+ // FIXME: Not clear what to do with pre-wrap or pre-line here.
if (style->whiteSpace() == PRE) {
QChar *text = static_cast<RenderText *>(r)->text();
int i = static_cast<RenderText *>(r)->length();
@@ -625,6 +626,7 @@
if (includeLineBreak && !n->isAncestor(startBlock))
return VisiblePosition(n, 0, DOWNSTREAM);
int length = static_cast<RenderText *>(r)->length();
+ // FIXME: Not clear what to do with pre-wrap or pre-line here.
if (style->whiteSpace() == PRE) {
QChar *text = static_cast<RenderText *>(r)->text();
int o = 0;
1.27 +33 -0 WebCore/khtml/html/html_blockimpl.cpp
Index: html_blockimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_blockimpl.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- html_blockimpl.cpp 3 Oct 2005 21:12:27 -0000 1.26
+++ html_blockimpl.cpp 2 Nov 2005 08:52:44 -0000 1.27
@@ -294,6 +294,29 @@
{
}
+bool HTMLPreElementImpl::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
+{
+ if (attrName == widthAttr || attrName == wrapAttr) {
+ result = ePre;
+ return false;
+ }
+ return HTMLElementImpl::mapToEntry(attrName, result);
+}
+
+void HTMLPreElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
+{
+ if (attr->name() == widthAttr) {
+ // FIXME: Implement this some day. Width on a <pre> is the # of characters that
+ // we should size the pre to. We basically need to take the width of a space,
+ // multiply by the value of the attribute and then set that as the width CSS
+ // property.
+ } else if (attr->name() == wrapAttr) {
+ if (!attr->value().isNull())
+ addCSSProperty(attr, CSS_PROP_WHITE_SPACE, CSS_VAL_PRE_WRAP);
+ } else
+ return HTMLElementImpl::parseMappedAttribute(attr);
+}
+
int HTMLPreElementImpl::width() const
{
return getAttribute(widthAttr).toInt();
@@ -304,6 +327,16 @@
setAttribute(widthAttr, QString::number(width));
}
+bool HTMLPreElementImpl::wrap() const
+{
+ return !getAttribute(wrapAttr).isNull();
+}
+
+void HTMLPreElementImpl::setWrap(bool wrap)
+{
+ setAttribute(wrapAttr, wrap ? "" : 0);
+}
+
// -------------------------------------------------------------------------
// WinIE uses 60ms as the minimum delay by default.
1.13 +6 -0 WebCore/khtml/html/html_blockimpl.h
Index: html_blockimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_blockimpl.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- html_blockimpl.h 16 Sep 2005 22:42:11 -0000 1.12
+++ html_blockimpl.h 2 Nov 2005 08:52:44 -0000 1.13
@@ -136,8 +136,14 @@
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 5; }
+ bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
+ void parseMappedAttribute(MappedAttributeImpl *attr);
+
int width() const;
void setWidth(int w);
+
+ bool wrap() const;
+ void setWrap(bool b);
};
// -------------------------------------------------------------------------
1.154 +49 -51 WebCore/khtml/rendering/bidi.cpp
Index: bidi.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/bidi.cpp,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -r1.153 -r1.154
--- bidi.cpp 24 Oct 2005 22:51:06 -0000 1.153
+++ bidi.cpp 2 Nov 2005 08:52:44 -0000 1.154
@@ -459,8 +459,8 @@
static void checkMidpoints(BidiIterator& lBreak, BidiState &bidi)
{
// Check to see if our last midpoint is a start point beyond the line break. If so,
- // shave it off the list, and shave off a trailing space if the previous end point isn't
- // white-space: pre.
+ // shave it off the list, and shave off a trailing space if the previous end point doesn't
+ // preserve whitespace.
if (lBreak.obj && sNumMidpoints && sNumMidpoints%2 == 0) {
BidiIterator* midpoints = smidpoints->data();
BidiIterator& endpoint = midpoints[sNumMidpoints-2];
@@ -471,7 +471,7 @@
if (currpoint == lBreak) {
// We hit the line break before the start point. Shave off the start point.
sNumMidpoints--;
- if (endpoint.obj->style()->whiteSpace() != PRE) {
+ if (endpoint.obj->style()->collapseWhiteSpace()) {
if (endpoint.obj->isText()) {
// Don't shave a character off the endpoint if it was from a soft hyphen.
RenderText* textObj = static_cast<RenderText*>(endpoint.obj);
@@ -818,7 +818,7 @@
}
if (!r->compact) {
RenderStyle *style = r->obj->style();
- if (style->whiteSpace() == NORMAL && style->khtmlLineBreak() == AFTER_WHITE_SPACE) {
+ if (style->autoWrap() && style->breakOnlyAfterWhiteSpace()) {
// shrink the box as needed to keep the line from overflowing the available width
textWidth = kMin(effectiveWidth, availableWidth - totWidth + style->borderLeftWidth());
}
@@ -892,8 +892,8 @@
KHTMLAssert(spaces <= numSpaces);
- // Only justify text with white-space: normal.
- if (r->obj->style()->whiteSpace() != PRE) {
+ // Only justify text if whitespace is collapsed.
+ if (r->obj->style()->collapseWhiteSpace()) {
spaceAdd = (availableWidth - totWidth)*spaces/numSpaces;
static_cast<InlineTextBox*>(r->box)->setSpaceAdd(spaceAdd);
totWidth += spaceAdd;
@@ -1639,7 +1639,7 @@
}
}
- if (end == start || (!previousLineBrokeCleanly && end.obj && end.obj->style()->whiteSpace() == PRE && end.current() == QChar('\n'))) {
+ if (end == start || (!previousLineBrokeCleanly && end.obj && end.obj->style()->preserveNewline() && end.current() == '\n')) {
adjustEmbedding = true;
end.increment(bidi);
adjustEmbedding = false;
@@ -1877,14 +1877,12 @@
if (it.obj->style()->nbspMode() != SPACE || it.current().unicode() != nonBreakingSpace)
return false;
+ // FIXME: This is bad. It makes nbsp inconsistent with space and won't work correctly
+ // with m_minWidth/m_maxWidth.
// Do not skip a non-breaking space if it is the first character
- // on the first line of a block.
- if (m_firstLine && isLineEmpty)
- return false;
-
- // Do not skip a non-breaking space if it is the first character
- // on a line after a clean line break.
- if (!m_firstLine && isLineEmpty && previousLineBrokeCleanly)
+ // on a line after a clean line break (or on the first line, since previousLineBrokeCleanly starts off
+ // |true|).
+ if (isLineEmpty && previousLineBrokeCleanly)
return false;
return true;
@@ -1897,9 +1895,9 @@
// elements quite right. In other words, we need to build this function's work into the normal line
// object iteration process.
int w = lineWidth(m_height);
- while (!it.atEnd() && (it.obj->isInlineFlow() || (it.obj->style()->whiteSpace() != PRE && !it.obj->isBR() &&
- (it.current() == ' ' || it.current() == '\t' || it.current() == '\n' || it.current().unicode() == SOFT_HYPHEN ||
- skipNonBreakingSpace(it) || it.obj->isFloatingOrPositioned())))) {
+ while (!it.atEnd() && (it.obj->isInlineFlow() || (it.obj->style()->collapseWhiteSpace() && !it.obj->isBR() &&
+ (it.current() == ' ' || it.current() == '\t' || (!it.obj->style()->preserveNewline() && it.current() == '\n') ||
+ it.current().unicode() == SOFT_HYPHEN || skipNonBreakingSpace(it) || it.obj->isFloatingOrPositioned())))) {
if (it.obj->isFloatingOrPositioned()) {
RenderObject *o = it.obj;
// add to special objects...
@@ -2081,7 +2079,7 @@
// FIXME: This does not match WinIE, Opera, and Mozilla. They treat replaced elements
// like characters in a word, and require spaces between the replaced elements in order
// to break.
- if (currWS == NORMAL || lastWS == NORMAL) {
+ if (RenderStyle::autoWrap(currWS) || RenderStyle::autoWrap(lastWS)) {
w += tmpW;
tmpW = 0;
lBreak.obj = o;
@@ -2107,13 +2105,11 @@
// Optimize for a common case. If we can't find whitespace after the list
// item, then this is all moot. -dwh
RenderObject* next = Bidinext( start.par, o, bidi );
- if (!m_pre && next && next->isText() && static_cast<RenderText*>(next)->stringLength() > 0) {
+ if (style()->collapseWhiteSpace() && next && next->isText() && static_cast<RenderText*>(next)->stringLength() > 0) {
RenderText *nextText = static_cast<RenderText*>(next);
QChar nextChar = nextText->text()[0];
- if (nextText->style()->whiteSpace() != PRE &&
- (nextChar == ' ' || nextChar == '\n' || nextChar == '\t' ||
- nextChar.unicode() == nonBreakingSpace && next->style()->nbspMode() == SPACE)) {
+ if (nextText->style()->isCollapsibleWhiteSpace(nextChar)) {
currentCharacterIsSpace = true;
currentCharacterIsWS = true;
ignoringSpaces = true;
@@ -2131,7 +2127,6 @@
const Font *f = t->htmlFont( m_firstLine );
// proportional font, needs a bit more work.
int lastSpace = pos;
- bool isPre = o->style()->whiteSpace() == PRE;
int wordSpacing = o->style()->wordSpacing();
bool appliedStartWidth = pos > 0; // If the span originated on a previous line,
@@ -2145,9 +2140,9 @@
bool previousCharacterIsSpace = currentCharacterIsSpace;
bool previousCharacterIsWS = currentCharacterIsWS;
const QChar c = str[pos];
- currentCharacterIsSpace = c == ' ' || c == '\t' || (!isPre && (c == '\n'));
+ currentCharacterIsSpace = c == ' ' || c == '\t' || (!o->style()->preserveNewline() && (c == '\n'));
- if (isPre || !currentCharacterIsSpace)
+ if (!style()->collapseWhiteSpace() || !currentCharacterIsSpace)
isLineEmpty = false;
// Check for soft hyphens. Go ahead and ignore them.
@@ -2168,9 +2163,9 @@
// Add the width up to but not including the hyphen.
tmpW += t->width(lastSpace, pos - lastSpace, f, w+tmpW);
- // For whitespace normal only, include the hyphen. We need to ensure it will fit
+ // For wrapping text only, include the hyphen. We need to ensure it will fit
// on the line if it shows when we break.
- if (o->style()->whiteSpace() == NORMAL)
+ if (o->style()->autoWrap())
tmpW += t->width(pos, 1, f, w+tmpW);
BidiIterator startMid(0, o, pos+1);
@@ -2184,16 +2179,18 @@
}
bool applyWordSpacing = false;
- bool isNormal = o->style()->whiteSpace() == NORMAL;
- bool breakNBSP = isNormal && o->style()->nbspMode() == SPACE;
- bool breakWords = o->style()->wordWrap() == BREAK_WORD && ((isNormal && w == 0) || o->style()->whiteSpace() == PRE);
+ bool allowBreak = o->style()->autoWrap();
+ bool breakNBSP = allowBreak && o->style()->nbspMode() == SPACE;
+
+ // FIXME: This check looks suspicious. Why does w have to be 0?
+ bool breakWords = o->style()->wordWrap() == BREAK_WORD && ((allowBreak && w == 0) || o->style()->whiteSpace() == PRE);
currentCharacterIsWS = currentCharacterIsSpace || (breakNBSP && c.unicode() == nonBreakingSpace);
if (breakWords)
wrapW += t->width(pos, 1, f, w+wrapW);
- if (c == '\n' || (!isPre && isBreakable(str, pos, strlen, nextBreakable, breakNBSP)) || (breakWords && (w + wrapW > width))) {
+ if (c == '\n' || (o->style()->whiteSpace() != PRE && isBreakable(str, pos, strlen, nextBreakable, breakNBSP)) || (breakWords && (w + wrapW > width))) {
if (ignoringSpaces) {
if (!currentCharacterIsSpace) {
// Stop ignoring spaces and begin at this
@@ -2222,7 +2219,7 @@
#ifdef DEBUG_LINEBREAKS
kdDebug(6041) << "found space at " << pos << " in string '" << QString( str, strlen ).latin1() << "' adding " << tmpW << " new width = " << w << endl;
#endif
- if (isNormal && w + tmpW > width && w == 0) {
+ if (o->style()->autoWrap() && w + tmpW > width && w == 0) {
int fb = nearestFloatBottom(m_height);
int newLineWidth = lineWidth(fb);
// See if |tmpW| will fit on the new line. As long as it does not,
@@ -2243,12 +2240,12 @@
}
}
- if (o->style()->whiteSpace() == NORMAL || breakWords) {
- // In AFTER_WHITE_SPACE mode, consider the current character
+ if (o->style()->autoWrap() || breakWords) {
+ // If we break only after white-space, consider the current character
// as candidate width for this line.
- int charWidth = o->style()->khtmlLineBreak() == AFTER_WHITE_SPACE ? t->width(pos, 1, f, w + tmpW) : 0;
+ int charWidth = o->style()->breakOnlyAfterWhiteSpace() ? t->width(pos, 1, f, w + tmpW) : 0;
if (w + tmpW + charWidth > width) {
- if (o->style()->khtmlLineBreak() == AFTER_WHITE_SPACE) {
+ if (o->style()->breakOnlyAfterWhiteSpace()) {
// Check if line is too big even without the extra space
// at the end of the line. If it is not, do nothing.
// If the line needs the extra whitespace to be too long,
@@ -2267,7 +2264,7 @@
tmpW -= t->width(pos-1, 1, f, w+tmpW);
}
- if( *(str+pos) == '\n' && isPre) {
+ if( *(str+pos) == '\n' && o->style()->preserveNewline()) {
lBreak.obj = o;
lBreak.pos = pos;
@@ -2277,7 +2274,7 @@
return lBreak;
}
- if (o->style()->whiteSpace() == NORMAL) {
+ if (o->style()->autoWrap()) {
w += tmpW;
tmpW = 0;
lBreak.obj = o;
@@ -2289,7 +2286,7 @@
if (applyWordSpacing)
w += wordSpacing;
- if (!ignoringSpaces && !isPre) {
+ if (!ignoringSpaces && o->style()->collapseWhiteSpace()) {
// If we encounter a newline, or if we encounter a
// second space, we need to go ahead and break up this
// run and enter a mode where we start collapsing spaces.
@@ -2319,15 +2316,15 @@
}
if (!currentCharacterIsWS && previousCharacterIsWS) {
- if (o->style()->khtmlLineBreak() == AFTER_WHITE_SPACE && o->style()->whiteSpace() == NORMAL) {
+ if (o->style()->autoWrap() && o->style()->breakOnlyAfterWhiteSpace()) {
lBreak.obj = o;
lBreak.pos = pos;
}
}
- if (!isPre && currentCharacterIsSpace && !ignoringSpaces)
+ if (o->style()->collapseWhiteSpace() && currentCharacterIsSpace && !ignoringSpaces)
trailingSpaceObject = o;
- else if (isPre || !currentCharacterIsSpace)
+ else if (!o->style()->collapseWhiteSpace() || !currentCharacterIsSpace)
trailingSpaceObject = 0;
pos++;
@@ -2345,12 +2342,12 @@
KHTMLAssert( false );
RenderObject* next = Bidinext(start.par, o, bidi);
- bool isNormal = o->style()->whiteSpace() == NORMAL;
- bool checkForBreak = isNormal;
+ bool autoWrap = o->style()->autoWrap();
+ bool checkForBreak = autoWrap;
if (w && w + tmpW > width+1 && lBreak.obj && o->style()->whiteSpace() == NOWRAP)
checkForBreak = true;
else if (next && o->isText() && next->isText() && !next->isBR()) {
- if (isNormal || (next->style()->whiteSpace() == NORMAL)) {
+ if (autoWrap || (next->style()->autoWrap())) {
if (currentCharacterIsSpace)
checkForBreak = true;
else {
@@ -2358,7 +2355,7 @@
RenderText* nextText = static_cast<RenderText*>(next);
if (nextText->stringLength() != 0) {
QChar c = nextText->text()[0];
- if (c == ' ' || c == '\t' || (c == '\n' && next->style()->whiteSpace() != PRE)) {
+ if (c == ' ' || c == '\t' || (c == '\n' && !next->style()->preserveNewline())) {
// If the next item on the line is text, and if we did not end with
// a space, then the next text run continues our word (and so it needs to
// keep adding to |tmpW|. Just update and continue.
@@ -2366,7 +2363,7 @@
tmpW += nextText->htmlFont(m_firstLine)->getWordSpacing();
}
}
- bool canPlaceOnLine = (w + tmpW <= width+1) || !isNormal;
+ bool canPlaceOnLine = (w + tmpW <= width+1) || !autoWrap;
if (canPlaceOnLine && checkForBreak) {
w += tmpW;
tmpW = 0;
@@ -2381,7 +2378,7 @@
//kdDebug() << " too wide w=" << w << " tmpW = " << tmpW << " width = " << width << endl;
//kdDebug() << "start=" << start.obj << " current=" << o << endl;
// if we have floats, try to get below them.
- if (currentCharacterIsSpace && !ignoringSpaces && o->style()->whiteSpace() != PRE)
+ if (currentCharacterIsSpace && !ignoringSpaces && o->style()->collapseWhiteSpace())
trailingSpaceObject = 0;
int fb = nearestFloatBottom(m_height);
@@ -2414,7 +2411,7 @@
previous = o;
o = next;
- if (!last->isFloatingOrPositioned() && last->isReplaced() && last->style()->whiteSpace() == NORMAL &&
+ if (!last->isFloatingOrPositioned() && last->isReplaced() && last->style()->autoWrap() &&
(!last->isListMarker() || last->style()->listStylePosition()==INSIDE)) {
// Go ahead and add in tmpW.
w += tmpW;
@@ -2425,7 +2422,7 @@
// Clear out our character space bool, since inline <pre>s don't collapse whitespace
// with adjacent inline normal/nowrap spans.
- if (last->style()->whiteSpace() == PRE)
+ if (!last->style()->collapseWhiteSpace())
currentCharacterIsSpace = false;
pos = 0;
@@ -2443,7 +2440,8 @@
if( lBreak == start && !lBreak.obj->isBR() ) {
// we just add as much as possible
- if ( m_pre ) {
+ if (style()->whiteSpace() == PRE) {
+ // FIXME: Don't really understand this case.
if(pos != 0) {
lBreak.obj = o;
lBreak.pos = pos - 1;
1.213 +16 -21 WebCore/khtml/rendering/render_block.cpp
Index: render_block.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_block.cpp,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -r1.212 -r1.213
--- render_block.cpp 25 Oct 2005 20:54:27 -0000 1.212
+++ render_block.cpp 2 Nov 2005 08:52:45 -0000 1.213
@@ -90,7 +90,6 @@
m_childrenInline = true;
m_floatingObjects = 0;
m_positionedObjects = 0;
- m_pre = false;
m_firstLine = false;
m_hasMarkupTruncation = false;
m_selectionState = SelectionNone;
@@ -114,10 +113,6 @@
RenderFlow::setStyle(_style);
- m_pre = false;
- if (_style->whiteSpace() == PRE)
- m_pre = true;
-
// ### we could save this call when the change only affected
// non inherited properties
RenderObject *child = firstChild();
@@ -2659,7 +2654,6 @@
m_minWidth = 0;
m_maxWidth = 0;
- bool preOrNowrap = style()->whiteSpace() != NORMAL;
if (childrenInline())
calcInlineMinMaxWidth();
else
@@ -2667,7 +2661,7 @@
if(m_maxWidth < m_minWidth) m_maxWidth = m_minWidth;
- if (preOrNowrap && childrenInline()) {
+ if (!style()->autoWrap() && childrenInline()) {
m_minWidth = m_maxWidth;
// A horizontal marquee with inline children has no minimum width.
@@ -2794,11 +2788,10 @@
return result;
}
-static void stripTrailingSpace(bool pre,
- int& inlineMax, int& inlineMin,
- RenderObject* trailingSpaceChild)
+static inline void stripTrailingSpace(int& inlineMax, int& inlineMin,
+ RenderObject* trailingSpaceChild)
{
- if (!pre && trailingSpaceChild && trailingSpaceChild->isText()) {
+ if (trailingSpaceChild && trailingSpaceChild->isText()) {
// Collapse away the trailing space at the end of a block.
RenderText* t = static_cast<RenderText *>(trailingSpaceChild);
const Font *f = t->htmlFont( false );
@@ -2822,15 +2815,15 @@
bool stripFrontSpaces = true;
RenderObject* trailingSpaceChild = 0;
- bool normal, oldnormal;
- normal = oldnormal = style()->whiteSpace() == NORMAL;
+ bool autoWrap, oldAutoWrap;
+ autoWrap = oldAutoWrap = style()->autoWrap();
InlineMinMaxIterator childIterator(this, this);
bool addedTextIndent = false; // Only gets added in once.
RenderObject* prevFloat = 0;
while (RenderObject* child = childIterator.next())
{
- normal = child->style()->whiteSpace() == NORMAL;
+ autoWrap = child->style()->autoWrap();
if (!child->isBR()) {
// Step One: determine whether or not we need to go ahead and
@@ -2905,7 +2898,9 @@
childMin += child->minWidth();
childMax += child->maxWidth();
- if (normal || oldnormal) {
+ // FIXME: This isn't right. WinIE, Opera, Mozilla all do this differently and
+ // treat replaced elements like characters in a word.
+ if (autoWrap || oldAutoWrap) {
if(m_minWidth < inlineMin) m_minWidth = inlineMin;
inlineMin = 0;
}
@@ -2934,7 +2929,7 @@
// Add our width to the max.
inlineMax += childMax;
- if (!normal)
+ if (!autoWrap)
inlineMin += childMin;
else {
// Now check our line.
@@ -3040,13 +3035,14 @@
trailingSpaceChild = 0;
}
- oldnormal = normal;
+ oldAutoWrap = autoWrap;
}
- stripTrailingSpace(m_pre, inlineMax, inlineMin, trailingSpaceChild);
+ if (style()->collapseWhiteSpace())
+ stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild);
- if(m_minWidth < inlineMin) m_minWidth = inlineMin;
- if(m_maxWidth < inlineMax) m_maxWidth = inlineMax;
+ m_minWidth = kMax(inlineMin, m_minWidth);
+ m_maxWidth = kMax(inlineMax, m_maxWidth);
// kdDebug( 6040 ) << "m_minWidth=" << m_minWidth
// << " m_maxWidth=" << m_maxWidth << endl;
@@ -3544,7 +3540,6 @@
void RenderBlock::dump(QTextStream *stream, QString ind) const
{
if (m_childrenInline) { *stream << " childrenInline"; }
- if (m_pre) { *stream << " pre"; }
if (m_firstLine) { *stream << " firstLine"; }
if (m_floatingObjects && !m_floatingObjects->isEmpty())
1.71 +0 -1 WebCore/khtml/rendering/render_block.h
Index: render_block.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_block.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- render_block.h 25 Oct 2005 20:54:27 -0000 1.70
+++ render_block.h 2 Nov 2005 08:52:45 -0000 1.71
@@ -404,7 +404,6 @@
QPtrList<RenderObject>* m_positionedObjects;
bool m_childrenInline : 1;
- bool m_pre : 1;
bool m_firstLine : 1;
EClear m_clearStatus : 2;
bool m_topMarginQuirk : 1;
1.55 +1 -1 WebCore/khtml/rendering/render_layer.h
Index: render_layer.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- render_layer.h 26 Oct 2005 21:47:37 -0000 1.54
+++ render_layer.h 2 Nov 2005 08:52:45 -0000 1.55
@@ -161,7 +161,7 @@
bool m_reset: 1;
bool m_suspended : 1;
bool m_stopped : 1;
- EWhiteSpace m_whiteSpace : 2;
+ EWhiteSpace m_whiteSpace : 3;
EMarqueeDirection m_direction : 4;
};
1.56 +1 -1 WebCore/khtml/rendering/render_line.cpp
Index: render_line.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_line.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- render_line.cpp 18 Oct 2005 03:15:31 -0000 1.55
+++ render_line.cpp 2 Nov 2005 08:52:45 -0000 1.56
@@ -916,7 +916,7 @@
shouldDraw = true;
break;
}
- else if (curr->isText() && !curr->isBR() && (curr->style()->whiteSpace() == PRE ||
+ else if (curr->isText() && !curr->isBR() && (!curr->style()->collapseWhiteSpace() ||
!curr->element() || !curr->element()->containsOnlyWhitespace())) {
shouldDraw = true;
break;
1.224 +1 -1 WebCore/khtml/rendering/render_object.cpp
Index: render_object.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_object.cpp,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- render_object.cpp 19 Oct 2005 09:15:14 -0000 1.223
+++ render_object.cpp 2 Nov 2005 08:52:45 -0000 1.224
@@ -1917,7 +1917,7 @@
int RenderObject::tabWidth() const
{
- if (style()->whiteSpace() != PRE)
+ if (style()->collapseWhiteSpace())
return 0;
return containingBlock()->tabWidth(true);
1.97 +41 -6 WebCore/khtml/rendering/render_style.h
Index: render_style.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_style.h,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- render_style.h 28 Oct 2005 07:03:26 -0000 1.96
+++ render_style.h 2 Nov 2005 08:52:46 -0000 1.97
@@ -838,7 +838,7 @@
//
enum EWhiteSpace {
- NORMAL, PRE, NOWRAP, KHTML_NOWRAP
+ NORMAL, PRE, PRE_WRAP, PRE_LINE, NOWRAP, KHTML_NOWRAP
};
enum ETextAlign {
@@ -1026,12 +1026,13 @@
ECursor _cursor_style : 4;
EDirection _direction : 1;
bool _border_collapse : 1 ;
- EWhiteSpace _white_space : 2;
+ EWhiteSpace _white_space : 3;
EBoxDirection _box_direction : 1; // CSS3 box_direction property (flexible box layout module)
- // non CSS2 inherited
- bool _visuallyOrdered : 1;
- bool _htmlHacks :1;
- bool _force_backgrounds_to_white : 1;
+
+ // non CSS2 inherited
+ bool _visuallyOrdered : 1;
+ bool _htmlHacks :1;
+ bool _force_backgrounds_to_white : 1;
} inherited_flags;
// don't inherit
@@ -1285,6 +1286,40 @@
Length lineHeight() const { return inherited->line_height; }
EWhiteSpace whiteSpace() const { return inherited_flags._white_space; }
+ static bool autoWrap(EWhiteSpace ws) {
+ // Nowrap and pre don't automatically wrap.
+ return ws != NOWRAP && ws != PRE;
+ }
+ bool autoWrap() const {
+ return autoWrap(whiteSpace());
+ }
+ static bool preserveNewline(EWhiteSpace ws) {
+ // Normal and nowrap do not preserve newlines.
+ return ws != NORMAL && ws != NOWRAP;
+ }
+ bool preserveNewline() const {
+ return preserveNewline(whiteSpace());
+ }
+ static bool collapseWhiteSpace(EWhiteSpace ws) {
+ // Pre and prewrap do not collapse whitespace.
+ return ws != PRE && ws != PRE_WRAP;
+ }
+ bool collapseWhiteSpace() const {
+ return collapseWhiteSpace(whiteSpace());
+ }
+ bool isCollapsibleWhiteSpace(const QChar& c) const {
+ switch (c.unicode()) {
+ case ' ':
+ case '\t':
+ return collapseWhiteSpace();
+ case '\n':
+ return !preserveNewline();
+ }
+ return false;
+ }
+ bool breakOnlyAfterWhiteSpace() const {
+ return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE;
+ }
const QColor & backgroundColor() const { return background->m_color; }
CachedImage *backgroundImage() const { return background->m_background.m_image; }
1.137 +1 -1 WebCore/khtml/rendering/render_table.cpp
Index: render_table.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_table.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- render_table.cpp 25 Oct 2005 22:26:29 -0000 1.136
+++ render_table.cpp 2 Nov 2005 08:52:46 -0000 1.137
@@ -1622,7 +1622,7 @@
void RenderTableCell::calcMinMaxWidth()
{
RenderBlock::calcMinMaxWidth();
- if (element() && style()->whiteSpace() == NORMAL) {
+ if (element() && style()->autoWrap()) {
// See if nowrap was set.
DOMString nowrap = static_cast<ElementImpl*>(element())->getAttribute(nowrapAttr);
if (!nowrap.isNull() && style()->width().isFixed())
1.205 +25 -28 WebCore/khtml/rendering/render_text.cpp
Index: render_text.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_text.cpp,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- render_text.cpp 28 Oct 2005 17:14:14 -0000 1.204
+++ render_text.cpp 2 Nov 2005 08:52:46 -0000 1.205
@@ -1098,7 +1098,7 @@
RenderBlock *cb = containingBlock();
int availableWidth = cb->lineWidth(top);
- if (style()->whiteSpace() == NORMAL)
+ if (style()->autoWrap())
left = kMin(left, absx + box->m_x + availableWidth - 1);
return QRect(left, top, 1, height);
@@ -1190,8 +1190,8 @@
int& beginMaxW, int& endMaxW,
int& minW, int& maxW, bool& stripFrontSpaces)
{
- bool isPre = style()->whiteSpace() == PRE;
- if (isPre)
+ bool collapseWhiteSpace = style()->collapseWhiteSpace();
+ if (!collapseWhiteSpace)
stripFrontSpaces = false;
int len = str->l;
@@ -1207,7 +1207,7 @@
minW = m_minWidth;
maxW = m_maxWidth;
- beginWS = stripFrontSpaces ? false : m_hasBeginWS;
+ beginWS = !stripFrontSpaces && m_hasBeginWS;
endWS = m_hasEndWS;
beginMinW = m_beginMinWidth;
@@ -1216,20 +1216,18 @@
hasBreakableChar = m_hasBreakableChar;
hasBreak = m_hasBreak;
- if (stripFrontSpaces && (str->s[0] == ' ' || (!isPre && (str->s[0] == '\n' || str->s[0] == '\t')))) {
+ if (stripFrontSpaces && (str->s[0] == ' ' || (str->s[0] == '\n' && !style()->preserveNewline()) || str->s[0] == '\t')) {
const Font *f = htmlFont( false );
QChar space[1]; space[0] = ' ';
int spaceWidth = f->width(space, 1, 0, 0);
maxW -= spaceWidth + f->getWordSpacing();
}
- stripFrontSpaces = !isPre && m_hasEndWS;
+ stripFrontSpaces = collapseWhiteSpace && m_hasEndWS;
- if (style()->whiteSpace() == NOWRAP)
+ if (!style()->autoWrap() || minW > maxW)
minW = maxW;
- else if (minW > maxW)
- minW = maxW;
-
+
// Compute our max widths by scanning the string for newlines.
if (hasBreak) {
const Font *f = htmlFont( false );
@@ -1294,7 +1292,6 @@
bool needsWordSpacing = false;
bool ignoringSpaces = false;
bool isSpace = false;
- bool isPre = style()->whiteSpace() == PRE;
bool firstWord = true;
bool firstLine = true;
int nextBreakable = -1;
@@ -1306,14 +1303,14 @@
bool isNewline = false;
if (c == '\n') {
- if (isPre) {
+ if (style()->preserveNewline()) {
m_hasBreak = true;
isNewline = true;
isSpace = false;
} else
isSpace = true;
} else if (c == '\t') {
- if (isPre) {
+ if (!style()->collapseWhiteSpace()) {
m_hasTab = true;
isSpace = false;
} else
@@ -1327,7 +1324,7 @@
if ((isSpace || isNewline) && i == len-1)
m_hasEndWS = true;
- if (!ignoringSpaces && !isPre && previousCharacterIsSpace && isSpace)
+ if (!ignoringSpaces && style()->collapseWhiteSpace() && previousCharacterIsSpace && isSpace)
ignoringSpaces = true;
if (ignoringSpaces && !isSpace)
@@ -1350,20 +1347,19 @@
}
int wordlen = j - i;
- if (wordlen)
- {
+ if (wordlen) {
int w = widthFromCache(f, i, wordlen, tabWidth(), leadWidth + currMaxWidth);
currMinWidth += w;
currMaxWidth += w;
- bool isBreakableCharSpace = (j < len) && ((!isPre && (c == '\n' || c == '\t')) || c == ' ');
-
- if (j < len && style()->whiteSpace() == NORMAL)
+ bool isSpace = (j < len) && c == ' ';
+ bool isCollapsibleWhiteSpace = (j < len) && style()->isCollapsibleWhiteSpace(c);
+ if (j < len && style()->autoWrap())
m_hasBreakableChar = true;
// Add in wordSpacing to our currMaxWidth, but not if this is the last word on a line or the
// last word in the run.
- if (wordSpacing && isBreakableCharSpace && !containsOnlyWhitespace(j, len-j))
+ if (wordSpacing && (isSpace || isCollapsibleWhiteSpace) && !containsOnlyWhitespace(j, len-j))
currMaxWidth += wordSpacing;
if (firstWord) {
@@ -1385,14 +1381,13 @@
else {
// Nowrap can never be broken, so don't bother setting the
// breakable character boolean. Pre can only be broken if we encounter a newline.
- if (style()->whiteSpace() == NORMAL || isNewline)
+ if (style()->autoWrap() || isNewline)
m_hasBreakableChar = true;
if (currMinWidth > m_minWidth) m_minWidth = currMinWidth;
currMinWidth = 0;
- if (isNewline) // Only set if isPre was true and we saw a newline.
- {
+ if (isNewline) { // Only set if preserveNewline was true and we saw a newline.
if (firstLine) {
firstLine = false;
leadWidth = 0;
@@ -1413,13 +1408,15 @@
if (needsWordSpacing && len > 1)
currMaxWidth += wordSpacing;
- if(currMinWidth > m_minWidth) m_minWidth = currMinWidth;
- if(currMaxWidth > m_maxWidth) m_maxWidth = currMaxWidth;
+ m_minWidth = kMax(currMinWidth, m_minWidth);
+ m_maxWidth = kMax(currMaxWidth, m_maxWidth);
- if (style()->whiteSpace() != NORMAL)
+ if (!style()->autoWrap())
m_minWidth = m_maxWidth;
- if (isPre) {
+ if (style()->whiteSpace() == PRE) {
+ // FIXME: pre-wrap and pre-line need to be dealt with possibly? This code won't be right
+ // for them though.
if (firstLine)
m_beginMinWidth = m_maxWidth;
m_endMinWidth = currMaxWidth;
@@ -1688,7 +1685,7 @@
if ( from + len > str->l ) len = str->l - from;
int w;
- if ( style()->whiteSpace() != PRE && f == &style()->htmlFont() && from == 0 && len == str->l ) {
+ if (!style()->preserveNewline() && f == &style()->htmlFont() && from == 0 && len == str->l ) {
w = m_maxWidth;
} else if (f == &style()->htmlFont()) {
w = widthFromCache(f, from, len, tabWidth(), xpos);
1.58 +1 -1 WebCore/khtml/xml/dom_elementimpl.h
Index: dom_elementimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_elementimpl.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- dom_elementimpl.h 26 Oct 2005 20:44:12 -0000 1.57
+++ dom_elementimpl.h 2 Nov 2005 08:52:49 -0000 1.58
@@ -335,7 +335,7 @@
// When adding new entries, make sure to keep eLastEntry at the end of the list.
enum MappedAttributeEntry { eNone, eUniversal, ePersistent, eReplaced, eBlock, eHR, eUnorderedList, eListItem,
- eTable, eCell, eCaption, eBDO, eLastEntry };
+ eTable, eCell, eCaption, eBDO, ePre, eLastEntry };
class CSSMappedAttributeDeclarationImpl : public CSSMutableStyleDeclarationImpl
{
1.35 +1 -1 WebCore/khtml/xml/dom_textimpl.cpp
Index: dom_textimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_textimpl.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- dom_textimpl.cpp 3 Oct 2005 21:12:54 -0000 1.34
+++ dom_textimpl.cpp 2 Nov 2005 08:52:50 -0000 1.35
@@ -429,7 +429,7 @@
if (par->isTable() || par->isTableRow() || par->isTableSection() || par->isTableCol() || par->isFrameSet())
return false;
- if (style->whiteSpace() == PRE)
+ if (style->preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
return true;
RenderObject *prev = previousRenderer();
1.682 +1 -1 WebCore/kwq/KWQKHTMLPart.mm
Index: KWQKHTMLPart.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
retrieving revision 1.681
retrieving revision 1.682
diff -u -r1.681 -r1.682
--- KWQKHTMLPart.mm 1 Nov 2005 19:04:22 -0000 1.681
+++ KWQKHTMLPart.mm 2 Nov 2005 08:52:50 -0000 1.682
@@ -2990,7 +2990,7 @@
int start = (n == _startNode) ? startOffset : -1;
int end = (n == endNode) ? endOffset : -1;
if (renderer->isText()) {
- if (style->whiteSpace() == PRE) {
+ if (!style->collapseWhiteSpace()) {
if (needSpace && !addedSpace) {
if (text.isEmpty() && linkStartLocation == [result length]) {
++linkStartLocation;
More information about the webkit-changes
mailing list