⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render_object.h

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * This file is part of the html renderer for KDE. * * Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org) *           (C) 2000 Antti Koivisto (koivisto@kde.org) *           (C) 2000-2003 Dirk Mueller (mueller@kde.org) *           (C) 2002-2003 Apple Computer, Inc. *           (C) 2004 Allan Sandfeld Jensen * * 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., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */#ifndef render_object_h#define render_object_h#include <qcolor.h>#include <qrect.h>#include <assert.h>#include <qvaluelist.h>#include <kdebug.h>#include <kglobal.h>#include "xml/dom_docimpl.h"#include "misc/khtmllayout.h"#include "misc/loader_client.h"#include "misc/helper.h"#include "rendering/render_style.h"class QPainter;class QTextStream;class CSSStyle;class KHTMLView;#ifndef NDEBUG#define KHTMLAssert( x ) if( !(x) ) { \    const RenderObject *o = this; while( o->parent() ) o = o->parent(); \    o->printTree(); \    qDebug(" this object = %p, %s", (void*) this, kdBacktrace().latin1() ); \    assert( x ); \}#else#define KHTMLAssert( x )#endif/* *	The painting of a layer occurs in three distinct phases.  Each phase involves *	a recursive descent into the layer's render objects. The first phase is the background phase. *	The backgrounds and borders of all blocks are painted.  Inlines are not painted at all. *	Floats must paint above block backgrounds but entirely below inline content that can overlap them. *	In the foreground phase, all inlines are fully painted.  Inline replaced elements will get all *	three phases invoked on them during this phase. */typedef enum {    PaintActionElementBackground = 0,    PaintActionChildBackground,    PaintActionChildBackgrounds,    PaintActionFloat,    PaintActionForeground,    PaintActionOutline,    PaintActionSelection,    PaintActionCollapsedTableBorders} PaintAction;typedef enum {    HitTestAll = 0,    HitTestSelfOnly = 1,    HitTestChildrenOnly = 2} HitTestAction;typedef enum {    PageBreakNormal = 0, // all rules apply    PageBreakHarder = 1, // page-break-inside: avoid is ignored    PageBreakForced = 2  // page-break-after/before: avoid, orphans and widows ignored} PageBreakLevel;inline PageBreakLevel operator| (PageBreakLevel a, PageBreakLevel b) {    if (a == PageBreakForced || b == PageBreakForced)        return PageBreakForced;    if (a == PageBreakHarder || b == PageBreakHarder)        return PageBreakHarder;    return PageBreakNormal;}namespace DOM {    class HTMLAreaElementImpl;    class DOMString;    class NodeImpl;    class DocumentImpl;    class ElementImpl;    class EventImpl;}namespace khtml {    class RenderFlow;    class RenderStyle;    class RenderTable;    class CachedObject;    class RenderObject;    class RenderCanvas;    class RenderText;    class RenderFrameSet;    class RenderArena;    class RenderLayer;    class RenderBlock;    class InlineBox;    class InlineFlowBox;    class CounterNode;/** * Base Class for all rendering tree objects. */class RenderObject : public CachedObjectClient{    RenderObject(const RenderObject&);    RenderObject& operator=(const RenderObject&);public:    RenderObject(DOM::NodeImpl* node);    virtual ~RenderObject();    RenderObject *parent() const { return m_parent; }    RenderObject *previousSibling() const { return m_previous; }    RenderObject *nextSibling() const { return m_next; }    virtual RenderObject *firstChild() const { return 0; }    virtual RenderObject *lastChild() const { return 0; }    virtual bool childAllowed() const { return false; }    virtual RenderLayer* layer() const { return 0; }    RenderLayer* enclosingLayer() const;    void addLayers(RenderLayer* parentLayer, RenderObject* newObject);    void removeLayers(RenderLayer* parentLayer);    void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);    RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint,                               bool checkParent=true);    virtual void positionChildLayers() { }    virtual bool requiresLayer() const {        return isRoot() || (!isTableCell() && (isPositioned() || isRelPositioned() || hasOverflowClip()));    }    // ### rename to overflowClipRect and clipRect    virtual QRect getOverflowClipRect(int /*tx*/, int /*ty*/)	{ return QRect(0,0,0,0); }    virtual QRect getClipRect(int /*tx*/, int /*ty*/) { return QRect(0,0,0,0); }    bool hasClip() const { return isPositioned() &&  style()->hasClip(); }    bool hasOverflowClip() const { return style()->hidesOverflow(); }    virtual int getBaselineOfFirstLineBox() { return -1; } // Tables and blocks implement this.    virtual InlineFlowBox* getFirstLineBox() { return 0; } // Tables and blocks implement this.    // Whether or not a positioned element requires normal flow x/y to be computed    // to determine its position.    bool hasStaticX() const;    bool hasStaticY() const;    // Linear tree traversal    RenderObject *objectBelow() const;    RenderObject *objectAbove() const;    // Returns if an object has counter-increment or counter-reset    bool hasCounter(const QString& counter) const;    // Calculates the value of the counter    CounterNode* getCounter(const QString& counter, bool view = false, bool counters = false);    // Detaches all counterNodes    void detachCounters();protected:    // Helper functions for counter-cache    void insertCounter(const QString& counter, CounterNode* value);    CounterNode* lookupCounter(const QString& counter) const;public:    //////////////////////////////////////////    // RenderObject tree manipulation    virtual void addChild(RenderObject *newChild, RenderObject *beforeChild = 0);    void removeChild(RenderObject *oldChild);    // raw tree manipulation    virtual RenderObject* removeChildNode(RenderObject* child);    virtual void appendChildNode(RenderObject* child);    virtual void insertChildNode(RenderObject* child, RenderObject* before);    //////////////////////////////////////////    //////////////////////////////////////////    // Helper functions. Dangerous to use!    void setPreviousSibling(RenderObject *previous) { m_previous = previous; }    void setNextSibling(RenderObject *next) { m_next = next; }    void setParent(RenderObject *parent) { m_parent = parent; }    //////////////////////////////////////////public:    virtual const char *renderName() const { return "RenderObject"; }#ifdef ENABLE_DUMP    QString information() const;    virtual void printTree(int indent=0) const;    virtual void dump(QTextStream &stream, const QString &ind = QString::null) const;#endif    static RenderObject *createObject(DOM::NodeImpl* node, RenderStyle* style);    // Overloaded new operator.  Derived classes must override operator new    // in order to allocate out of the RenderArena.    void* operator new(size_t sz, RenderArena* renderArena) throw();    // Overridden to prevent the normal delete from being called.    void operator delete(void* ptr, size_t sz);private:    // The normal operator new is disallowed on all render objects.    void* operator new(size_t sz);public:    RenderArena* renderArena() const;    virtual RenderFlow* continuation() const { return 0; }    virtual bool isInlineContinuation() const { return false; }    bool isRoot() const { return m_isRoot && !m_isAnonymous; }    void setIsRoot(bool b) { m_isRoot = b; }    bool isHR() const;    // some helper functions...    virtual bool isRenderBlock() const { return false; }    virtual bool isRenderInline() const { return false; }    virtual bool isInlineFlow() const { return false; }    virtual bool isBlockFlow() const { return false; }    virtual bool isInlineBlockOrInlineTable() const { return false; }    virtual bool childrenInline() const { return false; }    virtual bool isBox() const { return false; }    virtual bool isRenderReplaced() const { return false; }    virtual bool isCounter() const { return false; }    virtual bool isQuote() const { return false; }    virtual bool isListItem() const { return false; }    virtual bool isListMarker() const { return false; }    virtual bool isCanvas() const { return false; }    virtual bool isBR() const { return false; }    virtual bool isTableCell() const { return false; }    virtual bool isTableRow() const { return false; }    virtual bool isTableSection() const { return false; }    virtual bool isTableCol() const { return false; }    virtual bool isTable() const { return false; }    virtual bool isWidget() const { return false; }    virtual bool isBody() const { return false; }    virtual bool isFormElement() const { return false; }    virtual bool isFrameSet() const { return false; }    virtual bool isApplet() const { return false; }    bool isHTMLMarquee() const;    bool isAnonymous() const { return m_isAnonymous; }    void setIsAnonymous(bool b) { m_isAnonymous = b; }    bool isAnonymousBlock() const { return isAnonymous() && style()->display() == BLOCK && node()->isDocumentNode(); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -