Commit 1bb17f28 authored by darin's avatar darin

Reviewed by Dave.

	- clean room rewrite of QCString::operator<<.

        * kwq/KWQCString.mm: (operator<<): Rewrote it.

	- update format of render tree dumping for real use

        * khtml/rendering/render_layer.h: Added elementList().
        * khtml/rendering/render_layer.cpp: (RenderLayer::elementList): Added.

        * kwq/KWQRenderTreeDebug.cpp:
        (operator<<): Added an overload for writing out QRect.
        (writeIndent): Added.
        (write): Use the overload for QRect, also reorganize to dump layers.
        (writeLayers): Use this to dump the layers.
        (externalRepresentation): Call writeLayers instead of write.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d3ed1c91
2003-01-17 Darin Adler <darin@apple.com>
Reviewed by Dave.
- clean room rewrite of QCString::operator<<.
* kwq/KWQCString.mm: (operator<<): Rewrote it.
- update format of render tree dumping for real use
* khtml/rendering/render_layer.h: Added elementList().
* khtml/rendering/render_layer.cpp: (RenderLayer::elementList): Added.
* kwq/KWQRenderTreeDebug.cpp:
(operator<<): Added an overload for writing out QRect.
(writeIndent): Added.
(write): Use the overload for QRect, also reorganize to dump layers.
(writeLayers): Use this to dump the layers.
(externalRepresentation): Call writeLayers instead of write.
2003-01-17 Darin Adler <darin@apple.com>
Reviewed by Ken.
......
2003-01-17 Darin Adler <darin@apple.com>
Reviewed by Dave.
- clean room rewrite of QCString::operator<<.
* kwq/KWQCString.mm: (operator<<): Rewrote it.
- update format of render tree dumping for real use
* khtml/rendering/render_layer.h: Added elementList().
* khtml/rendering/render_layer.cpp: (RenderLayer::elementList): Added.
* kwq/KWQRenderTreeDebug.cpp:
(operator<<): Added an overload for writing out QRect.
(writeIndent): Added.
(write): Use the overload for QRect, also reorganize to dump layers.
(writeLayers): Use this to dump the layers.
(externalRepresentation): Call writeLayers instead of write.
2003-01-17 Darin Adler <darin@apple.com>
Reviewed by Ken.
......
/*
* Copyright (C) 2002 Apple Computer, Inc.
* Copyright (C) 2002, 2003 Apple Computer, Inc.
*
* Portions are Copyright (C) 1998 Netscape Communications Corporation.
*
......@@ -213,13 +213,13 @@ void
RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
{
// Create the z-tree of layers that should be displayed.
QRect damageRect = QRect(x,y,w,h);
RenderLayer::RenderZTreeNode* node = constructZTree(damageRect, damageRect, this);
QRect damageRect(x,y,w,h);
RenderZTreeNode* node = constructZTree(damageRect, damageRect, this);
if (!node)
return;
// Flatten the tree into a back-to-front list for painting.
QPtrVector<RenderLayer::RenderLayerElement> layerList;
QPtrVector<RenderLayerElement> layerList;
constructLayerList(node, &layerList);
// Walk the list and paint each layer, adding in the appropriate offset.
......@@ -228,7 +228,7 @@ RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
uint count = layerList.count();
for (uint i = 0; i < count; i++) {
RenderLayer::RenderLayerElement* elt = layerList.at(i);
RenderLayerElement* elt = layerList.at(i);
// Elements add in their own positions as a translation factor. This forces
// us to subtract that out, so that when it's added back in, we get the right
......@@ -319,18 +319,18 @@ RenderLayer::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y)
{
bool inside = false;
QRect damageRect(m_x, m_y, m_width, m_height);
RenderLayer::RenderZTreeNode* node = constructZTree(damageRect, damageRect, this, true, x, y);
RenderZTreeNode* node = constructZTree(damageRect, damageRect, this, true, x, y);
if (!node)
return false;
// Flatten the tree into a back-to-front list for painting.
QPtrVector<RenderLayer::RenderLayerElement> layerList;
QPtrVector<RenderLayerElement> layerList;
constructLayerList(node, &layerList);
// Walk the list and test each layer, adding in the appropriate offset.
uint count = layerList.count();
for (int i = count-1; i >= 0; i--) {
RenderLayer::RenderLayerElement* elt = layerList.at(i);
RenderLayerElement* elt = layerList.at(i);
// Elements add in their own positions as a translation factor. This forces
// us to subtract that out, so that when it's added back in, we get the right
......@@ -358,7 +358,7 @@ RenderLayer::constructZTree(QRect overflowClipRect, QRect posClipRect,
RenderArena* renderArena = renderer()->renderArena();
// This variable stores the result we will hand back.
RenderLayer::RenderZTreeNode* returnNode = 0;
RenderZTreeNode* returnNode = 0;
// If a layer isn't visible, then none of its child layers are visible either.
// Don't build this branch of the z-tree, since these layers should not be painted.
......@@ -488,10 +488,10 @@ RenderLayer::constructZTree(QRect overflowClipRect, QRect posClipRect,
}
void
RenderLayer::constructLayerList(RenderZTreeNode* ztree, QPtrVector<RenderLayer::RenderLayerElement>* result)
RenderLayer::constructLayerList(RenderZTreeNode* ztree, QPtrVector<RenderLayerElement>* result)
{
// This merge buffer is just a temporary used during computation as we do merge sorting.
QPtrVector<RenderLayer::RenderLayerElement> mergeBuffer;
QPtrVector<RenderLayerElement> mergeBuffer;
ztree->constructLayerList(&mergeBuffer, result);
}
......@@ -602,7 +602,7 @@ void RenderLayer::RenderZTreeNode::constructLayerList(QPtrVector<RenderLayerElem
// Now set all of the elements' z-indices to match the parent's explicit z-index, so that
// they will be layered properly in the ancestor layer's stacking context.
for (uint i = startIndex; i < endIndex; i++) {
RenderLayer::RenderLayerElement* elt = buffer->at(i);
RenderLayerElement* elt = buffer->at(i);
elt->zindex = explicitZIndex;
}
}
......@@ -674,3 +674,16 @@ void RenderLayer::RenderZTreeNode::detach(RenderArena* renderArena)
renderArena->free(*(size_t *)this, this);
}
QPtrVector<RenderLayer::RenderLayerElement> RenderLayer::elementList()
{
QPtrVector<RenderLayerElement> list;
QRect damageRect(m_x, m_y, m_width, m_height);
RenderZTreeNode *node = constructZTree(damageRect, damageRect, this);
if (node) {
constructLayerList(node, &list);
node->detach(renderer()->renderArena());
}
return list;
}
/*
* Copyright (C) 2002 Apple Computer, Inc.
* Copyright (C) 2002, 2003 Apple Computer, Inc.
*
* Portions are Copyright (C) 1998 Netscape Communications Corporation.
*
......@@ -231,6 +231,9 @@ public:
// The normal operator new is disallowed.
void* operator new(size_t sz) throw();
};
// For debugging.
QPtrVector<RenderLayerElement> elementList();
private:
// The constructZTree function creates a z-tree for a given layer hierarchy
......
/*
* Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2001, 2002, 2003 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,6 +27,8 @@
#import <ctype.h>
using std::ostream;
QCString::QCString() : QByteArray(0)
{
}
......@@ -302,8 +304,11 @@ bool operator==(const QCString &s1, const char *s2)
}
#ifdef _KWQ_IOSTREAM_
std::ostream &operator<<(std::ostream &o, const QCString &s)
ostream &operator <<(ostream &o, const QCString &s)
{
return o << (const char *)s.data();
const char *chs = s;
return o << chs;
}
#endif
......@@ -35,32 +35,37 @@
#include "KWQKHTMLPart.h"
#include "KWQTextStream.h"
using khtml::RenderLayer;
using khtml::RenderObject;
using khtml::RenderTableCell;
using khtml::RenderWidget;
typedef khtml::RenderLayer::RenderLayerElement RenderLayerElement;
static void writeLayers(QTextStream &ts, const RenderObject &o, int indent = 0);
static QTextStream &operator<<(QTextStream &ts, const QRect &r)
{
return ts << "(" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ")";
}
static QTextStream &operator<<(QTextStream &ts, const RenderObject &o)
{
ts << o.renderName();
ts << " ";
if (o.isInline()) ts << "il ";
if (o.childrenInline()) ts << "ci ";
if (o.isFloating()) ts << "fl ";
if (o.isAnonymousBox()) ts << "an ";
if (o.isRelPositioned()) ts << "rp ";
if (o.isPositioned()) ts << "ps ";
if (o.overhangingContents()) ts << "oc ";
if (o.layouted()) ts << "lt ";
if (o.mouseInside()) ts << "mi ";
if (o.style() && o.style()->zIndex()) ts << "zI: " << o.style()->zIndex();
if (o.style() && o.style()->zIndex()) {
ts << " zI: " << o.style()->zIndex();
}
if (o.element() && o.element()->active()) ts << "act ";
if (o.element() && o.element()->hasAnchor()) ts << "anchor ";
if (o.element() && o.element()->focused()) ts << "focus ";
if (o.element()) ts << " <" << getTagName(o.element()->id()).string() << ">";
if (o.element()) {
QString tagName(getTagName(o.element()->id()).string());
if (!tagName.isEmpty()) {
ts << " {" << tagName << "}";
}
}
ts << " (" << o.xPos() << "," << o.yPos() << "," << o.width() << "," << o.height() << ")";
QRect r(o.xPos(), o.yPos(), o.width(), o.height());
ts << " " << r;
if (o.isTableCell()) {
const RenderTableCell &c = static_cast<const RenderTableCell &>(o);
......@@ -70,17 +75,23 @@ static QTextStream &operator<<(QTextStream &ts, const RenderObject &o)
return ts;
}
static void write(QTextStream &ts, const RenderObject &o, int indent = 0)
static void writeIndent(QTextStream &ts, int indent)
{
{
QString indentationSpaces;
indentationSpaces.fill(' ', indent * 2);
ts << indentationSpaces;
for (int i = 0; i != indent; ++i) {
ts << " ";
}
}
static void write(QTextStream &ts, const RenderObject &o, int indent = 0)
{
writeIndent(ts, indent);
ts << o << '\n';
ts << o << "\n";
for (RenderObject *child = o.firstChild(); child; child = child->nextSibling()) {
if (child->layer()) {
continue;
}
write(ts, *child, indent + 1);
}
......@@ -89,19 +100,51 @@ static void write(QTextStream &ts, const RenderObject &o, int indent = 0)
if (view) {
RenderObject *root = KWQ(view->part())->renderer();
if (root) {
write(ts, *root, indent + 1);
writeLayers(ts, *root, indent + 1);
}
}
}
}
static void write(QTextStream &ts, const RenderLayerElement &e, int indent = 0)
{
RenderLayer &l = *e.layer;
writeIndent(ts, indent);
ts << "RenderLayer";
QRect r(l.xPos(), l.yPos(), l.width(), l.height());
ts << " " << r;
if (r != r.intersect(e.backgroundClipRect)) {
ts << " backgroundClip" << e.backgroundClipRect;
}
if (r != r.intersect(e.clipRect)) {
ts << " clip" << e.clipRect;
}
ts << "\n";
write(ts, *l.renderer(), indent + 1);
}
static void writeLayers(QTextStream &ts, const RenderObject &o, int indent)
{
QPtrVector<RenderLayerElement> list = o.layer()->elementList();
for (unsigned i = 0; i != list.count(); ++i) {
write(ts, *list[i], indent);
}
}
QString externalRepresentation(const RenderObject *o)
{
QString s;
{
QTextStream ts(&s);
if (o) {
write(ts, *o);
writeLayers(ts, *o);
}
}
return s;
......
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