nowrap issues
David Hyatt
hyatt@apple.com
Fri, 17 Jan 2003 00:13:36 -0800
--Apple-Mail-5-59506638
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Attached is a patch for the KHTML trunk. Note that our calcMinMaxWidth
methods are very different, so you'll want to test this out and make
sure it works for you.
--Apple-Mail-5-59506638
Content-Disposition: attachment;
filename=diff.txt
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
x-unix-mode=0644;
name="diff.txt"
? diff.txt
Index: css/cssstyleselector.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.259
diff -u -r1.259 cssstyleselector.cpp
--- css/cssstyleselector.cpp 16 Jan 2003 17:16:31 -0000 1.259
+++ css/cssstyleselector.cpp 17 Jan 2003 08:11:27 -0000
@@ -1899,6 +1899,7 @@
EWhiteSpace s;
switch(primitiveValue->getIdent()) {
+ case CSS_VAL__KONQ_NOWRAP: s = KONQ_NOWRAP; break;
case CSS_VAL_NOWRAP: s = NOWRAP; break;
case CSS_VAL_PRE: s = PRE; break;
case CSS_VAL_NORMAL:
Index: css/cssvalues.in
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/cssvalues.in,v
retrieving revision 1.28
diff -u -r1.28 cssvalues.in
--- css/cssvalues.in 16 Jan 2003 17:16:32 -0000 1.28
+++ css/cssvalues.in 17 Jan 2003 08:11:27 -0000
@@ -311,6 +311,7 @@
thick
thin
underline
+-konq-nowrap
# CSS_PROP__KONQ_FLOW_MODE
-konq-normal
-konq-around-floats
Index: html/html_tableimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_tableimpl.cpp,v
retrieving revision 1.170
diff -u -r1.170 html_tableimpl.cpp
--- html/html_tableimpl.cpp 14 Jan 2003 16:57:36 -0000 1.170
+++ html/html_tableimpl.cpp 17 Jan 2003 08:11:28 -0000
@@ -746,7 +746,6 @@
_col = -1;
_row = -1;
cSpan = rSpan = 1;
- m_nowrap = false;
_id = tag;
rowHeight = 0;
m_solid = false;
@@ -788,7 +787,10 @@
if(cSpan < 1 || cSpan > 1024) cSpan = 1;
break;
case ATTR_NOWRAP:
- m_nowrap = (attr->val() != 0);
+ if (attr->val() != 0)
+ addCSSProperty(CSS_PROP_WHITE_SPACE, "-konq-nowrap");
+ else
+ removeCSSProperty(CSS_PROP_WHITE_SPACE);
break;
case ATTR_WIDTH:
if (!attr->value().isEmpty())
Index: html/html_tableimpl.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_tableimpl.h,v
retrieving revision 1.66
diff -u -r1.66 html_tableimpl.h
--- html/html_tableimpl.h 9 Dec 2002 07:21:44 -0000 1.66
+++ html/html_tableimpl.h 17 Jan 2003 08:11:28 -0000
@@ -188,8 +188,7 @@
int colSpan() const { return cSpan; }
int rowSpan() const { return rSpan; }
- bool noWrap() const { return m_nowrap; }
-
+
virtual Id id() const { return _id; }
virtual void parseAttribute(AttributeImpl *attr);
virtual void attach();
Index: rendering/render_flow.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_flow.cpp,v
retrieving revision 1.318
diff -u -r1.318 render_flow.cpp
--- rendering/render_flow.cpp 13 Jan 2003 12:04:10 -0000 1.318
+++ rendering/render_flow.cpp 17 Jan 2003 08:11:30 -0000
@@ -1122,8 +1122,7 @@
bool tableCell = (isTableCell() && !style()->width().isFixed());
// ## maybe we should replace the noWrap stuff in RenderTable by CSS.
- bool nowrap = style()->whiteSpace() == NOWRAP ||
- ( tableCell && static_cast<RenderTableCell *>(this)->noWrap() );
+ bool nowrap = style()->whiteSpace() == NOWRAP;
// non breaking space
const QChar nbsp = 0xa0;
Index: rendering/render_style.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_style.h,v
retrieving revision 1.80
diff -u -r1.80 render_style.h
--- rendering/render_style.h 28 Dec 2002 14:05:05 -0000 1.80
+++ rendering/render_style.h 17 Jan 2003 08:11:31 -0000
@@ -370,7 +370,7 @@
// this applies to decoration_color too
enum EWhiteSpace {
- NORMAL, PRE, NOWRAP
+ NORMAL, PRE, NOWRAP, KONQ_NOWRAP
};
enum ETextAlign {
Index: rendering/render_table.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_table.cpp,v
retrieving revision 1.221
diff -u -r1.221 render_table.cpp
--- rendering/render_table.cpp 10 Jan 2003 11:47:42 -0000 1.221
+++ rendering/render_table.cpp 17 Jan 2003 08:11:33 -0000
@@ -1331,10 +1331,8 @@
DOM::HTMLTableCellElementImpl *tc = static_cast<DOM::HTMLTableCellElementImpl *>(node);
cSpan = tc->colSpan();
rSpan = tc->rowSpan();
- nWrap = tc->noWrap();
} else {
cSpan = rSpan = 1;
- nWrap = false;
}
}
@@ -1406,6 +1404,16 @@
style->setDisplay(TABLE_CELL);
RenderFlow::setStyle( style );
setSpecialObjects(true);
+
+ if (style->whiteSpace() == KONQ_NOWRAP) {
+ // Figure out if we are really nowrapping or if we should just
+ // use normal instead. If the width of the cell is fixed, then
+ // we don't actually use NOWRAP.
+ if (style->width().isFixed())
+ style->setWhiteSpace(NORMAL);
+ else
+ style->setWhiteSpace(NOWRAP);
+ }
}
#ifdef BOX_DEBUG
Index: rendering/render_table.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_table.h,v
retrieving revision 1.80
diff -u -r1.80 render_table.h
--- rendering/render_table.h 8 Jan 2003 19:10:44 -0000 1.80
+++ rendering/render_table.h 17 Jan 2003 08:11:33 -0000
@@ -308,9 +308,6 @@
unsigned short rowSpan() const { return rSpan; }
void setRowSpan( unsigned short r ) { rSpan = r; }
- bool noWrap() const { return nWrap; }
- void setNoWrap(bool nw) { nWrap = nw; }
-
int col() const { return _col; }
void setCol(int col) { _col = col; }
int row() const { return _row; }
--Apple-Mail-5-59506638
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
On Thursday, January 16, 2003, at 11:06 PM, Lars Knoll wrote:
> Sounds like a good idea. I'd like to move more of these hacks into CSS
> anyways. Tell me if you have a working patch and I'll apply it to CVS
> aswell
> :)
>
> Cheers,
> Lars
>
>> I implemented this, and it works. I just added the new value, and
>> then
>> do this in RenderTableCell's setStyle.
>>
>> if (style->whiteSpace() == KONQ_NOWRAP) {
>> // Figure out if we are really nowrapping or if we should
>> just
>> // use normal instead. If the width of the cell is fixed,
>> then
>> // we don't actually use NOWRAP.
>> if (style->width().isFixed())
>> style->setWhiteSpace(NORMAL);
>> else
>> style->setWhiteSpace(NOWRAP);
>> }
>>
>> This lets you get rid of the table cell casting and checks in
>> RenderFlow::calcMinMaxWidth too.
>>
>> dave
>>
>> On Thursday, January 16, 2003, at 01:42 PM, David Hyatt wrote:
>>> So now that I made nowrap work like the KHTML trunk (I was improperly
>>> applying nowrap when calcing the minmax for block children, when it
>>> should have only applied for minmax calcs of inline children),
>>> Apple's
>>> internal HR site misrenders. It does so because it has a
>>> construction
>>> like the following:
>>>
>>> <td nowrap>
>>> <div>
>>> Some text that shouldn't wrap.
>>> </div>
>>> </td>
>>>
>>> The problem with the current way table nowrap is handled is that it
>>> isn't placed into CSS, so there's no inheritance of white-space into
>>> child content. The <div> thinks it has white-space: normal, so it
>>> computes a min-width that is way too small.
>>>
>>> My idea for correcting this is to actually make a new CSS value for
>>> the white-space property, -konq-nowrap, that can be used to represent
>>> <td nowrap>. When encountered, the value can be dynamically mapped
>>> to
>>> "normal" if the cell has a fixed width or to "nowrap" if the cell
>>> does
>>> not.
>>>
>>> What do you think?
>>>
>>> dave
>>> (hyatt@apple.com)
>>>
>>> _______________________________________________
>>> Khtml-devel@mail.kde.org
>>> http://mail.kde.org/mailman/listinfo/khtml-devel
>>
>> _______________________________________________
>> Khtml-devel@mail.kde.org
>> http://mail.kde.org/mailman/listinfo/khtml-devel
>
--Apple-Mail-5-59506638--