Commit 8dc5fa9f authored by hyatt's avatar hyatt
Browse files

Change relative positioned blocks so that they are treated as special objects and

	painted last along with absolutely positioned blocks and floaters.  Note that the
	entire special object system is fundamentally flawed, and it needs to be replaced
	with a real layering subsystem.

	This checkin at least gets relatively positioned divs painting correctly some of
	the time (in the cases where the containing blocks of absolute and relative positioned
	divs happen to be the same).  It does not, however, deal with the problem of ensuring
	correct stacking of positioned elements with different containing blocks.

	render_layer.h and .cpp include a new implementation (not used yet, just the beginnings)
	of a layering subsystem that I am going to be working on over the next few days
	that will eventually be responsible for handling event dispatching and painting and that
	will also understand how to deal with form controls and other objects that have Cocoa
	views.

        * WebCore.pbproj/project.pbxproj:
        * khtml/rendering/render_box.cpp:
        (RenderBox::RenderBox):
        * khtml/rendering/render_box.h:
        * khtml/rendering/render_flow.cpp:
        (RenderFlow::printObject):
        (RenderFlow::printSpecialObjects):
        (RenderFlow::layoutSpecialObjects):
        (RenderFlow::layoutBlockChildren):
        (RenderFlow::insertSpecialObject):
        * khtml/rendering/render_flow.h:
        * khtml/rendering/render_layer.cpp: Added.
        (RenderLayer::RenderLayer):
        (RenderLayer::~RenderLayer):
        (RenderLayer::addChild):
        (RenderLayer::removeChild):
        * khtml/rendering/render_layer.h: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1922 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7a0cc4de
2002-08-27 David Hyatt <hyatt@apple.com>
Change relative positioned blocks so that they are treated as special objects and
painted last along with absolutely positioned blocks and floaters. Note that the
entire special object system is fundamentally flawed, and it needs to be replaced
with a real layering subsystem.
This checkin at least gets relatively positioned divs painting correctly some of
the time (in the cases where the containing blocks of absolute and relative positioned
divs happen to be the same). It does not, however, deal with the problem of ensuring
correct stacking of positioned elements with different containing blocks.
render_layer.h and .cpp include a new implementation (not used yet, just the beginnings)
of a layering subsystem that I am going to be working on over the next few days
that will eventually be responsible for handling event dispatching and painting and that
will also understand how to deal with form controls and other objects that have Cocoa
views.
* WebCore.pbproj/project.pbxproj:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::printObject):
(RenderFlow::printSpecialObjects):
(RenderFlow::layoutSpecialObjects):
(RenderFlow::layoutBlockChildren):
(RenderFlow::insertSpecialObject):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_layer.cpp: Added.
(RenderLayer::RenderLayer):
(RenderLayer::~RenderLayer):
(RenderLayer::addChild):
(RenderLayer::removeChild):
* khtml/rendering/render_layer.h: Added.
2002-08-27 Darin Adler <darin@apple.com>
- fixed 3031952 -- null-dereference in dispatchToUInt32 closing window
......
2002-08-27 David Hyatt <hyatt@apple.com>
Change relative positioned blocks so that they are treated as special objects and
painted last along with absolutely positioned blocks and floaters. Note that the
entire special object system is fundamentally flawed, and it needs to be replaced
with a real layering subsystem.
This checkin at least gets relatively positioned divs painting correctly some of
the time (in the cases where the containing blocks of absolute and relative positioned
divs happen to be the same). It does not, however, deal with the problem of ensuring
correct stacking of positioned elements with different containing blocks.
render_layer.h and .cpp include a new implementation (not used yet, just the beginnings)
of a layering subsystem that I am going to be working on over the next few days
that will eventually be responsible for handling event dispatching and painting and that
will also understand how to deal with form controls and other objects that have Cocoa
views.
* WebCore.pbproj/project.pbxproj:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::printObject):
(RenderFlow::printSpecialObjects):
(RenderFlow::layoutSpecialObjects):
(RenderFlow::layoutBlockChildren):
(RenderFlow::insertSpecialObject):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_layer.cpp: Added.
(RenderLayer::RenderLayer):
(RenderLayer::~RenderLayer):
(RenderLayer::addChild):
(RenderLayer::removeChild):
* khtml/rendering/render_layer.h: Added.
2002-08-27 Darin Adler <darin@apple.com>
- fixed 3031952 -- null-dereference in dispatchToUInt32 closing window
......
2002-08-27 David Hyatt <hyatt@apple.com>
Change relative positioned blocks so that they are treated as special objects and
painted last along with absolutely positioned blocks and floaters. Note that the
entire special object system is fundamentally flawed, and it needs to be replaced
with a real layering subsystem.
This checkin at least gets relatively positioned divs painting correctly some of
the time (in the cases where the containing blocks of absolute and relative positioned
divs happen to be the same). It does not, however, deal with the problem of ensuring
correct stacking of positioned elements with different containing blocks.
render_layer.h and .cpp include a new implementation (not used yet, just the beginnings)
of a layering subsystem that I am going to be working on over the next few days
that will eventually be responsible for handling event dispatching and painting and that
will also understand how to deal with form controls and other objects that have Cocoa
views.
* WebCore.pbproj/project.pbxproj:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
* khtml/rendering/render_box.h:
* khtml/rendering/render_flow.cpp:
(RenderFlow::printObject):
(RenderFlow::printSpecialObjects):
(RenderFlow::layoutSpecialObjects):
(RenderFlow::layoutBlockChildren):
(RenderFlow::insertSpecialObject):
* khtml/rendering/render_flow.h:
* khtml/rendering/render_layer.cpp: Added.
(RenderLayer::RenderLayer):
(RenderLayer::~RenderLayer):
(RenderLayer::addChild):
(RenderLayer::removeChild):
* khtml/rendering/render_layer.h: Added.
2002-08-27 Darin Adler <darin@apple.com>
- fixed 3031952 -- null-dereference in dispatchToUInt32 closing window
......
......@@ -492,6 +492,7 @@
F593F87D0302BE00018635CE,
F583D50303140623018635CE,
F5517DC4031AB56301A80180,
F690CFEC031C47F401CA2AC4,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -721,6 +722,7 @@
F593F87E0302BE00018635CE,
F583D50403140623018635CE,
F5517DC5031AB56301A80180,
F690CFED031C47F401CA2AC4,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
......@@ -3340,6 +3342,8 @@
F523D2B602DE4438018635CA,
F523D2B702DE4438018635CA,
F523D2B802DE4438018635CA,
F690CFEA031C47F401CA2AC4,
F690CFEB031C47F401CA2AC4,
F523D2B902DE4438018635CA,
F523D2BA02DE4438018635CA,
F523D2BC02DE4438018635CA,
......@@ -7581,6 +7585,38 @@
//F52
//F53
//F54
//F60
//F61
//F62
//F63
//F64
F690CFEA031C47F401CA2AC4 = {
isa = PBXFileReference;
path = render_layer.h;
refType = 4;
};
F690CFEB031C47F401CA2AC4 = {
isa = PBXFileReference;
path = render_layer.cpp;
refType = 4;
};
F690CFEC031C47F401CA2AC4 = {
fileRef = F690CFEA031C47F401CA2AC4;
isa = PBXBuildFile;
settings = {
};
};
F690CFED031C47F401CA2AC4 = {
fileRef = F690CFEB031C47F401CA2AC4;
isa = PBXBuildFile;
settings = {
};
};
//F60
//F61
//F62
//F63
//F64
//F80
//F81
//F82
......
......@@ -56,6 +56,7 @@ RenderBox::RenderBox(DOM::NodeImpl* node)
m_marginBottom = 0;
m_marginLeft = 0;
m_marginRight = 0;
m_layer = 0;
}
void RenderBox::setStyle(RenderStyle *_style)
......
......@@ -28,7 +28,8 @@
namespace khtml {
class CachedObject;
class RenderLayer;
class RenderBox : public RenderContainer
{
......@@ -100,6 +101,8 @@ public:
void relativePositionOffset(int &tx, int &ty);
RenderLayer* layer() { return m_layer; }
protected:
virtual void printBoxDecorations(QPainter *p,int _x, int _y,
int _w, int _h, int _tx, int _ty);
......@@ -137,6 +140,10 @@ protected:
* ( = the width of the element with line breaking disabled)
*/
short m_maxWidth;
// A pointer to our layer if we have one. Currently only positioned elements
// and floaters have layers.
RenderLayer* m_layer;
};
......
......@@ -164,7 +164,7 @@ void RenderFlow::printObject(QPainter *p, int _x, int _y,
RenderObject *child = firstChild();
while(child != 0)
{
if(!child->isFloating() && !child->isPositioned())
if(!child->isFloating() && !child->isPositioned() && !child->isRelPositioned())
child->print(p, _x, _y, _w, _h, _tx, _ty);
child = child->nextSibling();
}
......@@ -202,9 +202,9 @@ void RenderFlow::printSpecialObjects( QPainter *p, int x, int y, int w, int h, i
for ( ; (r = it.current()); ++it ) {
// A special object may be registered with several different objects... so we only print the
// object if we are its containing block
if (r->node->isPositioned() && r->node->containingBlock() == this) {
if ((r->node->isPositioned() || r->node->isRelPositioned()) && r->node->containingBlock() == this)
r->node->print(p, x, y, w, h, tx , ty);
} else if ( ( r->node->isFloating() && !r->noPaint ) ) {
else if ( ( r->node->isFloating() && !r->noPaint ) ) {
r->node->print(p, x, y, w, h, tx + r->left - r->node->xPos() + r->node->marginLeft(),
ty + r->startY - r->node->yPos() + r->node->marginTop() );
}
......@@ -320,6 +320,7 @@ void RenderFlow::layoutSpecialObjects( bool relayoutChildren )
if ( !r->node->layouted() )
r->node->layout();
}
// We don't lay out relative positioned objects here. They get a layout during the normal flow - dwh
}
specialObjects->sort();
}
......@@ -394,12 +395,27 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
// kdDebug( 6040 ) << t.elapsed() << endl;
// ### might be some layouts are done two times... FIX that.
if (child->isPositioned())
if (child->isPositioned() || child->isRelPositioned())
{
static_cast<RenderFlow*>(child->containingBlock())->insertSpecialObject(child);
//kdDebug() << "RenderFlow::layoutBlockChildren inserting positioned into " << child->containingBlock()->renderName() << endl;
child = child->nextSibling();
continue;
// Absolute positioned objects aren't part of the flow, but relative objects are.
// Both types of positioned objects have to be painted after all normal flow objects though,
// and relative objects can even paint on top of absolute positioned objects if they occur later in
// the content model (or have a higher z-index). -dwh
//
// A simple example:
/* <div style="width:317px;height:381px;background-color:red;position: absolute;"></div>
<div style="background-color: green; color: white; position: relative; height: 30px;">
This text should be clearly visible.
</div>
</div>
*/
if (child->isPositioned()) {
child = child->nextSibling();
continue;
}
} else if ( child->isReplaced() ) {
if ( !child->layouted() )
child->layout();
......@@ -545,6 +561,10 @@ void RenderFlow::insertSpecialObject(RenderObject *o)
newObj = new SpecialObject(SpecialObject::Positioned);
setOverhangingContents();
}
else if (o->isRelPositioned()) {
// relative positioned object.
newObj = new SpecialObject(SpecialObject::RelPositioned);
}
else if (o->isFloating()) {
// floating object
if ( !o->layouted() )
......
......@@ -138,7 +138,8 @@ protected:
enum Type {
FloatLeft,
FloatRight,
Positioned
Positioned,
RelPositioned
};
SpecialObject(Type _type) {
......
/**
* This file is part of the html renderer for KDE.
*
* Copyright (C) 2002 (hyatt@apple.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "render_layer.h"
#include <kdebug.h>
#include <assert.h>
#include "khtmlview.h"
using namespace DOM;
using namespace khtml;
RenderLayer::RenderLayer(RenderObject* object)
: m_object( object ),
m_parent( 0 ),
m_previous( 0 ),
m_next( 0 ),
m_first( 0 ),
m_last( 0 ),
m_height( 0 ),
m_y( 0 ),
m_x( 0 ),
m_width( 0 )
{
}
RenderLayer::~RenderLayer()
{
// Child layers will be deleted by their corresponding render objects, so
// our destructor doesn't have to do anything.
}
void RenderLayer::addChild(RenderLayer *child, RenderLayer *beforeChild)
{
if (!beforeChild)
setLastChild(child);
if(beforeChild == firstChild()) // Handles the null case too.
setFirstChild(child);
RenderLayer* prev = beforeChild ? beforeChild->previousSibling() : 0;
child->setNextSibling(beforeChild);
if (beforeChild) beforeChild->setPreviousSibling(child);
if(prev) prev->setNextSibling(child);
child->setPreviousSibling(prev);
child->setParent(this);
}
RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild)
{
// remove the child
if (oldChild->previousSibling())
oldChild->previousSibling()->setNextSibling(oldChild->nextSibling());
if (oldChild->nextSibling())
oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling());
if (m_first == oldChild)
m_first = oldChild->nextSibling();
if (m_last == oldChild)
m_last = oldChild->previousSibling();
oldChild->setPreviousSibling(0);
oldChild->setNextSibling(0);
oldChild->setParent(0);
return oldChild;
}
/*
* This file contains the implementation of the layering system for the compositing
* of stacked layers (and for proper event handling with stacked layers).
*
* Copyright (C) 2002 (hyatt@apple.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef render_layer_h
#define render_layer_h
#include <qcolor.h>
#include <qrect.h>
#include <assert.h>
#include "misc/khtmllayout.h"
#include "misc/loader_client.h"
#include "misc/helper.h"
#include "rendering/render_style.h"
namespace khtml {
class RenderFlow;
class RenderStyle;
class RenderTable;
class CachedObject;
class RenderRoot;
class RenderText;
class RenderFrameSet;
class RenderObject;
class RenderLayer
{
public:
RenderLayer(RenderObject* object);
~RenderLayer();
RenderLayer *parent() const { return m_parent; }
RenderLayer *previousSibling() const { return m_previous; }
RenderLayer *nextSibling() const { return m_next; }
RenderLayer *firstChild() const { return m_first; }
RenderLayer *lastChild() const { return m_last; }
void addChild(RenderLayer *newChild, RenderLayer *beforeChild = 0);
RenderLayer* removeChild(RenderLayer *oldChild);
int xPos() const { return m_x; }
int yPos() const { return m_y; }
short width() const { return m_width; }
int height() const { return m_height; }
void setWidth( int width ) { m_width = width; }
void setHeight( int height ) { m_height = height; }
void setPos( int xPos, int yPos ) { m_x = xPos; m_y = yPos; }
private:
void setNextSibling(RenderLayer* next) { m_next = next; }
void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
void setParent(RenderLayer* parent) { m_parent = parent; }
void setFirstChild(RenderLayer* first) { m_first = first; }
void setLastChild(RenderLayer* last) { m_last = last; }
protected:
RenderObject* m_object;
RenderLayer *m_parent;
RenderLayer *m_previous;
RenderLayer *m_next;
RenderLayer *m_first;
RenderLayer *m_last;
// Our (x,y) coordinates are in our parent layer's coordinate space.
int m_height;
int m_y;
short m_x;
short m_width;
};
}; // namespace
#endif
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