📄 render_style.h
字号:
/* * This file is part of the DOM implementation 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-2004 Apple Computer, Inc. * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) * * 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 RENDERSTYLE_H#define RENDERSTYLE_H/* * WARNING: * -------- * * The order of the values in the enums have to agree with the order specified * in cssvalues.in, otherwise some optimizations in the parser will fail, * and produce invaliud results. */#include <qcolor.h>#include <qfont.h>#include <qfontmetrics.h>#include <qptrlist.h>#include <qpalette.h>#include <qapplication.h>#include "dom/dom_misc.h"#include "dom/dom_string.h"#include "misc/khtmllayout.h"#include "misc/shared.h"#include "rendering/font.h"#include <assert.h>#define SET_VAR(group,variable,value) \ if (!(group->variable == value)) \ group.access()->variable = value;#ifndef ENABLE_DUMP#ifndef NDEBUG#define ENABLE_DUMP 1#endif#endifnamespace DOM { class DOMStringImpl; class ShadowValueImpl; class QuotesValueImpl; class CounterImpl; class CSSValueListImpl; class CounterActImpl;}namespace khtml { class CachedImage; class CachedObject;template <class DATA>class DataRef{public: DataRef() { data=0; } DataRef( const DataRef<DATA> &d ) { data = d.data; data->ref(); } ~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() { 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; } bool operator == ( const DataRef<DATA> &o ) const { return (*data == *(o.data) ); } bool operator != ( const DataRef<DATA> &o ) const { return (*data != *(o.data) ); }private: DATA* data;};//------------------------------------------------//------------------------------------------------// Box model attributes. Not inherited.struct LengthBox{ LengthBox() { } LengthBox( LengthType t ) : left( t ), right ( t ), top( t ), bottom( t ) {} 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() || right.value() || top.value() || bottom.value(); }};enum EPosition { STATIC, RELATIVE, ABSOLUTE, FIXED};enum EFloat { FNONE = 0, FLEFT = 0x01, FRIGHT = 0x02, FLEFT_ALIGN = 0x05, FRIGHT_ALIGN = 0x06};//------------------------------------------------// Border attributes. Not inherited.// These have been defined in the order of their precedence for border-collapsing. Do// not change this order!enum EBorderStyle { BNATIVE, BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE};class BorderValue{public: BorderValue() : width( 3 ), style( BNONE ) {} QColor color; unsigned short width : 12; EBorderStyle style : 6; bool nonZero() const { // rikkus: workaround for gcc 2.95.3 return width!=0 && !(style==BNONE); } bool isTransparent() const { return color.isValid() && qAlpha(color.rgb()) == 0; } bool operator==(const BorderValue& o) const { return width==o.width && style==o.style && color==o.color; } bool operator!=(const BorderValue& o) const { return !(*this == o); }};class OutlineValue : public BorderValue{ public: OutlineValue() { _offset = 0; _auto = false; } bool operator==(const OutlineValue& o) const { return width==o.width && style==o.style && color==o.color && _offset == o._offset && _auto == o._auto; } bool operator!=(const OutlineValue& o) const { return !(*this == o); } int _offset; bool _auto;};enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };struct CollapsedBorderValue{ CollapsedBorderValue() :border(0), precedence(BOFF) {} CollapsedBorderValue(const BorderValue* b, EBorderPrecedence p) :border(b), precedence(p) {} int width() const { return border && border->nonZero() ? border->width : 0; } EBorderStyle style() const { return border ? border->style : BHIDDEN; } bool exists() const { return border; } QColor color() const { return border ? border->color : QColor(); } bool isTransparent() const { return border ? border->isTransparent() : true; } bool operator==(const CollapsedBorderValue& o) const { if (!border) return !o.border; if (!o.border) return false; return *border == *o.border && precedence == o.precedence; } const BorderValue* border; EBorderPrecedence precedence;};class BorderData : public Shared<BorderData>{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 Shared<StyleSurroundData>{public: StyleSurroundData(); StyleSurroundData(const StyleSurroundData& o ); bool operator==(const StyleSurroundData& o) const; bool operator!=(const StyleSurroundData& o) const { return !(*this == o); } LengthBox offset; LengthBox margin; LengthBox padding; BorderData border;};//------------------------------------------------// Box attributes. Not inherited.enum EBoxSizing { BORDER_BOX, CONTENT_BOX};class StyleBoxData : public Shared<StyleBoxData>{public: StyleBoxData(); StyleBoxData(const StyleBoxData& o ); // copy and assignment// StyleBoxData(const StyleBoxData &other);// const StyleBoxData &operator = (const StyleBoxData &other); bool operator==(const StyleBoxData& o) const; bool operator!=(const StyleBoxData& o) const { return !(*this == o); } Length width; Length height; Length min_width; Length max_width; Length min_height; Length max_height;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -