📄 render_style.h
字号:
/* * This file is part of the DOM implementation for KDE. * * Copyright (C) 2000 Lars Knoll (knoll@kde.org) * (C) 2000 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) * Copyright (C) 2003 Apple Computer, Inc. * * 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. * */#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 <qlist.h>#include <qpalette.h>#include <qapplication.h>#include "dom/dom_misc.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;class RenderArena;namespace DOM { class DOMStringImpl; class ShadowValueImpl;}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;};enum PseudoState { PseudoUnknown, PseudoNone, PseudoAnyLink, PseudoLink, PseudoVisited};//------------------------------------------------//------------------------------------------------// 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!=0 || right.value!=0 || top.value!=0 || bottom.value!=0; }};enum EPosition { STATIC, RELATIVE, ABSOLUTE, FIXED};enum EFloat { FNONE = 0, FLEFT, FRIGHT};//------------------------------------------------// Border attributes. Not inherited.// These have been defined in the order of their precedence for border-collapsing. Do// not change this order!enum EBorderStyle { BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE};class BorderValue{public: BorderValue() { width = 3; // medium is default value style = BNONE; } QColor color; unsigned short width : 12; EBorderStyle style : 4; 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; } 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.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; Length vertical_align; int z_index; bool z_auto : 1;};//------------------------------------------------// Random visual rendering model attributes. Not inherited.enum EOverflow { OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE, OOVERLAY};enum EVerticalAlign { BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP, TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH};enum EClear{ CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -