Commit 4948ef9f authored by hyatt's avatar hyatt

Fix shroudedisles.com table misalignment by removing more\

	bogus rules from html4.css.

	Fix forums on macosx.com by implementing support for the align
	attribute on the <P> tag.

	Implement min-width and max-width for block level floating
	and normal flow elements.

	Fix event handling so that :hover notifications get through to
	objects inside floats.

        Reviewed by: rjw

        * khtml/css/html4.css:
        * khtml/html/html_blockimpl.cpp:
        (HTMLParagraphElementImpl::parseAttribute):
        * khtml/html/html_blockimpl.h:
        * khtml/rendering/render_box.cpp:
        (RenderBox::calcWidth):
        (RenderBox::calcWidthUsing):
        (RenderBox::calcHeight):
        * khtml/rendering/render_box.h:
        * khtml/rendering/render_flow.cpp:
        (RenderFlow::layoutBlockChildren):
        (RenderFlow::nodeAtPoint):
        * khtml/rendering/render_flow.h:
        * khtml/rendering/render_frames.cpp:
        (RenderFrameSet::nodeAtPoint):
        * khtml/rendering/render_frames.h:
        * khtml/rendering/render_image.cpp:
        (RenderImage::nodeAtPoint):
        * khtml/rendering/render_image.h:
        * khtml/rendering/render_object.cpp:
        (RenderObject::nodeAtPoint):
        * khtml/rendering/render_object.h:
        * khtml/rendering/render_root.cpp:
        (RenderRoot::calcHeight):
        * khtml/rendering/render_style.cpp:
        (StyleBoxData::StyleBoxData):
        * khtml/rendering/render_text.cpp:
        (RenderText::nodeAtPoint):
        * khtml/rendering/render_text.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 266af2d5
2002-12-04 David Hyatt <hyatt@apple.com>
Fix shroudedisles.com table misalignment by removing more\
bogus rules from html4.css.
Fix forums on macosx.com by implementing support for the align
attribute on the <P> tag.
Implement min-width and max-width for block level floating
and normal flow elements.
Fix event handling so that :hover notifications get through to
objects inside floats.
Reviewed by: rjw
* khtml/css/html4.css:
* khtml/html/html_blockimpl.cpp:
(HTMLParagraphElementImpl::parseAttribute):
* khtml/html/html_blockimpl.h:
* khtml/rendering/render_box.cpp:
(RenderBox::calcWidth):
(RenderBox::calcWidthUsing):
(RenderBox::calcHeight):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::layoutBlockChildren):
(RenderFlow::nodeAtPoint):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_frames.cpp:
(RenderFrameSet::nodeAtPoint):
* khtml/rendering/render_frames.h:
* khtml/rendering/render_image.cpp:
(RenderImage::nodeAtPoint):
* khtml/rendering/render_image.h:
* khtml/rendering/render_object.cpp:
(RenderObject::nodeAtPoint):
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::calcHeight):
* khtml/rendering/render_style.cpp:
(StyleBoxData::StyleBoxData):
* khtml/rendering/render_text.cpp:
(RenderText::nodeAtPoint):
* khtml/rendering/render_text.h:
2002-12-04 Darin Adler <darin@apple.com>
Reviewed by Trey and Maciej.
......
2002-12-04 David Hyatt <hyatt@apple.com>
Fix shroudedisles.com table misalignment by removing more\
bogus rules from html4.css.
Fix forums on macosx.com by implementing support for the align
attribute on the <P> tag.
Implement min-width and max-width for block level floating
and normal flow elements.
Fix event handling so that :hover notifications get through to
objects inside floats.
Reviewed by: rjw
* khtml/css/html4.css:
* khtml/html/html_blockimpl.cpp:
(HTMLParagraphElementImpl::parseAttribute):
* khtml/html/html_blockimpl.h:
* khtml/rendering/render_box.cpp:
(RenderBox::calcWidth):
(RenderBox::calcWidthUsing):
(RenderBox::calcHeight):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::layoutBlockChildren):
(RenderFlow::nodeAtPoint):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_frames.cpp:
(RenderFrameSet::nodeAtPoint):
* khtml/rendering/render_frames.h:
* khtml/rendering/render_image.cpp:
(RenderImage::nodeAtPoint):
* khtml/rendering/render_image.h:
* khtml/rendering/render_object.cpp:
(RenderObject::nodeAtPoint):
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::calcHeight):
* khtml/rendering/render_style.cpp:
(StyleBoxData::StyleBoxData):
* khtml/rendering/render_text.cpp:
(RenderText::nodeAtPoint):
* khtml/rendering/render_text.h:
2002-12-04 Darin Adler <darin@apple.com>
Reviewed by Trey and Maciej.
......
......@@ -249,19 +249,6 @@ DIV[align="right"] > P,
DIV[align="right"] > DIV
{ margin-left: auto; margin-right: 0px; }
/* don't use "TD[align=...] > *". This sould give problems with
* constructs as <td align=left><ul><li>...
* Hope the next ones cover all relevant cases. Lars
*/
TD[align="right"] > TABLE { margin-left: auto; margin-right: 0px; }
TD[align="left"] > TABLE { margin-left: 0px; margin-right: auto; }
TD[align="right"] > DIV { margin-left: auto; margin-right: 0px; text-align: right; }
TD[align="left"] > DIV { margin-left: 0px; margin-right: auto; text-align: left; }
TD[align="right"] > P { margin-left: auto; margin-right: 0px; text-align: right; }
TD[align="left"] > P { margin-left: 0px; margin-right: auto; text-align: left; }
TD[align="right"] > HR { margin-left: auto; margin-right: 1px; }
TD[align="left"] > HR { margin-left: 0px; margin-right: auto; }
/*
* Lists
*/
......
......@@ -187,6 +187,23 @@ NodeImpl::Id HTMLParagraphElementImpl::id() const
return ID_P;
}
void HTMLParagraphElementImpl::parseAttribute(AttributeImpl *attr)
{
switch(attr->id())
{
case ATTR_ALIGN:
{
DOMString v = attr->value();
if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
v = "-konq-center";
addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
break;
}
default:
HTMLElementImpl::parseAttribute(attr);
}
}
// -------------------------------------------------------------------------
HTMLPreElementImpl::HTMLPreElementImpl(DocumentPtr *doc, unsigned short _tagid)
......
......@@ -94,6 +94,8 @@ class HTMLParagraphElementImpl : public HTMLElementImpl
public:
HTMLParagraphElementImpl(DocumentPtr *doc);
virtual void parseAttribute(AttributeImpl *attr);
virtual NodeImpl::Id id() const;
};
......
......@@ -485,11 +485,11 @@ void RenderBox::calcWidth()
Length mr = style()->marginRight();
int cw;
RenderObject *cb = containingBlock();
if ( style()->flowAroundFloats() && cb->isFlow() )
cw = static_cast<RenderFlow *>(cb)->lineWidth( m_y );
else
cw = cb->contentWidth();
RenderObject *cb = containingBlock();
if ( style()->flowAroundFloats() && cb->isFlow() )
cw = static_cast<RenderFlow *>(cb)->lineWidth( m_y );
else
cw = cb->contentWidth();
if (cw<0) cw = 0;
......@@ -510,28 +510,38 @@ void RenderBox::calcWidth()
return;
}
else if (w.type == Variable)
{
// kdDebug( 6040 ) << "variable" << endl;
m_marginLeft = ml.minWidth(cw);
m_marginRight = mr.minWidth(cw);
if (cw) m_width = cw - m_marginLeft - m_marginRight;
// kdDebug( 6040 ) << m_width <<"," << cw <<"," <<
// m_marginLeft <<"," << m_marginRight << endl;
if (isFloating()) {
if(m_width < m_minWidth) m_width = m_minWidth;
if(m_width > m_maxWidth) m_width = m_maxWidth;
else {
LengthType widthType, minWidthType, maxWidthType;
if (isReplaced()) {
m_width = w.width(cw);
m_width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
widthType = w.type;
} else {
m_width = calcWidthUsing(Width, cw, widthType);
int minW = calcWidthUsing(MinWidth, cw, minWidthType);
int maxW = style()->maxWidth().value == UNDEFINED ?
m_width : calcWidthUsing(MaxWidth, cw, maxWidthType);
if (m_width > maxW) {
m_width = maxW;
widthType = maxWidthType;
}
else if (m_width < minW) {
m_width = minW;
widthType = minWidthType;
}
}
if (widthType == Variable) {
// kdDebug( 6040 ) << "variable" << endl;
m_marginLeft = ml.minWidth(cw);
m_marginRight = mr.minWidth(cw);
}
else
{
// kdDebug( 6040 ) << "non-variable " << w.type << ","<< w.value << endl;
calcHorizontalMargins(ml,mr,cw);
}
}
else
{
// kdDebug( 6040 ) << "non-variable " << w.type << ","<< w.value << endl;
m_width = w.width(cw);
m_width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
calcHorizontalMargins(ml,mr,cw);
}
if (cw && cw != m_width + m_marginLeft + m_marginRight && !isFloating() && !isInline())
......@@ -549,6 +559,40 @@ void RenderBox::calcWidth()
#endif
}
int RenderBox::calcWidthUsing(WidthType widthType, int cw, LengthType& lengthType)
{
int width = m_width;
Length w;
if (widthType == Width)
w = style()->width();
else if (widthType == MinWidth)
w = style()->minWidth();
else
w = style()->maxWidth();
lengthType = w.type;
if (lengthType == Variable) {
int marginLeft = style()->marginLeft().minWidth(cw);
int marginRight = style()->marginRight().minWidth(cw);
if (cw) width = cw - marginLeft - marginRight;
if (isFloating()) {
if (width < m_minWidth)
width = m_minWidth;
if (width > m_maxWidth)
width = m_maxWidth;
}
}
else
{
width = w.width(cw);
width += paddingLeft() + paddingRight() + borderLeft() + borderRight();
}
return width;
}
void RenderBox::calcHorizontalMargins(const Length& ml, const Length& mr, int cw)
{
if (isFloating())
......@@ -629,8 +673,13 @@ void RenderBox::calcHeight()
}
if (cb->isRoot()) {
// Don't allow this to affect the root's m_height member variable, since this
// can get called while the root is still laying out its kids.
// e.g., <html style="height:100%">etc. -dwh
int oldHeight = cb->height();
static_cast<RenderRoot*>(cb)->calcHeight();
fh = h.width(cb->height()) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
cb->setHeight(oldHeight);
}
else if (ch.isFixed())
fh = h.width(ch.value) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
......
......@@ -30,6 +30,8 @@
namespace khtml {
class CachedObject;
enum WidthType { Width, MinWidth, MaxWidth };
class RenderBox : public RenderContainer
{
......@@ -96,6 +98,8 @@ public:
virtual void calcWidth();
virtual void calcHeight();
int calcWidthUsing(WidthType widthType, int cw, LengthType& lengthType);
virtual short calcReplacedWidth(bool* ieHack=0) const;
virtual int calcReplacedHeight() const;
......
......@@ -520,7 +520,7 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
}
child->calcVerticalMargins();
//kdDebug(0) << "margin = " << margin << " yPos = " << m_height << endl;
// Try to guess our correct y position. In most cases this guess will
......@@ -635,6 +635,7 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
bottomChildQuirk = child->isBottomMarginQuirk();
}
}
child->setPos(child->xPos(), ypos);
if (ypos != yPosEstimate) {
// Our guess was wrong. Make the child lay itself out again.
......@@ -718,7 +719,6 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
child = child->nextSibling();
}
// XXX This check is unconvincing. Needs to be a reliable way to test for auto height. -dwh
bool autoHeight = style()->height().isVariable() && style()->height().value == 0;
// If any height other than auto is specified in CSS, then we don't collapse our bottom
......@@ -2238,9 +2238,8 @@ void RenderFlow::removeChild(RenderObject *oldChild)
}
}
bool RenderFlow::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
bool RenderFlow::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inBox)
{
bool inBox = false;
if (specialObjects) {
int stx = _tx + xPos();
int sty = _ty + yPos();
......@@ -2257,7 +2256,7 @@ bool RenderFlow::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
sty+o->startY + o->node->marginTop() - o->node->yPos());
}
inBox |= RenderBox::nodeAtPoint(info, _x, _y, _tx, _ty);
inBox |= RenderBox::nodeAtPoint(info, _x, _y, _tx, _ty, inBox);
return inBox;
}
......
......@@ -111,7 +111,7 @@ public:
virtual void dump(QTextStream *stream, QString ind = "") const;
#endif
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside=false);
protected:
......
......@@ -83,11 +83,11 @@ RenderFrameSet::~RenderFrameSet()
delete [] m_vSplitVar;
}
bool RenderFrameSet::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
bool RenderFrameSet::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inside)
{
RenderBox::nodeAtPoint(info, _x, _y, _tx, _ty);
RenderBox::nodeAtPoint(info, _x, _y, _tx, _ty, inside);
bool inside = m_resizing || canResize(_x, _y);
inside = m_resizing || canResize(_x, _y);
if ( inside && element() && !element()->noResize() && !info.readonly()){
info.setInnerNode(element());
......
......@@ -60,7 +60,7 @@ public:
bool canResize( int _x, int _y);
void setResizing(bool e);
bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty);
bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside=false);
DOM::HTMLFrameSetElementImpl *element() const
{ return static_cast<DOM::HTMLFrameSetElementImpl*>(RenderObject::element()); }
......
......@@ -345,9 +345,9 @@ void RenderImage::notifyFinished(CachedObject *finishedObj)
}
}
bool RenderImage::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
bool RenderImage::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inside)
{
bool inside = RenderReplaced::nodeAtPoint(info, _x, _y, _tx, _ty);
inside |= RenderReplaced::nodeAtPoint(info, _x, _y, _tx, _ty, inside);
if (inside && element()) {
int tx = _tx + m_x;
......
......@@ -64,7 +64,7 @@ public:
virtual void notifyFinished(CachedObject *finishedObj);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside=false);
private:
/*
......
......@@ -976,15 +976,14 @@ bool RenderObject::mouseInside() const
return m_mouseInside;
}
bool RenderObject::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
bool RenderObject::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, bool inside)
{
int tx = _tx + xPos();
int ty = _ty + yPos();
bool inside = (style()->visibility() != HIDDEN && ((_y >= ty) && (_y < ty + height()) &&
inside |= (style()->visibility() != HIDDEN && ((_y >= ty) && (_y < ty + height()) &&
(_x >= tx) && (_x < tx + width()))) || isBody() || isHtml();
bool inner = !info.innerNode();
// ### table should have its own, more performant method
if (overhangingContents() || isInline() || isRoot() || isTableRow() || isTableSection() || inside || mouseInside() ) {
for (RenderObject* child = lastChild(); child; child = child->previousSibling())
......@@ -1015,14 +1014,16 @@ bool RenderObject::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty)
if (!info.readonly()) {
// lets see if we need a new style
bool oldinside = mouseInside();
setMouseInside(inside && inner);
if (element()) {
bool oldactive = element()->active();
if (oldactive != (inside && info.active() && element() == info.innerNode()))
element()->setActive(inside && info.active() && element() == info.innerNode());
if ( ((oldinside != mouseInside()) && style()->hasHover()) ||
((oldactive != element()->active()) && style()->hasActive()))
element()->setChanged();
setMouseInside(inside);
DOM::NodeImpl* elt = (!isInline() && continuation()) ? continuation()->element() : element();
RenderObject* obj = (!isInline() && continuation()) ? continuation() : this;
if (elt) {
bool oldactive = elt->active();
if (oldactive != (inside && info.active() && elt == info.innerNode()))
elt->setActive(inside && info.active() && elt == info.innerNode());
if ( ((oldinside != mouseInside()) && obj->style()->hasHover()) ||
((oldactive != elt->active()) && obj->style()->hasActive()))
elt->setChanged();
}
}
......
......@@ -341,7 +341,7 @@ public:
virtual FindSelectionResult checkSelectionPoint( int _x, int _y, int _tx, int _ty,
DOM::NodeImpl*&, int & offset );
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside=false);
// set the style of the object.
virtual void setStyle(RenderStyle *style);
......
......@@ -79,7 +79,7 @@ void RenderRoot::calcHeight()
else if (!m_view)
{
m_height = m_rootHeight;
}
}
}
void RenderRoot::calcWidth()
......
......@@ -49,6 +49,15 @@ bool StyleSurroundData::operator==(const StyleSurroundData& o) const
StyleBoxData::StyleBoxData()
: z_index( 0 ), z_auto(true)
{
// Initialize our min/max widths/heights.
min_width.type = Fixed;
min_width.value = 0;
min_height.type = Fixed;
min_height.value = 0;
max_width.type = Fixed;
max_width.value = UNDEFINED;
max_height.type = Fixed;
max_height.value = UNDEFINED;
}
StyleBoxData::StyleBoxData(const StyleBoxData& o )
......
......@@ -388,7 +388,7 @@ TextSlave * RenderText::findTextSlave( int offset, int &pos )
return s;
}
bool RenderText::nodeAtPoint(NodeInfo& /*info*/, int _x, int _y, int _tx, int _ty)
bool RenderText::nodeAtPoint(NodeInfo& /*info*/, int _x, int _y, int _tx, int _ty, bool inside)
{
assert(parent());
......@@ -398,7 +398,6 @@ bool RenderText::nodeAtPoint(NodeInfo& /*info*/, int _x, int _y, int _tx, int _t
int height = m_lineHeight + borderTop() + paddingTop() +
borderBottom() + paddingBottom();
bool inside = false;
TextSlave *s = m_lines.count() ? m_lines[0] : 0;
int si = 0;
while(s) {
......
......@@ -146,7 +146,7 @@ public:
virtual void layout() {assert(false);}
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, bool inside);
// Return before, after (offset set to max), or inside the text, at @p offset
virtual FindSelectionResult checkSelectionPoint( int _x, int _y, int _tx, int _ty,
......
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