📄 css_valueimpl.h
字号:
/*
* This file is part of the DOM implementation for KDE.
*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004 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 _CSS_css_valueimpl_h_
#define _CSS_css_valueimpl_h_
#include "dom/css_value.h"
#include "css/css_base.h"
#include "misc/loader_client.h"
#include <qvaluelist.h>
namespace khtml {
class RenderStyle;
class CachedImage;
class DocLoader;
}
namespace DOM {
class CSSMutableStyleDeclarationImpl;
class CounterImpl;
extern const int inheritableProperties[];
extern const unsigned numInheritableProperties;
class CSSStyleDeclarationImpl : public StyleBaseImpl
{
public:
virtual bool isStyleDeclaration();
CSSRuleImpl *parentRule() const;
virtual DOMString cssText() const = 0;
virtual void setCssText(const DOMString &, int &exceptionCode) = 0;
virtual unsigned long length() const = 0;
virtual DOMString item(unsigned long index) const = 0;
virtual CSSValueImpl *getPropertyCSSValue(int propertyID) const = 0;
virtual DOMString getPropertyValue(int propertyID) const = 0;
virtual bool getPropertyPriority(int propertyID) const = 0;
virtual void setProperty(int propertyId, const DOMString &value, bool important, int &exceptionCode) = 0;
virtual DOMString removeProperty(int propertyID, int &exceptionCode) = 0;
virtual CSSMutableStyleDeclarationImpl *copy() const = 0;
virtual CSSMutableStyleDeclarationImpl *makeMutable() = 0;
void diff(CSSMutableStyleDeclarationImpl *) const;
CSSMutableStyleDeclarationImpl *copyPropertiesInSet(const int *set, unsigned length) const;
protected:
CSSStyleDeclarationImpl(CSSRuleImpl *parentRule = 0);
private:
CSSStyleDeclarationImpl(const CSSStyleDeclarationImpl &);
CSSStyleDeclarationImpl& operator=(const CSSStyleDeclarationImpl &);
};
class CSSValueImpl : public StyleBaseImpl
{
public:
virtual unsigned short cssValueType() const = 0;
virtual DOMString cssText() const = 0;
virtual bool isValue() { return true; }
virtual bool isFontValue() { return false; }
};
class CSSInheritedValueImpl : public CSSValueImpl
{
public:
virtual unsigned short cssValueType() const;
virtual DOMString cssText() const;
};
class CSSInitialValueImpl : public CSSValueImpl
{
public:
virtual unsigned short cssValueType() const;
virtual DOMString cssText() const;
};
class CSSValueListImpl : public CSSValueImpl
{
public:
CSSValueListImpl();
virtual ~CSSValueListImpl();
unsigned long length() const { return m_values.count(); }
CSSValueImpl *item ( unsigned long index ) { return m_values.at(index); }
virtual bool isValueList() { return true; }
virtual unsigned short cssValueType() const;
void append(CSSValueImpl *val);
virtual DOMString cssText() const;
protected:
QPtrList<CSSValueImpl> m_values;
};
class Counter;
class RGBColor;
class Rect;
class DashboardRegionImpl;
class CSSPrimitiveValueImpl : public CSSValueImpl
{
public:
CSSPrimitiveValueImpl();
CSSPrimitiveValueImpl(int ident);
CSSPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type);
CSSPrimitiveValueImpl(const DOMString &str, CSSPrimitiveValue::UnitTypes type);
CSSPrimitiveValueImpl(const Counter &c);
CSSPrimitiveValueImpl(RectImpl *r);
CSSPrimitiveValueImpl(DashboardRegionImpl *r);
CSSPrimitiveValueImpl(QRgb color);
virtual ~CSSPrimitiveValueImpl();
void cleanup();
unsigned short primitiveType() const {
return m_type;
}
/*
* computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
* the fontinfo in case val is defined in em or ex.
*
* The metrics have to be a bit different for screen and printer output.
* For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
*
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics, double multiplier );
double computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics,
bool applyZoomFactor = true );
// use with care!!!
void setPrimitiveType(unsigned short type) { m_type = type; }
void setFloatValue ( unsigned short unitType, double floatValue, int &exceptioncode );
double getFloatValue ( unsigned short/* unitType */) const {
return m_value.num;
}
void setStringValue ( unsigned short stringType, const DOM::DOMString &stringValue, int &exceptioncode );
DOM::DOMString getStringValue() const;
CounterImpl *getCounterValue () const {
return ( m_type != CSSPrimitiveValue::CSS_COUNTER ? 0 : m_value.counter );
}
RectImpl *getRectValue () const {
return ( m_type != CSSPrimitiveValue::CSS_RECT ? 0 : m_value.rect );
}
QRgb getRGBColorValue () const {
return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
}
#if APPLE_CHANGES
DashboardRegionImpl *getDashboardRegionValue () const {
return ( m_type != CSSPrimitiveValue::CSS_DASHBOARD_REGION ? 0 : m_value.region );
}
#endif
virtual bool isPrimitiveValue() const { return true; }
virtual unsigned short cssValueType() const;
int getIdent();
virtual bool parseString( const DOMString &string, bool = false);
virtual DOMString cssText() const;
virtual bool isQuirkValue() { return false; }
protected:
int m_type;
union {
int ident;
double num;
DOMStringImpl *string;
CounterImpl *counter;
RectImpl *rect;
QRgb rgbcolor;
DashboardRegionImpl *region;
} m_value;
};
// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em
// in a stylesheet. When the quirky value is used, if you're in quirks mode, the margin will
// collapse away inside a table cell.
class CSSQuirkPrimitiveValueImpl : public CSSPrimitiveValueImpl
{
public:
CSSQuirkPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type)
:CSSPrimitiveValueImpl(num, type) {}
virtual bool isQuirkValue() { return true; }
};
class CounterImpl : public khtml::Shared<CounterImpl> {
public:
DOMString identifier() const { return m_identifier; }
DOMString listStyle() const { return m_listStyle; }
DOMString separator() const { return m_separator; }
DOMString m_identifier;
DOMString m_listStyle;
DOMString m_separator;
};
class RectImpl : public khtml::Shared<RectImpl> {
public:
RectImpl();
virtual ~RectImpl();
CSSPrimitiveValueImpl *top() { return m_top; }
CSSPrimitiveValueImpl *right() { return m_right; }
CSSPrimitiveValueImpl *bottom() { return m_bottom; }
CSSPrimitiveValueImpl *left() { return m_left; }
void setTop( CSSPrimitiveValueImpl *top );
void setRight( CSSPrimitiveValueImpl *right );
void setBottom( CSSPrimitiveValueImpl *bottom );
void setLeft( CSSPrimitiveValueImpl *left );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -