Commit c5764f8d authored by darin's avatar darin
Browse files

Reviewed by Don.

	- fixed 3130566 -- REGRESSION: list item numbers are overlapping the text of the list items

	Moved the hack that handles list items that are not in lists out of the parser and into
	the DOM and Render tree code itself. This fixes the issue where the parser doesn't know which
	will be the parent node of the list item, and other problems with the old hack.

        * khtml/html/html_listimpl.cpp: (HTMLLIElementImpl::attach): Find the parent list (OL or UL).
	If there is no parent list, set a "not in list" flag on the render object so it knows to render
	"inside" no matter what the style says. Also use this parent and a safer check to make the
	start attribute work even when there is an intervening DOM element in the hierarchy.

        * khtml/html/htmlparser.cpp: (KHTMLParser::getElement): Remove the code that tries to set
	the style of an LI based on the current node at the time it's parsed, because the current node
	is now often not the OL or the UL due to our DTD fix to allow other nodes in lists.

        * khtml/rendering/render_list.h: Add isInside() to RenderListMarker, setNotInList(), notInList(),
	and _notInList to RenderListItem.

        * khtml/rendering/render_list.cpp:
        (RenderListItem::RenderListItem): Initialize _notInList to false.
        (RenderListMarker::paintObject): Use isInside() instead of checking listStylePosition().
        (RenderListMarker::calcMinMaxWidth): Ditto.
        (RenderListMarker::baselinePosition): Ditto.
        (RenderListMarker::isInside): Return true if we are not in a list, or if "inside" style is requested.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bd2f5f11
2002-12-29 Darin Adler <darin@apple.com>
Reviewed by Don.
- fixed 3130566 -- REGRESSION: list item numbers are overlapping the text of the list items
Moved the hack that handles list items that are not in lists out of the parser and into
the DOM and Render tree code itself. This fixes the issue where the parser doesn't know which
will be the parent node of the list item, and other problems with the old hack.
* khtml/html/html_listimpl.cpp: (HTMLLIElementImpl::attach): Find the parent list (OL or UL).
If there is no parent list, set a "not in list" flag on the render object so it knows to render
"inside" no matter what the style says. Also use this parent and a safer check to make the
start attribute work even when there is an intervening DOM element in the hierarchy.
* khtml/html/htmlparser.cpp: (KHTMLParser::getElement): Remove the code that tries to set
the style of an LI based on the current node at the time it's parsed, because the current node
is now often not the OL or the UL due to our DTD fix to allow other nodes in lists.
* khtml/rendering/render_list.h: Add isInside() to RenderListMarker, setNotInList(), notInList(),
and _notInList to RenderListItem.
* khtml/rendering/render_list.cpp:
(RenderListItem::RenderListItem): Initialize _notInList to false.
(RenderListMarker::paintObject): Use isInside() instead of checking listStylePosition().
(RenderListMarker::calcMinMaxWidth): Ditto.
(RenderListMarker::baselinePosition): Ditto.
(RenderListMarker::isInside): Return true if we are not in a list, or if "inside" style is requested.
2002-12-29 Darin Adler <darin@apple.com>
Reviewed by Don.
......
2002-12-29 Darin Adler <darin@apple.com>
Reviewed by Don.
- fixed 3130566 -- REGRESSION: list item numbers are overlapping the text of the list items
Moved the hack that handles list items that are not in lists out of the parser and into
the DOM and Render tree code itself. This fixes the issue where the parser doesn't know which
will be the parent node of the list item, and other problems with the old hack.
* khtml/html/html_listimpl.cpp: (HTMLLIElementImpl::attach): Find the parent list (OL or UL).
If there is no parent list, set a "not in list" flag on the render object so it knows to render
"inside" no matter what the style says. Also use this parent and a safer check to make the
start attribute work even when there is an intervening DOM element in the hierarchy.
* khtml/html/htmlparser.cpp: (KHTMLParser::getElement): Remove the code that tries to set
the style of an LI based on the current node at the time it's parsed, because the current node
is now often not the OL or the UL due to our DTD fix to allow other nodes in lists.
* khtml/rendering/render_list.h: Add isInside() to RenderListMarker, setNotInList(), notInList(),
and _notInList to RenderListItem.
* khtml/rendering/render_list.cpp:
(RenderListItem::RenderListItem): Initialize _notInList to false.
(RenderListMarker::paintObject): Use isInside() instead of checking listStylePosition().
(RenderListMarker::calcMinMaxWidth): Ditto.
(RenderListMarker::baselinePosition): Ditto.
(RenderListMarker::isInside): Return true if we are not in a list, or if "inside" style is requested.
2002-12-29 Darin Adler <darin@apple.com>
Reviewed by Don.
......
......@@ -143,19 +143,34 @@ void HTMLLIElementImpl::attach()
HTMLElementImpl::attach();
if ( m_render && m_render->style()->display() == LIST_ITEM ) {
// If we are first, and the OL has a start attr.
if (parentNode() && parentNode()->id() == ID_OL) {
HTMLOListElementImpl *ol = static_cast<HTMLOListElementImpl *>(parentNode());
if(ol->firstChild() && ol->firstChild() == this && m_render)
static_cast<RenderListItem*>(m_render)->setValue(ol->start());
RenderListItem *render = static_cast<RenderListItem *>(m_render);
// Find the enclosing list node.
NodeImpl *listNode = 0;
NodeImpl *n = this;
while (!listNode && (n = n->parentNode())) {
switch (n->id()) {
case ID_UL:
case ID_OL:
listNode = n;
}
}
// If we are not in a list, tell the renderer so it can position us inside.
// We don't want to change our style to say "inside" since that would affect nested nodes.
if (!listNode)
render->setNotInList(true);
// If we are first, and the OL has a start attr, set the value.
if (listNode && listNode->id() == ID_OL && !m_render->previousSibling()) {
HTMLOListElementImpl *ol = static_cast<HTMLOListElementImpl *>(listNode);
render->setValue(ol->start());
}
// If we had a value attr.
if (isValued && m_render)
static_cast<RenderListItem*>(m_render)->setValue(requestedValue);
if (isValued)
render->setValue(requestedValue);
}
}
......
......@@ -896,10 +896,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
case ID_LI:
{
popBlock(ID_LI);
HTMLElementImpl *e = new HTMLLIElementImpl(document);
n = e;
if( current->id() != ID_UL && current->id() != ID_OL )
e->addCSSProperty(CSS_PROP_LIST_STYLE_POSITION, CSS_VAL_INSIDE);
n = new HTMLLIElementImpl(document);
break;
}
// formatting elements (block)
......
......@@ -121,7 +121,7 @@ static QString toHebrew( int number ) {
// -------------------------------------------------------------------------
RenderListItem::RenderListItem(DOM::NodeImpl* node)
: RenderFlow(node)
: RenderFlow(node), _notInList(false)
{
// init RenderObject attributes
setInline(false); // our object is not Inline
......@@ -367,7 +367,7 @@ void RenderListMarker::paintObject(QPainter *p, int, int _y,
RenderObject* listItem = 0;
int leftLineOffset = 0;
int rightLineOffset = 0;
if (style()->listStylePosition() == OUTSIDE) {
if (!isInside()) {
listItem = this;
int yOffset = 0;
int xOffset = 0;
......@@ -411,7 +411,7 @@ void RenderListMarker::paintObject(QPainter *p, int, int _y,
int xoff = 0;
int yoff = fm.ascent() - offset;
if(style()->listStylePosition() == OUTSIDE)
if (!isInside())
if (listItem->style()->direction() == LTR)
xoff = -7 - offset;
else
......@@ -424,7 +424,7 @@ void RenderListMarker::paintObject(QPainter *p, int, int _y,
// For LTR don't forget to add in the width of the image to the offset as
// well (you are moving the image left, so you have to also add in the width
// of the image's border box as well). -dwh
if (style()->listStylePosition() == OUTSIDE) {
if (!isInside()) {
if (style()->direction() == LTR)
xoff -= m_listImage->pixmap().width() - fm.ascent()*1/3;
else
......@@ -468,7 +468,7 @@ void RenderListMarker::paintObject(QPainter *p, int, int _y,
#else
//_ty += fm.ascent() - fm.height()/2 + 1;
#endif
if (style()->listStylePosition() == INSIDE) {
if (isInside()) {
if( style()->direction() == LTR)
p->drawText(_tx, _ty, 0, 0, Qt::AlignLeft|Qt::DontClip, m_item);
else
......@@ -515,7 +515,7 @@ void RenderListMarker::calcMinMaxWidth()
m_width = 0;
if(m_listImage) {
if(style()->listStylePosition() == INSIDE)
if (isInside())
m_width = m_listImage->pixmap().width() + 5;
m_height = m_listImage->pixmap().height();
m_minWidth = m_maxWidth = m_width;
......@@ -534,7 +534,7 @@ void RenderListMarker::calcMinMaxWidth()
case DISC:
case CIRCLE:
case SQUARE:
if(style()->listStylePosition() == INSIDE) {
if (isInside()) {
m_width = m_height; //fm.ascent();
}
goto end;
......@@ -585,7 +585,7 @@ void RenderListMarker::calcMinMaxWidth()
}
m_item += QString::fromLatin1(". ");
if(style()->listStylePosition() == INSIDE)
if (isInside())
m_width = fm.width(m_item);
end:
......@@ -616,4 +616,9 @@ short RenderListMarker::baselinePosition(bool b) const
return RenderBox::baselinePosition(b);
}
bool RenderListMarker::isInside() const
{
return m_listItem->notInList() || style()->listStylePosition() == INSIDE;
}
#undef BOX_DEBUG
......@@ -69,6 +69,8 @@ public:
protected:
friend class RenderListItem;
bool isInside() const;
QString m_item;
CachedImage *m_listImage;
......@@ -99,10 +101,14 @@ public:
int xoff, int yoff, int paintPhase);
virtual void layout( );
void setNotInList(bool notInList) { _notInList = notInList; }
bool notInList() const { return _notInList; }
protected:
long int predefVal;
RenderListMarker *m_marker;
bool _notInList;
};
}; //namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment