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

📄 renderobject.h

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (C) 2000 Lars Knoll (knoll@kde.org) *           (C) 2000 Antti Koivisto (koivisto@kde.org) *           (C) 2000 Dirk Mueller (mueller@kde.org) *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. * * 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 RenderObject_h#define RenderObject_h#include "CachedResourceClient.h"#include "FloatQuad.h"#include "Document.h"#include "RenderObjectChildList.h"#include "RenderStyle.h"#include "TransformationMatrix.h"namespace WebCore {class AnimationController;class HitTestResult;class InlineBox;class InlineFlowBox;class RenderBoxModelObject;class RenderInline;class RenderBlock;class RenderFlow;class RenderLayer;class TransformState;class VisiblePosition;/* *  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. */enum PaintPhase {    PaintPhaseBlockBackground,    PaintPhaseChildBlockBackground,    PaintPhaseChildBlockBackgrounds,    PaintPhaseFloat,    PaintPhaseForeground,    PaintPhaseOutline,    PaintPhaseChildOutlines,    PaintPhaseSelfOutline,    PaintPhaseSelection,    PaintPhaseCollapsedTableBorders,    PaintPhaseTextClip,    PaintPhaseMask};enum PaintRestriction {    PaintRestrictionNone,    PaintRestrictionSelectionOnly,    PaintRestrictionSelectionOnlyBlackText};enum HitTestFilter {    HitTestAll,    HitTestSelf,    HitTestDescendants};enum HitTestAction {    HitTestBlockBackground,    HitTestChildBlockBackground,    HitTestChildBlockBackgrounds,    HitTestFloat,    HitTestForeground};// Sides used when drawing borders and outlines.  This is in RenderObject rather than RenderBoxModelObject since outlines can// be drawn by SVG around bounding boxes.enum BoxSide {    BSTop,    BSBottom,    BSLeft,    BSRight};const int caretWidth = 1;#if ENABLE(DASHBOARD_SUPPORT)struct DashboardRegionValue {    bool operator==(const DashboardRegionValue& o) const    {        return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;    }    bool operator!=(const DashboardRegionValue& o) const    {        return !(*this == o);    }    String label;    IntRect bounds;    IntRect clip;    int type;};#endif// Base class for all rendering tree objects.class RenderObject : public CachedResourceClient {    friend class RenderBlock;    friend class RenderBox;    friend class RenderLayer;    friend class RenderObjectChildList;    friend class RenderSVGContainer;public:    // Anonymous objects should pass the document as their node, and they will then automatically be    // marked as anonymous in the constructor.    RenderObject(Node*);    virtual ~RenderObject();    virtual const char* renderName() const = 0;    RenderObject* parent() const { return m_parent; }    bool isDescendantOf(const RenderObject*) const;    RenderObject* previousSibling() const { return m_previous; }    RenderObject* nextSibling() const { return m_next; }    RenderObject* firstChild() const    {        if (const RenderObjectChildList* children = virtualChildren())            return children->firstChild();        return 0;    }    RenderObject* lastChild() const    {        if (const RenderObjectChildList* children = virtualChildren())            return children->lastChild();        return 0;    }    virtual RenderObjectChildList* virtualChildren() { return 0; }    virtual const RenderObjectChildList* virtualChildren() const { return 0; }    RenderObject* nextInPreOrder() const;    RenderObject* nextInPreOrder(RenderObject* stayWithin) const;    RenderObject* nextInPreOrderAfterChildren() const;    RenderObject* nextInPreOrderAfterChildren(RenderObject* stayWithin) const;    RenderObject* previousInPreOrder() const;    RenderObject* childAt(unsigned) const;    RenderObject* firstLeafChild() const;    RenderObject* lastLeafChild() const;    // The following five functions are used when the render tree hierarchy changes to make sure layers get    // properly added and removed.  Since containership can be implemented by any subclass, and since a hierarchy    // can contain a mixture of boxes and other object types, these functions need to be in the base class.    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);    // Convenience function for getting to the nearest enclosing box of a RenderObject.    RenderBox* enclosingBox() const;        virtual bool isEmpty() const { return firstChild() == 0; }#ifndef NDEBUG    void setHasAXObject(bool flag) { m_hasAXObject = flag; }    bool hasAXObject() const { return m_hasAXObject; }    bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }    void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }#endif    // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline    // children.    virtual RenderBlock* firstLineBlock() const;    // Called when an object that was floating or positioned becomes a normal flow object    // again.  We have to make sure the render tree updates as needed to accommodate the new    // normal flow object.    void handleDynamicFloatPositionChange();        // RenderObject tree manipulation    //////////////////////////////////////////    virtual bool canHaveChildren() const { return virtualChildren(); }    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }    virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);    virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }    virtual void removeChild(RenderObject*);    virtual bool createsAnonymousWrapper() const { return false; }    //////////////////////////////////////////protected:    //////////////////////////////////////////    // 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; }    //////////////////////////////////////////private:    void addAbsoluteRectForLayer(IntRect& result);    void setLayerNeedsFullRepaint();public:#ifndef NDEBUG    void showTreeForThis() const;#endif    static RenderObject* createObject(Node*, RenderStyle*);    // Overloaded new operator.  Derived classes must override operator new    // in order to allocate out of the RenderArena.    void* operator new(size_t, RenderArena*) throw();    // Overridden to prevent the normal delete from being called.    void operator delete(void*, size_t);private:    // The normal operator new is disallowed on all render objects.    void* operator new(size_t) throw();public:    RenderArena* renderArena() const { return document()->renderArena(); }    virtual bool isApplet() const { return false; }    virtual bool isBR() const { return false; }    virtual bool isBlockFlow() const { return false; }    virtual bool isBoxModelObject() const { return false; }    virtual bool isCounter() const { return false; }    virtual bool isFieldset() const { return false; }    virtual bool isFrame() const { return false; }    virtual bool isFrameSet() const { return false; }    virtual bool isImage() const { return false; }    virtual bool isInlineBlockOrInlineTable() const { return false; }    virtual bool isListBox() const { return false; }    virtual bool isListItem() const { return false; }    virtual bool isListMarker() const { return false; }    virtual bool isMedia() const { return false; }    virtual bool isMenuList() const { return false; }    virtual bool isRenderBlock() const { return false; }    virtual bool isRenderButton() const { return false; }    virtual bool isRenderImage() const { return false; }    virtual bool isRenderInline() const { return false; }    virtual bool isRenderPart() const { return false; }    virtual bool isRenderView() const { return false; }    virtual bool isSlider() const { return false; }    virtual bool isTable() const { return false; }    virtual bool isTableCell() const { return false; }    virtual bool isTableCol() const { return false; }    virtual bool isTableRow() const { return false; }    virtual bool isTableSection() const { return false; }    virtual bool isTextControl() const { return false; }    virtual bool isTextArea() const { return false; }    virtual bool isTextField() const { return false; }    virtual bool isWidget() const { return false; }    bool isRoot() const { return document()->documentElement() == m_node; }    bool isBody() const;    bool isHR() const;    bool isHTMLMarquee() const;    bool childrenInline() const { return m_childrenInline; }    void setChildrenInline(bool b = true) { m_childrenInline = b; }    bool hasColumns() const { return m_hasColumns; }    void setHasColumns(bool b = true) { m_hasColumns = b; }    bool cellWidthChanged() const { return m_cellWidthChanged; }    void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; }#if ENABLE(SVG)    virtual bool isSVGRoot() const { return false; }    virtual bool isSVGContainer() const { return false; }    virtual bool isSVGHiddenContainer() const { return false; }    virtual bool isRenderPath() const { return false; }    virtual bool isSVGText() const { return false; }    virtual FloatRect relativeBBox(bool includeStroke = true) const;    virtual TransformationMatrix localTransform() const;    virtual TransformationMatrix absoluteTransform() const;#endif    bool isAnonymous() const { return m_isAnonymous; }    void setIsAnonymous(bool b) { m_isAnonymous = b; }    bool isAnonymousBlock() const    {        return m_isAnonymous && style()->display() == BLOCK && style()->styleType() == NOPSEUDO && !isListMarker();    }    bool isInlineContinuation() const { return (node() ? node()->renderer() != this : false) && isRenderInline(); }    bool isFloating() const { return m_floating; }    bool isPositioned() const { return m_positioned; } // absolute or fixed positioning    bool isRelPositioned() const { return m_relPositioned; } // relative positioning

⌨️ 快捷键说明

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