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

📄 render_style.h

📁 monqueror一个很具有参考价值的源玛
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * This file is part of the DOM implementation for KDE. * * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) * * 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. * * $Id: render_style.h,v 1.1.1.1 2002/01/16 10:39:56 ymwei Exp $ */#ifndef RENDERSTYLE_H#define RENDERSTYLE_H#include "render_interface.h"#include "mgcolor.h"#include "mgfont.h"#include "khtmllayout.h"#define SET_VAR(group,variable,value) \    if (group->variable != value) \        group.access()->variable = value;namespace khtml {    class MGCachedImage;template <class DATA>class DataRef{public:    DataRef()    {	data=0;    }    virtual ~DataRef()    {    	if(data) data->deref();    }    const DATA* operator->() const    {    	    	return data;    }        const DATA* get() const    {    	    	return data;    }    DATA* access()    {    	    	if (!data->hasOneRef())	{	    data->deref();	    data = new DATA(*data);	    data->ref();	}	return data;    }    void init()    {    	if (data)    	    data->deref();    	data = new DATA;	data->ref();    }    DataRef<DATA>& operator=(const DataRef<DATA>& d)    {    	if (data==d.data)	    return *this;    	if (data)    	    data->deref();    	data = d.data;	data->ref();		return *this;    }private:    DATA* data;};class SharedData{public:    SharedData() { _ref=0; counter++; }    virtual ~SharedData() { counter--; }    void ref() { _ref++;  }    void deref() { if(_ref) _ref--; if(_ref<=0) delete this; }    bool hasOneRef() { //kdDebug(300) << "ref=" << _ref << endl;    	return _ref==1; }    static int counter;protected:    unsigned int _ref;};//------------------------------------------------//------------------------------------------------// Box model attributes. Not inherited.struct LengthBox{    LengthBox()    {    }    Length left;    Length right;    Length top;    Length bottom;    Length& operator=(Length& len)    {    	left=len;	right=len;	top=len;	bottom=len;	return len;    }    bool operator==(const LengthBox& o) const    {    	return left==o.left && right==o.right && top==o.top && bottom==o.bottom;    }    bool nonZero() const { return left.value!=0 || right.value!=0 || top.value!=0 || bottom.value!=0; }};enum EPosition {    STATIC, RELATIVE, ABSOLUTE, FIXED};enum EFloat {    FNONE, FLEFT, FRIGHT};//------------------------------------------------// Border attributes. Not inherited.enum EBorderStyle {    BNONE, BHIDDEN, DOTTED, DASHED, SOLID, DOUBLE,    GROOVE, RIDGE, INSET, OUTSET};class BorderValue{public:    BorderValue()    {	width = 3; // medium is default value	style = BNONE;    }    unsigned short width;    MGColor color;    EBorderStyle style : 4;    bool nonZero() const { return width!=0 && style!=BNONE; }    bool operator==(const BorderValue& o) const    {    	return width==o.width && style==o.style && color==o.color;    }};class BorderData : public SharedData{public:    BorderValue left;    BorderValue right;    BorderValue top;    BorderValue bottom;    bool hasBorder() const    {    	return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();	    }    bool operator==(const BorderData& o) const    {    	return left==o.left && right==o.right && top==o.top && bottom==o.bottom;    }};class StyleSurroundData : public SharedData{public:    StyleSurroundData();    virtual ~StyleSurroundData()    {    }    StyleSurroundData(const StyleSurroundData& o );    bool operator==(const StyleSurroundData& o) const;    LengthBox offset;    LengthBox margin;    LengthBox padding;    BorderData border;};//------------------------------------------------// Box attributes. Not inherited.const int ZAUTO=0;class StyleBoxData : public SharedData{public:    StyleBoxData();    StyleBoxData(const StyleBoxData& o );    // copy and assignment//    StyleBoxData(const StyleBoxData &other);//    const StyleBoxData &operator = (const StyleBoxData &other);    void setDefaultValues()    {    	z_index = ZAUTO;    }    bool operator==(const StyleBoxData& o) const;    Length width;    Length height;    Length min_width;    Length max_width;    Length min_height;    Length max_height;    int z_index;};//------------------------------------------------// Random visual rendering model attributes. Not inherited.enum EOverflow {    OVISIBLE, OHIDDEN, SCROLL, AUTO};enum EVerticalAlign {    BASELINE, SUB, SUPER, TOP, TEXT_TOP, MIDDLE,    BOTTOM, TEXT_BOTTOM};enum EClear{    CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3};enum ETableLayout {    TAUTO, TFIXED};class StyleVisualData : public SharedData{public:    StyleVisualData()    {	colspan = 1;    }    virtual ~StyleVisualData() {    }    StyleVisualData(const StyleVisualData& o ) : SharedData()    {    	clip = o.clip;	colspan = o.colspan;	counter_increment = o.counter_increment;	counter_reset = o.counter_reset;    }    bool operator==(const StyleVisualData& o) const    {    	return	    clip == o.clip &&	    colspan == o.colspan &&	    counter_increment == o.counter_increment &&	    counter_reset == o.counter_reset;    }    LengthBox clip;    short colspan; // for html, not a css2 attribute    short counter_increment; //ok, so these are not visual mode spesific    short counter_reset;     //can't go to inherited, since these are not inherited};//------------------------------------------------enum EBackgroundRepeat {    REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT};class StyleBackgroundData : public SharedData{public:    StyleBackgroundData()    {	image = 0;    }    virtual ~StyleBackgroundData()    {    }    StyleBackgroundData(const StyleBackgroundData& o ) : SharedData()    {    	color = o.color;	image = o.image;	x_position = o.x_position;	y_position = o.y_position;    }    bool operator==(const StyleBackgroundData& o) const    {    	return	    color == o.color &&	    image == o.image &&	    x_position == o.x_position &&	    y_position == o.y_position;    }    MGColor color;    MGCachedImage *image;    Length x_position;    Length y_position;};//------------------------------------------------// Inherited attributes.//// the inherited-decoration and inherited-shadow attributes// are inherited from the// first parent which is block level//// this applies to decoration_color tooenum EWhiteSpace {    NORMAL, PRE, NOWRAP};enum ETextAlign{    LEFT, RIGHT, CENTER, JUSTIFY, KONQ_CENTER};enum EDirection{    LTR, RTL};

⌨️ 快捷键说明

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