下面列出了org.w3c.dom.css.CSSPrimitiveValue#CSS_IDENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue(CSSStylableElement elt, CSSEngine engine,
int idx, Value value) {
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
Value percentage = (Value) percentValues.get(value
.getStringValue());
if (percentage != null) {
return percentage;
}
throw createInvalidIdentifierDOMException(value
.getStringValue());
}
}
return super.computeValue(elt, engine, idx, value);
}
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue(CSSStylableElement elt, CSSEngine engine,
int idx, Value value) {
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
Value percentage = (Value) percentValues.get(value
.getStringValue());
if (percentage != null) {
return percentage;
}
throw createInvalidIdentifierDOMException(value
.getStringValue());
}
}
return super.computeValue(elt, engine, idx, value);
}
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue( CSSStylableElement elt, CSSEngine engine,
int idx, Value value )
{
if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE )
{
if ( value.getPrimitiveType( ) == CSSPrimitiveValue.CSS_IDENT )
{
return CSSValueConstants.NUMBER_0;
}
}
return super.computeValue( elt, engine, idx, value );
}
public Value computeValue( CSSStylableElement elt, CSSEngine engine,
int idx, Value value )
{
IStyle cs = elt.getComputedStyle( );
CSSValue borderStyle = null;
switch ( idx )
{
case IStyle.STYLE_BORDER_TOP_WIDTH :
borderStyle = cs.getProperty( IStyle.STYLE_BORDER_TOP_STYLE );
break;
case IStyle.STYLE_BORDER_BOTTOM_WIDTH :
borderStyle = cs.getProperty( IStyle.STYLE_BORDER_BOTTOM_STYLE );
break;
case IStyle.STYLE_BORDER_LEFT_WIDTH :
borderStyle = cs.getProperty( IStyle.STYLE_BORDER_LEFT_STYLE );
break;
case IStyle.STYLE_BORDER_RIGHT_WIDTH :
borderStyle = cs.getProperty( IStyle.STYLE_BORDER_RIGHT_STYLE );
break;
}
if ( borderStyle == CSSValueConstants.NONE_VALUE
|| borderStyle == CSSValueConstants.HIDDEN_VALUE )
{
return CSSValueConstants.NUMBER_0;
}
if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE )
{
if ( value.getPrimitiveType( ) == CSSPrimitiveValue.CSS_IDENT )
{
String ident = value.getStringValue( );
Value cv = (Value) computedValues.get( ident );
if ( cv != null )
{
value = cv;
}
}
}
return super.computeValue( elt, engine, idx, value );
}
/**
* Implements {@link
* ValueManager#createStringValue(short,String,CSSEngine)}.
*/
public CSSPrimitiveValue createStringValue(short type, String value)
throws DOMException {
if (type != CSSPrimitiveValue.CSS_IDENT) {
throw createInvalidStringTypeDOMException(type);
}
Object v = values.get(value.toLowerCase().intern());
if (v == null) {
throw createInvalidIdentifierDOMException(value);
}
return (CSSPrimitiveValue) v;
}
protected Value createStringValue( short type, String value, CSSEngine engine )
throws DOMException
{
if ( type != CSSPrimitiveValue.CSS_IDENT )
{
throw createInvalidStringTypeDOMException( type );
}
Object v = getIdentifiers( ).get( value.toLowerCase( ).intern( ) );
if ( v == null )
{
throw createInvalidIdentifierDOMException( value );
}
return (Value) v;
}
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue( CSSStylableElement elt, CSSEngine engine,
int idx, Value value )
{
if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE )
{
CSSPrimitiveValue pvalue = (CSSPrimitiveValue) value;
int primitiveType = pvalue.getPrimitiveType( );
if ( primitiveType == CSSPrimitiveValue.CSS_IDENT )
{
String ident = pvalue.getStringValue( );
// Search for a direct computed value.
Value v = (Value) computedValues.get( ident );
if ( v != null )
{
return v;
}
// Must be a system color...
if ( values.get( ident ) == null )
{
throw new InternalError( );
}
return (Value) engine.getCSSContext( ).getSystemColor( ident );
}
if ( primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR )
{
RGBColor color = value.getRGBColorValue( );
CSSPrimitiveValue red = color.getRed( );
CSSPrimitiveValue green = color.getGreen( );
CSSPrimitiveValue blue = color.getBlue( );
return createRGBColor( createColorComponent( red ),
createColorComponent( green ),
createColorComponent( blue ) );
}
}
return super.computeValue( elt, engine, idx, value );
}