Commit 130a831d authored by hyatt's avatar hyatt
Browse files

Begin connecting the layer system. The root box and the <html>

	box now construct layers for themselves.  Those layers are
	connected in a layer tree properly and they correctly update
	their positions.

	Implemented all the code for layer construction and for keeping
	the layer tree in sync with the render object tree.

	The goal is to get the layer tree fully constructed and correct
	(with lots of testing) before actually switching over to it for
	painting.

	This change requires a clean of WebCore.

        * force-clean-timestamp:
        * khtml/rendering/render_box.cpp:
        (RenderBox::RenderBox):
        (RenderBox::~RenderBox):
        (RenderBox::setPos):
        (RenderBox::positionChildLayers):
        * khtml/rendering/render_box.h:
        * khtml/rendering/render_container.cpp:
        (RenderContainer::~RenderContainer):
        (RenderContainer::addChild):
        (RenderContainer::removeChildNode):
        * khtml/rendering/render_container.h:
        * khtml/rendering/render_html.cpp:
        (RenderHtml::RenderHtml):
        * khtml/rendering/render_layer.cpp:
        (RenderLayer::updateLayerPosition):
        * khtml/rendering/render_layer.h:
        * khtml/rendering/render_object.h:
        * khtml/rendering/render_root.cpp:
        (RenderRoot::RenderRoot):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1938 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34ead614
2002-08-29 David Hyatt <hyatt@apple.com>
Begin connecting the layer system. The root box and the <html>
box now construct layers for themselves. Those layers are
connected in a layer tree properly and they correctly update
their positions.
Implemented all the code for layer construction and for keeping
the layer tree in sync with the render object tree.
The goal is to get the layer tree fully constructed and correct
(with lots of testing) before actually switching over to it for
painting.
This change requires a clean of WebCore.
* force-clean-timestamp:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
(RenderBox::~RenderBox):
(RenderBox::setPos):
(RenderBox::positionChildLayers):
* khtml/rendering/render_box.h:
* khtml/rendering/render_container.cpp:
(RenderContainer::~RenderContainer):
(RenderContainer::addChild):
(RenderContainer::removeChildNode):
* khtml/rendering/render_container.h:
* khtml/rendering/render_html.cpp:
(RenderHtml::RenderHtml):
* khtml/rendering/render_layer.cpp:
(RenderLayer::updateLayerPosition):
* khtml/rendering/render_layer.h:
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::RenderRoot):
=== Alexander-21 ===
2002-08-28 David Hyatt <hyatt@apple.com>
......
2002-08-29 David Hyatt <hyatt@apple.com>
Begin connecting the layer system. The root box and the <html>
box now construct layers for themselves. Those layers are
connected in a layer tree properly and they correctly update
their positions.
Implemented all the code for layer construction and for keeping
the layer tree in sync with the render object tree.
The goal is to get the layer tree fully constructed and correct
(with lots of testing) before actually switching over to it for
painting.
This change requires a clean of WebCore.
* force-clean-timestamp:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
(RenderBox::~RenderBox):
(RenderBox::setPos):
(RenderBox::positionChildLayers):
* khtml/rendering/render_box.h:
* khtml/rendering/render_container.cpp:
(RenderContainer::~RenderContainer):
(RenderContainer::addChild):
(RenderContainer::removeChildNode):
* khtml/rendering/render_container.h:
* khtml/rendering/render_html.cpp:
(RenderHtml::RenderHtml):
* khtml/rendering/render_layer.cpp:
(RenderLayer::updateLayerPosition):
* khtml/rendering/render_layer.h:
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::RenderRoot):
=== Alexander-21 ===
2002-08-28 David Hyatt <hyatt@apple.com>
......
2002-08-29 David Hyatt <hyatt@apple.com>
Begin connecting the layer system. The root box and the <html>
box now construct layers for themselves. Those layers are
connected in a layer tree properly and they correctly update
their positions.
Implemented all the code for layer construction and for keeping
the layer tree in sync with the render object tree.
The goal is to get the layer tree fully constructed and correct
(with lots of testing) before actually switching over to it for
painting.
This change requires a clean of WebCore.
* force-clean-timestamp:
* khtml/rendering/render_box.cpp:
(RenderBox::RenderBox):
(RenderBox::~RenderBox):
(RenderBox::setPos):
(RenderBox::positionChildLayers):
* khtml/rendering/render_box.h:
* khtml/rendering/render_container.cpp:
(RenderContainer::~RenderContainer):
(RenderContainer::addChild):
(RenderContainer::removeChildNode):
* khtml/rendering/render_container.h:
* khtml/rendering/render_html.cpp:
(RenderHtml::RenderHtml):
* khtml/rendering/render_layer.cpp:
(RenderLayer::updateLayerPosition):
* khtml/rendering/render_layer.h:
* khtml/rendering/render_object.h:
* khtml/rendering/render_root.cpp:
(RenderRoot::RenderRoot):
=== Alexander-21 ===
2002-08-28 David Hyatt <hyatt@apple.com>
......
KHTML change 8/27
KHTML change 8/29
......@@ -57,6 +57,7 @@ RenderBox::RenderBox(DOM::NodeImpl* node)
m_marginLeft = 0;
m_marginRight = 0;
m_layer = 0;
m_hasChildLayers = false;
}
void RenderBox::setStyle(RenderStyle *_style)
......@@ -88,6 +89,7 @@ void RenderBox::setStyle(RenderStyle *_style)
RenderBox::~RenderBox()
{
//kdDebug( 6040 ) << "Element destructor: this=" << nodeName().string() << endl;
delete m_layer;
}
short RenderBox::contentWidth() const
......@@ -111,7 +113,26 @@ int RenderBox::contentHeight() const
void RenderBox::setPos( int xPos, int yPos )
{
if (xPos == m_x && yPos == m_y)
return; // Optimize for the case where we don't move at all.
m_x = xPos; m_y = yPos;
if (m_layer)
m_layer->updateLayerPosition();
else if (m_hasChildLayers)
// We don't have a layer, but we have children whose positions need to
// be updated. Crawl into our frame tree, find those views, and
// reposition the children.
positionChildLayers();
}
void RenderBox::positionChildLayers()
{
if (m_layer)
m_layer->updateLayerPosition();
else
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
curr->positionChildLayers();
}
short RenderBox::width() const
......
......@@ -25,10 +25,10 @@
#include "render_container.h"
#include "misc/loader.h"
#include "render_layer.h"
namespace khtml {
class CachedObject;
class RenderLayer;
class RenderBox : public RenderContainer
{
......@@ -69,8 +69,8 @@ public:
virtual short marginLeft() const { return m_marginLeft; }
virtual short marginRight() const { return m_marginRight; }
virtual void setWidth( int width ) { m_width = width; }
virtual void setHeight( int height ) { m_height = height; }
virtual void setWidth( int width ) { m_width = width; if (m_layer) m_layer->setWidth(width); }
virtual void setHeight( int height ) { m_height = height; if (m_layer) m_layer->setHeight(height); }
// This method is now public so that centered objects like tables that are
// shifted right by left-aligned floats can recompute their left and
......@@ -101,8 +101,19 @@ public:
void relativePositionOffset(int &tx, int &ty);
RenderLayer* layer() { return m_layer; }
virtual RenderLayer* layer() const { return m_layer; }
virtual bool hasChildLayers() const { return m_hasChildLayers; }
virtual void setHasChildLayers(bool hasLayers) {
if (m_hasChildLayers == hasLayers)
return;
m_hasChildLayers = hasLayers;
if (parent() && hasLayers)
parent()->setHasChildLayers(hasLayers);
}
virtual void positionChildLayers();
protected:
virtual void printBoxDecorations(QPainter *p,int _x, int _y,
int _w, int _h, int _tx, int _ty);
......@@ -144,6 +155,7 @@ protected:
// A pointer to our layer if we have one. Currently only positioned elements
// and floaters have layers.
RenderLayer* m_layer;
bool m_hasChildLayers : 1;
};
......
......@@ -47,7 +47,7 @@ RenderContainer::~RenderContainer()
{
RenderObject* next;
for(RenderObject* n = m_first; n; n = next ) {
n->removeFromSpecialObjects();
n->removeFromSpecialObjects();
n->setParent(0);
next = n->nextSibling();
n->detach();
......@@ -134,12 +134,25 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
}
newChild->setLayouted( false );
newChild->setMinMaxKnown( false );
// Keep our layer hierarchy updated.
if (newChild->layer()) {
RenderObject* ancestor = (newChild->isPositioned()) ? newChild->containingBlock() : this;
ancestor->enclosingLayer()->addChild(newChild->layer());
ancestor->setHasChildLayers(true);
}
}
RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
{
KHTMLAssert(oldChild->parent() == this);
// Keep our layer hierarchy updated.
if (oldChild->layer()) {
RenderObject* ancestor = (oldChild->isPositioned()) ? oldChild->containingBlock() : this;
ancestor->enclosingLayer()->removeChild(oldChild->layer());
}
// if oldChild is the start or end of the selection, then clear the selection to
// avoid problems of invalid pointers
......@@ -176,6 +189,7 @@ RenderObject* RenderContainer::removeChildNode(RenderObject* oldChild)
setLayouted( false );
setMinMaxKnown( false );
return oldChild;
}
......
......@@ -51,6 +51,15 @@ public:
virtual void calcMinMaxWidth() { setMinMaxKnown( true ); }
virtual void removeLeftoverAnonymousBoxes();
virtual RenderLayer* enclosingLayer() {
RenderObject* curr = this;
while (curr) {
if (curr->layer()) return curr->layer();
curr = curr->parent();
}
return 0;
}
private:
......
......@@ -32,6 +32,7 @@ using namespace khtml;
RenderHtml::RenderHtml(DOM::HTMLElementImpl* node)
: RenderFlow(node)
{
m_layer = new RenderLayer(this);
}
RenderHtml::~RenderHtml()
......
......@@ -49,6 +49,20 @@ RenderLayer::~RenderLayer()
// our destructor doesn't have to do anything.
}
void RenderLayer::updateLayerPosition()
{
int x = m_object->xPos();
int y = m_object->yPos();
RenderObject* curr = m_object->parent();
while (curr && !curr->layer()) {
x += curr->xPos();
y += curr->yPos();
}
setPos(x,y);
}
void RenderLayer::addChild(RenderLayer *child, RenderLayer *beforeChild)
{
if (!beforeChild)
......
......@@ -67,7 +67,8 @@ public:
void setHeight( int height ) { m_height = height; }
void setPos( int xPos, int yPos ) { m_x = xPos; m_y = yPos; }
void updateLayerPosition();
void convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y);
bool hasAutoZIndex() { return renderer()->style()->hasAutoZIndex(); }
......
......@@ -65,6 +65,7 @@ namespace khtml {
class RenderRoot;
class RenderText;
class RenderFrameSet;
class RenderLayer;
/**
* Base Class for all rendering tree objects.
......@@ -84,6 +85,12 @@ public:
virtual RenderObject *firstChild() const { return 0; }
virtual RenderObject *lastChild() const { return 0; }
virtual RenderLayer* layer() const { return 0; }
virtual RenderLayer* enclosingLayer() { return 0; }
virtual bool hasChildLayers() const { return false; }
virtual void setHasChildLayers(bool hasLayers) { }
virtual void positionChildLayers() { }
// RenderObject tree manipulation
//////////////////////////////////////////
virtual void addChild(RenderObject *newChild, RenderObject *beforeChild = 0);
......@@ -171,25 +178,26 @@ public:
void closeEntireTree() {
RenderObject *child = firstChild();
while (child) {
child->closeEntireTree();
child = child->nextSibling();
child->closeEntireTree();
child = child->nextSibling();
}
close();
}
void setLayouted(bool b=true) {
m_layouted = b;
if(!b) {
RenderObject *o = m_parent;
RenderObject *root = this;
while( o ) {
o->m_layouted = false;
root = o;
o = o->m_parent;
}
root->scheduleRelayout();
}
m_layouted = b;
if(!b) {
RenderObject *o = m_parent;
RenderObject *root = this;
while( o ) {
o->m_layouted = false;
root = o;
o = o->m_parent;
}
root->scheduleRelayout();
}
}
// hack to block inline layouts during parsing
// evil, evil. I didn't do it. <tm>
virtual void setBlockBidi() {}
......
......@@ -19,7 +19,7 @@
* Boston, MA 02111-1307, USA.
*/
#include "rendering/render_root.h"
#include "render_layer.h"
#include "khtmlview.h"
#include <kdebug.h>
......@@ -60,6 +60,9 @@ RenderRoot::RenderRoot(DOM::NodeImpl* node, KHTMLView *view)
m_selectionEnd = 0;
m_selectionStartPos = -1;
m_selectionEndPos = -1;
// Create a new root layer for our layer hierarchy.
m_layer = new RenderLayer(this);
}
RenderRoot::~RenderRoot()
......
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