[nobug] Add org.eclipse.wst.css.core to R3_2_5_patches from R3_2_maintenance
diff --git a/bundles/org.eclipse.wst.css.core/.classpath b/bundles/org.eclipse.wst.css.core/.classpath
new file mode 100644
index 0000000..c34f122
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.classpath
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="org/w3c/dom/css/**/*"/>
+ <accessrule kind="accessible" pattern="org/eclipse/wst/sse/core/**"/>
+ <accessrule kind="accessible" pattern="org/eclipse/wst/xml/core/**"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.wst.css.core/.cvsignore b/bundles/org.eclipse.wst.css.core/.cvsignore
new file mode 100644
index 0000000..eabf67a
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.cvsignore
@@ -0,0 +1,8 @@
+bin
+temp.folder
+cssmodel.jar
+build.xml
+dev.properties
+@dot
+src.zip
+javaCompiler...args
diff --git a/bundles/org.eclipse.wst.css.core/.options b/bundles/org.eclipse.wst.css.core/.options
new file mode 100644
index 0000000..490975b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.options
@@ -0,0 +1,2 @@
+org.eclipse.wst.css.core/debug=true
+org.eclipse.wst.css.core/debug/tracefilter=
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/.project b/bundles/org.eclipse.wst.css.core/.project
new file mode 100644
index 0000000..bb046e9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wst.css.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..afa5c91
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.runtime.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 0000000..7ec5750
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,3 @@
+#Mon Apr 17 01:48:39 EDT 2006
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..b9dc209
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,81 @@
+#Wed Mar 28 03:13:52 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=ignore
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=error
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..301c7ad
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Mon Apr 17 01:48:39 EDT 2006
+eclipse.preferences.version=1
+internal.default.compliance=default
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<templates/>
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.ltk.core.refactoring.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 0000000..c59368c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,3 @@
+#Tue Apr 04 03:36:32 EDT 2006
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.pde.prefs b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.pde.prefs
new file mode 100644
index 0000000..fc522bb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/.settings/org.eclipse.pde.prefs
@@ -0,0 +1,16 @@
+#Mon Apr 17 02:01:33 EDT 2006
+compilers.incompatible-environment=0
+compilers.p.build=0
+compilers.p.deprecated=1
+compilers.p.illegal-att-value=0
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=0
+compilers.p.unknown-attribute=0
+compilers.p.unknown-class=0
+compilers.p.unknown-element=0
+compilers.p.unknown-resource=0
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.p.unused-element-or-attribute=0
+compilers.use-project=true
+eclipse.preferences.version=1
diff --git a/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..a47b5ed
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.wst.css.core; singleton:=true
+Bundle-Version: 1.1.403.qualifier
+Bundle-Activator: org.eclipse.wst.css.core.internal.CSSCorePlugin
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.eclipse.wst.css.core.internal;x-friends:="org.eclipse.wst.css.ui",
+ org.eclipse.wst.css.core.internal.cleanup;x-internal:=true,
+ org.eclipse.wst.css.core.internal.contentmodel;x-internal:=true,
+ org.eclipse.wst.css.core.internal.contentproperties;x-internal:=true,
+ org.eclipse.wst.css.core.internal.contenttype;x-internal:=true,
+ org.eclipse.wst.css.core.internal.document;x-internal:=true,
+ org.eclipse.wst.css.core.internal.encoding;x-internal:=true,
+ org.eclipse.wst.css.core.internal.event;x-internal:=true,
+ org.eclipse.wst.css.core.internal.eventimpl;x-internal:=true,
+ org.eclipse.wst.css.core.internal.format;x-friends:="org.eclipse.wst.css.ui",
+ org.eclipse.wst.css.core.internal.formatter;x-internal:=true,
+ org.eclipse.wst.css.core.internal.metamodel;x-internal:=true,
+ org.eclipse.wst.css.core.internal.metamodel.util;x-friends:="org.eclipse.wst.css.ui",
+ org.eclipse.wst.css.core.internal.metamodelimpl;x-internal:=true,
+ org.eclipse.wst.css.core.internal.modelhandler;x-internal:=true,
+ org.eclipse.wst.css.core.internal.parser;x-internal:=true,
+ org.eclipse.wst.css.core.internal.parser.regions;x-internal:=true,
+ org.eclipse.wst.css.core.internal.parserz;x-friends:="org.eclipse.wst.css.ui",
+ org.eclipse.wst.css.core.internal.preferences;x-internal:=true,
+ org.eclipse.wst.css.core.internal.provisional.adapters;x-internal:=true,
+ org.eclipse.wst.css.core.internal.provisional.contenttype;x-internal:=true,
+ org.eclipse.wst.css.core.internal.provisional.document;x-internal:=true,
+ org.eclipse.wst.css.core.internal.provisional.preferences;x-internal:=true,
+ org.eclipse.wst.css.core.internal.provisional.text;x-internal:=true,
+ org.eclipse.wst.css.core.internal.tasks;x-internal:=true,
+ org.eclipse.wst.css.core.internal.text;x-internal:=true,
+ org.eclipse.wst.css.core.internal.util;x-friends:="org.eclipse.wst.css.ui",
+ org.eclipse.wst.css.core.internal.util.declaration;x-internal:=true,
+ org.eclipse.wst.css.core.text
+Import-Package: com.ibm.icu.util; version="3.8"
+Require-Bundle: org.apache.xerces;bundle-version="[2.9.0,3.0.0)";visibility:=reexport,
+ org.eclipse.wst.xml.core;bundle-version="[1.1.500,1.2.0)",
+ org.eclipse.wst.sse.core;bundle-version="[1.1.500,1.2.0)",
+ org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)"
+Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.css.core.internal.contenttype"
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.wst.css.core/about.html b/bundles/org.eclipse.wst.css.core/about.html
new file mode 100644
index 0000000..2199df3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/about.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+
+<BODY lang="EN-US">
+
+<H3>About This Content</H3>
+
+<P>June, 2008</P>
+
+<H3>License</H3>
+
+<P>The Eclipse Foundation makes available all content in this plug-in
+("Content"). Unless otherwise indicated below, the Content is provided to you
+under the terms and conditions of the Eclipse Public License Version 1.0
+("EPL"). A copy of the EPL is available at
+<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
+For purposes of the EPL, "Program" will mean the Content.</P>
+
+<P>If you did not receive this Content directly from the Eclipse Foundation, the
+Content is being redistributed by another party ("Redistributor") and different
+terms and conditions may apply to your use of any object code in the Content.
+Check the Redistributors license that was provided with the Content. If no such
+license exists, contact the Redistributor. Unless otherwise indicated below, the
+terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at
+<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
+
+</BODY>
+</HTML>
diff --git a/bundles/org.eclipse.wst.css.core/build.properties b/bundles/org.eclipse.wst.css.core/build.properties
new file mode 100644
index 0000000..60e22fd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/build.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2004, 2005 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+bin.includes = plugin.xml,\
+ cssprofile/,\
+ .options,\
+ plugin.properties,\
+ META-INF/,\
+ .,\
+ about.html
+bin.excludes = bin/**,\
+ @dot/**,\
+ temp.folder/**
+src.includes = component.xml
+source.. = src/
+
diff --git a/bundles/org.eclipse.wst.css.core/component.xml b/bundles/org.eclipse.wst.css.core/component.xml
new file mode 100644
index 0000000..476033a
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/component.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.wst.css">
+ <description url="http://eclipse.org/webtools/wst/components/css/overview.html"></description>
+ <component-depends unrestricted="true"></component-depends>
+ <plugin id="org.eclipse.wst.css.core" fragment="false" />
+ <plugin id="org.eclipse.wst.css.ui" fragment="false" />
+ <package name="org.eclipse.wst.css.ui.views.properties" api="false">
+ <type name="CSSPropertySheetConfiguration" subclass="true" instantiate="true" />
+ </package>
+ <package name="org.eclipse.wst.css.ui" api="false">
+ <type name="StructuredTextViewerConfigurationCSS" subclass="true" instantiate="true" />
+ </package>
+ <package name="org.eclipse.wst.css.ui.views.contentoutline" api="false">
+ <type name="CSSContentOutlineConfiguration" subclass="true" instantiate="true" />
+ </package>
+</component>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/css-profile.dtd b/bundles/org.eclipse.wst.css.core/cssprofile/css-profile.dtd
new file mode 100644
index 0000000..feb3ef8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/css-profile.dtd
@@ -0,0 +1,143 @@
+<!-- DTD for CSS Meta Model Profile -->
+<!--
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!-- Entities -->
+
+<!-- name-definition : In defining meta model object, object name -->
+<!-- is given by using this attribute. -->
+
+<!ENTITY % name-definition 'name CDATA #REQUIRED' >
+
+<!-- name-reference : used to refer meta model object that defined -->
+<!-- by name-definition -->
+
+<!ENTITY % name-reference 'name CDATA #REQUIRED' >
+
+<!-- availability : CSS Meta Model Profile permit importing -->
+<!-- other profile and describe difference for it. -->
+
+<!ENTITY % availability 'enabled (true | false) "true"' >
+<!ENTITY % overwrite 'overwrite (true | false) "false"' >
+
+<!-- ******************** -->
+<!-- elments/attributes -->
+<!-- ******************** -->
+
+<!ELEMENT css-profile (profile-import? , (stylesheet-def | charset-rule-def | import-rule-def | page-rule-def | media-rule-def | fontface-rule-def | style-rule-def | property-def | descriptor-def | container-def | function-def | number-def | unit-def | keyword-def | category-def | pseudo-element-def | pseudo-class-def)*) >
+
+<!-- a profile can include other profile -->
+
+<!ELEMENT profile-import EMPTY >
+<!ATTLIST profile-import name CDATA #REQUIRED >
+
+<!-- which type of rule can be used? -->
+
+<!ELEMENT stylesheet-def (description? , (charset-rule | import-rule | page-rule | media-rule | fontface-rule | style-rule)*) >
+<!ATTLIST stylesheet-def %overwrite; >
+
+<!ELEMENT charset-rule EMPTY >
+<!ATTLIST charset-rule %availability; >
+<!ELEMENT import-rule EMPTY >
+<!ATTLIST import-rule %availability; >
+<!ELEMENT page-rule EMPTY >
+<!ATTLIST page-rule %availability; >
+<!ELEMENT media-rule EMPTY >
+<!ATTLIST media-rule %availability; >
+<!ELEMENT fontface-rule EMPTY >
+<!ATTLIST fontface-rule %availability; >
+<!ELEMENT style-rule EMPTY >
+<!ATTLIST style-rule %availability; >
+
+<!ELEMENT charset-rule-def (description?) >
+<!ATTLIST charset-rule-def %overwrite; >
+
+<!ELEMENT import-rule-def (description?) >
+<!ATTLIST import-rule-def %overwrite; >
+
+<!ELEMENT page-rule-def (description? , (property | pseudo-class)*) >
+<!ATTLIST page-rule-def %overwrite; >
+
+<!ELEMENT media-rule-def (description?) >
+<!ATTLIST media-rule-def %overwrite; >
+
+<!ELEMENT fontface-rule-def (description? , descriptor*) >
+<!ATTLIST fontface-rule-def %overwrite; >
+
+<!ELEMENT style-rule-def (description? , (property | selector-expression | pseudo-class | pseudo-element)*) >
+<!ATTLIST style-rule-def %overwrite; >
+
+<!ELEMENT selector-expression EMPTY >
+<!ATTLIST selector-expression name (descendant | child | adjacent | universal | attribute) #REQUIRED %availability; >
+
+<!ELEMENT pseudo-class EMPTY >
+<!ATTLIST pseudo-class %name-reference; %availability; >
+
+<!ELEMENT pseudo-element EMPTY >
+<!ATTLIST pseudo-element %name-reference; %availability; >
+
+<!ELEMENT pseudo-class-def (description?, selector-value) >
+<!ATTLIST pseudo-class-def %name-definition; %overwrite; >
+<!ELEMENT selector-value (#PCDATA) >
+
+<!ELEMENT pseudo-element-def (description?, selector-value) >
+<!ATTLIST pseudo-element-def %name-definition; %overwrite; >
+
+<!ELEMENT keyword-def (description? , keyword-value) >
+<!ATTLIST keyword-def %name-definition; %overwrite; >
+<!ELEMENT keyword-value (#PCDATA) >
+<!ELEMENT description (#PCDATA) >
+
+<!ELEMENT function-def (description? , function-value) >
+<!ATTLIST function-def %name-definition; %overwrite; >
+<!ELEMENT function-value (#PCDATA) >
+
+<!ELEMENT number-def (description? , unit*) >
+<!ATTLIST number-def %name-definition; %overwrite; >
+<!ELEMENT unit EMPTY >
+<!ATTLIST unit %name-reference; %availability; >
+
+<!ELEMENT unit-def (description? , unit-value) >
+<!ATTLIST unit-def %name-definition; %overwrite; >
+<!ELEMENT unit-value (#PCDATA) >
+
+<!ELEMENT container-def (description? , (number | keyword | function | container)*) >
+<!ATTLIST container-def %name-definition; %overwrite; >
+
+<!ELEMENT category-def (description?, caption) >
+<!ATTLIST category-def %name-definition; %overwrite; >
+<!ELEMENT caption (#PCDATA) >
+
+<!ELEMENT property-def (description? , (number | keyword | function | container | string | separator | property)*) >
+<!ATTLIST property-def %name-definition; %overwrite;
+ inherited (yes | no | na) "na"
+ mediagroup CDATA #IMPLIED
+ category CDATA #IMPLIED >
+<!ELEMENT descriptor-def (description?, (number | keyword | function | container | string | separator | property)*) >
+<!ATTLIST descriptor-def %name-definition; %overwrite; >
+
+<!ELEMENT number EMPTY >
+<!ATTLIST number %name-reference; %availability; >
+<!ELEMENT keyword EMPTY >
+<!ATTLIST keyword %name-reference; %availability; >
+<!ELEMENT function EMPTY >
+<!ATTLIST function %name-reference; %availability; >
+<!ELEMENT container EMPTY >
+<!ATTLIST container %name-reference; %availability; >
+<!ELEMENT string EMPTY >
+<!ATTLIST string %name-reference; %availability; >
+<!ELEMENT separator EMPTY >
+<!ATTLIST separator name (comma | slash) #REQUIRED %availability; >
+<!ELEMENT property EMPTY >
+<!ATTLIST property %name-reference; %availability; >
+<!ELEMENT descriptor EMPTY >
+<!ATTLIST descriptor %name-reference; %availability; >
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css1.xml b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css1.xml
new file mode 100644
index 0000000..20a0ee5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css1.xml
@@ -0,0 +1,838 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!--<!DOCTYPE css-profile SYSTEM "css-profile.dtd" >-->
+<css-profile>
+ <stylesheet-def>
+ <description>%css1.stylesheet-def.description</description>
+ <import-rule/>
+ <style-rule/>
+ </stylesheet-def>
+
+ <import-rule-def>
+ </import-rule-def>
+
+ <style-rule-def>
+ <selector-expression name="descendant"/>
+ <pseudo-element name="first-line"/>
+ <pseudo-element name="first-letter"/>
+ <pseudo-class name="link"/>
+ <pseudo-class name="visited"/>
+ <pseudo-class name="active"/>
+ <property name="background"/>
+ <property name="background-attachment"/>
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-position"/>
+ <property name="background-repeat"/>
+ <property name="border"/>
+ <property name="border-bottom"/>
+ <property name="border-bottom-width"/>
+ <property name="border-color"/>
+ <property name="border-left"/>
+ <property name="border-left-width"/>
+ <property name="border-right"/>
+ <property name="border-right-width"/>
+ <property name="border-style"/>
+ <property name="border-top"/>
+ <property name="border-top-width"/>
+ <property name="border-width"/>
+ <property name="clear"/>
+ <property name="color"/>
+ <property name="display"/>
+ <property name="float"/>
+ <property name="font"/>
+ <property name="font-family"/>
+ <property name="font-size"/>
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="height"/>
+ <property name="letter-spacing"/>
+ <property name="line-height"/>
+ <property name="list-style"/>
+ <property name="list-style-image"/>
+ <property name="list-style-position"/>
+ <property name="list-style-type"/>
+ <property name="margin"/>
+ <property name="margin-bottom"/>
+ <property name="margin-left"/>
+ <property name="margin-right"/>
+ <property name="margin-top"/>
+ <property name="padding"/>
+ <property name="padding-bottom"/>
+ <property name="padding-left"/>
+ <property name="padding-right"/>
+ <property name="padding-top"/>
+ <property name="text-align"/>
+ <property name="text-decoration"/>
+ <property name="text-indent"/>
+ <property name="text-transform"/>
+ <property name="vertical-align"/>
+ <property name="white-space"/>
+ <property name="width"/>
+ <property name="word-spacing"/>
+ </style-rule-def>
+
+ <pseudo-class-def name="link">
+ <selector-value>link</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="visited">
+ <selector-value>visited</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="active">
+ <selector-value>active</selector-value>
+ </pseudo-class-def>
+
+ <pseudo-element-def name="first-line">
+ <selector-value>first-line</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="first-letter">
+ <selector-value>first-letter</selector-value>
+ </pseudo-element-def>
+
+ <!-- property definition -->
+
+ <property-def name="background" inherited="no" category="colorandbackground">
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-repeat"/>
+ <property name="background-attachment"/>
+ <property name="background-position"/>
+ </property-def>
+ <property-def name="background-attachment" inherited="no" category="colorandbackground">
+ <keyword name="scroll"/>
+ <keyword name="fixed"/>
+ </property-def>
+ <property-def name="background-color" inherited="no" category="colorandbackground">
+ <container name="color"/>
+ <keyword name="transparent"/>
+ </property-def>
+ <property-def name="background-image" inherited="no" category="colorandbackground">
+ <function name="uri"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="background-position" inherited="no" category="colorandbackground">
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="top"/>
+ <keyword name="center"/>
+ <keyword name="bottom"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ </property-def>
+ <property-def name="background-repeat" inherited="no" category="colorandbackground">
+ <keyword name="repeat"/>
+ <keyword name="repeat-x"/>
+ <keyword name="repeat-y"/>
+ <keyword name="no-repeat"/>
+ </property-def>
+ <property-def name="border" inherited="no" category="box">
+ <property name="border-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-color" inherited="no" category="box">
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-style" inherited="no" category="box">
+ <keyword name="none"/>
+ <keyword name="dotted"/>
+ <keyword name="dashed"/>
+ <keyword name="solid"/>
+ <keyword name="double"/>
+ <keyword name="groove"/>
+ <keyword name="ridge"/>
+ <keyword name="inset"/>
+ <keyword name="outset"/>
+ </property-def>
+ <property-def name="border-top" inherited="no" category="box">
+ <property name="border-top-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-right" inherited="no" category="box">
+ <property name="border-right-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-bottom" inherited="no" category="box">
+ <property name="border-bottom-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-left" inherited="no" category="box">
+ <property name="border-left-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ </property-def>
+ <property-def name="border-top-width" inherited="no" category="box">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="border-right-width" inherited="no" category="box">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="border-bottom-width" inherited="no" category="box">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="border-left-width" inherited="no" category="box">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="border-width" inherited="no" category="box">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="clear" inherited="no" category="box">
+ <keyword name="none"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="both"/>
+ </property-def>
+ <property-def name="color" inherited="yes" category="colorandbackground">
+ <container name="color"/>
+ </property-def>
+ <property-def name="display" inherited="no" category="classification">
+ <keyword name="block"/>
+ <keyword name="inline"/>
+ <keyword name="list-item"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="float" inherited="no" category="box">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="font"
+ inherited="yes" category="font">
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="font-size"/>
+ <property name="line-height"/>
+ <property name="font-family"/>
+ <separator name="slash"/>
+ </property-def>
+ <property-def name="font-family" inherited="yes" category="font">
+ <string name="family-name"/>
+ <container name="generic-family"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="font-size" inherited="yes" category="font">
+ <container name="absolute-size"/>
+ <container name="relative-size"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="font-style" inherited="yes" category="font">
+ <keyword name="normal"/>
+ <keyword name="italic"/>
+ <keyword name="oblique"/>
+ </property-def>
+ <property-def name="font-variant" inherited="yes" category="font">
+ <keyword name="normal"/>
+ <keyword name="small-caps"/>
+ </property-def>
+ <property-def name="font-weight" inherited="yes" category="font">
+ <keyword name="normal"/>
+ <keyword name="bold"/>
+ <keyword name="bolder"/>
+ <keyword name="lighter"/>
+ <keyword name="100"/>
+ <keyword name="200"/>
+ <keyword name="300"/>
+ <keyword name="400"/>
+ <keyword name="500"/>
+ <keyword name="600"/>
+ <keyword name="700"/>
+ <keyword name="800"/>
+ <keyword name="900"/>
+ </property-def>
+ <property-def name="height" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="letter-spacing" inherited="yes" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ </property-def>
+ <property-def name="line-height" inherited="yes" category="text">
+ <keyword name="normal"/>
+ <number name="number"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="list-style" inherited="yes" category="classification">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="none"/>
+ <keyword name="inside"/>
+ <keyword name="outside"/>
+ <function name="uri"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="list-style-image" inherited="yes" category="classification">
+ <function name="uri"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="list-style-position" inherited="yes" category="classification">
+ <keyword name="inside"/>
+ <keyword name="outside"/>
+ </property-def>
+ <property-def name="list-style-type" inherited="yes" category="classification">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="margin" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="margin-top" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="margin-right" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="margin-bottom" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="margin-left" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="padding" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="padding-top" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="padding-right" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="padding-bottom" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="padding-left" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="text-align" inherited="yes" category="text">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="center"/>
+ <keyword name="justify"/>
+ </property-def>
+ <property-def name="text-decoration" inherited="no" category="text">
+ <keyword name="none"/>
+ <keyword name="underline"/>
+ <keyword name="overline"/>
+ <keyword name="line-through"/>
+ <keyword name="blink"/>
+ </property-def>
+ <property-def name="text-indent" inherited="yes" category="text">
+ <number name="length"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="text-transform" inherited="yes" category="text">
+ <keyword name="capitalize"/>
+ <keyword name="uppercase"/>
+ <keyword name="lowercase"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="vertical-align" inherited="no" category="text">
+ <keyword name="baseline"/>
+ <keyword name="sub"/>
+ <keyword name="super"/>
+ <keyword name="top"/>
+ <keyword name="text-top"/>
+ <keyword name="middle"/>
+ <keyword name="bottom"/>
+ <keyword name="text-bottom"/>
+ <number name="percentage"/>
+ </property-def>
+ <property-def name="white-space" inherited="yes" category="classification">
+ <keyword name="normal"/>
+ <keyword name="pre"/>
+ <keyword name="nowrap"/>
+ </property-def>
+ <property-def name="width" inherited="no" category="box">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="word-spacing" inherited="yes" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ </property-def>
+
+ <!-- container definition : Container is the lump of values.
+ It can be used like macros. -->
+ <container-def name="absolute-size">
+ <keyword name="xx-small"/>
+ <keyword name="x-small"/>
+ <keyword name="small"/>
+ <keyword name="medium"/>
+ <keyword name="large"/>
+ <keyword name="x-large"/>
+ <keyword name="xx-large"/>
+ </container-def>
+ <container-def name="color">
+ <keyword name="aqua"/>
+ <keyword name="black"/>
+ <keyword name="blue"/>
+ <keyword name="fuchsia"/>
+ <keyword name="gray"/>
+ <keyword name="green"/>
+ <keyword name="lime"/>
+ <keyword name="maroon"/>
+ <keyword name="navy"/>
+ <keyword name="olive"/>
+ <keyword name="purple"/>
+ <keyword name="red"/>
+ <keyword name="silver"/>
+ <keyword name="teal"/>
+ <keyword name="white"/>
+ <keyword name="yellow"/>
+ <function name="rgb"/>
+ <number name="hash"/>
+ </container-def>
+ <container-def name="generic-family">
+ <keyword name="serif"/>
+ <keyword name="sans-serif"/>
+ <keyword name="cursive"/>
+ <keyword name="fantasy"/>
+ <keyword name="monospace"/>
+ </container-def>
+ <container-def name="relative-size">
+ <keyword name="smaller"/>
+ <keyword name="larger"/>
+ </container-def>
+
+ <!-- category definition : This is used to categorize properties
+ in Properties View. -->
+ <category-def name="box">
+ <caption>%css1.category-def.box.caption</caption>
+ </category-def>
+ <category-def name="colorandbackground">
+ <caption>%css1.category-def.colorandbackground.caption</caption>
+ </category-def>
+ <category-def name="classification">
+ <caption>%css1.category-def.classification.caption</caption>
+ </category-def>
+ <category-def name="font">
+ <caption>%css1.category-def.font.caption</caption>
+ </category-def>
+ <category-def name="text">
+ <caption>%css1.category-def.text.caption</caption>
+ </category-def>
+
+ <function-def name="rgb">
+ <function-value>rgb</function-value>
+ </function-def>
+ <function-def name="uri">
+ <function-value>url</function-value>
+ </function-def>
+
+ <!-- number definition : What unit types be acceptable for each
+ number type? -->
+ <number-def name="hash">
+ <unit name="hash"/>
+ </number-def>
+ <number-def name="length">
+ <unit name="em"/>
+ <unit name="ex"/>
+ <unit name="px"/>
+ <unit name="in"/>
+ <unit name="cm"/>
+ <unit name="mm"/>
+ <unit name="pt"/>
+ <unit name="pc"/>
+ </number-def>
+ <number-def name="number">
+ </number-def>
+ <number-def name="percentage">
+ <unit name="percentage"/>
+ </number-def>
+
+ <unit-def name="cm">
+ <unit-value>cm</unit-value>
+ </unit-def>
+ <unit-def name="em">
+ <unit-value>em</unit-value>
+ </unit-def>
+ <unit-def name="ex">
+ <unit-value>ex</unit-value>
+ </unit-def>
+ <unit-def name="hash">
+ <unit-value>#</unit-value>
+ </unit-def>
+ <unit-def name="in">
+ <unit-value>in</unit-value>
+ </unit-def>
+ <unit-def name="mm">
+ <unit-value>mm</unit-value>
+ </unit-def>
+ <unit-def name="pc">
+ <unit-value>pc</unit-value>
+ </unit-def>
+ <unit-def name="percentage">
+ <unit-value>%</unit-value>
+ </unit-def>
+ <unit-def name="pt">
+ <unit-value>pt</unit-value>
+ </unit-def>
+ <unit-def name="px">
+ <unit-value>px</unit-value>
+ </unit-def>
+
+ <!-- keywords : string constants (this is last part..) -->
+ <keyword-def name="100">
+ <keyword-value>100</keyword-value>
+ </keyword-def>
+ <keyword-def name="200">
+ <keyword-value>200</keyword-value>
+ </keyword-def>
+ <keyword-def name="300">
+ <keyword-value>300</keyword-value>
+ </keyword-def>
+ <keyword-def name="400">
+ <keyword-value>400</keyword-value>
+ </keyword-def>
+ <keyword-def name="500">
+ <keyword-value>500</keyword-value>
+ </keyword-def>
+ <keyword-def name="600">
+ <keyword-value>600</keyword-value>
+ </keyword-def>
+ <keyword-def name="700">
+ <keyword-value>700</keyword-value>
+ </keyword-def>
+ <keyword-def name="800">
+ <keyword-value>800</keyword-value>
+ </keyword-def>
+ <keyword-def name="900">
+ <keyword-value>900</keyword-value>
+ </keyword-def>
+ <keyword-def name="aqua">
+ <keyword-value>aqua</keyword-value>
+ </keyword-def>
+ <keyword-def name="auto">
+ <keyword-value>auto</keyword-value>
+ </keyword-def>
+ <keyword-def name="baseline">
+ <keyword-value>baseline</keyword-value>
+ </keyword-def>
+ <keyword-def name="black">
+ <keyword-value>black</keyword-value>
+ </keyword-def>
+ <keyword-def name="blink">
+ <keyword-value>blink</keyword-value>
+ </keyword-def>
+ <keyword-def name="block">
+ <keyword-value>block</keyword-value>
+ </keyword-def>
+ <keyword-def name="blue">
+ <keyword-value>blue</keyword-value>
+ </keyword-def>
+ <keyword-def name="bold">
+ <keyword-value>bold</keyword-value>
+ </keyword-def>
+ <keyword-def name="bolder">
+ <keyword-value>bolder</keyword-value>
+ </keyword-def>
+ <keyword-def name="both">
+ <keyword-value>both</keyword-value>
+ </keyword-def>
+ <keyword-def name="bottom">
+ <keyword-value>bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="capitalize">
+ <keyword-value>capitalize</keyword-value>
+ </keyword-def>
+ <keyword-def name="center">
+ <keyword-value>center</keyword-value>
+ </keyword-def>
+ <keyword-def name="circle">
+ <keyword-value>circle</keyword-value>
+ </keyword-def>
+ <keyword-def name="cursive">
+ <keyword-value>cursive</keyword-value>
+ </keyword-def>
+ <keyword-def name="dashed">
+ <keyword-value>dashed</keyword-value>
+ </keyword-def>
+ <keyword-def name="decimal">
+ <keyword-value>decimal</keyword-value>
+ </keyword-def>
+ <keyword-def name="disc">
+ <keyword-value>disc</keyword-value>
+ </keyword-def>
+ <keyword-def name="dotted">
+ <keyword-value>dotted</keyword-value>
+ </keyword-def>
+ <keyword-def name="double">
+ <keyword-value>double</keyword-value>
+ </keyword-def>
+ <keyword-def name="fantasy">
+ <keyword-value>fantasy</keyword-value>
+ </keyword-def>
+ <keyword-def name="fixed">
+ <keyword-value>fixed</keyword-value>
+ </keyword-def>
+ <keyword-def name="fuchsia">
+ <keyword-value>fuchsia</keyword-value>
+ </keyword-def>
+ <keyword-def name="gray">
+ <keyword-value>gray</keyword-value>
+ </keyword-def>
+ <keyword-def name="green">
+ <keyword-value>green</keyword-value>
+ </keyword-def>
+ <keyword-def name="groove">
+ <keyword-value>groove</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline">
+ <keyword-value>inline</keyword-value>
+ </keyword-def>
+ <keyword-def name="inset">
+ <keyword-value>inset</keyword-value>
+ </keyword-def>
+ <keyword-def name="inside">
+ <keyword-value>inside</keyword-value>
+ </keyword-def>
+ <keyword-def name="italic">
+ <keyword-value>italic</keyword-value>
+ </keyword-def>
+ <keyword-def name="justify">
+ <keyword-value>justify</keyword-value>
+ </keyword-def>
+ <keyword-def name="large">
+ <keyword-value>large</keyword-value>
+ </keyword-def>
+ <keyword-def name="larger">
+ <keyword-value>larger</keyword-value>
+ </keyword-def>
+ <keyword-def name="left">
+ <keyword-value>left</keyword-value>
+ </keyword-def>
+ <keyword-def name="lighter">
+ <keyword-value>lighter</keyword-value>
+ </keyword-def>
+ <keyword-def name="lime">
+ <keyword-value>lime</keyword-value>
+ </keyword-def>
+ <keyword-def name="line-through">
+ <keyword-value>line-through</keyword-value>
+ </keyword-def>
+ <keyword-def name="list-item">
+ <keyword-value>list-item</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-alpha">
+ <keyword-value>lower-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-roman">
+ <keyword-value>lower-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="lowercase">
+ <keyword-value>lowercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="maroon">
+ <keyword-value>maroon</keyword-value>
+ </keyword-def>
+ <keyword-def name="medium">
+ <keyword-value>medium</keyword-value>
+ </keyword-def>
+ <keyword-def name="middle">
+ <keyword-value>middle</keyword-value>
+ </keyword-def>
+ <keyword-def name="monospace">
+ <keyword-value>monospace</keyword-value>
+ </keyword-def>
+ <keyword-def name="navy">
+ <keyword-value>navy</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-repeat">
+ <keyword-value>no-repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="none">
+ <keyword-value>none</keyword-value>
+ </keyword-def>
+ <keyword-def name="normal">
+ <keyword-value>normal</keyword-value>
+ </keyword-def>
+ <keyword-def name="nowrap">
+ <keyword-value>nowrap</keyword-value>
+ </keyword-def>
+ <keyword-def name="oblique">
+ <keyword-value>oblique</keyword-value>
+ </keyword-def>
+ <keyword-def name="olive">
+ <keyword-value>olive</keyword-value>
+ </keyword-def>
+ <keyword-def name="outset">
+ <keyword-value>outset</keyword-value>
+ </keyword-def>
+ <keyword-def name="outside">
+ <keyword-value>outside</keyword-value>
+ </keyword-def>
+ <keyword-def name="overline">
+ <keyword-value>overline</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre">
+ <keyword-value>pre</keyword-value>
+ </keyword-def>
+ <keyword-def name="purple">
+ <keyword-value>purple</keyword-value>
+ </keyword-def>
+ <keyword-def name="red">
+ <keyword-value>red</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat">
+ <keyword-value>repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-x">
+ <keyword-value>repeat-x</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-y">
+ <keyword-value>repeat-y</keyword-value>
+ </keyword-def>
+ <keyword-def name="ridge">
+ <keyword-value>ridge</keyword-value>
+ </keyword-def>
+ <keyword-def name="right">
+ <keyword-value>right</keyword-value>
+ </keyword-def>
+ <keyword-def name="sans-serif">
+ <keyword-value>sans-serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="scroll">
+ <keyword-value>scroll</keyword-value>
+ </keyword-def>
+ <keyword-def name="serif">
+ <keyword-value>serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="silver">
+ <keyword-value>silver</keyword-value>
+ </keyword-def>
+ <keyword-def name="small">
+ <keyword-value>small</keyword-value>
+ </keyword-def>
+ <keyword-def name="small-caps">
+ <keyword-value>small-caps</keyword-value>
+ </keyword-def>
+ <keyword-def name="smaller">
+ <keyword-value>smaller</keyword-value>
+ </keyword-def>
+ <keyword-def name="solid">
+ <keyword-value>solid</keyword-value>
+ </keyword-def>
+ <keyword-def name="square">
+ <keyword-value>square</keyword-value>
+ </keyword-def>
+ <keyword-def name="sub">
+ <keyword-value>sub</keyword-value>
+ </keyword-def>
+ <keyword-def name="super">
+ <keyword-value>super</keyword-value>
+ </keyword-def>
+ <keyword-def name="teal">
+ <keyword-value>teal</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-top">
+ <keyword-value>text-top</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-bottom">
+ <keyword-value>text-bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="thick">
+ <keyword-value>thick</keyword-value>
+ </keyword-def>
+ <keyword-def name="thin">
+ <keyword-value>thin</keyword-value>
+ </keyword-def>
+ <keyword-def name="top">
+ <keyword-value>top</keyword-value>
+ </keyword-def>
+ <keyword-def name="transparent">
+ <keyword-value>transparent</keyword-value>
+ </keyword-def>
+ <keyword-def name="underline">
+ <keyword-value>underline</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-alpha">
+ <keyword-value>upper-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-roman">
+ <keyword-value>upper-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="uppercase">
+ <keyword-value>uppercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="white">
+ <keyword-value>white</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-large">
+ <keyword-value>x-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-small">
+ <keyword-value>x-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-small">
+ <keyword-value>xx-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-large">
+ <keyword-value>xx-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="yellow">
+ <keyword-value>yellow</keyword-value>
+ </keyword-def>
+</css-profile>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css2.xml b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css2.xml
new file mode 100644
index 0000000..3031984
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css2.xml
@@ -0,0 +1,2292 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!--<!DOCTYPE css-profile SYSTEM "css-profile.dtd" >-->
+<css-profile>
+ <stylesheet-def>
+ <description>%css2.stylesheet-def.description</description>
+ <charset-rule/>
+ <import-rule/>
+ <page-rule/>
+ <media-rule/>
+ <fontface-rule/>
+ <style-rule/>
+ </stylesheet-def>
+
+ <charset-rule-def>
+ </charset-rule-def>
+ <import-rule-def>
+ </import-rule-def>
+ <media-rule-def>
+ </media-rule-def>
+
+ <page-rule-def>
+ <pseudo-class name="left"/>
+ <pseudo-class name="right"/>
+ <pseudo-class name="first"/>
+ <property name="size"/>
+ <property name="marks"/>
+ <property name="page-break-after"/>
+ <property name="page-break-before"/>
+ <property name="page-break-inside"/>
+ <property name="orphans"/>
+ <property name="widows"/>
+ </page-rule-def>
+
+ <fontface-rule-def>
+ <descriptor name="ascent"/>
+ <descriptor name="baseline"/>
+ <descriptor name="bbox"/>
+ <descriptor name="cap-height"/>
+ <descriptor name="centerline"/>
+ <descriptor name="definition-src"/>
+ <descriptor name="descent"/>
+ <descriptor name="font-family"/>
+ <descriptor name="font-size"/>
+ <descriptor name="font-stretch"/>
+ <descriptor name="font-style"/>
+ <descriptor name="font-variant"/>
+ <descriptor name="font-weight"/>
+ <descriptor name="mathline"/>
+ <descriptor name="panose-1"/>
+ <descriptor name="slope"/>
+ <descriptor name="slope"/>
+ <descriptor name="src"/>
+ <descriptor name="stemh"/>
+ <descriptor name="stemv"/>
+ <descriptor name="topline"/>
+ <descriptor name="unicode-range"/>
+ <descriptor name="units-per-em"/>
+ <descriptor name="widths"/>
+ <descriptor name="x-height"/>
+ </fontface-rule-def>
+
+ <!-- Which properties can style rule include ? -->
+
+ <style-rule-def>
+ <selector-expression name="descendant"/>
+ <selector-expression name="child"/>
+ <selector-expression name="adjacent"/>
+ <selector-expression name="universal"/>
+ <selector-expression name="attribute"/>
+ <pseudo-element name="first-line"/>
+ <pseudo-element name="first-letter"/>
+ <pseudo-element name="before"/>
+ <pseudo-element name="after"/>
+ <pseudo-class name="first-child"/>
+ <pseudo-class name="link"/>
+ <pseudo-class name="visited"/>
+ <pseudo-class name="hover"/>
+ <pseudo-class name="active"/>
+ <pseudo-class name="focus"/>
+ <pseudo-class name="lang"/>
+ <property name="azimuth"/>
+ <property name="background"/>
+ <property name="background-attachment"/>
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-position"/>
+ <property name="background-repeat"/>
+ <property name="border"/>
+ <property name="border-collapse"/>
+ <property name="border-color"/>
+ <property name="border-spacing"/>
+ <property name="border-style"/>
+ <property name="border-top"/>
+ <property name="border-right"/>
+ <property name="border-bottom"/>
+ <property name="border-left"/>
+ <property name="border-top-color"/>
+ <property name="border-right-color"/>
+ <property name="border-bottom-color"/>
+ <property name="border-left-color"/>
+ <property name="border-top-style"/>
+ <property name="border-right-style"/>
+ <property name="border-bottom-style"/>
+ <property name="border-left-style"/>
+ <property name="border-top-width"/>
+ <property name="border-right-width"/>
+ <property name="border-bottom-width"/>
+ <property name="border-left-width"/>
+ <property name="border-width"/>
+ <property name="bottom"/>
+ <property name="caption-side"/>
+ <property name="clear"/>
+ <property name="clip"/>
+ <property name="color"/>
+ <property name="content"/>
+ <property name="counter-increment"/>
+ <property name="counter-reset"/>
+ <property name="cue"/>
+ <property name="cue-after"/>
+ <property name="cue-before"/>
+ <property name="cursor"/>
+ <property name="direction"/>
+ <property name="display"/>
+ <property name="elevation"/>
+ <property name="empty-cells"/>
+ <property name="float"/>
+ <property name="font"/>
+ <property name="font-family"/>
+ <property name="font-size"/>
+ <property name="font-size-adjust"/>
+ <property name="font-stretch"/>
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="height"/>
+ <property name="left"/>
+ <property name="letter-spacing"/>
+ <property name="line-height"/>
+ <property name="list-style"/>
+ <property name="list-style-image"/>
+ <property name="list-style-position"/>
+ <property name="list-style-type"/>
+ <property name="margin"/>
+ <property name="margin-top"/>
+ <property name="margin-right"/>
+ <property name="margin-bottom"/>
+ <property name="margin-left"/>
+ <property name="marker-offset"/>
+ <property name="marks"/>
+ <property name="max-height"/>
+ <property name="max-width"/>
+ <property name="min-height"/>
+ <property name="min-width"/>
+ <property name="orphans"/>
+ <property name="outline"/>
+ <property name="outline-color"/>
+ <property name="outline-style"/>
+ <property name="outline-width"/>
+ <property name="overflow"/>
+ <property name="padding"/>
+ <property name="padding-top"/>
+ <property name="padding-right"/>
+ <property name="padding-bottom"/>
+ <property name="padding-left"/>
+ <property name="page"/>
+ <property name="page-break-after"/>
+ <property name="page-break-before"/>
+ <property name="page-break-inside"/>
+ <property name="pause"/>
+ <property name="pause-after"/>
+ <property name="pause-before"/>
+ <property name="pitch"/>
+ <property name="pitch-range"/>
+ <property name="play-during"/>
+ <property name="position"/>
+ <property name="quotes"/>
+ <property name="richness"/>
+ <property name="right"/>
+ <property name="size"/>
+ <property name="speak"/>
+ <property name="speak-header"/>
+ <property name="speak-numeral"/>
+ <property name="speak-punctuation"/>
+ <property name="speech-rate"/>
+ <property name="stress"/>
+ <property name="table-layout"/>
+ <property name="text-align"/>
+ <property name="text-decoration"/>
+ <property name="text-indent"/>
+ <property name="text-shadow"/>
+ <property name="text-transform"/>
+ <property name="top"/>
+ <property name="unicode-bidi"/>
+ <property name="vertical-align"/>
+ <property name="visibility"/>
+ <property name="voice-family"/>
+ <property name="volume"/>
+ <property name="white-space"/>
+ <property name="widows"/>
+ <property name="width"/>
+ <property name="word-spacing"/>
+ <property name="z-index"/>
+ </style-rule-def>
+
+ <pseudo-class-def name="first-child">
+ <selector-value>first-child</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="link">
+ <selector-value>link</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="visited">
+ <selector-value>visited</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="hover">
+ <selector-value>hover</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="active">
+ <selector-value>active</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="focus">
+ <selector-value>focus</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="lang">
+ <selector-value>lang</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="left">
+ <selector-value>left</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="right">
+ <selector-value>right</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="first">
+ <selector-value>first</selector-value>
+ </pseudo-class-def>
+
+ <pseudo-element-def name="first-line">
+ <selector-value>first-line</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="first-letter">
+ <selector-value>first-letter</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="before">
+ <selector-value>before</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="after">
+ <selector-value>after</selector-value>
+ </pseudo-element-def>
+
+ <!-- property definition -->
+
+ <property-def name="azimuth"
+ inherited="yes" mediagroup="aural" category="aural">
+ <description>This provides spatial audio property for aural
+ presentation</description>
+ <number name="angle"/>
+ <keyword name="left-side"/>
+ <keyword name="far-left"/>
+ <keyword name="left"/>
+ <keyword name="center-left"/>
+ <keyword name="center"/>
+ <keyword name="center-right"/>
+ <keyword name="right"/>
+ <keyword name="far-right"/>
+ <keyword name="right-side"/>
+ <keyword name="behind"/>
+ <keyword name="leftwards"/>
+ <keyword name="rightwards"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-repeat"/>
+ <property name="background-attachment"/>
+ <property name="background-position"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-attachment"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <keyword name="scroll"/>
+ <keyword name="fixed"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-color"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <container name="color"/>
+ <keyword name="transparent"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-image"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-position"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="top"/>
+ <keyword name="center"/>
+ <keyword name="bottom"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-repeat"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <keyword name="repeat"/>
+ <keyword name="repeat-x"/>
+ <keyword name="repeat-y"/>
+ <keyword name="no-repeat"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-collapse"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="collapse"/>
+ <keyword name="separate"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="transparent"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-spacing"
+ inherited="yes" mediagroup="visual" category="tables">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-top-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-right-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-bottom-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-left-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="bottom"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="caption-side"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="top"/>
+ <keyword name="bottom"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="clear"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="none"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="both"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="clip"
+ inherited="no" mediagroup="visual" category="visual">
+ <container name="shape"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="color"
+ inherited="yes" mediagroup="visual" category="colorandbackground">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="content"
+ inherited="no" mediagroup="all" category="content">
+ <string name="any"/>
+ <function name="uri"/>
+ <function name="counter"/>
+ <function name="attr"/>
+ <keyword name="open-quote"/>
+ <keyword name="close-quote"/>
+ <keyword name="none"/>
+ <keyword name="normal"/>
+ <keyword name="no-open-quote"/>
+ <keyword name="no-close-quote"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="counter-increment"
+ inherited="no" mediagroup="all" category="content">
+ <string name="counter-identifier"/>
+ <number name="integer"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="counter-reset"
+ inherited="no" mediagroup="all" category="content">
+ <string name="counter-identifier"/>
+ <number name="integer"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue"
+ inherited="no" mediagroup="aural" category="aural">
+ <property name="cue-before"/>
+ <property name="cue-after"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue-after"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue-before"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cursor"
+ inherited="yes" mediagroup="visual,interactive" category="ui">
+ <function name="uri"/>
+ <keyword name="auto"/>
+ <keyword name="crosshair"/>
+ <keyword name="default"/>
+ <keyword name="pointer"/>
+ <keyword name="progress"/>
+ <keyword name="move"/>
+ <keyword name="e-resize"/>
+ <keyword name="ne-resize"/>
+ <keyword name="nw-resize"/>
+ <keyword name="n-resize"/>
+ <keyword name="se-resize"/>
+ <keyword name="sw-resize"/>
+ <keyword name="s-resize"/>
+ <keyword name="w-resize"/>
+ <keyword name="text"/>
+ <keyword name="wait"/>
+ <keyword name="help"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="direction"
+ inherited="yes" mediagroup="visual" category="visual">
+ <keyword name="ltr"/>
+ <keyword name="rtl"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="display"
+ inherited="no" mediagroup="all" category="visual">
+ <keyword name="inline"/>
+ <keyword name="inline-block"/>
+ <keyword name="block"/>
+ <keyword name="list-item"/>
+ <keyword name="run-in"/>
+ <keyword name="compact"/>
+ <keyword name="marker"/>
+ <keyword name="table"/>
+ <keyword name="inline-table"/>
+ <keyword name="table-row-group"/>
+ <keyword name="table-header-group"/>
+ <keyword name="table-footer-group"/>
+ <keyword name="table-row"/>
+ <keyword name="table-column-group"/>
+ <keyword name="table-column"/>
+ <keyword name="table-cell"/>
+ <keyword name="table-caption"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="elevation"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="angle"/>
+ <keyword name="below"/>
+ <keyword name="level"/>
+ <keyword name="above"/>
+ <keyword name="higher"/>
+ <keyword name="lower"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="empty-cells"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="show"/>
+ <keyword name="hide"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="float"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font"
+ inherited="yes" mediagroup="visual" category="font">
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="font-size"/>
+ <property name="line-height"/>
+ <property name="font-family"/>
+ <keyword name="caption"/>
+ <keyword name="icon"/>
+ <keyword name="menu"/>
+ <keyword name="message-box"/>
+ <keyword name="small-caption"/>
+ <keyword name="status-bar"/>
+ <keyword name="inherit"/>
+ <separator name="slash"/>
+ </property-def>
+ <property-def name="font-family"
+ inherited="yes" mediagroup="visual" category="font">
+ <string name="family-name"/>
+ <container name="generic-family"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="font-size"
+ inherited="yes" mediagroup="visual" category="font">
+ <container name="absolute-size"/>
+ <container name="relative-size"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-size-adjust"
+ inherited="yes" mediagroup="visual" category="font">
+ <number name="number"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-stretch"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="wider"/>
+ <keyword name="narrower"/>
+ <keyword name="ultra-condensed"/>
+ <keyword name="extra-condensed"/>
+ <keyword name="condensed"/>
+ <keyword name="semi-condensed"/>
+ <keyword name="semi-expanded"/>
+ <keyword name="expanded"/>
+ <keyword name="extra-expanded"/>
+ <keyword name="ultra-expanded"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-style"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="italic"/>
+ <keyword name="oblique"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-variant"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="small-caps"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-weight"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="bold"/>
+ <keyword name="bolder"/>
+ <keyword name="lighter"/>
+ <keyword name="100"/>
+ <keyword name="200"/>
+ <keyword name="300"/>
+ <keyword name="400"/>
+ <keyword name="500"/>
+ <keyword name="600"/>
+ <keyword name="700"/>
+ <keyword name="800"/>
+ <keyword name="900"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="left"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="letter-spacing"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="line-height"
+ inherited="yes" mediagroup="visual" category="visual">
+ <keyword name="normal"/>
+ <number name="number"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style"
+ inherited="yes" mediagroup="visual" category="content">
+ <property name="list-style-type"/>
+ <property name="list-style-position"/>
+ <property name="list-style-image"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-image"
+ inherited="yes" mediagroup="visual" category="content">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-position"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="inside"/>
+ <keyword name="outside"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-type"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="decimal-leading-zero"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-greek"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="lower-latin"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="upper-latin"/>
+ <keyword name="hebrew"/>
+ <keyword name="armenian"/>
+ <keyword name="georgian"/>
+ <keyword name="cjk-ideographic"/>
+ <keyword name="hiragana"/>
+ <keyword name="katakana"/>
+ <keyword name="hiragana-iroha"/>
+ <keyword name="katakana-iroha"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-top"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-right"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-left"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="marker-offset"
+ inherited="no" mediagroup="visual" category="content">
+ <number name="length"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="marks"
+ inherited="na" mediagroup="visual,paged" category="page">
+ <keyword name="crop"/>
+ <keyword name="cross"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="max-height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="max-width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="min-height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="min-width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="orphans"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <property name="outline-color"/>
+ <property name="outline-style"/>
+ <property name="outline-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-color"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="color"/>
+ <keyword name="invert"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-style"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-width"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="overflow"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="visible"/>
+ <keyword name="hidden"/>
+ <keyword name="scroll"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-top"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-right"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-left"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <string name="page-identifier"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="page-break-after"
+ inherited="no" mediagroup="visual,paged" category="page">
+ <keyword name="auto"/>
+ <keyword name="always"/>
+ <keyword name="avoid"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page-break-before"
+ inherited="no" mediagroup="visual,paged" category="page">
+ <keyword name="auto"/>
+ <keyword name="always"/>
+ <keyword name="avoid"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page-break-inside"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <keyword name="avoid"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause-after"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause-before"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pitch"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="frequency"/>
+ <keyword name="x-low"/>
+ <keyword name="low"/>
+ <keyword name="medium"/>
+ <keyword name="high"/>
+ <keyword name="x-high"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pitch-range"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="play-during"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="mix"/>
+ <keyword name="repeat"/>
+ <keyword name="auto"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="position"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="static"/>
+ <keyword name="relative"/>
+ <keyword name="absolute"/>
+ <keyword name="fixed"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="quotes"
+ inherited="yes" mediagroup="visual" category="content">
+ <string name="any"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="richness"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="right"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="size"
+ inherited="na" mediagroup="visual,paged" category="page">
+ <number name="length"/>
+ <keyword name="auto"/>
+ <keyword name="portrait"/>
+ <keyword name="landscape"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="normal"/>
+ <keyword name="none"/>
+ <keyword name="spell-out"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-header"
+ inherited="yes" mediagroup="aural" category="tables">
+ <keyword name="once"/>
+ <keyword name="always"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-numeral"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="digits"/>
+ <keyword name="continuous"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-punctuation"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="code"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speech-rate"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="x-slow"/>
+ <keyword name="slow"/>
+ <keyword name="medium"/>
+ <keyword name="fast"/>
+ <keyword name="x-fast"/>
+ <keyword name="faster"/>
+ <keyword name="slower"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="stress"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="table-layout"
+ inherited="no" mediagroup="visual" category="tables">
+ <keyword name="auto"/>
+ <keyword name="fixed"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-align"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="center"/>
+ <keyword name="justify"/>
+ <string name="any"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-decoration"
+ inherited="no" mediagroup="visual" category="text">
+ <keyword name="none"/>
+ <keyword name="underline"/>
+ <keyword name="overline"/>
+ <keyword name="line-through"/>
+ <keyword name="blink"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-indent"
+ inherited="yes" mediagroup="visual" category="text">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-shadow"
+ inherited="no" mediagroup="visual" category="text">
+ <keyword name="none"/>
+ <container name="color"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="text-transform"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="capitalize"/>
+ <keyword name="uppercase"/>
+ <keyword name="lowercase"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="top"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="unicode-bidi"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="normal"/>
+ <keyword name="embed"/>
+ <keyword name="bidi-override"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="vertical-align"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="baseline"/>
+ <keyword name="sub"/>
+ <keyword name="super"/>
+ <keyword name="top"/>
+ <keyword name="text-top"/>
+ <keyword name="middle"/>
+ <keyword name="bottom"/>
+ <keyword name="text-bottom"/>
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="visibility"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="visible"/>
+ <keyword name="hidden"/>
+ <keyword name="collapse"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="voice-family"
+ inherited="yes" mediagroup="aural" category="aural">
+ <string name="specific-voice"/>
+ <container name="generic-voice"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="volume"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <number name="percentage"/>
+ <keyword name="silent"/>
+ <keyword name="x-soft"/>
+ <keyword name="soft"/>
+ <keyword name="medium"/>
+ <keyword name="loud"/>
+ <keyword name="x-loud"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="white-space"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <keyword name="pre"/>
+ <keyword name="pre-line"/>
+ <keyword name="pre-wrap"/>
+ <keyword name="nowrap"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="widows"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="word-spacing"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="z-index"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="auto"/>
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+
+ <!-- descriptor definition : These are for @font-face -->
+
+ <descriptor-def name="ascent">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="baseline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="bbox">
+ <number name="number"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="cap-height">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="centerline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="definition-src">
+ <function name="uri"/>
+ </descriptor-def>
+ <descriptor-def name="descent">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="font-family">
+ <string name="family-name"/>
+ <container name="generic-family"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-size">
+ <keyword name="all"/>
+ <number name="length"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-stretch">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="ultra-condensed"/>
+ <keyword name="extra-condensed"/>
+ <keyword name="condensed"/>
+ <keyword name="semi-condensed"/>
+ <keyword name="semi-expanded"/>
+ <keyword name="expanded"/>
+ <keyword name="extra-expanded"/>
+ <keyword name="ultra-expanded"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-style">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="italic"/>
+ <keyword name="oblique"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-variant">
+ <keyword name="normal"/>
+ <keyword name="small-caps"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-weight">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="bold"/>
+ <keyword name="100"/>
+ <keyword name="200"/>
+ <keyword name="300"/>
+ <keyword name="400"/>
+ <keyword name="500"/>
+ <keyword name="600"/>
+ <keyword name="700"/>
+ <keyword name="800"/>
+ <keyword name="900"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="mathline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="panose-1">
+ <number name="integer"/>
+ </descriptor-def>
+ <descriptor-def name="slope">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="src">
+ <function name="uri"/>
+ <function name="format"/>
+ <container name="font-face-name"/>
+ </descriptor-def>
+ <descriptor-def name="stemh">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="stemv">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="topline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="unicode-range">
+ <string name="urange"/>
+ </descriptor-def>
+ <descriptor-def name="units-per-em">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="widths">
+ <string name="urange"/>
+ <number name="length"/>
+ </descriptor-def>
+ <descriptor-def name="x-height">
+ <number name="number"/>
+ </descriptor-def>
+
+ <!-- container definition : Container is the lump of values.
+ It can be used like macros. -->
+ <container-def name="absolute-size">
+ <keyword name="xx-small"/>
+ <keyword name="x-small"/>
+ <keyword name="small"/>
+ <keyword name="medium"/>
+ <keyword name="large"/>
+ <keyword name="x-large"/>
+ <keyword name="xx-large"/>
+ </container-def>
+ <container-def name="border-style">
+ <keyword name="none"/>
+ <keyword name="hidden"/>
+ <keyword name="dotted"/>
+ <keyword name="dashed"/>
+ <keyword name="solid"/>
+ <keyword name="double"/>
+ <keyword name="groove"/>
+ <keyword name="ridge"/>
+ <keyword name="inset"/>
+ <keyword name="outset"/>
+ </container-def>
+ <container-def name="border-width">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </container-def>
+ <container-def name="color">
+ <keyword name="aqua"/>
+ <keyword name="black"/>
+ <keyword name="blue"/>
+ <keyword name="fuchsia"/>
+ <keyword name="gray"/>
+ <keyword name="green"/>
+ <keyword name="lime"/>
+ <keyword name="maroon"/>
+ <keyword name="navy"/>
+ <keyword name="olive"/>
+ <keyword name="orange"/>
+ <keyword name="purple"/>
+ <keyword name="red"/>
+ <keyword name="silver"/>
+ <keyword name="teal"/>
+ <keyword name="white"/>
+ <keyword name="yellow"/>
+ <container name="system-color"/>
+ <function name="rgb"/>
+ <number name="hash"/>
+ </container-def>
+ <container-def name="generic-family">
+ <keyword name="serif"/>
+ <keyword name="sans-serif"/>
+ <keyword name="cursive"/>
+ <keyword name="fantasy"/>
+ <keyword name="monospace"/>
+ </container-def>
+ <container-def name="font-face-name">
+ <function name="local"/>
+ </container-def>
+ <container-def name="generic-voice">
+ <keyword name="male"/>
+ <keyword name="female"/>
+ <keyword name="child"/>
+ </container-def>
+ <container-def name="margin-width">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </container-def>
+ <container-def name="padding-width">
+ <number name="length"/>
+ <number name="percentage"/>
+ </container-def>
+ <container-def name="relative-size">
+ <keyword name="smaller"/>
+ <keyword name="larger"/>
+ </container-def>
+ <container-def name="shape">
+ <function name="rect"/>
+ </container-def>
+ <container-def name="system-color">
+ <keyword name="ActiveBorder"/>
+ <keyword name="ActiveCaption"/>
+ <keyword name="AppWorkspace"/>
+ <keyword name="Background"/>
+ <keyword name="ButtonFace"/>
+ <keyword name="ButtonHighlight"/>
+ <keyword name="ButtonShadow"/>
+ <keyword name="ButtonText"/>
+ <keyword name="CaptionText"/>
+ <keyword name="GrayText"/>
+ <keyword name="Highlight"/>
+ <keyword name="HighlightText"/>
+ <keyword name="InactiveBorder"/>
+ <keyword name="InactiveCaption"/>
+ <keyword name="InactiveCaptionText"/>
+ <keyword name="InfoBackground"/>
+ <keyword name="InfoText"/>
+ <keyword name="Menu"/>
+ <keyword name="MenuText"/>
+ <keyword name="Scrollbar"/>
+ <keyword name="ThreeDDarkShadow"/>
+ <keyword name="ThreeDFace"/>
+ <keyword name="ThreeDHighlight"/>
+ <keyword name="ThreeDLightShadow"/>
+ <keyword name="ThreeDShadow"/>
+ <keyword name="Window"/>
+ <keyword name="WindowFrame"/>
+ <keyword name="WindowText"/>
+ </container-def>
+
+ <!-- category definition : This is used to categorize properties
+ in Properties View. -->
+ <category-def name="aural">
+ <caption>%css2.category-def.aural.caption</caption>
+ </category-def>
+ <category-def name="box">
+ <caption>%css2.category-def.box.caption</caption>
+ </category-def>
+ <category-def name="colorandbackground">
+ <caption>%css2.category-def.colorandbackground.caption</caption>
+ </category-def>
+ <category-def name="content">
+ <caption>%css2.category-def.content.caption</caption>
+ </category-def>
+ <category-def name="font">
+ <caption>%css2.category-def.font.caption</caption>
+ </category-def>
+ <category-def name="page">
+ <caption>%css2.category-def.page.caption</caption>
+ </category-def>
+ <category-def name="tables">
+ <caption>%css2.category-def.tables.caption</caption>
+ </category-def>
+ <category-def name="text">
+ <caption>%css2.category-def.text.caption</caption>
+ </category-def>
+ <category-def name="ui">
+ <caption>%css2.category-def.ui.caption</caption>
+ </category-def>
+ <category-def name="visual">
+<!-- <caption>%css2.category-def.visual.caption</caption>-->
+ <caption>%css2.category-def.visual.caption</caption>
+ </category-def>
+
+ <!-- function definition -->
+ <function-def name="attr">
+ <function-value>attr</function-value>
+ </function-def>
+ <function-def name="counter">
+ <function-value>counter</function-value>
+ </function-def>
+ <function-def name="rect">
+ <function-value>rect</function-value>
+ </function-def>
+ <function-def name="rgb">
+ <function-value>rgb</function-value>
+ </function-def>
+ <function-def name="uri">
+ <function-value>url</function-value>
+ </function-def>
+ <function-def name="format">
+ <function-value>format</function-value>
+ </function-def>
+ <function-def name="local">
+ <function-value>local</function-value>
+ </function-def>
+
+ <!-- number definition : What unit types be acceptable for each
+ number type? -->
+ <number-def name="angle">
+ <unit name="deg"/>
+ <unit name="grad"/>
+ <unit name="rad"/>
+ </number-def>
+ <number-def name="frequency">
+ <unit name="hz"/>
+ <unit name="khz"/>
+ </number-def>
+ <number-def name="hash">
+ <unit name="hash"/>
+ </number-def>
+ <number-def name="integer">
+ </number-def>
+ <number-def name="length">
+ <unit name="em"/>
+ <unit name="ex"/>
+ <unit name="px"/>
+ <unit name="in"/>
+ <unit name="cm"/>
+ <unit name="mm"/>
+ <unit name="pt"/>
+ <unit name="pc"/>
+ </number-def>
+ <number-def name="number">
+ </number-def>
+ <number-def name="percentage">
+ <unit name="percentage"/>
+ </number-def>
+ <number-def name="time">
+ <unit name="ms"/>
+ <unit name="s"/>
+ </number-def>
+
+ <unit-def name="cm">
+ <unit-value>cm</unit-value>
+ </unit-def>
+ <unit-def name="deg">
+ <unit-value>deg</unit-value>
+ </unit-def>
+ <unit-def name="em">
+ <unit-value>em</unit-value>
+ </unit-def>
+ <unit-def name="ex">
+ <unit-value>ex</unit-value>
+ </unit-def>
+ <unit-def name="grad">
+ <unit-value>grad</unit-value>
+ </unit-def>
+ <unit-def name="hash">
+ <unit-value>#</unit-value>
+ </unit-def>
+ <unit-def name="hz">
+ <unit-value>Hz</unit-value>
+ </unit-def>
+ <unit-def name="in">
+ <unit-value>in</unit-value>
+ </unit-def>
+ <unit-def name="khz">
+ <unit-value>kHz</unit-value>
+ </unit-def>
+ <unit-def name="mm">
+ <unit-value>mm</unit-value>
+ </unit-def>
+ <unit-def name="ms">
+ <unit-value>ms</unit-value>
+ </unit-def>
+ <unit-def name="pc">
+ <unit-value>pc</unit-value>
+ </unit-def>
+ <unit-def name="percentage">
+ <unit-value>%</unit-value>
+ </unit-def>
+ <unit-def name="pt">
+ <unit-value>pt</unit-value>
+ </unit-def>
+ <unit-def name="px">
+ <unit-value>px</unit-value>
+ </unit-def>
+ <unit-def name="rad">
+ <unit-value>rad</unit-value>
+ </unit-def>
+ <unit-def name="s">
+ <unit-value>s</unit-value>
+ </unit-def>
+
+ <!-- keywords : string constants (this is last part..) -->
+ <keyword-def name="100">
+ <keyword-value>100</keyword-value>
+ </keyword-def>
+ <keyword-def name="200">
+ <keyword-value>200</keyword-value>
+ </keyword-def>
+ <keyword-def name="300">
+ <keyword-value>300</keyword-value>
+ </keyword-def>
+ <keyword-def name="400">
+ <keyword-value>400</keyword-value>
+ </keyword-def>
+ <keyword-def name="500">
+ <keyword-value>500</keyword-value>
+ </keyword-def>
+ <keyword-def name="600">
+ <keyword-value>600</keyword-value>
+ </keyword-def>
+ <keyword-def name="700">
+ <keyword-value>700</keyword-value>
+ </keyword-def>
+ <keyword-def name="800">
+ <keyword-value>800</keyword-value>
+ </keyword-def>
+ <keyword-def name="900">
+ <keyword-value>900</keyword-value>
+ </keyword-def>
+ <keyword-def name="above">
+ <keyword-value>above</keyword-value>
+ </keyword-def>
+ <keyword-def name="absolute">
+ <keyword-value>absolute</keyword-value>
+ </keyword-def>
+ <keyword-def name="ActiveBorder">
+ <keyword-value>ActiveBorder</keyword-value>
+ </keyword-def>
+ <keyword-def name="ActiveCaption">
+ <keyword-value>ActiveCaption</keyword-value>
+ </keyword-def>
+ <keyword-def name="all">
+ <keyword-value>all</keyword-value>
+ </keyword-def>
+ <keyword-def name="always">
+ <keyword-value>always</keyword-value>
+ </keyword-def>
+ <keyword-def name="AppWorkspace">
+ <keyword-value>AppWorkspace</keyword-value>
+ </keyword-def>
+ <keyword-def name="aqua">
+ <keyword-value>aqua</keyword-value>
+ </keyword-def>
+ <keyword-def name="armenian">
+ <keyword-value>armenian</keyword-value>
+ </keyword-def>
+ <keyword-def name="auto">
+ <keyword-value>auto</keyword-value>
+ </keyword-def>
+ <keyword-def name="avoid">
+ <keyword-value>avoid</keyword-value>
+ </keyword-def>
+ <keyword-def name="Background">
+ <keyword-value>Background</keyword-value>
+ </keyword-def>
+ <keyword-def name="baseline">
+ <keyword-value>baseline</keyword-value>
+ </keyword-def>
+ <keyword-def name="behind">
+ <keyword-value>behind</keyword-value>
+ </keyword-def>
+ <keyword-def name="below">
+ <keyword-value>below</keyword-value>
+ </keyword-def>
+ <keyword-def name="bidi-override">
+ <keyword-value>bidi-override</keyword-value>
+ </keyword-def>
+ <keyword-def name="black">
+ <keyword-value>black</keyword-value>
+ </keyword-def>
+ <keyword-def name="blink">
+ <keyword-value>blink</keyword-value>
+ </keyword-def>
+ <keyword-def name="block">
+ <keyword-value>block</keyword-value>
+ </keyword-def>
+ <keyword-def name="blue">
+ <keyword-value>blue</keyword-value>
+ </keyword-def>
+ <keyword-def name="bold">
+ <keyword-value>bold</keyword-value>
+ </keyword-def>
+ <keyword-def name="bolder">
+ <keyword-value>bolder</keyword-value>
+ </keyword-def>
+ <keyword-def name="both">
+ <keyword-value>both</keyword-value>
+ </keyword-def>
+ <keyword-def name="bottom">
+ <keyword-value>bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonFace">
+ <keyword-value>ButtonFace</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonHighlight">
+ <keyword-value>ButtonHighlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonShadow">
+ <keyword-value>ButtonShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonText">
+ <keyword-value>ButtonText</keyword-value>
+ </keyword-def>
+ <keyword-def name="capitalize">
+ <keyword-value>capitalize</keyword-value>
+ </keyword-def>
+ <keyword-def name="caption">
+ <keyword-value>caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="CaptionText">
+ <keyword-value>CaptionText</keyword-value>
+ </keyword-def>
+ <keyword-def name="center">
+ <keyword-value>center</keyword-value>
+ </keyword-def>
+ <keyword-def name="center-left">
+ <keyword-value>center-left</keyword-value>
+ </keyword-def>
+ <keyword-def name="center-right">
+ <keyword-value>center-right</keyword-value>
+ </keyword-def>
+ <keyword-def name="child">
+ <keyword-value>child</keyword-value>
+ </keyword-def>
+ <keyword-def name="circle">
+ <keyword-value>circle</keyword-value>
+ </keyword-def>
+ <keyword-def name="cjk-ideographic">
+ <keyword-value>cjk-ideographic</keyword-value>
+ </keyword-def>
+ <keyword-def name="close-quote">
+ <keyword-value>close-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="code">
+ <keyword-value>code</keyword-value>
+ </keyword-def>
+ <keyword-def name="condensed">
+ <keyword-value>condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="collapse">
+ <keyword-value>collapse</keyword-value>
+ </keyword-def>
+ <keyword-def name="compact">
+ <keyword-value>compact</keyword-value>
+ </keyword-def>
+ <keyword-def name="continuous">
+ <keyword-value>continuous</keyword-value>
+ </keyword-def>
+ <keyword-def name="crop">
+ <keyword-value>crop</keyword-value>
+ </keyword-def>
+ <keyword-def name="cross">
+ <keyword-value>cross</keyword-value>
+ </keyword-def>
+ <keyword-def name="crosshair">
+ <keyword-value>crosshair</keyword-value>
+ </keyword-def>
+ <keyword-def name="cursive">
+ <keyword-value>cursive</keyword-value>
+ </keyword-def>
+ <keyword-def name="dashed">
+ <keyword-value>dashed</keyword-value>
+ </keyword-def>
+ <keyword-def name="decimal">
+ <keyword-value>decimal</keyword-value>
+ </keyword-def>
+ <keyword-def name="decimal-leading-zero">
+ <keyword-value>decimal-leading-zero</keyword-value>
+ </keyword-def>
+ <keyword-def name="default">
+ <keyword-value>default</keyword-value>
+ </keyword-def>
+ <keyword-def name="digits">
+ <keyword-value>digits</keyword-value>
+ </keyword-def>
+ <keyword-def name="disc">
+ <keyword-value>disc</keyword-value>
+ </keyword-def>
+ <keyword-def name="dotted">
+ <keyword-value>dotted</keyword-value>
+ </keyword-def>
+ <keyword-def name="double">
+ <keyword-value>double</keyword-value>
+ </keyword-def>
+ <keyword-def name="e-resize">
+ <keyword-value>e-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="embed">
+ <keyword-value>embed</keyword-value>
+ </keyword-def>
+ <keyword-def name="expanded">
+ <keyword-value>expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="extra-condensed">
+ <keyword-value>extra-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="extra-expanded">
+ <keyword-value>extra-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="fantasy">
+ <keyword-value>fantasy</keyword-value>
+ </keyword-def>
+ <keyword-def name="far-left">
+ <keyword-value>far-left</keyword-value>
+ </keyword-def>
+ <keyword-def name="far-right">
+ <keyword-value>far-right</keyword-value>
+ </keyword-def>
+ <keyword-def name="fast">
+ <keyword-value>fast</keyword-value>
+ </keyword-def>
+ <keyword-def name="faster">
+ <keyword-value>faster</keyword-value>
+ </keyword-def>
+ <keyword-def name="female">
+ <keyword-value>female</keyword-value>
+ </keyword-def>
+ <keyword-def name="fixed">
+ <keyword-value>fixed</keyword-value>
+ </keyword-def>
+ <keyword-def name="fuchsia">
+ <keyword-value>fuchsia</keyword-value>
+ </keyword-def>
+ <keyword-def name="georgian">
+ <keyword-value>georgian</keyword-value>
+ </keyword-def>
+ <keyword-def name="gray">
+ <keyword-value>gray</keyword-value>
+ </keyword-def>
+ <keyword-def name="GrayText">
+ <keyword-value>GrayText</keyword-value>
+ </keyword-def>
+ <keyword-def name="green">
+ <keyword-value>green</keyword-value>
+ </keyword-def>
+ <keyword-def name="groove">
+ <keyword-value>groove</keyword-value>
+ </keyword-def>
+ <keyword-def name="hebrew">
+ <keyword-value>hebrew</keyword-value>
+ </keyword-def>
+ <keyword-def name="help">
+ <keyword-value>help</keyword-value>
+ </keyword-def>
+ <keyword-def name="hidden">
+ <keyword-value>hidden</keyword-value>
+ </keyword-def>
+ <keyword-def name="hide">
+ <keyword-value>hide</keyword-value>
+ </keyword-def>
+ <keyword-def name="high">
+ <keyword-value>high</keyword-value>
+ </keyword-def>
+ <keyword-def name="Highlight">
+ <keyword-value>Highlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="HighlightText">
+ <keyword-value>HighlightText</keyword-value>
+ </keyword-def>
+ <keyword-def name="higher">
+ <keyword-value>higher</keyword-value>
+ </keyword-def>
+ <keyword-def name="hiragana">
+ <keyword-value>hiragana</keyword-value>
+ </keyword-def>
+ <keyword-def name="hiragana-iroha">
+ <keyword-value>hiragana-iroha</keyword-value>
+ </keyword-def>
+ <keyword-def name="icon">
+ <keyword-value>icon</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveBorder">
+ <keyword-value>InactiveBorder</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveCaption">
+ <keyword-value>InactiveCaption</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveCaptionText">
+ <keyword-value>InactiveCaptionText</keyword-value>
+ </keyword-def>
+ <keyword-def name="InfoBackground">
+ <keyword-value>InfoBackground</keyword-value>
+ </keyword-def>
+ <keyword-def name="InfoText">
+ <keyword-value>InfoText</keyword-value>
+ </keyword-def>
+ <keyword-def name="inherit">
+ <keyword-value>inherit</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline">
+ <keyword-value>inline</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline-block">
+ <keyword-value>inline-block</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline-table">
+ <keyword-value>inline-table</keyword-value>
+ </keyword-def>
+ <keyword-def name="inset">
+ <keyword-value>inset</keyword-value>
+ </keyword-def>
+ <keyword-def name="inside">
+ <keyword-value>inside</keyword-value>
+ </keyword-def>
+ <keyword-def name="invert">
+ <keyword-value>invert</keyword-value>
+ </keyword-def>
+ <keyword-def name="italic">
+ <keyword-value>italic</keyword-value>
+ </keyword-def>
+ <keyword-def name="justify">
+ <keyword-value>justify</keyword-value>
+ </keyword-def>
+ <keyword-def name="katakana">
+ <keyword-value>katakana</keyword-value>
+ </keyword-def>
+ <keyword-def name="katakana-iroha">
+ <keyword-value>katakana-iroha</keyword-value>
+ </keyword-def>
+ <keyword-def name="landscape">
+ <keyword-value>landscape</keyword-value>
+ </keyword-def>
+ <keyword-def name="large">
+ <keyword-value>large</keyword-value>
+ </keyword-def>
+ <keyword-def name="larger">
+ <keyword-value>larger</keyword-value>
+ </keyword-def>
+ <keyword-def name="left">
+ <keyword-value>left</keyword-value>
+ </keyword-def>
+ <keyword-def name="left-side">
+ <keyword-value>left-side</keyword-value>
+ </keyword-def>
+ <keyword-def name="leftwards">
+ <keyword-value>leftwards</keyword-value>
+ </keyword-def>
+ <keyword-def name="level">
+ <keyword-value>level</keyword-value>
+ </keyword-def>
+ <keyword-def name="lighter">
+ <keyword-value>lighter</keyword-value>
+ </keyword-def>
+ <keyword-def name="lime">
+ <keyword-value>lime</keyword-value>
+ </keyword-def>
+ <keyword-def name="line-through">
+ <keyword-value>line-through</keyword-value>
+ </keyword-def>
+ <keyword-def name="list-item">
+ <keyword-value>list-item</keyword-value>
+ </keyword-def>
+ <keyword-def name="loud">
+ <keyword-value>loud</keyword-value>
+ </keyword-def>
+ <keyword-def name="low">
+ <keyword-value>low</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower">
+ <keyword-value>lower</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-alpha">
+ <keyword-value>lower-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-greek">
+ <keyword-value>lower-greek</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-latin">
+ <keyword-value>lower-latin</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-roman">
+ <keyword-value>lower-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="lowercase">
+ <keyword-value>lowercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="ltr">
+ <keyword-value>ltr</keyword-value>
+ </keyword-def>
+ <keyword-def name="male">
+ <keyword-value>male</keyword-value>
+ </keyword-def>
+ <keyword-def name="marker">
+ <keyword-value>marker</keyword-value>
+ </keyword-def>
+ <keyword-def name="maroon">
+ <keyword-value>maroon</keyword-value>
+ </keyword-def>
+ <keyword-def name="medium">
+ <keyword-value>medium</keyword-value>
+ </keyword-def>
+ <keyword-def name="Menu">
+ <keyword-value>Menu</keyword-value>
+ </keyword-def>
+ <keyword-def name="MenuText">
+ <keyword-value>MenuText</keyword-value>
+ </keyword-def>
+ <keyword-def name="message-box">
+ <keyword-value>message-box</keyword-value>
+ </keyword-def>
+ <keyword-def name="middle">
+ <keyword-value>middle</keyword-value>
+ </keyword-def>
+ <keyword-def name="mix">
+ <keyword-value>mix</keyword-value>
+ </keyword-def>
+ <keyword-def name="monospace">
+ <keyword-value>monospace</keyword-value>
+ </keyword-def>
+ <keyword-def name="move">
+ <keyword-value>move</keyword-value>
+ </keyword-def>
+ <keyword-def name="n-resize">
+ <keyword-value>n-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="narrower">
+ <keyword-value>narrower</keyword-value>
+ </keyword-def>
+ <keyword-def name="navy">
+ <keyword-value>navy</keyword-value>
+ </keyword-def>
+ <keyword-def name="ne-resize">
+ <keyword-value>ne-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-close-quote">
+ <keyword-value>no-close-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-open-quote">
+ <keyword-value>no-open-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-repeat">
+ <keyword-value>no-repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="none">
+ <keyword-value>none</keyword-value>
+ </keyword-def>
+ <keyword-def name="normal">
+ <keyword-value>normal</keyword-value>
+ </keyword-def>
+ <keyword-def name="nowrap">
+ <keyword-value>nowrap</keyword-value>
+ </keyword-def>
+ <keyword-def name="nw-resize">
+ <keyword-value>nw-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="oblique">
+ <keyword-value>oblique</keyword-value>
+ </keyword-def>
+ <keyword-def name="olive">
+ <keyword-value>olive</keyword-value>
+ </keyword-def>
+ <keyword-def name="once">
+ <keyword-value>once</keyword-value>
+ </keyword-def>
+ <keyword-def name="open-quote">
+ <keyword-value>open-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="orange">
+ <keyword-value>orange</keyword-value>
+ </keyword-def>
+ <keyword-def name="outset">
+ <keyword-value>outset</keyword-value>
+ </keyword-def>
+ <keyword-def name="outside">
+ <keyword-value>outside</keyword-value>
+ </keyword-def>
+ <keyword-def name="overline">
+ <keyword-value>overline</keyword-value>
+ </keyword-def>
+ <keyword-def name="pointer">
+ <keyword-value>pointer</keyword-value>
+ </keyword-def>
+ <keyword-def name="portrait">
+ <keyword-value>portrait</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre">
+ <keyword-value>pre</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre-line">
+ <keyword-value>pre-line</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre-wrap">
+ <keyword-value>pre-wrap</keyword-value>
+ </keyword-def>
+ <keyword-def name="progress">
+ <keyword-value>progress</keyword-value>
+ </keyword-def>
+ <keyword-def name="purple">
+ <keyword-value>purple</keyword-value>
+ </keyword-def>
+ <keyword-def name="red">
+ <keyword-value>red</keyword-value>
+ </keyword-def>
+ <keyword-def name="relative">
+ <keyword-value>relative</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat">
+ <keyword-value>repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-x">
+ <keyword-value>repeat-x</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-y">
+ <keyword-value>repeat-y</keyword-value>
+ </keyword-def>
+ <keyword-def name="ridge">
+ <keyword-value>ridge</keyword-value>
+ </keyword-def>
+ <keyword-def name="right">
+ <keyword-value>right</keyword-value>
+ </keyword-def>
+ <keyword-def name="right-side">
+ <keyword-value>right-side</keyword-value>
+ </keyword-def>
+ <keyword-def name="rightwards">
+ <keyword-value>rightwards</keyword-value>
+ </keyword-def>
+ <keyword-def name="rtl">
+ <keyword-value>rtl</keyword-value>
+ </keyword-def>
+ <keyword-def name="run-in">
+ <keyword-value>run-in</keyword-value>
+ </keyword-def>
+ <keyword-def name="s-resize">
+ <keyword-value>s-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="sans-serif">
+ <keyword-value>sans-serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="scroll">
+ <keyword-value>scroll</keyword-value>
+ </keyword-def>
+ <keyword-def name="Scrollbar">
+ <keyword-value>Scrollbar</keyword-value>
+ </keyword-def>
+ <keyword-def name="se-resize">
+ <keyword-value>se-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="semi-condensed">
+ <keyword-value>semi-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="semi-expanded">
+ <keyword-value>semi-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="separate">
+ <keyword-value>separate</keyword-value>
+ </keyword-def>
+ <keyword-def name="serif">
+ <keyword-value>serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="show">
+ <keyword-value>show</keyword-value>
+ </keyword-def>
+ <keyword-def name="silent">
+ <keyword-value>silent</keyword-value>
+ </keyword-def>
+ <keyword-def name="silver">
+ <keyword-value>silver</keyword-value>
+ </keyword-def>
+ <keyword-def name="slow">
+ <keyword-value>slow</keyword-value>
+ </keyword-def>
+ <keyword-def name="slower">
+ <keyword-value>slower</keyword-value>
+ </keyword-def>
+ <keyword-def name="small">
+ <keyword-value>small</keyword-value>
+ </keyword-def>
+ <keyword-def name="small-caps">
+ <keyword-value>small-caps</keyword-value>
+ </keyword-def>
+ <keyword-def name="small-caption">
+ <keyword-value>small-caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="smaller">
+ <keyword-value>smaller</keyword-value>
+ </keyword-def>
+ <keyword-def name="soft">
+ <keyword-value>soft</keyword-value>
+ </keyword-def>
+ <keyword-def name="solid">
+ <keyword-value>solid</keyword-value>
+ </keyword-def>
+ <keyword-def name="spell-out">
+ <keyword-value>spell-out</keyword-value>
+ </keyword-def>
+ <keyword-def name="square">
+ <keyword-value>square</keyword-value>
+ </keyword-def>
+ <keyword-def name="static">
+ <keyword-value>static</keyword-value>
+ </keyword-def>
+ <keyword-def name="status-bar">
+ <keyword-value>status-bar</keyword-value>
+ </keyword-def>
+ <keyword-def name="sub">
+ <keyword-value>sub</keyword-value>
+ </keyword-def>
+ <keyword-def name="super">
+ <keyword-value>super</keyword-value>
+ </keyword-def>
+ <keyword-def name="sw-resize">
+ <keyword-value>sw-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="table">
+ <keyword-value>table</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-caption">
+ <keyword-value>table-caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-cell">
+ <keyword-value>table-cell</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-column">
+ <keyword-value>table-column</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-column-group">
+ <keyword-value>table-column-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-footer-group">
+ <keyword-value>table-footer-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-header-group">
+ <keyword-value>table-header-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-row">
+ <keyword-value>table-row</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-row-group">
+ <keyword-value>table-row-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="teal">
+ <keyword-value>teal</keyword-value>
+ </keyword-def>
+ <keyword-def name="text">
+ <keyword-value>text</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-top">
+ <keyword-value>text-top</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-bottom">
+ <keyword-value>text-bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="thick">
+ <keyword-value>thick</keyword-value>
+ </keyword-def>
+ <keyword-def name="thin">
+ <keyword-value>thin</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDDarkShadow">
+ <keyword-value>ThreeDDarkShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDFace">
+ <keyword-value>ThreeDFace</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDHighlight">
+ <keyword-value>ThreeDHighlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDLightShadow">
+ <keyword-value>ThreeDLightShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDShadow">
+ <keyword-value>ThreeDShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="top">
+ <keyword-value>top</keyword-value>
+ </keyword-def>
+ <keyword-def name="transparent">
+ <keyword-value>transparent</keyword-value>
+ </keyword-def>
+ <keyword-def name="ultra-condensed">
+ <keyword-value>ultra-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="ultra-expanded">
+ <keyword-value>ultra-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="underline">
+ <keyword-value>underline</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-alpha">
+ <keyword-value>upper-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-latin">
+ <keyword-value>upper-latin</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-roman">
+ <keyword-value>upper-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="uppercase">
+ <keyword-value>uppercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="visible">
+ <keyword-value>visible</keyword-value>
+ </keyword-def>
+ <keyword-def name="w-resize">
+ <keyword-value>w-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="wait">
+ <keyword-value>wait</keyword-value>
+ </keyword-def>
+ <keyword-def name="white">
+ <keyword-value>white</keyword-value>
+ </keyword-def>
+ <keyword-def name="wider">
+ <keyword-value>wider</keyword-value>
+ </keyword-def>
+ <keyword-def name="Window">
+ <keyword-value>Window</keyword-value>
+ </keyword-def>
+ <keyword-def name="WindowFrame">
+ <keyword-value>WindowFrame</keyword-value>
+ </keyword-def>
+ <keyword-def name="WindowText">
+ <keyword-value>WindowText</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-fast">
+ <keyword-value>x-fast</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-high">
+ <keyword-value>x-high</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-large">
+ <keyword-value>x-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-loud">
+ <keyword-value>x-loud</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-low">
+ <keyword-value>x-low</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-slow">
+ <keyword-value>x-slow</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-small">
+ <keyword-value>x-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-soft">
+ <keyword-value>x-soft</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-small">
+ <keyword-value>xx-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-large">
+ <keyword-value>xx-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="yellow">
+ <keyword-value>yellow</keyword-value>
+ </keyword-def>
+</css-profile>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css3.xml b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css3.xml
new file mode 100644
index 0000000..194b383
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-css3.xml
@@ -0,0 +1,2566 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!--<!DOCTYPE css-profile SYSTEM "css-profile.dtd" >-->
+<css-profile>
+ <stylesheet-def>
+ <description>Cascading Style Sheets, level 3</description>
+ <charset-rule/>
+ <import-rule/>
+ <page-rule/>
+ <media-rule/>
+ <fontface-rule/>
+ <style-rule/>
+ </stylesheet-def>
+
+ <charset-rule-def>
+ </charset-rule-def>
+ <import-rule-def>
+ </import-rule-def>
+ <media-rule-def>
+ </media-rule-def>
+
+ <page-rule-def>
+ <pseudo-class name="left"/>
+ <pseudo-class name="right"/>
+ <pseudo-class name="first"/>
+ <property name="size"/>
+ <property name="marks"/>
+ <property name="page-break-after"/>
+ <property name="page-break-before"/>
+ <property name="page-break-inside"/>
+ <property name="orphans"/>
+ <property name="widows"/>
+ </page-rule-def>
+
+ <fontface-rule-def>
+ <descriptor name="ascent"/>
+ <descriptor name="baseline"/>
+ <descriptor name="bbox"/>
+ <descriptor name="cap-height"/>
+ <descriptor name="centerline"/>
+ <descriptor name="definition-src"/>
+ <descriptor name="descent"/>
+ <descriptor name="font-family"/>
+ <descriptor name="font-size"/>
+ <descriptor name="font-stretch"/>
+ <descriptor name="font-style"/>
+ <descriptor name="font-variant"/>
+ <descriptor name="font-weight"/>
+ <descriptor name="mathline"/>
+ <descriptor name="panose-1"/>
+ <descriptor name="slope"/>
+ <descriptor name="slope"/>
+ <descriptor name="src"/>
+ <descriptor name="stemh"/>
+ <descriptor name="stemv"/>
+ <descriptor name="topline"/>
+ <descriptor name="unicode-range"/>
+ <descriptor name="units-per-em"/>
+ <descriptor name="widths"/>
+ <descriptor name="x-height"/>
+ </fontface-rule-def>
+
+ <!-- Which properties can style rule include ? -->
+
+ <style-rule-def>
+ <selector-expression name="descendant"/>
+ <selector-expression name="child"/>
+ <selector-expression name="adjacent"/>
+ <selector-expression name="universal"/>
+ <selector-expression name="attribute"/>
+ <pseudo-element name="first-line"/>
+ <pseudo-element name="first-letter"/>
+ <pseudo-element name="before"/>
+ <pseudo-element name="after"/>
+ <pseudo-element name="selection"/>
+ <pseudo-class name="first-child"/>
+ <pseudo-class name="link"/>
+ <pseudo-class name="visited"/>
+ <pseudo-class name="hover"/>
+ <pseudo-class name="active"/>
+ <pseudo-class name="focus"/>
+ <pseudo-class name="empty"/>
+ <pseudo-class name="enabled"/>
+ <pseudo-class name="disabled"/>
+ <pseudo-class name="checked"/>
+ <pseudo-class name="first-of-type"/>
+ <pseudo-class name="last-child"/>
+ <pseudo-class name="last-of-type"/>
+ <pseudo-class name="not()"/>
+ <pseudo-class name="nth-child()"/>
+ <pseudo-class name="nth-last-child()"/>
+ <pseudo-class name="nth-last-of-type()"/>
+ <pseudo-class name="nth-of-type()"/>
+ <pseudo-class name="only-child"/>
+ <pseudo-class name="only-of-type"/>
+ <pseudo-class name="root"/>
+ <pseudo-class name="target"/>
+ <property name="azimuth"/>
+ <property name="background"/>
+ <property name="background-attachment"/>
+ <property name="background-clip"/>
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-origin"/>
+ <property name="background-position"/>
+ <property name="background-repeat"/>
+ <property name="background-size"/>
+ <property name="border"/>
+ <property name="border-collapse"/>
+ <property name="border-color"/>
+ <property name="border-spacing"/>
+ <property name="border-style"/>
+ <property name="border-top"/>
+ <property name="border-right"/>
+ <property name="border-bottom"/>
+ <property name="border-left"/>
+ <property name="border-top-color"/>
+ <property name="border-right-color"/>
+ <property name="border-bottom-color"/>
+ <property name="border-left-color"/>
+ <property name="border-top-style"/>
+ <property name="border-right-style"/>
+ <property name="border-bottom-style"/>
+ <property name="border-left-style"/>
+ <property name="border-top-width"/>
+ <property name="border-right-width"/>
+ <property name="border-bottom-width"/>
+ <property name="border-left-width"/>
+ <property name="border-width"/>
+ <property name="border-top-left-radius"/>
+ <property name="border-top-right-radius"/>
+ <property name="border-bottom-left-radius"/>
+ <property name="border-bottom-right-radius"/>
+ <property name="border-radius"/>
+ <property name="bottom"/>
+ <property name="box-shadow"/>
+ <property name="box-sizing"/>
+ <property name="caption-side"/>
+ <property name="clear"/>
+ <property name="clip"/>
+ <property name="color"/>
+ <property name="content"/>
+ <property name="columns"/>
+ <property name="column-count"/>
+ <property name="column-width"/>
+ <property name="column-gap"/>
+ <property name="column-rule-color"/>
+ <property name="column-rule-style"/>
+ <property name="column-rule-width"/>
+ <property name="column-rule"/>
+ <property name="column-span"/>
+ <property name="column-fill"/>
+ <property name="counter-increment"/>
+ <property name="counter-reset"/>
+ <property name="cue"/>
+ <property name="cue-after"/>
+ <property name="cue-before"/>
+ <property name="cursor"/>
+ <property name="direction"/>
+ <property name="display"/>
+ <property name="elevation"/>
+ <property name="empty-cells"/>
+ <property name="float"/>
+ <property name="font"/>
+ <property name="font-family"/>
+ <property name="font-size"/>
+ <property name="font-size-adjust"/>
+ <property name="font-stretch"/>
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="height"/>
+ <property name="left"/>
+ <property name="letter-spacing"/>
+ <property name="line-height"/>
+ <property name="list-style"/>
+ <property name="list-style-image"/>
+ <property name="list-style-position"/>
+ <property name="list-style-type"/>
+ <property name="margin"/>
+ <property name="margin-top"/>
+ <property name="margin-right"/>
+ <property name="margin-bottom"/>
+ <property name="margin-left"/>
+ <property name="marker-offset"/>
+ <property name="marks"/>
+ <property name="max-height"/>
+ <property name="max-width"/>
+ <property name="min-height"/>
+ <property name="min-width"/>
+ <property name="opacity"/>
+ <property name="orphans"/>
+ <property name="outline"/>
+ <property name="outline-color"/>
+ <property name="outline-style"/>
+ <property name="outline-width"/>
+ <property name="overflow"/>
+ <property name="padding"/>
+ <property name="padding-top"/>
+ <property name="padding-right"/>
+ <property name="padding-bottom"/>
+ <property name="padding-left"/>
+ <property name="page"/>
+ <property name="page-break-after"/>
+ <property name="page-break-before"/>
+ <property name="page-break-inside"/>
+ <property name="pause"/>
+ <property name="pause-after"/>
+ <property name="pause-before"/>
+ <property name="pitch"/>
+ <property name="pitch-range"/>
+ <property name="play-during"/>
+ <property name="position"/>
+ <property name="quotes"/>
+ <property name="resize"/>
+ <property name="richness"/>
+ <property name="right"/>
+ <property name="size"/>
+ <property name="speak"/>
+ <property name="speak-header"/>
+ <property name="speak-numeral"/>
+ <property name="speak-punctuation"/>
+ <property name="speech-rate"/>
+ <property name="stress"/>
+ <property name="table-layout"/>
+ <property name="text-align"/>
+ <property name="text-decoration"/>
+ <property name="text-indent"/>
+ <property name="text-overflow"/>
+ <property name="text-shadow"/>
+ <property name="text-transform"/>
+ <property name="top"/>
+ <property name="unicode-bidi"/>
+ <property name="vertical-align"/>
+ <property name="visibility"/>
+ <property name="voice-family"/>
+ <property name="volume"/>
+ <property name="white-space"/>
+ <property name="widows"/>
+ <property name="width"/>
+ <property name="word-spacing"/>
+ <property name="z-index"/>
+ </style-rule-def>
+
+ <pseudo-class-def name="checked" version="3">
+ <selector-value>checked</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="disabled" version="3">
+ <selector-value>disabled</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="empty" version="3">
+ <selector-value>empty</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="enabled" version="3">
+ <selector-value>enabled</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="first-of-type" version="3">
+ <selector-value>first-of-type</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="last-child" version="3">
+ <selector-value>last-child</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="last-of-type" version="3">
+ <selector-value>last-of-type</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="not()" version="3">
+ <selector-value>not()</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="nth-child()" version="3">
+ <selector-value>nth-child()</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="nth-last-child()" version="3">
+ <selector-value>nth-last-child()</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="nth-last-of-type()" version="3">
+ <selector-value>nth-last-of-type()</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="nth-of-type()" version="3">
+ <selector-value>nth-of-type()</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="only-child" version="3">
+ <selector-value>only-child</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="only-of-type" version="3">
+ <selector-value>only-of-type</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="root" version="3">
+ <selector-value>root</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="target" version="3">
+ <selector-value>target</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="first-child">
+ <selector-value>first-child</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="link">
+ <selector-value>link</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="visited">
+ <selector-value>visited</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="hover">
+ <selector-value>hover</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="active">
+ <selector-value>active</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="focus">
+ <selector-value>focus</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="lang">
+ <selector-value>lang</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="left">
+ <selector-value>left</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="right">
+ <selector-value>right</selector-value>
+ </pseudo-class-def>
+ <pseudo-class-def name="first">
+ <selector-value>first</selector-value>
+ </pseudo-class-def>
+
+ <pseudo-element-def name="first-line">
+ <selector-value>first-line</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="first-letter">
+ <selector-value>first-letter</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="before">
+ <selector-value>before</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="after">
+ <selector-value>after</selector-value>
+ </pseudo-element-def>
+ <pseudo-element-def name="selection" version="3">
+ <selector-value>selection</selector-value>
+ </pseudo-element-def>
+
+ <!-- property definition -->
+
+ <property-def name="azimuth"
+ inherited="yes" mediagroup="aural" category="aural">
+ <description>This provides spatial audio property for aural
+ presentation</description>
+ <number name="angle"/>
+ <keyword name="left-side"/>
+ <keyword name="far-left"/>
+ <keyword name="left"/>
+ <keyword name="center-left"/>
+ <keyword name="center"/>
+ <keyword name="center-right"/>
+ <keyword name="right"/>
+ <keyword name="far-right"/>
+ <keyword name="right-side"/>
+ <keyword name="behind"/>
+ <keyword name="leftwards"/>
+ <keyword name="rightwards"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <property name="background-color"/>
+ <property name="background-image"/>
+ <property name="background-repeat"/>
+ <property name="background-attachment"/>
+ <property name="background-position"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-attachment"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <keyword name="scroll"/>
+ <keyword name="fixed"/>
+ <keyword name="local"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-clip"
+ inherited="no" mediagroup="visual" category="colorandbackground" version="3">
+ <keyword name="border-box"/>
+ <keyword name="content-box"/>
+ <keyword name="padding-box"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-color"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <container name="color"/>
+ <keyword name="transparent"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-image"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-origin"
+ inherited="no" mediagroup="visual" category="colorandbackground" version="3">
+ <keyword name="padding-box"/>
+ <keyword name="border-box"/>
+ <keyword name="content-box"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-position"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="top"/>
+ <keyword name="center"/>
+ <keyword name="bottom"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-repeat"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <keyword name="repeat"/>
+ <keyword name="repeat-x"/>
+ <keyword name="repeat-y"/>
+ <keyword name="space"/>
+ <keyword name="round"/>
+ <keyword name="no-repeat"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="background-size"
+ inherited="no" mediagroup="visual" category="colorandbackground" version="3">
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="contain"/>
+ <keyword name="cover"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-collapse"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="collapse"/>
+ <keyword name="separate"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="transparent"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-spacing"
+ inherited="yes" mediagroup="visual" category="tables">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-top-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-left-radius"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-right-radius"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-right-radius"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-left-radius"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-radius"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-right-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-bottom-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left"
+ inherited="no" mediagroup="visual" category="box">
+ <property name="border-left-width"/>
+ <property name="border-style"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-color"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-style"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-top-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-right-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-bottom-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-left-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="border-width"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="bottom"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="box-shadow"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <number name="length"/>
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="box-sizing"
+ inherited="no" mediagroup="visual" category="box" version="3">
+ <keyword name="border-box"/>
+ <keyword name="content-box"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="caption-side"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="top"/>
+ <keyword name="bottom"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="clear"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="none"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="both"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="clip"
+ inherited="no" mediagroup="visual" category="visual">
+ <container name="shape"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="color"
+ inherited="yes" mediagroup="visual" category="colorandbackground">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="columns"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <property name="column-width"/>
+ <property name="column-count"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-width"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <number name="length"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-count"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <number name="integer"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-fill"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <keyword name="auto"/>
+ <keyword name="balance"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-gap"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <number name="length"/>
+ <keyword name="normal"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-rule"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <property name="column-rule-width"/>
+ <property name="column-rule-style"/>
+ <property name="column-rule-color"/>
+ </property-def>
+ <property-def name="column-rule-color"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <container name="color"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-rule-style"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-rule-width"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="column-span"
+ inherited="no" mediagroup="visual" category="visual" version="3">
+ <keyword name="all"/>
+ <keyword name="1"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="content"
+ inherited="no" mediagroup="all" category="content">
+ <string name="any"/>
+ <function name="uri"/>
+ <function name="counter"/>
+ <function name="attr"/>
+ <keyword name="open-quote"/>
+ <keyword name="close-quote"/>
+ <keyword name="none"/>
+ <keyword name="normal"/>
+ <keyword name="no-open-quote"/>
+ <keyword name="no-close-quote"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="counter-increment"
+ inherited="no" mediagroup="all" category="content">
+ <string name="counter-identifier"/>
+ <number name="integer"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="counter-reset"
+ inherited="no" mediagroup="all" category="content">
+ <string name="counter-identifier"/>
+ <number name="integer"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue"
+ inherited="no" mediagroup="aural" category="aural">
+ <property name="cue-before"/>
+ <property name="cue-after"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue-after"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cue-before"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="cursor"
+ inherited="yes" mediagroup="visual,interactive" category="ui">
+ <function name="uri"/>
+ <keyword name="auto"/>
+ <keyword name="crosshair"/>
+ <keyword name="default"/>
+ <keyword name="pointer"/>
+ <keyword name="progress"/>
+ <keyword name="move"/>
+ <keyword name="e-resize"/>
+ <keyword name="ne-resize"/>
+ <keyword name="nw-resize"/>
+ <keyword name="n-resize"/>
+ <keyword name="se-resize"/>
+ <keyword name="sw-resize"/>
+ <keyword name="s-resize"/>
+ <keyword name="w-resize"/>
+ <keyword name="text"/>
+ <keyword name="wait"/>
+ <keyword name="help"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="direction"
+ inherited="yes" mediagroup="visual" category="visual">
+ <keyword name="ltr"/>
+ <keyword name="rtl"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="display"
+ inherited="no" mediagroup="all" category="visual">
+ <keyword name="inline"/>
+ <keyword name="inline-block"/>
+ <keyword name="block"/>
+ <keyword name="list-item"/>
+ <keyword name="run-in"/>
+ <keyword name="compact"/>
+ <keyword name="marker"/>
+ <keyword name="table"/>
+ <keyword name="inline-table"/>
+ <keyword name="table-row-group"/>
+ <keyword name="table-header-group"/>
+ <keyword name="table-footer-group"/>
+ <keyword name="table-row"/>
+ <keyword name="table-column-group"/>
+ <keyword name="table-column"/>
+ <keyword name="table-cell"/>
+ <keyword name="table-caption"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="elevation"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="angle"/>
+ <keyword name="below"/>
+ <keyword name="level"/>
+ <keyword name="above"/>
+ <keyword name="higher"/>
+ <keyword name="lower"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="empty-cells"
+ inherited="yes" mediagroup="visual" category="tables">
+ <keyword name="show"/>
+ <keyword name="hide"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="float"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font"
+ inherited="yes" mediagroup="visual" category="font">
+ <property name="font-style"/>
+ <property name="font-variant"/>
+ <property name="font-weight"/>
+ <property name="font-size"/>
+ <property name="line-height"/>
+ <property name="font-family"/>
+ <keyword name="caption"/>
+ <keyword name="icon"/>
+ <keyword name="menu"/>
+ <keyword name="message-box"/>
+ <keyword name="small-caption"/>
+ <keyword name="status-bar"/>
+ <keyword name="inherit"/>
+ <separator name="slash"/>
+ </property-def>
+ <property-def name="font-family"
+ inherited="yes" mediagroup="visual" category="font">
+ <string name="family-name"/>
+ <container name="generic-family"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="font-size"
+ inherited="yes" mediagroup="visual" category="font">
+ <container name="absolute-size"/>
+ <container name="relative-size"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-size-adjust"
+ inherited="yes" mediagroup="visual" category="font">
+ <number name="number"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-stretch"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="wider"/>
+ <keyword name="narrower"/>
+ <keyword name="ultra-condensed"/>
+ <keyword name="extra-condensed"/>
+ <keyword name="condensed"/>
+ <keyword name="semi-condensed"/>
+ <keyword name="semi-expanded"/>
+ <keyword name="expanded"/>
+ <keyword name="extra-expanded"/>
+ <keyword name="ultra-expanded"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-style"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="italic"/>
+ <keyword name="oblique"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-variant"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="small-caps"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="font-weight"
+ inherited="yes" mediagroup="visual" category="font">
+ <keyword name="normal"/>
+ <keyword name="bold"/>
+ <keyword name="bolder"/>
+ <keyword name="lighter"/>
+ <keyword name="100"/>
+ <keyword name="200"/>
+ <keyword name="300"/>
+ <keyword name="400"/>
+ <keyword name="500"/>
+ <keyword name="600"/>
+ <keyword name="700"/>
+ <keyword name="800"/>
+ <keyword name="900"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="left"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="letter-spacing"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="line-height"
+ inherited="yes" mediagroup="visual" category="visual">
+ <keyword name="normal"/>
+ <number name="number"/>
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style"
+ inherited="yes" mediagroup="visual" category="content">
+ <property name="list-style-type"/>
+ <property name="list-style-position"/>
+ <property name="list-style-image"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-image"
+ inherited="yes" mediagroup="visual" category="content">
+ <function name="uri"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-position"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="inside"/>
+ <keyword name="outside"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="list-style-type"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="decimal-leading-zero"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-greek"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="lower-latin"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="upper-latin"/>
+ <keyword name="hebrew"/>
+ <keyword name="armenian"/>
+ <keyword name="georgian"/>
+ <keyword name="cjk-ideographic"/>
+ <keyword name="hiragana"/>
+ <keyword name="katakana"/>
+ <keyword name="hiragana-iroha"/>
+ <keyword name="katakana-iroha"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-top"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-right"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="margin-left"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="margin-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="marker-offset"
+ inherited="no" mediagroup="visual" category="content">
+ <number name="length"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="marks"
+ inherited="na" mediagroup="visual,paged" category="page">
+ <keyword name="crop"/>
+ <keyword name="cross"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="max-height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="max-width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="min-height"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="min-width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="opacity"
+ inherited="yes" mediagroup="visual" category="visual" version="3">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="orphans"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <property name="outline-color"/>
+ <property name="outline-style"/>
+ <property name="outline-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-color"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="color"/>
+ <keyword name="invert"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-style"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="border-style"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="outline-width"
+ inherited="no" mediagroup="visual,interactive" category="ui">
+ <container name="border-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="overflow"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="visible"/>
+ <keyword name="hidden"/>
+ <keyword name="scroll"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-top"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-right"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-bottom"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="padding-left"
+ inherited="no" mediagroup="visual" category="box">
+ <container name="padding-width"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <string name="page-identifier"/>
+ <keyword name="auto"/>
+ </property-def>
+ <property-def name="page-break-after"
+ inherited="no" mediagroup="visual,paged" category="page">
+ <keyword name="auto"/>
+ <keyword name="always"/>
+ <keyword name="avoid"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page-break-before"
+ inherited="no" mediagroup="visual,paged" category="page">
+ <keyword name="auto"/>
+ <keyword name="always"/>
+ <keyword name="avoid"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="page-break-inside"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <keyword name="avoid"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause-after"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pause-before"
+ inherited="no" mediagroup="aural" category="aural">
+ <number name="time"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pitch"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="frequency"/>
+ <keyword name="x-low"/>
+ <keyword name="low"/>
+ <keyword name="medium"/>
+ <keyword name="high"/>
+ <keyword name="x-high"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="pitch-range"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="play-during"
+ inherited="no" mediagroup="aural" category="aural">
+ <function name="uri"/>
+ <keyword name="mix"/>
+ <keyword name="repeat"/>
+ <keyword name="auto"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="position"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="static"/>
+ <keyword name="relative"/>
+ <keyword name="absolute"/>
+ <keyword name="fixed"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="quotes"
+ inherited="yes" mediagroup="visual" category="content">
+ <string name="any"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="resize"
+ inherited="yes" mediagroup="visual" category="visual" version="3">
+ <keyword name="both"/>
+ <keyword name="horizontal"/>
+ <keyword name="none"/>
+ <keyword name="vertical"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="richness"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="right"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="size"
+ inherited="na" mediagroup="visual,paged" category="page">
+ <number name="length"/>
+ <keyword name="auto"/>
+ <keyword name="portrait"/>
+ <keyword name="landscape"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="normal"/>
+ <keyword name="none"/>
+ <keyword name="spell-out"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-header"
+ inherited="yes" mediagroup="aural" category="tables">
+ <keyword name="once"/>
+ <keyword name="always"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-numeral"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="digits"/>
+ <keyword name="continuous"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speak-punctuation"
+ inherited="yes" mediagroup="aural" category="aural">
+ <keyword name="code"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="speech-rate"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="x-slow"/>
+ <keyword name="slow"/>
+ <keyword name="medium"/>
+ <keyword name="fast"/>
+ <keyword name="x-fast"/>
+ <keyword name="faster"/>
+ <keyword name="slower"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="stress"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="table-layout"
+ inherited="no" mediagroup="visual" category="tables">
+ <keyword name="auto"/>
+ <keyword name="fixed"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-align"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="center"/>
+ <keyword name="justify"/>
+ <string name="any"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-decoration"
+ inherited="no" mediagroup="visual" category="text">
+ <keyword name="none"/>
+ <keyword name="underline"/>
+ <keyword name="overline"/>
+ <keyword name="line-through"/>
+ <keyword name="blink"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-indent"
+ inherited="yes" mediagroup="visual" category="text">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-overflow"
+ inherited="no" mediagroup="visual" category="text" version="3">
+ <keyword name="clip"/>
+ <keyword name="ellipsis"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-shadow"
+ inherited="no" mediagroup="visual" category="text" version="3">
+ <keyword name="none"/>
+ <container name="color"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ <separator name="comma"/>
+ </property-def>
+ <property-def name="text-transform"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="capitalize"/>
+ <keyword name="uppercase"/>
+ <keyword name="lowercase"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="top"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="unicode-bidi"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="normal"/>
+ <keyword name="embed"/>
+ <keyword name="bidi-override"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="vertical-align"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="baseline"/>
+ <keyword name="sub"/>
+ <keyword name="super"/>
+ <keyword name="top"/>
+ <keyword name="text-top"/>
+ <keyword name="middle"/>
+ <keyword name="bottom"/>
+ <keyword name="text-bottom"/>
+ <number name="percentage"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="visibility"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="visible"/>
+ <keyword name="hidden"/>
+ <keyword name="collapse"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="voice-family"
+ inherited="yes" mediagroup="aural" category="aural">
+ <string name="specific-voice"/>
+ <container name="generic-voice"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="volume"
+ inherited="yes" mediagroup="aural" category="aural">
+ <number name="number"/>
+ <number name="percentage"/>
+ <keyword name="silent"/>
+ <keyword name="x-soft"/>
+ <keyword name="soft"/>
+ <keyword name="medium"/>
+ <keyword name="loud"/>
+ <keyword name="x-loud"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="white-space"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <keyword name="pre"/>
+ <keyword name="pre-line"/>
+ <keyword name="pre-wrap"/>
+ <keyword name="nowrap"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="widows"
+ inherited="yes" mediagroup="visual,paged" category="page">
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="width"
+ inherited="no" mediagroup="visual" category="visual">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="word-spacing"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="normal"/>
+ <number name="length"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="z-index"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="auto"/>
+ <number name="integer"/>
+ <keyword name="inherit"/>
+ </property-def>
+
+ <!-- descriptor definition : These are for @font-face -->
+
+ <descriptor-def name="ascent">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="baseline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="bbox">
+ <number name="number"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="cap-height">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="centerline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="definition-src">
+ <function name="uri"/>
+ </descriptor-def>
+ <descriptor-def name="descent">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="font-family">
+ <string name="family-name"/>
+ <container name="generic-family"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-size">
+ <keyword name="all"/>
+ <number name="length"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-stretch">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="ultra-condensed"/>
+ <keyword name="extra-condensed"/>
+ <keyword name="condensed"/>
+ <keyword name="semi-condensed"/>
+ <keyword name="semi-expanded"/>
+ <keyword name="expanded"/>
+ <keyword name="extra-expanded"/>
+ <keyword name="ultra-expanded"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-style">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="italic"/>
+ <keyword name="oblique"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-variant">
+ <keyword name="normal"/>
+ <keyword name="small-caps"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="font-weight">
+ <keyword name="all"/>
+ <keyword name="normal"/>
+ <keyword name="bold"/>
+ <keyword name="100"/>
+ <keyword name="200"/>
+ <keyword name="300"/>
+ <keyword name="400"/>
+ <keyword name="500"/>
+ <keyword name="600"/>
+ <keyword name="700"/>
+ <keyword name="800"/>
+ <keyword name="900"/>
+ <separator name="comma"/>
+ </descriptor-def>
+ <descriptor-def name="mathline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="panose-1">
+ <number name="integer"/>
+ </descriptor-def>
+ <descriptor-def name="slope">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="src">
+ <function name="uri"/>
+ <function name="format"/>
+ <container name="font-face-name"/>
+ </descriptor-def>
+ <descriptor-def name="stemh">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="stemv">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="topline">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="unicode-range">
+ <string name="urange"/>
+ </descriptor-def>
+ <descriptor-def name="units-per-em">
+ <number name="number"/>
+ </descriptor-def>
+ <descriptor-def name="widths">
+ <string name="urange"/>
+ <number name="length"/>
+ </descriptor-def>
+ <descriptor-def name="x-height">
+ <number name="number"/>
+ </descriptor-def>
+
+ <!-- container definition : Container is the lump of values.
+ It can be used like macros. -->
+ <container-def name="absolute-size">
+ <keyword name="xx-small"/>
+ <keyword name="x-small"/>
+ <keyword name="small"/>
+ <keyword name="medium"/>
+ <keyword name="large"/>
+ <keyword name="x-large"/>
+ <keyword name="xx-large"/>
+ </container-def>
+ <container-def name="border-style">
+ <keyword name="none"/>
+ <keyword name="hidden"/>
+ <keyword name="dotted"/>
+ <keyword name="dashed"/>
+ <keyword name="solid"/>
+ <keyword name="double"/>
+ <keyword name="groove"/>
+ <keyword name="ridge"/>
+ <keyword name="inset"/>
+ <keyword name="outset"/>
+ </container-def>
+ <container-def name="border-width">
+ <keyword name="thin"/>
+ <keyword name="medium"/>
+ <keyword name="thick"/>
+ <number name="length"/>
+ </container-def>
+ <container-def name="color">
+ <keyword name="aqua"/>
+ <keyword name="black"/>
+ <keyword name="blue"/>
+ <keyword name="fuchsia"/>
+ <keyword name="gray"/>
+ <keyword name="green"/>
+ <keyword name="lime"/>
+ <keyword name="maroon"/>
+ <keyword name="navy"/>
+ <keyword name="olive"/>
+ <keyword name="orange"/>
+ <keyword name="purple"/>
+ <keyword name="red"/>
+ <keyword name="silver"/>
+ <keyword name="teal"/>
+ <keyword name="white"/>
+ <keyword name="yellow"/>
+ <container name="system-color"/>
+ <function name="rgb"/>
+ <function name="rgba"/>
+ <number name="hash"/>
+ </container-def>
+ <container-def name="generic-family">
+ <keyword name="serif"/>
+ <keyword name="sans-serif"/>
+ <keyword name="cursive"/>
+ <keyword name="fantasy"/>
+ <keyword name="monospace"/>
+ </container-def>
+ <container-def name="font-face-name">
+ <function name="local"/>
+ </container-def>
+ <container-def name="generic-voice">
+ <keyword name="male"/>
+ <keyword name="female"/>
+ <keyword name="child"/>
+ </container-def>
+ <container-def name="margin-width">
+ <number name="length"/>
+ <number name="percentage"/>
+ <keyword name="auto"/>
+ </container-def>
+ <container-def name="padding-width">
+ <number name="length"/>
+ <number name="percentage"/>
+ </container-def>
+ <container-def name="relative-size">
+ <keyword name="smaller"/>
+ <keyword name="larger"/>
+ </container-def>
+ <container-def name="shape">
+ <function name="rect"/>
+ </container-def>
+ <container-def name="system-color">
+ <keyword name="ActiveBorder"/>
+ <keyword name="ActiveCaption"/>
+ <keyword name="AppWorkspace"/>
+ <keyword name="Background"/>
+ <keyword name="ButtonFace"/>
+ <keyword name="ButtonHighlight"/>
+ <keyword name="ButtonShadow"/>
+ <keyword name="ButtonText"/>
+ <keyword name="CaptionText"/>
+ <keyword name="GrayText"/>
+ <keyword name="Highlight"/>
+ <keyword name="HighlightText"/>
+ <keyword name="InactiveBorder"/>
+ <keyword name="InactiveCaption"/>
+ <keyword name="InactiveCaptionText"/>
+ <keyword name="InfoBackground"/>
+ <keyword name="InfoText"/>
+ <keyword name="Menu"/>
+ <keyword name="MenuText"/>
+ <keyword name="Scrollbar"/>
+ <keyword name="ThreeDDarkShadow"/>
+ <keyword name="ThreeDFace"/>
+ <keyword name="ThreeDHighlight"/>
+ <keyword name="ThreeDLightShadow"/>
+ <keyword name="ThreeDShadow"/>
+ <keyword name="Window"/>
+ <keyword name="WindowFrame"/>
+ <keyword name="WindowText"/>
+ </container-def>
+
+ <!-- category definition : This is used to categorize properties
+ in Properties View. -->
+ <category-def name="aural">
+ <caption>%css2.category-def.aural.caption</caption>
+ </category-def>
+ <category-def name="box">
+ <caption>%css2.category-def.box.caption</caption>
+ </category-def>
+ <category-def name="colorandbackground">
+ <caption>%css2.category-def.colorandbackground.caption</caption>
+ </category-def>
+ <category-def name="content">
+ <caption>%css2.category-def.content.caption</caption>
+ </category-def>
+ <category-def name="font">
+ <caption>%css2.category-def.font.caption</caption>
+ </category-def>
+ <category-def name="page">
+ <caption>%css2.category-def.page.caption</caption>
+ </category-def>
+ <category-def name="tables">
+ <caption>%css2.category-def.tables.caption</caption>
+ </category-def>
+ <category-def name="text">
+ <caption>%css2.category-def.text.caption</caption>
+ </category-def>
+ <category-def name="ui">
+ <caption>%css2.category-def.ui.caption</caption>
+ </category-def>
+ <category-def name="visual">
+<!-- <caption>%css2.category-def.visual.caption</caption>-->
+ <caption>%css2.category-def.visual.caption</caption>
+ </category-def>
+
+ <!-- function definition -->
+ <function-def name="attr">
+ <function-value>attr</function-value>
+ </function-def>
+ <function-def name="counter">
+ <function-value>counter</function-value>
+ </function-def>
+ <function-def name="rect">
+ <function-value>rect</function-value>
+ </function-def>
+ <function-def name="rgb">
+ <function-value>rgb</function-value>
+ </function-def>
+ <function-def name="rgba" version="3">
+ <function-value>rgba</function-value>
+ </function-def>
+ <function-def name="uri">
+ <function-value>url</function-value>
+ </function-def>
+ <function-def name="format">
+ <function-value>format</function-value>
+ </function-def>
+ <function-def name="local">
+ <function-value>local</function-value>
+ </function-def>
+
+ <!-- number definition : What unit types be acceptable for each
+ number type? -->
+ <number-def name="angle">
+ <unit name="deg"/>
+ <unit name="grad"/>
+ <unit name="rad"/>
+ </number-def>
+ <number-def name="frequency">
+ <unit name="hz"/>
+ <unit name="khz"/>
+ </number-def>
+ <number-def name="hash">
+ <unit name="hash"/>
+ </number-def>
+ <number-def name="integer">
+ </number-def>
+ <number-def name="length">
+ <unit name="em"/>
+ <unit name="ex"/>
+ <unit name="px"/>
+ <unit name="in"/>
+ <unit name="cm"/>
+ <unit name="mm"/>
+ <unit name="pt"/>
+ <unit name="pc"/>
+ </number-def>
+ <number-def name="number">
+ </number-def>
+ <number-def name="percentage">
+ <unit name="percentage"/>
+ </number-def>
+ <number-def name="time">
+ <unit name="ms"/>
+ <unit name="s"/>
+ </number-def>
+
+ <unit-def name="cm">
+ <unit-value>cm</unit-value>
+ </unit-def>
+ <unit-def name="deg">
+ <unit-value>deg</unit-value>
+ </unit-def>
+ <unit-def name="em">
+ <unit-value>em</unit-value>
+ </unit-def>
+ <unit-def name="ex">
+ <unit-value>ex</unit-value>
+ </unit-def>
+ <unit-def name="grad">
+ <unit-value>grad</unit-value>
+ </unit-def>
+ <unit-def name="hash">
+ <unit-value>#</unit-value>
+ </unit-def>
+ <unit-def name="hz">
+ <unit-value>Hz</unit-value>
+ </unit-def>
+ <unit-def name="in">
+ <unit-value>in</unit-value>
+ </unit-def>
+ <unit-def name="khz">
+ <unit-value>kHz</unit-value>
+ </unit-def>
+ <unit-def name="mm">
+ <unit-value>mm</unit-value>
+ </unit-def>
+ <unit-def name="ms">
+ <unit-value>ms</unit-value>
+ </unit-def>
+ <unit-def name="pc">
+ <unit-value>pc</unit-value>
+ </unit-def>
+ <unit-def name="percentage">
+ <unit-value>%</unit-value>
+ </unit-def>
+ <unit-def name="pt">
+ <unit-value>pt</unit-value>
+ </unit-def>
+ <unit-def name="px">
+ <unit-value>px</unit-value>
+ </unit-def>
+ <unit-def name="rad">
+ <unit-value>rad</unit-value>
+ </unit-def>
+ <unit-def name="s">
+ <unit-value>s</unit-value>
+ </unit-def>
+
+ <!-- keywords : string constants (this is last part..) -->
+ <keyword-def name="1" version="3">
+ <keyword-value>1</keyword-value>
+ </keyword-def>
+ <keyword-def name="100">
+ <keyword-value>100</keyword-value>
+ </keyword-def>
+ <keyword-def name="200">
+ <keyword-value>200</keyword-value>
+ </keyword-def>
+ <keyword-def name="300">
+ <keyword-value>300</keyword-value>
+ </keyword-def>
+ <keyword-def name="400">
+ <keyword-value>400</keyword-value>
+ </keyword-def>
+ <keyword-def name="500">
+ <keyword-value>500</keyword-value>
+ </keyword-def>
+ <keyword-def name="600">
+ <keyword-value>600</keyword-value>
+ </keyword-def>
+ <keyword-def name="700">
+ <keyword-value>700</keyword-value>
+ </keyword-def>
+ <keyword-def name="800">
+ <keyword-value>800</keyword-value>
+ </keyword-def>
+ <keyword-def name="900">
+ <keyword-value>900</keyword-value>
+ </keyword-def>
+ <keyword-def name="above">
+ <keyword-value>above</keyword-value>
+ </keyword-def>
+ <keyword-def name="absolute">
+ <keyword-value>absolute</keyword-value>
+ </keyword-def>
+ <keyword-def name="ActiveBorder">
+ <keyword-value>ActiveBorder</keyword-value>
+ </keyword-def>
+ <keyword-def name="ActiveCaption">
+ <keyword-value>ActiveCaption</keyword-value>
+ </keyword-def>
+ <keyword-def name="all">
+ <keyword-value>all</keyword-value>
+ </keyword-def>
+ <keyword-def name="always">
+ <keyword-value>always</keyword-value>
+ </keyword-def>
+ <keyword-def name="AppWorkspace">
+ <keyword-value>AppWorkspace</keyword-value>
+ </keyword-def>
+ <keyword-def name="aqua">
+ <keyword-value>aqua</keyword-value>
+ </keyword-def>
+ <keyword-def name="armenian">
+ <keyword-value>armenian</keyword-value>
+ </keyword-def>
+ <keyword-def name="auto">
+ <keyword-value>auto</keyword-value>
+ </keyword-def>
+ <keyword-def name="avoid">
+ <keyword-value>avoid</keyword-value>
+ </keyword-def>
+ <keyword-def name="balance" version="3">
+ <keyword-value>balance</keyword-value>
+ </keyword-def>
+ <keyword-def name="Background">
+ <keyword-value>Background</keyword-value>
+ </keyword-def>
+ <keyword-def name="baseline">
+ <keyword-value>baseline</keyword-value>
+ </keyword-def>
+ <keyword-def name="behind">
+ <keyword-value>behind</keyword-value>
+ </keyword-def>
+ <keyword-def name="below">
+ <keyword-value>below</keyword-value>
+ </keyword-def>
+ <keyword-def name="bidi-override">
+ <keyword-value>bidi-override</keyword-value>
+ </keyword-def>
+ <keyword-def name="black">
+ <keyword-value>black</keyword-value>
+ </keyword-def>
+ <keyword-def name="blink">
+ <keyword-value>blink</keyword-value>
+ </keyword-def>
+ <keyword-def name="block">
+ <keyword-value>block</keyword-value>
+ </keyword-def>
+ <keyword-def name="blue">
+ <keyword-value>blue</keyword-value>
+ </keyword-def>
+ <keyword-def name="bold">
+ <keyword-value>bold</keyword-value>
+ </keyword-def>
+ <keyword-def name="bolder">
+ <keyword-value>bolder</keyword-value>
+ </keyword-def>
+ <keyword-def name="border-box" version="3">
+ <keyword-value>border-box</keyword-value>
+ </keyword-def>
+ <keyword-def name="both">
+ <keyword-value>both</keyword-value>
+ </keyword-def>
+ <keyword-def name="bottom">
+ <keyword-value>bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonFace">
+ <keyword-value>ButtonFace</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonHighlight">
+ <keyword-value>ButtonHighlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonShadow">
+ <keyword-value>ButtonShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ButtonText">
+ <keyword-value>ButtonText</keyword-value>
+ </keyword-def>
+ <keyword-def name="capitalize">
+ <keyword-value>capitalize</keyword-value>
+ </keyword-def>
+ <keyword-def name="caption">
+ <keyword-value>caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="CaptionText">
+ <keyword-value>CaptionText</keyword-value>
+ </keyword-def>
+ <keyword-def name="center">
+ <keyword-value>center</keyword-value>
+ </keyword-def>
+ <keyword-def name="center-left">
+ <keyword-value>center-left</keyword-value>
+ </keyword-def>
+ <keyword-def name="center-right">
+ <keyword-value>center-right</keyword-value>
+ </keyword-def>
+ <keyword-def name="child">
+ <keyword-value>child</keyword-value>
+ </keyword-def>
+ <keyword-def name="circle">
+ <keyword-value>circle</keyword-value>
+ </keyword-def>
+ <keyword-def name="cjk-ideographic">
+ <keyword-value>cjk-ideographic</keyword-value>
+ </keyword-def>
+ <keyword-def name="clip" version="3">
+ <keyword-value>clip</keyword-value>
+ </keyword-def>
+ <keyword-def name="close-quote">
+ <keyword-value>close-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="code">
+ <keyword-value>code</keyword-value>
+ </keyword-def>
+ <keyword-def name="collapse">
+ <keyword-value>collapse</keyword-value>
+ </keyword-def>
+ <keyword-def name="compact">
+ <keyword-value>compact</keyword-value>
+ </keyword-def>
+ <keyword-def name="condensed">
+ <keyword-value>condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="contain" version="3">
+ <keyword-value>contain</keyword-value>
+ </keyword-def>
+ <keyword-def name="content-box" version="3">
+ <keyword-value>content-box</keyword-value>
+ </keyword-def>
+ <keyword-def name="continuous">
+ <keyword-value>continuous</keyword-value>
+ </keyword-def>
+ <keyword-def name="cover" version="3">
+ <keyword-value>cover</keyword-value>
+ </keyword-def>
+ <keyword-def name="crop">
+ <keyword-value>crop</keyword-value>
+ </keyword-def>
+ <keyword-def name="cross">
+ <keyword-value>cross</keyword-value>
+ </keyword-def>
+ <keyword-def name="crosshair">
+ <keyword-value>crosshair</keyword-value>
+ </keyword-def>
+ <keyword-def name="cursive">
+ <keyword-value>cursive</keyword-value>
+ </keyword-def>
+ <keyword-def name="dashed">
+ <keyword-value>dashed</keyword-value>
+ </keyword-def>
+ <keyword-def name="decimal">
+ <keyword-value>decimal</keyword-value>
+ </keyword-def>
+ <keyword-def name="decimal-leading-zero">
+ <keyword-value>decimal-leading-zero</keyword-value>
+ </keyword-def>
+ <keyword-def name="default">
+ <keyword-value>default</keyword-value>
+ </keyword-def>
+ <keyword-def name="digits">
+ <keyword-value>digits</keyword-value>
+ </keyword-def>
+ <keyword-def name="disc">
+ <keyword-value>disc</keyword-value>
+ </keyword-def>
+ <keyword-def name="dotted">
+ <keyword-value>dotted</keyword-value>
+ </keyword-def>
+ <keyword-def name="double">
+ <keyword-value>double</keyword-value>
+ </keyword-def>
+ <keyword-def name="e-resize">
+ <keyword-value>e-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="ellipsis" version="3">
+ <keyword-value>ellipsis</keyword-value>
+ </keyword-def>
+ <keyword-def name="embed">
+ <keyword-value>embed</keyword-value>
+ </keyword-def>
+ <keyword-def name="expanded">
+ <keyword-value>expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="extra-condensed">
+ <keyword-value>extra-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="extra-expanded">
+ <keyword-value>extra-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="fantasy">
+ <keyword-value>fantasy</keyword-value>
+ </keyword-def>
+ <keyword-def name="far-left">
+ <keyword-value>far-left</keyword-value>
+ </keyword-def>
+ <keyword-def name="far-right">
+ <keyword-value>far-right</keyword-value>
+ </keyword-def>
+ <keyword-def name="fast">
+ <keyword-value>fast</keyword-value>
+ </keyword-def>
+ <keyword-def name="faster">
+ <keyword-value>faster</keyword-value>
+ </keyword-def>
+ <keyword-def name="female">
+ <keyword-value>female</keyword-value>
+ </keyword-def>
+ <keyword-def name="fixed">
+ <keyword-value>fixed</keyword-value>
+ </keyword-def>
+ <keyword-def name="fuchsia">
+ <keyword-value>fuchsia</keyword-value>
+ </keyword-def>
+ <keyword-def name="georgian">
+ <keyword-value>georgian</keyword-value>
+ </keyword-def>
+ <keyword-def name="gray">
+ <keyword-value>gray</keyword-value>
+ </keyword-def>
+ <keyword-def name="GrayText">
+ <keyword-value>GrayText</keyword-value>
+ </keyword-def>
+ <keyword-def name="green">
+ <keyword-value>green</keyword-value>
+ </keyword-def>
+ <keyword-def name="groove">
+ <keyword-value>groove</keyword-value>
+ </keyword-def>
+ <keyword-def name="hebrew">
+ <keyword-value>hebrew</keyword-value>
+ </keyword-def>
+ <keyword-def name="help">
+ <keyword-value>help</keyword-value>
+ </keyword-def>
+ <keyword-def name="hidden">
+ <keyword-value>hidden</keyword-value>
+ </keyword-def>
+ <keyword-def name="hide">
+ <keyword-value>hide</keyword-value>
+ </keyword-def>
+ <keyword-def name="high">
+ <keyword-value>high</keyword-value>
+ </keyword-def>
+ <keyword-def name="Highlight">
+ <keyword-value>Highlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="HighlightText">
+ <keyword-value>HighlightText</keyword-value>
+ </keyword-def>
+ <keyword-def name="higher">
+ <keyword-value>higher</keyword-value>
+ </keyword-def>
+ <keyword-def name="hiragana">
+ <keyword-value>hiragana</keyword-value>
+ </keyword-def>
+ <keyword-def name="hiragana-iroha">
+ <keyword-value>hiragana-iroha</keyword-value>
+ </keyword-def>
+ <keyword-def name="horizontal" version="3">
+ <keyword-value>horizontal</keyword-value>
+ </keyword-def>
+ <keyword-def name="icon">
+ <keyword-value>icon</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveBorder">
+ <keyword-value>InactiveBorder</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveCaption">
+ <keyword-value>InactiveCaption</keyword-value>
+ </keyword-def>
+ <keyword-def name="InactiveCaptionText">
+ <keyword-value>InactiveCaptionText</keyword-value>
+ </keyword-def>
+ <keyword-def name="InfoBackground">
+ <keyword-value>InfoBackground</keyword-value>
+ </keyword-def>
+ <keyword-def name="InfoText">
+ <keyword-value>InfoText</keyword-value>
+ </keyword-def>
+ <keyword-def name="inherit">
+ <keyword-value>inherit</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline">
+ <keyword-value>inline</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline-block">
+ <keyword-value>inline-block</keyword-value>
+ </keyword-def>
+ <keyword-def name="inline-table">
+ <keyword-value>inline-table</keyword-value>
+ </keyword-def>
+ <keyword-def name="inset">
+ <keyword-value>inset</keyword-value>
+ </keyword-def>
+ <keyword-def name="inside">
+ <keyword-value>inside</keyword-value>
+ </keyword-def>
+ <keyword-def name="invert">
+ <keyword-value>invert</keyword-value>
+ </keyword-def>
+ <keyword-def name="italic">
+ <keyword-value>italic</keyword-value>
+ </keyword-def>
+ <keyword-def name="justify">
+ <keyword-value>justify</keyword-value>
+ </keyword-def>
+ <keyword-def name="katakana">
+ <keyword-value>katakana</keyword-value>
+ </keyword-def>
+ <keyword-def name="katakana-iroha">
+ <keyword-value>katakana-iroha</keyword-value>
+ </keyword-def>
+ <keyword-def name="landscape">
+ <keyword-value>landscape</keyword-value>
+ </keyword-def>
+ <keyword-def name="large">
+ <keyword-value>large</keyword-value>
+ </keyword-def>
+ <keyword-def name="larger">
+ <keyword-value>larger</keyword-value>
+ </keyword-def>
+ <keyword-def name="left">
+ <keyword-value>left</keyword-value>
+ </keyword-def>
+ <keyword-def name="left-side">
+ <keyword-value>left-side</keyword-value>
+ </keyword-def>
+ <keyword-def name="leftwards">
+ <keyword-value>leftwards</keyword-value>
+ </keyword-def>
+ <keyword-def name="level">
+ <keyword-value>level</keyword-value>
+ </keyword-def>
+ <keyword-def name="lighter">
+ <keyword-value>lighter</keyword-value>
+ </keyword-def>
+ <keyword-def name="lime">
+ <keyword-value>lime</keyword-value>
+ </keyword-def>
+ <keyword-def name="line-through">
+ <keyword-value>line-through</keyword-value>
+ </keyword-def>
+ <keyword-def name="list-item">
+ <keyword-value>list-item</keyword-value>
+ </keyword-def>
+ <keyword-def name="local" version="3">
+ <keyword-value>local</keyword-value>
+ </keyword-def>
+ <keyword-def name="loud">
+ <keyword-value>loud</keyword-value>
+ </keyword-def>
+ <keyword-def name="low">
+ <keyword-value>low</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower">
+ <keyword-value>lower</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-alpha">
+ <keyword-value>lower-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-greek">
+ <keyword-value>lower-greek</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-latin">
+ <keyword-value>lower-latin</keyword-value>
+ </keyword-def>
+ <keyword-def name="lower-roman">
+ <keyword-value>lower-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="lowercase">
+ <keyword-value>lowercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="ltr">
+ <keyword-value>ltr</keyword-value>
+ </keyword-def>
+ <keyword-def name="male">
+ <keyword-value>male</keyword-value>
+ </keyword-def>
+ <keyword-def name="marker">
+ <keyword-value>marker</keyword-value>
+ </keyword-def>
+ <keyword-def name="maroon">
+ <keyword-value>maroon</keyword-value>
+ </keyword-def>
+ <keyword-def name="medium">
+ <keyword-value>medium</keyword-value>
+ </keyword-def>
+ <keyword-def name="Menu">
+ <keyword-value>Menu</keyword-value>
+ </keyword-def>
+ <keyword-def name="MenuText">
+ <keyword-value>MenuText</keyword-value>
+ </keyword-def>
+ <keyword-def name="message-box">
+ <keyword-value>message-box</keyword-value>
+ </keyword-def>
+ <keyword-def name="middle">
+ <keyword-value>middle</keyword-value>
+ </keyword-def>
+ <keyword-def name="mix">
+ <keyword-value>mix</keyword-value>
+ </keyword-def>
+ <keyword-def name="monospace">
+ <keyword-value>monospace</keyword-value>
+ </keyword-def>
+ <keyword-def name="move">
+ <keyword-value>move</keyword-value>
+ </keyword-def>
+ <keyword-def name="n-resize">
+ <keyword-value>n-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="narrower">
+ <keyword-value>narrower</keyword-value>
+ </keyword-def>
+ <keyword-def name="navy">
+ <keyword-value>navy</keyword-value>
+ </keyword-def>
+ <keyword-def name="ne-resize">
+ <keyword-value>ne-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-close-quote">
+ <keyword-value>no-close-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-open-quote">
+ <keyword-value>no-open-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="no-repeat">
+ <keyword-value>no-repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="none">
+ <keyword-value>none</keyword-value>
+ </keyword-def>
+ <keyword-def name="normal">
+ <keyword-value>normal</keyword-value>
+ </keyword-def>
+ <keyword-def name="nowrap">
+ <keyword-value>nowrap</keyword-value>
+ </keyword-def>
+ <keyword-def name="nw-resize">
+ <keyword-value>nw-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="oblique">
+ <keyword-value>oblique</keyword-value>
+ </keyword-def>
+ <keyword-def name="olive">
+ <keyword-value>olive</keyword-value>
+ </keyword-def>
+ <keyword-def name="once">
+ <keyword-value>once</keyword-value>
+ </keyword-def>
+ <keyword-def name="open-quote">
+ <keyword-value>open-quote</keyword-value>
+ </keyword-def>
+ <keyword-def name="orange">
+ <keyword-value>orange</keyword-value>
+ </keyword-def>
+ <keyword-def name="outset">
+ <keyword-value>outset</keyword-value>
+ </keyword-def>
+ <keyword-def name="outside">
+ <keyword-value>outside</keyword-value>
+ </keyword-def>
+ <keyword-def name="overline">
+ <keyword-value>overline</keyword-value>
+ </keyword-def>
+ <keyword-def name="padding-box" version="3">
+ <keyword-value>padding-box</keyword-value>
+ </keyword-def>
+ <keyword-def name="pointer">
+ <keyword-value>pointer</keyword-value>
+ </keyword-def>
+ <keyword-def name="portrait">
+ <keyword-value>portrait</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre">
+ <keyword-value>pre</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre-line">
+ <keyword-value>pre-line</keyword-value>
+ </keyword-def>
+ <keyword-def name="pre-wrap">
+ <keyword-value>pre-wrap</keyword-value>
+ </keyword-def>
+ <keyword-def name="progress">
+ <keyword-value>progress</keyword-value>
+ </keyword-def>
+ <keyword-def name="purple">
+ <keyword-value>purple</keyword-value>
+ </keyword-def>
+ <keyword-def name="red">
+ <keyword-value>red</keyword-value>
+ </keyword-def>
+ <keyword-def name="relative">
+ <keyword-value>relative</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat">
+ <keyword-value>repeat</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-x">
+ <keyword-value>repeat-x</keyword-value>
+ </keyword-def>
+ <keyword-def name="repeat-y">
+ <keyword-value>repeat-y</keyword-value>
+ </keyword-def>
+ <keyword-def name="ridge">
+ <keyword-value>ridge</keyword-value>
+ </keyword-def>
+ <keyword-def name="right">
+ <keyword-value>right</keyword-value>
+ </keyword-def>
+ <keyword-def name="right-side">
+ <keyword-value>right-side</keyword-value>
+ </keyword-def>
+ <keyword-def name="rightwards">
+ <keyword-value>rightwards</keyword-value>
+ </keyword-def>
+ <keyword-def name="round" version="3">
+ <keyword-value>round</keyword-value>
+ </keyword-def>
+ <keyword-def name="rtl">
+ <keyword-value>rtl</keyword-value>
+ </keyword-def>
+ <keyword-def name="run-in">
+ <keyword-value>run-in</keyword-value>
+ </keyword-def>
+ <keyword-def name="s-resize">
+ <keyword-value>s-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="sans-serif">
+ <keyword-value>sans-serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="scroll">
+ <keyword-value>scroll</keyword-value>
+ </keyword-def>
+ <keyword-def name="Scrollbar">
+ <keyword-value>Scrollbar</keyword-value>
+ </keyword-def>
+ <keyword-def name="se-resize">
+ <keyword-value>se-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="semi-condensed">
+ <keyword-value>semi-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="semi-expanded">
+ <keyword-value>semi-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="separate">
+ <keyword-value>separate</keyword-value>
+ </keyword-def>
+ <keyword-def name="serif">
+ <keyword-value>serif</keyword-value>
+ </keyword-def>
+ <keyword-def name="show">
+ <keyword-value>show</keyword-value>
+ </keyword-def>
+ <keyword-def name="silent">
+ <keyword-value>silent</keyword-value>
+ </keyword-def>
+ <keyword-def name="silver">
+ <keyword-value>silver</keyword-value>
+ </keyword-def>
+ <keyword-def name="slow">
+ <keyword-value>slow</keyword-value>
+ </keyword-def>
+ <keyword-def name="slower">
+ <keyword-value>slower</keyword-value>
+ </keyword-def>
+ <keyword-def name="small">
+ <keyword-value>small</keyword-value>
+ </keyword-def>
+ <keyword-def name="small-caps">
+ <keyword-value>small-caps</keyword-value>
+ </keyword-def>
+ <keyword-def name="small-caption">
+ <keyword-value>small-caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="smaller">
+ <keyword-value>smaller</keyword-value>
+ </keyword-def>
+ <keyword-def name="soft">
+ <keyword-value>soft</keyword-value>
+ </keyword-def>
+ <keyword-def name="solid">
+ <keyword-value>solid</keyword-value>
+ </keyword-def>
+ <keyword-def name="space" version="3">
+ <keyword-value>space</keyword-value>
+ </keyword-def>
+ <keyword-def name="spell-out">
+ <keyword-value>spell-out</keyword-value>
+ </keyword-def>
+ <keyword-def name="square">
+ <keyword-value>square</keyword-value>
+ </keyword-def>
+ <keyword-def name="static">
+ <keyword-value>static</keyword-value>
+ </keyword-def>
+ <keyword-def name="status-bar">
+ <keyword-value>status-bar</keyword-value>
+ </keyword-def>
+ <keyword-def name="sub">
+ <keyword-value>sub</keyword-value>
+ </keyword-def>
+ <keyword-def name="super">
+ <keyword-value>super</keyword-value>
+ </keyword-def>
+ <keyword-def name="sw-resize">
+ <keyword-value>sw-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="table">
+ <keyword-value>table</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-caption">
+ <keyword-value>table-caption</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-cell">
+ <keyword-value>table-cell</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-column">
+ <keyword-value>table-column</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-column-group">
+ <keyword-value>table-column-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-footer-group">
+ <keyword-value>table-footer-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-header-group">
+ <keyword-value>table-header-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-row">
+ <keyword-value>table-row</keyword-value>
+ </keyword-def>
+ <keyword-def name="table-row-group">
+ <keyword-value>table-row-group</keyword-value>
+ </keyword-def>
+ <keyword-def name="teal">
+ <keyword-value>teal</keyword-value>
+ </keyword-def>
+ <keyword-def name="text">
+ <keyword-value>text</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-top">
+ <keyword-value>text-top</keyword-value>
+ </keyword-def>
+ <keyword-def name="text-bottom">
+ <keyword-value>text-bottom</keyword-value>
+ </keyword-def>
+ <keyword-def name="thick">
+ <keyword-value>thick</keyword-value>
+ </keyword-def>
+ <keyword-def name="thin">
+ <keyword-value>thin</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDDarkShadow">
+ <keyword-value>ThreeDDarkShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDFace">
+ <keyword-value>ThreeDFace</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDHighlight">
+ <keyword-value>ThreeDHighlight</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDLightShadow">
+ <keyword-value>ThreeDLightShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="ThreeDShadow">
+ <keyword-value>ThreeDShadow</keyword-value>
+ </keyword-def>
+ <keyword-def name="top">
+ <keyword-value>top</keyword-value>
+ </keyword-def>
+ <keyword-def name="transparent">
+ <keyword-value>transparent</keyword-value>
+ </keyword-def>
+ <keyword-def name="ultra-condensed">
+ <keyword-value>ultra-condensed</keyword-value>
+ </keyword-def>
+ <keyword-def name="ultra-expanded">
+ <keyword-value>ultra-expanded</keyword-value>
+ </keyword-def>
+ <keyword-def name="underline">
+ <keyword-value>underline</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-alpha">
+ <keyword-value>upper-alpha</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-latin">
+ <keyword-value>upper-latin</keyword-value>
+ </keyword-def>
+ <keyword-def name="upper-roman">
+ <keyword-value>upper-roman</keyword-value>
+ </keyword-def>
+ <keyword-def name="uppercase">
+ <keyword-value>uppercase</keyword-value>
+ </keyword-def>
+ <keyword-def name="vertical" version="3">
+ <keyword-value>vertical</keyword-value>
+ </keyword-def>
+ <keyword-def name="visible">
+ <keyword-value>visible</keyword-value>
+ </keyword-def>
+ <keyword-def name="w-resize">
+ <keyword-value>w-resize</keyword-value>
+ </keyword-def>
+ <keyword-def name="wait">
+ <keyword-value>wait</keyword-value>
+ </keyword-def>
+ <keyword-def name="white">
+ <keyword-value>white</keyword-value>
+ </keyword-def>
+ <keyword-def name="wider">
+ <keyword-value>wider</keyword-value>
+ </keyword-def>
+ <keyword-def name="Window">
+ <keyword-value>Window</keyword-value>
+ </keyword-def>
+ <keyword-def name="WindowFrame">
+ <keyword-value>WindowFrame</keyword-value>
+ </keyword-def>
+ <keyword-def name="WindowText">
+ <keyword-value>WindowText</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-fast">
+ <keyword-value>x-fast</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-high">
+ <keyword-value>x-high</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-large">
+ <keyword-value>x-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-loud">
+ <keyword-value>x-loud</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-low">
+ <keyword-value>x-low</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-slow">
+ <keyword-value>x-slow</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-small">
+ <keyword-value>x-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="x-soft">
+ <keyword-value>x-soft</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-small">
+ <keyword-value>xx-small</keyword-value>
+ </keyword-def>
+ <keyword-def name="xx-large">
+ <keyword-value>xx-large</keyword-value>
+ </keyword-def>
+ <keyword-def name="yellow">
+ <keyword-value>yellow</keyword-value>
+ </keyword-def>
+</css-profile>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-mobile1_0.xml b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-mobile1_0.xml
new file mode 100644
index 0000000..2d5d761
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-mobile1_0.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!--<!DOCTYPE css-profile SYSTEM "css-profile.dtd" >-->
+<css-profile>
+ <profile-import name="cssprofile-css2.xml"/>
+ <stylesheet-def>
+ <description>%mobile1_0.stylesheet-def.description</description>
+ <charset-rule/>
+ <import-rule/>
+ <media-rule/>
+ <style-rule/>
+ </stylesheet-def>
+
+ <!-- Which properties can style rule include ? -->
+ <!-- using "overwrite" method: only disabled properties are written. -->
+
+ <style-rule-def overwrite="true">
+ <selector-expression name="child" enabled="false"/>
+ <selector-expression name="adjacent" enabled="false"/>
+ <selector-expression name="attribute" enabled="false"/>
+ <pseudo-class name="first-child" enabled="false"/>
+ <pseudo-class name="link" enabled="false"/>
+ <pseudo-class name="active" enabled="false"/>
+ <pseudo-class name="lang" enabled="false"/>
+ <property name="azimuth" enabled="false"/>
+ <property name="border-collapse" enabled="false"/>
+ <property name="border-spacing" enabled="false"/>
+ <property name="bottom" enabled="false"/>
+ <property name="caption-side" enabled="false"/>
+ <property name="clip" enabled="false"/>
+ <property name="content" enabled="false"/>
+ <property name="counter-increment" enabled="false"/>
+ <property name="counter-reset" enabled="false"/>
+ <property name="cue" enabled="false"/>
+ <property name="cue-after" enabled="false"/>
+ <property name="cue-before" enabled="false"/>
+ <property name="cursor" enabled="false"/>
+ <property name="direction" enabled="false"/>
+ <property name="elevation" enabled="false"/>
+ <property name="empty-cells" enabled="false"/>
+ <property name="font-size-adjust" enabled="false"/>
+ <property name="font-stretch" enabled="false"/>
+ <property name="left" enabled="false"/>
+ <property name="letter-spacing" enabled="false"/>
+ <property name="line-height" enabled="false"/>
+ <property name="marker-offset" enabled="false"/>
+ <property name="marks" enabled="false"/>
+ <property name="max-height" enabled="false"/>
+ <property name="max-width" enabled="false"/>
+ <property name="min-height" enabled="false"/>
+ <property name="min-width" enabled="false"/>
+ <property name="orphans" enabled="false"/>
+ <property name="outline" enabled="false"/>
+ <property name="outline-color" enabled="false"/>
+ <property name="outline-style" enabled="false"/>
+ <property name="outline-width" enabled="false"/>
+ <property name="overflow" enabled="false"/>
+ <property name="page" enabled="false"/>
+ <property name="page-break-after" enabled="false"/>
+ <property name="page-break-before" enabled="false"/>
+ <property name="page-break-inside" enabled="false"/>
+ <property name="pause" enabled="false"/>
+ <property name="pause-after" enabled="false"/>
+ <property name="pause-before" enabled="false"/>
+ <property name="pitch" enabled="false"/>
+ <property name="pitch-range" enabled="false"/>
+ <property name="play-during" enabled="false"/>
+ <property name="position" enabled="false"/>
+ <property name="quotes" enabled="false"/>
+ <property name="richness" enabled="false"/>
+ <property name="right" enabled="false"/>
+ <property name="size" enabled="false"/>
+ <property name="speak" enabled="false"/>
+ <property name="speak-header" enabled="false"/>
+ <property name="speak-numeral" enabled="false"/>
+ <property name="speak-punctuation" enabled="false"/>
+ <property name="speech-rate" enabled="false"/>
+ <property name="stress" enabled="false"/>
+ <property name="table-layout" enabled="false"/>
+ <property name="text-shadow" enabled="false"/>
+ <property name="top" enabled="false"/>
+ <property name="unicode-bidi" enabled="false"/>
+ <property name="voice-family" enabled="false"/>
+ <property name="volume" enabled="false"/>
+ <property name="widows" enabled="false"/>
+ <property name="word-spacing" enabled="false"/>
+ <property name="z-index" enabled="false"/>
+ </style-rule-def>
+
+ <!-- property definition -->
+ <!-- using "redifine" method: if "overwrite" attribute is set to
+ "false" or not set, it means the node is cleanly redifined -->
+
+ <property-def name="background-attachment"
+ inherited="no" mediagroup="visual" category="colorandbackground">
+ <keyword name="scroll"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="display"
+ inherited="no" mediagroup="all" category="visual">
+ <keyword name="inline"/>
+ <keyword name="block"/>
+ <keyword name="list-item"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="list-style-type"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-greek"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-align"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="center"/>
+ <keyword name="justify"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-decoration"
+ inherited="no" mediagroup="visual" category="text">
+ <keyword name="none"/>
+ <keyword name="underline"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="vertical-align"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="baseline"/>
+ <keyword name="sub"/>
+ <keyword name="super"/>
+ <keyword name="inherit"/>
+ </property-def>
+
+ <!-- container definition : Container is the lump of values.
+ It can be used like macros. -->
+ <container-def name="color" overwrite="true">
+ <container name="system-color" enabled="false"/>
+ </container-def>
+</css-profile>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-wap.xml b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-wap.xml
new file mode 100644
index 0000000..ad401c1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile-wap.xml
@@ -0,0 +1,630 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ -->
+<!--<!DOCTYPE css-profile SYSTEM "css-profile.dtd" >-->
+<css-profile>
+ <profile-import name="cssprofile-css2.xml"/>
+ <stylesheet-def>
+ <description>%wap.stylesheet-def.description</description>
+ <charset-rule/>
+ <import-rule/>
+ <media-rule/>
+ <style-rule/>
+ </stylesheet-def>
+
+ <!-- Which properties can style rule include ? -->
+ <!-- using "overwrite" method: only disabled properties are written. -->
+
+ <style-rule-def overwrite="true">
+ <property name="azimuth" enabled="false"/>
+ <property name="border-collapse" enabled="false"/>
+ <property name="border-spacing" enabled="false"/>
+ <property name="bottom" enabled="false"/>
+ <property name="caption-side" enabled="false"/>
+ <property name="clip" enabled="false"/>
+ <property name="content" enabled="false"/>
+ <property name="cue" enabled="false"/>
+ <property name="cue-after" enabled="false"/>
+ <property name="cue-before" enabled="false"/>
+ <property name="cursor" enabled="false"/>
+ <property name="direction" enabled="false"/>
+ <property name="elevation" enabled="false"/>
+ <property name="empty-cells" enabled="false"/>
+ <property name="font-size-adjust" enabled="false"/>
+ <property name="font-stretch" enabled="false"/>
+ <property name="left" enabled="false"/>
+ <property name="letter-spacing" enabled="false"/>
+ <property name="line-height" enabled="false"/>
+ <property name="marker-offset" enabled="false"/>
+ <property name="marks" enabled="false"/>
+ <property name="max-height" enabled="false"/>
+ <property name="max-width" enabled="false"/>
+ <property name="min-height" enabled="false"/>
+ <property name="min-width" enabled="false"/>
+ <property name="orphans" enabled="false"/>
+ <property name="outline" enabled="false"/>
+ <property name="outline-color" enabled="false"/>
+ <property name="outline-style" enabled="false"/>
+ <property name="outline-width" enabled="false"/>
+ <property name="overflow" enabled="false"/>
+ <property name="page" enabled="false"/>
+ <property name="page-break-after" enabled="false"/>
+ <property name="page-break-before" enabled="false"/>
+ <property name="page-break-inside" enabled="false"/>
+ <property name="pause" enabled="false"/>
+ <property name="pause-after" enabled="false"/>
+ <property name="pause-before" enabled="false"/>
+ <property name="pitch" enabled="false"/>
+ <property name="pitch-range" enabled="false"/>
+ <property name="play-during" enabled="false"/>
+ <property name="position" enabled="false"/>
+ <property name="quotes" enabled="false"/>
+ <property name="richness" enabled="false"/>
+ <property name="right" enabled="false"/>
+ <property name="size" enabled="false"/>
+ <property name="speak" enabled="false"/>
+ <property name="speak-header" enabled="false"/>
+ <property name="speak-numeral" enabled="false"/>
+ <property name="speak-punctuation" enabled="false"/>
+ <property name="speech-rate" enabled="false"/>
+ <property name="stress" enabled="false"/>
+ <property name="table-layout" enabled="false"/>
+ <property name="text-shadow" enabled="false"/>
+ <property name="top" enabled="false"/>
+ <property name="unicode-bidi" enabled="false"/>
+ <property name="voice-family" enabled="false"/>
+ <property name="volume" enabled="false"/>
+ <property name="widows" enabled="false"/>
+ <property name="word-spacing" enabled="false"/>
+ <property name="z-index" enabled="false"/>
+ <property name="-wap-marquee-style"/>
+ <property name="-wap-marquee-loop"/>
+ <property name="-wap-marquee-dir"/>
+ <property name="-wap-marquee-speed"/>
+ <property name="-wap-accesskey"/>
+ <property name="-wap-input-format"/>
+ <property name="-wap-input-required"/>
+ </style-rule-def>
+
+ <!-- property definition -->
+ <!-- using "redifine" method: if "overwrite" attribute is set to
+ "false" or not set, it means the node is cleanly redifined -->
+
+ <property-def name="display"
+ inherited="no" mediagroup="all" category="visual">
+ <keyword name="inline"/>
+ <keyword name="block"/>
+ <keyword name="list-item"/>
+ <keyword name="-wap-marquee"/>
+ <keyword name="none"/>
+ </property-def>
+ <property-def name="list-style-type"
+ inherited="yes" mediagroup="visual" category="content">
+ <keyword name="disc"/>
+ <keyword name="circle"/>
+ <keyword name="square"/>
+ <keyword name="decimal"/>
+ <keyword name="lower-roman"/>
+ <keyword name="upper-roman"/>
+ <keyword name="lower-alpha"/>
+ <keyword name="upper-alpha"/>
+ <keyword name="none"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-align"
+ inherited="yes" mediagroup="visual" category="text">
+ <keyword name="left"/>
+ <keyword name="right"/>
+ <keyword name="center"/>
+ <keyword name="justify"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="text-decoration"
+ inherited="no" mediagroup="visual" category="text">
+ <keyword name="none"/>
+ <keyword name="underline"/>
+ <keyword name="blink"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="vertical-align"
+ inherited="no" mediagroup="visual" category="visual">
+ <keyword name="baseline"/>
+ <keyword name="sub"/>
+ <keyword name="super"/>
+ <keyword name="top"/>
+ <keyword name="middle"/>
+ <keyword name="bottom"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-marquee-style"
+ inherited="no" mediagroup="visual" category="wap">
+ <keyword name="scroll"/>
+ <keyword name="slide"/>
+ <keyword name="alternate"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-marquee-loop"
+ inherited="no" mediagroup="visual" category="wap">
+ <number name="integer"/>
+ <keyword name="infinite"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-marquee-dir"
+ inherited="no" mediagroup="visual" category="wap">
+ <keyword name="ltr"/>
+ <keyword name="rtl"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-marquee-speed"
+ inherited="no" mediagroup="visual" category="wap">
+ <keyword name="slow"/>
+ <keyword name="normal"/>
+ <keyword name="fast"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-accesskey"
+ inherited="no" mediagroup="interactive" category="wap">
+ <container name="keycombination"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-input-format"
+ inherited="no" mediagroup="interactive" category="wap">
+ <container name="format"/>
+ <keyword name="inherit"/>
+ </property-def>
+ <property-def name="-wap-input-required"
+ inherited="no" mediagroup="interactive" category="wap">
+ <keyword name="true"/>
+ <keyword name="false"/>
+ <keyword name="inherit"/>
+ </property-def>
+
+ <!-- container definition : Container is the lump of values.
+ It can be used like macros. -->
+ <container-def name="color" overwrite="true">
+ <container name="system-color" enabled="false"/>
+ </container-def>
+ <container-def name="format">
+ <string name="any"/>
+ </container-def>
+ <container-def name="keycombination">
+ <container name="key"/>
+ <keyword name="-"/>
+ </container-def>
+ <container-def name="key">
+ <keyword name="space"/>
+ <container name="specialkey"/>
+ </container-def>
+ <container-def name="specialkey">
+ <container name="modifierkey"/>
+ <container name="functionkey"/>
+ <container name="navigationkey"/>
+ <container name="editkey"/>
+ <container name="misckey"/>
+ <container name="volumecontrolkey"/>
+ <container name="applicationkey"/>
+ <container name="phonekey"/>
+ <container name="vendorkey"/>
+ </container-def>
+ <container-def name="modifierkey">
+ <keyword name="accesskey"/>
+ <container name="cmdkey"/>
+ <container name="optkey"/>
+ <container name="ctrlkey"/>
+ <container name="shiftkey"/>
+ <container name="altkey"/>
+ <container name="winkey"/>
+ <container name="metakey"/>
+ <keyword name="fn"/>
+ <keyword name="fcn"/>
+ <keyword name="caps"/>
+ </container-def>
+ <container-def name="cmdkey">
+ <keyword name="cmd"/>
+ <keyword name="rcmd"/>
+ <keyword name="lcmd"/>
+ </container-def>
+ <container-def name="optkey">
+ <keyword name="opt"/>
+ <keyword name="ropt"/>
+ <keyword name="lopt"/>
+ </container-def>
+ <container-def name="ctrlkey">
+ <keyword name="ctrl"/>
+ <keyword name="rctrl"/>
+ <keyword name="lctrl"/>
+ </container-def>
+ <container-def name="shiftkey">
+ <keyword name="shift"/>
+ <keyword name="rshift"/>
+ <keyword name="lshift"/>
+ </container-def>
+ <container-def name="altkey">
+ <keyword name="alt"/>
+ <keyword name="ralt"/>
+ <keyword name="lalt"/>
+ </container-def>
+ <container-def name="winkey">
+ <keyword name="win"/>
+ <keyword name="rwin"/>
+ <keyword name="lwin"/>
+ </container-def>
+ <container-def name="metakey">
+ <keyword name="meta"/>
+ <keyword name="rmeta"/>
+ <keyword name="lmeta"/>
+ </container-def>
+ <container-def name="functionkey">
+ <keyword name="f1"/>
+ <keyword name="f2"/>
+ <keyword name="f3"/>
+ <keyword name="f4"/>
+ <keyword name="f5"/>
+ <keyword name="f6"/>
+ <keyword name="f7"/>
+ <keyword name="f8"/>
+ <keyword name="f9"/>
+ <keyword name="f10"/>
+ <keyword name="f11"/>
+ <keyword name="f12"/>
+ <keyword name="f13"/>
+ <keyword name="f14"/>
+ <keyword name="f15"/>
+ </container-def>
+ <container-def name="navigationkey">
+ <keyword name="tab"/>
+ <keyword name="esc"/>
+ <keyword name="enter"/>
+ <keyword name="return"/>
+ <keyword name="menu"/>
+ <keyword name="help"/>
+ <keyword name="namemenu"/>
+ <keyword name="rcl"/>
+ <keyword name="snd"/>
+ <keyword name="arrowkey"/>
+ <keyword name="pagekey"/>
+ </container-def>
+ <container-def name="arrowkey">
+ <keyword name="up"/>
+ <keyword name="down"/>
+ <keyword name="left"/>
+ <keyword name="right"/>
+ </container-def>
+ <container-def name="pagekey">
+ <keyword name="home"/>
+ <keyword name="end"/>
+ <keyword name="pgup"/>
+ <keyword name="pgdn"/>
+ </container-def>
+ <container-def name="editkey">
+ <keyword name="bs"/>
+ <keyword name="del"/>
+ <keyword name="ins"/>
+ <keyword name="undo"/>
+ <keyword name="cut"/>
+ <keyword name="copy"/>
+ <keyword name="paste"/>
+ <keyword name="clr"/>
+ <keyword name="sto"/>
+ </container-def>
+ <container-def name="misckey">
+ <keyword name="prtsc"/>
+ <keyword name="sysrq"/>
+ <keyword name="scrlock"/>
+ <keyword name="pause"/>
+ <keyword name="brk"/>
+ <keyword name="numlock"/>
+ <keyword name="pwr"/>
+ </container-def>
+ <container-def name="volumecontrolkey">
+ <keyword name="volumeup"/>
+ <keyword name="volumedown"/>
+ </container-def>
+ <container-def name="applicationkey">
+ <keyword name="memo"/>
+ <keyword name="todo"/>
+ <keyword name="calendar"/>
+ <keyword name="mail"/>
+ <keyword name="address"/>
+ </container-def>
+ <container-def name="phonekey">
+ <keyword name="phone-send"/>
+ <keyword name="phone-end"/>
+ <keyword name="phone-accept"/>
+ </container-def>
+ <container-def name="vendorkey">
+ <keyword name="vnd."/>
+ </container-def>
+
+ <category-def name="wap">
+ <caption>%wap.category-def.wap.caption</caption>
+ </category-def>
+
+ <number-def name="length">
+ <unit name="em"/>
+ <unit name="ex"/>
+ <unit name="px"/>
+ </number-def>
+
+ <keyword-def name="-wap-marquee">
+ <keyword-value>-wap-marquee</keyword-value>
+ </keyword-def>
+ <keyword-def name="slide">
+ <keyword-value>slide</keyword-value>
+ </keyword-def>
+ <keyword-def name="alternate">
+ <keyword-value>alternate</keyword-value>
+ </keyword-def>
+ <keyword-def name="infinite">
+ <keyword-value>infinite</keyword-value>
+ </keyword-def>
+ <keyword-def name="-">
+ <keyword-value>-</keyword-value>
+ </keyword-def>
+ <keyword-def name="space">
+ <keyword-value>space</keyword-value>
+ </keyword-def>
+ <keyword-def name="accesskey">
+ <keyword-value>accesskey</keyword-value>
+ </keyword-def>
+ <keyword-def name="fn">
+ <keyword-value>fn</keyword-value>
+ </keyword-def>
+ <keyword-def name="fcn">
+ <keyword-value>fcn</keyword-value>
+ </keyword-def>
+ <keyword-def name="caps">
+ <keyword-value>caps</keyword-value>
+ </keyword-def>
+ <keyword-def name="cmd">
+ <keyword-value>cmd</keyword-value>
+ </keyword-def>
+ <keyword-def name="rcmd">
+ <keyword-value>rcmd</keyword-value>
+ </keyword-def>
+ <keyword-def name="lcmd">
+ <keyword-value>lcmd</keyword-value>
+ </keyword-def>
+ <keyword-def name="opt">
+ <keyword-value>opt</keyword-value>
+ </keyword-def>
+ <keyword-def name="ropt">
+ <keyword-value>ropt</keyword-value>
+ </keyword-def>
+ <keyword-def name="lopt">
+ <keyword-value>lopt</keyword-value>
+ </keyword-def>
+ <keyword-def name="ctrl">
+ <keyword-value>ctrl</keyword-value>
+ </keyword-def>
+ <keyword-def name="rctrl">
+ <keyword-value>rctrl</keyword-value>
+ </keyword-def>
+ <keyword-def name="lctrl">
+ <keyword-value>lctrl</keyword-value>
+ </keyword-def>
+ <keyword-def name="shift">
+ <keyword-value>shift</keyword-value>
+ </keyword-def>
+ <keyword-def name="rshift">
+ <keyword-value>rshift</keyword-value>
+ </keyword-def>
+ <keyword-def name="lshift">
+ <keyword-value>lshift</keyword-value>
+ </keyword-def>
+ <keyword-def name="alt">
+ <keyword-value>alt</keyword-value>
+ </keyword-def>
+ <keyword-def name="ralt">
+ <keyword-value>ralt</keyword-value>
+ </keyword-def>
+ <keyword-def name="lalt">
+ <keyword-value>lalt</keyword-value>
+ </keyword-def>
+ <keyword-def name="win">
+ <keyword-value>win</keyword-value>
+ </keyword-def>
+ <keyword-def name="rwin">
+ <keyword-value>rwin</keyword-value>
+ </keyword-def>
+ <keyword-def name="lwin">
+ <keyword-value>lwin</keyword-value>
+ </keyword-def>
+ <keyword-def name="meta">
+ <keyword-value>meta</keyword-value>
+ </keyword-def>
+ <keyword-def name="rmeta">
+ <keyword-value>rmeta</keyword-value>
+ </keyword-def>
+ <keyword-def name="lmeta">
+ <keyword-value>lmeta</keyword-value>
+ </keyword-def>
+ <keyword-def name="f1">
+ <keyword-value>f1</keyword-value>
+ </keyword-def>
+ <keyword-def name="f2">
+ <keyword-value>f2</keyword-value>
+ </keyword-def>
+ <keyword-def name="f3">
+ <keyword-value>f3</keyword-value>
+ </keyword-def>
+ <keyword-def name="f4">
+ <keyword-value>f4</keyword-value>
+ </keyword-def>
+ <keyword-def name="f5">
+ <keyword-value>f5</keyword-value>
+ </keyword-def>
+ <keyword-def name="f6">
+ <keyword-value>f6</keyword-value>
+ </keyword-def>
+ <keyword-def name="f7">
+ <keyword-value>f7</keyword-value>
+ </keyword-def>
+ <keyword-def name="f8">
+ <keyword-value>f8</keyword-value>
+ </keyword-def>
+ <keyword-def name="f9">
+ <keyword-value>f9</keyword-value>
+ </keyword-def>
+ <keyword-def name="f10">
+ <keyword-value>f10</keyword-value>
+ </keyword-def>
+ <keyword-def name="f11">
+ <keyword-value>f11</keyword-value>
+ </keyword-def>
+ <keyword-def name="f12">
+ <keyword-value>f12</keyword-value>
+ </keyword-def>
+ <keyword-def name="f13">
+ <keyword-value>f13</keyword-value>
+ </keyword-def>
+ <keyword-def name="f14">
+ <keyword-value>f14</keyword-value>
+ </keyword-def>
+ <keyword-def name="f15">
+ <keyword-value>f15</keyword-value>
+ </keyword-def>
+ <keyword-def name="tab">
+ <keyword-value>tab</keyword-value>
+ </keyword-def>
+ <keyword-def name="esc">
+ <keyword-value>esc</keyword-value>
+ </keyword-def>
+ <keyword-def name="enter">
+ <keyword-value>enter</keyword-value>
+ </keyword-def>
+ <keyword-def name="return">
+ <keyword-value>return</keyword-value>
+ </keyword-def>
+ <keyword-def name="namemenu">
+ <keyword-value>namemenu</keyword-value>
+ </keyword-def>
+ <keyword-def name="rcl">
+ <keyword-value>rcl</keyword-value>
+ </keyword-def>
+ <keyword-def name="snd">
+ <keyword-value>snd</keyword-value>
+ </keyword-def>
+ <keyword-def name="arrowkey">
+ <keyword-value>arrowkey</keyword-value>
+ </keyword-def>
+ <keyword-def name="pagekey">
+ <keyword-value>pagekey</keyword-value>
+ </keyword-def>
+ <keyword-def name="up">
+ <keyword-value>up</keyword-value>
+ </keyword-def>
+ <keyword-def name="down">
+ <keyword-value>down</keyword-value>
+ </keyword-def>
+ <keyword-def name="home">
+ <keyword-value>home</keyword-value>
+ </keyword-def>
+ <keyword-def name="end">
+ <keyword-value>end</keyword-value>
+ </keyword-def>
+ <keyword-def name="pgup">
+ <keyword-value>pgup</keyword-value>
+ </keyword-def>
+ <keyword-def name="pgdn">
+ <keyword-value>pgdn</keyword-value>
+ </keyword-def>
+ <keyword-def name="bs">
+ <keyword-value>bs</keyword-value>
+ </keyword-def>
+ <keyword-def name="del">
+ <keyword-value>del</keyword-value>
+ </keyword-def>
+ <keyword-def name="ins">
+ <keyword-value>ins</keyword-value>
+ </keyword-def>
+ <keyword-def name="undo">
+ <keyword-value>undo</keyword-value>
+ </keyword-def>
+ <keyword-def name="cut">
+ <keyword-value>cut</keyword-value>
+ </keyword-def>
+ <keyword-def name="copy">
+ <keyword-value>copy</keyword-value>
+ </keyword-def>
+ <keyword-def name="paste">
+ <keyword-value>paste</keyword-value>
+ </keyword-def>
+ <keyword-def name="clr">
+ <keyword-value>clr</keyword-value>
+ </keyword-def>
+ <keyword-def name="sto">
+ <keyword-value>sto</keyword-value>
+ </keyword-def>
+ <keyword-def name="prtsc">
+ <keyword-value>prtsc</keyword-value>
+ </keyword-def>
+ <keyword-def name="sysrq">
+ <keyword-value>sysrq</keyword-value>
+ </keyword-def>
+ <keyword-def name="scrlock">
+ <keyword-value>scrlock</keyword-value>
+ </keyword-def>
+ <keyword-def name="brk">
+ <keyword-value>brk</keyword-value>
+ </keyword-def>
+ <keyword-def name="numlock">
+ <keyword-value>numlock</keyword-value>
+ </keyword-def>
+ <keyword-def name="pwr">
+ <keyword-value>pwr</keyword-value>
+ </keyword-def>
+ <keyword-def name="volumeup">
+ <keyword-value>volumeup</keyword-value>
+ </keyword-def>
+ <keyword-def name="volumedown">
+ <keyword-value>volumedown</keyword-value>
+ </keyword-def>
+ <keyword-def name="memo">
+ <keyword-value>memo</keyword-value>
+ </keyword-def>
+ <keyword-def name="todo">
+ <keyword-value>todo</keyword-value>
+ </keyword-def>
+ <keyword-def name="calendar">
+ <keyword-value>calendar</keyword-value>
+ </keyword-def>
+ <keyword-def name="mail">
+ <keyword-value>mail</keyword-value>
+ </keyword-def>
+ <keyword-def name="address">
+ <keyword-value>address</keyword-value>
+ </keyword-def>
+ <keyword-def name="phone-send">
+ <keyword-value>phone-send</keyword-value>
+ </keyword-def>
+ <keyword-def name="phone-end">
+ <keyword-value>phone-end</keyword-value>
+ </keyword-def>
+ <keyword-def name="phone-accept">
+ <keyword-value>phone-accept</keyword-value>
+ </keyword-def>
+ <keyword-def name="vnd.">
+ <keyword-value>vnd.</keyword-value>
+ </keyword-def>
+ <keyword-def name="true">
+ <keyword-value>true</keyword-value>
+ </keyword-def>
+ <keyword-def name="false">
+ <keyword-value>false</keyword-value>
+ </keyword-def>
+ <keyword-def name="pause">
+ <keyword-value>pause</keyword-value>
+ </keyword-def>
+
+</css-profile>
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile.properties b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile.properties
new file mode 100644
index 0000000..dd7e399
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/cssprofile.properties
@@ -0,0 +1,34 @@
+###############################################################################
+# Copyright (c) 2004 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+# cssprofile-css1.xml
+css1.stylesheet-def.description=Cascading Style Sheets, level 1
+css1.category-def.box.caption=Box model
+css1.category-def.colorandbackground.caption=Colors and Backgrounds
+css1.category-def.classification.caption=Classification
+css1.category-def.font.caption=Font
+css1.category-def.text.caption=Text
+# cssprofile-css2.xml
+css2.stylesheet-def.description=Cascading Style Sheets, level 2
+css2.category-def.aural.caption=Aural
+css2.category-def.box.caption=Box model
+css2.category-def.colorandbackground.caption=Colors and Backgrounds
+css2.category-def.content.caption=Generated content/List
+css2.category-def.font.caption=Fonts
+css2.category-def.page.caption=Paged media
+css2.category-def.tables.caption=Tables
+css2.category-def.text.caption=Text
+css2.category-def.visual.caption=Visual
+css2.category-def.ui.caption=User interface
+# cssprofile-mobile1_0.xml
+mobile1_0.stylesheet-def.description=CSS Mobile Profile 1.0
+# cssprofile-wap.xml
+wap.stylesheet-def.description=WCSS 1.0
+wap.category-def.wap.caption=WCSS Extensions
diff --git a/bundles/org.eclipse.wst.css.core/cssprofile/description.txt b/bundles/org.eclipse.wst.css.core/cssprofile/description.txt
new file mode 100644
index 0000000..3f31f19
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/cssprofile/description.txt
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+
+ * None of the files in this directory
+ * need to be translated
+ * except for cssprofile.properties
+ *******************************************************************************/
+
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/plugin.properties b/bundles/org.eclipse.wst.css.core/plugin.properties
new file mode 100644
index 0000000..cc1c1cb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/plugin.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2004, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+providerName=Eclipse Web Tools Platform
+pluginName=Structured Source CSS Model
+cssprofile_css3.name=CSS3: Cascading Style Sheets, level 3
+cssprofile_css2.name=CSS2: Cascading Style Sheets, level 2
+cssprofile_css1.name=CSS1: Cascading Style Sheets, level 1
+cssprofile_mobile1_0.name=CSS Mobile Profile 1.0
+cssprofile_wap.name=WCSS 1.0
+Structured_CSS_Document_Factory_Extension.name=Structured CSS Document Factory Extension
+CSS_Content_Type_Extension_Element.name=CSS
+_taskMarker.name=CSS Task
diff --git a/bundles/org.eclipse.wst.css.core/plugin.xml b/bundles/org.eclipse.wst.css.core/plugin.xml
new file mode 100644
index 0000000..66f0499
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/plugin.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension point="org.eclipse.wst.sse.core.cssprofile">
+ <profile
+ name="%cssprofile_css3.name"
+ uri="cssprofile/cssprofile-css3.xml"
+ id="org.eclipse.wst.css.core.cssprofile.css3">
+ </profile>
+ <profile
+ name="%cssprofile_css2.name"
+ default="true"
+ uri="cssprofile/cssprofile-css2.xml"
+ id="org.eclipse.wst.css.core.cssprofile.css2">
+ </profile>
+ <profile
+ name="%cssprofile_css1.name"
+ uri="cssprofile/cssprofile-css1.xml"
+ id="org.eclipse.wst.css.core.cssprofile.css1">
+ </profile>
+ <profile
+ name="%cssprofile_mobile1_0.name"
+ uri="cssprofile/cssprofile-mobile1_0.xml"
+ id="org.eclipse.wst.css.core.cssprofile.mobile1_0">
+ </profile>
+ <profile
+ name="%cssprofile_wap.name"
+ uri="cssprofile/cssprofile-wap.xml"
+ id="org.eclipse.wst.css.core.cssprofile.wap">
+ </profile>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.core.modelHandler">
+ <modelHandler
+ class="org.eclipse.wst.css.core.internal.modelhandler.ModelHandlerForCSS"
+ associatedContentTypeId="org.eclipse.wst.css.core.csssource"
+ id="org.eclipse.wst.css.core.internal.modelhandler">
+ </modelHandler>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.core.taskscanner">
+ <scanner
+ id="org.eclipse.wst.css.core.internal.tasks.CSSFileTaskScanner"
+ class="org.eclipse.wst.css.core.internal.tasks.CSSFileTaskScanner:org.eclipse.wst.css.core.taskMarker"
+ contentTypeIds="org.eclipse.wst.css.core.csssource" />
+ </extension>
+ <extension
+ id="taskMarker"
+ name="%_taskMarker.name"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.taskmarker"/>
+ <persistent value="true"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.filebuffers.documentCreation"
+ id="org.eclipse.wst.css.core.documentfactories"
+ name="%Structured_CSS_Document_Factory_Extension.name">
+ <factory
+ contentTypeId="org.eclipse.wst.css.core.csssource"
+ class="org.eclipse.wst.sse.core.internal.filebuffers.BasicStructuredDocumentFactory" />
+ </extension>
+
+ <extension point="org.eclipse.team.core.fileTypes">
+ <fileTypes
+ type="text"
+ extension="css">
+ </fileTypes>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.core.formatProcessors">
+ <processor
+ class="org.eclipse.wst.css.core.internal.format.FormatProcessorCSS"
+ contentTypeId="org.eclipse.wst.css.core.csssource">
+ </processor>
+ </extension>
+
+ <extension point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ file-extensions="css"
+ priority="high"
+ name="%CSS_Content_Type_Extension_Element.name"
+ id="csssource"
+ base-type="org.eclipse.core.runtime.text">
+ <describer
+ class="org.eclipse.wst.css.core.internal.contenttype.ContentDescriberForCSS" />
+ </content-type>
+ </extension>
+
+ <!-- initialize css core preferences -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceInitializer" />
+ </extension>
+</plugin>
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java
new file mode 100644
index 0000000..b967a90
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCoreMessages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Strings used by CSS Core
+ *
+ * @plannedfor 1.0
+ */
+public class CSSCoreMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.wst.css.core.internal.CSSCorePluginResources";//$NON-NLS-1$
+
+ public static String You_cannot_use_CSSStyleShe_UI_;
+ public static String CSSContentPropertiesManager_Updating;
+ public static String CSSContentPropertiesManager_Problems_Updating;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, CSSCoreMessages.class);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java
new file mode 100644
index 0000000..f992edf
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePlugin.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.wst.css.core.internal.contentproperties.CSSContentPropertiesManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class CSSCorePlugin extends Plugin {
+ // The shared instance.
+ private static CSSCorePlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public CSSCorePlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static CSSCorePlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ // listen for resource changes to update content properties keys
+ CSSContentPropertiesManager.startup();
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // stop listenning for resource changes to update content properties
+ // keys
+ CSSContentPropertiesManager.shutdown();
+
+ super.stop(context);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties
new file mode 100644
index 0000000..e18d1fd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/CSSCorePluginResources.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2004, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+You_cannot_use_CSSStyleShe_UI_=You cannot use CSSStyleSheet.getOwnerRule() because of many referencers of this rule\nPlease use getOnwerRules()
+#
+CSSContentPropertiesManager_Updating=Updating CSS Content Settings
+CSSContentPropertiesManager_Problems_Updating=Problem saving CSS Content Settings for {0}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/IProductConstants.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/IProductConstants.java
new file mode 100644
index 0000000..f3a6235
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/IProductConstants.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal;
+
+public interface IProductConstants {
+ /** Default profile to be used in the CSS metamodel */
+ String DEFAULT_PROFILE = "wst.css.default_profile"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java
new file mode 100644
index 0000000..ebffda0
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/Logger.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal;
+
+
+
+import com.ibm.icu.util.StringTokenizer;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.Bundle;
+
+/**
+ * Small convenience class to log messages to plugin's log file and also, if
+ * desired, the console. This class should only be used by classes in this
+ * plugin. Other plugins should make their own copy, with appropriate ID.
+ */
+public class Logger {
+ private static final String PLUGIN_ID = "org.eclipse.wst.css.core"; //$NON-NLS-1$
+
+ private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
+
+ public static final int OK = IStatus.OK; // 0
+ public static final int INFO = IStatus.INFO; // 1
+ public static final int WARNING = IStatus.WARNING; // 2
+ public static final int ERROR = IStatus.ERROR; // 4
+
+ public static final int OK_DEBUG = 200 + OK;
+ public static final int INFO_DEBUG = 200 + INFO;
+ public static final int WARNING_DEBUG = 200 + WARNING;
+ public static final int ERROR_DEBUG = 200 + ERROR;
+
+ /**
+ * Adds message to log.
+ *
+ * @param level
+ * severity level of the message (OK, INFO, WARNING, ERROR,
+ * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
+ * @param message
+ * text to add to the log
+ * @param exception
+ * exception thrown
+ */
+ protected static void _log(int level, String message, Throwable exception) {
+ if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
+ if (!isDebugging())
+ return;
+ }
+
+ int severity = IStatus.OK;
+ switch (level) {
+ case INFO_DEBUG :
+ case INFO :
+ severity = IStatus.INFO;
+ break;
+ case WARNING_DEBUG :
+ case WARNING :
+ severity = IStatus.WARNING;
+ break;
+ case ERROR_DEBUG :
+ case ERROR :
+ severity = IStatus.ERROR;
+ }
+ message = (message != null) ? message : "null"; //$NON-NLS-1$
+ Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ if (bundle != null)
+ Platform.getLog(bundle).log(statusObj);
+ }
+
+ /**
+ * Prints message to log if category matches /debug/tracefilter option.
+ *
+ * @param message
+ * text to print
+ * @param category
+ * category of the message, to be compared with
+ * /debug/tracefilter
+ */
+ protected static void _trace(String category, String message, Throwable exception) {
+ if (isTracing(category)) {
+ message = (message != null) ? message : "null"; //$NON-NLS-1$
+ Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception);
+ Bundle bundle = Platform.getBundle(PLUGIN_ID);
+ if (bundle != null)
+ Platform.getLog(bundle).log(statusObj);
+ }
+ }
+
+ /**
+ * @return true if the platform is debugging
+ */
+ public static boolean isDebugging() {
+ return Platform.inDebugMode();
+ }
+
+ /**
+ * Determines if currently tracing a category
+ *
+ * @param category
+ * @return true if tracing category, false otherwise
+ */
+ public static boolean isTracing(String category) {
+ if (!isDebugging())
+ return false;
+
+ String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION);
+ if (traceFilter != null) {
+ StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens()) {
+ String cat = tokenizer.nextToken().trim();
+ if (category.equals(cat)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static void log(int level, String message) {
+ _log(level, message, null);
+ }
+
+ public static void log(int level, String message, Throwable exception) {
+ _log(level, message, exception);
+ }
+
+ public static void logException(String message, Throwable exception) {
+ _log(ERROR, message, exception);
+ }
+
+ public static void logException(Throwable exception) {
+ _log(ERROR, exception.getMessage(), exception);
+ }
+
+ public static void traceException(String category, String message, Throwable exception) {
+ _trace(category, message, exception);
+ }
+
+ public static void traceException(String category, Throwable exception) {
+ _trace(category, exception.getMessage(), exception);
+ }
+
+ public static void trace(String category, String message) {
+ _trace(category, message, null);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java
new file mode 100644
index 0000000..eb6d86e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategy.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.cleanup;
+
+
+
+public interface CSSCleanupStrategy {
+
+ static final short ASIS = 0;
+ static final short LOWER = 1;
+ static final short UPPER = 2;
+
+ /**
+ *
+ * @return short
+ */
+ short getIdentCase();
+
+ /**
+ *
+ * @return short
+ */
+ short getPropNameCase();
+
+ /**
+ *
+ * @return short
+ */
+ short getPropValueCase();
+
+ /**
+ *
+ * @return short
+ */
+ short getSelectorTagCase();
+
+ /**
+ *
+ * @return boolean
+ */
+ boolean isFormatSource();
+
+ /**
+ *
+ * @return boolean
+ */
+ boolean isQuoteValues();
+
+ /**
+ *
+ * @param formatSource
+ * boolean
+ */
+ void setFormatSource(boolean formatSource);
+
+ /**
+ *
+ * @param identCase
+ * short
+ */
+ void setIdentCase(short identCase);
+
+ /**
+ *
+ * @param propNameCase
+ * short
+ */
+ void setPropNameCase(short propNameCase);
+
+ /**
+ *
+ * @param propValueCase
+ * short
+ */
+ void setPropValueCase(short propValueCase);
+
+ /**
+ *
+ * @param quoteValues
+ * boolean
+ */
+ void setQuoteValues(boolean quoteValues);
+
+ /**
+ *
+ * @param selectorTagCase
+ * short
+ */
+ void setSelectorTagCase(short selectorTagCase);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java
new file mode 100644
index 0000000..5b190f4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CSSCleanupStrategyImpl.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.cleanup;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+
+
+
+public class CSSCleanupStrategyImpl implements CSSCleanupStrategy {
+
+ static private CSSCleanupStrategy instance = null;
+ // initialize with defaults
+ protected short fIdentCase = ASIS;
+ protected short fPropNameCase = ASIS;
+ protected short fPropValueCase = ASIS;
+ protected short fSelectorTagCase = UPPER;
+ protected boolean fQuoteValues = true;
+ protected boolean fFormatSource = true;
+
+ /**
+ * CSSCleanupStrategyImpl constructor comment.
+ */
+ protected CSSCleanupStrategyImpl() {
+ super();
+ initialize();
+ }
+
+ /**
+ *
+ * @return short
+ */
+ public short getIdentCase() {
+ return fIdentCase;
+ }
+
+ /**
+ *
+ * @return org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy
+ */
+ public synchronized static CSSCleanupStrategy getInstance() {
+ if (instance == null)
+ instance = new CSSCleanupStrategyImpl();
+ return instance;
+ }
+
+ /**
+ *
+ * @return short
+ */
+ public short getPropNameCase() {
+ return fPropNameCase;
+ }
+
+ /**
+ *
+ * @return short
+ */
+ public short getPropValueCase() {
+ return fPropValueCase;
+ }
+
+ /**
+ *
+ * @return short
+ */
+ public short getSelectorTagCase() {
+ return fSelectorTagCase;
+ }
+
+ /**
+ *
+ */
+ private void initialize() {
+ Preferences prefs = CSSCorePlugin.getDefault().getPluginPreferences();
+ fIdentCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_IDENTIFIER));
+ fPropNameCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME));
+ fPropValueCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE));
+ fSelectorTagCase = getCleanupCaseValue(prefs.getInt(CSSCorePreferenceNames.CLEANUP_CASE_SELECTOR));
+ fQuoteValues = prefs.getBoolean(CSSCorePreferenceNames.QUOTE_ATTR_VALUES);
+ fFormatSource = prefs.getBoolean(CSSCorePreferenceNames.FORMAT_SOURCE);
+ }
+
+ /**
+ * Return the CSSCleanupStrategy equivalent case short value when given an
+ * int
+ *
+ * @param value
+ * @return equivalent case short or ASIS if cannot be determined
+ */
+ private short getCleanupCaseValue(int value) {
+ switch (value) {
+ case CSSCorePreferenceNames.LOWER :
+ return LOWER;
+ case CSSCorePreferenceNames.UPPER :
+ return UPPER;
+ }
+ return ASIS;
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ public boolean isFormatSource() {
+ return fFormatSource;
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ public boolean isQuoteValues() {
+ return fQuoteValues;
+ }
+
+ /**
+ *
+ * @param formatSource
+ * boolean
+ */
+ public void setFormatSource(boolean formatSource) {
+ fFormatSource = formatSource;
+ }
+
+ /**
+ *
+ * @param identCase
+ * short
+ */
+ public void setIdentCase(short identCase) {
+ fIdentCase = identCase;
+ }
+
+ /**
+ *
+ * @param propNameCase
+ * short
+ */
+ public void setPropNameCase(short propNameCase) {
+ fPropNameCase = propNameCase;
+ }
+
+ /**
+ *
+ * @param propValueCase
+ * short
+ */
+ public void setPropValueCase(short propValueCase) {
+ fPropValueCase = propValueCase;
+ }
+
+ /**
+ *
+ * @param quoteValues
+ * boolean
+ */
+ public void setQuoteValues(boolean quoteValues) {
+ fQuoteValues = quoteValues;
+ }
+
+ /**
+ *
+ * @param selectorTagCase
+ * short
+ */
+ public void setSelectorTagCase(short selectorTagCase) {
+ fSelectorTagCase = selectorTagCase;
+ }
+
+ // TODO: a saveOptions should be added to CSSCleanupStrategy interface
+ public void saveOptions() {
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_IDENTIFIER, fIdentCase);
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME, fPropNameCase);
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE, fPropValueCase);
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.CLEANUP_CASE_SELECTOR, fSelectorTagCase);
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.QUOTE_ATTR_VALUES, fQuoteValues);
+ CSSCorePlugin.getDefault().getPluginPreferences().setValue(CSSCorePreferenceNames.FORMAT_SOURCE, fFormatSource);
+ CSSCorePlugin.getDefault().savePluginPreferences();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java
new file mode 100644
index 0000000..1fadf34
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.cleanup;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.css.core.internal.formatter.CSSFormatUtil;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory;
+import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.cleanup.AbstractStructuredCleanupProcessor;
+import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupHandler;
+import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Node;
+
+
+public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
+
+ public void cleanupModel(IStructuredModel structuredModel, int start, int length) {
+ CSSFormatUtil formatUtil = CSSFormatUtil.getInstance();
+ if (structuredModel instanceof ICSSModel) {
+ ICSSDocument doc = ((ICSSModel) structuredModel).getDocument();
+ CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) doc);
+ StringBuffer buf = formatter.cleanup(doc);
+ if (buf != null) {
+ int startOffset = ((IndexedRegion) doc).getStartOffset();
+ int endOffset = ((IndexedRegion) doc).getEndOffset();
+ formatUtil.replaceSource(doc.getModel(), startOffset, endOffset - startOffset, buf.toString());
+ }
+ }
+ else if (structuredModel instanceof IDOMModel) {
+ List cssnodes = formatUtil.collectCSSNodes(structuredModel, start, length);
+ if (cssnodes != null && !cssnodes.isEmpty()) {
+ ICSSModel model = null;
+ for (int i = 0; i < cssnodes.size(); i++) {
+ ICSSNode node = (ICSSNode) cssnodes.get(i);
+ CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) node);
+ StringBuffer buf = formatter.cleanup(node);
+ if (buf != null) {
+ int startOffset = ((IndexedRegion) node).getStartOffset();
+ int endOffset = ((IndexedRegion) node).getEndOffset();
+ if (model == null) {
+ model = node.getOwnerDocument().getModel();
+ }
+ formatUtil.replaceSource(model, startOffset, endOffset - startOffset, buf.toString());
+ }
+ }
+ }
+ }
+ }
+
+ protected String getContentType() {
+ return ContentTypeIdForCSS.ContentTypeID_CSS;
+ }
+
+ public void cleanupModel(IStructuredModel structuredModel) {
+ int start = 0;
+ int length = structuredModel.getStructuredDocument().getLength();
+
+ cleanupModel(structuredModel, start, length);
+ }
+
+ public void cleanupDocument(IDocument document) throws IOException, CoreException {
+ // TODO should implement, or delete?
+
+ }
+
+ public void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException {
+ // TODO should implement, or delete?
+
+ }
+
+ protected IStructuredCleanupHandler getCleanupHandler(Node node) {
+ return null;
+ }
+
+ protected IStructuredFormatProcessor getFormatProcessor() {
+ return null;
+ }
+
+ protected void refreshCleanupPreferences() {
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java
new file mode 100644
index 0000000..8d02ac8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IMediaGroupID.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+/**
+ *
+ */
+public interface IMediaGroupID {
+
+ public final static String M_CONTINUOUS = "continuous"; //$NON-NLS-1$
+ public final static String M_PAGED = "paged"; //$NON-NLS-1$
+
+ public final static String M_VISUAL = "visual"; //$NON-NLS-1$
+ public final static String M_AURAL = "aural"; //$NON-NLS-1$
+ public final static String M_TACTILE = "tactile"; //$NON-NLS-1$
+
+ public final static String M_GRID = "grid"; //$NON-NLS-1$
+ public final static String M_BITMAP = "bitmap"; //$NON-NLS-1$
+
+ public final static String M_INTERACTIVE = "interactive"; //$NON-NLS-1$
+ public final static String M_STATIC = "static"; //$NON-NLS-1$
+
+ public final static String M_ALL = "all"; //$NON-NLS-1$
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java
new file mode 100644
index 0000000..113e855
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/IValID.java
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+/**
+ *
+ */
+public interface IValID {
+
+ public final static String V_1 = "1";//$NON-NLS-1$
+ public final static String V_100 = "100"; //$NON-NLS-1$
+ public final static String V_200 = "200"; //$NON-NLS-1$
+ public final static String V_300 = "300"; //$NON-NLS-1$
+ public final static String V_400 = "400"; //$NON-NLS-1$
+ public final static String V_500 = "500"; //$NON-NLS-1$
+ public final static String V_600 = "600"; //$NON-NLS-1$
+ public final static String V_700 = "700"; //$NON-NLS-1$
+ public final static String V_800 = "800"; //$NON-NLS-1$
+ public final static String V_900 = "900"; //$NON-NLS-1$
+ public final static String V_ABOVE = "above"; //$NON-NLS-1$
+ public final static String V_ABSOLUTE = "absolute"; //$NON-NLS-1$
+ public final static String V_ACTIVEBORDER = "ActiveBorder"; //$NON-NLS-1$
+ public final static String V_ACTIVECAPTION = "ActiveCaption"; //$NON-NLS-1$
+ public final static String V_ALL = "all"; //$NON-NLS-1$
+ public final static String V_ALWAYS = "always"; //$NON-NLS-1$
+ public final static String V_APPWORKSPACE = "AppWorkspace"; //$NON-NLS-1$
+ public final static String V_AQUA = "aqua"; //$NON-NLS-1$
+ public final static String V_ARMENIAN = "armenian"; //$NON-NLS-1$
+ public final static String V_AUTO = "auto"; //$NON-NLS-1$
+ public final static String V_AVOID = "avoid"; //$NON-NLS-1$
+ public final static String V_BACKGROUND = "Background"; //$NON-NLS-1$
+ public final static String V_BALANCE = "balance";//$NON-NLS-1$
+ public final static String V_BASELINE = "baseline"; //$NON-NLS-1$
+ public final static String V_BEHIND = "behind"; //$NON-NLS-1$
+ public final static String V_BELOW = "below"; //$NON-NLS-1$
+ public final static String V_BIDI_OVERRIDE = "bidi-override"; //$NON-NLS-1$
+ public final static String V_BLACK = "black"; //$NON-NLS-1$
+ public final static String V_BLINK = "blink"; //$NON-NLS-1$
+ public final static String V_BLOCK = "block"; //$NON-NLS-1$
+ public final static String V_BLUE = "blue"; //$NON-NLS-1$
+ public final static String V_BOLD = "bold"; //$NON-NLS-1$
+ public final static String V_BOLDER = "bolder"; //$NON-NLS-1$
+ public final static String V_BORDER_BOX = "border-box"; //$NON-NLS-1$
+ public final static String V_BOTH = "both"; //$NON-NLS-1$
+ public final static String V_BOTTOM = "bottom"; //$NON-NLS-1$
+ public final static String V_BUTTONFACE = "ButtonFace"; //$NON-NLS-1$
+ public final static String V_BUTTONHIGHLIGHT = "ButtonHighlight"; //$NON-NLS-1$
+ public final static String V_BUTTONSHADOW = "ButtonShadow"; //$NON-NLS-1$
+ public final static String V_BUTTONTEXT = "ButtonText"; //$NON-NLS-1$
+ public final static String V_CAPITALIZE = "capitalize"; //$NON-NLS-1$
+ public final static String V_CAPTION = "caption"; //$NON-NLS-1$
+ public final static String V_CAPTIONTEXT = "CaptionText"; //$NON-NLS-1$
+ public final static String V_CENTER = "center"; //$NON-NLS-1$
+ public final static String V_CENTER_LEFT = "center-left"; //$NON-NLS-1$
+ public final static String V_CENTER_RIGHT = "center-right"; //$NON-NLS-1$
+ public final static String V_CHILD = "child"; //$NON-NLS-1$
+ public final static String V_CIRCLE = "circle"; //$NON-NLS-1$
+ public final static String V_CJK_IDEOGRAPHIC = "cjk-ideographic"; //$NON-NLS-1$
+ public final static String V_CLIP = "clip"; //$NON-NLS-1$
+ public final static String V_CLOSE_QUOTE = "close-quote"; //$NON-NLS-1$
+ public final static String V_CODE = "code"; //$NON-NLS-1$
+ public final static String V_CONDENSED = "condensed"; //$NON-NLS-1$
+ public final static String V_COLLAPSE = "collapse"; //$NON-NLS-1$
+ public final static String V_COMPACT = "compact"; //$NON-NLS-1$
+ public final static String V_CONTAIN = "contain"; //$NON-NLS-1$
+ public final static String V_CONTENT_BOX = "content-box"; //$NON-NLS-1$
+ public final static String V_CONTINUOUS = "continuous"; //$NON-NLS-1$
+ public final static String V_COVER = "cover"; //$NON-NLS-1$
+ public final static String V_CROP = "crop"; //$NON-NLS-1$
+ public final static String V_CROSS = "cross"; //$NON-NLS-1$
+ public final static String V_CROSSHAIR = "crosshair"; //$NON-NLS-1$
+ public final static String V_CURSIVE = "cursive"; //$NON-NLS-1$
+ public final static String V_DASHED = "dashed"; //$NON-NLS-1$
+ public final static String V_DECIMAL = "decimal"; //$NON-NLS-1$
+ public final static String V_DECIMAL_LEADING_ZERO = "decimal-leading-zero"; //$NON-NLS-1$
+ public final static String V_DEFAULT = "default"; //$NON-NLS-1$
+ public final static String V_DIGITS = "digits"; //$NON-NLS-1$
+ public final static String V_DISC = "disc"; //$NON-NLS-1$
+ public final static String V_DOTTED = "dotted"; //$NON-NLS-1$
+ public final static String V_DOUBLE = "double"; //$NON-NLS-1$
+ public final static String V_E_RESIZE = "e-resize"; //$NON-NLS-1$
+ public final static String V_ELLIPSIS = "ellipsis"; //$NON-NLS-1$
+ public final static String V_EMBED = "embed"; //$NON-NLS-1$
+ public final static String V_EXPANDED = "expanded"; //$NON-NLS-1$
+ public final static String V_EXTRA_CONDENSED = "extra-condensed"; //$NON-NLS-1$
+ public final static String V_EXTRA_EXPANDED = "extra-expanded"; //$NON-NLS-1$
+ public final static String V_FANTASY = "fantasy"; //$NON-NLS-1$
+ public final static String V_FAR_LEFT = "far-left"; //$NON-NLS-1$
+ public final static String V_FAR_RIGHT = "far-right"; //$NON-NLS-1$
+ public final static String V_FAST = "fast"; //$NON-NLS-1$
+ public final static String V_FASTER = "faster"; //$NON-NLS-1$
+ public final static String V_FEMALE = "female"; //$NON-NLS-1$
+ public final static String V_FIXED = "fixed"; //$NON-NLS-1$
+ public final static String V_FUCHSIA = "fuchsia"; //$NON-NLS-1$
+ public final static String V_GEORGIAN = "georgian"; //$NON-NLS-1$
+ public final static String V_GRAY = "gray"; //$NON-NLS-1$
+ public final static String V_GRAYTEXT = "GrayText"; //$NON-NLS-1$
+ public final static String V_GREEN = "green"; //$NON-NLS-1$
+ public final static String V_GROOVE = "groove"; //$NON-NLS-1$
+ public final static String V_HEBREW = "hebrew"; //$NON-NLS-1$
+ public final static String V_HELP = "help"; //$NON-NLS-1$
+ public final static String V_HIDDEN = "hidden"; //$NON-NLS-1$
+ public final static String V_HIDE = "hide"; //$NON-NLS-1$
+ public final static String V_HIGH = "high"; //$NON-NLS-1$
+ public final static String V_HIGHLIGHT = "Highlight"; //$NON-NLS-1$
+ public final static String V_HIGHLIGHTTEXT = "HighlightText"; //$NON-NLS-1$
+ public final static String V_HIGHER = "higher"; //$NON-NLS-1$
+ public final static String V_HIRAGANA = "hiragana"; //$NON-NLS-1$
+ public final static String V_HIRAGANA_IROHA = "hiragana-iroha"; //$NON-NLS-1$
+ public final static String V_HORIZONTAL = "horizontal"; //$NON-NLS-1$
+ public final static String V_ICON = "icon"; //$NON-NLS-1$
+ public final static String V_INACTIVEBORDER = "InactiveBorder"; //$NON-NLS-1$
+ public final static String V_INACTIVECAPTION = "InactiveCaption"; //$NON-NLS-1$
+ public final static String V_INACTIVECAPTIONTEXT = "InactiveCaptionText"; //$NON-NLS-1$
+ public final static String V_INFOBACKGROUND = "InfoBackground"; //$NON-NLS-1$
+ public final static String V_INFOTEXT = "InfoText"; //$NON-NLS-1$
+ public final static String V_INLINE = "inline"; //$NON-NLS-1$
+ public final static String V_INLINE_BLOCK = "inline-block"; //$NON-NLS-1$
+ public final static String V_INLINE_TABLE = "inline-table"; //$NON-NLS-1$
+ public final static String V_INSET = "inset"; //$NON-NLS-1$
+ public final static String V_INSIDE = "inside"; //$NON-NLS-1$
+ public final static String V_INVERT = "invert"; //$NON-NLS-1$
+ public final static String V_ITALIC = "italic"; //$NON-NLS-1$
+ public final static String V_JUSTIFY = "justify"; //$NON-NLS-1$
+ public final static String V_KATAKANA = "katakana"; //$NON-NLS-1$
+ public final static String V_KATAKANA_IROHA = "katakana-iroha"; //$NON-NLS-1$
+ public final static String V_LANDSCAPE = "landscape"; //$NON-NLS-1$
+ public final static String V_LARGE = "large"; //$NON-NLS-1$
+ public final static String V_LARGER = "larger"; //$NON-NLS-1$
+ public final static String V_LEFT = "left"; //$NON-NLS-1$
+ public final static String V_LEFT_SIDE = "left-side"; //$NON-NLS-1$
+ public final static String V_LEFTWARDS = "leftwards"; //$NON-NLS-1$
+ public final static String V_LEVEL = "level"; //$NON-NLS-1$
+ public final static String V_LIGHTER = "lighter"; //$NON-NLS-1$
+ public final static String V_LIME = "lime"; //$NON-NLS-1$
+ public final static String V_LINE_THROUGH = "line-through"; //$NON-NLS-1$
+ public final static String V_LIST_ITEM = "list-item"; //$NON-NLS-1$
+ public final static String V_LOCAL = "local"; //$NON-NLS-1$
+ public final static String V_LOUD = "loud"; //$NON-NLS-1$
+ public final static String V_LOW = "low"; //$NON-NLS-1$
+ public final static String V_LOWER = "lower"; //$NON-NLS-1$
+ public final static String V_LOWER_ALPHA = "lower-alpha"; //$NON-NLS-1$
+ public final static String V_LOWER_GREEK = "lower-greek"; //$NON-NLS-1$
+ public final static String V_LOWER_LATIN = "lower-latin"; //$NON-NLS-1$
+ public final static String V_LOWER_ROMAN = "lower-roman"; //$NON-NLS-1$
+ public final static String V_LOWERCASE = "lowercase"; //$NON-NLS-1$
+ public final static String V_LTR = "ltr"; //$NON-NLS-1$
+ public final static String V_MALE = "male"; //$NON-NLS-1$
+ public final static String V_MARKER = "marker"; //$NON-NLS-1$
+ public final static String V_MAROON = "maroon"; //$NON-NLS-1$
+ public final static String V_MEDIUM = "medium"; //$NON-NLS-1$
+ public final static String V_MENU = "menu"; //$NON-NLS-1$
+ public final static String V_MENUTEXT = "MenuText"; //$NON-NLS-1$
+ public final static String V_MESSAGE_BOX = "message-box"; //$NON-NLS-1$
+ public final static String V_MIDDLE = "middle"; //$NON-NLS-1$
+ public final static String V_MIX = "mix"; //$NON-NLS-1$
+ public final static String V_MONOSPACE = "monospace"; //$NON-NLS-1$
+ public final static String V_MOVE = "move"; //$NON-NLS-1$
+ public final static String V_N_RESIZE = "n-resize"; //$NON-NLS-1$
+ public final static String V_NARROWER = "narrower"; //$NON-NLS-1$
+ public final static String V_NAVY = "navy"; //$NON-NLS-1$
+ public final static String V_NE_RESIZE = "ne-resize"; //$NON-NLS-1$
+ public final static String V_NO_CLOSE_QUOTE = "no-close-quote"; //$NON-NLS-1$
+ public final static String V_NO_OPEN_QUOTE = "no-open-quote"; //$NON-NLS-1$
+ public final static String V_NO_REPEAT = "no-repeat"; //$NON-NLS-1$
+ public final static String V_NONE = "none"; //$NON-NLS-1$
+ public final static String V_NORMAL = "normal"; //$NON-NLS-1$
+ public final static String V_NOWRAP = "nowrap"; //$NON-NLS-1$
+ public final static String V_NW_RESIZE = "nw-resize"; //$NON-NLS-1$
+ public final static String V_OBLIQUE = "oblique"; //$NON-NLS-1$
+ public final static String V_OLIVE = "olive"; //$NON-NLS-1$
+ public final static String V_ONCE = "once"; //$NON-NLS-1$
+ public final static String V_OPEN_QUOTE = "open-quote"; //$NON-NLS-1$
+ public final static String V_ORANGE = "orange"; //$NON-NLS-1$
+ public final static String V_OUTSET = "outset"; //$NON-NLS-1$
+ public final static String V_OUTSIDE = "outside"; //$NON-NLS-1$
+ public final static String V_OVERLINE = "overline"; //$NON-NLS-1$
+ public final static String V_PADDING_BOX = "padding-box"; //$NON-NLS-1$
+ public final static String V_POINTER = "pointer"; //$NON-NLS-1$
+ public final static String V_PORTRAIT = "portrait"; //$NON-NLS-1$
+ public final static String V_PRE = "pre"; //$NON-NLS-1$
+ public final static String V_PRE_LINE = "pre-line"; //$NON-NLS-1$
+ public final static String V_PRE_WRAP = "pre-wrap"; //$NON-NLS-1$
+ public final static String V_PROGRESS = "progress"; //$NON-NLS-1$
+ public final static String V_PURPLE = "purple"; //$NON-NLS-1$
+ public final static String V_RED = "red"; //$NON-NLS-1$
+ public final static String V_RELATIVE = "relative"; //$NON-NLS-1$
+ public final static String V_REPEAT = "repeat"; //$NON-NLS-1$
+ public final static String V_REPEAT_X = "repeat-x"; //$NON-NLS-1$
+ public final static String V_REPEAT_Y = "repeat-y"; //$NON-NLS-1$
+ public final static String V_RIDGE = "ridge"; //$NON-NLS-1$
+ public final static String V_RIGHT = "right"; //$NON-NLS-1$
+ public final static String V_RIGHT_SIDE = "right-side"; //$NON-NLS-1$
+ public final static String V_RIGHTWARDS = "rightwards"; //$NON-NLS-1$
+ public final static String V_ROUND = "round"; //$NON-NLS-1$
+ public final static String V_RTL = "rtl"; //$NON-NLS-1$
+ public final static String V_RUN_IN = "run-in"; //$NON-NLS-1$
+ public final static String V_S_RESIZE = "s-resize"; //$NON-NLS-1$
+ public final static String V_SANS_SERIF = "sans-serif"; //$NON-NLS-1$
+ public final static String V_SCROLL = "scroll"; //$NON-NLS-1$
+ public final static String V_SCROLLBAR = "Scrollbar"; //$NON-NLS-1$
+ public final static String V_SE_RESIZE = "se-resize"; //$NON-NLS-1$
+ public final static String V_SEMI_CONDENSED = "semi-condensed"; //$NON-NLS-1$
+ public final static String V_SEMI_EXPANDED = "semi-expanded"; //$NON-NLS-1$
+ public final static String V_SEPARATE = "separate"; //$NON-NLS-1$
+ public final static String V_SERIF = "serif"; //$NON-NLS-1$
+ public final static String V_SHOW = "show"; //$NON-NLS-1$
+ public final static String V_SILENT = "silent"; //$NON-NLS-1$
+ public final static String V_SILVER = "silver"; //$NON-NLS-1$
+ public final static String V_SLOW = "slow"; //$NON-NLS-1$
+ public final static String V_SLOWER = "slower"; //$NON-NLS-1$
+ public final static String V_SMALL = "small"; //$NON-NLS-1$
+ public final static String V_SMALL_CAPS = "small-caps"; //$NON-NLS-1$
+ public final static String V_SMALL_CAPTION = "small-caption"; //$NON-NLS-1$
+ public final static String V_SMALLER = "smaller"; //$NON-NLS-1$
+ public final static String V_SOFT = "soft"; //$NON-NLS-1$
+ public final static String V_SOLID = "solid"; //$NON-NLS-1$
+ public final static String V_SPACE = "space"; //$NON-NLS-1$
+ public final static String V_SPELL_OUT = "spell-out"; //$NON-NLS-1$
+ public final static String V_SQUARE = "square"; //$NON-NLS-1$
+ public final static String V_STATIC = "static"; //$NON-NLS-1$
+ public final static String V_STATUS_BAR = "status-bar"; //$NON-NLS-1$
+ public final static String V_SUB = "sub"; //$NON-NLS-1$
+ public final static String V_SUPER = "super"; //$NON-NLS-1$
+ public final static String V_SW_RESIZE = "sw-resize"; //$NON-NLS-1$
+ public final static String V_TABLE = "table"; //$NON-NLS-1$
+ public final static String V_TABLE_CAPTION = "table-caption"; //$NON-NLS-1$
+ public final static String V_TABLE_CELL = "table-cell"; //$NON-NLS-1$
+ public final static String V_TABLE_COLUMN = "table-column"; //$NON-NLS-1$
+ public final static String V_TABLE_COLUMN_GROUP = "table-column-group"; //$NON-NLS-1$
+ public final static String V_TABLE_FOOTER_GROUP = "table-footer-group"; //$NON-NLS-1$
+ public final static String V_TABLE_HEADER_GROUP = "table-header-group"; //$NON-NLS-1$
+ public final static String V_TABLE_ROW = "table-row"; //$NON-NLS-1$
+ public final static String V_TABLE_ROW_GROUP = "table-row-group"; //$NON-NLS-1$
+ public final static String V_TEAL = "teal"; //$NON-NLS-1$
+ public final static String V_TEXT = "text"; //$NON-NLS-1$
+ public final static String V_TEXT_TOP = "text-top"; //$NON-NLS-1$
+ public final static String V_TEXT_BOTTOM = "text-bottom"; //$NON-NLS-1$
+ public final static String V_THICK = "thick"; //$NON-NLS-1$
+ public final static String V_THIN = "thin"; //$NON-NLS-1$
+ public final static String V_THREEDDARKSHADOW = "ThreeDDarkShadow"; //$NON-NLS-1$
+ public final static String V_THREEDFACE = "ThreeDFace"; //$NON-NLS-1$
+ public final static String V_THREEDHIGHLIGHT = "ThreeDHighlight"; //$NON-NLS-1$
+ public final static String V_THREEDLIGHTSHADOW = "ThreeDLightShadow"; //$NON-NLS-1$
+ public final static String V_THREEDSHADOW = "ThreeDShadow"; //$NON-NLS-1$
+ public final static String V_TOP = "top"; //$NON-NLS-1$
+ public final static String V_TRANSPARENT = "transparent"; //$NON-NLS-1$
+ public final static String V_ULTRA_CONDENSED = "ultra-condensed"; //$NON-NLS-1$
+ public final static String V_ULTRA_EXPANDED = "ultra-expanded"; //$NON-NLS-1$
+ public final static String V_UNDERLINE = "underline"; //$NON-NLS-1$
+ public final static String V_UPPER_ALPHA = "upper-alpha"; //$NON-NLS-1$
+ public final static String V_UPPER_LATIN = "upper-latin"; //$NON-NLS-1$
+ public final static String V_UPPER_ROMAN = "upper-roman"; //$NON-NLS-1$
+ public final static String V_UPPERCASE = "uppercase"; //$NON-NLS-1$
+ public final static String V_VERTICAL = "vertical";//$NON-NLS-1$
+ public final static String V_VISIBLE = "visible"; //$NON-NLS-1$
+ public final static String V_W_RESIZE = "w-resize"; //$NON-NLS-1$
+ public final static String V_WAIT = "wait"; //$NON-NLS-1$
+ public final static String V_WHITE = "white"; //$NON-NLS-1$
+ public final static String V_WIDER = "wider"; //$NON-NLS-1$
+ public final static String V_WINDOW = "Window"; //$NON-NLS-1$
+ public final static String V_WINDOWFRAME = "WindowFrame"; //$NON-NLS-1$
+ public final static String V_WINDOWTEXT = "WindowText"; //$NON-NLS-1$
+ public final static String V_X_FAST = "x-fast"; //$NON-NLS-1$
+ public final static String V_X_HIGH = "x-high"; //$NON-NLS-1$
+ public final static String V_X_LARGE = "x-large"; //$NON-NLS-1$
+ public final static String V_X_LOUD = "x-loud"; //$NON-NLS-1$
+ public final static String V_X_LOW = "x-low"; //$NON-NLS-1$
+ public final static String V_X_SLOW = "x-slow"; //$NON-NLS-1$
+ public final static String V_X_SMALL = "x-small"; //$NON-NLS-1$
+ public final static String V_X_SOFT = "x-soft"; //$NON-NLS-1$
+ public final static String V_XX_SMALL = "xx-small"; //$NON-NLS-1$
+ public final static String V_XX_LARGE = "xx-large"; //$NON-NLS-1$
+ public final static String V_YELLOW = "yellow"; //$NON-NLS-1$
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java
new file mode 100644
index 0000000..d013f7c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMContainer.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class PropCMContainer extends PropCMNode {
+
+ private java.util.Vector nodes = new Vector();
+ private static java.util.Hashtable instances = null;
+ public final static String VAL_ABSOLUTE_SIZE = "absolute-size";//$NON-NLS-1$
+ public final static String VAL_BORDER_STYLE = "border-style";//$NON-NLS-1$
+ public final static String VAL_BORDER_WIDTH = "border-width";//$NON-NLS-1$
+ public final static String VAL_COLOR = "color";//$NON-NLS-1$
+ public final static String VAL_SYSTEM_COLOR = "system-color";//$NON-NLS-1$
+ public final static String VAL_GENERIC_FAMILY = "generic-family";//$NON-NLS-1$
+ public final static String VAL_GENERIC_VOICE = "generic-voice";//$NON-NLS-1$
+ public final static String VAL_MARGIN_WIDTH = "margin-width";//$NON-NLS-1$
+ public final static String VAL_PADDING_WIDTH = "padding-width";//$NON-NLS-1$
+ public final static String VAL_RELATIVE_SIZE = "relative-size";//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMContainer(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ Object appendChild(Object node) {
+ if (!nodes.contains(node))
+ nodes.add(node);
+ return node;
+ }
+
+ /**
+ *
+ */
+ public boolean canHave(String identifier) {
+ int nChild = getNumChild();
+ for (int i = 0; i < nChild; i++) {
+ Object child = getChildAt(i);
+ if (child instanceof String && identifier.equalsIgnoreCase((String) child))
+ return true;
+ if (child instanceof PropCMContainer && ((PropCMContainer) child).canHave(identifier))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public Object getChildAt(int index) {
+ if (nodes == null || index < 0 || nodes.size() <= index)
+ return null;
+ return nodes.elementAt(index);
+ }
+
+ /**
+ *
+ */
+ static PropCMContainer getContInstanceOf(String name) {
+ if (name == null)
+ return null;
+
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(20);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMContainer) node;
+
+ if (PropCMNode.isLoading()) {
+ // register
+ node = new PropCMContainer(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMContainer) node;
+ }
+
+ /**
+ *
+ */
+ void getIdentifiers(Set idents) {
+ if (idents == null)
+ return;
+ int nChildren = nodes.size();
+ for (int i = 0; i < nChildren; i++) {
+ Object node = nodes.elementAt(i);
+ if (node instanceof PropCMNode)
+ ((PropCMNode) node).getIdentifiers(idents);
+ else if (node instanceof String)
+ idents.add(node);
+ }
+ }
+
+ /**
+ *
+ */
+ public int getNumChild() {
+ if (nodes == null)
+ return 0;
+ return nodes.size();
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_CONTAINER;
+ }
+
+ /**
+ *
+ */
+ void getValues(Collection values) {
+ if (values == null)
+ return;
+ int nChildren = nodes.size();
+ for (int i = 0; i < nChildren; i++) {
+ Object node = nodes.elementAt(i);
+ if (node instanceof PropCMNode)
+ ((PropCMNode) node).getValues(values);
+ else if (node instanceof String) {
+ if (!values.contains(node))
+ values.add(node);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ Object removeChild(Object node) {
+ nodes.remove(node);
+ return node;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java
new file mode 100644
index 0000000..a28e21d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFontProperty.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class PropCMFontProperty extends PropCMProperty {
+
+ // static fields
+ private static java.util.Hashtable instances = null;
+ private static java.util.Hashtable cachedIdMap = null;
+ // selecting properties
+ public final static String PF_FONT_FAMILY = "font-family";//$NON-NLS-1$
+ public final static String PF_FONT_STYLE = "font-style";//$NON-NLS-1$
+ public final static String PF_FONT_VARIANT = "font-variant";//$NON-NLS-1$
+ public final static String PF_FONT_WEIGHT = "font-weight";//$NON-NLS-1$
+ public final static String PF_FONT_STRETCH = "font-stretch";//$NON-NLS-1$
+ public final static String PF_FONT_SIZE = "font-size";//$NON-NLS-1$
+ // qualification properties
+ public final static String PF_UNICODE_RANGE = "unicode-range";//$NON-NLS-1$
+ // numeric properties
+ public final static String PF_UNITS_PER_EM = "units-per-em";//$NON-NLS-1$
+ // referencing properties
+ public final static String PF_SRC = "src";//$NON-NLS-1$
+ // matching properties
+ public final static String PF_PANOSE_1 = "panose-1";//$NON-NLS-1$
+ public final static String PF_STEMV = "stemv";//$NON-NLS-1$
+ public final static String PF_STEMH = "stemh";//$NON-NLS-1$
+ public final static String PF_SLOPE = "slope";//$NON-NLS-1$
+ public final static String PF_CAP_HEIGHT = "cap-height";//$NON-NLS-1$
+ public final static String PF_X_HEIGHT = "x-height";//$NON-NLS-1$
+ public final static String PF_ASCENT = "ascent";//$NON-NLS-1$
+ public final static String PF_DESCENT = "descent";//$NON-NLS-1$
+ // synthesis properties
+ public final static String PF_WIDTHS = "widths";//$NON-NLS-1$
+ public final static String PF_BBOX = "bbox";//$NON-NLS-1$
+ public final static String PF_DEFINITION_SRC = "definition-src";//$NON-NLS-1$
+ // alignment properties
+ public final static String PF_BASELINE = "baseline";//$NON-NLS-1$
+ public final static String PF_CENTERLINE = "centerline";//$NON-NLS-1$
+ public final static String PF_MATHLINE = "mathline";//$NON-NLS-1$
+ public final static String PF_TOPLINE = "topline";//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMFontProperty(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ public static PropCMProperty getInstanceOf(String name) {
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(10);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMProperty) node;
+
+ // register
+ if (PropCMNode.isLoading()) {
+ node = new PropCMFontProperty(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMProperty) node;
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getNameEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.keys();
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getPropertyEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.elements();
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_FONTPROPERTY;
+ }
+
+ /**
+ *
+ */
+ public static Vector names() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return new Vector(instances.keySet());
+ }
+
+ /**
+ *
+ */
+ public static List names(Object mediaGroup) {
+ if (mediaGroup == null)
+ return names();
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ Vector properties = new Vector();
+
+ Iterator it = instances.values().iterator();
+ while (it.hasNext()) {
+ PropCMProperty prop = (PropCMProperty) it.next();
+ if (prop.getMediaGroups().contains(mediaGroup))
+ properties.add(prop.getName());
+ }
+
+ return properties;
+ }
+
+ /**
+ * If itentifier is null, get all properties
+ */
+ public static Vector propertiesFor(String identifier, boolean shorthands) {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // if identifier is null, get all properties
+ if (identifier == null)
+ return new Vector(instances.values());
+
+ if (cachedIdMap == null) {
+ // start cacheing
+ cachedIdMap = new Hashtable();
+ }
+ else {
+ // search cached
+ Object ret = cachedIdMap.get(identifier + String.valueOf(shorthands));
+ if (ret != null)
+ return new Vector((Collection) ret);
+ }
+
+ // create
+ Enumeration properties = getPropertyEnum();
+ HashSet set = new HashSet();
+ while (properties.hasMoreElements()) {
+ PropCMProperty prop = (PropCMProperty) properties.nextElement();
+ if (!shorthands && prop.isShorthand())
+ continue;
+ if (prop.canHave(identifier))
+ set.add(prop);
+ }
+
+ // cache
+ cachedIdMap.put(identifier + String.valueOf(shorthands), set);
+
+ return new Vector(set);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java
new file mode 100644
index 0000000..03efc91
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMFunction.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Set;
+
+/**
+ *
+ */
+public class PropCMFunction extends PropCMNode {
+
+ private static java.util.Hashtable instances = null;
+ public final static String VAL_ATTR = "attr";//$NON-NLS-1$
+ public final static String VAL_COUNTER = "counter";//$NON-NLS-1$
+ public final static String VAL_RGB = "rgb";//$NON-NLS-1$
+ public final static String VAL_SHAPE = "rect";//$NON-NLS-1$
+ public final static String VAL_URI = "url";//$NON-NLS-1$
+ public final static String VAL_FORMAT = "format";//$NON-NLS-1$
+ public final static String VAL_LOCAL = "local";//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMFunction(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ void getIdentifiers(Set indents) {
+ }
+
+ /**
+ *
+ */
+ static public PropCMFunction getInstanceOf(String name) {
+ if (name == null)
+ return null;
+
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(10);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMFunction) node;
+
+ // register
+ if (PropCMNode.isLoading()) {
+ node = new PropCMFunction(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMFunction) node;
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_FUNC;
+ }
+
+ /**
+ *
+ */
+ void getValues(Collection values) {
+ if (values != null && !values.contains(this))
+ values.add(this);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java
new file mode 100644
index 0000000..476ead2
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNode.java
@@ -0,0 +1,1521 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ *
+ */
+public abstract class PropCMNode {
+
+ public final static short VAL_IDENTIFIER = 0;
+ public final static short VAL_PROPERTY = 1;
+ public final static short VAL_NUMBER = 2;
+ public final static short VAL_STRING = 3;
+ public final static short VAL_FUNC = 4;
+ public final static short VAL_CONTAINER = 5;
+ public final static short VAL_SUBPROPERTY = 6;
+ public final static short VAL_FONTPROPERTY = 7;
+ public final static short VAL_UNICODE_RANGE = 8;
+ protected java.lang.String name = null;
+ private static short LOADING = 0; // 0 : not initialized, 1 : under
+ // initializing, 2 : initialize-done
+ // and fix DB
+
+ /**
+ *
+ */
+ public PropCMNode(String name) {
+ super();
+ this.name = name;
+ }
+
+ /**
+ *
+ */
+ public Set getIdentifiers() {
+ HashSet ids = new HashSet();
+ getIdentifiers(ids);
+ return ids;
+ }
+
+ /**
+ *
+ */
+ abstract void getIdentifiers(Set indents);
+
+ /**
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ */
+ public abstract short getType();
+
+ /**
+ *
+ */
+ public Collection getValues() {
+ Vector vals = new Vector();
+ getValues(vals);
+ return vals;
+ }
+
+ /**
+ *
+ */
+ abstract void getValues(Collection values);
+
+ /**
+ *
+ */
+ protected static void initPropertyCM() {
+ if (!isNeedInitialize())
+ return;
+ LOADING = 1;
+
+ PropCMNumber.initNumberCMDim();
+
+ // azimuth
+ PropCMProperty prop = PropCMProperty.getInstanceOf(PropCMProperty.P_AZIMUTH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_ANGLE));
+ prop.appendChild(IValID.V_LEFT_SIDE);
+ prop.appendChild(IValID.V_FAR_LEFT);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_CENTER_LEFT);
+ prop.appendChild(IValID.V_CENTER);
+ prop.appendChild(IValID.V_CENTER_RIGHT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendChild(IValID.V_FAR_RIGHT);
+ prop.appendChild(IValID.V_RIGHT_SIDE);
+ prop.appendChild(IValID.V_BEHIND);
+ prop.appendChild(IValID.V_LEFTWARDS);
+ prop.appendChild(IValID.V_RIGHTWARDS);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+ prop.setMaxValueCount(2);
+
+ // background
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.setMaxValueCount(6);
+
+ // background-attachment
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT);
+ prop.appendChild(IValID.V_SCROLL);
+ prop.appendChild(IValID.V_FIXED);
+ prop.appendChild(IValID.V_LOCAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-clip
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_CLIP);
+ prop.appendChild(IValID.V_BORDER_BOX);
+ prop.appendChild(IValID.V_CONTENT_BOX);
+ prop.appendChild(IValID.V_PADDING_BOX);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(IValID.V_TRANSPARENT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-image
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-origin
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ORIGIN);
+ prop.appendChild(IValID.V_PADDING_BOX);
+ prop.appendChild(IValID.V_BORDER_BOX);
+ prop.appendChild(IValID.V_CONTENT_BOX);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-position ---- sub-properties horizontal
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_CENTER);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-position ---- sub-properties vertical
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_TOP);
+ prop.appendChild(IValID.V_CENTER);
+ prop.appendChild(IValID.V_BOTTOM);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-position
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION);
+ prop.appendChild(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X));
+ prop.appendChild(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y));
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-repeat
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT);
+ prop.appendChild(IValID.V_REPEAT);
+ prop.appendChild(IValID.V_REPEAT_X);
+ prop.appendChild(IValID.V_REPEAT_Y);
+ prop.appendChild(IValID.V_SPACE);
+ prop.appendChild(IValID.V_ROUND);
+ prop.appendChild(IValID.V_NO_REPEAT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // background-size
+ prop = PropCMSubProperty.getInstanceOf(PropCMProperty.P_BG_SIZE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_CONTAIN);
+ prop.appendChild(IValID.V_COVER);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE));
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR));
+ prop.setMaxValueCount(9);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-collapse
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLLAPSE);
+ prop.appendChild(IValID.V_COLLAPSE);
+ prop.appendChild(IValID.V_SEPARATE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR));
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(IValID.V_TRANSPARENT);
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-spacing
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_SPACING);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE));
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-right
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-left
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-right-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-right-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-right-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-left-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-left-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-left-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH);
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH));
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top-left-radius
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_LEFT_RADIUS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-top-right-radius
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_RIGHT_RADIUS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom-left-radius
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_LEFT_RADIUS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // border-bottom-right-radius
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_RIGHT_RADIUS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RADIUS);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_LEFT_RADIUS));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_RIGHT_RADIUS));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_LEFT_RADIUS));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_RIGHT_RADIUS));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.setMaxValueCount(4);
+
+ // bottom
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOTTOM);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // box-shadow
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOX_SHADOW);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // box-shadow
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_BOX_SIZING);
+ prop.appendChild(IValID.V_BORDER_BOX);
+ prop.appendChild(IValID.V_CONTENT_BOX);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // caption-side
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CAPTION_SIDE);
+ prop.appendChild(IValID.V_TOP);
+ prop.appendChild(IValID.V_BOTTOM);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clear
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CLEAR);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendChild(IValID.V_BOTH);
+ prop.appendChild(IValID.V_STATIC);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clip ---- sub-properties top
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clip ---- sub-properties right
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clip ---- sub-properties bottom
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clip ---- sub-properties left
+ prop = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ ((PropCMSubProperty) prop).setContainer(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // clip
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_SHAPE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // columns
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMNS);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_COUNT));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_WIDTH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-count
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_COUNT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-fill
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_FILL);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_BALANCE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-gap
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_GAP);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-rule
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_COLOR));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-rule-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-rule-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-rule-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_RULE_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // column-span
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COLUMN_SPAN);
+ prop.appendChild(IValID.V_1);
+ prop.appendChild(IValID.V_ALL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // content
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CONTENT);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY));
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_COUNTER));
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_ATTR));
+ prop.appendChild(IValID.V_OPEN_QUOTE);
+ prop.appendChild(IValID.V_CLOSE_QUOTE);
+ prop.appendChild(IValID.V_NO_OPEN_QUOTE);
+ prop.appendChild(IValID.V_NO_CLOSE_QUOTE);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.setMaxValueCount(-1); // infinite
+ prop.appendMediaGroup(IMediaGroupID.M_ALL);
+
+ // counter-increment
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_INCREMENT);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_COUNTER_ID));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_ALL);
+
+ // counter-reset
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_RESET);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_COUNTER_ID));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_ALL);
+
+ // cue
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER));
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // cue-after
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // cue-before
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // cursor
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_CURSOR);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_CROSSHAIR);
+ prop.appendChild(IValID.V_DEFAULT);
+ prop.appendChild(IValID.V_POINTER);
+ prop.appendChild(IValID.V_PROGRESS);
+ prop.appendChild(IValID.V_MOVE);
+ prop.appendChild(IValID.V_E_RESIZE);
+ prop.appendChild(IValID.V_NE_RESIZE);
+ prop.appendChild(IValID.V_NW_RESIZE);
+ prop.appendChild(IValID.V_N_RESIZE);
+ prop.appendChild(IValID.V_SE_RESIZE);
+ prop.appendChild(IValID.V_SW_RESIZE);
+ prop.appendChild(IValID.V_S_RESIZE);
+ prop.appendChild(IValID.V_W_RESIZE);
+ prop.appendChild(IValID.V_TEXT);
+ prop.appendChild(IValID.V_WAIT);
+ prop.appendChild(IValID.V_HELP);
+ prop.setMaxValueCount(-1); // infinite
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE);
+
+ // direction
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_DIRECTION);
+ prop.appendChild(IValID.V_LTR);
+ prop.appendChild(IValID.V_RTL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // display
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_DISPLAY);
+ prop.appendChild(IValID.V_INLINE);
+ prop.appendChild(IValID.V_INLINE_BLOCK);
+ prop.appendChild(IValID.V_BLOCK);
+ prop.appendChild(IValID.V_LIST_ITEM);
+ prop.appendChild(IValID.V_RUN_IN);
+ prop.appendChild(IValID.V_COMPACT);
+ prop.appendChild(IValID.V_MARKER);
+ prop.appendChild(IValID.V_TABLE);
+ prop.appendChild(IValID.V_INLINE_TABLE);
+ prop.appendChild(IValID.V_TABLE_ROW_GROUP);
+ prop.appendChild(IValID.V_TABLE_HEADER_GROUP);
+ prop.appendChild(IValID.V_TABLE_FOOTER_GROUP);
+ prop.appendChild(IValID.V_TABLE_ROW);
+ prop.appendChild(IValID.V_TABLE_COLUMN_GROUP);
+ prop.appendChild(IValID.V_TABLE_COLUMN);
+ prop.appendChild(IValID.V_TABLE_CELL);
+ prop.appendChild(IValID.V_TABLE_CAPTION);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_ALL);
+
+ // elevation
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_ELEVATION);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_ANGLE));
+ prop.appendChild(IValID.V_BELOW);
+ prop.appendChild(IValID.V_LEVEL);
+ prop.appendChild(IValID.V_ABOVE);
+ prop.appendChild(IValID.V_HIGHER);
+ prop.appendChild(IValID.V_LOWER);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // empty-cells
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_EMPTY_CELLS);
+ prop.appendChild(IValID.V_SHOW);
+ prop.appendChild(IValID.V_HIDE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // float
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FLOAT);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY));
+ prop.appendChild(IValID.V_CAPTION);
+ prop.appendChild(IValID.V_ICON);
+ prop.appendChild(IValID.V_MENU);
+ prop.appendChild(IValID.V_MESSAGE_BOX);
+ prop.appendChild(IValID.V_SMALL_CAPTION);
+ prop.appendChild(IValID.V_STATUS_BAR);
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-family
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_FONT));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY));
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-size
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-size-adjust
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE_ADJUST);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-stretch
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STRETCH);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_WIDER);
+ prop.appendChild(IValID.V_NARROWER);
+ prop.appendChild(IValID.V_ULTRA_CONDENSED);
+ prop.appendChild(IValID.V_EXTRA_CONDENSED);
+ prop.appendChild(IValID.V_CONDENSED);
+ prop.appendChild(IValID.V_SEMI_CONDENSED);
+ prop.appendChild(IValID.V_SEMI_EXPANDED);
+ prop.appendChild(IValID.V_EXPANDED);
+ prop.appendChild(IValID.V_EXTRA_EXPANDED);
+ prop.appendChild(IValID.V_ULTRA_EXPANDED);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE);
+ prop.appendChild(IValID.V_ITALIC);
+ prop.appendChild(IValID.V_OBLIQUE);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-variant
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT);
+ prop.appendChild(IValID.V_SMALL_CAPS);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // font-weight
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT);
+ prop.appendChild(IValID.V_BOLD);
+ prop.appendChild(IValID.V_100);
+ prop.appendChild(IValID.V_200);
+ prop.appendChild(IValID.V_300);
+ prop.appendChild(IValID.V_400);
+ prop.appendChild(IValID.V_500);
+ prop.appendChild(IValID.V_600);
+ prop.appendChild(IValID.V_700);
+ prop.appendChild(IValID.V_800);
+ prop.appendChild(IValID.V_900);
+ prop.appendChild(IValID.V_LIGHTER);
+ prop.appendChild(IValID.V_BOLDER);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // height
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_HEIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // leftt
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LEFT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // letter-spacing
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LETTER_SPACING);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // line-height
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // list-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // list-style-image
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // list-style-position
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION);
+ prop.appendChild(IValID.V_INSIDE);
+ prop.appendChild(IValID.V_OUTSIDE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // list-style-type
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE);
+ prop.appendChild(IValID.V_DISC);
+ prop.appendChild(IValID.V_CIRCLE);
+ prop.appendChild(IValID.V_SQUARE);
+ prop.appendChild(IValID.V_DECIMAL);
+ prop.appendChild(IValID.V_DECIMAL_LEADING_ZERO);
+ prop.appendChild(IValID.V_LOWER_ROMAN);
+ prop.appendChild(IValID.V_UPPER_ROMAN);
+ prop.appendChild(IValID.V_LOWER_GREEK);
+ prop.appendChild(IValID.V_LOWER_ALPHA);
+ prop.appendChild(IValID.V_LOWER_LATIN);
+ prop.appendChild(IValID.V_UPPER_ALPHA);
+ prop.appendChild(IValID.V_UPPER_LATIN);
+ prop.appendChild(IValID.V_HEBREW);
+ prop.appendChild(IValID.V_ARMENIAN);
+ prop.appendChild(IValID.V_GEORGIAN);
+ prop.appendChild(IValID.V_CJK_IDEOGRAPHIC);
+ prop.appendChild(IValID.V_HIRAGANA);
+ prop.appendChild(IValID.V_KATAKANA);
+ prop.appendChild(IValID.V_HIRAGANA_IROHA);
+ prop.appendChild(IValID.V_KATAKANA_IROHA);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // margin
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN);
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT));
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // margin-top
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // margin-right
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // margin-bottom
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // margin-left
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // marker-offset
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARKER_OFFSET);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // marks
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MARKS);
+ prop.appendChild(IValID.V_CROP);
+ prop.appendChild(IValID.V_CROSS);
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // max-height
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_HEIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // max-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_WIDTH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // min-height
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_HEIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // min-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_WIDTH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // opacity
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OPACITY);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // orphans
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_ORPHANS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // outline
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE);
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH));
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE);
+
+ // outline-color
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(IValID.V_INVERT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE);
+
+ // outline-style
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE);
+
+ // outline-width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_INTERACTIVE);
+
+ // overflow
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_OVERFLOW);
+ prop.appendChild(IValID.V_VISIBLE);
+ prop.appendChild(IValID.V_HIDDEN);
+ prop.appendChild(IValID.V_SCROLL);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // padding
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING);
+ // prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM));
+ prop.appendChild(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT));
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // padding-top
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // padding-right
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // padding-bottom
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // padding-left
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // page
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_PAGE_ID));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // page-break-after
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_AFTER);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_ALWAYS);
+ prop.appendChild(IValID.V_AVOID);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // page-break-before
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_BEFORE);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_ALWAYS);
+ prop.appendChild(IValID.V_AVOID);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // page-break-inside
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_INSIDE);
+ prop.appendChild(IValID.V_AVOID);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // pause
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // pause-after
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_AFTER);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // pause-before
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_BEFORE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_TIME));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // pitch
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_FREQUENCY));
+ prop.appendChild(IValID.V_X_LOW);
+ prop.appendChild(IValID.V_LOW);
+ prop.appendChild(IValID.V_MEDIUM);
+ prop.appendChild(IValID.V_HIGH);
+ prop.appendChild(IValID.V_X_HIGH);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // pitch-range
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH_RANGE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // play-during
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_PLAY_DURING);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(IValID.V_MIX);
+ prop.appendChild(IValID.V_REPEAT);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(3);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // position
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_POSITION);
+ prop.appendChild(IValID.V_ABSOLUTE);
+ prop.appendChild(IValID.V_RELATIVE);
+ prop.appendChild(IValID.V_FIXED);
+ prop.appendChild(IValID.V_STATIC);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // quotes
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_QUOTES);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY));
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // resize
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RESIZE);
+ prop.appendChild(IValID.V_BOTH);
+ prop.appendChild(IValID.V_HORIZONTAL);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendChild(IValID.V_VERTICAL);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // richness
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RICHNESS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // right
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_RIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // size
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SIZE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_PORTRAIT);
+ prop.appendChild(IValID.V_LANDSCAPE);
+ prop.setMaxValueCount(2);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // speak
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendChild(IValID.V_SPELL_OUT);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // speak-header
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_HEADER);
+ prop.appendChild(IValID.V_ONCE);
+ prop.appendChild(IValID.V_ALWAYS);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // speak-numeral
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_NUMERAL);
+ prop.appendChild(IValID.V_DIGITS);
+ prop.appendChild(IValID.V_CONTINUOUS);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // speak-punctuation
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_PUNCTUATION);
+ prop.appendChild(IValID.V_CODE);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // speech-rate
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_SPEECH_RATE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendChild(IValID.V_X_SLOW);
+ prop.appendChild(IValID.V_SLOW);
+ prop.appendChild(IValID.V_MEDIUM);
+ prop.appendChild(IValID.V_FAST);
+ prop.appendChild(IValID.V_X_FAST);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // stress
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_STRESS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // table-layout
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TABLE_LAYOUT);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(IValID.V_FIXED);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-align
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_ALIGN);
+ prop.appendChild(IValID.V_LEFT);
+ prop.appendChild(IValID.V_CENTER);
+ prop.appendChild(IValID.V_RIGHT);
+ prop.appendChild(IValID.V_JUSTIFY);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_ANY));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-decoration
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_DECORATION);
+ prop.appendChild(IValID.V_UNDERLINE);
+ prop.appendChild(IValID.V_OVERLINE);
+ prop.appendChild(IValID.V_LINE_THROUGH);
+ prop.appendChild(IValID.V_BLINK);
+ prop.appendChild(IValID.V_NONE);
+ prop.setMaxValueCount(4);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-indent
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_INDENT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-overflow
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_OVERFLOW);
+ prop.appendChild(IValID.V_CLIP);
+ prop.appendChild(IValID.V_ELLIPSIS);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-shadow
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_SHADOW);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // text-transform
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_TRANSFORM);
+ prop.appendChild(IValID.V_CAPITALIZE);
+ prop.appendChild(IValID.V_UPPERCASE);
+ prop.appendChild(IValID.V_LOWERCASE);
+ prop.appendChild(IValID.V_NONE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // top
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_TOP);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // unicode-bidi
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_UNICODE_BIDI);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_EMBED);
+ prop.appendChild(IValID.V_BIDI_OVERRIDE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // vertical-align
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VERTICAL_ALIGN);
+ prop.appendChild(IValID.V_BOTTOM);
+ prop.appendChild(IValID.V_TEXT_BOTTOM);
+ prop.appendChild(IValID.V_SUB);
+ prop.appendChild(IValID.V_BASELINE);
+ prop.appendChild(IValID.V_MIDDLE);
+ prop.appendChild(IValID.V_SUPER);
+ prop.appendChild(IValID.V_TEXT_TOP);
+ prop.appendChild(IValID.V_TOP);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // visibility
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VISIBILITY);
+ prop.appendChild(IValID.V_VISIBLE);
+ prop.appendChild(IValID.V_HIDDEN);
+ prop.appendChild(IValID.V_COLLAPSE);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // voice-family
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VOICE_FAMILY);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_VOICE));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_VOICE));
+ prop.setMaxValueCount(-1);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // volume
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_VOLUME);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_SILENT);
+ prop.appendChild(IValID.V_X_SOFT);
+ prop.appendChild(IValID.V_SOFT);
+ prop.appendChild(IValID.V_MEDIUM);
+ prop.appendChild(IValID.V_LOUD);
+ prop.appendChild(IValID.V_X_LOUD);
+ prop.appendMediaGroup(IMediaGroupID.M_AURAL);
+
+ // white-space
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WHITE_SPACE);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_PRE);
+ prop.appendChild(IValID.V_PRE_LINE);
+ prop.appendChild(IValID.V_PRE_WRAP);
+ prop.appendChild(IValID.V_NOWRAP);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // widows
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WIDOWS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+ prop.appendMediaGroup(IMediaGroupID.M_PAGED);
+
+ // width
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WIDTH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // word-spacing
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_WORD_SPACING);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ // z-index
+ prop = PropCMProperty.getInstanceOf(PropCMProperty.P_Z_INDEX);
+ prop.appendChild(IValID.V_AUTO);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.appendMediaGroup(IMediaGroupID.M_VISUAL);
+
+ /** ******** font properties ********* */
+ // font-family
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_FAMILY);
+ prop.appendChild(PropCMString.getInstanceOf(PropCMString.VAL_FONT));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY));
+ prop.setMaxValueCount(-1);
+
+ // font-style
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_STYLE);
+ prop.appendChild(IValID.V_ITALIC);
+ prop.appendChild(IValID.V_OBLIQUE);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_ALL);
+ prop.setMaxValueCount(-1);
+
+ // font-variant
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_VARIANT);
+ prop.appendChild(IValID.V_SMALL_CAPS);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.setMaxValueCount(-1);
+
+ // font-weight
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_WEIGHT);
+ prop.appendChild(IValID.V_BOLD);
+ prop.appendChild(IValID.V_100);
+ prop.appendChild(IValID.V_200);
+ prop.appendChild(IValID.V_300);
+ prop.appendChild(IValID.V_400);
+ prop.appendChild(IValID.V_500);
+ prop.appendChild(IValID.V_600);
+ prop.appendChild(IValID.V_700);
+ prop.appendChild(IValID.V_800);
+ prop.appendChild(IValID.V_900);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_ALL);
+ prop.setMaxValueCount(-1);
+
+ // font-stretch
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_STRETCH);
+ prop.appendChild(IValID.V_NORMAL);
+ prop.appendChild(IValID.V_ULTRA_CONDENSED);
+ prop.appendChild(IValID.V_EXTRA_CONDENSED);
+ prop.appendChild(IValID.V_CONDENSED);
+ prop.appendChild(IValID.V_SEMI_CONDENSED);
+ prop.appendChild(IValID.V_SEMI_EXPANDED);
+ prop.appendChild(IValID.V_EXPANDED);
+ prop.appendChild(IValID.V_EXTRA_EXPANDED);
+ prop.appendChild(IValID.V_ULTRA_EXPANDED);
+ prop.appendChild(IValID.V_ALL);
+ prop.setMaxValueCount(-1);
+
+ // font-size
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_FONT_SIZE);
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE));
+ prop.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ prop.appendChild(IValID.V_ALL);
+ prop.setMaxValueCount(-1);
+
+ // unicode-range
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_UNICODE_RANGE);
+ prop.appendChild(PropCMURange.getInstanceOf(PropCMURange.VAL_URANGE));
+ prop.setMaxValueCount(-1);
+
+ // units-per-em
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_UNITS_PER_EM);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // src
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_SRC);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_FORMAT));
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_LOCAL));
+ prop.setMaxValueCount(-1);
+
+ // panose-1
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_PANOSE_1);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_INTEGER));
+ prop.setMaxValueCount(10);
+
+ // stemv
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_STEMV);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // stemh
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_STEMH);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // slope
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_SLOPE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // cap-height
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_CAP_HEIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // x-height
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_X_HEIGHT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // ascent
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_ASCENT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // descent
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_DESCENT);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // widths
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_WIDTHS);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.appendChild(PropCMURange.getInstanceOf(PropCMURange.VAL_URANGE));
+ prop.setMaxValueCount(-1);
+
+ // bbox
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_BBOX);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+ prop.setMaxValueCount(4);
+ prop.setMaxValueCount(4);
+
+ // definition-src
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_DEFINITION_SRC);
+ prop.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_URI));
+
+ // baseline
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_BASELINE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // centerline
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_CENTERLINE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // mathline
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_MATHLINE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ // topline
+ prop = PropCMFontProperty.getInstanceOf(PropCMFontProperty.PF_TOPLINE);
+ prop.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_NUM));
+
+ /** ******** containers ********* */
+
+ // absolute-size
+ PropCMContainer cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_ABSOLUTE_SIZE);
+ cont.appendChild(IValID.V_XX_SMALL);
+ cont.appendChild(IValID.V_X_SMALL);
+ cont.appendChild(IValID.V_SMALL);
+ cont.appendChild(IValID.V_MEDIUM);
+ cont.appendChild(IValID.V_LARGE);
+ cont.appendChild(IValID.V_X_LARGE);
+ cont.appendChild(IValID.V_XX_LARGE);
+
+ // border-style
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_STYLE);
+ cont.appendChild(IValID.V_SOLID);
+ cont.appendChild(IValID.V_DASHED);
+ cont.appendChild(IValID.V_DOTTED);
+ cont.appendChild(IValID.V_DOUBLE);
+ cont.appendChild(IValID.V_GROOVE);
+ cont.appendChild(IValID.V_RIDGE);
+ cont.appendChild(IValID.V_INSET);
+ cont.appendChild(IValID.V_OUTSET);
+ cont.appendChild(IValID.V_HIDDEN);
+ cont.appendChild(IValID.V_NONE);
+
+ // border-width
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_BORDER_WIDTH);
+ cont.appendChild(IValID.V_THIN);
+ cont.appendChild(IValID.V_MEDIUM);
+ cont.appendChild(IValID.V_THICK);
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+
+ // color
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_COLOR);
+ cont.appendChild(IValID.V_AQUA);
+ cont.appendChild(IValID.V_BLACK);
+ cont.appendChild(IValID.V_BLUE);
+ cont.appendChild(IValID.V_FUCHSIA);
+ cont.appendChild(IValID.V_GRAY);
+ cont.appendChild(IValID.V_GREEN);
+ cont.appendChild(IValID.V_LIME);
+ cont.appendChild(IValID.V_MAROON);
+ cont.appendChild(IValID.V_NAVY);
+ cont.appendChild(IValID.V_OLIVE);
+ cont.appendChild(IValID.V_ORANGE);
+ cont.appendChild(IValID.V_PURPLE);
+ cont.appendChild(IValID.V_RED);
+ cont.appendChild(IValID.V_SILVER);
+ cont.appendChild(IValID.V_TEAL);
+ cont.appendChild(IValID.V_WHITE);
+ cont.appendChild(IValID.V_YELLOW);
+ cont.appendChild(PropCMContainer.getContInstanceOf(PropCMContainer.VAL_SYSTEM_COLOR));
+ cont.appendChild(PropCMFunction.getInstanceOf(PropCMFunction.VAL_RGB));
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_HASH));
+
+ // system color
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_SYSTEM_COLOR);
+ cont.appendChild(IValID.V_ACTIVEBORDER);
+ cont.appendChild(IValID.V_ACTIVECAPTION);
+ cont.appendChild(IValID.V_APPWORKSPACE);
+ cont.appendChild(IValID.V_BACKGROUND);
+ cont.appendChild(IValID.V_BUTTONFACE);
+ cont.appendChild(IValID.V_BUTTONHIGHLIGHT);
+ cont.appendChild(IValID.V_BUTTONSHADOW);
+ cont.appendChild(IValID.V_BUTTONTEXT);
+ cont.appendChild(IValID.V_CAPTIONTEXT);
+ cont.appendChild(IValID.V_GRAYTEXT);
+ cont.appendChild(IValID.V_HIGHLIGHT);
+ cont.appendChild(IValID.V_HIGHLIGHTTEXT);
+ cont.appendChild(IValID.V_INACTIVEBORDER);
+ cont.appendChild(IValID.V_INACTIVECAPTION);
+ cont.appendChild(IValID.V_INACTIVECAPTIONTEXT);
+ cont.appendChild(IValID.V_INFOBACKGROUND);
+ cont.appendChild(IValID.V_INFOTEXT);
+ cont.appendChild(IValID.V_MENU);
+ cont.appendChild(IValID.V_MENUTEXT);
+ cont.appendChild(IValID.V_SCROLLBAR);
+ cont.appendChild(IValID.V_THREEDDARKSHADOW);
+ cont.appendChild(IValID.V_THREEDFACE);
+ cont.appendChild(IValID.V_THREEDHIGHLIGHT);
+ cont.appendChild(IValID.V_THREEDLIGHTSHADOW);
+ cont.appendChild(IValID.V_THREEDSHADOW);
+ cont.appendChild(IValID.V_WINDOW);
+ cont.appendChild(IValID.V_WINDOWFRAME);
+ cont.appendChild(IValID.V_WINDOWTEXT);
+
+ // generic-family
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_FAMILY);
+ cont.appendChild(IValID.V_SERIF);
+ cont.appendChild(IValID.V_SANS_SERIF);
+ cont.appendChild(IValID.V_CURSIVE);
+ cont.appendChild(IValID.V_FANTASY);
+ cont.appendChild(IValID.V_MONOSPACE);
+
+ // generic-voice
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_GENERIC_VOICE);
+ cont.appendChild(IValID.V_MALE);
+ cont.appendChild(IValID.V_FEMALE);
+ cont.appendChild(IValID.V_CHILD);
+
+ // margin-width
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_MARGIN_WIDTH);
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+ cont.appendChild(IValID.V_AUTO);
+
+ // padding-width
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_PADDING_WIDTH);
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_LENGTH));
+ cont.appendChild(PropCMNumber.getInstanceOf(PropCMNumber.VAL_PERCENTAGE));
+
+ // relative-size
+ cont = PropCMContainer.getContInstanceOf(PropCMContainer.VAL_RELATIVE_SIZE);
+ cont.appendChild(IValID.V_SMALLER);
+ cont.appendChild(IValID.V_LARGER);
+
+ LOADING = 2;
+ }
+
+ /**
+ *
+ */
+ protected static boolean isLoading() {
+ return LOADING == 1;
+ }
+
+ /**
+ *
+ */
+ protected static boolean isNeedInitialize() {
+ return LOADING == 0;
+ }
+
+ /**
+ *
+ */
+ public String toString() {
+ return getName();
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java
new file mode 100644
index 0000000..3896bb5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMNumber.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.w3c.dom.css.CSSPrimitiveValue;
+
+
+/**
+ *
+ */
+public class PropCMNumber extends PropCMNode {
+
+ private static java.util.Hashtable instances = null;
+ public final static java.lang.String VAL_ANGLE = "angle";//$NON-NLS-1$
+ public final static java.lang.String VAL_FREQUENCY = "frequency";//$NON-NLS-1$
+ public final static java.lang.String VAL_INTEGER = "integer";//$NON-NLS-1$
+ public final static java.lang.String VAL_LENGTH = "length";//$NON-NLS-1$
+ public final static java.lang.String VAL_PERCENTAGE = "percentage";//$NON-NLS-1$
+ public final static java.lang.String VAL_TIME = "time";//$NON-NLS-1$
+ public final static java.lang.String VAL_HASH = "hash"; //$NON-NLS-1$
+ public final static java.lang.String VAL_NUM = "number";//$NON-NLS-1$
+ public final static String DIM_CM = "cm";//$NON-NLS-1$
+ public final static String DIM_DEG = "deg";//$NON-NLS-1$
+ public final static String DIM_EMS = "em";//$NON-NLS-1$
+ public final static String DIM_EXS = "ex";//$NON-NLS-1$
+ public final static String DIM_GRAD = "grad";//$NON-NLS-1$
+ public final static String DIM_HASH = "#";//$NON-NLS-1$
+ public final static String DIM_HZ = "Hz";//$NON-NLS-1$
+ public final static String DIM_IN = "in";//$NON-NLS-1$
+ public final static String DIM_INTEGER = "INTEGER";//$NON-NLS-1$
+ public final static String DIM_KHZ = "kHz";//$NON-NLS-1$
+ public final static String DIM_MM = "mm";//$NON-NLS-1$
+ public final static String DIM_MS = "ms";//$NON-NLS-1$
+ public final static String DIM_NUMBER = "NUMBER";//$NON-NLS-1$
+ public final static String DIM_PC = "pc";//$NON-NLS-1$
+ public final static String DIM_PERCENTAGE = "%";//$NON-NLS-1$
+ public final static String DIM_PT = "pt";//$NON-NLS-1$
+ public final static String DIM_PX = "px";//$NON-NLS-1$
+ public final static String DIM_RAD = "rad";//$NON-NLS-1$
+ public final static String DIM_S = "s";//$NON-NLS-1$
+ private java.util.Vector fDims = new Vector();
+
+ /**
+ *
+ */
+ protected PropCMNumber(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ public static String getDimension(short primitiveType) {
+ switch (primitiveType) {
+ case CSSPrimitiveValue.CSS_CM :
+ return DIM_CM;
+ case CSSPrimitiveValue.CSS_DEG :
+ return DIM_DEG;
+ case CSSPrimitiveValue.CSS_EMS :
+ return DIM_EMS;
+ case CSSPrimitiveValue.CSS_EXS :
+ return DIM_EXS;
+ case CSSPrimitiveValue.CSS_GRAD :
+ return DIM_GRAD;
+ case ICSSPrimitiveValue.CSS_HASH :
+ return DIM_HASH; // prefix dimension ....
+ case CSSPrimitiveValue.CSS_HZ :
+ return DIM_HZ;
+ case CSSPrimitiveValue.CSS_IN :
+ return DIM_IN;
+ case ICSSPrimitiveValue.CSS_INTEGER :
+ return "";//$NON-NLS-1$
+ case CSSPrimitiveValue.CSS_KHZ :
+ return DIM_KHZ;
+ case CSSPrimitiveValue.CSS_MM :
+ return DIM_MM;
+ case CSSPrimitiveValue.CSS_MS :
+ return DIM_MS;
+ case CSSPrimitiveValue.CSS_NUMBER :
+ return "";//$NON-NLS-1$
+ case CSSPrimitiveValue.CSS_PC :
+ return DIM_PC;
+ case CSSPrimitiveValue.CSS_PERCENTAGE :
+ return DIM_PERCENTAGE;
+ case CSSPrimitiveValue.CSS_PT :
+ return DIM_PT;
+ case CSSPrimitiveValue.CSS_PX :
+ return DIM_PX;
+ case CSSPrimitiveValue.CSS_RAD :
+ return DIM_RAD;
+ case CSSPrimitiveValue.CSS_S :
+ return DIM_S;
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ */
+ public Set getDimensions() {
+ HashSet vals = new HashSet();
+ Iterator it = fDims.iterator();
+ while (it.hasNext()) {
+ vals.add(it.next());
+ }
+
+ return vals;
+ }
+
+ /**
+ *
+ */
+ void getIdentifiers(Set indents) {
+ }
+
+ /**
+ *
+ */
+ static public PropCMNumber getInstanceOf(String name) {
+ if (name == null)
+ return null;
+
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(20);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMNumber) node;
+
+ // register
+ if (PropCMNode.isLoading()) {
+ node = new PropCMNumber(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMNumber) node;
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_NUMBER;
+ }
+
+ /**
+ *
+ */
+ void getValues(Collection values) {
+ if (values != null && !values.contains(this))
+ values.add(this);
+ }
+
+ /**
+ *
+ */
+ static void initNumberCMDim() {
+ PropCMNumber num = getInstanceOf(VAL_ANGLE);
+ num.fDims.add(DIM_DEG);
+ num.fDims.add(DIM_GRAD);
+ num.fDims.add(DIM_RAD);
+
+ num = getInstanceOf(VAL_FREQUENCY);
+ num.fDims.add(DIM_HZ);
+ num.fDims.add(DIM_KHZ);
+
+ num = getInstanceOf(VAL_HASH);
+ num.fDims.add(DIM_HASH);
+
+ // num = getInstanceOf(VAL_INTEGER);
+ // num.fDims.add(DIM_INTEGER);
+
+ num = getInstanceOf(VAL_LENGTH);
+ num.fDims.add(DIM_CM);
+ num.fDims.add(DIM_EMS);
+ num.fDims.add(DIM_EXS);
+ num.fDims.add(DIM_IN);
+ num.fDims.add(DIM_MM);
+ num.fDims.add(DIM_PC);
+ num.fDims.add(DIM_PT);
+ num.fDims.add(DIM_PX);
+
+ // num = getInstanceOf(VAL_NUMBER);
+ // num.fDims.add(DIM_NUMBER);
+
+ num = getInstanceOf(VAL_PERCENTAGE);
+ num.fDims.add(DIM_PERCENTAGE);
+
+ num = getInstanceOf(VAL_TIME);
+ num.fDims.add(DIM_MS);
+ num.fDims.add(DIM_S);
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java
new file mode 100644
index 0000000..54cd4fb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMProperty.java
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class PropCMProperty extends PropCMContainer {
+
+ // static fields
+ private static java.util.Hashtable instances = null;
+ private static java.util.Hashtable cachedIdMap = null;
+ public final static String P_AZIMUTH = "azimuth";//$NON-NLS-1$
+ public final static String P_BG = "background";//$NON-NLS-1$
+ public final static String P_BG_ATTACHMENT = "background-attachment";//$NON-NLS-1$
+ public final static String P_BG_CLIP = "background-clip"; //$NON-NLS-1$
+ public final static String P_BG_COLOR = "background-color";//$NON-NLS-1$
+ public final static String P_BG_IMAGE = "background-image";//$NON-NLS-1$
+ public final static String P_BG_ORIGIN = "background-origin"; //$NON-NLS-1$
+ public final static String P_BG_POSITION = "background-position";//$NON-NLS-1$
+ public final static String P_BG_REPEAT = "background-repeat";//$NON-NLS-1$
+ public final static String P_BG_SIZE = "background-size"; //$NON-NLS-1$
+ public final static String P_BORDER = "border";//$NON-NLS-1$
+ public final static String P_BORDER_COLLAPSE = "border-collapse";//$NON-NLS-1$
+ public final static String P_BORDER_COLOR = "border-color";//$NON-NLS-1$
+ public final static String P_BORDER_SPACING = "border-spacing";//$NON-NLS-1$
+ public final static String P_BORDER_STYLE = "border-style";//$NON-NLS-1$
+ public final static String P_BORDER_TOP = "border-top";//$NON-NLS-1$
+ public final static String P_BORDER_RIGHT = "border-right";//$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM = "border-bottom";//$NON-NLS-1$
+ public final static String P_BORDER_LEFT = "border-left";//$NON-NLS-1$
+ public final static String P_BORDER_TOP_COLOR = "border-top-color";//$NON-NLS-1$
+ public final static String P_BORDER_RIGHT_COLOR = "border-right-color";//$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM_COLOR = "border-bottom-color";//$NON-NLS-1$
+ public final static String P_BORDER_LEFT_COLOR = "border-left-color";//$NON-NLS-1$
+ public final static String P_BORDER_TOP_STYLE = "border-top-style";//$NON-NLS-1$
+ public final static String P_BORDER_RIGHT_STYLE = "border-right-style";//$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM_STYLE = "border-bottom-style";//$NON-NLS-1$
+ public final static String P_BORDER_LEFT_STYLE = "border-left-style";//$NON-NLS-1$
+ public final static String P_BORDER_TOP_WIDTH = "border-top-width";//$NON-NLS-1$
+ public final static String P_BORDER_RIGHT_WIDTH = "border-right-width";//$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM_WIDTH = "border-bottom-width";//$NON-NLS-1$
+ public final static String P_BORDER_LEFT_WIDTH = "border-left-width";//$NON-NLS-1$
+ public final static String P_BORDER_WIDTH = "border-width";//$NON-NLS-1$
+ public final static String P_BORDER_RADIUS = "border-radius"; //$NON-NLS-1$
+ public final static String P_BORDER_TOP_LEFT_RADIUS = "border-top-left-radius"; //$NON-NLS-1$
+ public final static String P_BORDER_TOP_RIGHT_RADIUS = "border-top-right-radius"; //$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM_LEFT_RADIUS = "border-bottom-left-radius"; //$NON-NLS-1$
+ public final static String P_BORDER_BOTTOM_RIGHT_RADIUS = "border-bottom-right-radius"; //$NON-NLS-1$
+ public final static String P_BOTTOM = "bottom";//$NON-NLS-1$
+ public final static String P_BOX_SHADOW = "box-shadow"; //$NON-NLS-1$
+ public final static String P_BOX_SIZING = "box-sizing"; //$NON-NLS-1$
+ public final static String P_CAPTION_SIDE = "caption-side";//$NON-NLS-1$
+ public final static String P_CLEAR = "clear";//$NON-NLS-1$
+ public final static String P_CLIP = "clip";//$NON-NLS-1$
+ public final static String P_COLOR = "color";//$NON-NLS-1$
+ public final static String P_COLUMNS = "columns";//$NON-NLS-1$
+ public final static String P_COLUMN_COUNT = "column-count";//$NON-NLS-1$
+ public final static String P_COLUMN_FILL = "column-fill";//$NON-NLS-1$
+ public final static String P_COLUMN_GAP = "column-gap";//$NON-NLS-1$
+ public final static String P_COLUMN_RULE = "column-rule";//$NON-NLS-1$
+ public final static String P_COLUMN_RULE_COLOR = "column-rule-color";//$NON-NLS-1$
+ public final static String P_COLUMN_RULE_STYLE = "column-rule-styler";//$NON-NLS-1$
+ public final static String P_COLUMN_RULE_WIDTH = "column-rule-width";//$NON-NLS-1$
+ public final static String P_COLUMN_SPAN = "column-span";//$NON-NLS-1$
+ public final static String P_COLUMN_WIDTH = "column-width";//$NON-NLS-1$
+ public final static String P_CONTENT = "content";//$NON-NLS-1$
+ public final static String P_COUNTER_INCREMENT = "counter-increment";//$NON-NLS-1$
+ public final static String P_COUNTER_RESET = "counter-reset";//$NON-NLS-1$
+ public final static String P_CUE = "cue";//$NON-NLS-1$
+ public final static String P_CUE_AFTER = "cue-after";//$NON-NLS-1$
+ public final static String P_CUE_BEFORE = "cue-before";//$NON-NLS-1$
+ public final static String P_CURSOR = "cursor";//$NON-NLS-1$
+ public final static String P_DIRECTION = "direction";//$NON-NLS-1$
+ public final static String P_DISPLAY = "display";//$NON-NLS-1$
+ public final static String P_ELEVATION = "elevation";//$NON-NLS-1$
+ public final static String P_EMPTY_CELLS = "empty-cells";//$NON-NLS-1$
+ public final static String P_FLOAT = "float";//$NON-NLS-1$
+ public final static String P_FONT = "font";//$NON-NLS-1$
+ public final static String P_FONT_FAMILY = "font-family";//$NON-NLS-1$
+ public final static String P_FONT_SIZE = "font-size";//$NON-NLS-1$
+ public final static String P_FONT_SIZE_ADJUST = "font-size-adjust";//$NON-NLS-1$
+ public final static String P_FONT_STRETCH = "font-stretch";//$NON-NLS-1$
+ public final static String P_FONT_STYLE = "font-style";//$NON-NLS-1$
+ public final static String P_FONT_VARIANT = "font-variant";//$NON-NLS-1$
+ public final static String P_FONT_WEIGHT = "font-weight";//$NON-NLS-1$
+ public final static String P_HEIGHT = "height";//$NON-NLS-1$
+ public final static String P_LEFT = "left";//$NON-NLS-1$
+ public final static String P_LETTER_SPACING = "letter-spacing";//$NON-NLS-1$
+ public final static String P_LINE_HEIGHT = "line-height";//$NON-NLS-1$
+ public final static String P_LIST_STYLE = "list-style";//$NON-NLS-1$
+ public final static String P_LIST_STYLE_IMAGE = "list-style-image";//$NON-NLS-1$
+ public final static String P_LIST_STYLE_POSITION = "list-style-position";//$NON-NLS-1$
+ public final static String P_LIST_STYLE_TYPE = "list-style-type";//$NON-NLS-1$
+ public final static String P_MARGIN = "margin";//$NON-NLS-1$
+ public final static String P_MARGIN_TOP = "margin-top";//$NON-NLS-1$
+ public final static String P_MARGIN_RIGHT = "margin-right";//$NON-NLS-1$
+ public final static String P_MARGIN_BOTTOM = "margin-bottom";//$NON-NLS-1$
+ public final static String P_MARGIN_LEFT = "margin-left";//$NON-NLS-1$
+ public final static String P_MARKER_OFFSET = "marker-offset";//$NON-NLS-1$
+ public final static String P_MARKS = "marks";//$NON-NLS-1$
+ public final static String P_MAX_HEIGHT = "max-height";//$NON-NLS-1$
+ public final static String P_MAX_WIDTH = "max-width";//$NON-NLS-1$
+ public final static String P_MIN_HEIGHT = "min-height";//$NON-NLS-1$
+ public final static String P_MIN_WIDTH = "min-width";//$NON-NLS-1$
+ public final static String P_OPACITY = "opacity"; //$NON-NLS-1$
+ public final static String P_ORPHANS = "orphans";//$NON-NLS-1$
+ public final static String P_OUTLINE = "outline";//$NON-NLS-1$
+ public final static String P_OUTLINE_COLOR = "outline-color";//$NON-NLS-1$
+ public final static String P_OUTLINE_STYLE = "outline-style";//$NON-NLS-1$
+ public final static String P_OUTLINE_WIDTH = "outline-width";//$NON-NLS-1$
+ public final static String P_OVERFLOW = "overflow";//$NON-NLS-1$
+ public final static String P_PADDING = "padding";//$NON-NLS-1$
+ public final static String P_PADDING_TOP = "padding-top";//$NON-NLS-1$
+ public final static String P_PADDING_RIGHT = "padding-right";//$NON-NLS-1$
+ public final static String P_PADDING_BOTTOM = "padding-bottom";//$NON-NLS-1$
+ public final static String P_PADDING_LEFT = "padding-left";//$NON-NLS-1$
+ public final static String P_PAGE = "page";//$NON-NLS-1$
+ public final static String P_PAGE_BREAK_AFTER = "page-break-after";//$NON-NLS-1$
+ public final static String P_PAGE_BREAK_BEFORE = "page-break-before";//$NON-NLS-1$
+ public final static String P_PAGE_BREAK_INSIDE = "page-break-inside";//$NON-NLS-1$
+ public final static String P_PAUSE = "pause";//$NON-NLS-1$
+ public final static String P_PAUSE_AFTER = "pause-after";//$NON-NLS-1$
+ public final static String P_PAUSE_BEFORE = "pause-before";//$NON-NLS-1$
+ public final static String P_PITCH = "pitch";//$NON-NLS-1$
+ public final static String P_PITCH_RANGE = "pitch-range";//$NON-NLS-1$
+ public final static String P_PLAY_DURING = "play-during";//$NON-NLS-1$
+ public final static String P_POSITION = "position";//$NON-NLS-1$
+ public final static String P_QUOTES = "quotes";//$NON-NLS-1$
+ public final static String P_RESIZE = "resize"; //$NON-NLS-1$
+ public final static String P_RICHNESS = "richness";//$NON-NLS-1$
+ public final static String P_RIGHT = "right";//$NON-NLS-1$
+ public final static String P_SIZE = "size";//$NON-NLS-1$
+ public final static String P_SPEAK = "speak";//$NON-NLS-1$
+ public final static String P_SPEAK_HEADER = "speak-header";//$NON-NLS-1$
+ public final static String P_SPEAK_NUMERAL = "speak-numeral";//$NON-NLS-1$
+ public final static String P_SPEAK_PUNCTUATION = "speak-punctuation";//$NON-NLS-1$
+ public final static String P_SPEECH_RATE = "speech-rate";//$NON-NLS-1$
+ public final static String P_STRESS = "stress";//$NON-NLS-1$
+ public final static String P_TABLE_LAYOUT = "table-layout";//$NON-NLS-1$
+ public final static String P_TEXT_ALIGN = "text-align";//$NON-NLS-1$
+ public final static String P_TEXT_DECORATION = "text-decoration";//$NON-NLS-1$
+ public final static String P_TEXT_INDENT = "text-indent";//$NON-NLS-1$
+ public final static String P_TEXT_OVERFLOW = "text-overflow"; //$NON-NLS-1$
+ public final static String P_TEXT_SHADOW = "text-shadow";//$NON-NLS-1$
+ public final static String P_TEXT_TRANSFORM = "text-transform";//$NON-NLS-1$
+ public final static String P_TOP = "top";//$NON-NLS-1$
+ public final static String P_UNICODE_BIDI = "unicode-bidi";//$NON-NLS-1$
+ public final static String P_VERTICAL_ALIGN = "vertical-align";//$NON-NLS-1$
+ public final static String P_VISIBILITY = "visibility";//$NON-NLS-1$
+ public final static String P_VOICE_FAMILY = "voice-family";//$NON-NLS-1$
+ public final static String P_VOLUME = "volume";//$NON-NLS-1$
+ public final static String P_WHITE_SPACE = "white-space";//$NON-NLS-1$
+ public final static String P_WIDOWS = "widows";//$NON-NLS-1$
+ public final static String P_WIDTH = "width";//$NON-NLS-1$
+ public final static String P_WORD_SPACING = "word-spacing";//$NON-NLS-1$
+ public final static String P_Z_INDEX = "z-index";//$NON-NLS-1$
+ // instance fields
+ private int fMinValueCount = 1;
+ private int fMaxValueCount = 1;
+ private Object[] mediaGroups;
+ protected List containers;
+
+ /**
+ *
+ */
+ protected PropCMProperty(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ Object appendChild(Object node) {
+ Object ret = super.appendChild(node);
+ if (node instanceof PropCMProperty) {
+ // register shorthand container
+ PropCMProperty cm = (PropCMProperty) node;
+ if (cm.containers == null)
+ cm.containers = new Vector();
+ if (!cm.containers.contains(this))
+ cm.containers.add(this);
+ }
+ return ret;
+ }
+
+ /**
+ *
+ */
+ void appendMediaGroup(Object mg) {
+ if (mediaGroups == null)
+ mediaGroups = new Object[1];
+ else {
+ Object[] oldMediaGroups = mediaGroups;
+ mediaGroups = new Object[oldMediaGroups.length + 1];
+ System.arraycopy(oldMediaGroups, 0, mediaGroups, 0, oldMediaGroups.length);
+ }
+ mediaGroups[mediaGroups.length - 1] = mg;
+ }
+
+ /**
+ *
+ */
+ public static PropCMProperty getInstanceOf(String name) {
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(200);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMProperty) node;
+
+ // register
+ if (PropCMNode.isLoading()) {
+ node = new PropCMProperty(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMProperty) node;
+ }
+
+ /**
+ *
+ */
+ public int getMaxValueCount() {
+ return fMaxValueCount;
+ }
+
+ /**
+ *
+ */
+ public List getMediaGroups() {
+ if (mediaGroups != null)
+ return Arrays.asList(mediaGroups);
+ else
+ return new ArrayList();
+ }
+
+ /**
+ *
+ */
+ public int getMinValueCount() {
+ return fMinValueCount;
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getNameEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.keys();
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getPropertyEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.elements();
+ }
+
+ /**
+ *
+ */
+ public int getShorthandContainerCount() {
+ return (containers == null) ? 0 : containers.size();
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_PROPERTY;
+ }
+
+ /**
+ *
+ */
+ public boolean isShorthand() {
+ int nChild = getNumChild();
+ for (int i = 0; i < nChild; i++) {
+ Object obj = getChildAt(i);
+ if (obj instanceof PropCMProperty && !(obj instanceof PropCMSubProperty))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static Vector names() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return new Vector(instances.keySet());
+ }
+
+ /**
+ *
+ */
+ public static List names(Object mediaGroup) {
+ if (mediaGroup == null)
+ return names();
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ Vector properties = new Vector();
+
+ Iterator it = instances.values().iterator();
+ while (it.hasNext()) {
+ PropCMProperty prop = (PropCMProperty) it.next();
+ if (prop.getMediaGroups().contains(mediaGroup))
+ properties.add(prop.getName());
+ }
+
+ return properties;
+ }
+
+ /**
+ * If identifier is null, get all properties
+ */
+ public static Vector propertiesFor(String identifier, boolean shorthands) {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // if identifier is null, get all properties
+ if (identifier == null)
+ return new Vector(instances.values());
+
+ if (cachedIdMap == null) {
+ // start cacheing
+ cachedIdMap = new Hashtable();
+ }
+ else {
+ // search cached
+ Object ret = cachedIdMap.get(identifier + String.valueOf(shorthands));
+ if (ret != null)
+ return new Vector((Collection) ret);
+ }
+
+ // create
+ Enumeration propertyEnum = getPropertyEnum();
+ HashSet set = new HashSet();
+ while (propertyEnum.hasMoreElements()) {
+ PropCMProperty prop = (PropCMProperty) propertyEnum.nextElement();
+ if (!shorthands && prop.isShorthand())
+ continue;
+ if (prop.canHave(identifier))
+ set.add(prop);
+ }
+
+ // cache
+ cachedIdMap.put(identifier + String.valueOf(shorthands), set);
+
+ return new Vector(set);
+ }
+
+ /**
+ *
+ */
+ protected void setMaxValueCount(int newMaxValueCount) {
+ fMaxValueCount = newMaxValueCount;
+ }
+
+ /**
+ *
+ */
+ protected void setMinValueCount(int newMinValueCount) {
+ fMinValueCount = newMinValueCount;
+ }
+
+ /**
+ *
+ */
+ public PropCMProperty shorthandContainerAt(int i) {
+ if (containers == null)
+ return null;
+ if (i < 0 || containers.size() <= i)
+ return null;
+ return (PropCMProperty) containers.get(i);
+ }
+
+ /**
+ *
+ */
+ public Iterator shorthandContainerIterator() {
+ if (containers == null) {
+ return new Iterator() {
+ public boolean hasNext() {
+ return false;
+ }
+
+ public Object next() {
+ return null;
+ }
+
+ public void remove() {
+ }
+ };
+ }
+ else
+ return containers.iterator();
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java
new file mode 100644
index 0000000..00a1e82
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMString.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Set;
+
+/**
+ *
+ */
+public class PropCMString extends PropCMNode {
+
+ private static java.util.Hashtable instances = null;
+ public final static java.lang.String VAL_FONT = "font";//$NON-NLS-1$
+ public final static java.lang.String VAL_COUNTER_ID = "counterId";//$NON-NLS-1$
+ public final static java.lang.String VAL_PAGE_ID = "pageId";//$NON-NLS-1$
+ public final static java.lang.String VAL_VOICE = "voice";//$NON-NLS-1$
+ public final static java.lang.String VAL_ANY = "any"; //$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMString(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ void getIdentifiers(Set indents) {
+ }
+
+ /**
+ *
+ */
+ static public PropCMString getInstanceOf(String name) {
+ if (name == null)
+ return null;
+
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(10);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMString) node;
+
+ // register
+ node = new PropCMString(name);
+ instances.put(name, node);
+
+ return (PropCMString) node;
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_STRING;
+ }
+
+ /**
+ *
+ */
+ void getValues(Collection values) {
+ if (values != null && !values.contains(this))
+ values.add(this);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java
new file mode 100644
index 0000000..81ebb37
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMSubProperty.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ *
+ */
+public class PropCMSubProperty extends PropCMProperty {
+
+ // static fields
+ private static java.util.Hashtable instances = null;
+ public final static String PSUB_BG_POSITION_X = "background-positionH";//$NON-NLS-1$
+ public final static String PSUB_BG_POSITION_Y = "background-positionV";//$NON-NLS-1$
+ public final static String PSUB_CLIP_TOP = "clipTop";//$NON-NLS-1$
+ public final static String PSUB_CLIP_RIGHT = "clipRight";//$NON-NLS-1$
+ public final static String PSUB_CLIP_BOTTOM = "clipBottom";//$NON-NLS-1$
+ public final static String PSUB_CLIP_LEFT = "clipLeft";//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMSubProperty(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ public PropCMProperty getContainer() {
+ return shorthandContainerAt(0);
+ }
+
+ /**
+ *
+ */
+ public static PropCMProperty getInstanceOf(String name) {
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(10);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMProperty) node;
+
+ // register
+ if (PropCMNode.isLoading()) {
+ node = new PropCMSubProperty(name);
+ instances.put(name, node);
+ }
+
+ return (PropCMProperty) node;
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getNameEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.keys();
+ }
+
+ /**
+ *
+ */
+ public static Enumeration getPropertyEnum() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return instances.elements();
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_SUBPROPERTY;
+ }
+
+ /**
+ *
+ */
+ public static Vector names() {
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ return new Vector(instances.keySet());
+ }
+
+ /**
+ *
+ */
+ public void setContainer(PropCMProperty prop) {
+ if (containers == null)
+ containers = new Vector();
+ containers.clear();
+ containers.add(prop);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java
new file mode 100644
index 0000000..3375715
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMURange.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Set;
+
+/**
+ *
+ */
+public class PropCMURange extends PropCMNode {
+
+ private static java.util.Hashtable instances = null;
+ public final static String VAL_URANGE = "urange";//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected PropCMURange(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ */
+ void getIdentifiers(Set indents) {
+ }
+
+ /**
+ *
+ */
+ public static PropCMURange getInstanceOf(String name) {
+ if (name == null)
+ return null;
+
+ // initialize
+ if (instances == null)
+ instances = new Hashtable(10);
+
+ // Initialize of DB
+ if (isNeedInitialize())
+ PropCMNode.initPropertyCM();
+
+ // query
+ Object node = instances.get(name);
+ if (node != null)
+ return (PropCMURange) node;
+
+ // register
+ node = new PropCMURange(name);
+ instances.put(name, node);
+
+ return (PropCMURange) node;
+ }
+
+ /**
+ *
+ */
+ public short getType() {
+ return VAL_UNICODE_RANGE;
+ }
+
+ /**
+ *
+ */
+ void getValues(Collection values) {
+ if (values != null && !values.contains(this))
+ values.add(this);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java
new file mode 100644
index 0000000..816ba37
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentmodel/PropCMUtil.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentmodel;
+
+
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ *
+ */
+public class PropCMUtil {
+
+ /**
+ *
+ */
+ public static void minus(Collection src, Collection ref) {
+ Iterator it = ref.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (src.contains(obj))
+ src.remove(obj);
+ }
+ return;
+ }
+
+ /**
+ *
+ */
+ public static void plus(Collection src, Collection ref) {
+ Iterator it = ref.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (!src.contains(obj))
+ src.add(obj);
+ }
+ return;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java
new file mode 100644
index 0000000..3bbc582
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentProperties.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentproperties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.Logger;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * Properties constants used by CSS. Clients should only read and modify the
+ * CSS properties programmatically using this class.
+ *
+ * @since 1.1
+ */
+public class CSSContentProperties {
+ static final String CSSCORE_ID = CSSCorePlugin.getDefault().getBundle().getSymbolicName();
+ private static final String PROJECT_KEY = "<project>"; //$NON-NLS-1$
+
+ /**
+ * The default css profile to use when none is specified.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ */
+ public static final String CSS_PROFILE = "css-profile"; //$NON-NLS-1$
+
+ /**
+ * Generates a preference key based on resourcePath
+ *
+ * @param resourcePath
+ * the path the key will be based off of
+ * @return preference key based on resourcePath (basically the
+ * resourcePath without the filename); PROJECT_KEY if resourcePath
+ * is null
+ */
+ static String getKeyFor(IPath resourcePath) {
+ String key = PROJECT_KEY;
+ if (resourcePath != null && resourcePath.segmentCount() > 1) {
+ key = resourcePath.removeFirstSegments(1).toString();
+ }
+ return key;
+ }
+
+ /**
+ * Get the preferences node associated with the given project scope and
+ * preference key (subNode) If create is true, the preference node will be
+ * created if one does not already exist
+ *
+ * @param project
+ * the project the preference node is under
+ * @param preferenceKey
+ * the subnode/category the preference node is located in
+ * @param create
+ * if true, a preference node will be created if one does not
+ * already exist
+ * @return Preferences associated with the given project scope and
+ * preference key. null if one could not be found and create is
+ * false
+ */
+ static Preferences getPreferences(IProject project, String preferenceKey, boolean create) {
+ if (create)
+ // create all nodes down to the one we are interested in
+ return new ProjectScope(project).getNode(CSSCORE_ID).node(preferenceKey);
+ // be careful looking up for our node so not to create any nodes as
+ // side effect
+ Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
+ try {
+ // TODO once bug 90500 is fixed, should be as simple as this:
+ // String path = project.getName() + IPath.SEPARATOR +
+ // ResourcesPlugin.PI_RESOURCES + IPath.SEPARATOR +
+ // ENCODING_PREF_NODE;
+ // return node.nodeExists(path) ? node.node(path) : null;
+ // for now, take the long way
+ if (!node.nodeExists(project.getName()))
+ return null;
+ node = node.node(project.getName());
+ if (!node.nodeExists(CSSCORE_ID))
+ return null;
+ node = node.node(CSSCORE_ID);
+ if (!node.nodeExists(preferenceKey))
+ return null;
+ return node.node(preferenceKey);
+ }
+ catch (BackingStoreException e) {
+ // nodeExists failed
+ Logger.log(Logger.WARNING_DEBUG, "Could not retrieve preference node", e); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ /**
+ * Returns the value for the given key in the given context.
+ *
+ * @param key
+ * The property key
+ * @param resource
+ * The current context or <code>null</code> if no context is
+ * available and the workspace setting should be taken. Note
+ * that passing <code>null</code> should be avoided.
+ * @param recurse
+ * whether the parent should be queried till property is found
+ * @return Returns the current value for the key.
+ * @since 1.1
+ */
+ public static String getProperty(String key, IResource resource, boolean recurse) {
+ String val = null;
+ // boolean preferenceFound = false;
+ if (resource != null) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ Preferences preferences = getPreferences(project, key, false);
+ if (preferences != null) {
+ val = internalGetProperty(resource, recurse, preferences);
+ // preferenceFound = true;
+ }
+ }
+ }
+ // Workbench preference may not be needed so leave out for now
+ // // no preferences found - for performance reasons,
+ // // short-circuit
+ // // lookup by falling back to workspace's default
+ // // setting
+ // if (!preferenceFound)
+ // val = getWorkbenchPreference(key);
+ return val;
+ }
+
+ private static String internalGetProperty(IResource resource, boolean recurse, Preferences preferences) {
+ String value = preferences.get(getKeyFor(resource.getFullPath()), null);
+ if (value == null && resource != resource.getProject() && recurse) {
+ value = preferences.get(getKeyFor(null), null);
+ }
+
+ // Workbench preference may not be needed so leave out for now
+ // // ensure we default to the workspace preference if none is found
+ // return value == null ? getWorkbenchPreference(key) : value;
+ return value;
+ }
+
+ /**
+ * Sets the value for the given key in the given context.
+ *
+ * @param key
+ * The property key
+ * @param resource
+ * The current context. Note context cannot be
+ * <code>null</code>.
+ * @param value
+ * The value to set for the key. If value is <code>null</code>
+ * the key is removed from properties.
+ * @since 1.1
+ */
+ public static void setProperty(String key, IResource resource, String value) throws CoreException {
+ if (resource != null) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ Preferences preferences = getPreferences(project, key, true);
+ if (value == null || value.trim().length() == 0)
+ preferences.remove(getKeyFor(resource.getFullPath()));
+ else
+ preferences.put(getKeyFor(resource.getFullPath()), value);
+ try {
+ // save changes
+ preferences.flush();
+ }
+ catch (BackingStoreException e) {
+ throw new CoreException(new Status(IStatus.ERROR, CSSCORE_ID, IStatus.ERROR, "Unable to set property", e)); //$NON-NLS-1$
+ }
+ }
+ }
+ // Workbench preference may not be needed so leave out for now
+ // just set a preference in the instance scope
+ // if (!preferenceFound) {
+ // setWorkbenchPreference(key);
+ // }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java
new file mode 100644
index 0000000..25a4b8d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contentproperties/CSSContentPropertiesManager.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contentproperties;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.css.core.internal.CSSCoreMessages;
+import org.eclipse.wst.css.core.internal.Logger;
+import org.osgi.framework.Bundle;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+public class CSSContentPropertiesManager {
+ public CSSContentPropertiesManager() {
+ super();
+ fResourceChangeListener = new ResourceChangeListener();
+ fJob = new ContentPropertiesManagerJob();
+ }
+
+ private static CSSContentPropertiesManager _instance = null;
+ private IResourceChangeListener fResourceChangeListener;
+ ContentPropertiesManagerJob fJob;
+
+ /**
+ * This job implementation is used to allow the resource change listener
+ * to schedule operations that need to modify the workspace.
+ */
+ private class ContentPropertiesManagerJob extends Job {
+ private static final int PROPERTIES_UPDATE_DELAY = 500;
+ private List asyncChanges = new ArrayList();
+
+ public ContentPropertiesManagerJob() {
+ super(CSSCoreMessages.CSSContentPropertiesManager_Updating);
+ setSystem(true);
+ setPriority(Job.INTERACTIVE);
+ }
+
+ public void addChanges(Set newChanges) {
+ if (newChanges.isEmpty())
+ return;
+ synchronized (asyncChanges) {
+ asyncChanges.addAll(newChanges);
+ asyncChanges.notify();
+ }
+ schedule(PROPERTIES_UPDATE_DELAY);
+ }
+
+ public IProject getNextChange() {
+ synchronized (asyncChanges) {
+ return asyncChanges.isEmpty() ? null : (IProject) asyncChanges.remove(asyncChanges.size() - 1);
+ }
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ MultiStatus result = new MultiStatus(CSSContentProperties.CSSCORE_ID, IResourceStatus.FAILED_SETTING_CHARSET, CSSCoreMessages.CSSContentPropertiesManager_Updating, null);
+ monitor = monitor == null ? new NullProgressMonitor() : monitor;
+ try {
+ monitor.beginTask(CSSCoreMessages.CSSContentPropertiesManager_Updating, asyncChanges.size());
+ try {
+ IProject next;
+ while ((next = getNextChange()) != null) {
+ // just exit if the system is shutting down or has
+ // been shut down
+ // it is too late to change the workspace at this
+ // point anyway
+ if (Platform.getBundle("org.eclipse.osgi").getState() != Bundle.ACTIVE) //$NON-NLS-1$
+ return Status.OK_STATUS;
+ try {
+ // save the preferences nodes
+ if (next.isAccessible()) {
+ // save css profile preferences
+ Preferences projectPrefs = CSSContentProperties.getPreferences(next, CSSContentProperties.CSS_PROFILE, false);
+ if (projectPrefs != null)
+ projectPrefs.flush();
+
+ }
+ }
+ catch (BackingStoreException e) {
+ // we got an error saving
+ String detailMessage = NLS.bind(CSSCoreMessages.CSSContentPropertiesManager_Problems_Updating, next.getFullPath());
+ result.add(new Status(1 << (IResourceStatus.FAILED_SETTING_CHARSET % 100 / 33), ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_SETTING_CHARSET, detailMessage, e));
+ }
+ }
+ monitor.worked(1);
+ }
+ catch (OperationCanceledException e) {
+ throw e;
+ }
+ }
+ finally {
+ monitor.done();
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#shouldRun()
+ */
+ public boolean shouldRun() {
+ synchronized (asyncChanges) {
+ return !asyncChanges.isEmpty();
+ }
+ }
+ }
+
+ class ResourceChangeListener implements IResourceChangeListener {
+ private void processEntryChanges(IResourceDelta projectDelta, Set projectsToSave) {
+ // check each resource with css content setting to see if it has
+ // been moved/deleted
+ boolean resourceChanges = false;
+
+ // project affected
+ IProject currentProject = (IProject) projectDelta.getResource();
+
+ resourceChanges = processPreferences(currentProject, CSSContentProperties.CSS_PROFILE, projectDelta, projectsToSave);
+
+ // if there was a preference key change, need to save preferences
+ if (resourceChanges)
+ projectsToSave.add(currentProject);
+ }
+
+ /**
+ * Goes through all the resource-dependent preferences associated with
+ * currentProject & key and updates the preference keys if needed
+ * based on projectDelta
+ *
+ * @param currentProject
+ * current project of the preferences to be looked at
+ * @param key
+ * current key/subcategory of the preferences to be looked
+ * at
+ * @param projectDelta
+ * the changes to process the preference keys against
+ * @param projectsToSave
+ * the projects that need to be updated/saved
+ * @return true if currentProject's preferences were modified
+ */
+ private boolean processPreferences(IProject currentProject, String key, IResourceDelta projectDelta, Set projectsToSave) {
+ boolean resourceChanges = false;
+
+ // get the project-key preference node
+ Preferences projectPrefs = CSSContentProperties.getPreferences(currentProject, key, false);
+ if (projectPrefs == null)
+ // no preferences for this project-key, just bail
+ return false;
+ String[] affectedResources;
+ try {
+ affectedResources = projectPrefs.keys();
+ }
+ catch (BackingStoreException e) {
+ // problems with the project scope... we gonna miss the
+ // changes (but will log)
+ Logger.log(Logger.WARNING_DEBUG, "Problem retreiving JSP Fragment preferences", e); //$NON-NLS-1$
+ return false;
+ }
+
+ // go through each preference key (which is really a file name)
+ for (int i = 0; i < affectedResources.length; i++) {
+ // see if preference key/file name was file that was changed
+ IResourceDelta memberDelta = projectDelta.findMember(new Path(affectedResources[i]));
+ // no changes for the given resource
+ if (memberDelta == null)
+ continue;
+ if (memberDelta.getKind() == IResourceDelta.REMOVED) {
+ resourceChanges = true;
+ // remove the setting for the original location
+ String currentValue = projectPrefs.get(affectedResources[i], null);
+ projectPrefs.remove(affectedResources[i]);
+ if ((memberDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ // if moving, copy the setting for the new location
+ IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(memberDelta.getMovedToPath().segment(0));
+ Preferences targetPrefs = CSSContentProperties.getPreferences(targetProject, key, true);
+ targetPrefs.put(CSSContentProperties.getKeyFor(memberDelta.getMovedToPath()), currentValue);
+ if (targetProject != currentProject)
+ projectsToSave.add(targetProject);
+ }
+ }
+ }
+ return resourceChanges;
+ }
+
+ /**
+ * For any change to the encoding file or any resource with encoding
+ * set, just discard the cache for the corresponding project.
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ if (delta == null)
+ return;
+ IResourceDelta[] projectDeltas = delta.getAffectedChildren();
+ // process each project in the delta
+ Set projectsToSave = new HashSet();
+ for (int i = 0; i < projectDeltas.length; i++)
+ // nothing to do if a project has been added/removed/moved
+ if (projectDeltas[i].getKind() == IResourceDelta.CHANGED && (projectDeltas[i].getFlags() & IResourceDelta.OPEN) == 0)
+ processEntryChanges(projectDeltas[i], projectsToSave);
+ fJob.addChanges(projectsToSave);
+ }
+ }
+
+ public synchronized static void startup() {
+ _instance = new CSSContentPropertiesManager();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(_instance.fResourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+ }
+
+ public synchronized static void shutdown() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(_instance.fResourceChangeListener);
+ _instance = null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java
new file mode 100644
index 0000000..72b876b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ByteReader.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
+
+/**
+ * This is an "adapter" class, simply to get in input stream to act like a
+ * reader. We could not use InputStreamReader directly because its internal
+ * buffers are not controllable, and it sometimes pulls too much out of input
+ * stream (even when it wasn't needed for our purposes).
+ *
+ * The use of this class is highly specialized and by no means meant to be
+ * general purpose. Its use is restricted to those cases where the input
+ * stream can be regarded as ascii just long enough to determine what the real
+ * encoding should be.
+ */
+
+public class ByteReader extends Reader {
+
+
+ public static final int DEFAULT_BUFFER_SIZE = CodedIO.MAX_BUF_SIZE;
+
+ protected byte[] fBuffer;
+
+ protected InputStream fInputStream;
+
+ protected ByteReader() {
+ super();
+ }
+
+ public ByteReader(InputStream inputStream) {
+ this(inputStream, DEFAULT_BUFFER_SIZE);
+ if (!inputStream.markSupported()) {
+ throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
+ }
+ }
+
+ public ByteReader(InputStream inputStream, int size) {
+ this.fInputStream = inputStream;
+ if (!inputStream.markSupported()) {
+ throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
+ }
+ this.fBuffer = new byte[size];
+
+ }
+
+ public void close() throws IOException {
+ this.fInputStream.close();
+ }
+
+ public void mark(int readAheadLimit) {
+ this.fInputStream.mark(readAheadLimit);
+ }
+
+ public boolean markSupported() {
+ return true;
+ }
+
+ public int read() throws IOException {
+ int b0 = this.fInputStream.read();
+ return (b0 & 0x00FF);
+ }
+
+ public int read(char ch[], int offset, int length) throws IOException {
+ if (length > this.fBuffer.length) {
+ length = this.fBuffer.length;
+ }
+
+ int count = this.fInputStream.read(this.fBuffer, 0, length);
+
+ for (int i = 0; i < count; i++) {
+ int b0 = this.fBuffer[i];
+ // the 0x00FF is to "lose" the negative bits filled in the byte to
+ // int conversion
+ // (and which would be there if cast directly from byte to char).
+ char c0 = (char) (b0 & 0x00FF);
+ ch[offset + i] = c0;
+ }
+ return count;
+ }
+
+ public boolean ready() throws IOException {
+ return this.fInputStream.available() > 0;
+ }
+
+ public void reset() throws IOException {
+ this.fInputStream.reset();
+ }
+
+ public long skip(long n) throws IOException {
+ return this.fInputStream.skip(n);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java
new file mode 100644
index 0000000..dbdffec
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizer.java
@@ -0,0 +1,1440 @@
+/* The following code was generated by JFlex 1.2.2 on 7/28/08 5:19 PM */
+
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*nlsXXX*/
+package org.eclipse.wst.css.core.internal.contenttype;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants;
+import org.eclipse.wst.xml.core.internal.contenttype.XMLHeadTokenizerConstants;
+
+
+
+
+/**
+ * This class is a scanner generated by
+ * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2
+ * on 7/28/08 5:19 PM from the specification file
+ * <tt>file:/D:/workspaces/wtp301/workspace/org.eclipse.wst.sse.core/DevTimeSupport/HeadParsers/CSSHeadTokenizer/CSSHeadTokenizer.jFlex</tt>
+ */
+public class CSSHeadTokenizer {
+
+ /** this character denotes the end of file */
+ final public static int YYEOF = -1;
+
+ /** lexical states */
+ final public static int YYINITIAL = 0;
+ final public static int UnDelimitedString = 12;
+ final public static int DQ_STRING = 8;
+ final public static int SQ_STRING = 10;
+ final public static int ST_XMLDecl = 2;
+ final public static int QuotedAttributeValue = 6;
+ final public static int CHARSET_RULE = 4;
+
+ /**
+ * YY_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private final static int YY_LEXSTATE[] = {
+ 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ final private static String yycmap_packed =
+ "\1\11\10\0\1\6\1\10\2\0\1\7\22\0\1\6\1\0\1\37"+
+ "\2\0\1\42\1\0\1\40\7\0\1\41\13\0\1\36\1\13\1\12"+
+ "\1\35\1\14\1\20\1\23\1\0\1\21\1\32\1\26\1\0\1\34"+
+ "\1\22\1\33\2\0\1\17\1\16\1\30\1\31\2\0\1\24\1\25"+
+ "\1\27\3\0\1\15\10\0\1\23\1\0\1\21\1\32\1\26\1\0"+
+ "\1\34\1\22\1\33\2\0\1\17\1\16\1\30\1\31\2\0\1\24"+
+ "\1\25\1\27\3\0\1\15\102\0\1\4\3\0\1\5\17\0\1\3"+
+ "\16\0\1\1\20\0\1\3\16\0\1\1\1\2\170\0\1\2\ufe87\0";
+
+ /**
+ * Translates characters to character classes
+ */
+ final private static char [] yycmap = yy_unpack_cmap(yycmap_packed);
+
+
+ /* error codes */
+ final private static int YY_UNKNOWN_ERROR = 0;
+ final private static int YY_ILLEGAL_STATE = 1;
+ final private static int YY_NO_MATCH = 2;
+ final private static int YY_PUSHBACK_2BIG = 3;
+
+ /* error messages for the codes above */
+ final private static String YY_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Internal error: unknown state",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /** the input device */
+ private java.io.Reader yy_reader;
+
+ /** the current state of the DFA */
+ private int yy_state;
+
+ /** the current lexical state */
+ private int yy_lexical_state = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char yy_buffer[] = new char[16384];
+
+ /** the textposition at the last accepting state */
+ private int yy_markedPos;
+
+ /** the textposition at the last state to be included in yytext */
+ private int yy_pushbackPos;
+
+ /** the current text position in the buffer */
+ private int yy_currentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int yy_startRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int yy_endRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+// private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+// private int yycolumn;
+
+ /**
+ * yy_atBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean yy_atBOL;
+
+ /** yy_atEOF == true <=> the scanner has returned a value for EOF */
+ private boolean yy_atEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean yy_eof_done;
+
+ /* user code: */
+
+
+ private boolean hasMore = true;
+ private final static int MAX_TO_SCAN = 8000;
+ StringBuffer string = new StringBuffer();
+ // state stack for easier state handling
+ private IntStack fStateStack = new IntStack();
+ private String valueText = null;
+
+
+
+ public CSSHeadTokenizer() {
+ super();
+ }
+
+ public void reset (Reader in) {
+ /* the input device */
+ yy_reader = in;
+
+ /* the current state of the DFA */
+ yy_state = 0;
+
+ /* the current lexical state */
+ yy_lexical_state = YYINITIAL;
+
+ /* this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ java.util.Arrays.fill(yy_buffer, (char)0);
+
+ /* the textposition at the last accepting state */
+ yy_markedPos = 0;
+
+ /* the textposition at the last state to be included in yytext */
+ yy_pushbackPos = 0;
+
+ /* the current text position in the buffer */
+ yy_currentPos = 0;
+
+ /* startRead marks the beginning of the yytext() string in the buffer */
+ yy_startRead = 0;
+
+ /**
+ * endRead marks the last character in the buffer, that has been read
+ * from input
+ */
+ yy_endRead = 0;
+
+ /* number of newlines encountered up to the start of the matched text */
+// yyline = 0;
+
+ /* the number of characters up to the start of the matched text */
+ yychar = 0;
+
+ /**
+ * the number of characters from the last newline up to the start
+ * of the matched text
+ */
+// yycolumn = 0;
+
+ /**
+ * yy_atBOL == true <=> the scanner is currently at the beginning
+ * of a line
+ */
+ yy_atBOL = false;
+
+ /* yy_atEOF == true <=> the scanner has returned a value for EOF */
+ yy_atEOF = false;
+
+ /* denotes if the user-EOF-code has already been executed */
+ yy_eof_done = false;
+
+
+ fStateStack.clear();
+
+ hasMore = true;
+
+ // its a little wasteful to "throw away" first char array generated
+ // by class init (via auto generated code), but we really do want
+ // a small buffer for our head parsers.
+ if (yy_buffer.length != MAX_TO_SCAN) {
+ yy_buffer = new char[MAX_TO_SCAN];
+ }
+
+
+ }
+
+
+ public final HeadParserToken getNextToken() throws IOException {
+ String context = null;
+ context = primGetNextToken();
+ HeadParserToken result = null;
+ if (valueText != null) {
+ result = createToken(context, yychar, valueText);
+ valueText = null;
+ } else {
+ result = createToken(context, yychar, yytext());
+ }
+ return result;
+ }
+
+ public final boolean hasMoreTokens() {
+ return hasMore && yychar < MAX_TO_SCAN;
+ }
+ private void pushCurrentState() {
+ fStateStack.push(yystate());
+
+ }
+
+ private void popState() {
+ yybegin(fStateStack.pop());
+ }
+ private HeadParserToken createToken(String context, int start, String text) {
+ return new HeadParserToken(context, start, text);
+ }
+
+
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ public CSSHeadTokenizer(java.io.Reader in) {
+ this.yy_reader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ public CSSHeadTokenizer(java.io.InputStream in) {
+ this(new java.io.InputStreamReader(in));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] yy_unpack_cmap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 160) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Gets the next input character.
+ *
+ * @return the next character of the input stream, EOF if the
+ * end of the stream is reached.
+ * @exception IOException if any I/O-Error occurs
+ */
+ private int yy_advance() throws java.io.IOException {
+
+ /* standard case */
+ if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++];
+
+ /* if the eof is reached, we don't need to work hard */
+ if (yy_atEOF) return YYEOF;
+
+ /* otherwise: need to refill the buffer */
+
+ /* first: make room (if you can) */
+ if (yy_startRead > 0) {
+ System.arraycopy(yy_buffer, yy_startRead,
+ yy_buffer, 0,
+ yy_endRead-yy_startRead);
+
+ /* translate stored positions */
+ yy_endRead-= yy_startRead;
+ yy_currentPos-= yy_startRead;
+ yy_markedPos-= yy_startRead;
+ yy_pushbackPos-= yy_startRead;
+ yy_startRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (yy_currentPos >= yy_buffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[yy_currentPos*2];
+ System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
+ yy_buffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = yy_reader.read(yy_buffer, yy_endRead,
+ yy_buffer.length-yy_endRead);
+
+ if ( numRead == -1 ) return YYEOF;
+
+ yy_endRead+= numRead;
+
+ return yy_buffer[yy_currentPos++];
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ final public void yyclose() throws java.io.IOException {
+ yy_atEOF = true; /* indicate end of file */
+ yy_endRead = yy_startRead; /* invalidate buffer */
+ yy_reader.close();
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ final public int yystate() {
+ return yy_lexical_state;
+ }
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ final public void yybegin(int newState) {
+ yy_lexical_state = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ final public String yytext() {
+ return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead );
+ }
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ final public int yylength() {
+ return yy_markedPos-yy_startRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void yy_ScanError(int errorCode) {
+ try {
+ System.out.println(YY_ERROR_MSG[errorCode]);
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
+ }
+
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ private void yypushback(int number) {
+ if ( number > yylength() )
+ yy_ScanError(YY_PUSHBACK_2BIG);
+
+ yy_markedPos -= number;
+ }
+
+
+ /**
+ * Contains user EOF-code, which will be executed exactly once,
+ * when the end of file is reached
+ */
+ private void yy_do_eof() {
+ if (!yy_eof_done) {
+ yy_eof_done = true;
+ hasMore=false;
+
+ }
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception IOException if any I/O-Error occurs
+ */
+ public String primGetNextToken() throws java.io.IOException {
+ int yy_input;
+ int yy_action;
+
+
+ while (true) {
+
+ yychar+= yylength();
+
+ yy_atBOL = yy_markedPos <= 0 || yy_buffer[yy_markedPos-1] == '\n';
+ if (!yy_atBOL && yy_buffer[yy_markedPos-1] == '\r') {
+ yy_atBOL = yy_advance() != '\n';
+ if (!yy_atEOF) yy_currentPos--;
+ }
+
+ yy_action = -1;
+
+ yy_currentPos = yy_startRead = yy_markedPos;
+
+ if (yy_atBOL)
+ yy_state = YY_LEXSTATE[yy_lexical_state+1];
+ else
+ yy_state = YY_LEXSTATE[yy_lexical_state];
+
+
+ yy_forAction: {
+ while (true) {
+
+ yy_input = yy_advance();
+
+ if ( yy_input == YYEOF ) break yy_forAction;
+
+ yy_input = yycmap[yy_input];
+
+ boolean yy_isFinal = false;
+ boolean yy_noLookAhead = false;
+
+ yy_forNext: { switch (yy_state) {
+ case 0:
+ switch (yy_input) {
+ case 1: yy_isFinal = true; yy_state = 9; break yy_forNext;
+ case 2: yy_isFinal = true; yy_state = 10; break yy_forNext;
+ case 3: yy_isFinal = true; yy_state = 11; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext;
+ }
+
+ case 1:
+ switch (yy_input) {
+ case 1: yy_isFinal = true; yy_state = 9; break yy_forNext;
+ case 2: yy_isFinal = true; yy_state = 10; break yy_forNext;
+ case 3: yy_isFinal = true; yy_state = 11; break yy_forNext;
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 12; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 13; break yy_forNext;
+ case 11: yy_isFinal = true; yy_state = 14; break yy_forNext;
+ case 16: yy_isFinal = true; yy_state = 15; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext;
+ }
+
+ case 2:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_state = 16; break yy_forNext;
+ case 12: yy_isFinal = true; yy_state = 17; break yy_forNext;
+ case 22: yy_isFinal = true; yy_state = 18; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext;
+ }
+
+ case 3:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 19; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 20; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 21; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 8; break yy_forNext;
+ }
+
+ case 4:
+ switch (yy_input) {
+ case 6:
+ case 7: yy_isFinal = true; yy_state = 23; break yy_forNext;
+ case 8: yy_isFinal = true; yy_state = 24; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 25; break yy_forNext;
+ case 31: yy_isFinal = true; yy_state = 26; break yy_forNext;
+ case 32: yy_isFinal = true; yy_state = 27; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext;
+ }
+
+ case 5:
+ switch (yy_input) {
+ case 7:
+ case 8:
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 30; break yy_forNext;
+ case 12:
+ case 33: yy_isFinal = true; yy_state = 31; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 31: yy_isFinal = true; yy_state = 33; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext;
+ }
+
+ case 6:
+ switch (yy_input) {
+ case 7:
+ case 8:
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 33: yy_isFinal = true; yy_state = 31; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 32: yy_isFinal = true; yy_state = 33; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 34; break yy_forNext;
+ case 34: yy_isFinal = true; yy_state = 35; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext;
+ }
+
+ case 7:
+ switch (yy_input) {
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 33: yy_isFinal = true; yy_state = 31; break yy_forNext;
+ case 12: yy_isFinal = true; yy_state = 35; break yy_forNext;
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 36; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 37; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 38; break yy_forNext;
+ case 31:
+ case 32: yy_isFinal = true; yy_state = 39; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 28; break yy_forNext;
+ }
+
+ case 9:
+ switch (yy_input) {
+ case 2: yy_isFinal = true; yy_noLookAhead = true; yy_state = 40; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 10:
+ switch (yy_input) {
+ case 1: yy_isFinal = true; yy_noLookAhead = true; yy_state = 41; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 11:
+ switch (yy_input) {
+ case 4: yy_state = 42; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 12:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 43; break yy_forNext;
+ case 9: yy_state = 44; break yy_forNext;
+ case 11: yy_state = 45; break yy_forNext;
+ case 16: yy_state = 46; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 13:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 43; break yy_forNext;
+ case 11: yy_state = 45; break yy_forNext;
+ case 16: yy_state = 46; break yy_forNext;
+ case 9: yy_state = 47; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 14:
+ switch (yy_input) {
+ case 9: yy_state = 48; break yy_forNext;
+ case 12: yy_state = 49; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 15:
+ switch (yy_input) {
+ case 9: yy_state = 50; break yy_forNext;
+ case 17: yy_state = 51; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 16:
+ switch (yy_input) {
+ case 12: yy_state = 52; break yy_forNext;
+ case 22: yy_state = 53; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 17:
+ switch (yy_input) {
+ case 9: yy_state = 54; break yy_forNext;
+ case 29: yy_isFinal = true; yy_state = 55; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 18:
+ switch (yy_input) {
+ case 9: yy_state = 56; break yy_forNext;
+ case 24: yy_state = 57; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 19:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 19; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 58; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 20:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 19; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 21; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 21:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 59; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 23:
+ switch (yy_input) {
+ case 6:
+ case 7: yy_isFinal = true; yy_state = 23; break yy_forNext;
+ case 8: yy_state = 60; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 61; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext;
+ }
+
+ case 24:
+ switch (yy_input) {
+ case 6:
+ case 7: yy_isFinal = true; yy_state = 23; break yy_forNext;
+ case 8: yy_state = 60; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 61; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext;
+ }
+
+ case 25:
+ switch (yy_input) {
+ case 31: yy_isFinal = true; yy_state = 26; break yy_forNext;
+ case 32: yy_isFinal = true; yy_state = 27; break yy_forNext;
+ case 6:
+ case 7:
+ case 8: yy_state = 60; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 26:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 62; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 27:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 63; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 29:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 64; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 30:
+ switch (yy_input) {
+ case 7:
+ case 8:
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 31: yy_isFinal = true; yy_state = 33; break yy_forNext;
+ case 12:
+ case 33: yy_state = 65; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 31:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 9: yy_state = 66; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 32:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 67; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 33:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 68; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 34:
+ switch (yy_input) {
+ case 7:
+ case 8:
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 32: yy_isFinal = true; yy_state = 33; break yy_forNext;
+ case 33: yy_state = 65; break yy_forNext;
+ case 34: yy_state = 69; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 35:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 9: yy_state = 70; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 36:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 71; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 37:
+ switch (yy_input) {
+ case 11:
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 36; break yy_forNext;
+ case 30: yy_isFinal = true; yy_state = 38; break yy_forNext;
+ case 31:
+ case 32: yy_isFinal = true; yy_state = 39; break yy_forNext;
+ case 33: yy_state = 65; break yy_forNext;
+ case 12: yy_state = 69; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 38:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 72; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 39:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 73; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 42:
+ switch (yy_input) {
+ case 5: yy_isFinal = true; yy_noLookAhead = true; yy_state = 74; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 43:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 43; break yy_forNext;
+ case 9: yy_state = 44; break yy_forNext;
+ case 11: yy_state = 45; break yy_forNext;
+ case 16: yy_state = 46; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 44:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 43; break yy_forNext;
+ case 11: yy_state = 45; break yy_forNext;
+ case 16: yy_state = 46; break yy_forNext;
+ case 9: yy_state = 47; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 45:
+ switch (yy_input) {
+ case 9: yy_state = 48; break yy_forNext;
+ case 12: yy_state = 49; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 46:
+ switch (yy_input) {
+ case 9: yy_state = 50; break yy_forNext;
+ case 17: yy_state = 51; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 47:
+ switch (yy_input) {
+ case 11: yy_state = 45; break yy_forNext;
+ case 16: yy_state = 46; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 48:
+ switch (yy_input) {
+ case 12: yy_state = 49; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 49:
+ switch (yy_input) {
+ case 9: yy_state = 75; break yy_forNext;
+ case 13: yy_state = 76; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 50:
+ switch (yy_input) {
+ case 17: yy_state = 51; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 51:
+ switch (yy_input) {
+ case 9: yy_state = 77; break yy_forNext;
+ case 18: yy_state = 78; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 52:
+ switch (yy_input) {
+ case 9: yy_state = 54; break yy_forNext;
+ case 29: yy_isFinal = true; yy_state = 55; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 53:
+ switch (yy_input) {
+ case 9: yy_state = 56; break yy_forNext;
+ case 24: yy_state = 57; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 54:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 55; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 55:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 79; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 56:
+ switch (yy_input) {
+ case 24: yy_state = 57; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 57:
+ switch (yy_input) {
+ case 9: yy_state = 80; break yy_forNext;
+ case 17: yy_state = 81; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 58:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 19; break yy_forNext;
+ case 9: yy_state = 82; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 60:
+ switch (yy_input) {
+ case 6:
+ case 7: yy_isFinal = true; yy_state = 23; break yy_forNext;
+ case 8: yy_state = 60; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 61; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext;
+ }
+
+ case 61:
+ switch (yy_input) {
+ case 6:
+ case 7: yy_isFinal = true; yy_state = 23; break yy_forNext;
+ case 8: yy_state = 60; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 83; break yy_forNext;
+ default: yy_isFinal = true; yy_noLookAhead = true; yy_state = 22; break yy_forNext;
+ }
+
+ case 65:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ case 9: yy_state = 66; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 66:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 32; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 69:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ case 9: yy_state = 70; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 70:
+ switch (yy_input) {
+ case 29: yy_isFinal = true; yy_state = 29; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 75:
+ switch (yy_input) {
+ case 13: yy_state = 76; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 76:
+ switch (yy_input) {
+ case 9: yy_state = 84; break yy_forNext;
+ case 14: yy_state = 85; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 77:
+ switch (yy_input) {
+ case 18: yy_state = 78; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 78:
+ switch (yy_input) {
+ case 9: yy_state = 86; break yy_forNext;
+ case 19: yy_state = 87; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 80:
+ switch (yy_input) {
+ case 17: yy_state = 81; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 81:
+ switch (yy_input) {
+ case 9: yy_state = 88; break yy_forNext;
+ case 25: yy_state = 89; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 82:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 19; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 83:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 60; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 84:
+ switch (yy_input) {
+ case 14: yy_state = 85; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 85:
+ switch (yy_input) {
+ case 9: yy_state = 90; break yy_forNext;
+ case 15: yy_state = 91; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 86:
+ switch (yy_input) {
+ case 19: yy_state = 87; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 87:
+ switch (yy_input) {
+ case 9: yy_state = 92; break yy_forNext;
+ case 20: yy_state = 93; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 88:
+ switch (yy_input) {
+ case 25: yy_state = 89; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 89:
+ switch (yy_input) {
+ case 9: yy_state = 94; break yy_forNext;
+ case 26: yy_state = 95; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 90:
+ switch (yy_input) {
+ case 15: yy_state = 91; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 91:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 96; break yy_forNext;
+ case 9: yy_state = 97; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 92:
+ switch (yy_input) {
+ case 20: yy_state = 93; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 93:
+ switch (yy_input) {
+ case 9: yy_state = 98; break yy_forNext;
+ case 21: yy_state = 99; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 94:
+ switch (yy_input) {
+ case 26: yy_state = 95; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 95:
+ switch (yy_input) {
+ case 9: yy_state = 100; break yy_forNext;
+ case 27: yy_state = 101; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 96:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 96; break yy_forNext;
+ case 9: yy_isFinal = true; yy_state = 102; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 97:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 96; break yy_forNext;
+ case 9: yy_state = 103; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 98:
+ switch (yy_input) {
+ case 21: yy_state = 99; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 99:
+ switch (yy_input) {
+ case 9: yy_state = 104; break yy_forNext;
+ case 22: yy_state = 105; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 100:
+ switch (yy_input) {
+ case 27: yy_state = 101; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 101:
+ switch (yy_input) {
+ case 9: yy_state = 106; break yy_forNext;
+ case 24: yy_state = 107; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 102:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 96; break yy_forNext;
+ case 9: yy_state = 103; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 103:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 96; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 104:
+ switch (yy_input) {
+ case 22: yy_state = 105; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 105:
+ switch (yy_input) {
+ case 9: yy_state = 108; break yy_forNext;
+ case 23: yy_isFinal = true; yy_state = 109; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 106:
+ switch (yy_input) {
+ case 24: yy_state = 107; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 107:
+ switch (yy_input) {
+ case 9: yy_state = 110; break yy_forNext;
+ case 28: yy_state = 111; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 108:
+ switch (yy_input) {
+ case 23: yy_isFinal = true; yy_state = 109; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 109:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_noLookAhead = true; yy_state = 112; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 110:
+ switch (yy_input) {
+ case 28: yy_state = 111; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 111:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 111; break yy_forNext;
+ case 9: yy_state = 113; break yy_forNext;
+ case 10: yy_isFinal = true; yy_state = 114; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 113:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 111; break yy_forNext;
+ case 10: yy_isFinal = true; yy_state = 114; break yy_forNext;
+ case 9: yy_state = 115; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 114:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 116; break yy_forNext;
+ case 9: yy_state = 117; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 115:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_state = 111; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 116:
+ switch (yy_input) {
+ case 9: yy_isFinal = true; yy_state = 114; break yy_forNext;
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 116; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ case 117:
+ switch (yy_input) {
+ case 6:
+ case 7:
+ case 8: yy_isFinal = true; yy_state = 116; break yy_forNext;
+ default: break yy_forAction;
+ }
+
+ default:
+ yy_ScanError(YY_ILLEGAL_STATE);
+ break;
+ } }
+
+ if ( yy_isFinal ) {
+ yy_action = yy_state;
+ yy_markedPos = yy_currentPos;
+ if ( yy_noLookAhead ) break yy_forAction;
+ }
+
+ }
+ }
+
+
+ switch (yy_action) {
+
+ case 29:
+ case 64:
+ { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue; }
+ case 119: break;
+ case 22:
+ case 23:
+ case 25:
+ case 61:
+ case 83:
+ { yypushback(yylength()); yybegin(UnDelimitedString); string.setLength(0); }
+ case 120: break;
+ case 21:
+ case 59:
+ { yybegin(YYINITIAL); hasMore = false; return CSSHeadTokenizerConstants.RuleEnd; }
+ case 121: break;
+ case 39:
+ case 73:
+ { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue; }
+ case 122: break;
+ case 109:
+ case 112:
+ { if (yychar == 0 ) {yybegin(CHARSET_RULE); return CSSHeadTokenizerConstants.CHARSET_RULE;} }
+ case 123: break;
+ case 96:
+ case 102:
+ { if (yychar == 0 ) {yybegin(ST_XMLDecl); return XMLHeadTokenizerConstants.XMLDeclStart;} }
+ case 124: break;
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 20:
+ case 24:
+ case 30:
+ case 34:
+ case 37:
+ { if(yychar > MAX_TO_SCAN) {hasMore=false; return EncodingParserConstants.MAX_CHARS_REACHED;} }
+ case 125: break;
+ case 55:
+ case 79:
+ { yybegin(YYINITIAL); return XMLHeadTokenizerConstants.XMLDeclEnd; }
+ case 126: break;
+ case 114:
+ case 116:
+ { pushCurrentState(); yybegin(QuotedAttributeValue); return XMLHeadTokenizerConstants.XMLDelEncoding; }
+ case 127: break;
+ case 3:
+ case 19:
+ case 58:
+ { pushCurrentState(); yybegin(QuotedAttributeValue); }
+ case 128: break;
+ case 40:
+ { hasMore = false; return EncodingParserConstants.UTF16BE; }
+ case 129: break;
+ case 41:
+ { hasMore = false; return EncodingParserConstants.UTF16LE; }
+ case 130: break;
+ case 74:
+ { hasMore = false; return EncodingParserConstants.UTF83ByteBOM; }
+ case 131: break;
+ case 28:
+ case 31:
+ case 35:
+ { string.append( yytext() ); }
+ case 132: break;
+ case 27:
+ case 63:
+ { yybegin(SQ_STRING); string.setLength(0); }
+ case 133: break;
+ case 26:
+ case 62:
+ { yybegin(DQ_STRING); string.setLength(0); }
+ case 134: break;
+ case 32:
+ case 67:
+ { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.InvalidTerminatedStringValue; }
+ case 135: break;
+ case 33:
+ case 68:
+ { popState(); valueText = string.toString(); return EncodingParserConstants.StringValue; }
+ case 136: break;
+ case 36:
+ case 71:
+ { yypushback(yylength());popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue; }
+ case 137: break;
+ case 38:
+ case 72:
+ { yypushback(yylength()); popState(); valueText = string.toString(); return EncodingParserConstants.UnDelimitedStringValue; }
+ case 138: break;
+ default:
+ if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
+ yy_atEOF = true;
+ yy_do_eof();
+ { hasMore = false; return EncodingParserConstants.EOF; }
+ }
+ else {
+ yy_ScanError(YY_NO_MATCH);
+ }
+ }
+ }
+ }
+
+ /**
+ * Runs the scanner on input files.
+ *
+ * This main method is the debugging routine for the scanner.
+ * It prints each returned token to System.out until the end of
+ * file is reached, or an error occured.
+ *
+ * @param argv the command line, contains the filenames to run
+ * the scanner on.
+ */
+ public static void main(String argv[]) {
+ for (int i = 0; i < argv.length; i++) {
+ CSSHeadTokenizer scanner = null;
+ try {
+ scanner = new CSSHeadTokenizer( new java.io.FileReader(argv[i]) );
+ }
+ catch (java.io.FileNotFoundException e) {
+ System.out.println("File not found : \""+argv[i]+"\"");
+ System.exit(1);
+ }
+ catch (java.io.IOException e) {
+ System.out.println("Error opening file \""+argv[i]+"\"");
+ System.exit(1);
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ System.out.println("Usage : java CSSHeadTokenizer <inputfile>");
+ System.exit(1);
+ }
+
+ try {
+ do {
+ System.out.println(scanner.primGetNextToken());
+ } while (!scanner.yy_atEOF);
+
+ }
+ catch (java.io.IOException e) {
+ System.out.println("An I/O error occured while scanning :");
+ System.out.println(e);
+ System.exit(1);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java
new file mode 100644
index 0000000..a991a03
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSHeadTokenizerConstants.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+
+public interface CSSHeadTokenizerConstants {
+
+ String RuleEnd = "RuleEnd"; //$NON-NLS-1$
+ String CHARSET_RULE = "CHARSET_RULE"; //$NON-NLS-1$
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java
new file mode 100644
index 0000000..16f5fbd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/CSSResourceEncodingDetector.java
@@ -0,0 +1,367 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
+import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
+import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
+import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
+import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants;
+
+
+
+public class CSSResourceEncodingDetector implements IResourceCharsetDetector {
+ class NullMemento extends EncodingMemento {
+ /**
+ *
+ */
+ public NullMemento() {
+ super();
+ String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null);
+ setJavaCharsetName(defaultCharset);
+ setAppropriateDefault(defaultCharset);
+ setDetectedCharsetName(null);
+ }
+ }
+
+
+ private CSSHeadTokenizer fTokenizer;
+ private EncodingMemento fEncodingMemento;
+ private boolean fHeaderParsed;
+ private Reader fReader;
+
+ /**
+ * There is no spec defined encoding for CSS, so Null is returned.
+ */
+ public String getSpecDefaultEncoding() {
+ // should match what's in plugin.xml (or look it up from there).
+ return null;
+ }
+
+ private boolean canHandleAsUnicodeStream(String tokenType) {
+ boolean canHandleAsUnicodeStream = false;
+ if (tokenType == EncodingParserConstants.UTF83ByteBOM) {
+ canHandleAsUnicodeStream = true;
+ String enc = "UTF-8"; //$NON-NLS-1$
+ createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
+ fEncodingMemento.setUTF83ByteBOMUsed(true);
+ }
+ else if (tokenType == EncodingParserConstants.UTF16BE || tokenType == EncodingParserConstants.UTF16LE) {
+ canHandleAsUnicodeStream = true;
+ String enc = "UTF-16"; //$NON-NLS-1$
+ byte[] bom = (tokenType == EncodingParserConstants.UTF16BE) ? IContentDescription.BOM_UTF_16BE : IContentDescription.BOM_UTF_16LE;
+ createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
+ fEncodingMemento.setUnicodeStream(true);
+ fEncodingMemento.setUnicodeBOM(bom);
+ }
+ return canHandleAsUnicodeStream;
+ }
+
+ /**
+ * @return Returns the tokenizer.
+ */
+ private CSSHeadTokenizer getTokenizer() {
+ if (fTokenizer == null) {
+ fTokenizer = new CSSHeadTokenizer();
+ }
+ return fTokenizer;
+ }
+
+ private boolean isLegalString(String valueTokenType) {
+ boolean result = false;
+ if (valueTokenType != null) {
+ result = valueTokenType.equals(EncodingParserConstants.StringValue) || valueTokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue);
+ }
+ return result;
+ }
+
+ private void parseInput() throws IOException {
+ checkInContents();
+ if (fEncodingMemento == null) {
+ checkHeuristics();
+ }
+ }
+
+ private void checkInContents() throws IOException {
+ CSSHeadTokenizer tokenizer = getTokenizer();
+ tokenizer.reset(fReader);
+ HeadParserToken token = null;
+ String tokenType = null;
+ do {
+ token = tokenizer.getNextToken();
+ tokenType = token.getType();
+ if (canHandleAsUnicodeStream(tokenType)) {
+ // side effect of canHandle is to create appropriate memento
+ }
+ else if (tokenType == CSSHeadTokenizerConstants.CHARSET_RULE) {
+ if (tokenizer.hasMoreTokens()) {
+ HeadParserToken valueToken = tokenizer.getNextToken();
+ String valueTokenType = valueToken.getType();
+ if (isLegalString(valueTokenType)) {
+ createEncodingMemento(valueToken.getText(), EncodingMemento.FOUND_ENCODING_IN_CONTENT);
+
+ }
+ }
+ }
+
+ }
+ while (tokenizer.hasMoreTokens());
+ }
+
+ /**
+ *
+ */
+ private void checkHeuristics() throws IOException {
+ boolean noHeuristic = false;
+ String heuristicEncoding = null;
+ try {
+ fReader.reset();
+ byte[] bytes = new byte[3];
+ int nRead = 0;
+ for (int i = 0; i < bytes.length; i++) {
+ if (fReader.ready()) {
+ int oneByte = fReader.read();
+ nRead++;
+ if (oneByte <= 0xFF) {
+ bytes[i] = (byte) oneByte;
+ }
+ else {
+ noHeuristic = true;
+ }
+ }
+ else {
+ noHeuristic = true;
+ break;
+ }
+ }
+ if (!noHeuristic && nRead == 3) {
+ heuristicEncoding = EncodingGuesser.guessEncoding(bytes, 3);
+ }
+ }
+ catch (IOException e) {
+ // if any IO exception, then not a heuristic case
+ }
+ finally {
+ fReader.reset();
+ }
+ if (heuristicEncoding != null) {
+ createEncodingMemento(heuristicEncoding, EncodingMemento.GUESSED_ENCODING_FROM_STREAM);
+ }
+
+ }
+
+ /**
+ * Note: once this instance is created, trace info still needs to be
+ * appended by caller, depending on the context its created.
+ */
+ private void createEncodingMemento(String detectedCharsetName) {
+ fEncodingMemento = new EncodingMemento();
+ fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName));
+ fEncodingMemento.setDetectedCharsetName(detectedCharsetName);
+ // TODO: if detectedCharset and spec default is
+ // null, need to use "work
+ // bench based" defaults.
+ fEncodingMemento.setAppropriateDefault(getSpecDefaultEncoding());
+ }
+
+ /**
+ * convience method all subclasses can use (but not override)
+ *
+ * @param detectedCharsetName
+ * @param reason
+ */
+ private void createEncodingMemento(String detectedCharsetName, String reason) {
+ createEncodingMemento(detectedCharsetName);
+ }
+
+ /**
+ * convience method all subclasses can use (but not override)
+ */
+ private final void ensureInputSet() {
+ if (fReader == null) {
+ throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This method can return null, if invalid charset name (in which case
+ * "appropriateDefault" should be used, if a name is really need for some
+ * "save anyway" cases).
+ *
+ * @param detectedCharsetName
+ * @return
+ */
+ private String getAppropriateJavaCharset(String detectedCharsetName) {
+ String result = null;
+ // 1. Check explicit mapping overrides from
+ // property file -- its here we pick up "rules" for cases
+ // that are not even in Java
+ result = CodedIO.checkMappingOverrides(detectedCharsetName);
+ // 2. Use the "canonical" name from JRE mappings
+ // Note: see Charset JavaDoc, the name you get one
+ // with can be alias,
+ // the name you get back is "standard" name.
+ Charset javaCharset = null;
+ try {
+ javaCharset = Charset.forName(detectedCharsetName);
+ }
+ catch (UnsupportedCharsetException e) {
+ // only set invalid, if result is same as detected -- they won't
+ // be equal if
+ // overridden
+ if (result != null && result.equals(detectedCharsetName)) {
+ fEncodingMemento.setInvalidEncoding(detectedCharsetName);
+ }
+ }
+ catch (IllegalCharsetNameException e) {
+ // only set invalid, if result is same as detected -- they won't
+ // be equal if
+ // overridden
+ if (result != null && result.equals(detectedCharsetName)) {
+ fEncodingMemento.setInvalidEncoding(detectedCharsetName);
+ }
+ }
+ // give priority to java cononical name, if present
+ if (javaCharset != null) {
+ result = javaCharset.name();
+ // but still allow overrides
+ result = CodedIO.checkMappingOverrides(result);
+ }
+ return result;
+ }
+
+ public String getEncoding() throws IOException {
+ return getEncodingMemento().getDetectedCharsetName();
+ }
+
+ public EncodingMemento getEncodingMemento() throws IOException {
+ ensureInputSet();
+ if (!fHeaderParsed) {
+ parseInput();
+ // we keep track of if header's already been
+ // parse, so can make
+ // multiple 'get' calls, without causing
+ // reparsing.
+ fHeaderParsed = true;
+ // Note: there is a "hidden assumption" here
+ // that an empty
+ // string in content should be treated same as
+ // not present.
+ }
+ if (fEncodingMemento == null) {
+ handleSpecDefault();
+ }
+ if (fEncodingMemento == null) {
+ // safty net
+ fEncodingMemento = new NullMemento();
+ }
+ return fEncodingMemento;
+ }
+
+ public EncodingMemento getSpecDefaultEncodingMemento() {
+ resetAll();
+ EncodingMemento result = null;
+ String enc = getSpecDefaultEncoding();
+ if (enc != null) {
+ createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT);
+ fEncodingMemento.setAppropriateDefault(enc);
+ result = fEncodingMemento;
+ }
+ return result;
+ }
+
+ private void handleSpecDefault() {
+ String encodingName;
+ encodingName = getSpecDefaultEncoding();
+ if (encodingName != null) {
+ // createEncodingMemento(encodingName,
+ // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
+ fEncodingMemento = new EncodingMemento();
+ fEncodingMemento.setJavaCharsetName(encodingName);
+ fEncodingMemento.setAppropriateDefault(encodingName);
+ }
+ }
+
+ /**
+ *
+ */
+ private void resetAll() {
+ fReader = null;
+ fHeaderParsed = false;
+ fEncodingMemento = null;
+ }
+
+ /**
+ *
+ */
+ public void set(InputStream inputStream) {
+ resetAll();
+ fReader = new ByteReader(inputStream);
+ try {
+ fReader.mark(CodedIO.MAX_MARK_SIZE);
+ }
+ catch (IOException e) {
+ // impossible, since we know ByteReader
+ // supports marking
+ throw new Error(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public void set(IStorage iStorage) throws CoreException {
+ resetAll();
+ InputStream inputStream = iStorage.getContents();
+ InputStream resettableStream = new BufferedInputStream(inputStream, CodedIO.MAX_BUF_SIZE);
+ resettableStream.mark(CodedIO.MAX_MARK_SIZE);
+ set(resettableStream);
+ // TODO we'll need to "remember" IFile, or
+ // get its (or its project's) settings, in case
+ // those are needed to handle cases when the
+ // encoding is not in the file stream.
+ }
+
+ /**
+ * Note: this is not part of interface to help avoid confusion ... it
+ * expected this Reader is a well formed character reader ... that is, its
+ * all ready been determined to not be a unicode marked input stream. And,
+ * its assumed to be in the correct position, at position zero, ready to
+ * read first character.
+ */
+ public void set(Reader reader) {
+ resetAll();
+ fReader = reader;
+ if (!fReader.markSupported()) {
+ fReader = new BufferedReader(fReader);
+ }
+ try {
+ fReader.mark(CodedIO.MAX_MARK_SIZE);
+ }
+ catch (IOException e) {
+ // impossble, since we just checked if markable
+ throw new Error(e);
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java
new file mode 100644
index 0000000..d04863d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/ContentDescriberForCSS.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentDescriber;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.ITextContentDescriber;
+import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
+import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended;
+import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector;
+
+
+public final class ContentDescriberForCSS implements ITextContentDescriber {
+ final private static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT};
+
+ public int describe(InputStream contents, IContentDescription description) throws IOException {
+ int result = IContentDescriber.INDETERMINATE;
+
+ if (description == null) {
+ result = computeValidity(contents);
+ }
+ else {
+ calculateSupportedOptions(contents, description);
+ result = computeValidity(contents);
+ }
+ return result;
+ }
+
+ public int describe(Reader contents, IContentDescription description) throws IOException {
+ int result = IContentDescriber.INDETERMINATE;
+
+ if (description == null) {
+ result = computeValidity(contents);
+ }
+ else {
+ calculateSupportedOptions(contents, description);
+ result = computeValidity(contents);
+ }
+ return result;
+ }
+
+ public QualifiedName[] getSupportedOptions() {
+
+ return SUPPORTED_OPTIONS;
+ }
+
+ private void calculateSupportedOptions(InputStream contents, IContentDescription description) throws IOException {
+ if (isRelevent(description)) {
+ IResourceCharsetDetector detector = getDetector();
+ detector.set(contents);
+ handleCalculations(description, detector);
+ }
+ }
+
+ /**
+ * @param contents
+ * @param description
+ * @throws IOException
+ */
+ private void calculateSupportedOptions(Reader contents, IContentDescription description) throws IOException {
+ if (isRelevent(description)) {
+ IResourceCharsetDetector detector = getDetector();
+ detector.set(contents);
+ handleCalculations(description, detector);
+ }
+ }
+
+ private int computeValidity(InputStream inputStream) {
+ // currently no specific check for validilty
+ // based on contents.
+ return IContentDescriber.INDETERMINATE;
+ }
+
+ private int computeValidity(Reader reader) {
+ // currently no specific check for validilty
+ // based on contents.
+ return IContentDescriber.INDETERMINATE;
+ }
+
+ private IResourceCharsetDetector getDetector() {
+ return new CSSResourceEncodingDetector();
+ }
+
+ /**
+ * @param description
+ * @param detector
+ * @throws IOException
+ */
+ private void handleCalculations(IContentDescription description, IResourceCharsetDetector detector) throws IOException {
+ // note: if we're asked for one, we set them all. I need to be sure if
+ // called
+ // mulitiple times (one for each, say) that we don't waste time
+ // processing same
+ // content again.
+ EncodingMemento encodingMemento = ((CSSResourceEncodingDetector) detector).getEncodingMemento();
+ // TODO: I need to verify to see if this BOM work is always done
+ // by text type.
+ Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
+ if (detectedByteOrderMark != null) {
+ Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
+ // not sure why would ever be different, so if is different, may
+ // need to "push" up into base.
+ if (!detectedByteOrderMark.equals(existingByteOrderMark))
+ description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
+ }
+
+
+ if (!encodingMemento.isValid()) {
+ // note: after setting here, its the mere presence of
+ // IContentDescriptionExtended.UNSUPPORTED_CHARSET
+ // in the resource's description that can be used to determine if
+ // invalid
+ // in those cases, the "detected" property contains an
+ // "appropriate default" to use.
+ description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
+ description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
+ }
+
+ Object detectedCharset = encodingMemento.getDetectedCharsetName();
+ Object javaCharset = encodingMemento.getJavaCharsetName();
+
+ // we always include detected, if its different than java
+ handleDetectedSpecialCase(description, detectedCharset, javaCharset);
+
+ if (javaCharset != null) {
+ Object existingCharset = description.getProperty(IContentDescription.CHARSET);
+ if (javaCharset.equals(existingCharset)) {
+ handleDetectedSpecialCase(description, detectedCharset, javaCharset);
+ }
+ else {
+ // we may need to add what we found, but only need to add
+ // if different from default.the
+ Object defaultCharset = getDetector().getSpecDefaultEncoding();
+ if (defaultCharset != null) {
+ if (!defaultCharset.equals(javaCharset)) {
+ description.setProperty(IContentDescription.CHARSET, javaCharset);
+ }
+ }
+ else {
+ // assuming if there is no spec default, we always need to
+ // add, I'm assuming
+ description.setProperty(IContentDescription.CHARSET, javaCharset);
+ }
+ }
+ }
+
+ }
+
+ private void handleDetectedSpecialCase(IContentDescription description, Object detectedCharset, Object javaCharset) {
+ // since equal, we don't need to add, but if our detected version is
+ // different than javaCharset, then we should add it. This will
+ // happen, for example, if there's differences in case, or differences
+ // due to override properties
+ if (detectedCharset != null) {
+
+ // Once we detected a charset, we should set the property even
+ // though it's the same as javaCharset
+ // because there are clients that rely on this property to
+ // determine if the charset is actually detected in file or not.
+ description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, detectedCharset);
+ }
+ }
+
+ /**
+ * @param description
+ * @return
+ */
+ private boolean isRelevent(IContentDescription description) {
+ boolean result = false;
+ if (description == null)
+ result = false;
+ else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK))
+ result = true;
+ else if (description.isRequested(IContentDescription.CHARSET))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.DETECTED_CHARSET))
+ result = true;
+ else if (description.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET))
+ result = true;
+ // else if
+ // (description.isRequested(IContentDescriptionExtended.ENCODING_MEMENTO))
+ // result = true;
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java
new file mode 100644
index 0000000..130800e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/EncodingGuesser.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+/**
+ *
+ * This is ported from PageDesigner's hpbcom/Kanji.cpp's
+ * Kanji::guess_kanji_code(),
+ *
+ */
+public class EncodingGuesser {
+ private static final int ASCII = 0; // ASCII
+ // ISO-2022-JP
+ private static final int ASCII_IN = 8; // This is after ISO2022's change
+ // Shift-JIS
+ private static final int EUC_HALFKANA = 6; // This is Half Kana in EUC-JP
+ private static final int EUC_JP = 3; // This is EUC-JP
+ private static final int ISO2022_JP = 4; // This is ISO-2022-JP
+ private static final int JIS_HALFKANA = 7; // THis is Half Kana in
+ private static final byte KT_EUC1 = 0x40;
+ private static final byte KT_EUC2 = (byte) 0x80;
+ // ASCII
+ private static final byte KT_JIN = 0x01;
+ private static final byte KT_JOUT = 0x02;
+ // private static final byte KT_ESC = 0x04;
+ // private static final byte KT_JIS = 0x08;
+ private static final byte KT_SFT1 = 0x10;
+ private static final byte KT_SFT2 = 0x20;
+ private static final byte ktype[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08, /* !"#$%&' *//* " */
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* ()*+,-./ */
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 01234567 */
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 89:; <=>? */
+ 0x29, 0x28, 0x2b, 0x28, 0x28, 0x28, 0x28, 0x28, /* @ABCDEFG */
+ 0x2a, 0x28, 0x2a, 0x28, 0x28, 0x28, 0x28, 0x28, /* HIJKLMNO */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* PQRSTUVW */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* XYZ[\]^_ */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* abcdefg */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* hijklmno */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, /* pqrstuvw */
+ 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x00, /* xyz{|}~ */
+ 0x20, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, /* 80 */
+ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, /* 90 */
+ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x20, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* A0 */
+ (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* B0 */
+ (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* C0 */
+ (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, /* D0 */
+ (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xe0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, /* E0 */
+ (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, /* F0 */
+ (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xf0, (byte) 0xc0, (byte) 0xc0, 0x00,};
+ // private static final int ISO8859_1 = 1; // ISO-1
+ private static final int SHIFT_JIS = 2; // This is Shift-JIS
+ private static final int SJIS_HALFKANA = 5; // This is Half Kana in
+
+ /**
+ * Currently, only Japanese encodings are supported.
+ */
+ private static final int UNKNOWN = -1; // Unknown
+
+ /**
+ * @return java.lang.String
+ * @param code
+ * int
+ *
+ * Convert private int to IANA Encoding name.
+ */
+ private static String convertToIANAEncodingName(int code) {
+ String encoding = null;
+
+ switch (code) {
+ case SHIFT_JIS :
+ case SJIS_HALFKANA :
+ encoding = "Shift_JIS";//$NON-NLS-1$
+ break;
+ case EUC_JP :
+ case EUC_HALFKANA :
+ encoding = "EUC-JP";//$NON-NLS-1$
+ break;
+ case ISO2022_JP :
+ case JIS_HALFKANA :
+ encoding = "ISO-2022-JP";//$NON-NLS-1$
+ default :
+ break;
+ }
+
+ return encoding;
+ }
+
+ /**
+ * Return guessed Java Encoding name target: bytes to be inspected length:
+ * length of target
+ */
+ public static String guessEncoding(byte[] target, int length) {
+ int code = UNKNOWN;
+
+ // Currently, only Japanese is supported.
+ String system_ctype = java.util.Locale.getDefault().getLanguage();
+ String jp_ctype = java.util.Locale.JAPANESE.getLanguage();
+ if (system_ctype.compareTo(jp_ctype) == 0) {
+ // Ok, I'm under ja_JP.
+ code = ASCII;
+ int pos = 0;
+ while ((code == ASCII) && (length > 0)) {
+ int ch1 = target[pos];
+ ch1 = ch1 & 0x000000FF;
+ int ch2 = (length >= 2) ? target[pos + 1] : 0;
+ ch2 = ch2 & 0x000000FF;
+ int ch3 = (length >= 3) ? target[pos + 2] : 0;
+ ch3 = ch3 & 0x000000FF;
+ code = guessJapaneseKanjiCode(ch1, ch2, ch3, 0);
+ pos++;
+ length--;
+ }
+ switch (code) {
+ case ISO2022_JP :
+ case JIS_HALFKANA :
+ code = ISO2022_JP;
+ break;
+ case EUC_JP :
+ code = EUC_JP;
+ break;
+ default :
+ code = SHIFT_JIS;
+ }
+ }
+ return (convertToIANAEncodingName(code));
+ }
+
+ /**
+ * Guess the encoding. halfkana_flag = 0x01 ( detect SJIS half kana )
+ * halfkana_flag = 0x02 ( detect EUC half kana )
+ */
+ private static int guessJapaneseKanjiCode(int ch1, int ch2, int ch3, int halfkana_flag) {
+ boolean sjis_hankaku_flag = ((halfkana_flag & 0x01) != 0) ? true : false;
+ boolean euc_hankaku_flag = ((halfkana_flag & 0x02) != 0) ? true : false;
+
+ if (ch1 == 0)
+ return UNKNOWN;
+ if (sjis_hankaku_flag && ch1 >= 0xa1 && ch1 <= 0xdf)
+ return SJIS_HALFKANA;
+ else if (euc_hankaku_flag && ch1 == 0x8e && ch2 >= 0xa1 && ch2 <= 0xdf)
+ return EUC_HALFKANA;
+ else if (((ktype[ch1] & KT_SFT1) != 0) && ((ktype[ch2] & KT_SFT2) != 0))
+ return SHIFT_JIS;
+ else if (((ktype[ch1] & KT_EUC1) != 0) && ((ktype[ch2] & KT_EUC2) != 0))
+ return EUC_JP;
+ else if (ch1 == 0x1b && ((ktype[ch2] & KT_JIN) != 0))
+ return ISO2022_JP;
+ else if (ch1 >= 0xa1 && ch1 <= 0xdf)
+ return SJIS_HALFKANA;
+ else if (ch1 == 0x1b && ch2 == 0x28/* '(' */&& ch3 == 0x49/* 'I' */)
+ return JIS_HALFKANA;
+ else if (ch1 == 0x1b && ch2 == 0x28/* '(' */&& ((ktype[ch3] & KT_JOUT) != 0))
+ return ASCII_IN;
+
+ return ASCII;
+ }
+
+ public EncodingGuesser() {
+ super();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java
new file mode 100644
index 0000000..51dc01c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/HeadParserToken.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+public class HeadParserToken {
+ private int fStart;
+
+ private String fText;
+ private String fType;
+
+ protected HeadParserToken() {
+ super();
+ }
+
+ public HeadParserToken(String type, int start, String text) {
+ this();
+ fType = type;
+ fStart = start;
+ fText = text;
+
+ }
+
+ public String getText() {
+ return fText;
+ }
+
+ public String getType() {
+ return fType;
+ }
+
+ public String toString() {
+ return ("text: " + fText + " offset: " + fStart + " type: " + fType); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java
new file mode 100644
index 0000000..f2830b9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/contenttype/IntStack.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.contenttype;
+
+/*
+ *
+ * A non-resizable class implementing the behavior of java.util.Stack, but
+ * directly for the <code> integer </code> primitive.
+ */
+import java.util.EmptyStackException;
+
+public class IntStack {
+ private int[] list = null;
+
+ private int size = 0;
+
+ public IntStack() {
+ this(100);
+ }
+
+ public IntStack(int maxdepth) {
+ super();
+ list = new int[maxdepth];
+ initialize();
+ }
+
+ public void clear() {
+ initialize();
+ }
+
+ public boolean empty() {
+ return size == 0;
+ }
+
+ public int get(int slot) {
+ return list[slot];
+ }
+
+ private void initialize() {
+ for (int i = 0; i < list.length; i++)
+ list[i] = -1;
+ }
+
+ /**
+ * Returns the int at the top of the stack without removing it
+ *
+ * @return int at the top of this stack.
+ * @exception EmptyStackException
+ * when empty.
+ */
+ public int peek() {
+ if (size == 0)
+ throw new EmptyStackException();
+ return list[size - 1];
+ }
+
+ /**
+ * Removes and returns the int at the top of the stack
+ *
+ * @return int at the top of this stack.
+ * @exception EmptyStackException
+ * when empty.
+ */
+ public int pop() {
+ int value = peek();
+ list[size - 1] = -1;
+ size--;
+ return value;
+ }
+
+ /**
+ * Pushes an item onto the top of this stack.
+ *
+ * @param newValue -
+ * the int to be pushed onto this stack.
+ * @return the <code>newValue</code> argument.
+ */
+ public int push(int newValue) {
+ if (size == list.length) {
+ throw new StackOverflowError();
+ }
+ list[size++] = newValue;
+ return newValue;
+ }
+
+ public int size() {
+ return size;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer s = new StringBuffer(getClass().getName() + ":" +size + " [");
+ for (int i = 0; i < size; i++) {
+ s.append(list[i]);
+ if(i < size - 1) {
+ s.append(", ");
+ }
+ }
+ s.append("]");
+ return s.toString();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java
new file mode 100644
index 0000000..007991b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/AbstractCSSNodeList.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+
+/**
+ *
+ */
+abstract class AbstractCSSNodeList {
+
+ protected Vector nodes = null;
+
+ ICSSNode appendNode(ICSSNode node) {
+ if (node == null)
+ return null;
+ if (this.nodes == null)
+ this.nodes = new Vector();
+ this.nodes.addElement(node);
+ return node;
+ }
+
+ /**
+ * @return int
+ */
+ public int getLength() {
+ if (this.nodes == null)
+ return 0;
+ return this.nodes.size();
+ }
+
+
+ protected ICSSNode itemImpl(int index) {
+ if (this.nodes == null)
+ return null;
+ if (index < 0 || index >= this.nodes.size())
+ return null;
+ return (ICSSNode) this.nodes.elementAt(index);
+ }
+
+
+ ICSSNode removeNode(int index) {
+ if (this.nodes == null)
+ return null; // no node
+ if (index < 0 || index >= this.nodes.size())
+ return null; // invalid parameter
+
+ ICSSNode removed = (ICSSNode) this.nodes.elementAt(index);
+ this.nodes.removeElementAt(index);
+ return removed;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java
new file mode 100644
index 0000000..9a04a4f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSAttrImpl.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+/**
+ *
+ */
+class CSSAttrImpl extends CSSRegionContainer implements ICSSAttr {
+
+ private String fName = null;
+ private String fValue = null;
+ private CSSNodeImpl ownerCSSNode = null;
+
+ CSSAttrImpl(CSSAttrImpl that) {
+ super(that);
+ this.fName = that.fName;
+ this.setValue(that.fValue);
+ }
+
+ /**
+ * CSSAttr constructor comment.
+ */
+ CSSAttrImpl(String name) {
+ super();
+ this.fName = name;
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ return new CSSAttrImpl(this);
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNamedNodeMap
+ */
+ public ICSSNamedNodeMap getAttributes() {
+ return null;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public java.lang.String getName() {
+ return fName;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return ATTR_NODE;
+ }
+
+ public ICSSNode getOwnerCSSNode() {
+ return ownerCSSNode;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public java.lang.String getValue() {
+ return fValue;
+ }
+
+ /**
+ * @return boolean
+ * @param name
+ * java.lang.String
+ */
+ protected boolean matchName(String name) {
+ if (name == null)
+ return /* (this.name == null) */false;
+ if (this.fName == null)
+ return false;
+ return this.fName.equals(name);
+ }
+
+ /**
+ *
+ */
+ protected void notifyValueChanged(String oldValue) {
+ if (this.ownerCSSNode == null)
+ return;
+
+ // for model
+ ICSSDocument doc = ownerCSSNode.getContainerDocument();
+ if (doc == null)
+ return;
+ CSSModelImpl model = (CSSModelImpl) doc.getModel();
+ if (model == null)
+ return;
+ model.valueChanged(this, oldValue);
+
+ // for adapters
+ String value = getValue();
+ this.ownerCSSNode.notify(CHANGE, this, oldValue, value, this.ownerCSSNode.getStartOffset());
+ }
+
+ /**
+ * @param newName
+ * java.lang.String
+ */
+ protected void setName(java.lang.String newName) {
+ fName = newName;
+ }
+
+ protected void setOwnerCSSNode(CSSNodeImpl newOwnerCSSNode) {
+ ownerCSSNode = newOwnerCSSNode;
+ }
+
+ /**
+ * @param newValue
+ * java.lang.String
+ */
+ public void setValue(java.lang.String newValue) {
+ String oldValue = fValue;
+ fValue = newValue;
+
+ notifyValueChanged(oldValue);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java
new file mode 100644
index 0000000..676c305
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSCharsetRuleImpl.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+
+
+/**
+ *
+ */
+class CSSCharsetRuleImpl extends CSSRuleImpl implements ICSSCharsetRule {
+
+ /**
+ *
+ */
+ CSSCharsetRuleImpl() {
+ super();
+ }
+
+ CSSCharsetRuleImpl(CSSCharsetRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSCharsetRuleImpl cloned = new CSSCharsetRuleImpl(this);
+
+ return cloned;
+ }
+
+ /**
+ * The encoding information used in this <code>@charset</code> rule.
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the specified encoding value has a
+ * syntax error and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this encoding
+ * rule is readonly.
+ */
+ public String getEncoding() {
+ return CSSUtil.extractStringContents(getAttribute(ENCODING));
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return CHARSETRULE_NODE;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return CHARSET_RULE;
+ }
+
+ public void setEncoding(String encoding) throws org.w3c.dom.DOMException {
+ String quote = CSSCorePlugin.getDefault().getPluginPreferences().getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ String enc = CSSUtil.extractStringContents(encoding);
+ quote = CSSUtil.detectQuote(enc, quote);
+ setAttribute(ENCODING, quote + enc + quote);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java
new file mode 100644
index 0000000..4e45041
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDeclarationItemParser.java
@@ -0,0 +1,1075 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICounter;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl;
+import org.w3c.dom.css.CSSPrimitiveValue;
+
+
+/**
+ *
+ */
+class CSSDeclarationItemParser {
+ /**
+ *
+ */
+ final class FloatInfo {
+ /**
+ *
+ */
+ FloatInfo(String text) {
+ parse(text);
+ }
+
+ /**
+ *
+ */
+ void parse(String text) {
+ StringBuffer bufValue = new StringBuffer();
+ StringBuffer bufIdent = new StringBuffer();
+ boolean bNum = true;
+ int len = text.length();
+ for (int i = 0; i < len; i++) {
+ char c = text.charAt(i);
+ if (bNum) {
+ // Only add +/- if it's the first character in the value buffer
+ if ('0' <= c && c <= '9' || c == '.' || ((c == '+' || c == '-') && i == 0)) {
+ bufValue.append(c);
+ }
+ else {
+ bufIdent.append(c);
+ bNum = false;
+ }
+ }
+ else {
+ bufIdent.append(c);
+ }
+ }
+ String valueStr = bufValue.toString();
+ try {
+ fValue = Float.valueOf(valueStr).floatValue();
+ }
+ catch (NumberFormatException e) {
+ bufIdent.insert(0, valueStr);
+ }
+ fIdentifier = bufIdent.toString();
+ fType = getFloatValueType(valueStr, fIdentifier);
+ }
+
+ /**
+ *
+ */
+ float getValue() {
+ return fValue;
+ }
+
+ /**
+ *
+ */
+ String getIdentifier() {
+ return fIdentifier;
+ }
+
+ /**
+ *
+ */
+ short getValueType() {
+ return fType;
+ }
+
+ private float fValue = 0.0f;
+ private String fIdentifier = null;
+ private short fType = CSSPrimitiveValue.CSS_UNKNOWN;
+ }
+
+ final static int S_NORMAL = 0;
+ final static int S_FUNCTION = 1;
+ final static int S_FONT_SLASH = 2;
+ final static int S_COMMA_SEPARATION = 3;
+ private ICSSDocument fDocument = null;
+ private IStructuredDocumentRegion fParentRegion = null;
+ private boolean fTempStructuredDocument = false;
+ private CSSModelUpdateContext fUpdateContext = null;
+
+ /**
+ * CSSDeclarationItemParser constructor comment.
+ */
+ CSSDeclarationItemParser(ICSSDocument doc) {
+ super();
+ fDocument = doc;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createAttrValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("attr")) { //$NON-NLS-1$
+ return null;
+ }
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ if (valueRegions.size() != 1) {
+ return null;
+ }
+
+ CSSPrimitiveValueImpl value = getCSSPrimitiveValue(CSSPrimitiveValue.CSS_ATTR);
+ if (value == null) {
+ return null;
+ }
+
+ ITextRegion region = valueRegions.get(0);
+ value.setValue(getText(region));
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createCountersValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("counters")) { //$NON-NLS-1$
+ return null;
+ }
+
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT, CSSRegionContexts.CSS_DECLARATION_VALUE_STRING};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ int size = valueRegions.size();
+ if (size != 2 && size != 3) {
+ return null;
+ }
+
+ CounterImpl value = getCounter();
+ if (value == null) {
+ return null;
+ }
+
+ for (int i = 0; i < size; i++) {
+ ITextRegion region = valueRegions.get(i);
+ String text = getText(region);
+ CSSAttrImpl attr = null;
+ switch (i) {
+ case 0 :
+ value.setIdentifier(text);
+ attr = value.getAttributeNode(ICounter.IDENTIFIER);
+ break;
+ case 1 :
+ value.setSeparator(text);
+ attr = value.getAttributeNode(ICounter.SEPARATOR);
+ break;
+ case 2 :
+ value.setListStyle(text);
+ attr = value.getAttributeNode(ICounter.LISTSTYLE);
+ break;
+ default :
+ break;
+ }
+ if (attr != null) {
+ attr.setRangeRegion(fParentRegion, region, region);
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createCounterValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("counter")) { //$NON-NLS-1$
+ return null;
+ }
+
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ int size = valueRegions.size();
+ if (size != 1 && size != 2) {
+ return null;
+ }
+
+ CounterImpl value = getCounter();
+ if (value == null) {
+ return null;
+ }
+
+ for (int i = 0; i < size; i++) {
+ ITextRegion region = valueRegions.get(i);
+ String text = getText(region);
+ CSSAttrImpl attr = null;
+ switch (i) {
+ case 0 :
+ value.setIdentifier(text);
+ attr = value.getAttributeNode(ICounter.IDENTIFIER);
+ break;
+ case 1 :
+ value.setListStyle(text);
+ attr = value.getAttributeNode(ICounter.LISTSTYLE);
+ break;
+ default :
+ break;
+ }
+ if (attr != null) {
+ attr.setRangeRegion(fParentRegion, region, region);
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSStyleDeclItemImpl createDeclarationItem(ITextRegionList nodeRegions) {
+ CSSStyleDeclItemImpl item = null;
+ String name = getPropertyName(nodeRegions);
+ if (name != null) {
+ item = getCSSStyleDeclItem(name);
+ }
+ return item;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createFloatValue(String text, String type) {
+ FloatInfo info = new FloatInfo(text);
+ CSSPrimitiveValueImpl value = getCSSPrimitiveValue(info.getValueType());
+ if (value != null) {
+ value.setValue(info.getValue());
+ }
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createFormatValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("format")) { //$NON-NLS-1$
+ return null;
+ }
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_STRING};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ // format can take variable args.
+ if (valueRegions.size() == 0) {
+ return null;
+ }
+
+ CSSPrimitiveValueImpl value = getCSSPrimitiveValue(ICSSPrimitiveValue.CSS_FORMAT);
+ if (value == null) {
+ return null;
+ }
+
+ ITextRegion region = valueRegions.get(0);
+ value.setValue(CSSUtil.extractStringContents(getText(region)));
+
+ return value;
+
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createLocalValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("local")) { //$NON-NLS-1$
+ return null;
+ }
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_STRING};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ if (valueRegions.size() != 1) {
+ return null;
+ }
+
+ CSSPrimitiveValueImpl value = getCSSPrimitiveValue(ICSSPrimitiveValue.CSS_LOCAL);
+ if (value == null) {
+ return null;
+ }
+
+ ITextRegion region = valueRegions.get(0);
+ value.setValue(CSSUtil.extractStringContents(getText(region)));
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createPrimitiveValue(ITextRegion region) {
+ if (region == null) {
+ return null;
+ }
+ CSSPrimitiveValueImpl value = null;
+ String type = region.getType();
+ String text = getText(region);
+ if (isBlank(type)) {
+ value = null;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION || type == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) {
+ value = createFloatValue(text, type);
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_STRING || type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI || type == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ value = createStringValue(text, type);
+ }
+
+ if (value == null) {
+ value = createStringValue(text, type);
+ }
+
+ if (!fTempStructuredDocument && value != null) {
+ value.setRangeRegion(fParentRegion, region, region);
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createPrimitiveValue(ITextRegionList regions) {
+ CSSPrimitiveValueImpl value = null;
+ CSSUtil.stripSurroundingSpace(regions);
+ if (regions.isEmpty()) {
+ return null;
+ }
+ ITextRegion region = regions.get(0);
+ if (region == null) {
+ return null;
+ }
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ String text = getText(region).toLowerCase();
+ if (text.equals("rgb(")) { //$NON-NLS-1$
+ value = createRgbValue(regions);
+ }
+ else if (text.equals("counter(")) { //$NON-NLS-1$
+ value = createCounterValue(regions);
+ }
+ else if (text.equals("counters(")) { //$NON-NLS-1$
+ value = createCountersValue(regions);
+ }
+ else if (text.equals("attr(")) { //$NON-NLS-1$
+ value = createAttrValue(regions);
+ }
+ else if (text.equals("format(")) { //$NON-NLS-1$
+ value = createFormatValue(regions);
+ }
+ else if (text.equals("local(")) { //$NON-NLS-1$
+ value = createLocalValue(regions);
+ }
+ else if (text.equals("rect(")) { //$NON-NLS-1$
+ value = createRectValue(regions);
+ }
+ if (value == null) {
+ value = createStringValue(regions);
+ }
+ }
+ else {
+ value = createStringValue(regions);
+ }
+
+ if (!fTempStructuredDocument && value != null) {
+ value.setRangeRegion(fParentRegion, regions.get(0), regions.get(regions.size() - 1));
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createRectValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("rect")) { //$NON-NLS-1$
+ return null;
+ }
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION, CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT}; // IDENT:
+ // for
+ // 'auto'
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ if (valueRegions.size() != 4) {
+ return null;
+ }
+
+ RectImpl value = getRect();
+ if (value == null) {
+ return null;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ ITextRegion region = valueRegions.get(i);
+ CSSPrimitiveValueImpl childValue = null;
+ switch (i) {
+ case 0 :
+ childValue = (CSSPrimitiveValueImpl) value.getTop();
+ break;
+ case 1 :
+ childValue = (CSSPrimitiveValueImpl) value.getRight();
+ break;
+ case 2 :
+ childValue = (CSSPrimitiveValueImpl) value.getBottom();
+ break;
+ case 3 :
+ childValue = (CSSPrimitiveValueImpl) value.getLeft();
+ break;
+ default :
+ break;
+ }
+ if (childValue == null) {
+ return null;
+ }
+ String text = getText(region);
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ setStringValue(childValue, text, type);
+ }
+ else {
+ setFloatValue(childValue, text, type);
+ }
+ if (!fTempStructuredDocument) {
+ childValue.setRangeRegion(fParentRegion, region, region);
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createRgbValue(ITextRegionList regions) {
+ String funcName = getFunctionName(regions);
+ if (funcName == null || !funcName.toLowerCase().equals("rgb")) { //$NON-NLS-1$
+ return null;
+ }
+ String accepts[] = {CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER, CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE};
+ ITextRegionList valueRegions = getFunctionParameters(regions, accepts);
+ if (valueRegions.size() != 3) {
+ return null;
+ }
+
+ RGBColorImpl value = getRGBColor();
+ if (value == null) {
+ return null;
+ }
+
+ for (int i = 0; i < 3; i++) {
+ ITextRegion region = valueRegions.get(i);
+ CSSPrimitiveValueImpl childValue = null;
+ switch (i) {
+ case 0 :
+ childValue = (CSSPrimitiveValueImpl) value.getRed();
+ break;
+ case 1 :
+ childValue = (CSSPrimitiveValueImpl) value.getGreen();
+ break;
+ case 2 :
+ childValue = (CSSPrimitiveValueImpl) value.getBlue();
+ break;
+ default :
+ break;
+ }
+ if (childValue == null) {
+ return null;
+ }
+ setFloatValue(childValue, getText(region), region.getType());
+ if (!fTempStructuredDocument) {
+ childValue.setRangeRegion(fParentRegion, region, region);
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createStringValue(String text, String type) {
+ short valueType = getStringValueType(text, type);
+ CSSPrimitiveValueImpl value = getCSSPrimitiveValue(valueType);
+ if (value != null) {
+ if (valueType == CSSPrimitiveValue.CSS_URI) {
+ text = CSSUtil.extractUriContents(text);
+ }
+ else if (valueType == CSSPrimitiveValue.CSS_STRING) {
+ text = CSSUtil.extractStringContents(text);
+ }
+ value.setValue(text);
+ }
+ return value;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl createStringValue(ITextRegionList regions) {
+ String type = CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT;
+ if (regions.size() == 1) {
+ ITextRegion region = regions.get(0);
+ type = region.getType();
+ }
+ return createStringValue(makeString(regions), type);
+ }
+
+ /**
+ *
+ */
+ private CounterImpl getCounter() {
+ CounterImpl node;
+ if (fUpdateContext != null && fUpdateContext.isActive()) {
+ node = fUpdateContext.getCounter();
+ }
+ else {
+ node = (CounterImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_COUNTER);
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ private CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) {
+ CSSPrimitiveValueImpl node;
+ if (fUpdateContext != null && fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSPrimitiveValue(type);
+ }
+ else {
+ node = (CSSPrimitiveValueImpl) fDocument.createCSSPrimitiveValue(type);
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ private CSSStyleDeclItemImpl getCSSStyleDeclItem(String propertyName) {
+ CSSStyleDeclItemImpl node;
+ if (fUpdateContext != null && fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSStyleDeclItem(propertyName);
+ }
+ else {
+ node = (CSSStyleDeclItemImpl) fDocument.createCSSStyleDeclItem(propertyName);
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ static short getFloatValueType(String ident) {
+ ident = ident.toLowerCase();
+ short valueType;
+ if (ident.length() == 0) {
+ valueType = CSSPrimitiveValue.CSS_NUMBER;
+ }
+ else if (ident.equals("%")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PERCENTAGE;
+ }
+ else if (ident.equalsIgnoreCase("em")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_EMS;
+ }
+ else if (ident.equalsIgnoreCase("ex")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_EXS;
+ }
+ else if (ident.equalsIgnoreCase("px")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PX;
+ }
+ else if (ident.equalsIgnoreCase("cm")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_CM;
+ }
+ else if (ident.equalsIgnoreCase("mm")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_MM;
+ }
+ else if (ident.equalsIgnoreCase("in")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_IN;
+ }
+ else if (ident.equalsIgnoreCase("pt")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PT;
+ }
+ else if (ident.equalsIgnoreCase("pc")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PC;
+ }
+ else if (ident.equalsIgnoreCase("deg")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_DEG;
+ }
+ else if (ident.equalsIgnoreCase("rad")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_RAD;
+ }
+ else if (ident.equalsIgnoreCase("grad")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_GRAD;
+ }
+ else if (ident.equalsIgnoreCase("ms")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_MS;
+ }
+ else if (ident.equalsIgnoreCase("s")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_S;
+ }
+ else if (ident.equalsIgnoreCase("hz")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_HZ;
+ }
+ else if (ident.equalsIgnoreCase("khz")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_KHZ;
+ }
+ else {
+ valueType = CSSPrimitiveValue.CSS_DIMENSION;
+ }
+ return valueType;
+ }
+
+ /**
+ *
+ */
+ static short getFloatValueType(String value, String ident) {
+ ident = ident.toLowerCase();
+ short valueType;
+ if (ident.length() == 0) {
+ if (0 <= value.indexOf('.')) {
+ valueType = CSSPrimitiveValue.CSS_NUMBER;
+ }
+ else {
+ valueType = ICSSPrimitiveValue.CSS_INTEGER;
+ }
+ }
+ else if (ident.equals("%")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PERCENTAGE;
+ }
+ else if (ident.equalsIgnoreCase("em")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_EMS;
+ }
+ else if (ident.equalsIgnoreCase("ex")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_EXS;
+ }
+ else if (ident.equalsIgnoreCase("px")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PX;
+ }
+ else if (ident.equalsIgnoreCase("cm")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_CM;
+ }
+ else if (ident.equalsIgnoreCase("mm")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_MM;
+ }
+ else if (ident.equalsIgnoreCase("in")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_IN;
+ }
+ else if (ident.equalsIgnoreCase("pt")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PT;
+ }
+ else if (ident.equalsIgnoreCase("pc")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_PC;
+ }
+ else if (ident.equalsIgnoreCase("deg")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_DEG;
+ }
+ else if (ident.equalsIgnoreCase("rad")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_RAD;
+ }
+ else if (ident.equalsIgnoreCase("grad")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_GRAD;
+ }
+ else if (ident.equalsIgnoreCase("ms")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_MS;
+ }
+ else if (ident.equalsIgnoreCase("s")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_S;
+ }
+ else if (ident.equalsIgnoreCase("hz")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_HZ;
+ }
+ else if (ident.equalsIgnoreCase("khz")) { //$NON-NLS-1$
+ valueType = CSSPrimitiveValue.CSS_KHZ;
+ }
+ else {
+ valueType = CSSPrimitiveValue.CSS_DIMENSION;
+ }
+ return valueType;
+ }
+
+ /**
+ *
+ */
+ private String getFunctionName(ITextRegionList regions) {
+ if (regions == null || regions.size() < 2) {
+ return null;
+ }
+ ITextRegion firstRegion = regions.get(0);
+ if (firstRegion.getType() != CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ return null;
+ }
+ ITextRegion lastRegion = regions.get(regions.size() - 1);
+ if (lastRegion.getType() != CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
+ return null;
+ }
+ String text = getText(firstRegion);
+ return text.substring(0, text.length() - 1);
+ }
+
+ /**
+ * this method has no validation check, then regions must be passed
+ * getFunctionName()...
+ */
+ private ITextRegionList getFunctionParameters(ITextRegionList regions, String[] accepts) {
+ ITextRegionList newRegions = new TextRegionListImpl();
+ int nAccepts = (accepts != null) ? accepts.length : 0;
+ Iterator i = regions.iterator();
+ i.next(); // skip FUNCTION
+ while (i.hasNext()) {
+ ITextRegion region = (ITextRegion) i.next();
+ if (region == null) {
+ continue;
+ }
+ String type = region.getType();
+ if (isBlank(type)) {
+ continue;
+ }
+ if (nAccepts == 0) {
+ newRegions.add(region);
+ }
+ else {
+ for (int iAccept = 0; iAccept < nAccepts; iAccept++) {
+ if (type == accepts[iAccept]) {
+ newRegions.add(region);
+ break;
+ }
+ }
+ }
+ }
+ return newRegions;
+ }
+
+ /**
+ *
+ */
+ // private String getPropertyName(IStructuredDocumentRegion flatNode) {
+ // Vector nodeRegions = new Vector(flatNode.getRegions());
+ // return getPropertyName(nodeRegions);
+ // }
+ /**
+ *
+ */
+ private String getPropertyName(ITextRegionList nodeRegions) {
+ ITextRegionList nameRegions = new TextRegionListImpl();
+ String name = null;
+ while (!nodeRegions.isEmpty()) {
+ ITextRegion region = nodeRegions.remove(0);
+ if (region == null) {
+ continue;
+ }
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ CSSUtil.stripSurroundingSpace(nameRegions);
+ name = makeString(nameRegions);
+ break;
+ }
+ else {
+ nameRegions.add(region);
+ }
+ }
+ return name;
+ }
+
+ /**
+ *
+ */
+ private RectImpl getRect() {
+ RectImpl node;
+ if (fUpdateContext != null && fUpdateContext.isActive()) {
+ node = fUpdateContext.getRect();
+ }
+ else {
+ node = (RectImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_RECT);
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ private RGBColorImpl getRGBColor() {
+ RGBColorImpl node;
+ if (fUpdateContext != null && fUpdateContext.isActive()) {
+ node = fUpdateContext.getRGBColor();
+ }
+ else {
+ node = (RGBColorImpl) fDocument.createCSSPrimitiveValue(CSSPrimitiveValue.CSS_RGBCOLOR);
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ private short getStringValueType(String text, String type) {
+ short valueType;
+ if (text.toLowerCase().equals("inherit")) { //$NON-NLS-1$
+ valueType = ICSSPrimitiveValue.CSS_INHERIT_PRIMITIVE;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ valueType = CSSPrimitiveValue.CSS_URI;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_STRING) {
+ valueType = CSSPrimitiveValue.CSS_STRING;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ valueType = ICSSPrimitiveValue.CSS_HASH;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && text.equals(",")) { //$NON-NLS-1$
+ valueType = ICSSPrimitiveValue.CSS_COMMA;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && text.equals("/")) { //$NON-NLS-1$
+ valueType = ICSSPrimitiveValue.CSS_SLASH;
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_UNICODE_RANGE) {
+ valueType = ICSSPrimitiveValue.CSS_URANGE;
+ }
+ else {
+ valueType = CSSPrimitiveValue.CSS_IDENT;
+ }
+ return valueType;
+ }
+
+ /**
+ *
+ */
+ private String makeString(ITextRegionList regions) {
+ StringBuffer buf = new StringBuffer();
+ boolean bSpace = false;
+ for (Iterator i = regions.iterator(); i.hasNext();) {
+ ITextRegion region = (ITextRegion) i.next();
+ String type = region.getType();
+ if (!bSpace && isBlank(type)) {
+ buf.append(" "); //$NON-NLS-1$
+ bSpace = true;
+ }
+ else {
+ // [274945] Multiple regions should have the spaces between collapsed
+ String text = i.hasNext() ? getCollapsedText(region) : getText(region);
+ buf.append(text);
+ bSpace = false;
+ }
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ *
+ */
+ void setStructuredDocumentTemporary(boolean bTemp) {
+ fTempStructuredDocument = bTemp;
+ }
+
+ /**
+ *
+ */
+ private void setFloatValue(CSSPrimitiveValueImpl value, String text, String type) {
+ FloatInfo info = new FloatInfo(text);
+ value.setFloatValue(info.getValueType(), info.getValue());
+ }
+
+ /**
+ *
+ */
+ private void setStringValue(CSSPrimitiveValueImpl value, String text, String type) {
+ short valueType = getStringValueType(text, type);
+ value.setStringValue(valueType, text);
+ }
+
+
+ /**
+ *
+ */
+ void setUpdateContext(CSSModelUpdateContext updateContext) {
+ fUpdateContext = updateContext;
+ }
+
+ /**
+ *
+ */
+ public static boolean hasColonSeparator(IStructuredDocumentRegion flatNode) {
+ if (flatNode == null) {
+ return false;
+ }
+ ITextRegionList regions = flatNode.getRegions();
+ if (regions == null || regions.size() == 0) {
+ return false;
+ }
+
+ for (Iterator i = regions.iterator(); i.hasNext();) {
+ ITextRegion region = (ITextRegion) i.next();
+ if (region == null) {
+ continue;
+ }
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ CSSStyleDeclItemImpl setupDeclarationItem(IStructuredDocumentRegion flatNode) {
+ if (flatNode == null) {
+ return null;
+ }
+ if (!hasColonSeparator(flatNode)) {
+ return null;
+ }
+
+ fParentRegion = flatNode;
+
+ ITextRegionList nodeRegions = new TextRegionListImpl(flatNode.getRegions()); // make
+ // copy
+ CSSStyleDeclItemImpl newItem = createDeclarationItem(nodeRegions);
+ if (newItem == null) {
+ return null;
+ }
+ if (!fTempStructuredDocument && flatNode != null) {
+ newItem.setRangeStructuredDocumentRegion(flatNode, flatNode);
+ }
+
+ CSSUtil.stripSurroundingSpace(nodeRegions);
+ // Now, nodeRegions just has regions for value.
+ setupValues(newItem, nodeRegions);
+ return newItem;
+ }
+
+ void setupValues(ICSSStyleDeclItem item, IStructuredDocumentRegion parentRegion, ITextRegionList nodeRegions) {
+ fParentRegion = parentRegion;
+ setupValues(item, nodeRegions);
+ }
+
+ /**
+ * nodeRegions must be broken. If you need after, make copy of them.
+ */
+ private void setupValues(ICSSStyleDeclItem item, ITextRegionList nodeRegions) {
+ if (item == null) {
+ return;
+ }
+
+ ICSSPrimitiveValue value;
+ ITextRegionList regionBuf = new TextRegionListImpl();
+
+ String propertyName = item.getPropertyName().toLowerCase();
+ boolean bFont = (propertyName.equals(PropCMProperty.P_FONT));
+ // (short-hand) font
+ int status = (propertyName.equals(PropCMProperty.P_VOICE_FAMILY) || propertyName.equals(PropCMProperty.P_FONT_FAMILY)) ? S_COMMA_SEPARATION : S_NORMAL;
+ while (!nodeRegions.isEmpty()) {
+ value = null;
+ ITextRegion region = nodeRegions.remove(0);
+ if (region == null) {
+ continue;
+ }
+ String type = region.getType();
+ // if (type == CSSRegionContexts.CSS_DECLARATION_DELIMITER || type
+ // == CSSRegionContexts.CSS_RBRACE) {
+ // break;
+ // }
+ switch (status) {
+ case S_NORMAL :
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ regionBuf.add(region);
+ status = S_FUNCTION;
+ }
+ else if (bFont && type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && fParentRegion.getText(region).equals("/")) { //$NON-NLS-1$
+ value = createPrimitiveValue(region);
+ status = S_FONT_SLASH;
+ }
+ else if (!isBlank(type)) {
+ value = createPrimitiveValue(region);
+ }
+ break;
+ case S_FUNCTION :
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
+ regionBuf.add(region);
+ value = createPrimitiveValue(regionBuf);
+ regionBuf.clear();
+ status = S_NORMAL;
+ }
+ else if (!isBlank(type)) {
+ regionBuf.add(region);
+ }
+ break;
+ case S_FONT_SLASH :
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION) {
+ value = createPrimitiveValue(region);
+ status = S_COMMA_SEPARATION;
+ }
+ else if (!isBlank(type)) {
+ value = createPrimitiveValue(region);
+ }
+ break;
+ case S_COMMA_SEPARATION :
+ if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && fParentRegion.getText(region).equals(",")) { //$NON-NLS-1$
+ value = createPrimitiveValue(regionBuf);
+ regionBuf.clear();
+ if (value != null) {
+ if (fUpdateContext == null || !fUpdateContext.isActive()) {
+ item.appendValue(value);
+ }
+ }
+ value = createPrimitiveValue(region);
+ }
+ else {
+ regionBuf.add(region);
+ }
+ break;
+ default :
+ break;
+ }
+ if (value != null) {
+ if (fUpdateContext == null || !fUpdateContext.isActive()) {
+ item.appendValue(value);
+ }
+ }
+ }
+ if (!regionBuf.isEmpty()) {
+ value = createPrimitiveValue(regionBuf);
+ if (fUpdateContext == null || !fUpdateContext.isActive()) {
+ item.appendValue(value);
+ }
+ }
+ }
+
+ private String getCollapsedText(ITextRegion region) {
+ if (fParentRegion == null)
+ return ""; //$NON-NLS-1$
+ StringBuffer text = new StringBuffer(fParentRegion.getFullText(region));
+ if (region.getLength() > region.getTextLength())
+ text.replace(region.getTextLength(), region.getLength(), " "); //$NON-NLS-1$
+ return text.toString();
+ }
+
+ private String getText(ITextRegion region) {
+ return (fParentRegion != null) ? fParentRegion.getText(region) : ""; //$NON-NLS-1$
+ }
+
+ private static boolean isBlank(String type) {
+ return (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_S);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java
new file mode 100644
index 0000000..e3a543b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSDocumentImpl.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.w3c.dom.css.CSSFontFaceRule;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSUnknownRule;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ *
+ */
+abstract class CSSDocumentImpl extends CSSStructuredDocumentRegionContainer implements ICSSDocument {
+
+ private CSSModelImpl fModel = null;
+
+ /**
+ * CSSDocumentImpl constructor comment.
+ */
+ CSSDocumentImpl() {
+ super();
+ }
+
+
+ CSSDocumentImpl(CSSDocumentImpl that) {
+ super(that);
+ }
+
+ ICSSNode createCSSAttr(String name) {
+ CSSAttrImpl attr = new CSSAttrImpl(name);
+ attr.setOwnerDocument(this);
+
+ return attr;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSCharsetRule
+ */
+ public ICSSCharsetRule createCSSCharsetRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSFontFaceRule
+ */
+ public CSSFontFaceRule createCSSFontFaceRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSImportRule
+ */
+ public ICSSImportRule createCSSImportRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.ICSSMediaRule
+ */
+ public ICSSMediaRule createCSSMediaRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPageRule
+ */
+ public ICSSPageRule createCSSPageRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ */
+ public ICSSPrimitiveValue createCSSPrimitiveValue(short primitiveType) {
+ CSSPrimitiveValueImpl value = null;
+ if (primitiveType == CSSPrimitiveValue.CSS_COUNTER)
+ value = new CounterImpl();
+ else if (primitiveType == CSSPrimitiveValue.CSS_RECT)
+ value = new RectImpl();
+ else if (primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR)
+ value = new RGBColorImpl();
+ else
+ value = new CSSPrimitiveValueImpl(primitiveType);
+ value.setOwnerDocument(this);
+
+ return value;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * java.lang.String
+ */
+ public CSSRule createCSSRule(String rule) {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleDeclaration
+ */
+ public ICSSStyleDeclaration createCSSStyleDeclaration() {
+ return null;
+ }
+
+ public ICSSStyleDeclItem createCSSStyleDeclItem(String propertyName) {
+ CSSStyleDeclItemImpl item = new CSSStyleDeclItemImpl(propertyName);
+ item.setOwnerDocument(this);
+
+ return item;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleRule
+ */
+ public ICSSStyleRule createCSSStyleRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSUnknownRule
+ */
+ public CSSUnknownRule createCSSUnknownRule() {
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.stylesheets.MediaList
+ */
+ public MediaList createMediaList() {
+ return null;
+ }
+
+ public ICSSModel getModel() {
+ return fModel;
+ }
+
+ void setModel(CSSModelImpl model) {
+ this.fModel = model;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java
new file mode 100644
index 0000000..10cd9f7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSFontFaceRuleImpl.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSFontFaceRule;
+
+
+/**
+ *
+ */
+class CSSFontFaceRuleImpl extends CSSRuleDeclContainer implements CSSFontFaceRule {
+
+ /**
+ *
+ */
+ CSSFontFaceRuleImpl() {
+ super();
+ }
+
+ CSSFontFaceRuleImpl(CSSFontFaceRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSFontFaceRuleImpl cloned = new CSSFontFaceRuleImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ String extractPreString() {
+ return "@font-face";//$NON-NLS-1$
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return FONTFACERULE_NODE;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return FONT_FACE_RULE;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java
new file mode 100644
index 0000000..4fa385b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSImportRuleImpl.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.internal.util.CSSLinkConverter;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.URLModelProviderCSS;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSStyleSheet;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ * currently public but may be made default access protected in future.
+ */
+public class CSSImportRuleImpl extends CSSRuleImpl implements ICSSImportRule {
+
+ private boolean fDirty = true;
+ private ICSSStyleSheet fStyleSheet;
+
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSImportRuleImpl() {
+ super();
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSImportRuleImpl(CSSImportRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSImportRuleImpl cloned = new CSSImportRuleImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ *
+ */
+ void closeStyleSheet() {
+ if (fStyleSheet != null) {
+ ICSSStyleSheet sheet = fStyleSheet;
+ fStyleSheet = null; // to prevent loop, we must reset fStyleSheet
+ // before all closing action
+
+ sheet.getModel().removeStyleListener(getOwnerDocument().getModel());
+ // get ModelProvideAdapter
+ IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
+ // if (getOwnerDocument().getModel().getStyleSheetType() ==
+ // ICSSModel.EMBEDDED) { // case STYLE tag
+ // adapter = (ModelProvideAdapter)
+ // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class);
+ // }
+ if (adapter != null)
+ adapter.modelRemoved(sheet.getModel());
+
+ sheet.getModel().releaseFromRead();
+ }
+ }
+
+ /**
+ * The location of the style sheet to be imported. The attribute will not
+ * contain the <code>"url(...)"</code> specifier around the URI.
+ */
+ public String getHref() {
+ return CSSUtil.extractUriContents(getAttribute(HREF));
+ }
+
+ /**
+ * A list of media types for which this style sheet may be used.
+ */
+ public org.w3c.dom.stylesheets.MediaList getMedia() {
+ ICSSNode media = getFirstChild();
+ if (media != null) {
+ if (media instanceof MediaList) {
+ return (MediaList) media;
+ }
+ }
+
+ // THIS CASE IS ERROR CASE
+ return null;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return IMPORTRULE_NODE;
+ }
+
+ /**
+ * The style sheet referred to by this rule, if it has been loaded. The
+ * value of this attribute is <code>null</code> if the style sheet has
+ * not yet been loaded or if it will not be loaded (e.g. if the style
+ * sheet is for a media type not supported by the user agent).
+ */
+ public CSSStyleSheet getStyleSheet() {
+
+ if (fDirty) {
+ // NOTE: try/catch block is a TEMP fix to avoid compile errors:
+ try {
+ closeStyleSheet();
+
+ if (getHref() == null || getHref().length() <= 0) {
+ fDirty = false;
+ return null;
+ }
+
+ IStructuredModel baseModel = getOwnerDocument().getModel();
+ if (getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) { // case
+ // STYLE
+ // tag
+ baseModel = ((IDOMNode) getOwnerDocument().getModel().getOwnerDOMNode()).getModel();
+ }
+ // get ModelProvideAdapter
+ IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
+ // if (getOwnerDocument().getModel().getStyleSheetType() ==
+ // ICSSModel.EMBEDDED) { // case STYLE tag
+ // adapter = (ModelProvideAdapter)
+ // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class);
+ // }
+
+ // load model from IModelManager
+ URLModelProviderCSS provider = new URLModelProviderCSS();
+ IStructuredModel newModel = provider.getModelForRead(baseModel, getHref());
+ fDirty = false;
+
+ if (newModel == null)
+ return null;
+ if (!(newModel instanceof ICSSModel)) {
+ newModel.releaseFromRead();
+ return null;
+ }
+
+ // notify adapter
+ if (adapter != null)
+ adapter.modelProvided(newModel);
+
+ fStyleSheet = (ICSSStyleSheet) ((ICSSModel) newModel).getDocument();
+ if (fStyleSheet != null)
+ fStyleSheet.getModel().addStyleListener(getOwnerDocument().getModel());
+ }
+ catch (java.io.IOException e) {
+ Logger.logException(e);
+ }
+ }
+ return fStyleSheet;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return IMPORT_RULE;
+ }
+
+ /**
+ *
+ */
+ public void refreshStyleSheet() {
+ if (!fDirty) {
+ closeStyleSheet();
+ fDirty = true;
+ notify(INodeNotifier.CHANGE, getAttributeNode(HREF), null, null, getStartOffset());
+ }
+ }
+
+ /**
+ */
+ void releaseRule() {
+ if (fStyleSheet != null) {
+ ICSSStyleSheet sheet = fStyleSheet;
+ fStyleSheet = null; // to prevent loop, we must reset fStyleSheet
+ // before all closing action
+
+ sheet.getModel().removeStyleListener(getOwnerDocument().getModel());
+ // get ModelProvideAdapter
+ IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
+ // if (getOwnerDocument().getModel().getStyleSheetType() ==
+ // ICSSModel.EMBEDDED) { // case STYLE tag
+ // adapter = (ModelProvideAdapter)
+ // ((INodeNotifier)getOwnerDocument().getModel().getOwnerDOMNode()).getAdapterFor(ModelProvideAdapter.class);
+ // }
+ if (adapter != null)
+ adapter.modelReleased(sheet.getModel());
+
+ sheet.getModel().releaseFromRead();
+ }
+ }
+
+ /**
+ * @param href
+ * java.lang.String
+ */
+ public void setHref(String href) throws DOMException {
+ fDirty = true;
+ setAttribute(HREF, CSSLinkConverter.addFunc(href));
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java
new file mode 100644
index 0000000..0175c87
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSMediaRuleImpl.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ *
+ */
+class CSSMediaRuleImpl extends CSSRuleImpl implements ICSSMediaRule {
+
+ /**
+ *
+ */
+ CSSMediaRuleImpl() {
+ super();
+ }
+
+ CSSMediaRuleImpl(CSSMediaRuleImpl that) {
+ super(that);
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule appendRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException {
+ if (rule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) appendChild((CSSNodeImpl) rule);
+ return ret;
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSMediaRuleImpl cloned = new CSSMediaRuleImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * Used to delete a rule from the media block.
+ *
+ * @param index
+ * The index within the media block's rule collection of the
+ * rule to remove.
+ * @exception DOMException
+ * INDEX_SIZE_ERR: Raised if the specified index does not
+ * correspond to a rule in the media rule list. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule
+ * is readonly.
+ */
+ public void deleteRule(int index) throws DOMException {
+ CSSNodeImpl node = getIndexedRule(index);
+ if (node != null)
+ removeChild(node);
+ }
+
+ /**
+ * A list of all CSS rules contained within the media block.
+ */
+ public CSSRuleList getCssRules() {
+ CSSRuleListImpl list = new CSSRuleListImpl();
+
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSRule)
+ list.appendNode(node);
+ }
+
+ return list;
+ }
+
+ CSSRuleImpl getIndexedRule(int index) {
+ if (index < 0)
+ return null;
+
+ int i = 0;
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSRule) {
+ if (i++ == index)
+ return (CSSRuleImpl) node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * A list of media types for this rule.
+ */
+ public MediaList getMedia() {
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof MediaListImpl)
+ return (MediaList) node;
+ }
+
+ return null;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return MEDIARULE_NODE;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return MEDIA_RULE;
+ }
+
+ /**
+ * Used to insert a new rule into the media block.
+ *
+ * @param rule
+ * The parsable text representing the rule. For rule sets this
+ * contains both the selector and the style declaration. For
+ * at-rules, this specifies both the at-identifier and the rule
+ * content.
+ * @param index
+ * The index within the media block's rule collection of the
+ * rule before which to insert the specified rule. If the
+ * specified index is equal to the length of the media blocks's
+ * rule collection, the rule will be added to the end of the
+ * media block.
+ * @return The index within the media block's rule collection of the newly
+ * inserted rule.
+ * @exception DOMException
+ * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be
+ * inserted at the specified index, e.g., if an
+ * <code>@import</code> rule is inserted after a standard rule set or other
+ * at-rule. <br>
+ * INDEX_SIZE_ERR: Raised if the specified index is not a valid
+ * insertion point. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is
+ * readonly. <br>
+ * SYNTAX_ERR: Raised if the specified rule has a syntax error and
+ * is unparsable.
+ */
+ public int insertRule(String rule, int index) throws DOMException {
+ int length = getCssRules().getLength();
+ if (index < 0 || length < index)
+ throw new DOMException(DOMException.INDEX_SIZE_ERR, "");//$NON-NLS-1$
+
+ CSSRuleImpl refRule = (length != index) ? getIndexedRule(index) : null;
+
+ CSSRuleImpl newRule = (CSSRuleImpl) getOwnerDocument().createCSSRule(rule);
+
+ // prevent from nesting @media rule
+ if (newRule.getType() == CSSRule.MEDIA_RULE)
+ throw new DOMException(DOMException.SYNTAX_ERR, "");//$NON-NLS-1$
+
+ insertBefore(newRule, refRule);
+
+ return index;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newRule
+ * org.w3c.dom.css.CSSRule
+ * @param refRule
+ * org.w3c.dom.css.CSSRule
+ */
+ public org.w3c.dom.css.CSSRule insertRuleBefore(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule refRule) throws org.w3c.dom.DOMException {
+ if (newRule == null && refRule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) insertBefore((CSSNodeImpl) newRule, (CSSNodeImpl) refRule);
+ return ret;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule removeRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException {
+ if (rule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) removeChild((CSSNodeImpl) rule);
+ return ret;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newChild
+ * org.w3c.dom.css.CSSRule
+ * @param oldChild
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule replaceRule(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule oldRule) throws org.w3c.dom.DOMException {
+ if (newRule == null && oldRule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) replaceChild((CSSNodeImpl) newRule, (CSSNodeImpl) oldRule);
+ return ret;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java
new file mode 100644
index 0000000..8494a09
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelCreationContext.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+
+
+/**
+ * currently public but may be made default access protected in future.
+ */
+public class CSSModelCreationContext {
+
+ private CSSNodeImpl fRootNode = null;
+ private CSSNodeImpl fTargetNode = null;
+ private CSSNodeImpl fNextNode = null;
+ private int fReparseStart = -1;
+ private int fReparseEnd = -1;
+
+ /**
+ * CSSModelContext constructor comment.
+ */
+ CSSModelCreationContext(CSSNodeImpl rootNode) {
+ super();
+
+ fRootNode = rootNode;
+ }
+
+ /**
+ *
+ */
+ void clear() {
+ fNextNode = null;
+ fTargetNode = null;
+ resetReparseRange();
+ }
+
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSNodeImpl getNextNode() {
+ return fNextNode;
+ }
+
+ /**
+ *
+ */
+ int getReparseEnd() {
+ return fReparseEnd;
+ }
+
+ /**
+ *
+ */
+ int getReparseStart() {
+ return fReparseStart;
+ }
+
+ /**
+ *
+ */
+ CSSNodeImpl getRootNode() {
+ return fRootNode;
+ }
+
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSNodeImpl getTargetNode() {
+ return fTargetNode;
+ }
+
+ /**
+ *
+ */
+ boolean isToReparse() {
+ return (0 <= getReparseStart() && 0 <= getReparseEnd());
+ }
+
+ /**
+ *
+ */
+ void resetReparseRange() {
+ fReparseStart = fReparseEnd = -1;
+ }
+
+ /**
+ *
+ */
+ void setLast() {
+ fNextNode = null;
+
+ if (!(fRootNode instanceof CSSStructuredDocumentRegionContainer)) {
+ fTargetNode = fRootNode;
+ }
+ else {
+ IStructuredDocumentRegion lastStructuredDocumentRegion = ((CSSStructuredDocumentRegionContainer) fRootNode).getLastStructuredDocumentRegion();
+ CSSNodeImpl node = fRootNode;
+ while (node != null) {
+ ICSSNode lastChild = node.getLastChild();
+ if (lastChild instanceof CSSStructuredDocumentRegionContainer && ((CSSStructuredDocumentRegionContainer) lastChild).getLastStructuredDocumentRegion() == lastStructuredDocumentRegion) {
+ node = (CSSNodeImpl) lastChild;
+ }
+ else {
+ break;
+ }
+ }
+ fTargetNode = node;
+ }
+ }
+
+ /**
+ *
+ */
+ void setNextNode(ICSSNode node) {
+ fNextNode = (CSSNodeImpl) node;
+ if (fNextNode != null) {
+ fTargetNode = (CSSNodeImpl) fNextNode.getParentNode();
+ }
+ }
+
+ /**
+ *
+ */
+ void setReparseEnd(int end) {
+ fReparseEnd = end;
+ }
+
+ /**
+ *
+ */
+ void setReparseStart(int start) {
+ fReparseStart = start;
+ }
+
+ /**
+ *
+ */
+ void setTargetNode(ICSSNode node) {
+ fTargetNode = (CSSNodeImpl) node;
+ if (fNextNode != null && fNextNode.getParentNode() != fTargetNode) {
+ fNextNode = null;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java
new file mode 100644
index 0000000..5858bec
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelDeletionContext.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+
+
+/**
+ *
+ */
+class CSSModelDeletionContext {
+
+ private int fOldStart = -1;
+ private int fOldLength = 0;
+ private int fNewStart = -1;
+ private int fNewLength = 0;
+ private int fLengthDifference = 0;
+ // private ICSSNode fRootNode = null;
+ private int fRemovedRangeBegin = -1;
+ private int fRemovedRangeEnd = -1;
+ private CSSNodeListImpl fNodesToBeRemoved = new CSSNodeListImpl();
+ private Set fOldRegionsList;
+
+ /**
+ * CSSModelDeletionContext constructor comment.
+ */
+ CSSModelDeletionContext(ICSSNode rootNode) {
+ super();
+
+ // fRootNode = rootNode;
+ }
+
+ /**
+ *
+ */
+ boolean addNodeToBeRemoved(ICSSNode node) {
+ int nNodes = fNodesToBeRemoved.getLength();
+ for (int i = 0; i < nNodes; i++) {
+ ICSSNode parent = fNodesToBeRemoved.item(i);
+ if (CSSModelUtil.isParentOf(parent, node)) {
+ return false;
+ }
+ }
+ fNodesToBeRemoved.appendNode(node);
+ return true;
+ }
+
+ /**
+ *
+ */
+ void expandRemovedRangeBegin(IStructuredDocumentRegion flatNode) {
+ if (flatNode == null) {
+ return;
+ }
+ int newBegin = flatNode.getStart(); // fOldStart == fNewStart, right??
+ if (fRemovedRangeBegin < 0 || newBegin < fRemovedRangeBegin) {
+ fRemovedRangeBegin = newBegin;
+ }
+ }
+
+ /**
+ *
+ */
+ void expandRemovedRangeEnd(IStructuredDocumentRegion flatNode) {
+ if (flatNode == null) {
+ return;
+ }
+ int newEnd = flatNode.getEnd() + ((isOldNode(flatNode)) ? fLengthDifference : 0);
+ if (fRemovedRangeEnd < 0 || fRemovedRangeEnd < newEnd) {
+ fRemovedRangeEnd = newEnd;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSStructuredDocumentRegionContainer findContainer(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) {
+ if (parent instanceof CSSStructuredDocumentRegionContainer) {
+ // Am i a container of flatNode?
+ IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) parent).getFirstStructuredDocumentRegion();
+ IStructuredDocumentRegion lastNode = ((CSSStructuredDocumentRegionContainer) parent).getLastStructuredDocumentRegion();
+ int firstStart = getOriginalOffset(firstNode);
+ int lastStart = getOriginalOffset(lastNode);
+ int start = flatNode.getStart();
+
+ if (firstStart <= start && start <= lastStart) {
+ // I am a container, is my child a container ?
+ for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSNodeImpl) {
+ CSSStructuredDocumentRegionContainer container = findContainer((CSSNodeImpl) node, flatNode);
+ if (container != null) {
+ return container;
+ }
+ }
+ }
+ return (CSSStructuredDocumentRegionContainer) parent;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ */
+ CSSStructuredDocumentRegionContainer findDeletionTarget(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) {
+ CSSStructuredDocumentRegionContainer target = findContainer(parent, flatNode);
+ if (target == null) {
+ return null;
+ }
+
+ // System.out.print(flatNode.toString() + ": ");
+
+ // child a(=====)b(=====)c
+ // parent (================) a,c can remove parent, but b cannot.
+
+ ICSSNode child;
+
+ for (child = target.getFirstChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getNextSibling()) {
+ // just advancing
+ }
+
+ if (child == null) {
+ // System.out.println("target has no children."); // TESTBYCOZY
+ return target; // has no child containers.
+ }
+ else {
+ IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion();
+ if (flatNode.getStart() < getOriginalOffset(firstNode)) {
+ // System.out.println("flatNode is in front of first child");
+ // // TESTBYCOZY
+ return target; // a
+ }
+ }
+
+ for (child = target.getLastChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getPreviousSibling()) {
+ // just advancing
+ }
+
+ if (child == null) {
+ // System.out.println("target has no children."); // TESTBYCOZY
+ return target; // has no child containers.
+ }
+ else {
+ IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion();
+ if (getOriginalOffset(firstNode) < flatNode.getStart()) {
+ // System.out.println("flatNode is in after of last child");
+ // // TESTBYCOZY
+ return target; // c
+ }
+ }
+
+ // System.out.println("flatNode inner of children"); // TESTBYCOZY
+ return null; // b
+ }
+
+ /**
+ *
+ */
+ Iterator getNodesToBeRemoved() {
+ Collection nodes = new ArrayList();
+ int nNodes = fNodesToBeRemoved.getLength();
+ for (int i = 0; i < nNodes; i++) {
+ nodes.add(fNodesToBeRemoved.item(i));
+ }
+ return nodes.iterator();
+ }
+
+ /**
+ *
+ */
+ private int getOriginalOffset(IStructuredDocumentRegion flatNode) {
+ int offset = 0;
+ if (flatNode != null) {
+ offset = flatNode.getStart();
+ if (0 <= fLengthDifference) {
+ if (fNewStart + fNewLength < offset) {
+ offset -= fLengthDifference;
+ }
+ }
+ else {
+ if (fOldStart + fOldLength <= offset || (fNewStart < 0 && fOldStart <= offset && !isOldNode(flatNode)) || (0 <= fNewStart && fNewStart + fNewLength <= offset && !isOldNode(flatNode))) {
+ offset -= fLengthDifference;
+ }
+ }
+ }
+
+ return offset;
+ }
+
+ /**
+ *
+ */
+ int getRemovedRangeBegin() {
+ return fRemovedRangeBegin;
+ }
+
+ /**
+ *
+ */
+ int getRemovedRangeEnd() {
+ return fRemovedRangeEnd;
+ }
+
+ /**
+ *
+ */
+ private boolean isOldNode(IStructuredDocumentRegion flatNode) {
+ return fOldRegionsList.contains(flatNode);
+ }
+
+ /**
+ *
+ */
+ void setupContext(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
+ IStructuredDocumentRegion flatNode = null;
+ fOldLength = CSSUtil.getTextLength(oldStructuredDocumentRegions);
+ if (oldStructuredDocumentRegions != null && 0 < oldStructuredDocumentRegions.getLength() && (flatNode = oldStructuredDocumentRegions.item(0)) != null) {
+ fOldStart = flatNode.getStart();
+ }
+ else {
+ fOldStart = -1;
+ }
+ fNewLength = CSSUtil.getTextLength(newStructuredDocumentRegions);
+ if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength() && (flatNode = newStructuredDocumentRegions.item(0)) != null) {
+ fNewStart = flatNode.getStart();
+ fRemovedRangeBegin = fNewStart;
+ fRemovedRangeEnd = fNewStart + fNewLength;
+ }
+ else {
+ fNewStart = -1;
+ fRemovedRangeBegin = fRemovedRangeEnd = -1;
+ }
+ fLengthDifference = fNewLength - fOldLength;
+
+ fOldRegionsList = new HashSet();
+ final Enumeration elements = oldStructuredDocumentRegions.elements();
+ while (elements.hasMoreElements()) {
+ fOldRegionsList.add(elements.nextElement());
+ }
+ // cleanup nodes
+ while (0 < fNodesToBeRemoved.getLength()) {
+ fNodesToBeRemoved.removeNode(0);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java
new file mode 100644
index 0000000..c8e7b5d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java
@@ -0,0 +1,627 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.event.ICSSStyleListener;
+import org.eclipse.wst.css.core.internal.eventimpl.CSSEmbededStyleNotifyAdapter;
+import org.eclipse.wst.css.core.internal.eventimpl.CSSStyleNotifyAdapter;
+import org.eclipse.wst.css.core.internal.parser.CSSSourceParser;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.eclipse.wst.css.core.internal.util.ImportRuleCollector;
+import org.eclipse.wst.css.core.internal.util.ImportedCollector;
+import org.eclipse.wst.css.core.internal.util.SelectorsCollector;
+import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
+import org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
+import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
+import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent;
+import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
+import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent;
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent;
+import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.util.Assert;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+
+public class CSSModelImpl extends AbstractStructuredModel implements ICSSModel, IStructuredDocumentListener {
+
+ private CSSDocumentImpl document = null;
+ private org.w3c.dom.Node ownerNode = null;
+ private CSSStyleNotifyAdapter styleNotifier = null;
+ private CSSModelParser fParser = null;
+ private CSSModelUpdater fUpdater = null;
+ private boolean fStructuredDocumentUpdate = false;
+ private final static String ID_NON_EXTERNAL_CSS = "**_NON_EXTERNAL_CSS_***";//$NON-NLS-1$
+
+ /**
+ * CSSModelImpl constructor comment.
+ *
+ */
+ public CSSModelImpl() {
+ super();
+ }
+
+ /**
+ * @param listener
+ * org.eclipse.wst.css.core.event.CSSStyleListener
+ */
+ public void addStyleListener(ICSSStyleListener listener) {
+ getStyleNotifier().addStyleListener(listener);
+ }
+
+ void attrReplaced(CSSNodeImpl parentNode, CSSNodeImpl newAttr, CSSNodeImpl oldAttr) {
+ if (!fStructuredDocumentUpdate) {
+ CSSModelUpdater updater = getUpdater();
+ updater.attrReplaced(parentNode, newAttr, oldAttr);
+ }
+
+ ICSSSelector removed[] = null, added[] = null;
+ if (oldAttr != null && oldAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) oldAttr).getName().equals(ICSSStyleRule.SELECTOR)) {
+ CSSAttrImpl attr = (CSSAttrImpl) oldAttr;
+ // collect changed selector
+ ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue());
+ removed = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ removed[i] = list.getSelector(i);
+ }
+ if (newAttr != null && newAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) newAttr).getName().equals(ICSSStyleRule.SELECTOR)) {
+ CSSAttrImpl attr = (CSSAttrImpl) newAttr;
+ // collect changed selector
+ ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue());
+ added = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ added[i] = list.getSelector(i);
+ }
+ if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) {
+ getStyleNotifier().fire(removed, added, null);
+ }
+ // for href attribute
+ if (getStyleListeners() != null && getStyleListeners().size() > 0) {
+ boolean update = false;
+ if (oldAttr != null && oldAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) oldAttr).getName().equals(ICSSImportRule.HREF)) {
+ update = true;
+ }
+ if (newAttr != null && newAttr.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) newAttr).getName().equals(ICSSImportRule.HREF)) {
+ update = true;
+ }
+ if (update)
+ ((ICSSImportRule) parentNode).getStyleSheet();
+ }
+ }
+
+ /**
+ *
+ */
+ public void beginRecording(Object requester, String label, String description) {
+ getStyleNotifier().beginRecording();
+
+ Node node = getOwnerDOMNode();
+ if (node != null && node instanceof IDOMNode) {
+ IStructuredModel model = ((IDOMNode) node).getModel();
+ if (model != null) {
+ model.beginRecording(requester, label, description);
+ return;
+ }
+ }
+ super.beginRecording(requester, label, description);
+ }
+
+ void childReplaced(CSSNodeImpl parentNode, CSSNodeImpl newChild, CSSNodeImpl oldChild) {
+ if (!fStructuredDocumentUpdate) {
+ CSSModelUpdater updater = getUpdater();
+ updater.childReplaced(parentNode, newChild, oldChild);
+ }
+
+ // always check and send selector event
+ ICSSSelector removed[] = null, added[] = null;
+ if (parentNode.getNodeType() == ICSSNode.STYLESHEET_NODE || parentNode.getNodeType() == ICSSNode.MEDIARULE_NODE) {
+ // collect old selectors
+ SelectorsCollector selTrav = new SelectorsCollector();
+ selTrav.apply(oldChild);
+ int nSel = selTrav.getSelectors().size();
+ if (nSel > 0) {
+ removed = new ICSSSelector[nSel];
+ for (int i = 0; i < nSel; i++)
+ removed[i] = (ICSSSelector) selTrav.getSelectors().get(i);
+ }
+ // collect new selectors
+ selTrav = new SelectorsCollector();
+ selTrav.apply(newChild);
+ nSel = selTrav.getSelectors().size();
+ if (nSel > 0) {
+ added = new ICSSSelector[nSel];
+ for (int i = 0; i < nSel; i++)
+ added[i] = (ICSSSelector) selTrav.getSelectors().get(i);
+ }
+ }
+ else {
+ // modification
+ ICSSNode rule = parentNode;
+ while (rule != null) {
+ if (rule instanceof ICSSStyleRule)
+ break;
+ rule = rule.getParentNode();
+ }
+ if (rule != null) {
+ ICSSSelectorList list = ((ICSSStyleRule) rule).getSelectors();
+ added = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ added[i] = list.getSelector(i);
+ }
+ }
+ if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) {
+ // send selector changed event
+ getStyleNotifier().fire(removed, added, null);
+ }
+ // close removed import-rule's external style sheets
+ {
+ ImportRuleCollector trav = new ImportRuleCollector();
+ trav.apply(oldChild);
+ Iterator it = trav.getRules().iterator();
+ while (it.hasNext()) {
+ ((CSSImportRuleImpl) it.next()).closeStyleSheet();
+ }
+ }
+ // send events to listener for new import-rules
+ if (getStyleListeners() != null && getStyleListeners().size() > 0) {
+ ImportedCollector trav = new ImportedCollector();
+ trav.apply(newChild);
+ }
+ }
+
+ /**
+ *
+ */
+ private void closeImported() {
+ if (!isShared()) {
+ // release listeners
+ if (getStyleListeners() != null) {
+ Vector toRemove = new Vector(getStyleListeners());
+ Iterator it = toRemove.iterator();
+ while (it.hasNext()) {
+ removeStyleListener((ICSSStyleListener) it.next());
+ }
+ }
+ // close import rules
+ ImportRuleCollector trav = new ImportRuleCollector();
+ trav.apply(getDocument());
+ Iterator it2 = trav.getRules().iterator();
+ while (it2.hasNext()) {
+ ((CSSImportRuleImpl) it2.next()).releaseRule();
+ }
+ }
+ }
+
+ private CSSDocumentImpl createDocument() {
+ CSSDocumentImpl doc = null;
+ int parserMode = CSSSourceParser.MODE_STYLESHEET;
+ if (ownerNode == null) {
+ // this case is external CSS file
+ doc = (CSSStyleSheetImpl) DOMCSSImpl.createCSSStyleSheet(null, null); // parameters
+ // are
+ // for
+ // STYLE-tag
+ parserMode = CSSSourceParser.MODE_STYLESHEET;
+ }
+ else if (ownerNode instanceof org.w3c.dom.Element && ((Element) ownerNode).getTagName().toUpperCase().equals("STYLE")) {//$NON-NLS-1$
+ // this case is STYLE-tag
+ Element style = (Element) ownerNode;
+ doc = (CSSStyleSheetImpl) DOMCSSImpl.createCSSStyleSheet(style.getAttribute("TITLE"), //$NON-NLS-1$
+ style.getAttribute("MEDIA"));//$NON-NLS-1$
+ parserMode = CSSSourceParser.MODE_STYLESHEET;
+ }
+ else if (ownerNode instanceof org.w3c.dom.Element || ownerNode instanceof org.w3c.dom.Attr) {
+ // Inline attributes
+ doc = (CSSStyleDeclarationImpl) DOMCSSImpl.createCSSStyleDeclaration();
+ parserMode = CSSSourceParser.MODE_DECLARATION;
+ }
+ RegionParser regionParser = getStructuredDocument().getParser();
+ if (regionParser instanceof CSSSourceParser) {
+ ((CSSSourceParser) regionParser).setParserMode(parserMode);
+ }
+ return doc;
+ }
+
+ /**
+ *
+ */
+ public void endRecording(Object requester) {
+ Node node = getOwnerDOMNode();
+ if (node != null && node instanceof IDOMNode) {
+ IStructuredModel model = ((IDOMNode) node).getModel();
+ if (model != null) {
+ model.endRecording(requester);
+ return;
+ }
+ }
+ super.endRecording(requester);
+
+ getStyleNotifier().endRecording();
+ }
+
+ public ICSSDocument getDocument() {
+ if (document == null) {
+ this.document = createDocument();
+ this.document.setModel(this);
+ }
+ return this.document;
+ }
+
+ public IStructuredDocument getStructuredDocument() {
+ IStructuredDocument structuredDocument = null;
+ structuredDocument = super.getStructuredDocument();
+ if (structuredDocument != null)
+ return structuredDocument;
+
+ // the first time
+ Assert.isNotNull(getModelHandler());
+ structuredDocument = (IStructuredDocument) getModelHandler().getDocumentLoader().createNewStructuredDocument();
+
+ setStructuredDocument(structuredDocument);
+ return structuredDocument;
+ }
+
+ /**
+ * getNode method comment.
+ */
+ public IndexedRegion getIndexedRegion(int offset) {
+ if (getDocument() == null)
+ return null;
+ return ((CSSStructuredDocumentRegionContainer) getDocument()).getContainerNode(offset);
+ }
+
+ /**
+ * @return org.w3c.dom.Node
+ */
+ public Node getOwnerDOMNode() {
+ return ownerNode;
+ }
+
+ /**
+ * @param ownerNode
+ * org.w3c.dom.Node if the case of external CSS model, you
+ * should set null, else if internal css, you should set
+ * STYLE-tag node, else if inline css, you should set the
+ * element that is the owner of style-attribute.
+ */
+ public void setOwnerDOMNode(Node node) {
+ // prohibit owner change
+ Assert.isTrue(ownerNode == null);
+ ownerNode = node;
+ if (ownerNode != null) { // for internal/inline CSS context
+ try {
+ setId(ID_NON_EXTERNAL_CSS);
+ }
+ catch (ResourceInUse e) {
+ // impossible
+ }
+ }
+ }
+
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ protected CSSModelParser getParser() {
+ if (fParser == null) {
+ if (getDocument() != null) {
+ fParser = new CSSModelParser(document);
+ }
+ }
+ return fParser;
+ }
+
+ /**
+ * @return java.util.List
+ */
+ public List getStyleListeners() {
+ return getStyleNotifier().getStyleListeners();
+ }
+
+ /**
+ *
+ * @return java.lang.Object
+ */
+ public java.lang.Object getStyleSheetType() {
+ if (getDocument() instanceof ICSSStyleDeclaration)
+ return INLINE;
+ if (getOwnerDOMNode() != null)
+ return EMBEDDED;
+ else
+ return EXTERNAL;
+ }
+
+ private CSSStyleNotifyAdapter getStyleNotifier() {
+ if (styleNotifier == null) {
+ styleNotifier = (ownerNode != null) ? new CSSEmbededStyleNotifyAdapter(this) : new CSSStyleNotifyAdapter(this);
+ }
+ return styleNotifier;
+ }
+
+ /**
+ *
+ */
+ private CSSModelUpdater getUpdater() {
+ if (fUpdater == null) {
+ fUpdater = new CSSModelUpdater(this);
+ fUpdater.setParser(getParser());
+ }
+ return fUpdater;
+ }
+
+ /**
+ */
+ public boolean isRecording() {
+ return getStyleNotifier().isRecording();
+ }
+
+ /**
+ * This function returns true if there are other references to the
+ * underlying model.
+ */
+ public boolean isShared() {
+ return (getStyleSheetType() == EXTERNAL) && super.isShared();
+ }
+
+ public void newModel(NewDocumentEvent structuredDocumentEvent) {
+ if (structuredDocumentEvent == null)
+ return;
+ IStructuredDocument structuredDocument = structuredDocumentEvent.getStructuredDocument();
+ if (structuredDocument == null)
+ return;
+ // this should not happen, but for the case
+ if (structuredDocument != getStructuredDocument())
+ setStructuredDocument(structuredDocument);
+ IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
+ if (flatNodes == null)
+ return;
+ if (getDocument() == null)
+ return;
+
+ fStructuredDocumentUpdate = true;
+
+ ((CSSStructuredDocumentRegionContainer) getDocument()).removeChildNodes();
+
+ CSSModelParser parser = getParser();
+ parser.setStructuredDocumentEvent(structuredDocumentEvent);
+ parser.replaceStructuredDocumentRegions(flatNodes, null);
+
+ fStructuredDocumentUpdate = false;
+ }
+
+ /**
+ * noChange method comment.
+ */
+ public void noChange(NoChangeEvent structuredDocumentEvent) {
+ // nop
+ }
+
+ public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
+ if (structuredDocumentEvent == null) {
+ return;
+ }
+ IStructuredDocumentRegionList oldStructuredDocumentRegions = structuredDocumentEvent.getOldStructuredDocumentRegions();
+ IStructuredDocumentRegionList newStructuredDocumentRegions = structuredDocumentEvent.getNewStructuredDocumentRegions();
+ if (oldStructuredDocumentRegions == null && newStructuredDocumentRegions == null) {
+ return;
+ }
+
+ fStructuredDocumentUpdate = true;
+
+ CSSModelParser parser = getParser();
+ parser.setStructuredDocumentEvent(structuredDocumentEvent);
+ if (structuredDocumentEvent.isEntireDocumentReplaced())
+ parser.replaceDocument(newStructuredDocumentRegions);
+ else
+ parser.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
+
+ fStructuredDocumentUpdate = false;
+ }
+
+ /**
+ * cleanup -> rebuild CSS Nodes This is pre-beta fix for 178176.
+ */
+ public void refreshNodes() {
+ // cleanup old nodes
+ fStructuredDocumentUpdate = true;
+ ((CSSStructuredDocumentRegionContainer) getDocument()).removeChildNodes();
+ fStructuredDocumentUpdate = false;
+
+ getParser().cleanupUpdateContext();
+
+ IStructuredDocument structuredDocument = getStructuredDocument();
+ String source = structuredDocument.getText();
+
+ structuredDocument.replaceText(this, 0, source.length(), null);
+ structuredDocument.replaceText(this, 0, 0, source);
+ }
+
+ public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
+ if (structuredDocumentEvent == null) {
+ return;
+ }
+ IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion();
+ if (flatNode == null) {
+ return;
+ }
+ ITextRegion region = structuredDocumentEvent.getRegion();
+ if (region == null) {
+ return;
+ }
+
+ fStructuredDocumentUpdate = true;
+
+ CSSModelParser parser = getParser();
+ parser.setStructuredDocumentEvent(structuredDocumentEvent);
+ parser.changeRegion(flatNode, region);
+
+ fStructuredDocumentUpdate = false;
+ }
+
+ public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
+ if (structuredDocumentEvent == null)
+ return;
+ IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion();
+ if (flatNode == null)
+ return;
+ ITextRegionList oldRegions = structuredDocumentEvent.getOldRegions();
+ ITextRegionList newRegions = structuredDocumentEvent.getNewRegions();
+ if (oldRegions == null && newRegions == null)
+ return;
+
+ fStructuredDocumentUpdate = true;
+
+ CSSModelParser parser = getParser();
+ parser.setStructuredDocumentEvent(structuredDocumentEvent);
+ parser.replaceRegions(flatNode, newRegions, oldRegions);
+
+ fStructuredDocumentUpdate = false;
+
+ }
+
+ /**
+ *
+ */
+ public void releaseFromEdit() {
+ closeImported();
+ if (getStyleSheetType() == EXTERNAL) {
+ super.releaseFromEdit();
+ }
+ }
+
+ /**
+ *
+ */
+ public void releaseFromRead() {
+ closeImported();
+ if (getStyleSheetType() == EXTERNAL) {
+ super.releaseFromRead();
+ }
+ }
+
+ /**
+ * @param listener
+ * org.eclipse.wst.css.core.event.CSSStyleListener
+ */
+ public void removeStyleListener(ICSSStyleListener listener) {
+ getStyleNotifier().removeStyleListener(listener);
+ }
+
+ public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
+ IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
+ if (newStructuredDocument == oldStructuredDocument)
+ return; // noting to do
+
+ if (oldStructuredDocument != null)
+ oldStructuredDocument.removeDocumentChangingListener(this);
+ super.setStructuredDocument(newStructuredDocument);
+
+ if (newStructuredDocument != null) {
+ if (newStructuredDocument.getLength() > 0) {
+ newModel(new NewDocumentEvent(newStructuredDocument, this));
+ }
+ newStructuredDocument.addDocumentChangingListener(this);
+ }
+ }
+
+ /**
+ * @param srcModel
+ * com.imb.sed.css.mode.intefaces.ICSSModel
+ * @param removed
+ * org.eclipse.wst.css.core.model.interfaces.ICSSSelector[]
+ * @param added
+ * org.eclipse.wst.css.core.model.interfaces.ICSSSelector[]
+ */
+ public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
+ getStyleNotifier().styleChanged(srcModel, removed, added, media);
+ }
+
+ /**
+ * @param srcModel
+ * org.eclipse.wst.css.core.model.interfaces.ICSSModel
+ */
+ public void styleUpdate(ICSSModel srcModel) {
+ getStyleNotifier().styleUpdate(srcModel);
+ }
+
+ void valueChanged(CSSNodeImpl node, String oldValue) {
+ if (!fStructuredDocumentUpdate) {
+ CSSModelUpdater updater = getUpdater();
+ updater.valueChanged(node, oldValue);
+ }
+
+ ICSSSelector removed[] = null, added[] = null;
+ if (node != null) {
+ if (node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSStyleRule.SELECTOR)) {
+ CSSAttrImpl attr = (CSSAttrImpl) node;
+ // collect changed selector
+ ICSSSelectorList list = new CSSSelectorListImpl(attr.getValue());
+ added = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ added[i] = list.getSelector(i);
+
+ // get old value
+ list = new CSSSelectorListImpl(oldValue);
+ removed = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ removed[i] = list.getSelector(i);
+ }
+ else if (node instanceof ICSSValue) {
+ ICSSNode rule = node;
+ while (rule != null) {
+ if (rule instanceof ICSSStyleRule)
+ break;
+ rule = rule.getParentNode();
+ }
+ if (rule != null) {
+ ICSSSelectorList list = ((ICSSStyleRule) rule).getSelectors();
+ added = new ICSSSelector[list.getLength()];
+ for (int i = 0; i < list.getLength(); i++)
+ added[i] = list.getSelector(i);
+ }
+ }
+ }
+ if (removed != null || added != null || getDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE) {
+ // send selector changed event
+ getStyleNotifier().fire(removed, added, null);
+ }
+ // for href attribute
+ if (getStyleListeners() != null && getStyleListeners().size() > 0) {
+ if (node != null && node.getNodeType() == ICSSNode.ATTR_NODE && ((CSSAttrImpl) node).getName().equals(ICSSImportRule.HREF)) {
+ ((ICSSImportRule) ((ICSSAttr) node).getOwnerCSSNode()).getStyleSheet();
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java
new file mode 100644
index 0000000..d6e6486
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelNodeFeeder.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+
+
+/**
+ *
+ */
+class CSSModelNodeFeeder {
+ /**
+ * currently ICSSDocument is used but may go back to CSSDocumentImpl in future.
+ */
+ ICSSDocument fDocument = null;
+ CSSModelUpdateContext fUpdateContext = null;
+
+ /**
+ * CSSModelNodeFeeder constructor comment.
+ */
+ CSSModelNodeFeeder() {
+ super();
+ }
+
+ /**
+ * CSSModelNodeFeeder constructor comment.
+ * currently ICSSDocument is used but may go back to CSSDocumentImpl in future.
+ */
+ CSSModelNodeFeeder(ICSSDocument document, CSSModelUpdateContext updateContext) {
+ super();
+ fDocument = document;
+ fUpdateContext = updateContext;
+ }
+
+ /**
+ *
+ */
+ CSSCharsetRuleImpl getCSSCharsetRule() {
+ CSSCharsetRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSCharsetRule();
+ }
+ else {
+ node = (CSSCharsetRuleImpl) fDocument.createCSSCharsetRule();
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ CSSFontFaceRuleImpl getCSSFontFaceRule() {
+ CSSFontFaceRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSFontFaceRule();
+ }
+ else {
+ node = (CSSFontFaceRuleImpl) fDocument.createCSSFontFaceRule();
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ CSSImportRuleImpl getCSSImportRule() {
+ CSSImportRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSImportRule();
+ }
+ else {
+ node = (CSSImportRuleImpl) fDocument.createCSSImportRule();
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ CSSMediaRuleImpl getCSSMediaRule() {
+ CSSMediaRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSMediaRule();
+ }
+ else {
+ node = (CSSMediaRuleImpl) fDocument.createCSSMediaRule();
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ CSSPageRuleImpl getCSSPageRule() {
+ CSSPageRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSPageRule();
+ }
+ else {
+ node = (CSSPageRuleImpl) fDocument.createCSSPageRule();
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ CSSStyleRuleImpl getCSSStyleRule() {
+ CSSStyleRuleImpl node;
+ if (fUpdateContext.isActive()) {
+ node = fUpdateContext.getCSSStyleRule();
+ }
+ else {
+ node = (CSSStyleRuleImpl) fDocument.createCSSStyleRule();
+ }
+ return node;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java
new file mode 100644
index 0000000..a9e971e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelParser.java
@@ -0,0 +1,1317 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.text.StructuredDocumentWalker;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.text.CoreNodeList;
+import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl;
+import org.eclipse.wst.sse.core.internal.util.Assert;
+import org.w3c.dom.css.CSSFontFaceRule;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+
+/**
+ * currently public but may be made default access protected in future.
+ */
+public class CSSModelParser {
+
+ private ICSSDocument fDocument = null;
+ private CSSModelCreationContext fCreationContext = null;
+ private CSSModelDeletionContext fDeletionContext = null;
+ private CSSModelUpdateContext fUpdateContext = null;
+ private CSSModelNodeFeeder fFeeder = null;
+ private StructuredDocumentWalker fStructuredDocumentWalker = null;
+ private boolean fParseFloating = false;
+
+ /**
+ * CSSModelParser constructor comment.
+ */
+ private CSSModelParser() {
+ super();
+ }
+
+ /**
+ * currently provded this method but may be removed in future.
+ */
+ protected boolean isParseFloating(){
+ return fParseFloating;
+ }
+ /**
+ * currently provded this method but may be removed in future.
+ */
+ protected CSSModelCreationContext getCreationContext(){
+ return fCreationContext;
+ }
+ /**
+ * currently provded this method but may be removed in future.
+ */
+ protected boolean isUpdateContextActive(){
+ return fUpdateContext != null ? fUpdateContext.isActive() : false;
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSModelParser(ICSSDocument doc) {
+ this();
+ fDocument = doc;
+ fCreationContext = new CSSModelCreationContext((CSSNodeImpl)doc);
+ fDeletionContext = new CSSModelDeletionContext(doc);
+ fUpdateContext = new CSSModelUpdateContext();
+ fFeeder = new CSSModelNodeFeeder(doc, fUpdateContext);
+ }
+
+ /**
+ *
+ */
+ void changeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
+ replaceStructuredDocumentRegions(new CoreNodeList(flatNode, flatNode), new CoreNodeList(flatNode, flatNode));
+ }
+
+ /**
+ *
+ */
+ void changeRegion(IStructuredDocumentRegion flatNode, ITextRegion region) {
+ if (flatNode == null || region == null) {
+ return;
+ }
+ if (fDocument == null) {
+ return;
+ }
+
+ changeStructuredDocumentRegion(flatNode);
+ }
+
+ /**
+ *
+ */
+ private void checkNextNode(IStructuredDocumentRegion flatNode, String type) {
+ IStructuredDocumentRegion next = CSSUtil.findNextSignificantNode(flatNode);
+ if (CSSUtil.getStructuredDocumentRegionType(next) == type) {
+ fCreationContext.setReparseStart(flatNode.getEnd());
+ fCreationContext.setReparseEnd(next.getEnd());
+ }
+ }
+
+ /**
+ *
+ */
+ private void cleanupDeletionContext() {
+ // setupDeletionContext(null);
+ }
+
+ /**
+ *
+ */
+ boolean cleanupFirstNode(IStructuredDocumentRegion firstNode, CSSStructuredDocumentRegionContainer target) {
+ if (firstNode == null || target == null) {
+ return false;
+ }
+
+ if (firstNode == target.getFirstStructuredDocumentRegion()) {
+ IStructuredDocumentRegion nextNode = fStructuredDocumentWalker.getNextNodeInCurrent(firstNode);
+ IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion();
+ if (lastNode == null || fStructuredDocumentWalker.isOldNode(lastNode) || nextNode == null || lastNode.getStartOffset() < nextNode.getStartOffset()) {
+ target.setRangeStructuredDocumentRegion(null, null);
+ }
+ else {
+ target.setFirstStructuredDocumentRegion(nextNode);
+ }
+ ICSSNode parent = target.getParentNode();
+ if (parent instanceof CSSStructuredDocumentRegionContainer) {
+ cleanupFirstNode(firstNode, (CSSStructuredDocumentRegionContainer) parent);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ boolean cleanupLastNode(IStructuredDocumentRegion lastNode, CSSStructuredDocumentRegionContainer target) {
+ if (lastNode == null || target == null) {
+ return false;
+ }
+
+ if (lastNode == target.getLastStructuredDocumentRegion()) {
+ IStructuredDocumentRegion prevNode = fStructuredDocumentWalker.getPrevNodeInCurrent(lastNode);
+ IStructuredDocumentRegion firstNode = target.getFirstStructuredDocumentRegion();
+ if (firstNode == null || fStructuredDocumentWalker.isOldNode(firstNode) || prevNode == null || prevNode.getStartOffset() < firstNode.getStartOffset()) {
+ target.setRangeStructuredDocumentRegion(null, null);
+ }
+ else {
+ target.setLastStructuredDocumentRegion(prevNode);
+ }
+ ICSSNode parent = target.getParentNode();
+ if (parent instanceof CSSStructuredDocumentRegionContainer) {
+ cleanupLastNode(lastNode, (CSSStructuredDocumentRegionContainer) parent);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ int cleanupUpdateContext() {
+ int remains = fUpdateContext.getNodeCount();
+ fUpdateContext.cleanupContext();
+ return remains;
+ }
+
+ /**
+ * create floating CSS rule (owner document will be set) this is for
+ * CSSStyleSheet.createCSSRule(String)
+ *
+ * @return org.w3c.dom.css.CSSRule
+ */
+ CSSRule createCSSRule(IStructuredDocumentRegionList flatNodes) {
+ if (flatNodes == null) {
+ return null;
+ }
+
+ fParseFloating = true;
+
+ // setup creation context
+ fCreationContext.clear();
+ fCreationContext.setTargetNode(null);
+ fCreationContext.setNextNode(null);
+ CSSRuleImpl parentRule = null;
+
+ for (Enumeration e = flatNodes.elements(); e.hasMoreElements();) {
+ IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement();
+ if (flatNode == null) {
+ continue;
+ }
+ CSSNodeImpl modified = insertStructuredDocumentRegion(flatNode);
+ if (parentRule == null && modified instanceof CSSRuleImpl) {
+ parentRule = (CSSRuleImpl) modified;
+ }
+ }
+
+ fParseFloating = false;
+
+ if (parentRule != null) {
+ CSSModelUtil.cleanupContainer(parentRule);
+ }
+
+ return parentRule;
+ }
+
+ /**
+ *
+ */
+ private IStructuredDocumentRegion findBraceClose(int depth, IStructuredDocumentRegion start, boolean bBreakSibling) {
+ IStructuredDocumentRegion result = null;
+ int braceLevel = 0;
+ IStructuredDocumentRegion prevNode = null;
+ IStructuredDocumentRegion region = start.getNext();
+ for (; region != null; region = region.getNext()) {
+ int offset = region.getStart();
+ if (offset < 0) {
+ Assert.isTrue(false);
+ break;
+ }
+ CSSNodeImpl node = getNodeAt(offset);
+ int depthHit = (node != null) ? CSSModelUtil.getDepth(node) : -1;
+ if (depth <= depthHit) {
+ // sibling is found before "}"
+ if (bBreakSibling) {
+ CSSNodeImpl parent = (CSSNodeImpl) node.getParentNode();
+ while (depth <= CSSModelUtil.getDepth(parent)) {
+ node = parent;
+ parent = (CSSNodeImpl) parent.getParentNode();
+ }
+ if (parent != null && node != null) {
+ parent.removeChild(node);
+ }
+ }
+ else {
+ result = prevNode;
+ break;
+ }
+ }
+ String type = CSSUtil.getStructuredDocumentRegionType(region);
+ if (type == CSSRegionContexts.CSS_LBRACE) {
+ braceLevel++;
+ }
+ if (type == CSSRegionContexts.CSS_RBRACE) {
+ braceLevel--;
+ if (braceLevel < 0) {
+ result = region;
+ break;
+ }
+ }
+ prevNode = region;
+ }
+
+ if (result == null && region == null) {
+ // reach the end of document
+ result = prevNode;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ */
+ private IStructuredDocumentRegionList getStructuredDocumentRegionList(int start, int end) {
+ IStructuredDocumentRegionList nodeList = null;
+ if (0 <= start && start <= end) {
+ ICSSModel model = fDocument.getModel();
+ if (model instanceof CSSModelImpl) {
+ IStructuredDocument structuredDocument = ((CSSModelImpl) model).getStructuredDocument();
+ if (structuredDocument != null) {
+ IStructuredDocumentRegion startNode = structuredDocument.getRegionAtCharacterOffset(start);
+ IStructuredDocumentRegion endNode = structuredDocument.getRegionAtCharacterOffset(end - 1);
+ if (startNode != null && endNode != null) {
+ nodeList = new CoreNodeList(startNode, endNode);
+ }
+ }
+ }
+ }
+
+ return nodeList;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl getNodeAt(int offset) {
+ CSSNodeImpl rootNode = fCreationContext.getRootNode();
+ ICSSNode target = rootNode.getNodeAt(offset);
+ if (target instanceof CSSNodeImpl) {
+ return (CSSNodeImpl) target;
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertBraceClose(IStructuredDocumentRegion region) {
+ ICSSNode target = CSSModelUtil.findBraceContainer(fCreationContext.getTargetNode());
+
+ if (!(target instanceof CSSStructuredDocumentRegionContainer)) {
+ return null;
+ }
+
+ CSSStructuredDocumentRegionContainer parent = (CSSStructuredDocumentRegionContainer) target;
+ if (CSSModelUtil.isInterruption(parent, region)) {
+ ICSSNode node = parent.getParentNode();
+ if (node instanceof CSSNodeImpl) {
+ fCreationContext.setReparseStart(parent.getStartOffset());
+ fCreationContext.setReparseEnd(parent.getEndOffset());
+ ((CSSNodeImpl) node).removeChild(parent);
+ }
+ return null;
+ }
+
+ if (parent instanceof ICSSPageRule || parent instanceof ICSSMediaRule || parent instanceof CSSFontFaceRule || parent instanceof ICSSStyleRule) {
+ CSSModelUtil.expandStructuredDocumentRegionContainer(parent, region);
+ if (!CSSModelUtil.isBraceClosed(target)) {
+ fCreationContext.setTargetNode(parent.getParentNode());
+ fCreationContext.setNextNode(parent.getNextSibling());
+ return parent;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertBraceOpen(IStructuredDocumentRegion region) {
+ IStructuredDocumentRegion keyRegion = CSSUtil.findPreviousSignificantNode(region);
+ if (keyRegion == null) {
+ return null;
+ }
+ if (!fParseFloating) {
+ CSSNodeImpl node = getNodeAt(keyRegion.getStartOffset());
+ if (node != null && !(node instanceof ICSSRuleContainer)) {
+ return null;
+ }
+ }
+ String type = CSSUtil.getStructuredDocumentRegionType(keyRegion);
+
+ CSSNodeImpl inserted = null;
+ if (type == CSSRegionContexts.CSS_PAGE) {
+ inserted = insertPageRule(keyRegion, region);
+ }
+ else if (type == CSSRegionContexts.CSS_MEDIA) {
+ inserted = insertMediaRule(keyRegion, region);
+ }
+ else if (type == CSSRegionContexts.CSS_FONT_FACE) {
+ inserted = insertFontFaceRule(keyRegion, region);
+ }
+ else if (CSSUtil.isSelectorText(keyRegion)) {
+ inserted = insertStyleRule(keyRegion, region);
+ }
+
+ if (inserted instanceof CSSStructuredDocumentRegionContainer) {
+ // CSSModelUtil.expandStructuredDocumentRegionContainer((CSSStructuredDocumentRegionContainer)inserted,
+ // flatNode);
+ IStructuredDocumentRegion braceClose = findBraceClose(CSSModelUtil.getDepth(inserted), region, (type == CSSRegionContexts.CSS_MEDIA));
+ if (braceClose != null) {
+ fCreationContext.setReparseStart(region.getEnd());
+ fCreationContext.setReparseEnd(braceClose.getEnd());
+ }
+ }
+
+ return inserted;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertCharsetRule(IStructuredDocumentRegion beginDocRegion, IStructuredDocumentRegion endDocRegion) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ ITextRegionList regions = new TextRegionListImpl(beginDocRegion.getRegions());
+ regions.remove(0); // must be "@charset"
+ ITextRegion encodingRegion = null;
+ while (!regions.isEmpty()) {
+ ITextRegion textRegion = regions.remove(0);
+ if (textRegion == null) {
+ continue;
+ }
+ String type = textRegion.getType();
+ if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
+ continue;
+ }
+ if (type == CSSRegionContexts.CSS_STRING) {
+ encodingRegion = textRegion;
+ break;
+ }
+ else {
+ break;
+ }
+ }
+ if (encodingRegion == null) {
+ return null;
+ }
+
+ CSSCharsetRuleImpl rule = fFeeder.getCSSCharsetRule();
+ if (rule == null) {
+ return null;
+ }
+
+ if (!fUpdateContext.isActive()) {
+ rule.setAttribute(ICSSCharsetRule.ENCODING, beginDocRegion.getText(encodingRegion));
+ }
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(beginDocRegion, endDocRegion);
+ CSSAttrImpl attr = rule.getAttributeNode(ICSSCharsetRule.ENCODING);
+ if (attr != null) {
+ attr.setRangeRegion(beginDocRegion, encodingRegion, encodingRegion);
+ }
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ return rule;
+ }
+
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ protected CSSNodeImpl insertStructuredDocumentRegion(IStructuredDocumentRegion region) {
+ if (fCreationContext == null || region == null) {
+ return null;
+ }
+
+ String type = ((BasicStructuredDocumentRegion) region).getType();
+ CSSNodeImpl modified = null;
+
+ ICSSNode target = fCreationContext.getTargetNode();
+
+ if ((fParseFloating && target == null) || target instanceof ICSSRuleContainer) {
+ if (type == CSSRegionContexts.CSS_DELIMITER) {
+ modified = insertSemiColonForRule(region);
+ }
+ else if (type == CSSRegionContexts.CSS_LBRACE) {
+ modified = insertBraceOpen(region);
+ }
+ else if (type == CSSRegionContexts.CSS_RBRACE) {
+ modified = insertBraceClose(region);
+ }
+ else if (type == CSSRegionContexts.CSS_MEDIA || type == CSSRegionContexts.CSS_PAGE || type == CSSRegionContexts.CSS_FONT_FACE || CSSUtil.isSelectorText(region)) {
+ checkNextNode(region, CSSRegionContexts.CSS_LBRACE);
+ }
+ else if (type == CSSRegionContexts.CSS_IMPORT || type == CSSRegionContexts.CSS_CHARSET) {
+ checkNextNode(region, CSSRegionContexts.CSS_DELIMITER);
+ }
+ }
+ else if ((target instanceof CSSRuleDeclContainer || target instanceof CSSStyleDeclaration) && type == CSSRegionContexts.CSS_DECLARATION_PROPERTY) {
+ modified = insertStyleDeclarationItem(region);
+ }
+ else if (target instanceof ICSSStyleDeclItem && type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ modified = insertSemiColonForStyleDeclarationItem(region);
+ }
+ else if (type == CSSRegionContexts.CSS_RBRACE) {
+ modified = insertBraceClose(region);
+ }
+
+ // post process
+ if (modified != null) {
+ if (modified instanceof CSSStructuredDocumentRegionContainer) {
+ ((CSSStructuredDocumentRegionContainer) modified).propagateRangeStructuredDocumentRegion();
+ }
+ }
+
+ return modified;
+ }
+
+ /**
+ *
+ */
+ private void insertStructuredDocumentRegions(IStructuredDocumentRegionList regionList) {
+ for (Enumeration e = regionList.elements(); e.hasMoreElements();) {
+ IStructuredDocumentRegion region = (IStructuredDocumentRegion) e.nextElement();
+ if (region == null) {
+ continue;
+ }
+ insertStructuredDocumentRegion(region);
+ if (fCreationContext.isToReparse()) {
+ int origStart = region.getEnd();
+ int origEnd = regionList.item(regionList.getLength() - 1).getEnd();
+ int newStart = fCreationContext.getReparseStart();
+ int newEnd = fCreationContext.getReparseEnd();
+ if (newStart < origStart || origEnd < newEnd) {
+ IStructuredDocumentRegionList newNodeList = getStructuredDocumentRegionList(newStart, newEnd);
+ setupCreationContext(newNodeList.item(0));
+ insertStructuredDocumentRegions(newNodeList);
+ return;
+ }
+ else {
+ fCreationContext.resetReparseRange();
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertFontFaceRule(IStructuredDocumentRegion region, IStructuredDocumentRegion braceNode) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ CSSFontFaceRuleImpl rule = fFeeder.getCSSFontFaceRule();
+ if (rule == null) {
+ return null;
+ }
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(region, braceNode);
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ fCreationContext.setTargetNode(rule);
+ // TargetNext is set to null automatically
+
+ return rule;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertImportRule(IStructuredDocumentRegion beginDocRegion, IStructuredDocumentRegion endDocRegion) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ ITextRegionList regions = new TextRegionListImpl(beginDocRegion.getRegions());
+ regions.remove(0); // must be "@import"
+ ITextRegion hrefRegion = null;
+ while (!regions.isEmpty()) {
+ ITextRegion textRegion = regions.remove(0);
+ if (textRegion == null) {
+ continue;
+ }
+ String type = textRegion.getType();
+ if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
+ continue;
+ }
+ if (type == CSSRegionContexts.CSS_URI || type == CSSRegionContexts.CSS_STRING) {
+ hrefRegion = textRegion;
+ break;
+ }
+ else {
+ break;
+ }
+ }
+ if (hrefRegion == null) {
+ return null;
+ }
+
+ CSSImportRuleImpl rule = fFeeder.getCSSImportRule();
+ if (rule == null) {
+ return null;
+ }
+
+ CSSUtil.stripSurroundingSpace(regions);
+ MediaListImpl mediaList = (MediaListImpl) rule.getMedia();
+ setMediaList(mediaList, beginDocRegion, regions);
+
+ if (!fUpdateContext.isActive()) {
+ rule.setAttribute(ICSSImportRule.HREF, beginDocRegion.getText(hrefRegion));
+ }
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(beginDocRegion, endDocRegion);
+ CSSAttrImpl attr = rule.getAttributeNode(ICSSImportRule.HREF);
+ if (attr != null) {
+ attr.setRangeRegion(beginDocRegion, hrefRegion, hrefRegion);
+ }
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ return rule;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertMediaRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ CSSMediaRuleImpl rule = fFeeder.getCSSMediaRule();
+ if (rule == null) {
+ return null;
+ }
+
+ ITextRegionList regions = new TextRegionListImpl(flatNode.getRegions());
+ regions.remove(0); // must be "@media"
+
+ CSSUtil.stripSurroundingSpace(regions);
+ MediaListImpl mediaList = (MediaListImpl) rule.getMedia();
+ setMediaList(mediaList, flatNode, regions);
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(flatNode, braceNode);
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ fCreationContext.setTargetNode(rule);
+ // TargetNext is set to null automatically
+
+ return rule;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertPageRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ // get selector regions
+ ITextRegionList selectorRegions = new TextRegionListImpl(flatNode.getRegions());
+ selectorRegions.remove(0); // must be "@page"
+ CSSUtil.stripSurroundingSpace(selectorRegions);
+
+ CSSPageRuleImpl rule = fFeeder.getCSSPageRule();
+ if (rule == null) {
+ return null;
+ }
+
+ if (!fUpdateContext.isActive()) {
+ String selectorStr = CSSUtil.getRegionText(flatNode, selectorRegions);
+ if (0 < selectorStr.length()) {
+ rule.setSelectorText(selectorStr);
+ }
+ }
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(flatNode, braceNode);
+ CSSAttrImpl attr = rule.getAttributeNode(ICSSPageRule.SELECTOR);
+ if (attr != null && selectorRegions != null && !selectorRegions.isEmpty()) {
+ attr.setRangeRegion(flatNode, selectorRegions.get(0), selectorRegions.get(selectorRegions.size() - 1));
+ }
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ fCreationContext.setTargetNode(rule);
+ // TargetNext is set to null automatically
+
+ return rule;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertSemiColonForRule(IStructuredDocumentRegion region) {
+ IStructuredDocumentRegion keyRegion = CSSUtil.findPreviousSignificantNode(region);
+ String type = CSSUtil.getStructuredDocumentRegionType(keyRegion);
+
+ CSSNodeImpl inserted = null;
+ if (type == CSSRegionContexts.CSS_IMPORT) {
+ inserted = insertImportRule(keyRegion, region);
+ }
+ else if (type == CSSRegionContexts.CSS_CHARSET) {
+ inserted = insertCharsetRule(keyRegion, region);
+ }
+
+ return inserted;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertSemiColonForStyleDeclarationItem(IStructuredDocumentRegion region) {
+ // only target/net node is changed. nothing to do.
+
+ CSSNodeImpl targetNode = fCreationContext.getTargetNode();
+ if (targetNode instanceof ICSSStyleDeclItem) {
+ int offset = targetNode.getStartOffset();
+ // widen document region range
+ // ((CSSStyleDeclItemImpl)targetNode).setLastStructuredDocumentRegion(region);
+ CSSModelUtil.expandStructuredDocumentRegionContainer((CSSStyleDeclItemImpl) targetNode, region);
+ // psStructuredDocumentRegion indicates CSSStyleDeclItem
+ ICSSNode parentNode = targetNode.getParentNode();
+ fCreationContext.setTargetNode(parentNode);
+ ICSSNode next = null;
+ if (parentNode.hasChildNodes()) {
+ for (ICSSNode child = targetNode.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof CSSStructuredDocumentRegionContainer && offset < ((CSSStructuredDocumentRegionContainer) child).getStartOffset()) {
+ next = child;
+ break;
+ }
+ }
+ }
+ fCreationContext.setNextNode(next);
+
+ return targetNode;
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertStyleDeclarationItem(IStructuredDocumentRegion docRegion) {
+ CSSStyleDeclarationImpl parent = null;
+ CSSNodeImpl node = fCreationContext.getTargetNode();
+ if (node instanceof CSSRuleDeclContainer) {
+ CSSRuleDeclContainer declContainer = (CSSRuleDeclContainer) node;
+ parent = (CSSStyleDeclarationImpl) declContainer.getStyle();
+ }
+ else if (node instanceof CSSStyleDeclarationImpl) {
+ parent = (CSSStyleDeclarationImpl) node;
+ }
+
+ CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(parent.getOwnerDocument());
+ itemParser.setStructuredDocumentTemporary(false);
+ itemParser.setUpdateContext(fUpdateContext);
+ CSSStyleDeclItemImpl declItem = itemParser.setupDeclarationItem(docRegion);
+ if (declItem == null) {
+ return null;
+ }
+
+ // setup flat container
+ declItem.setRangeStructuredDocumentRegion(docRegion, docRegion);
+
+ // insert to tree
+ if (!fUpdateContext.isActive()) {
+ propagateRangePreInsert(parent, declItem);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(declItem, next);
+ }
+ else {
+ parent.appendChild(declItem);
+ }
+ }
+
+ fCreationContext.setTargetNode(declItem);
+ // TargetNext is set to null automatically
+
+ return declItem;
+ }
+
+ /**
+ *
+ */
+ private CSSNodeImpl insertStyleRule(IStructuredDocumentRegion flatNode, IStructuredDocumentRegion braceNode) {
+ CSSNodeImpl parent = fCreationContext.getTargetNode();
+ if (!fParseFloating && !(parent instanceof ICSSRuleContainer)) {
+ return null;
+ }
+
+ // get selector regions
+ ITextRegionList selectorRegions = new TextRegionListImpl(flatNode.getRegions());
+ CSSUtil.stripSurroundingSpace(selectorRegions);
+
+ CSSStyleRuleImpl rule = fFeeder.getCSSStyleRule();
+ if (rule == null) {
+ return null;
+ }
+
+ if (!fUpdateContext.isActive()) {
+ String selectorStr = CSSUtil.getRegionText(flatNode, selectorRegions);
+ if (selectorStr != null && 0 < selectorStr.length()) {
+ rule.setSelectorText(selectorStr);
+ }
+ }
+
+ // setup flat container
+ rule.setRangeStructuredDocumentRegion(flatNode, braceNode);
+ CSSAttrImpl attr = rule.getAttributeNode(ICSSPageRule.SELECTOR);
+ if (attr != null && selectorRegions != null && !selectorRegions.isEmpty()) {
+ attr.setRangeRegion(flatNode, selectorRegions.get(0), selectorRegions.get(selectorRegions.size() - 1));
+ }
+
+ // insert to tree
+ if (!fUpdateContext.isActive() && parent != null) {
+ propagateRangePreInsert(parent, rule);
+ CSSNodeImpl next = fCreationContext.getNextNode();
+ if (next != null) {
+ parent.insertBefore(rule, next);
+ }
+ else {
+ parent.appendChild(rule);
+ }
+ }
+
+ fCreationContext.setTargetNode(rule);
+ // TargetNext is set to null automatically
+
+ return rule;
+ }
+
+ /**
+ *
+ */
+ private void pretendRemoveNode() {
+ CSSStructuredDocumentRegionContainer node = (CSSStructuredDocumentRegionContainer) fUpdateContext.getDeletionTarget();
+ if (node == null) {
+ return;
+ }
+
+ IStructuredDocumentRegion firstNode = node.getFirstStructuredDocumentRegion();
+ if (firstNode != null) {
+ fDeletionContext.expandRemovedRangeBegin(firstNode);
+ }
+ IStructuredDocumentRegion lastNode = node.getLastStructuredDocumentRegion();
+ if (lastNode != null) {
+ fDeletionContext.expandRemovedRangeEnd(lastNode);
+ }
+
+ shrinkContainer((CSSStructuredDocumentRegionContainer) fUpdateContext.getDeletionTargetParent(), node);
+ }
+
+ /**
+ * currently public but may be made default access protected in future.
+ *
+ * @param parent
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param child
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ protected void propagateRangePreInsert(CSSNodeImpl parent, CSSNodeImpl child) {
+ if (!(child instanceof CSSStructuredDocumentRegionContainer) || !(parent instanceof CSSStructuredDocumentRegionContainer)) {
+ return;
+ }
+
+ CSSStructuredDocumentRegionContainer parentContainer = (CSSStructuredDocumentRegionContainer) parent;
+ CSSStructuredDocumentRegionContainer childContainer = (CSSStructuredDocumentRegionContainer) child;
+ IStructuredDocumentRegion firstNode = childContainer.getFirstStructuredDocumentRegion();
+ IStructuredDocumentRegion lastNode = childContainer.getLastStructuredDocumentRegion();
+ if (firstNode == null || lastNode == null) {
+ return;
+ }
+
+ boolean bModified = parentContainer.includeRangeStructuredDocumentRegion(firstNode, lastNode);
+ if (bModified) {
+ parentContainer.propagateRangeStructuredDocumentRegion();
+ }
+ }
+
+ /**
+ *
+ */
+ private void removeStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
+ String type = CSSUtil.getStructuredDocumentRegionType(flatNode);
+ if (type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ do {
+ flatNode = fStructuredDocumentWalker.getPrevNode(flatNode);
+ type = (flatNode != null) ? CSSUtil.getStructuredDocumentRegionType(flatNode) : null;
+ }
+ while (type != null && (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT));
+ }
+ if (flatNode == null) {
+ return;
+ }
+
+ // if (fDeletionContext.isInRemovedRange(flatNode)) { // already
+ // removed
+ // return;
+ // }
+
+ CSSStructuredDocumentRegionContainer node = fDeletionContext.findDeletionTarget((CSSNodeImpl)fDocument, flatNode);
+ if (node == null || node == fDocument) {
+ return; // not attached with any treeNode
+ }
+
+ if (node instanceof CSSStyleDeclarationImpl) {
+ ICSSNode rule = node.getParentNode();
+ if (rule instanceof CSSStyleRuleImpl) {
+ node = (CSSStructuredDocumentRegionContainer) rule;
+ }
+ else {
+ return;
+ }
+ }
+
+ // ICSSNode p = node.getParentNode();
+ // if (p == null || ! (p instanceof
+ // CSSStructuredDocumentRegionContainer)) {
+ // return;
+ // }
+ // CSSStructuredDocumentRegionContainer parent =
+ // (CSSStructuredDocumentRegionContainer)p;
+
+ if (fDeletionContext.addNodeToBeRemoved(node)) {
+ IStructuredDocumentRegion firstNode = node.getFirstStructuredDocumentRegion();
+ if (firstNode != null) {
+ fDeletionContext.expandRemovedRangeBegin(firstNode);
+ }
+ IStructuredDocumentRegion lastNode = node.getLastStructuredDocumentRegion();
+ if (lastNode != null) {
+ fDeletionContext.expandRemovedRangeEnd(lastNode);
+ }
+ }
+
+ // shrinkContainer(node);
+ // parent.removeChild(node);
+ }
+
+ /**
+ *
+ */
+ private void removeStructuredDocumentRegions(IStructuredDocumentRegionList flatNodes) {
+ for (Enumeration e = flatNodes.elements(); e.hasMoreElements();) {
+ IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement();
+ if (flatNode == null) {
+ continue;
+ }
+ removeStructuredDocumentRegion(flatNode);
+ }
+
+ Iterator i = fDeletionContext.getNodesToBeRemoved();
+ while (i.hasNext()) {
+ CSSNodeImpl node = (CSSNodeImpl) i.next();
+ if (!(node instanceof CSSStructuredDocumentRegionContainer)) {
+ continue;
+ }
+ CSSNodeImpl parent = (CSSNodeImpl) node.getParentNode();
+ if (!(parent instanceof CSSStructuredDocumentRegionContainer)) {
+ continue;
+ }
+ shrinkContainer((CSSStructuredDocumentRegionContainer) parent, (CSSStructuredDocumentRegionContainer) node);
+ parent.removeChild(node);
+ }
+ }
+
+ void replaceDocument(IStructuredDocumentRegionList newStructuredDocumentRegions) {
+ if (fDocument == null || fCreationContext == null)
+ return;
+ ((CSSDocumentImpl) fDocument).removeChildNodes();
+
+ if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength()) {
+ setupCreationContext(newStructuredDocumentRegions.item(0));
+ insertStructuredDocumentRegions(newStructuredDocumentRegions);
+ }
+
+ IStructuredDocument structuredDocument = fStructuredDocumentWalker.getStructuredDocument();
+ ((CSSStructuredDocumentRegionContainer)fDocument).setRangeStructuredDocumentRegion(structuredDocument.getFirstStructuredDocumentRegion(), structuredDocument.getLastStructuredDocumentRegion());
+ }
+
+ /**
+ *
+ */
+ void replaceStructuredDocumentRegions(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
+ if (fDocument == null || fCreationContext == null) {
+ return;
+ }
+
+ if (oldStructuredDocumentRegions != null && 0 < oldStructuredDocumentRegions.getLength()) {
+ setupDeletionContext(newStructuredDocumentRegions, oldStructuredDocumentRegions);
+ short updateMode = fUpdateContext.getUpdateMode();
+ if (updateMode == CSSModelUpdateContext.UPDATE_IDLE) {
+ removeStructuredDocumentRegions(oldStructuredDocumentRegions);
+ }
+ else {
+ pretendRemoveNode();
+ }
+ newStructuredDocumentRegions = getStructuredDocumentRegionList(fDeletionContext.getRemovedRangeBegin(), fDeletionContext.getRemovedRangeEnd());
+ cleanupDeletionContext();
+ }
+
+ if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength()) {
+ /* when removing old nodes the creation context should be set up based on them
+ * else creation context is that of the new nodes
+ */
+ if( oldStructuredDocumentRegions != null && oldStructuredDocumentRegions.getLength() < 0) {
+ setupCreationContext(oldStructuredDocumentRegions.item(0));
+ } else {
+ setupCreationContext(newStructuredDocumentRegions.item(0));
+ }
+ insertStructuredDocumentRegions(newStructuredDocumentRegions);
+ }
+
+ // make document hold whole structuredDocument
+ /*
+ * boolean bUpdate = false; IStructuredDocumentRegion flatNode;
+ * flatNode = fDocument.getFirstStructuredDocumentRegion(); bUpdate =
+ * bUpdate || (flatNode == null ||
+ * fStructuredDocumentWalker.isOldNode(flatNode) ||
+ * flatNode.getPrevious() != null); flatNode =
+ * fDocument.getLastStructuredDocumentRegion(); bUpdate = bUpdate ||
+ * (flatNode == null || fStructuredDocumentWalker.isOldNode(flatNode) ||
+ * flatNode.getNext() != null);
+ */
+ IStructuredDocument structuredDocument = fStructuredDocumentWalker.getStructuredDocument();
+ ((CSSStructuredDocumentRegionContainer)fDocument).setRangeStructuredDocumentRegion(structuredDocument.getFirstStructuredDocumentRegion(), structuredDocument.getLastStructuredDocumentRegion());
+ /* } */
+
+ // remove in official release
+ // CSSModelUtil.diagnoseTree(fDocument,
+ // fStructuredDocumentWalker.getStructuredDocument());
+ }
+
+ /**
+ *
+ */
+ void replaceRegions(IStructuredDocumentRegion flatNode, ITextRegionList newRegions, ITextRegionList oldRegions) {
+ if (flatNode == null) {
+ return;
+ }
+ if (newRegions == null || oldRegions == null) {
+ return;
+ }
+ if (fDocument == null) {
+ return;
+ }
+
+ changeStructuredDocumentRegion(flatNode);
+ }
+
+ /**
+ */
+ private void resetCreationTarget(IStructuredDocumentRegion newStructuredDocumentRegion) {
+ if (newStructuredDocumentRegion == null || newStructuredDocumentRegion.getStartOffset() <= 0) {
+ // top of document
+ fCreationContext.setTargetNode(fDocument);
+ fCreationContext.setNextNode(fDocument.getFirstChild());
+ return;
+ }
+
+ int cursorPos = newStructuredDocumentRegion.getStartOffset();
+ CSSNodeImpl cursorNode = getNodeAt(cursorPos);
+ if (cursorNode == null) { // end of document
+ cursorNode = (CSSNodeImpl)fDocument;
+ }
+
+ // find edge of tree node
+ CSSNodeImpl node = null;
+ // boolean bOverSemiColon = false;
+ boolean bOverOpenBrace = false;
+ IStructuredDocumentRegion flatNode;
+ for (flatNode = newStructuredDocumentRegion; flatNode != null; flatNode = flatNode.getPrevious()) {
+ node = getNodeAt(flatNode.getStartOffset());
+ if (node == null) {
+ node = (CSSNodeImpl)fDocument;
+ }
+ if (node != cursorNode || node.getStartOffset() == flatNode.getStartOffset()) {
+ break;
+ }
+ if (flatNode != newStructuredDocumentRegion) {
+ String type = CSSUtil.getStructuredDocumentRegionType(flatNode);
+ // if (type == CSSRegionContexts.CSS_DELIMITER ||
+ // type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ // bOverSemiColon = true;
+ // } else
+ if (type == CSSRegionContexts.CSS_LBRACE) {
+ bOverOpenBrace = true;
+ }
+ }
+ }
+
+ CSSNodeImpl targetNode = null;
+
+ // if (flatNode == null) {
+ // v<--|
+ // AAAAAA
+ // BBBBBBBBBB cursorNode:A , node:B -> target is A
+ // targetNode = (node == null) ? fDocument : node;
+ // } else
+ if (cursorNode == node) {
+ // v<--|
+ // AAAAAA
+ // BBBBBBBBBB cursorNode:A , node:B -> target is A
+ if (bOverOpenBrace && cursorNode instanceof CSSRuleDeclContainer) {
+ targetNode = (CSSNodeImpl) ((CSSRuleDeclContainer) cursorNode).getStyle();
+ }
+ else {
+ targetNode = cursorNode;
+ }
+ }
+ else {
+ // v<--|
+ // AAA
+ // BBBBBBBBBB cursorNode:B , node:A -> depend on A's node type
+ short nodeType = node.getNodeType();
+ if (nodeType == ICSSNode.STYLEDECLITEM_NODE || nodeType == ICSSNode.CHARSETRULE_NODE || nodeType == ICSSNode.IMPORTRULE_NODE) {
+ // targetNode = (CSSNodeImpl)((bOverSemiColon) ?
+ // node.getParentNode() : node); // NP
+ String regionType = CSSUtil.getStructuredDocumentRegionType(flatNode);
+ if (regionType == CSSRegionContexts.CSS_DELIMITER || regionType == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ targetNode = (CSSNodeImpl) node.getParentNode();
+ }
+ else {
+ targetNode = node;
+ }
+ }
+ else if (CSSUtil.getStructuredDocumentRegionType(flatNode) == CSSRegionContexts.CSS_RBRACE) {
+ targetNode = (CSSNodeImpl) node.getParentNode();
+ }
+ else {
+ targetNode = node;
+ }
+ }
+
+ fCreationContext.setTargetNode(targetNode);
+ ICSSNode next = null;
+ if (targetNode.hasChildNodes()) {
+ for (ICSSNode child = targetNode.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof CSSStructuredDocumentRegionContainer && cursorPos < ((CSSStructuredDocumentRegionContainer) child).getStartOffset()) {
+ next = child;
+ break;
+ }
+ }
+ }
+ fCreationContext.setNextNode(next);
+
+ }
+
+ /**
+ */
+ private void resetReparseRange() {
+ fCreationContext.clear();
+ }
+
+ void setStructuredDocumentEvent(StructuredDocumentEvent event) {
+ if (fStructuredDocumentWalker == null) {
+ fStructuredDocumentWalker = new StructuredDocumentWalker();
+ }
+ fStructuredDocumentWalker.initialize(event);
+ }
+
+ /**
+ * regions: surrounding spaces should be removed. Q. Why did you set
+ * mediaTable ? A. MediaList may have two or more medium that have same
+ * value, then searcing in MediaList is not perfect. Q.
+ * fUpdateContext.isActive() is not care. Are you OK? A. OK.
+ */
+ private void setMediaList(MediaListImpl mediaList, IStructuredDocumentRegion region, ITextRegionList textRegions) {
+ if (mediaList == null || textRegions == null) {
+ return;
+ }
+ Collection mediaTable = new HashSet();
+ CSSNodeListImpl attrs = mediaList.getMedia();
+ for (int i = 0; i != attrs.getLength(); i++) {
+ mediaTable.add(attrs.item(i));
+ }
+
+ ITextRegion start = null;
+ ITextRegion end = null;
+
+ Iterator i = textRegions.iterator();
+ ITextRegion textRegion = (ITextRegion) ((i.hasNext()) ? i.next() : null);
+ while (textRegion != null) {
+ if (textRegion.getType() == CSSRegionContexts.CSS_MEDIUM) {
+ String mediumStr = region.getText(textRegion);
+ if (0 < mediumStr.length()) {
+ CSSAttrImpl attr = null;
+ // is the medium already set ?
+ Iterator iTable = mediaTable.iterator();
+ while (iTable.hasNext()) {
+ CSSAttrImpl cai = (CSSAttrImpl) iTable.next();
+ if (mediumStr.equalsIgnoreCase(cai.getValue())) {
+ attr = cai;
+ mediaTable.remove(cai);
+ break;
+ }
+ }
+ if (attr == null) {
+ // is not set. create new attribute
+ String key = "mediumP" + mediaList.mediumCounter++; //$NON-NLS-1$
+ mediaList.setAttribute(key, mediumStr);
+ attr = mediaList.getAttributeNode(key);
+ }
+ attr.setRangeRegion(region, textRegion, textRegion);
+ if (start == null) {
+ start = textRegion;
+ }
+ end = textRegion;
+ }
+ }
+ textRegion = (ITextRegion) ((i.hasNext()) ? i.next() : null);
+ }
+
+ if (start != null && end != null) {
+ mediaList.setRangeRegion(region, start, end);
+ }
+ }
+
+ /**
+ *
+ */
+ private void setupCreationContext(IStructuredDocumentRegion region) {
+ resetReparseRange();
+ resetCreationTarget(region);
+ }
+
+ /**
+ *
+ */
+ private void setupDeletionContext(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
+ fDeletionContext.setupContext(newStructuredDocumentRegions, oldStructuredDocumentRegions);
+ }
+
+ /**
+ *
+ */
+ void setupUpdateContext(short updateMode, ICSSNode parentNode, ICSSNode targetNode) {
+ fUpdateContext.setupContext(updateMode, parentNode, targetNode);
+ }
+
+ /**
+ *
+ */
+ void shrinkContainer(CSSStructuredDocumentRegionContainer parent, CSSStructuredDocumentRegionContainer child) {
+ if (child == null) {
+ return;
+ }
+
+ boolean bModified = false;
+ bModified = bModified || cleanupLastNode(child.getLastStructuredDocumentRegion(), parent);
+ bModified = bModified || cleanupFirstNode(child.getFirstStructuredDocumentRegion(), parent);
+
+ if (bModified) {
+ if (parent != null) {
+ for (ICSSNode node = parent.getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (child != node && node instanceof CSSStructuredDocumentRegionContainer) {
+ ((CSSStructuredDocumentRegionContainer) node).propagateRangeStructuredDocumentRegion();
+ }
+ }
+ }
+ }
+
+ child.setRangeStructuredDocumentRegion(null, null);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java
new file mode 100644
index 0000000..e7f4e93
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdateContext.java
@@ -0,0 +1,416 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.LinkedList;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.util.AbstractCssTraverser;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSPrimitiveValue;
+
+
+/**
+ *
+ */
+class CSSModelUpdateContext {
+
+
+ class CSSNodeUpdateTraverser extends AbstractCssTraverser {
+ public CSSNodeUpdateTraverser() {
+ super();
+ setTraverseImported(false);
+ setTraverseImportFirst(false);
+ }
+
+ public LinkedList getNodeList() {
+ return fTravNodeList;
+ }
+
+ protected void begin(ICSSNode node) {
+ fTravNodeList = new LinkedList();
+ }
+
+ protected short preNode(ICSSNode node) {
+ if (node instanceof CSSStyleDeclarationImpl || node instanceof CSSAttrImpl || node instanceof MediaListImpl) {
+ // skip
+ }
+ else {
+ fTravNodeList.add(node);
+ }
+ if (node instanceof CSSPrimitiveContainer) {
+ return TRAV_PRUNE;
+ }
+ else {
+ return TRAV_CONT;
+ }
+ }
+
+ LinkedList fTravNodeList = null;
+ }
+
+ ICSSNode fLastNode = null;
+ ICSSNode fDeletionTargetParent = null;
+ ICSSNode fDeletionTarget = null;
+ LinkedList fNodeList = null;
+ private short fUpdateMode = UPDATE_IDLE;
+ static final short UPDATE_IDLE = 0;
+ static final short UPDATE_INSERT_FNCONTAINER = 1;
+ static final short UPDATE_INSERT_RCONTAINER = 2;
+ static final short UPDATE_REMOVE_FNCONTAINER = 3;
+ static final short UPDATE_REMOVE_RCONTAINER = 4;
+ static final short UPDATE_CHANGE_RCONTAINER = 5;
+
+ /**
+ * CSSNodeUpdateQueue constructor comment.
+ */
+ CSSModelUpdateContext() {
+ super();
+ }
+
+ /**
+ *
+ */
+ void cleanupContext() {
+ fNodeList = null;
+ fDeletionTarget = null;
+ fDeletionTargetParent = null;
+ fUpdateMode = UPDATE_IDLE;
+ }
+
+ /**
+ *
+ */
+ CounterImpl getCounter() {
+ ICSSNode node = getNode();
+ if (node instanceof CounterImpl) {
+ return (CounterImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CounterImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSCharsetRuleImpl getCSSCharsetRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSCharsetRuleImpl) {
+ return (CSSCharsetRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSCharsetRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSFontFaceRuleImpl getCSSFontFaceRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSFontFaceRuleImpl) {
+ return (CSSFontFaceRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSFontFaceRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSImportRuleImpl getCSSImportRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSImportRuleImpl) {
+ return (CSSImportRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSImportRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSMediaRuleImpl getCSSMediaRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSMediaRuleImpl) {
+ return (CSSMediaRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSMediaRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSPageRuleImpl getCSSPageRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSPageRuleImpl) {
+ return (CSSPageRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSPageRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSPrimitiveValueImpl getCSSPrimitiveValue(short type) {
+ ICSSNode node = getNode();
+ if (node instanceof CSSPrimitiveValueImpl) {
+ short nodeType = ((CSSPrimitiveValueImpl) node).getPrimitiveType();
+ if (nodeType == type || ((nodeType == CSSPrimitiveValue.CSS_NUMBER || nodeType == ICSSPrimitiveValue.CSS_INTEGER) && (type == CSSPrimitiveValue.CSS_NUMBER || type == ICSSPrimitiveValue.CSS_INTEGER))) {
+ return (CSSPrimitiveValueImpl) node;
+ }
+ }
+
+ if (node instanceof CSSPrimitiveValueImpl) {
+ CSSPrimitiveValueImpl value = (CSSPrimitiveValueImpl) node;
+ CSSUtil.debugOut("CSSPrimitiveValueImpl [" + type + //$NON-NLS-1$
+ "] is expected, but type is [" + //$NON-NLS-1$
+ value.getPrimitiveType() + "]: \"" + value.generateSource() + "\"");//$NON-NLS-2$//$NON-NLS-1$
+ }
+ else {
+ CSSUtil.debugOut("CSSPrimitiveValueImpl(" + type + //$NON-NLS-1$
+ ") is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ }
+
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ CSSPrimitiveValueImpl getCSSPrimitiveValueAny() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSPrimitiveValueImpl) {
+ return (CSSPrimitiveValueImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSPrimitiveValueImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSStyleDeclItemImpl getCSSStyleDeclItem(String propertyName) {
+ ICSSNode node = getNode();
+ if (node instanceof CSSStyleDeclItemImpl && ((CSSStyleDeclItemImpl) node).getPropertyName().equalsIgnoreCase(propertyName)) {
+ return (CSSStyleDeclItemImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSStyleDeclItemImpl(" + propertyName + //$NON-NLS-1$
+ ") is expected, but " + CSSUtil.getClassString(node));//$NON-NLS-1$
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ CSSStyleRuleImpl getCSSStyleRule() {
+ ICSSNode node = getNode();
+ if (node instanceof CSSStyleRuleImpl) {
+ return (CSSStyleRuleImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("CSSStyleRuleImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ ICSSNode getDeletionTarget() {
+ return fDeletionTarget;
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ ICSSNode getDeletionTargetParent() {
+ return fDeletionTargetParent;
+ }
+
+ /**
+ *
+ */
+ private ICSSNode getNode() {
+ ICSSNode node = null;
+ if (fNodeList != null && 0 < fNodeList.size()) {
+ node = (ICSSNode) fNodeList.removeFirst();
+ }
+ fLastNode = node;
+ return node;
+ }
+
+ /**
+ *
+ */
+ int getNodeCount() {
+ if (fNodeList != null) {
+ return fNodeList.size();
+ }
+ else {
+ return -1;
+ }
+ }
+
+ /**
+ *
+ */
+ // ICSSNode getParentNode() {
+ // return fParentNode;
+ // }
+ /**
+ *
+ */
+ RectImpl getRect() {
+ ICSSNode node = getNode();
+ if (node instanceof RectImpl) {
+ return (RectImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("RectImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ RGBColorImpl getRGBColor() {
+ ICSSNode node = getNode();
+ if (node instanceof RGBColorImpl) {
+ return (RGBColorImpl) node;
+ }
+ else {
+ CSSUtil.debugOut("RGBColorImpl is expected, but " + //$NON-NLS-1$
+ CSSUtil.getClassString(node));
+ ungetNode();
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return short
+ */
+ short getUpdateMode() {
+ return fUpdateMode;
+ }
+
+ /**
+ *
+ */
+ boolean isActive() {
+ return (fNodeList != null);
+ }
+
+ /**
+ *
+ */
+ void setupContext(short updateMode, ICSSNode parentNode, ICSSNode targetNode) {
+ fUpdateMode = updateMode;
+
+ ICSSNode traverseRoot;
+ if (updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_CHANGE_RCONTAINER) {
+ traverseRoot = parentNode;
+ while (traverseRoot instanceof CSSRegionContainer) {
+ traverseRoot = traverseRoot.getParentNode();
+ }
+ }
+ else {
+ traverseRoot = targetNode;
+ }
+
+ if (updateMode == UPDATE_REMOVE_RCONTAINER || updateMode == UPDATE_INSERT_RCONTAINER || // region
+ // insert
+ // =>
+ // replace
+ // flat
+ // node
+ updateMode == UPDATE_CHANGE_RCONTAINER || updateMode == UPDATE_REMOVE_FNCONTAINER) {
+ fDeletionTarget = traverseRoot;
+ if (fDeletionTarget == targetNode) {
+ fDeletionTargetParent = parentNode;
+ }
+ else {
+ fDeletionTargetParent = fDeletionTarget.getParentNode();
+ }
+ }
+ else {
+ fDeletionTarget = null;
+ fDeletionTargetParent = null;
+ }
+
+ if (updateMode == UPDATE_INSERT_RCONTAINER || updateMode == UPDATE_INSERT_FNCONTAINER || updateMode == UPDATE_REMOVE_RCONTAINER || // region
+ // remove
+ // =>
+ // re-insert
+ // flat
+ // node
+ updateMode == UPDATE_CHANGE_RCONTAINER) {
+ CSSNodeUpdateTraverser traverser = new CSSNodeUpdateTraverser();
+ traverser.apply(traverseRoot);
+ fNodeList = traverser.getNodeList();
+ }
+ else {
+ fNodeList = null;
+ }
+ }
+
+ /**
+ *
+ */
+ private void ungetNode() {
+ if (fNodeList != null && fLastNode != null) {
+ fNodeList.addFirst(fLastNode);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java
new file mode 100644
index 0000000..5bb8a8b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUpdater.java
@@ -0,0 +1,518 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.formatter.AttrChangeContext;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
+
+
+/**
+ *
+ */
+class CSSModelUpdater {
+
+ private CSSModelImpl fModel = null;
+ private CSSModelParser fParser = null;
+
+ /**
+ * CSSModelUpdater constructor comment.
+ */
+ CSSModelUpdater() {
+ super();
+ }
+
+ /**
+ *
+ */
+ CSSModelUpdater(CSSModelImpl model) {
+ super();
+ fModel = model;
+ }
+
+ /**
+ * @param parentNode
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private void attrInserted(CSSNodeImpl parentNode, CSSAttrImpl attr) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode);
+
+ if (formatter == null) {
+ CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());//$NON-NLS-1$
+ return;
+ }
+
+ short updateMode = CSSModelUpdateContext.UPDATE_INSERT_RCONTAINER;
+ fParser.setupUpdateContext(updateMode, parentNode, attr);
+
+ // get formatted info
+ AttrChangeContext region = new AttrChangeContext();
+ String text = new String(formatter.formatAttrChanged(parentNode, attr, true, region));
+
+ // set text
+ insertText(region.start, region.end - region.start, text);
+
+ fParser.cleanupUpdateContext();
+ }
+
+ /**
+ * @param parentNode
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private void attrRemoved(CSSNodeImpl parentNode, CSSAttrImpl attr) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode);
+
+ if (formatter == null) {
+ CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());//$NON-NLS-1$
+ return;
+ }
+
+ short updateMode = CSSModelUpdateContext.UPDATE_REMOVE_RCONTAINER;
+ fParser.setupUpdateContext(updateMode, parentNode, attr);
+
+ // get formatted info
+ AttrChangeContext region = new AttrChangeContext();
+ String text = new String(formatter.formatAttrChanged(parentNode, attr, false, region));
+
+ // set text
+ insertText(region.start, region.end - region.start, text);
+
+ fParser.cleanupUpdateContext();
+ }
+
+ /**
+ *
+ */
+ void attrReplaced(CSSNodeImpl parentNode, CSSNodeImpl newAttr, CSSNodeImpl oldAttr) {
+ if (parentNode == null) {
+ return;
+ }
+
+ if (oldAttr != null) {
+ attrRemoved(parentNode, (CSSAttrImpl) oldAttr);
+ }
+
+ if (newAttr != null) {
+ attrInserted(parentNode, (CSSAttrImpl) newAttr);
+ }
+ }
+
+ /**
+ *
+ */
+ private void childInserted(CSSNodeImpl parentNode, CSSNodeImpl node) {
+ short updateMode = CSSModelUpdateContext.UPDATE_IDLE;
+
+ if (node instanceof CSSStructuredDocumentRegionContainer) {
+ updateMode = CSSModelUpdateContext.UPDATE_INSERT_FNCONTAINER;
+ }
+ else if (node instanceof CSSRegionContainer) {
+ updateMode = CSSModelUpdateContext.UPDATE_INSERT_RCONTAINER;
+ }
+ else {
+ CSSUtil.debugOut("What's this node? : " + node.getClass().toString());//$NON-NLS-1$
+ return;
+ }
+
+ fParser.setupUpdateContext(updateMode, parentNode, node);
+
+ defaultInserted(parentNode, node);
+
+ fParser.cleanupUpdateContext();
+ }
+
+ /**
+ *
+ */
+ private void childRemoved(CSSNodeImpl parentNode, CSSNodeImpl node) {
+ short updateMode = CSSModelUpdateContext.UPDATE_IDLE;
+
+ if (node instanceof CSSStructuredDocumentRegionContainer) {
+ updateMode = CSSModelUpdateContext.UPDATE_REMOVE_FNCONTAINER;
+ }
+ else if (node instanceof CSSRegionContainer) {
+ updateMode = CSSModelUpdateContext.UPDATE_REMOVE_RCONTAINER;
+ }
+ else {
+ CSSUtil.debugOut("What's this node? : " + node.getClass().toString());//$NON-NLS-1$
+ return;
+ }
+
+ fParser.setupUpdateContext(updateMode, parentNode, node);
+
+ CSSNodeImpl prev = getOldPrevious(parentNode, node);
+ CSSNodeImpl next = getOldNext(parentNode, node);
+ int insertPos = -1, endPos = -1;
+ String source = "";//$NON-NLS-1$
+ if (prev != null) {
+ insertPos = prev.getEndOffset();
+ }
+ else {
+ insertPos = node.getStartOffset();
+ insertPos -= nearestSpaceLengthBefore(parentNode, insertPos);
+ }
+ if (next != null) {
+ endPos = next.getStartOffset();
+ }
+ else {
+ endPos = node.getEndOffset();
+ endPos += nearestSpaceLengthAfter(parentNode, endPos);
+ }
+ source = getSpaceBefore(parentNode, next, node);
+ if (source.length() > 0) {
+ insertText(insertPos, endPos - insertPos, source);
+ }
+ else {
+ removeText(insertPos, endPos - insertPos);
+ }
+
+ fParser.cleanupUpdateContext();
+ }
+
+ /**
+ *
+ */
+ void childReplaced(CSSNodeImpl parentNode, CSSNodeImpl newChild, CSSNodeImpl oldChild) {
+ if (parentNode == null) {
+ return;
+ }
+
+ if (oldChild != null) {
+ childRemoved(parentNode, oldChild);
+ }
+
+ if (newChild != null) {
+ childInserted(parentNode, newChild);
+ }
+ }
+
+ /**
+ *
+ */
+ private StructuredDocumentEvent defaultInserted(CSSNodeImpl parentNode, CSSNodeImpl node) {
+ int insertPos = -1;
+ ICSSNode sibling;
+ String preSpace = "", postSpace = "";//$NON-NLS-2$//$NON-NLS-1$
+ int length = 0;
+
+ if (insertPos < 0) {
+ if ((sibling = node.getPreviousSibling()) != null) {
+ // after previous child
+ insertPos = getTextEnd(sibling);
+ }
+ }
+
+ if (insertPos < 0) {
+ if ((sibling = node.getNextSibling()) != null) {
+ // before next child
+ insertPos = getTextStart(sibling);
+ }
+ }
+
+ if (insertPos < 0) {
+ // position of parent
+ insertPos = getChildInsertPos(parentNode);
+ }
+
+ if (insertPos < 0) {
+ // firsttime
+ insertPos = 0;
+ }
+
+ // format previous spaces
+ length = nearestSpaceLengthBefore(parentNode, insertPos);
+ insertPos -= length;
+ preSpace = getSpaceBefore(parentNode, node, null);
+ // format post spaces
+ length += nearestSpaceLengthAfter(parentNode, insertPos + length);
+ postSpace = getSpaceBefore(parentNode, node.getNextSibling(), null);
+
+ // set text
+ String text = preSpace + node.generateSource().trim() + postSpace;
+ return insertText(insertPos, length, text);
+ }
+
+ /**
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private int getChildInsertPos(CSSNodeImpl node) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node);
+ if (formatter != null)
+ return formatter.getChildInsertPos(node);
+ else
+ return node.getEndOffset();
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param parentNode
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private CSSNodeImpl getOldNext(CSSNodeImpl parentNode, CSSNodeImpl node) {
+ CSSNodeImpl child = (CSSNodeImpl) parentNode.getLastChild();
+ CSSNodeImpl ret = null;
+ while (child != null) {
+ if (node.getEndOffset() < child.getEndOffset())
+ ret = child;
+ else
+ break;
+ child = (CSSNodeImpl) child.getPreviousSibling();
+ }
+ return ret;
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param parentNode
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private CSSNodeImpl getOldPrevious(CSSNodeImpl parentNode, CSSNodeImpl node) {
+ CSSNodeImpl child = (CSSNodeImpl) parentNode.getFirstChild();
+ CSSNodeImpl ret = null;
+ while (child != null) {
+ if (child.getStartOffset() < node.getStartOffset())
+ ret = child;
+ else
+ break;
+ child = (CSSNodeImpl) child.getNextSibling();
+ }
+ return ret;
+ }
+
+ /**
+ * @return java.lang.String
+ * @param parentNode
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ * @param node
+ * org.eclipse.wst.css.core.model.CSSNodeImpl
+ */
+ private String getSpaceBefore(ICSSNode parentNode, ICSSNode node, ICSSNode toRemove) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) parentNode);
+
+ if (formatter != null) {
+ org.eclipse.jface.text.IRegion exceptFor = null;
+ if (toRemove != null) {
+ CSSNodeImpl remove = (CSSNodeImpl) toRemove;
+ exceptFor = new org.eclipse.jface.text.Region(remove.getStartOffset(), remove.getEndOffset() - remove.getStartOffset());
+ }
+ return formatter.formatBefore(parentNode, node, exceptFor).toString();
+ }
+ else
+ return "";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ private int getTextEnd(ICSSNode node) {
+ int end = -1;
+ if (node != null) {
+ if (node instanceof CSSStructuredDocumentRegionContainer) {
+ end = ((CSSStructuredDocumentRegionContainer) node).getEndOffset();
+ }
+ else if (node instanceof CSSRegionContainer) {
+ end = ((CSSRegionContainer) node).getEndOffset();
+ }
+ }
+ return end;
+ }
+
+ /**
+ *
+ */
+ private int getTextStart(ICSSNode node) {
+ int start = -1;
+ if (node != null) {
+ if (node instanceof CSSStructuredDocumentRegionContainer) {
+ start = ((CSSStructuredDocumentRegionContainer) node).getStartOffset();
+ }
+ else if (node instanceof CSSRegionContainer) {
+ start = ((CSSRegionContainer) node).getStartOffset();
+ }
+ }
+ return start;
+ }
+
+ /**
+ *
+ */
+ private StructuredDocumentEvent insertText(int start, int oldLength, String text) {
+ StructuredDocumentEvent result = null;
+ BasicStructuredDocument structuredDocument = (BasicStructuredDocument) fModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ if (text != null && 0 < oldLength && start + oldLength <= structuredDocument.getLength()) {
+ // minimize text change
+ String delText = structuredDocument.get(start, oldLength);
+ int newLength = text.length();
+ int shorterLen = Math.min(oldLength, newLength);
+ int stMatchLen;
+ for (stMatchLen = 0; stMatchLen < shorterLen && text.charAt(stMatchLen) == delText.charAt(stMatchLen); stMatchLen++) {
+ //
+ }
+ if (0 < stMatchLen && stMatchLen < shorterLen && text.charAt(stMatchLen - 1) == 0x000d && (text.charAt(stMatchLen) == 0x000a || delText.charAt(stMatchLen) == 0x000a)) {
+ // must not divide 0d->0a sequence
+ stMatchLen--;
+ }
+ if (stMatchLen == shorterLen) {
+ if (oldLength < newLength) { // just insert
+ oldLength = 0;
+ start += stMatchLen;
+ text = text.substring(stMatchLen);
+ }
+ else if (newLength < oldLength) { // just remove
+ oldLength -= stMatchLen;
+ start += stMatchLen;
+ text = null;
+ }
+ else { // nothing to do
+ oldLength = 0;
+ text = null;
+ }
+ }
+ else {
+ int edMatchLen;
+ for (edMatchLen = 0; stMatchLen + edMatchLen < shorterLen && text.charAt(newLength - edMatchLen - 1) == delText.charAt(oldLength - edMatchLen - 1); edMatchLen++) {
+ //
+ }
+ if (0 < edMatchLen && text.charAt(newLength - edMatchLen) == 0x000a && ((edMatchLen < newLength && text.charAt(newLength - edMatchLen - 1) == 0x000d) || (edMatchLen < oldLength && delText.charAt(oldLength - edMatchLen - 1) == 0x000d))) {
+ // must not divide 0d->0a sequence
+ edMatchLen--;
+ }
+ oldLength -= stMatchLen + edMatchLen;
+ start += stMatchLen;
+ if (stMatchLen + edMatchLen < newLength) {
+ text = text.substring(stMatchLen, newLength - edMatchLen);
+ }
+ else {
+ text = null;
+ }
+ }
+ }
+ if (0 < oldLength || text != null) {
+ // String delText = structuredDocument.get(start, oldLength);
+ result = structuredDocument.replaceText(fModel, start, oldLength, text);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @return int
+ * @param insertPos
+ * int
+ */
+ private int nearestSpaceLengthAfter(CSSNodeImpl node, int insertPos) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node);
+ if (formatter != null) {
+ return formatter.getLengthToReformatAfter(node, insertPos);
+ }
+ else
+ return 0;
+ }
+
+ /**
+ * @return int
+ * @param insertPos
+ * int
+ */
+ private int nearestSpaceLengthBefore(CSSNodeImpl node, int insertPos) {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(node);
+ if (formatter != null) {
+ return formatter.getLengthToReformatBefore(node, insertPos);
+ }
+ else
+ return 0;
+ }
+
+ /**
+ *
+ */
+ private StructuredDocumentEvent removeText(int start, int length) {
+ StructuredDocumentEvent result = null;
+ IStructuredDocument structuredDocument = fModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ result = structuredDocument.replaceText(fModel, start, length, new String(""));//$NON-NLS-1$
+ }
+ return result;
+ }
+
+ /**
+ *
+ */
+ void setParser(CSSModelParser parser) {
+ fParser = parser;
+ }
+
+ /**
+ *
+ */
+ void valueChanged(CSSNodeImpl node, String oldValue) {
+ if (!(node instanceof CSSRegionContainer)) {
+ CSSUtil.debugOut("Too Bad.." + //$NON-NLS-1$
+ ((node == null) ? "null" : node.getClass().toString()));//$NON-NLS-1$
+ return;
+ }
+
+ int start = node.getStartOffset();
+
+ if (node.getNodeType() == ICSSNode.ATTR_NODE) {
+ ICSSAttr attr = (ICSSAttr) node;
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) attr.getOwnerCSSNode());
+ if (formatter != null)
+ start = formatter.getAttrInsertPos(attr.getOwnerCSSNode(), attr.getName());
+ }
+
+ int oldLength = (oldValue == null) ? 0 : oldValue.length();
+ // flash old IStructuredDocumentRegion/ITextRegion
+ if (node instanceof CSSStructuredDocumentRegionContainer) {
+ ((CSSStructuredDocumentRegionContainer) node).setFirstStructuredDocumentRegion(null);
+ ((CSSStructuredDocumentRegionContainer) node).setLastStructuredDocumentRegion(null);
+ }
+ else if (node instanceof CSSRegionContainer) {
+ ((CSSRegionContainer) node).setRangeRegion(null, null, null);
+ }
+ // generate new source
+ String newValue = node.generateSource();
+
+ ICSSNode parent;
+ if (node.getNodeType() == ICSSNode.ATTR_NODE) {
+ parent = ((ICSSAttr) node).getOwnerCSSNode();
+ }
+ else {
+ parent = node.getParentNode();
+ }
+
+ fParser.setupUpdateContext(CSSModelUpdateContext.UPDATE_CHANGE_RCONTAINER, parent, node);
+
+ insertText(start, oldLength, newValue);
+
+ fParser.cleanupUpdateContext();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java
new file mode 100644
index 0000000..d87b011
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelUtil.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+/**
+ *
+ */
+class CSSModelUtil {
+
+ /**
+ *
+ */
+ static boolean canContainBrace(ICSSNode node) {
+ return (node != null && (node instanceof ICSSRuleContainer || node instanceof CSSRuleDeclContainer)) ? true : false;
+ }
+
+ /**
+ * @param parent
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ static void cleanupContainer(ICSSNode parent) {
+ if (parent == null) {
+ return;
+ }
+ for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
+ cleanupContainer(child);
+ }
+ if (parent instanceof CSSStructuredDocumentRegionContainer) {
+ ((CSSStructuredDocumentRegionContainer) parent).setRangeStructuredDocumentRegion(null, null);
+ }
+ else if (parent instanceof CSSRegionContainer) {
+ ((CSSRegionContainer) parent).setRangeRegion(null, null, null);
+ }
+ }
+
+ static boolean diagnoseNode(ICSSNode parent, IStructuredDocument structuredDocument) {
+ // check this
+ Vector errors = new Vector();
+ if (parent instanceof CSSStructuredDocumentRegionContainer) {
+ CSSStructuredDocumentRegionContainer node = (CSSStructuredDocumentRegionContainer) parent;
+ String nodeText = CSSUtil.getClassString(node) + ": ";//$NON-NLS-1$
+ IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
+ if (flatNode == null && (!(node instanceof CSSStyleDeclarationImpl || node instanceof CSSStyleSheetImpl) || node.getFirstChild() != null)) {
+ errors.add(nodeText + "first flat node is null."); //$NON-NLS-1$
+ }
+ else if (flatNode != null) {
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(flatNode.getStart());
+ if (flatNode != modelNode) {
+ errors.add(nodeText + "first flat node is not in model."); //$NON-NLS-1$
+ }
+ }
+ flatNode = node.getLastStructuredDocumentRegion();
+ if (flatNode == null && (!(node instanceof CSSStyleDeclarationImpl || node instanceof CSSStyleSheetImpl) || node.getFirstChild() != null)) {
+ errors.add(nodeText + "last flat node is null."); //$NON-NLS-1$
+ }
+ else if (flatNode != null) {
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(flatNode.getStart());
+ if (flatNode != modelNode) {
+ errors.add(nodeText + "last flat node is not in model."); //$NON-NLS-1$
+ }
+ }
+ }
+ else if (parent instanceof CSSRegionContainer) {
+ CSSRegionContainer node = (CSSRegionContainer) parent;
+ String nodeText = CSSUtil.getClassString(node) + ": ";//$NON-NLS-1$
+ ITextRegion region = node.getFirstRegion();
+ IStructuredDocumentRegion parentRegion = node.getDocumentRegion();
+ if (region == null && (!(node instanceof MediaListImpl) || node.getFirstChild() != null)) {
+ errors.add(nodeText + "first region is null."); //$NON-NLS-1$
+ }
+ else if (region != null) {
+ int offset = parentRegion.getStartOffset(region);
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset);
+ ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset);
+ if (region != modelRegion) {
+ errors.add(nodeText + "first region is not in model."); //$NON-NLS-1$
+ }
+ }
+ region = node.getLastRegion();
+ if (region == null && (!(node instanceof MediaListImpl) || node.getFirstChild() != null)) {
+ errors.add(nodeText + "last region is null."); //$NON-NLS-1$
+ }
+ else if (region != null) {
+ int offset = parentRegion.getStartOffset(region);
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset);
+ ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset);
+ if (region != modelRegion) {
+ errors.add(nodeText + "last region is not in model."); //$NON-NLS-1$
+ }
+ }
+ }
+
+ ICSSNodeList attrs = parent.getAttributes();
+ int nAttrs = attrs.getLength();
+ for (int i = 0; i < nAttrs; i++) {
+ ICSSAttr attr = (ICSSAttr) attrs.item(i);
+ CSSRegionContainer node = (CSSRegionContainer) attr;
+ String nodeText = CSSUtil.getClassString(node) + "(" + attr.getName() + "): ";//$NON-NLS-2$//$NON-NLS-1$
+ ITextRegion region = node.getFirstRegion();
+ IStructuredDocumentRegion parentRegion = node.getDocumentRegion();
+ if (region == null && 0 < attr.getValue().length()) {
+ errors.add(nodeText + "first region is null."); //$NON-NLS-1$
+ }
+ else if (region != null) {
+ int offset = parentRegion.getStartOffset(region);
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset);
+ ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset);
+ if (region != modelRegion) {
+ errors.add(nodeText + "first region is not in model."); //$NON-NLS-1$
+ }
+ }
+ region = node.getLastRegion();
+ if (region == null && 0 < attr.getValue().length()) {
+ errors.add(nodeText + "last region is null."); //$NON-NLS-1$
+ }
+ else if (region != null) {
+ int offset = parentRegion.getStartOffset(region);
+ IStructuredDocumentRegion modelNode = structuredDocument.getRegionAtCharacterOffset(offset);
+ ITextRegion modelRegion = modelNode.getRegionAtCharacterOffset(offset);
+ if (region != modelRegion) {
+ errors.add(nodeText + "last region is not in model."); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (!errors.isEmpty()) {
+ Iterator i = errors.iterator();
+ while (i.hasNext()) {
+ CSSUtil.debugOut((String) i.next());
+ }
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * @return boolean
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ static boolean diagnoseTree(ICSSNode parent, IStructuredDocument structuredDocument) {
+ if (parent == null) {
+ return false;
+ }
+ // check children
+ for (ICSSNode child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
+ diagnoseTree(child, structuredDocument);
+ }
+
+ diagnoseNode(parent, structuredDocument);
+
+ return true;
+ }
+
+ /**
+ * If needed, modify last flat node
+ */
+ static void expandStructuredDocumentRegionContainer(CSSStructuredDocumentRegionContainer target, IStructuredDocumentRegion flatNode) {
+ if (target == null || flatNode == null) {
+ return;
+ }
+
+ IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion();
+ if (lastNode == flatNode) {
+ return;
+ }
+ if (lastNode == null || lastNode.getStart() < flatNode.getStart()) {
+ target.setLastStructuredDocumentRegion(flatNode);
+ }
+ }
+
+ /*
+ *
+ */
+ static ICSSNode findBraceContainer(ICSSNode node) {
+ for (ICSSNode i = node; i != null; i = i.getParentNode()) {
+ if (CSSModelUtil.canContainBrace(i)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ static int getDepth(ICSSNode node) {
+ int depth = -1;
+ while (node != null) {
+ depth++;
+ node = node.getParentNode();
+ }
+ return depth;
+ }
+
+ /**
+ *
+ */
+ static boolean isBraceClosed(ICSSNode node) {
+ boolean bClosed = true;
+ if (!(node instanceof CSSStructuredDocumentRegionContainer)) {
+ return bClosed;
+ }
+
+ IStructuredDocumentRegion first = ((CSSStructuredDocumentRegionContainer) node).getFirstStructuredDocumentRegion();
+ IStructuredDocumentRegion last = ((CSSStructuredDocumentRegionContainer) node).getLastStructuredDocumentRegion();
+ if (first == null || last == null) {
+ return bClosed;
+ }
+ if (last.getStart() < first.getStart()) {
+ return bClosed;
+ }
+
+ IStructuredDocumentRegion flatNode = first;
+ int nOpen = 0;
+ int nClose = 0;
+ do {
+ String type = CSSUtil.getStructuredDocumentRegionType(flatNode);
+ if (type == CSSRegionContexts.CSS_LBRACE) {
+ nOpen++;
+ }
+ else if (type == CSSRegionContexts.CSS_RBRACE) {
+ nClose++;
+ }
+ flatNode = flatNode.getNext();
+ }
+ while (flatNode != null && flatNode != last);
+
+ if ((nOpen == 0 && nClose == 0) || nClose < nOpen) {
+ bClosed = false;
+ }
+
+ return bClosed;
+ }
+
+ /**
+ * only for insertion..
+ */
+ static boolean isInterruption(CSSStructuredDocumentRegionContainer target, IStructuredDocumentRegion flatNode) {
+ if (target == null || flatNode == null) {
+ return false;
+ }
+ int start = flatNode.getStart();
+ IStructuredDocumentRegion firstNode = target.getFirstStructuredDocumentRegion();
+ IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion();
+ if (firstNode != null && firstNode.getStart() < start && lastNode != null && start < lastNode.getStart()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ static boolean isParentOf(ICSSNode parent, ICSSNode child) {
+ if (parent == null || child == null) {
+ return false;
+ }
+
+ for (ICSSNode node = child; node != null; node = node.getParentNode()) {
+ if (parent == node) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java
new file mode 100644
index 0000000..9d21149
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNamedNodeMapImpl.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+
+/**
+ *
+ */
+public class CSSNamedNodeMapImpl extends CSSNodeListImpl implements ICSSNamedNodeMap {
+
+ /**
+ * CSSNamedNodeMapImpl constructor comment.
+ */
+ CSSNamedNodeMapImpl() {
+ super();
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param name
+ * java.lang.String
+ */
+ public ICSSNode getNamedItem(String name) {
+ Iterator it = nodes.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj instanceof CSSAttrImpl && ((CSSAttrImpl) obj).getName().compareToIgnoreCase(name) == 0) {
+ return (ICSSNode) obj;
+ }
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java
new file mode 100644
index 0000000..0f37dac
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeImpl.java
@@ -0,0 +1,470 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNamedNodeMap;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList;
+import org.eclipse.wst.css.core.internal.util.ImportRuleCollector;
+import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
+import org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.w3c.dom.DOMException;
+
+
+/**
+ *
+ */
+public abstract class CSSNodeImpl extends AbstractNotifier implements ICSSNode, IndexedRegion {
+
+ private CSSDocumentImpl fOwnerDocument = null;
+ private CSSNodeImpl fParentNode = null;
+ private CSSNodeImpl fNextSibling = null;
+ private CSSNodeImpl fPreviousSibling = null;
+ private CSSNodeImpl fFirstChild = null;
+ private CSSNodeImpl fLastChild = null;
+ protected CSSNamedNodeMapImpl fAttrs = null;
+
+ /**
+ * CSSNodeImpl constructor comment.
+ */
+ CSSNodeImpl() {
+ super();
+ }
+
+ CSSNodeImpl(CSSNodeImpl that) {
+ if (that != null) {
+ this.fOwnerDocument = that.fOwnerDocument;
+ if (that.fAttrs != null) {
+ int nAttrs = that.fAttrs.getLength();
+ for (int i = 0; i < nAttrs; i++) {
+ CSSAttrImpl attr = (CSSAttrImpl) that.fAttrs.item(i);
+ setAttribute(attr.getName(), attr.getValue());
+ }
+ }
+ }
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSNodeImpl appendChild(CSSNodeImpl newChild) throws org.w3c.dom.DOMException {
+ return insertBefore(newChild, null);
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ protected void cloneChildNodes(ICSSNode newParent, boolean deep) {
+ if (newParent == null || newParent == this)
+ return;
+
+ CSSNodeImpl container = (CSSNodeImpl) newParent;
+ container.removeChildNodes();
+
+ for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) {
+ CSSNodeImpl cloned = (CSSNodeImpl) child.cloneNode(deep);
+ if (cloned != null)
+ container.appendChild(cloned);
+ }
+ }
+
+ /**
+ * @return boolean
+ * @param offset
+ * int
+ */
+ public boolean contains(int offset) {
+ return (getStartOffset() <= offset && offset < getEndOffset());
+ }
+
+ /**
+ *
+ * currently public but may be made default access protected in future.
+ *
+ * @return java.lang.String
+ */
+ protected String generateSource() {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(this);
+ return formatter.format(this).toString();
+ }
+
+ /**
+ *
+ * currently public but may be made default access protected in future.
+ *
+ * @return java.lang.String
+ * @param name
+ * java.lang.String
+ */
+ protected String getAttribute(String name) {
+ CSSAttrImpl attr = getAttributeNode(name);
+ if (attr != null)
+ return attr.getValue();
+ return null;
+ }
+
+ protected CSSAttrImpl getAttributeNode(String name) {
+ if (fAttrs == null)
+ return null;
+
+ int nAttrs = fAttrs.getLength();
+ for (int i = 0; i < nAttrs; i++) {
+ CSSAttrImpl attr = (CSSAttrImpl) fAttrs.item(i);
+ if (attr.matchName(name))
+ return attr;
+ }
+ return null;
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNamedNodeMap
+ */
+ public ICSSNamedNodeMap getAttributes() {
+ if (fAttrs == null)
+ fAttrs = new CSSNamedNodeMapImpl();
+ return fAttrs;
+ }
+
+ public ICSSNodeList getChildNodes() {
+ CSSNodeListImpl list = new CSSNodeListImpl();
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ list.appendNode(node);
+ }
+ return list;
+ }
+
+ ICSSNode getCommonAncestor(ICSSNode node) {
+ if (node == null)
+ return null;
+
+ for (ICSSNode na = node; na != null; na = na.getParentNode()) {
+ for (ICSSNode ta = this; ta != null; ta = ta.getParentNode()) {
+ if (ta == na)
+ return ta;
+ }
+ }
+
+ return null; // not found
+ }
+
+ CSSDocumentImpl getContainerDocument() {
+ for (ICSSNode node = this; node != null; node = node.getParentNode()) {
+ if (node instanceof CSSDocumentImpl) {
+ CSSDocumentImpl doc = (CSSDocumentImpl) node;
+ if (doc.isDocument())
+ return doc;
+ }
+ }
+ return null;
+ }
+
+ CSSNodeImpl getContainerNode(int offset) {
+ if (!contains(offset))
+ return null;
+
+ for (ICSSNode child = getFirstChild(); child != null; child = child.getNextSibling()) {
+ ICSSNode found = ((CSSNodeImpl) child).getContainerNode(offset);
+ if (found != null)
+ return (CSSNodeImpl) found;
+ }
+
+ return this;
+ }
+
+ /**
+ */
+ public FactoryRegistry getFactoryRegistry() {
+ ICSSModel model = getOwnerDocument().getModel();
+ if (model != null) {
+ FactoryRegistry reg = model.getFactoryRegistry();
+ if (reg != null)
+ return reg;
+ }
+ return null;
+ }
+
+ public ICSSNode getFirstChild() {
+ return this.fFirstChild;
+ }
+
+ public ICSSNode getLastChild() {
+ return this.fLastChild;
+ }
+
+ public ICSSNode getNextSibling() {
+ return this.fNextSibling;
+ }
+
+ ICSSNode getNodeAt(int offset) {
+ // the same as getContainerNode()
+ return getContainerNode(offset);
+ }
+
+ public ICSSDocument getOwnerDocument() {
+ return this.fOwnerDocument;
+ }
+
+ public ICSSNode getParentNode() {
+ return this.fParentNode;
+ }
+
+ public ICSSNode getPreviousSibling() {
+ return this.fPreviousSibling;
+ }
+
+ ICSSNode getRootNode() {
+ CSSNodeImpl parent = (CSSNodeImpl) getParentNode();
+ if (parent == null)
+ return this;
+ return parent.getRootNode();
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean hasChildNodes() {
+ return (this.fFirstChild != null);
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean hasProperties() {
+ return false;
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSNodeImpl insertBefore(CSSNodeImpl newChild, CSSNodeImpl refChild) throws org.w3c.dom.DOMException {
+ if (newChild == null)
+ return null;
+
+ CSSNodeImpl child = newChild;
+ CSSNodeImpl next = refChild;
+ CSSNodeImpl prev = null;
+ if (next == null) {
+ prev = this.fLastChild;
+ this.fLastChild = child;
+ }
+ else {
+ prev = (CSSNodeImpl) next.getPreviousSibling();
+ next.setPreviousSibling(child);
+ }
+
+ if (prev == null)
+ this.fFirstChild = child;
+ else
+ prev.setNextSibling(child);
+ child.setPreviousSibling(prev);
+ child.setNextSibling(next);
+ child.setParentNode(this);
+
+ notifyChildReplaced(child, null);
+
+ return newChild;
+ }
+
+ protected void notifyAttrReplaced(CSSNodeImpl newAttr, CSSNodeImpl oldAttr) {
+ // for model
+ ICSSDocument doc = getContainerDocument();
+ if (doc == null)
+ return;
+ CSSModelImpl model = (CSSModelImpl) doc.getModel();
+ if (model == null)
+ return;
+ model.attrReplaced(this, newAttr, oldAttr);
+
+ // for adapters
+ int type = CHANGE;
+ if (newAttr == null)
+ type = REMOVE;
+ else if (oldAttr == null)
+ type = ADD;
+ notify(type, oldAttr, oldAttr, newAttr, getStartOffset());
+ }
+
+ protected void notifyChildReplaced(CSSNodeImpl newChild, CSSNodeImpl oldChild) {
+ // for model
+ ICSSDocument doc = getContainerDocument();
+ if (doc == null)
+ return;
+ CSSModelImpl model = (CSSModelImpl) doc.getModel();
+ if (model == null)
+ return;
+ model.childReplaced(this, newChild, oldChild);
+
+ // for adapters
+ int type = CHANGE;
+ if (newChild == null)
+ type = REMOVE;
+ else if (oldChild == null)
+ type = ADD;
+ notify(type, oldChild, oldChild, newChild, getStartOffset());
+ }
+
+ void removeAttributeNode(CSSNodeImpl attr) {
+ // find
+ int nAttrs = fAttrs.getLength();
+ for (int i = 0; i < nAttrs; i++) {
+ if (fAttrs.item(i) == attr) {
+ fAttrs.removeNode(i);
+ notifyAttrReplaced(null, attr);
+ return;
+ }
+ }
+ }
+
+ protected CSSNodeImpl removeChild(CSSNodeImpl oldChild) throws org.w3c.dom.DOMException {
+ if (oldChild == null)
+ return null;
+ if (oldChild.getParentNode() != this)
+ return null;
+
+ // close import rules
+ ImportRuleCollector trav = new ImportRuleCollector();
+ trav.apply(oldChild);
+ Iterator it = trav.getRules().iterator();
+ while (it.hasNext()) {
+ ((CSSImportRuleImpl) it.next()).closeStyleSheet();
+ }
+
+ CSSNodeImpl child = oldChild;
+ CSSNodeImpl prev = (CSSNodeImpl) child.getPreviousSibling();
+ CSSNodeImpl next = (CSSNodeImpl) child.getNextSibling();
+
+ if (prev == null)
+ this.fFirstChild = next;
+ else
+ prev.setNextSibling(next);
+
+ if (next == null)
+ this.fLastChild = prev;
+ else
+ next.setPreviousSibling(prev);
+
+ child.setPreviousSibling(null);
+ child.setNextSibling(null);
+ child.setParentNode(null);
+
+ notifyChildReplaced(null, child);
+
+ return child;
+ }
+
+ /**
+ *
+ */
+ void removeChildNodes() {
+ ICSSNode nextChild = null;
+ for (ICSSNode child = getFirstChild(); child != null; child = nextChild) {
+ nextChild = child.getNextSibling();
+ removeChild((CSSNodeImpl) child);
+ }
+ }
+
+ protected CSSNodeImpl replaceChild(CSSNodeImpl newChild, CSSNodeImpl oldChild) throws org.w3c.dom.DOMException {
+ if (oldChild == null)
+ return newChild;
+ if (newChild != null)
+ insertBefore(newChild, oldChild);
+ return removeChild(oldChild);
+ }
+
+ /**
+ *
+ * currently public but may be made default access protected in future.
+ *
+ * @param name
+ * java.lang.String
+ * @param value
+ * java.lang.String
+ */
+ public void setAttribute(String name, String value) {
+ if (name == null)
+ return;
+
+ CSSAttrImpl attr = getAttributeNode(name);
+ if (attr != null) {
+ String oldValue = attr.getValue();
+ if (value != null && value.equals(oldValue))
+ return;
+ if (value == null) {
+ if (oldValue != null) {
+ removeAttributeNode(attr);
+ }
+ return;
+ }
+ }
+ else {
+ if (value == null)
+ return;
+ if (fAttrs == null)
+ fAttrs = new CSSNamedNodeMapImpl();
+ CSSDocumentImpl doc = (CSSDocumentImpl) getOwnerDocument();
+ if (doc == null)
+ return;
+ attr = (CSSAttrImpl) doc.createCSSAttr(name);
+ attr.setOwnerCSSNode(this);
+ fAttrs.appendNode(attr);
+ notifyAttrReplaced(attr, null);
+ }
+ attr.setValue(value);
+ }
+
+ /**
+ * @param cssText
+ * java.lang.String
+ */
+ public void setCssText(String cssText) {
+ // TODO : call flat model parser and replace myself with new three!!
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+
+ private void setNextSibling(ICSSNode nextSibling) {
+ this.fNextSibling = (CSSNodeImpl) nextSibling;
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public void setOwnerDocument(ICSSDocument ownerDocument) {
+ this.fOwnerDocument = (CSSDocumentImpl) ownerDocument;
+ }
+
+ private void setParentNode(ICSSNode parentNode) {
+ this.fParentNode = (CSSNodeImpl) parentNode;
+ }
+
+ private void setPreviousSibling(ICSSNode previousSibling) {
+ this.fPreviousSibling = (CSSNodeImpl) previousSibling;
+ }
+
+ public int getLength() {
+ int result = -1;
+ int start = getStartOffset();
+ if (start >= 0) {
+ int end = getEndOffset();
+ if (end >= 0) {
+ result = end - start;
+ if (result < -1) {
+ result = -1;
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java
new file mode 100644
index 0000000..ed13871
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSNodeListImpl.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList;
+
+class CSSNodeListImpl extends AbstractCSSNodeList implements ICSSNodeList {
+
+ CSSNodeListImpl() {
+ super();
+ }
+
+ public ICSSNode item(int index) {
+ return itemImpl(index);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java
new file mode 100644
index 0000000..e49d578
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPageRuleImpl.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+
+
+/**
+ *
+ */
+class CSSPageRuleImpl extends CSSRuleDeclContainer implements ICSSPageRule {
+
+ ICSSSelectorList fSelectorList = new CSSSelectorListImpl(null);
+
+ /**
+ *
+ */
+ CSSPageRuleImpl() {
+ super();
+ }
+
+ CSSPageRuleImpl(CSSPageRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSPageRuleImpl cloned = new CSSPageRuleImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ String extractPreString() {
+ StringBuffer preStr = new StringBuffer("@page ");//$NON-NLS-1$
+ preStr.append(getSelectorText());
+
+ return preStr.toString();
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return PAGERULE_NODE;
+ }
+
+ public ICSSSelectorList getSelectors() {
+ return fSelectorList;
+ }
+
+ /**
+ * The parsable textual representation of the page selector for the rule.
+ *
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the specified CSS string value has
+ * a syntax error and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is
+ * readonly.
+ */
+ public String getSelectorText() {
+ return getAttribute(SELECTOR);
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return PAGE_RULE;
+ }
+
+ /**
+ *
+ */
+ public void setSelectorText(String selectorText) throws org.w3c.dom.DOMException {
+ setAttribute(SELECTOR, selectorText);
+ fSelectorList = new CSSSelectorListImpl(selectorText);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java
new file mode 100644
index 0000000..8d1f186
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveContainer.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+
+/**
+ *
+ */
+abstract class CSSPrimitiveContainer extends CSSPrimitiveValueImpl {
+
+ CSSPrimitiveContainer(CSSPrimitiveContainer that) {
+ super(that);
+ }
+
+ CSSPrimitiveContainer(short primitiveType) {
+ super(primitiveType);
+ }
+
+ protected abstract void initPrimitives();
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public void setOwnerDocument(ICSSDocument ownerDocument) {
+ super.setOwnerDocument(ownerDocument);
+
+ initPrimitives();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java
new file mode 100644
index 0000000..1bbc097
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSPrimitiveValueImpl.java
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.Counter;
+import org.w3c.dom.css.RGBColor;
+import org.w3c.dom.css.Rect;
+
+
+/**
+ *
+ */
+class CSSPrimitiveValueImpl extends CSSRegionContainer implements ICSSPrimitiveValue {
+
+ protected short fPrimitiveType = CSS_UNKNOWN;
+ private float fFloatValue = 0.0f;
+ private String fStringValue = null;
+
+ CSSPrimitiveValueImpl(CSSPrimitiveValueImpl that) {
+ super(that);
+
+ this.fPrimitiveType = that.fPrimitiveType;
+ this.fFloatValue = that.fFloatValue;
+ this.fStringValue = that.fStringValue;
+ }
+
+ CSSPrimitiveValueImpl(short primitiveType) {
+ super();
+ fPrimitiveType = primitiveType;
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSPrimitiveValueImpl cloned = new CSSPrimitiveValueImpl(this);
+
+ return cloned;
+ }
+
+ /**
+ * This method is used to get the Counter value. If this CSS value doesn't
+ * contain a counter value, a <code>DOMException</code> is raised.
+ * Modification to the corresponding style property can be achieved using
+ * the <code>Counter</code> interface.
+ *
+ * @return The Counter value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a Counter value (e.g. this is not
+ * <code>CSS_COUNTER</code>).
+ */
+ public Counter getCounterValue() throws DOMException {
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public java.lang.String getCSSValueText() {
+ return getCssText();
+ }
+
+ /**
+ * A code defining the type of the value as defined above.
+ */
+ public short getCssValueType() {
+ if (getPrimitiveType() == CSS_INHERIT_PRIMITIVE) {
+ return CSS_INHERIT;
+ }
+ else {
+ return CSS_PRIMITIVE_VALUE;
+ }
+ }
+
+ /**
+ * This method is used to get a float value in a specified unit. If this
+ * CSS value doesn't contain a float value or can't be converted into the
+ * specified unit, a <code>DOMException</code> is raised.
+ *
+ * @param unitType
+ * A unit code to get the float value. The unit code can only
+ * be a float unit type (i.e. <code>CSS_NUMBER</code>,
+ * <code>CSS_PERCENTAGE</code>,<code>CSS_EMS</code>,
+ * <code>CSS_EXS</code>,<code>CSS_PX</code>,
+ * <code>CSS_CM</code>,<code>CSS_MM</code>,
+ * <code>CSS_IN</code>,<code>CSS_PT</code>,
+ * <code>CSS_PC</code>,<code>CSS_DEG</code>,
+ * <code>CSS_RAD</code>,<code>CSS_GRAD</code>,
+ * <code>CSS_MS</code>,<code>CSS_S</code>,
+ * <code>CSS_HZ</code>,<code>CSS_KHZ</code>,
+ * <code>CSS_DIMENSION</code>).
+ * @return The float value in the specified unit.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a float value or if the float value can't be
+ * converted into the specified unit.
+ */
+ public float getFloatValue(short unitType) throws DOMException {
+ switch (fPrimitiveType) {
+ case CSS_NUMBER :
+ case CSS_PERCENTAGE :
+ case CSS_EMS :
+ case CSS_EXS :
+ case CSS_PX :
+ case CSS_CM :
+ case CSS_MM :
+ case CSS_IN :
+ case CSS_PT :
+ case CSS_PC :
+ case CSS_DEG :
+ case CSS_RAD :
+ case CSS_GRAD :
+ case CSS_MS :
+ case CSS_S :
+ case CSS_HZ :
+ case CSS_KHZ :
+ case CSS_DIMENSION :
+ case CSS_INTEGER :
+ case CSS_HASH :
+ return fFloatValue;
+ default :
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/01/17
+ * 12:12:18)
+ *
+ * @return short
+ */
+ public short getNodeType() {
+ return PRIMITIVEVALUE_NODE;
+ }
+
+ /**
+ * The type of the value as defined by the constants specified above.
+ */
+ public short getPrimitiveType() {
+ return fPrimitiveType;
+ }
+
+ /**
+ * This method is used to get the Rect value. If this CSS value doesn't
+ * contain a rect value, a <code>DOMException</code> is raised.
+ * Modification to the corresponding style property can be achieved using
+ * the <code>Rect</code> interface.
+ *
+ * @return The Rect value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a Rect value. (e.g. this is not
+ * <code>CSS_RECT</code>).
+ */
+ public Rect getRectValue() throws DOMException {
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+
+ /**
+ * This method is used to get the RGB color. If this CSS value doesn't
+ * contain a RGB color value, a <code>DOMException</code> is raised.
+ * Modification to the corresponding style property can be achieved using
+ * the <code>RGBColor</code> interface.
+ *
+ * @return the RGB color value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the attached property
+ * can't return a RGB color value (e.g. this is not
+ * <code>CSS_RGBCOLOR</code>).
+ */
+ public RGBColor getRGBColorValue() throws DOMException {
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+
+ /**
+ * This method is used to get the string value. If the CSS value doesn't
+ * contain a string value, a <code>DOMException</code> is raised. Some
+ * properties (like 'font-family' or 'voice-family') convert a whitespace
+ * separated list of idents to a string.
+ *
+ * @return The string value in the current unit. The current
+ * <code>primitiveType</code> can only be a string unit type
+ * (i.e. <code>CSS_STRING</code>,<code>CSS_URI</code>,
+ * <code>CSS_IDENT</code> and <code>CSS_ATTR</code>).
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a string value.
+ */
+ public String getStringValue() throws DOMException {
+ switch (fPrimitiveType) {
+ case CSS_STRING :
+ case CSS_URI :
+ case CSS_IDENT :
+ case CSS_ATTR :
+ case CSS_URANGE :
+ case CSS_FORMAT :
+ case CSS_LOCAL :
+ case CSS_HASH :
+ case CSS_COMMA :
+ case CSS_SLASH :
+ case CSS_INHERIT_PRIMITIVE :
+ return fStringValue;
+ default :
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void notifyValueChanged(String oldValue) {
+ // for model
+ ICSSDocument doc = getContainerDocument();
+ if (doc == null)
+ return;
+ CSSModelImpl model = (CSSModelImpl) doc.getModel();
+ if (model == null)
+ return;
+ model.valueChanged(this, oldValue);
+
+ // for adapters
+ notify(CHANGE, new Short(fPrimitiveType), null, null, getStartOffset());
+ }
+
+ /**
+ * A method to set the float value with a specified unit. If the property
+ * attached with this value can not accept the specified unit or the float
+ * value, the value will be unchanged and a <code>DOMException</code>
+ * will be raised.
+ *
+ * @param unitType
+ * A unit code as defined above. The unit code can only be a
+ * float unit type (i.e. <code>CSS_NUMBER</code>,
+ * <code>CSS_PERCENTAGE</code>,<code>CSS_EMS</code>,
+ * <code>CSS_EXS</code>,<code>CSS_PX</code>,
+ * <code>CSS_CM</code>,<code>CSS_MM</code>,
+ * <code>CSS_IN</code>,<code>CSS_PT</code>,
+ * <code>CSS_PC</code>,<code>CSS_DEG</code>,
+ * <code>CSS_RAD</code>,<code>CSS_GRAD</code>,
+ * <code>CSS_MS</code>,<code>CSS_S</code>,
+ * <code>CSS_HZ</code>,<code>CSS_KHZ</code>,
+ * <code>CSS_DIMENSION</code>).
+ * @param floatValue
+ * The new float value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the attached property
+ * doesn't support the float value or the unit type. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public void setFloatValue(short unitType, float floatValue) throws DOMException {
+ switch (unitType) {
+ case CSS_NUMBER :
+ case CSS_PERCENTAGE :
+ case CSS_EMS :
+ case CSS_EXS :
+ case CSS_PX :
+ case CSS_CM :
+ case CSS_MM :
+ case CSS_IN :
+ case CSS_PT :
+ case CSS_PC :
+ case CSS_DEG :
+ case CSS_RAD :
+ case CSS_GRAD :
+ case CSS_MS :
+ case CSS_S :
+ case CSS_HZ :
+ case CSS_KHZ :
+ case CSS_DIMENSION :
+ case CSS_INTEGER :
+ String oldValue = getCSSValueText();
+ fPrimitiveType = unitType;
+ fFloatValue = floatValue;
+ notifyValueChanged(oldValue);
+ break;
+ default :
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * A method to set the string value with the specified unit. If the
+ * property attached to this value can't accept the specified unit or the
+ * string value, the value will be unchanged and a
+ * <code>DOMException</code> will be raised.
+ *
+ * @param stringType
+ * A string code as defined above. The string code can only be
+ * a string unit type (i.e. <code>CSS_STRING</code>,
+ * <code>CSS_URI</code>,<code>CSS_IDENT</code>, and
+ * <code>CSS_ATTR</code>).
+ * @param stringValue
+ * The new string value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a string value or if the string value can't be
+ * converted into the specified unit. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public void setStringValue(short stringType, String stringValue) throws DOMException {
+ switch (stringType) {
+ case CSS_STRING :
+ case CSS_URI :
+ case CSS_IDENT :
+ case CSS_ATTR :
+ case CSS_URANGE :
+ case CSS_FORMAT :
+ case CSS_LOCAL :
+ case CSS_HASH :
+ case CSS_COMMA :
+ case CSS_SLASH :
+ case CSS_INHERIT_PRIMITIVE :
+ String oldValue = getCSSValueText();
+ fPrimitiveType = stringType;
+ fStringValue = stringValue;
+ notifyValueChanged(oldValue);
+ break;
+ default :
+ throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/01/24
+ * 15:06:25)
+ *
+ * @param floatValue
+ * float
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setValue(float floatValue) throws org.w3c.dom.DOMException {
+ setFloatValue(getPrimitiveType(), floatValue);
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/01/24
+ * 15:06:25)
+ *
+ * @param stringValue
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setValue(java.lang.String stringValue) throws org.w3c.dom.DOMException {
+ setStringValue(getPrimitiveType(), stringValue);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java
new file mode 100644
index 0000000..3e5caef
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRegionContainer.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+
+/**
+ *
+ */
+abstract class CSSRegionContainer extends CSSNodeImpl {
+
+ private ITextRegion fFirstRegion = null;
+ private ITextRegion fLastRegion = null;
+ private IStructuredDocumentRegion fParentRegion = null;
+
+ /**
+ * CSSRegionContainer constructor comment.
+ */
+ CSSRegionContainer() {
+ super();
+ }
+
+ CSSRegionContainer(CSSRegionContainer that) {
+ super(that);
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getCssText() {
+ if (fFirstRegion == null || fLastRegion == null)
+ return generateSource();
+
+ ITextRegionList regions = fParentRegion.getRegions();
+ StringBuffer source = new StringBuffer();
+ boolean bIn = false;
+ for (int i = 0; i < regions.size(); i++) {
+ ITextRegion current = regions.get(i);
+ if (bIn) {
+ source.append(fParentRegion.getFullText(current));
+ if (current == fLastRegion)
+ break;
+ }
+ else {
+ if (current == fFirstRegion) {
+ bIn = true;
+ source.append(fParentRegion.getFullText(current));
+ if (current == fLastRegion)
+ break;
+ }
+ }
+ }
+ return source.toString();
+ }
+
+ /**
+ * @return int
+ */
+ public int getEndOffset() {
+ int result = -1;
+ ITextRegion region = getLastRegion();
+ if (!(region == null || fParentRegion == null)) {
+ result = fParentRegion.getEndOffset(region);
+ }
+ return result;
+ }
+
+ IStructuredDocumentRegion getDocumentRegion() {
+ return fParentRegion;
+ }
+
+ ITextRegion getFirstRegion() {
+ return fFirstRegion;
+ }
+
+ ITextRegion getLastRegion() {
+ return fLastRegion;
+ }
+
+ ITextRegion getRegion(int index) {
+ if (getFirstRegion() == null)
+ return null;
+ ITextRegionList regions = fParentRegion.getRegions();
+
+ for (int i = 0; i < regions.size(); i++) {
+ if (regions.get(i) == getFirstRegion()) {
+ if (i + index < regions.size()) {
+ ITextRegion target = regions.get(i + index);
+ if (target.getStart() <= getLastRegion().getStart())
+ return target;
+ }
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return int
+ */
+ int getRegionCount() {
+ validateRange();
+
+ if (getFirstRegion() == null)
+ return 0;
+ if (getFirstRegion() == getLastRegion())
+ return 1;
+ ITextRegionList regions = fParentRegion.getRegions();
+
+ int j = 0;
+ for (int i = 0; i < regions.size(); i++) {
+ ITextRegion current = regions.get(i);
+ if (j != 0 || current == getFirstRegion())
+ j++;
+ if (current == getLastRegion())
+ break;
+ }
+ return j;
+ }
+
+ /**
+ * @return int
+ */
+ public int getStartOffset() {
+ int result = -1;
+ ITextRegion region = getFirstRegion();
+ if (!(region == null || fParentRegion == null)) {
+ result = fParentRegion.getStartOffset(region);
+ }
+ return result;
+ }
+
+
+
+ /**
+ * @deprecated
+ */
+ ITextRegion setFirstRegion(ITextRegion region) {
+ this.fFirstRegion = region;
+ return region;
+ }
+
+ /**
+ * @deprecated
+ */
+ ITextRegion setLastRegion(ITextRegion lastRegion) {
+ this.fLastRegion = lastRegion;
+ return lastRegion;
+ }
+
+ void setRangeRegion(IStructuredDocumentRegion parentRegion, ITextRegion firstRegion, ITextRegion lastRegion) {
+ this.fParentRegion = parentRegion;
+ this.fFirstRegion = firstRegion;
+ this.fLastRegion = lastRegion;
+
+ if (firstRegion == null && lastRegion == null) {
+ setFirstRegion(null);
+ setLastRegion(null);
+ }
+ else { // range validation
+ validateRange();
+ }
+ }
+
+ /**
+ * @return boolean
+ */
+ private boolean validateRange() {
+ boolean bModified = false;
+
+ if (this.fFirstRegion != null || this.fLastRegion != null) {
+ if (this.fFirstRegion == null) {
+ this.fFirstRegion = this.fLastRegion;
+ bModified = true;
+ }
+ else if (this.fLastRegion == null) {
+ this.fLastRegion = this.fFirstRegion;
+ bModified = true;
+ }
+ else if (this.fFirstRegion.getStart() > this.fLastRegion.getStart()) {
+ // need to swap first for last
+ ITextRegion reg = fFirstRegion;
+ fFirstRegion = fLastRegion;
+ fLastRegion = reg;
+ bModified = true;
+ }
+ }
+ return bModified;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java
new file mode 100644
index 0000000..6438164
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleDeclContainer.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+
+/**
+ *
+ */
+abstract class CSSRuleDeclContainer extends CSSRuleImpl {
+
+ /**
+ * CSSRuleDeclContainer constructor comment.
+ */
+ CSSRuleDeclContainer() {
+ super();
+ }
+
+ /**
+ * CSSRuleDeclContainer constructor comment.
+ *
+ */
+ CSSRuleDeclContainer(CSSRuleDeclContainer that) {
+ super(that);
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ abstract String extractPreString();
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleDeclaration
+ */
+ public CSSStyleDeclaration getStyle() {
+
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSStyleDeclaration)
+ return (CSSStyleDeclaration) node;
+ }
+
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java
new file mode 100644
index 0000000..32e6e38
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleImpl.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSStyleSheet;
+
+
+/**
+ *
+ */
+abstract class CSSRuleImpl extends CSSStructuredDocumentRegionContainer implements CSSRule {
+
+ /**
+ *
+ */
+ CSSRuleImpl() {
+ super();
+ }
+
+ CSSRuleImpl(CSSRuleImpl that) {
+ super(that);
+ }
+
+ /**
+ * If this rule is contained inside another rule (e.g. a style rule inside
+ * an
+ *
+ * @media block), this is the containing rule. If this rule is not nested
+ * inside any other rules, this returns <code>null</code>.
+ */
+ public CSSRule getParentRule() {
+ ICSSNode rule = getParentNode();
+
+ // parent rule is used only if parent is media rule
+ if (rule instanceof CSSMediaRuleImpl)
+ return (CSSRule) rule;
+
+ return null;
+ }
+
+ /**
+ * The style sheet that contains this rule.
+ */
+ public CSSStyleSheet getParentStyleSheet() {
+ ICSSNode parent = getParentNode();
+ while (parent != null) {
+ if (parent instanceof CSSStyleSheetImpl)
+ return (CSSStyleSheet) parent;
+ parent = parent.getParentNode();
+ }
+ return null;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public abstract short getType();
+
+ /**
+ * @return boolean
+ */
+ public boolean hasProperties() {
+ return true;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java
new file mode 100644
index 0000000..51f15a4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSRuleListImpl.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+
+/**
+ *
+ */
+public class CSSRuleListImpl extends AbstractCSSNodeList implements CSSRuleList {
+
+ /**
+ *
+ */
+ CSSRuleListImpl() {
+ super();
+ }
+
+ /**
+ * Used to retrieve a CSS rule by ordinal index. The order in this
+ * collection represents the order of the rules in the CSS style sheet. If
+ * index is greater than or equal to the number of rules in the list, this
+ * returns <code>null</code>.
+ *
+ * @param indexIndex
+ * into the collection
+ * @return The style rule at the <code>index</code> position in the
+ * <code>CSSRuleList</code>, or <code>null</code> if that is
+ * not a valid index.
+ */
+ public CSSRule item(int index) {
+ return (CSSRule) itemImpl(index);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java
new file mode 100644
index 0000000..4f039a5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelector.java
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSelectorAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import com.ibm.icu.util.StringTokenizer;
+
+class CSSSelector implements ICSSSelector {
+
+ private int fSpecificity = -1;
+ private String fCachedString = null;
+ private List fTokens = null;
+ private List fItems = null;
+ private List fParseErrors = null;
+ private List fNameErrors = null;
+
+ CSSSelector(List tokens) {
+ fTokens = new ArrayList(tokens);
+ }
+
+ /**
+ * @return boolean
+ * @param obj
+ * java.lang.Object
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || this.getClass() != obj.getClass())
+ return false;
+
+ CSSSelector foreign = (CSSSelector) obj;
+
+ // if (fSpecificity != foreign.fSpecificity) return false;
+
+ if (getLength() != foreign.getLength())
+ return false;
+
+ for (int i = 0; i < getLength(); i++) {
+ if (!getItem(i).equals(foreign.getItem(i)))
+ return false;
+ }
+
+ return true;
+ }
+
+ public ICSSSelectorItem getItem(int index) {
+ if (fItems == null) {
+ fItems = parseSelector(fTokens);
+ }
+ if (fItems != null && 0 <= index && index < fItems.size()) {
+ return (ICSSSelectorItem) fItems.get(index);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * @return java.util.Iterator
+ */
+ public Iterator getIterator() {
+ if (fItems == null) {
+ fItems = parseSelector(fTokens);
+ }
+ return (fItems != null) ? fItems.iterator() : null;
+ }
+
+ /**
+ * @return int
+ */
+ public int getLength() {
+ if (fItems == null) {
+ fItems = parseSelector(fTokens);
+ }
+ return (fItems != null) ? fItems.size() : 0;
+ }
+
+ /**
+ * @return org.w3c.dom.Element
+ */
+ private Element getParentElement(Element element) {
+ Node node = element.getParentNode();
+ if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) node;
+ }
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.Element
+ */
+ private Element getPreviousElement(Element element) {
+ Element p = null;
+ for (Node node = element.getPreviousSibling(); node != null; node = node.getPreviousSibling()) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ p = (Element) node;
+ break;
+ }
+ }
+ return p;
+ }
+
+ /**
+ * Calculate a selector's specificity a = the number of ID attributes in
+ * the selector b = the number of other attributes and pseudo-classes in
+ * the selector c = the number of element names in the selector (ignore
+ * pseudo-elements) Concatenating the three numbers a-b-c (in a number
+ * system with a large base) gives the specificity.
+ *
+ * @return int
+ */
+ public int getSpecificity() {
+ if (fSpecificity < 0) {
+ int nIDs = 0;
+ int nAttributes = 0;
+ int nElements = 0;
+ Iterator i = getIterator();
+ while (i.hasNext()) {
+ ICSSSelectorItem item = (ICSSSelectorItem) i.next();
+ if (item instanceof CSSSimpleSelector) {
+ CSSSimpleSelector selector = (CSSSimpleSelector) item;
+ nIDs += selector.getNumOfIDs();
+ nAttributes += selector.getNumOfAttributes();
+ nAttributes += selector.getNumOfClasses();
+ nAttributes += selector.getNumOfPseudoNames();
+ if (!selector.isUniversal()) {
+ nElements++;
+ }
+ }
+ }
+ fSpecificity = nIDs * 10000 + nAttributes * 100 + nElements;
+ }
+
+ return fSpecificity;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getString() {
+ if (fCachedString == null) {
+ StringBuffer buf = new StringBuffer();
+ Iterator i = getIterator();
+ while (i.hasNext()) {
+ ICSSSelectorItem item = (ICSSSelectorItem) i.next();
+ if (item instanceof CSSSelectorCombinator) {
+ // If item is DESCENDANT combinator, it is just single
+ // space.
+ // Then, you dont have to append string..
+ if (((CSSSelectorCombinator) item).getCombinatorType() != ICSSSelectorCombinator.DESCENDANT) {
+ buf.append(" ");//$NON-NLS-1$
+ buf.append(item.getString());
+ }
+ buf.append(" ");//$NON-NLS-1$
+ }
+ else {
+ buf.append(item.getString());
+ }
+ }
+ fCachedString = buf.toString();
+ }
+
+ return fCachedString;
+ }
+
+ /**
+ * @return boolean
+ * @param element
+ * org.w3c.dom.Element
+ */
+ public boolean match(org.w3c.dom.Element element, java.lang.String pseudoName) {
+ Element target = element;
+ char combinatorType = ICSSSelectorCombinator.UNKNOWN;
+ Element chunkStartElement = null; // for CHILD and ADJACENT
+ // combinator
+ int chunkStartItem = -1; // for CHILD and ADJACENT combinator
+ int numItems = getLength();
+ for (int iItem = numItems - 1; iItem >= 0; iItem--) {
+ // Check Selector Items
+ ICSSSelectorItem item = getItem(iItem);
+ if (item instanceof ICSSSimpleSelector) {
+ // Simple Selector
+ if (target == null)
+ return false;
+ if (!matchExactly((ICSSSimpleSelector) item, target, pseudoName)) {
+ switch (combinatorType) {
+ case ICSSSelectorCombinator.DESCENDANT :
+ do {
+ target = getParentElement(target);
+ if (target == null)
+ return false;
+ }
+ while (!matchExactly((ICSSSimpleSelector) item, target, pseudoName));
+ break;
+ case ICSSSelectorCombinator.CHILD :
+ case ICSSSelectorCombinator.ADJACENT :
+ if (chunkStartElement != null && chunkStartElement != element) {
+ // previous conbinator must be DESCENDENT.
+ // goto parent
+ target = getParentElement(chunkStartElement);
+ iItem = chunkStartItem + 1;
+ chunkStartElement = null;
+ chunkStartItem = -1;
+ break;
+ }
+ default :
+ // other combinators are not supported yet.
+ return false;
+ }
+ }
+ }
+ else if (item instanceof ICSSSelectorCombinator) {
+ // Combinator ( "+", ">", " ", ...)
+ if (iItem == numItems - 1)
+ return false; // last item is combinator
+
+ ICSSSelectorCombinator sc = (ICSSSelectorCombinator) item;
+ combinatorType = sc.getCombinatorType();
+ switch (combinatorType) {
+ case ICSSSelectorCombinator.DESCENDANT :
+ target = getParentElement(target);
+ break;
+ case ICSSSelectorCombinator.CHILD :
+ case ICSSSelectorCombinator.ADJACENT :
+ if (chunkStartElement == null) {
+ chunkStartElement = target;
+ chunkStartItem = iItem + 1; // safe because this
+ // is not a last item.
+ }
+ if (combinatorType == ICSSSelectorCombinator.CHILD) {
+ target = getParentElement(target);
+ }
+ else {
+ target = getPreviousElement(target);
+ }
+ break;
+ }
+ }
+ else {
+ // what is this item ???
+ return false;
+ }
+ }
+ // OK this selector maches the element.
+ return true;
+
+ }
+
+ /**
+ * @return boolean
+ */
+ private boolean matchExactly(ICSSSimpleSelector selector, Element element, String pseudoName) {
+ IStyleSelectorAdapter adapter = (IStyleSelectorAdapter) ((INodeNotifier) element).getAdapterFor(IStyleSelectorAdapter.class);
+ if (adapter != null) {
+ return adapter.match(selector, element, pseudoName);
+ }
+
+ if (element == null)
+ return false;
+ int i;
+ String key;
+
+ // TODO: PseudoName
+
+ // check tag name
+ if (!selector.isUniversal() && !element.getNodeName().equals(selector.getName()))
+ return false;
+
+ // check id
+ i = selector.getNumOfIDs();
+ if (i > 0) {
+ if (i > 1)
+ return false;
+ if (!element.hasAttribute("id") || (key = element.getAttribute("id")).length() == 0)//$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ if (!selector.getID(0).equals(key))
+ return false;
+ }
+
+ // check class
+ i = selector.getNumOfClasses();
+ if (i > 0) {
+ if (!element.hasAttribute("class") || (key = element.getAttribute("class")).length() == 0) //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ StringTokenizer tokenizer = new StringTokenizer(key);
+ for (i = i - 1; i >= 0; i--) {
+ boolean ok = false;
+ while (tokenizer.hasMoreTokens()) {
+ if (selector.getClass(i).equals(tokenizer.nextToken())) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok)
+ return false;
+ }
+ }
+
+ // check attributes
+ for (i = selector.getNumOfAttributes() - 1; i >= 0; i--) {
+ StringTokenizer tokenizer = new StringTokenizer(selector.getAttribute(i), "=~| \t\r\n\f");//$NON-NLS-1$
+ int countTokens = tokenizer.countTokens();
+ if (countTokens > 0) {
+ String attrName = tokenizer.nextToken();
+ String attrValue = null;
+ if (!element.hasAttribute(attrName) || (attrValue = element.getAttribute(attrName)).length() == 0)
+ return false;
+ if (countTokens > 1) {
+ String token = tokenizer.nextToken("= \t\r\n\f");//$NON-NLS-1$
+ StringTokenizer attrValueTokenizer = null;
+ if (token.equals("~")) {//$NON-NLS-1$
+ attrValueTokenizer = new StringTokenizer(attrValue);
+ }
+ else if (token.equals("|")) {//$NON-NLS-1$
+ attrValueTokenizer = new StringTokenizer(attrValue, "-");//$NON-NLS-1$
+ }
+ if (attrValueTokenizer != null) {
+ if (tokenizer.hasMoreTokens()) {
+ token = tokenizer.nextToken();
+ boolean ok = false;
+ while (attrValueTokenizer.hasMoreTokens()) {
+ if (token.equals(attrValueTokenizer.nextToken())) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok)
+ return false;
+ }
+ }
+ else {
+ if (!attrValue.equals(token))
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private List parseSelector(List tokens) {
+ CSSSelectorParser parser = new CSSSelectorParser(tokens);
+ List selector = parser.getSelector();
+ Iterator i = parser.getErrors();
+ fParseErrors = new ArrayList();
+ while (i.hasNext()) {
+ fParseErrors.add(i.next());
+ }
+ return selector;
+ }
+
+ public Iterator getErrors() {
+ if (fNameErrors == null) {
+ fNameErrors = new ArrayList();
+ Iterator iItem = getIterator();
+ while (iItem.hasNext()) {
+ ICSSSelectorItem item = (ICSSSelectorItem) iItem.next();
+ if (item instanceof ICSSSimpleSelector) {
+ if (!((ICSSSimpleSelector) item).isUniversal()) {
+ String name = ((ICSSSimpleSelector) item).getName();
+ if (!NameValidator.isValid(name)) {
+ fNameErrors.add(item);
+ }
+ }
+ }
+ }
+ }
+ List errors = new ArrayList(fParseErrors);
+ errors.addAll(fNameErrors);
+ return errors.iterator();
+ }
+
+ public String toString() {
+ return getString();
+ }
+
+ /**
+ * @see ICSSSelector#getErrorCount()
+ */
+ public int getErrorCount() {
+ int nErrors = 0;
+ Iterator i = getErrors();
+ while (i.hasNext()) {
+ nErrors++;
+ i.next();
+ }
+ return nErrors;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java
new file mode 100644
index 0000000..d015aa5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorCombinator.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator;
+
+/**
+ *
+ */
+class CSSSelectorCombinator extends CSSSelectorItem implements ICSSSelectorCombinator {
+
+ char fType = ICSSSelectorCombinator.UNKNOWN;
+
+ /**
+ * CSSSelectorCombinator constructor comment.
+ */
+ public CSSSelectorCombinator(char type) {
+ super();
+ setCombinatorType(type);
+ }
+
+ /**
+ * @return boolean
+ * @param obj
+ * java.lang.Object
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || this.getClass() != obj.getClass())
+ return false;
+
+ CSSSelectorCombinator foreign = (CSSSelectorCombinator) obj;
+
+ return (getCombinatorType() == foreign.getCombinatorType());
+
+ }
+
+ /**
+ * @return int
+ */
+ public char getCombinatorType() {
+ return fType;
+ }
+
+ /**
+ * @return int
+ */
+ public int getItemType() {
+ return COMBINATOR;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(fType);
+ return buf.toString();
+ }
+
+ void setCombinatorType(char type) {
+ fType = type;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java
new file mode 100644
index 0000000..3436661
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorItem.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem;
+
+/**
+ *
+ */
+abstract class CSSSelectorItem implements ICSSSelectorItem {
+
+ /**
+ * CSSSelectorItem constructor comment.
+ */
+ public CSSSelectorItem() {
+ super();
+ }
+
+ /**
+ * @return int
+ */
+ public int getItemType() {
+ return 0;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getString() {
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java
new file mode 100644
index 0000000..ed231f9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorListImpl.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.w3c.dom.Element;
+
+
+/**
+ *
+ */
+public class CSSSelectorListImpl implements ICSSSelectorList {
+
+ private String fText = null;
+ private String fCachedString = null; // normalized string
+ private List fSelectors = null;
+
+ public CSSSelectorListImpl(String cssText) {
+ super();
+ fText = cssText;
+ parseSelectorText();
+ }
+
+ /**
+ * @return boolean
+ * @param obj
+ * java.lang.Object
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || this.getClass() != obj.getClass())
+ return false;
+
+ CSSSelectorListImpl foreign = (CSSSelectorListImpl) obj;
+
+ if (getLength() != foreign.getLength())
+ return false;
+
+ for (int i = 0; i < getLength(); i++) {
+ if (!getSelector(i).equals(foreign.getSelector(i)))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @return java.util.Iterator
+ */
+ public Iterator getIterator() {
+ return getSelectors().iterator();
+ }
+
+ /**
+ * @return int
+ */
+ public int getLength() {
+ return getSelectors().size();
+ }
+
+ public ICSSSelector getSelector(int index) {
+ List selectors = getSelectors();
+ if (0 <= index && index < selectors.size()) {
+ return (ICSSSelector) selectors.get(index);
+ }
+ else {
+ return null;
+ }
+ }
+
+ private List getSelectors() {
+ if (fSelectors == null) {
+ parseSelectorText();
+ }
+ return fSelectors;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getString() {
+ if (fCachedString == null) {
+ StringBuffer buf = new StringBuffer();
+ boolean bFirst = true;
+ // groups is list of comma-separated selectors
+ Iterator i = getSelectors().iterator();
+ while (i.hasNext()) {
+ if (!bFirst) {
+ buf.append(", ");//$NON-NLS-1$
+ }
+ ICSSSelector item = (ICSSSelector) i.next();
+ buf.append(item.getString());
+ bFirst = false;
+ }
+ fCachedString = buf.toString();
+ }
+ return fCachedString;
+ }
+
+ /**
+ * @return boolean
+ * @param element
+ * org.w3c.dom.Element
+ */
+ public boolean match(Element element, String pseudoName) {
+ int nSelectors = getLength();
+ for (int iSelector = 0; iSelector < nSelectors; iSelector++) {
+ // Check each Selector Lists
+ ICSSSelector selector = getSelector(iSelector);
+ if (selector.match(element, pseudoName))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ private void parseSelectorText() {
+ fSelectors = new ArrayList();
+ if (fText == null) {
+ return;
+ }
+
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_STYLESHEET, fText);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return;
+ }
+
+ List tokenGroup = new ArrayList();
+ for (int i = 0; i < tokens.length; i++) {
+ CSSTextToken token = tokens[i];
+ if (token.kind == CSSRegionContexts.CSS_SELECTOR_SEPARATOR && 0 < tokenGroup.size()) {
+ ICSSSelector selector = new CSSSelector(tokenGroup);
+ if (selector != null) {
+ fSelectors.add(selector);
+ }
+ tokenGroup.clear();
+ }
+ else {
+ tokenGroup.add(tokens[i]);
+ }
+ }
+ if (0 < tokenGroup.size()) {
+ ICSSSelector selector = new CSSSelector(tokenGroup);
+ if (selector != null) {
+ fSelectors.add(selector);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public String toString() {
+ return getString();
+ }
+
+ /**
+ *
+ */
+ public Iterator getErrors() {
+ List errors = new ArrayList();
+ Iterator iSelector = getSelectors().iterator();
+ while (iSelector.hasNext()) {
+ Iterator iError = ((ICSSSelector) iSelector.next()).getErrors();
+ while (iError.hasNext()) {
+ errors.add(iError.next());
+ }
+ }
+ return errors.iterator();
+ }
+
+ /**
+ *
+ */
+ public int getErrorCount() {
+ int nErrors = 0;
+ Iterator i = getErrors();
+ while (i.hasNext()) {
+ nErrors++;
+ i.next();
+ }
+ return nErrors;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java
new file mode 100644
index 0000000..b605610
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSelectorParser.java
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorCombinator;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem;
+
+
+/**
+ *
+ */
+public class CSSSelectorParser {
+
+ private final static int IDLE = 0;
+ private final static int ATTRIBUTE = 1;
+ private final static int SIMPLE = 2;
+
+ private List fTokens = null;
+ private List fItems = null;
+ private List fErrors = null;
+
+ /**
+ *
+ */
+ CSSSelectorParser(List tokens) {
+ super();
+ fTokens = new ArrayList(tokens);
+ }
+
+ /**
+ *
+ */
+ List getSelector() {
+ if (fItems == null) {
+ parseSelector();
+ }
+ return fItems;
+ }
+
+ /**
+ *
+ */
+ private void parseSelector() {
+ fItems = new ArrayList();
+
+ List attrBuf = null;
+ CSSSimpleSelector item = null;
+
+ int status = IDLE;
+ Iterator i = fTokens.iterator();
+ while (i.hasNext()) {
+ CSSTextToken token = (CSSTextToken) i.next();
+ if (token == null || token.kind == CSSRegionContexts.CSS_S || token.kind == CSSRegionContexts.CSS_COMMENT) {
+ continue;
+ }
+ switch (status) {
+ case IDLE :
+ if (isTag(token)) {
+ item = createSimple();
+ appendTag(item, token);
+ status = SIMPLE;
+ }
+ else if (isID(token)) {
+ item = createSimple();
+ appendID(item, token);
+ status = SIMPLE;
+ }
+ else if (isClass(token)) {
+ item = createSimple();
+ appendClass(item, token);
+ status = SIMPLE;
+ }
+ else if (isPseudo(token)) {
+ item = createSimple();
+ appendPseudo(item, token);
+ status = SIMPLE;
+ }
+ else if (isAttributeBegin(token)) {
+ item = createSimple();
+ status = ATTRIBUTE;
+ }
+ else {
+ addError(token);
+ }
+ break;
+ case SIMPLE :
+ if (isID(token)) {
+ appendID(item, token);
+ }
+ else if (isClass(token)) {
+ appendClass(item, token);
+ }
+ else if (isPseudo(token)) {
+ appendPseudo(item, token);
+ }
+ else if (isAttributeBegin(token)) {
+ status = ATTRIBUTE;
+ }
+ else if (isCombinator(token)) { // combinator
+ closeItem(item);
+ closeItem(createCombinator(token));
+ status = IDLE;
+ }
+ else {
+ addError(token);
+ }
+ break;
+ case ATTRIBUTE :
+ if (isAttributeEnd(token)) {
+ appendAttribute(item, attrBuf);
+ attrBuf = null;
+ status = SIMPLE;
+ }
+ else {
+ if (attrBuf == null) {
+ attrBuf = new ArrayList();
+ }
+ attrBuf.add(token);
+ if (!isAttributeContent(token)) {
+ addError(token);
+ }
+ }
+ break;
+ default :
+ break;
+ }
+ }
+
+ closeItem(item);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isAttributeContent(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_OPERATOR || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isAttributeEnd(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isAttributeBegin(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isCombinator(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_COMBINATOR);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isPseudo(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_PSEUDO);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isClass(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_CLASS);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isID(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_ID);
+ }
+
+ /**
+ * @param token
+ * @return
+ */
+ private boolean isTag(CSSTextToken token) {
+ String type = token.kind;
+ return (type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_UNIVERSAL || type == CSSRegionContexts.CSS_UNKNOWN);
+ }
+
+ private CSSSimpleSelector createSimple() {
+ return new CSSSimpleSelector();
+ }
+
+ /**
+ * if " " or "+" or ">" appeared, close simpleselector and add new
+ * combinator
+ */
+ private CSSSelectorCombinator createCombinator(CSSTextToken token) {
+ char type = 0;
+
+ String str = token.image;
+ if (str.trim().length() == 0) { // space
+ type = ICSSSelectorCombinator.DESCENDANT;
+ }
+ else if (str.equals("+")) { //$NON-NLS-1$
+ type = ICSSSelectorCombinator.ADJACENT;
+ }
+ else if (str.equals(">")) { //$NON-NLS-1$
+ type = ICSSSelectorCombinator.CHILD;
+ }
+
+ if (0 < type) {
+ return new CSSSelectorCombinator(type);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private void closeItem(ICSSSelectorItem item) {
+ if (item != null) {
+ fItems.add(item);
+ }
+ }
+
+ private void appendTag(CSSSimpleSelector item, CSSTextToken token) {
+ item.setName(token.image);
+ if (token.kind == CSSRegionContexts.CSS_UNKNOWN) {
+ addError(token);
+ }
+ }
+
+ /**
+ * if "#xxxx" appeared, add ID to current selector
+ */
+ private void appendID(CSSSimpleSelector item, CSSTextToken token) {
+ String text = token.toString();
+ String idContent = text.substring(1, text.length());
+ item.addID(idContent);
+ }
+
+ /**
+ * if ".xxxx" appeared, add Class to current selector
+ */
+ private void appendClass(CSSSimpleSelector item, CSSTextToken token) {
+ String text = token.toString();
+ String classContent = text.substring(1, text.length());
+ item.addClass(classContent);
+ if (Character.isDigit(classContent.charAt(0))) {
+ addError(token);
+ }
+ }
+
+ /**
+ * if ":xxxx" appeared, add Pseudo(element/class) to current selector
+ */
+ private void appendPseudo(CSSSimpleSelector item, CSSTextToken token) {
+ String text = token.toString();
+ String pseudoContent = text.substring(1, text.length());
+ item.addPseudoName(pseudoContent);
+ }
+
+ /**
+ *
+ */
+ private void appendAttribute(CSSSimpleSelector item, List tokens) {
+ StringBuffer buf = new StringBuffer();
+
+ CSSTextToken token;
+ Iterator i = tokens.iterator();
+ while (i.hasNext()) {
+ token = (CSSTextToken) i.next();
+ buf.append(token.image);
+ }
+
+ item.addAttribute(buf.toString());
+ }
+
+ /**
+ *
+ */
+ List getSelectorTags() {
+ List tagList = new ArrayList();
+ return tagList;
+ }
+
+ /**
+ *
+ */
+ private void addError(CSSTextToken token) {
+ if (fErrors == null) {
+ fErrors = new ArrayList();
+ }
+ fErrors.add(token);
+ }
+
+ /**
+ *
+ */
+ Iterator getErrors() {
+ return (fErrors == null) ? Collections.EMPTY_LIST.iterator() : fErrors.iterator();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java
new file mode 100644
index 0000000..5928e90
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSSimpleSelector.java
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector;
+
+
+/**
+ *
+ */
+class CSSSimpleSelector extends CSSSelectorItem implements ICSSSimpleSelector {
+
+ private String fName = null;
+ private String fCachedString = null;
+ private StringBuffer fStringBuf = null;
+ private List fPseudoName = null;
+ private List fAttribute = null;
+ private List fClass = null;
+ private List fID = null;
+
+ /**
+ * CSSSimpleSelector constructor comment.
+ */
+ public CSSSimpleSelector() {
+ super();
+ }
+
+ /**
+ *
+ */
+ void addAttribute(String attribute) {
+ if (fAttribute == null) {
+ fAttribute = new ArrayList();
+ }
+ fAttribute.add(attribute);
+ addToBuf("[");//$NON-NLS-1$
+ addToBuf(attribute);
+ addToBuf("]");//$NON-NLS-1$
+ fCachedString = null;
+ }
+
+ /**
+ *
+ */
+ void addClass(String cls) {
+ if (fClass == null) {
+ fClass = new ArrayList();
+ }
+ fClass.add(cls);
+ addToBuf(".");//$NON-NLS-1$
+ addToBuf(cls);
+ fCachedString = null;
+ }
+
+ /**
+ *
+ */
+ void addID(String id) {
+ if (fID == null) {
+ fID = new ArrayList();
+ }
+ fID.add(id);
+ addToBuf("#");//$NON-NLS-1$
+ addToBuf(id);
+ fCachedString = null;
+ }
+
+ /**
+ *
+ */
+ void addPseudoName(String cls) {
+ if (fPseudoName == null) {
+ fPseudoName = new ArrayList();
+ }
+ fPseudoName.add(cls);
+ addToBuf(":");//$NON-NLS-1$
+ addToBuf(cls);
+ fCachedString = null;
+ }
+
+ /**
+ *
+ */
+ private void addToBuf(String str) {
+ if (fStringBuf == null) {
+ fStringBuf = new StringBuffer();
+ }
+ fStringBuf.append(str);
+ }
+
+ /**
+ * @return boolean
+ * @param obj
+ * java.lang.Object
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+
+ if (obj == null || this.getClass() != obj.getClass())
+ return false;
+
+ CSSSimpleSelector foreign = (CSSSimpleSelector) obj;
+
+ if (getName().compareToIgnoreCase(foreign.getName()) != 0)
+ return false;
+
+ int i;
+
+ // compare pseudo-classes / pseudo-elements
+ if (getNumOfPseudoNames() != foreign.getNumOfPseudoNames())
+ return false;
+ for (i = 0; i < getNumOfPseudoNames(); i++) {
+ if (getPseudoName(i).compareToIgnoreCase(foreign.getPseudoName(i)) != 0)
+ return false;
+ }
+
+ // compare classes
+ if (getNumOfClasses() != foreign.getNumOfClasses())
+ return false;
+ for (i = 0; i < getNumOfClasses(); i++) {
+ if (getClass(i).compareToIgnoreCase(foreign.getClass(i)) != 0)
+ return false;
+ }
+
+ // compare IDs
+ if (getNumOfIDs() != foreign.getNumOfIDs())
+ return false;
+ for (i = 0; i < getNumOfIDs(); i++) {
+ if (getID(i).compareToIgnoreCase(foreign.getID(i)) != 0)
+ return false;
+ }
+
+ // compare Attributes
+ if (getNumOfAttributes() != foreign.getNumOfAttributes())
+ return false;
+ for (i = 0; i < getNumOfAttributes(); i++) {
+ if (getAttribute(i).compareToIgnoreCase(foreign.getAttribute(i)) != 0)
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ public String getAttribute(int index) {
+ if (fAttribute != null && 0 <= index && index < fAttribute.size()) {
+ return (String) fAttribute.get(index);
+ }
+ else {
+ return "";//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ public String getClass(int index) {
+ if (fClass != null && 0 <= index && index < fClass.size()) {
+ return (String) fClass.get(index);
+ }
+ else {
+ return "";//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ public String getID(int index) {
+ if (fID != null && 0 <= index && index < fID.size()) {
+ return (String) fID.get(index);
+ }
+ else {
+ return "";//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public int getItemType() {
+ return SIMPLE;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getName() {
+ return (fName != null) ? fName : "";//$NON-NLS-1$
+ }
+
+ /**
+ * @return boolean
+ */
+ public int getNumOfAttributes() {
+ return (fAttribute != null) ? fAttribute.size() : 0;
+ }
+
+ /**
+ * @return boolean
+ */
+ public int getNumOfClasses() {
+ return (fClass != null) ? fClass.size() : 0;
+ }
+
+ /**
+ * @return boolean
+ */
+ public int getNumOfIDs() {
+ return (fID != null) ? fID.size() : 0;
+ }
+
+ /**
+ * @return boolean
+ */
+ public int getNumOfPseudoNames() {
+ return (fPseudoName != null) ? fPseudoName.size() : 0;
+ }
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ public String getPseudoName(int index) {
+ if (fPseudoName != null && 0 <= index && index < fPseudoName.size()) {
+ return (String) fPseudoName.get(index);
+ }
+ else {
+ return "";//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getString() {
+ if (fCachedString == null) {
+ StringBuffer buf = new StringBuffer(getName());
+ if (fStringBuf != null) {
+ buf.append(fStringBuf.toString());
+ }
+ fCachedString = buf.toString();
+ }
+ return fCachedString;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isUniversal() {
+ return (fName == null || fName.equals("*"));//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ void setName(String name) {
+ fName = name;
+ fCachedString = null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java
new file mode 100644
index 0000000..07bf389
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStructuredDocumentRegionContainer.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+
+/**
+ * currently public but may be made default access protected in future.
+ */
+public abstract class CSSStructuredDocumentRegionContainer extends CSSNodeImpl {
+
+ private IStructuredDocumentRegion firstStructuredDocumentRegion = null;
+ private IStructuredDocumentRegion lastStructuredDocumentRegion = null;
+
+ /**
+ * CSSContainer constructor comment.
+ * currently public but may be made default access protected in future.
+ */
+ public CSSStructuredDocumentRegionContainer() {
+ super();
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public CSSStructuredDocumentRegionContainer(CSSStructuredDocumentRegionContainer that) {
+ super(that);
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getCssText() {
+ if (getFirstStructuredDocumentRegion() == null)
+ return generateSource();
+
+ StringBuffer str = new StringBuffer(getFirstStructuredDocumentRegion().getText());
+ IStructuredDocumentRegion node = getFirstStructuredDocumentRegion();
+
+ while (node != getLastStructuredDocumentRegion()) {
+ node = node.getNext();
+ str.append(node.getText());
+ }
+
+ return str.toString();
+ }
+
+ /**
+ * @return int
+ */
+ public int getEndOffset() {
+ IStructuredDocumentRegion flatNode = getLastStructuredDocumentRegion();
+ if (flatNode != null)
+ return flatNode.getEnd();
+ return -1;
+ }
+
+ IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
+ return firstStructuredDocumentRegion;
+ }
+
+ IStructuredDocumentRegion getStructuredDocumentRegion(int index) {
+ IStructuredDocumentRegion node = firstStructuredDocumentRegion;
+ for (int i = index; i > 0; i--) {
+ if (node == null)
+ return null;
+ node = node.getNext();
+ }
+ return node;
+ }
+
+ /**
+ * @return int
+ */
+ int getStructuredDocumentRegionCount() {
+ if (firstStructuredDocumentRegion == null)
+ return 0;
+
+ IStructuredDocumentRegion node = firstStructuredDocumentRegion;
+ int i = 0;
+ for (; node != null; i++)
+ node = node.getNext();
+ return i;
+ }
+
+ IStructuredDocumentRegion getLastStructuredDocumentRegion() {
+ return lastStructuredDocumentRegion;
+ }
+
+ /**
+ * @return int
+ */
+ public int getStartOffset() {
+ IStructuredDocumentRegion flatNode = getFirstStructuredDocumentRegion();
+ if (flatNode != null)
+ return flatNode.getStart();
+ return -1;
+ }
+
+ boolean includeRangeStructuredDocumentRegion(IStructuredDocumentRegion first, IStructuredDocumentRegion last) {
+ boolean bModified = false;
+
+ // validate range of parameters
+ if (first != null && last != null) {
+ if (first.getStart() > last.getStart()) {
+ IStructuredDocumentRegion node = first;
+ first = last;
+ last = node;
+ }
+ }
+
+ // validate mine
+ boolean b = validateRange();
+ bModified = b || bModified;
+
+ if (first != null) {
+ if (getFirstStructuredDocumentRegion() == null || getFirstStructuredDocumentRegion().getStart() > first.getStart()) {
+ setFirstStructuredDocumentRegion(first);
+ bModified = true;
+ }
+ }
+
+ if (last != null) {
+ if (getLastStructuredDocumentRegion() == null || getLastStructuredDocumentRegion().getStart() < last.getStart()) {
+ setLastStructuredDocumentRegion(last);
+ bModified = true;
+ }
+ }
+
+ // re-validate
+ if (bModified)
+ validateRange();
+
+ return bModified;
+ }
+
+ /**
+ *
+ */
+ public boolean propagateRangeStructuredDocumentRegion() {
+ boolean bModified = false;
+
+ CSSStructuredDocumentRegionContainer parent = (CSSStructuredDocumentRegionContainer) getParentNode();
+ if (parent == null)
+ return bModified;
+
+ boolean b = parent.includeRangeStructuredDocumentRegion(getFirstStructuredDocumentRegion(), getLastStructuredDocumentRegion());
+ bModified = b || bModified;
+
+ if (b)
+ parent.propagateRangeStructuredDocumentRegion();
+ // else need not update range of ancestors
+
+ return bModified;
+ }
+
+ /**
+ * @param cssText
+ * java.lang.String
+ */
+ public void setCssText(String cssText) {
+ if (firstStructuredDocumentRegion != null) {
+ getOwnerDocument().getModel().getStructuredDocument().replaceText(this, getStartOffset(), getEndOffset() - getStartOffset(), cssText);
+ }
+ else
+ super.setCssText(cssText);
+ }
+
+ IStructuredDocumentRegion setFirstStructuredDocumentRegion(IStructuredDocumentRegion node) {
+ firstStructuredDocumentRegion = node;
+ return node;
+ }
+
+ IStructuredDocumentRegion setLastStructuredDocumentRegion(IStructuredDocumentRegion node) {
+ lastStructuredDocumentRegion = node;
+ return node;
+ }
+
+ public void setRangeStructuredDocumentRegion(IStructuredDocumentRegion firstNode, IStructuredDocumentRegion lastNode) {
+ if (firstNode != null)
+ setFirstStructuredDocumentRegion(firstNode);
+ if (lastNode != null)
+ setLastStructuredDocumentRegion(lastNode);
+
+ if (firstNode == null && lastNode == null) {
+ setFirstStructuredDocumentRegion(null);
+ setLastStructuredDocumentRegion(null);
+ }
+ else { // range validation
+ validateRange();
+ }
+ }
+
+ /**
+ * @return boolean
+ */
+ private boolean validateRange() {
+ boolean bModified = false;
+
+ if (firstStructuredDocumentRegion != null || lastStructuredDocumentRegion != null) {
+ if (this.firstStructuredDocumentRegion == null) {
+ this.firstStructuredDocumentRegion = this.lastStructuredDocumentRegion;
+ bModified = true;
+ }
+ else if (this.lastStructuredDocumentRegion == null) {
+ this.lastStructuredDocumentRegion = this.firstStructuredDocumentRegion;
+ bModified = true;
+ }
+ else if (this.firstStructuredDocumentRegion.getStart() > this.lastStructuredDocumentRegion.getStart()) {
+ // need to swap first for last
+ IStructuredDocumentRegion node = firstStructuredDocumentRegion;
+ firstStructuredDocumentRegion = lastStructuredDocumentRegion;
+ lastStructuredDocumentRegion = node;
+ bModified = true;
+ }
+ }
+
+ return bModified;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java
new file mode 100644
index 0000000..94a5cc6
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclItemImpl.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator;
+import org.eclipse.wst.css.core.internal.formatter.StyleDeclItemFormatter;
+import org.eclipse.wst.css.core.internal.parser.CSSSourceParser;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.text.TextRegionListImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ *
+ */
+class CSSStyleDeclItemImpl extends CSSStructuredDocumentRegionContainer implements ICSSStyleDeclItem {
+
+ private java.lang.String fPropertyName;
+
+ /**
+ * CSSStyleDeclItemImpl constructor comment.
+ *
+ */
+ CSSStyleDeclItemImpl(CSSStyleDeclItemImpl that) {
+ super(that);
+ this.fPropertyName = that.fPropertyName;
+ }
+
+ /**
+ * CSSStyleDeclItemImpl constructor comment.
+ */
+ CSSStyleDeclItemImpl(String propertyName) {
+ super();
+ this.fPropertyName = propertyName;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ public ICSSPrimitiveValue appendValue(ICSSPrimitiveValue value) throws DOMException {
+ return insertValueBefore(value, null);
+ }
+
+ /**
+ * @param deep
+ * boolean
+ */
+ public ICSSNode cloneNode(boolean deep) {
+ CSSStyleDeclItemImpl cloned = new CSSStyleDeclItemImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ String generateValueSource() {
+ CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(this);
+ if (formatter != null && formatter instanceof StyleDeclItemFormatter)
+ return ((StyleDeclItemFormatter) formatter).formatValue(this).toString();
+ else
+ return "";//$NON-NLS-1$
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSValue
+ */
+ public CSSValue getCSSValue() {
+ int nValue = getLength();
+ if (nValue <= 0)
+ return null;
+ else if (nValue == 1)
+ return item(0);
+ else
+ return this;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public java.lang.String getCSSValueText() {
+ if (getFirstChild() == null)
+ return "";//$NON-NLS-1$
+ // check whether children has flatnodes
+ ICSSNode child = getFirstChild();
+ while (child != null) {
+ if (((IndexedRegion) child).getEndOffset() <= 0)
+ return generateValueSource();
+ child = child.getNextSibling();
+ }
+
+ IStructuredDocumentRegion node = getFirstStructuredDocumentRegion();
+ int start = ((IndexedRegion) getFirstChild()).getStartOffset() - node.getStartOffset();
+ int end = ((IndexedRegion) getLastChild()).getEndOffset() - node.getStartOffset();
+ return node.getText().substring(start, end);
+ }
+
+ /**
+ * @return short
+ */
+ public short getCssValueType() {
+ return CSS_VALUE_LIST;
+ }
+
+ /**
+ * @return int
+ */
+ public int getLength() {
+ int i = 0;
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSPrimitiveValueImpl)
+ i++;
+ }
+ return i;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return STYLEDECLITEM_NODE;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public java.lang.String getPriority() {
+ return getAttribute(IMPORTANT);
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ public String getPropertyName() {
+ String name = fPropertyName.trim();
+ return PropCMProperty.getInstanceOf(name) != null ? fPropertyName.trim().toLowerCase() : name;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param newValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @param refValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ ICSSPrimitiveValue insertValueBefore(ICSSPrimitiveValue newValue, ICSSPrimitiveValue refValue) {
+ ICSSNode node = insertBefore((CSSNodeImpl) newValue, (CSSNodeImpl) refValue);
+ return (ICSSPrimitiveValue) node;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSValue
+ * @param index
+ * int
+ */
+ public CSSValue item(int index) {
+ int i = 0;
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSPrimitiveValueImpl) {
+ if (i++ == index)
+ return (CSSValue) node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ public ICSSPrimitiveValue removeValue(ICSSPrimitiveValue value) throws DOMException {
+ ICSSNode node = removeChild((CSSNodeImpl) value);
+ return (ICSSPrimitiveValue) node;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param newValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @param oldValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ public ICSSPrimitiveValue replaceValue(ICSSPrimitiveValue newValue, ICSSPrimitiveValue oldValue) throws DOMException {
+ if (oldValue == null)
+ return newValue;
+ if (newValue != null)
+ insertValueBefore(newValue, oldValue);
+ return removeValue(oldValue);
+ }
+
+ /**
+ * @param value
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setCssValueText(String value) throws DOMException {
+ ICSSNode child = getFirstChild();
+ while (child != null) {
+ ICSSNode next = child.getNextSibling();
+ if (child instanceof ICSSPrimitiveValue) {
+ removeChild((CSSNodeImpl) child);
+ }
+ child = next;
+ }
+ setCssValueTextCore(value);
+ }
+
+ private void setCssValueTextCore(String value) throws DOMException {
+ // use temporary document
+ synchronized (CSSStyleDeclarationImpl.class) {
+ if (sharedStructuredDocument == null) {
+ IDocumentLoader loader = new CSSDocumentLoader();
+ sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
+ ((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
+
+ }
+ sharedStructuredDocument.set(value);
+ IStructuredDocumentRegion node = sharedStructuredDocument.getFirstStructuredDocumentRegion();
+
+ if (node == null) {
+ return;
+ }
+ if (node.getNext() != null) {
+ throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$
+ }
+
+ CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(getOwnerDocument());
+ itemParser.setStructuredDocumentTemporary(true);
+ // make a copy of nodelist because setupValues will destroy list
+ ITextRegionList nodeList = new TextRegionListImpl(node.getRegions());
+ itemParser.setupValues(this, node, nodeList);
+ }
+ }
+
+ private static IStructuredDocument sharedStructuredDocument;
+
+ /**
+ * @param newPriority
+ * java.lang.String
+ */
+ public void setPriority(java.lang.String newPriority) throws DOMException {
+ setAttribute(IMPORTANT, newPriority);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java
new file mode 100644
index 0000000..1d56480
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationFactoryContext.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+
+public abstract class CSSStyleDeclarationFactoryContext {
+
+ protected ICSSDocument fOwnerDocument = null;
+
+ /**
+ *
+ */
+ protected void cloneChildNodes(ICSSNode src, ICSSNode dest) {
+ if (fOwnerDocument == null) {
+ return;
+ }
+ if (!(dest instanceof CSSNodeImpl)) {
+ return;
+ }
+
+ CSSNodeImpl container = (CSSNodeImpl) dest;
+ container.removeChildNodes();
+
+ for (ICSSNode child = src.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof CSSStyleDeclItemImpl) {
+ // extract shorthand property ..
+ // --> Temp
+ ICSSNode cloned = child.cloneNode(false);
+ if (cloned instanceof CSSNodeImpl) {
+ ((CSSNodeImpl) cloned).setOwnerDocument(fOwnerDocument);
+ container.appendChild((CSSNodeImpl) cloned);
+ cloneChildNodes(child, cloned);
+ }
+ // <-- Temp
+ }
+ else {
+ ICSSNode cloned = child.cloneNode(false);
+ if (cloned instanceof CSSNodeImpl) {
+ ((CSSNodeImpl) cloned).setOwnerDocument(fOwnerDocument);
+ container.appendChild((CSSNodeImpl) cloned);
+ cloneChildNodes(child, cloned);
+ }
+ }
+ }
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSStyleDeclaration
+ */
+ public ICSSStyleDeclaration createStyleDeclaration() {
+ CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(true);
+ decl.setOwnerDocument(decl);
+ return decl;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java
new file mode 100644
index 0000000..90aed46
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleDeclarationImpl.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ *
+ */
+class CSSStyleDeclarationImpl extends CSSDocumentImpl implements ICSSStyleDeclaration {
+
+ private boolean fIsDocument;
+
+ CSSStyleDeclarationImpl(CSSStyleDeclarationImpl that) {
+ super(that);
+ this.fIsDocument = that.fIsDocument;
+ if (fIsDocument) {
+ setOwnerDocument(this);
+ }
+ }
+
+ CSSStyleDeclarationImpl(boolean isDocument) {
+ super();
+ fIsDocument = isDocument;
+ if (fIsDocument) {
+ setOwnerDocument(this);
+ }
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSStyleDeclarationImpl cloned = new CSSStyleDeclarationImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ public ICSSStyleDeclItem getDeclItemNode(String propertyName) {
+ ICSSNode node = getLastChild();
+ propertyName = propertyName.trim();
+ while (node != null) {
+ if (node instanceof CSSStyleDeclItemImpl) {
+ ICSSStyleDeclItem item = (ICSSStyleDeclItem) node;
+ if (propertyName.compareToIgnoreCase(item.getPropertyName().trim()) == 0)
+ return item;
+ }
+ node = node.getPreviousSibling();
+ }
+ return null;
+ }
+
+ /**
+ * @return int
+ */
+ public int getLength() {
+ int i = 0;
+ ICSSNode node = getFirstChild();
+ while (node != null) {
+ if (node instanceof CSSStyleDeclItemImpl)
+ i++;
+ node = node.getNextSibling();
+ }
+ return i;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return STYLEDECLARATION_NODE;
+ }
+
+ /**
+ * The CSS rule that contains this declaration block or <code>null</code>
+ * if this <code>CSSStyleDeclaration</code> is not attached to a
+ * <code>CSSRule</code>.
+ */
+ public CSSRule getParentRule() {
+ ICSSNode parent = getParentNode();
+ if (parent instanceof CSSRule)
+ return (CSSRule) parent;
+ return null;
+ }
+
+ /**
+ * Used to retrieve the object representation of the value of a CSS
+ * property if it has been explicitly set within this declaration block.
+ * This method returns <code>null</code> if the property is a shorthand
+ * property. Shorthand property values can only be accessed and modified
+ * as strings, using the <code>getPropertyValue</code> and
+ * <code>setProperty</code> methods.
+ *
+ * @param propertyName
+ * The name of the CSS property. See the CSS property index.
+ * @return Returns the value of the property if it has been explicitly set
+ * for this declaration block. Returns <code>null</code> if the
+ * property has not been set.
+ */
+ public CSSValue getPropertyCSSValue(String propertyName) {
+ ICSSStyleDeclItem item = getDeclItemNode(propertyName);
+ if (item != null)
+ return item.getCSSValue();
+ return null;
+ }
+
+ /**
+ * Used to retrieve the priority of a CSS property (e.g. the
+ * <code>"important"</code> qualifier) if the property has been
+ * explicitly set in this declaration block.
+ *
+ * @param propertyName
+ * The name of the CSS property. See the CSS property index.
+ * @return A string representing the priority (e.g.
+ * <code>"important"</code>) if one exists. The empty string if
+ * none exists.
+ */
+ public String getPropertyPriority(String propertyName) {
+ ICSSStyleDeclItem item = getDeclItemNode(propertyName);
+ if (item != null)
+ return item.getPriority();
+ return null;
+ }
+
+ /**
+ * Used to retrieve the value of a CSS property if it has been explicitly
+ * set within this declaration block.
+ *
+ * @param propertyName
+ * The name of the CSS property. See the CSS property index.
+ * @return Returns the value of the property if it has been explicitly set
+ * for this declaration block. Returns the empty string if the
+ * property has not been set.
+ */
+ public String getPropertyValue(String propertyName) {
+ CSSValue value = getPropertyCSSValue(propertyName);
+ if (value != null)
+ return ((ICSSValue) value).getCSSValueText();
+ return null;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isDocument() {
+ return fIsDocument;
+ }
+
+ /**
+ * Used to retrieve the properties that have been explicitly set in this
+ * declaration block. The order of the properties retrieved using this
+ * method does not have to be the order in which they were set. This
+ * method can be used to iterate over all properties in this declaration
+ * block.
+ *
+ * @param index
+ * Index of the property name to retrieve.
+ * @return The name of the property at this ordinal position. The empty
+ * string if no property exists at this position.
+ */
+ public String item(int index) {
+ if (index < 0)
+ return null;
+
+ int i = 0;
+ ICSSNode node = getFirstChild();
+ while (node != null) {
+ if (node instanceof CSSStyleDeclItemImpl) {
+ if (i != index)
+ i++;
+ else {
+ CSSStyleDeclItemImpl item = (CSSStyleDeclItemImpl) node;
+ return item.getPropertyName();
+ }
+ }
+ node = node.getNextSibling();
+ }
+ return null;
+ }
+
+ public ICSSStyleDeclItem removeDeclItemNode(ICSSStyleDeclItem oldDecl) throws DOMException {
+ return (ICSSStyleDeclItem) removeChild((CSSNodeImpl) oldDecl);
+ }
+
+ /**
+ * Used to remove a CSS property if it has been explicitly set within this
+ * declaration block.
+ *
+ * @param propertyName
+ * The name of the CSS property. See the CSS property index.
+ * @return Returns the value of the property if it has been explicitly set
+ * for this declaration block. Returns the empty string if the
+ * property has not been set or the property name does not
+ * correspond to a known CSS property.
+ * @exception DOMException
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration
+ * is readonly or the property is readonly.
+ */
+ public String removeProperty(String propertyName) throws DOMException {
+ ICSSStyleDeclItem item = getDeclItemNode(propertyName);
+ if (item != null) {
+ removeChild((CSSNodeImpl) item);
+ return item.getCssText();
+ }
+ return null;
+ }
+
+ public ICSSStyleDeclItem setDeclItemNode(ICSSStyleDeclItem newDecl) throws DOMException {
+ if (newDecl == null)
+ return null;
+
+ ICSSStyleDeclItem item = getDeclItemNode(newDecl.getPropertyName());
+ if (item != null)
+ return (ICSSStyleDeclItem) replaceChild((CSSNodeImpl) newDecl, (CSSNodeImpl) item);
+ else
+ return (ICSSStyleDeclItem) appendChild((CSSNodeImpl) newDecl);
+ }
+
+ /**
+ * Used to set a property value and priority within this declaration
+ * block.
+ *
+ * @param propertyName
+ * The name of the CSS property. See the CSS property index.
+ * @param value
+ * The new value of the property.
+ * @param priority
+ * The new priority of the property (e.g.
+ * <code>"important"</code>).
+ * @exception DOMException
+ * SYNTAX_ERR: Raised if the specified value has a syntax
+ * error and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration
+ * is readonly or the property is readonly.
+ */
+ public void setProperty(String propertyName, String value, String priority) throws DOMException {
+ if (propertyName.equals("")) //$NON-NLS-1$
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, ""); //$NON-NLS-1$
+
+ // You can use this only if CSSValue.setCssText() is implemented
+ CSSStyleDeclItemImpl item = (CSSStyleDeclItemImpl) getDeclItemNode(propertyName);
+ if (item == null) {
+ item = (CSSStyleDeclItemImpl) getOwnerDocument().createCSSStyleDeclItem(propertyName);
+ appendChild(item);
+ }
+
+ // ICSSNode next = item.getNextSibling();
+ // removeChild(item);
+
+ item.setCssValueText(value);
+ item.setPriority(priority);
+
+ // insertBefore(item, (CSSNodeImpl)next);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java
new file mode 100644
index 0000000..3366f09
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleRuleImpl.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.w3c.dom.DOMException;
+
+
+/**
+ *
+ */
+class CSSStyleRuleImpl extends CSSRuleDeclContainer implements ICSSStyleRule {
+
+ ICSSSelectorList fSelectorList = new CSSSelectorListImpl(null);
+
+ /**
+ *
+ */
+ CSSStyleRuleImpl() {
+ super();
+ }
+
+ CSSStyleRuleImpl(CSSStyleRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSStyleRuleImpl cloned = new CSSStyleRuleImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * @return java.lang.String
+ */
+ String extractPreString() {
+ return getSelectorText();
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return STYLERULE_NODE;
+ }
+
+ public ICSSSelectorList getSelectors() {
+ return fSelectorList;
+ }
+
+ /**
+ * The textual representation of the selector for the rule set. The
+ * implementation may have stripped out insignificant whitespace while
+ * parsing the selector.
+ *
+ * @exception DOMException
+ * SYNTAX_ERR: Raised if the specified CSS string value has
+ * a syntax error and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this rule is
+ * readonly.
+ */
+ public String getSelectorText() {
+ return getAttribute(SELECTOR);
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return STYLE_RULE;
+ }
+
+ /**
+ *
+ */
+ public void setSelectorText(String selectorText) throws DOMException {
+ setAttribute(SELECTOR, selectorText);
+ fSelectorList = new CSSSelectorListImpl(selectorText);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java
new file mode 100644
index 0000000..2e66af5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSStyleSheetImpl.java
@@ -0,0 +1,654 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.CSSCoreMessages;
+import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.internal.util.ImportRuleCollector;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.util.Assert;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.css.CSSFontFaceRule;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.css.CSSStyleSheet;
+import org.w3c.dom.css.CSSUnknownRule;
+import org.w3c.dom.stylesheets.MediaList;
+import org.w3c.dom.stylesheets.StyleSheet;
+import org.w3c.dom.stylesheets.StyleSheetList;
+
+/**
+ *
+ */
+class CSSStyleSheetImpl extends CSSDocumentImpl implements ICSSStyleSheet {
+
+
+ class InternalNodeList implements NodeList {
+
+ Vector nodes = new Vector();
+
+ public int getLength() {
+ if (nodes == null)
+ return 0;
+ else
+ return nodes.size();
+ }
+
+ public Node item(int i) {
+ if (nodes == null)
+ return null;
+ if (i < 0 || nodes.size() <= i)
+ return null;
+ return (Node) nodes.get(i);
+ }
+ }
+
+ class InternalStyleSheetList extends AbstractCSSNodeList implements StyleSheetList {
+
+ public ICSSNode appendNode(ICSSNode node) {
+ if (nodes == null || !nodes.contains(node))
+ return super.appendNode(node);
+ else
+ return node;
+ }
+
+ public StyleSheet item(int i) {
+ return (StyleSheet) itemImpl(i);
+ }
+ }
+
+ private boolean fDisabled = false;
+
+ /**
+ *
+ */
+ CSSStyleSheetImpl() {
+ super();
+ setOwnerDocument(this);
+ }
+
+ CSSStyleSheetImpl(CSSStyleSheetImpl that) {
+ super(that);
+ setOwnerDocument(this);
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule appendRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException {
+ if (rule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) appendChild((CSSNodeImpl) rule);
+ return ret;
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSStyleSheetImpl cloned = new CSSStyleSheetImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSCharsetRule
+ */
+ public ICSSCharsetRule createCSSCharsetRule() {
+ CSSCharsetRuleImpl rule = new CSSCharsetRuleImpl();
+ rule.setOwnerDocument(this);
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSFontFaceRule
+ */
+ public CSSFontFaceRule createCSSFontFaceRule() {
+ CSSFontFaceRuleImpl rule = new CSSFontFaceRuleImpl();
+ CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration();
+
+ rule.appendChild(style);
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSImportRule
+ */
+ public ICSSImportRule createCSSImportRule() {
+ CSSImportRuleImpl rule = new CSSImportRuleImpl();
+ MediaListImpl media = (MediaListImpl) createMediaList();
+
+ rule.appendChild(media);
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.ICSSMediaRule
+ */
+ public ICSSMediaRule createCSSMediaRule() {
+ CSSMediaRuleImpl rule = new CSSMediaRuleImpl();
+ MediaListImpl media = (MediaListImpl) createMediaList();
+
+ rule.insertBefore(media, (CSSNodeImpl) rule.getFirstChild()); // media
+ // must
+ // be
+ // the
+ // top
+ // of
+ // children
+ // list
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSPageRule
+ */
+ public ICSSPageRule createCSSPageRule() {
+ CSSPageRuleImpl rule = new CSSPageRuleImpl();
+ CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration();
+
+ rule.appendChild(style);
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * java.lang.String
+ */
+ public CSSRule createCSSRule(String rule) {
+ CSSDocumentLoader loader = new CSSDocumentLoader();
+ IStructuredDocument structuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
+ structuredDocument.set(rule);
+
+ //CSSModelParser modelParser = new CSSModelParser((CSSDocumentImpl) getOwnerDocument());
+ CSSModelParser modelParser = new CSSModelParser(getOwnerDocument());
+ return modelParser.createCSSRule(structuredDocument.getRegionList());
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleDeclaration
+ */
+ public ICSSStyleDeclaration createCSSStyleDeclaration() {
+ CSSStyleDeclarationImpl decl = new CSSStyleDeclarationImpl(false);
+ decl.setOwnerDocument(this);
+
+ return decl;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleRule
+ */
+ public ICSSStyleRule createCSSStyleRule() {
+ CSSStyleRuleImpl rule = new CSSStyleRuleImpl();
+ CSSStyleDeclarationImpl style = (CSSStyleDeclarationImpl) createCSSStyleDeclaration();
+
+ rule.appendChild(style);
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSUnknownRule
+ */
+ public CSSUnknownRule createCSSUnknownRule() {
+ CSSUnknownRuleImpl rule = new CSSUnknownRuleImpl();
+ rule.setOwnerDocument(this);
+
+ return rule;
+ }
+
+ /**
+ * @return org.w3c.dom.stylesheets.MediaList
+ */
+ public MediaList createMediaList() {
+ MediaListImpl media = new MediaListImpl();
+ media.setOwnerDocument(this);
+
+ return media;
+ }
+
+ /**
+ * Used to delete a rule from the style sheet.
+ *
+ * @param index
+ * The index within the style sheet's rule list of the rule to
+ * remove.
+ * @exception DOMException
+ * INDEX_SIZE_ERR: Raised if the specified index does not
+ * correspond to a rule in the style sheet's rule list.
+ * <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet
+ * is readonly.
+ */
+ public void deleteRule(int index) throws DOMException {
+ CSSNodeImpl node = getIndexedRule(index);
+ if (node != null)
+ removeChild(node);
+ }
+
+ /**
+ * The list of all CSS rules contained within the style sheet. This
+ * includes both rule sets and at-rules.
+ */
+ public CSSRuleList getCssRules() {
+ CSSRuleListImpl list = new CSSRuleListImpl();
+
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSRule) {
+ list.appendNode(node);
+ }
+ }
+
+ return list;
+ }
+
+ public CSSRuleList getCssRules(boolean shouldImport) {
+ if (!shouldImport)
+ return getCssRules();
+
+ CSSRuleListImpl list = new CSSRuleListImpl();
+ Stack refs = new Stack();
+ getRules(list, this, refs);
+ return list;
+ }
+
+ private void getRules(CSSRuleListImpl list, ICSSStyleSheet sheet, Stack refs) {
+ String href = sheet.getHref();
+ if (href != null) {
+ // Avoid circular @imports
+ if (refs.contains(href))
+ return;
+ refs.push(href);
+ }
+ boolean acceptImports = true;
+ for (ICSSNode node = sheet.getFirstChild(); node != null; node = node.getNextSibling()) {
+ // Import the stylesheet into the list
+ // @import rules must precede all other rules, according to the spec
+ if (node.getNodeType() == ICSSNode.IMPORTRULE_NODE && acceptImports) {
+ CSSStyleSheet importSheet = ((ICSSImportRule) node).getStyleSheet();
+ if (importSheet instanceof ICSSStyleSheet)
+ getRules(list, (ICSSStyleSheet) importSheet, refs);
+ else
+ list.appendNode(node);
+ }
+ // Add the rule to the list
+ else if (node instanceof CSSRule) {
+ list.appendNode(node);
+ if (node.getNodeType() != ICSSNode.CHARSETRULE_NODE)
+ acceptImports = false;
+ }
+ }
+ if (href != null)
+ refs.pop();
+ }
+
+ /**
+ * <code>false</code> if the style sheet is applied to the document.
+ * <code>true</code> if it is not. Modifying this attribute may cause a
+ * new resolution of style for the document. A stylesheet only applies if
+ * both an appropriate medium definition is present and the disabled
+ * attribute is false. So, if the media doesn't apply to the current user
+ * agent, the <code>disabled</code> attribute is ignored.
+ */
+ public boolean getDisabled() {
+ return fDisabled;
+ }
+
+ /**
+ * If the style sheet is a linked style sheet, the value of its attribute
+ * is its location. For inline style sheets, the value of this attribute
+ * is <code>null</code>. See the href attribute definition for the
+ * <code>LINK</code> element in HTML 4.0, and the href pseudo-attribute
+ * for the XML style sheet processing instruction.
+ */
+ public String getHref() {
+ ICSSModel model = getModel();
+ if (model != null && model.getStyleSheetType() == ICSSModel.EXTERNAL) {
+ return model.getBaseLocation();
+ /*
+ * Object id = model.getId(); if (id != null) { if (id instanceof
+ * IResource) { // TODO: need to check whether this is correct or
+ * not, later. return ((IResource)id).getFullPath().toString(); }
+ * return id.toString(); }
+ */}
+ return null;
+ }
+
+ CSSRuleImpl getIndexedRule(int index) {
+ if (index < 0)
+ return null;
+
+ int i = 0;
+ for (ICSSNode node = getFirstChild(); node != null; node = node.getNextSibling()) {
+ if (node instanceof CSSRule) {
+ if (i++ == index)
+ return (CSSRuleImpl) node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * The intended destination media for style information. The media is
+ * often specified in the <code>ownerNode</code>. If no media has been
+ * specified, the <code>MediaList</code> will be empty. See the media
+ * attribute definition for the <code>LINK</code> element in HTML 4.0,
+ * and the media pseudo-attribute for the XML style sheet processing
+ * instruction . Modifying the media list may cause a change to the
+ * attribute <code>disabled</code>.
+ */
+ public MediaList getMedia() {
+ return null;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return STYLESHEET_NODE;
+ }
+
+ /**
+ * The node that associates this style sheet with the document. For HTML,
+ * this may be the corresponding <code>LINK</code> or <code>STYLE</code>
+ * element. For XML, it may be the linking processing instruction. For
+ * style sheets that are included by other style sheets, the value of this
+ * attribute is <code>null</code>.
+ */
+ public Node getOwnerNode() {
+ // for <LINK> tag or <STYLE> tag
+ ICSSModel model = getModel();
+ if (model != null)
+ return model.getOwnerDOMNode();
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.NodeList
+ */
+ public org.w3c.dom.NodeList getOwnerNodes() {
+ List list = (getModel().getStyleListeners() != null) ? new Vector(getModel().getStyleListeners()) : null;
+ if (list == null)
+ return null;
+ InternalNodeList nodes = new InternalNodeList();
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj instanceof IStyleSheetAdapter) {
+ nodes.nodes.add(((IStyleSheetAdapter) obj).getElement());
+ }
+ }
+ if (nodes.getLength() > 0)
+ return nodes;
+ else
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.NodeList
+ * @param doc
+ * org.w3c.dom.Document
+ */
+ public NodeList getOwnerNodes(Document doc) {
+ List list = (getModel().getStyleListeners() != null) ? new Vector(getModel().getStyleListeners()) : null;
+ if (list == null)
+ return null;
+ InternalNodeList nodes = new InternalNodeList();
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj instanceof IStyleSheetAdapter) {
+ Element ele = ((IStyleSheetAdapter) obj).getElement();
+ if (ele.getOwnerDocument() == doc)
+ nodes.nodes.add(ele);
+ }
+ }
+ if (nodes.getLength() > 0)
+ return nodes;
+ else
+ return null;
+ }
+
+ /**
+ * If this style sheet comes from an <code>@import</code> rule, the <code>ownerRule</code> attribute will
+ * contain the <code>CSSImportRule</code>. In that case, the
+ * <code>ownerNode</code> attribute in the
+ * <code>StyleSheet</code> interface will be <code>null</code>.
+ * If the style sheet comes from an element or a processing
+ * instruction, the <code>ownerRule</code> attribute will be
+ * <code>null</code> and the <code>ownerNode</code> attribute
+ * will contain the <code>Node</code>.
+ */
+ public CSSRule getOwnerRule() {
+ Assert.isTrue(false, CSSCoreMessages.You_cannot_use_CSSStyleShe_UI_); //$NON-NLS-1$ = "You cannot use CSSStyleSheet.getOwnerRule() because of many referencers of this rule\nPlease use getOnwerRules()"
+ // for @import
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRuleList
+ */
+ public org.w3c.dom.css.CSSRuleList getOwnerRules() {
+ StyleSheetList list = getParentStyleSheets();
+ if (list == null)
+ return null;
+ CSSRuleListImpl ruleList = new CSSRuleListImpl();
+ for (int i = 0; i < list.getLength(); i++) {
+ ImportRuleCollector trav = new ImportRuleCollector(this);
+ trav.apply((ICSSStyleSheet) list.item(i));
+ ruleList.nodes.addAll(trav.getRules());
+ }
+ return ruleList;
+ }
+
+ /**
+ * For style sheet languages that support the concept of style sheet
+ * inclusion, this attribute represents the including style sheet, if one
+ * exists. If the style sheet is a top-level style sheet, or the style
+ * sheet language does not support inclusion, the value of this attribute
+ * is <code>null</code>.
+ */
+ public StyleSheet getParentStyleSheet() {
+ CSSRule owner = getOwnerRule();
+ if (owner != null)
+ return owner.getParentStyleSheet();
+ return null;
+ }
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheetList
+ */
+ public org.w3c.dom.stylesheets.StyleSheetList getParentStyleSheets() {
+ List list = (getModel().getStyleListeners() != null) ? new Vector(getModel().getStyleListeners()) : null;
+ if (list == null)
+ return null;
+ InternalStyleSheetList sheets = new InternalStyleSheetList();
+ Iterator it = list.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj instanceof ICSSModel) {
+ sheets.appendNode(((ICSSModel) obj).getDocument());
+ }
+ }
+ if (sheets.getLength() > 0)
+ return sheets;
+ else
+ return null;
+ }
+
+ /**
+ * The advisory title. The title is often specified in the
+ * <code>ownerNode</code>. See the title attribute definition for the
+ * <code>LINK</code> element in HTML 4.0, and the title pseudo-attribute
+ * for the XML style sheet processing instruction.
+ */
+ public String getTitle() {
+ Node node = getOwnerNode();
+ if (node instanceof Element) {
+ return ((Element) node).hasAttribute("TITLE") ? ((Element) node).getAttribute("TITLE") : null;//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ /**
+ * This specifies the style sheet language for this style sheet. The style
+ * sheet language is specified as a content type (e.g. "text/css"). The
+ * content type is often specified in the <code>ownerNode</code>. Also
+ * see the type attribute definition for the <code>LINK</code> element
+ * in HTML 4.0, and the type pseudo-attribute for the XML style sheet
+ * processing instruction.
+ */
+ public String getType() {
+ Node node = getOwnerNode();
+ if (node instanceof Element) {
+ return ((Element) node).hasAttribute("TYPE") ? ((Element) node).getAttribute("TYPE") : null;//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ /**
+ * Used to insert a new rule into the style sheet. The new rule now
+ * becomes part of the cascade.
+ *
+ * @param rule
+ * The parsable text representing the rule. For rule sets this
+ * contains both the selector and the style declaration. For
+ * at-rules, this specifies both the at-identifier and the rule
+ * content.
+ * @param index
+ * The index within the style sheet's rule list of the rule
+ * before which to insert the specified rule. If the specified
+ * index is equal to the length of the style sheet's rule
+ * collection, the rule will be added to the end of the style
+ * sheet.
+ * @return The index within the style sheet's rule collection of the newly
+ * inserted rule.
+ * @exception DOMException
+ * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be
+ * inserted at the specified index e.g. if an
+ * <code>@import</code> rule is inserted after a standard rule set or other
+ * at-rule. <br>
+ * INDEX_SIZE_ERR: Raised if the specified index is not a valid
+ * insertion point. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
+ * readonly. <br>
+ * SYNTAX_ERR: Raised if the specified rule has a syntax error and
+ * is unparsable.
+ */
+ public int insertRule(String rule, int index) throws DOMException {
+ int length = getCssRules().getLength();
+ if (index < 0 || length < index)
+ throw new DOMException(DOMException.INDEX_SIZE_ERR, "");//$NON-NLS-1$
+
+ IStructuredDocument doc = getModel().getStructuredDocument();
+ CSSRuleImpl refRule = (length != index) ? getIndexedRule(index) : null;
+ int offset = (refRule != null) ? refRule.getStartOffset() : doc.getLength();
+ doc.replaceText(this, offset, 0, rule);
+
+ // insertBefore((CSSNodeImpl) createCSSRule(rule),refRule);
+ return index;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newRule
+ * org.w3c.dom.css.CSSRule
+ * @param refRule
+ * org.w3c.dom.css.CSSRule
+ */
+ public org.w3c.dom.css.CSSRule insertRuleBefore(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule refRule) throws org.w3c.dom.DOMException {
+ if (newRule == null && refRule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) insertBefore((CSSNodeImpl) newRule, (CSSNodeImpl) refRule);
+ return ret;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean isDocument() {
+ return true;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule removeRule(org.w3c.dom.css.CSSRule rule) throws org.w3c.dom.DOMException {
+ if (rule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) removeChild((CSSNodeImpl) rule);
+ return ret;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newChild
+ * org.w3c.dom.css.CSSRule
+ * @param oldChild
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public org.w3c.dom.css.CSSRule replaceRule(org.w3c.dom.css.CSSRule newRule, org.w3c.dom.css.CSSRule oldRule) throws org.w3c.dom.DOMException {
+ if (newRule == null && oldRule == null)
+ return null;
+
+ CSSRule ret = (CSSRule) replaceChild((CSSNodeImpl) newRule, (CSSNodeImpl) oldRule);
+ return ret;
+ }
+
+ /**
+ * setDisabled method comment.
+ */
+ public void setDisabled(boolean disabled) {
+ this.fDisabled = disabled;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSUnknownRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSUnknownRuleImpl.java
new file mode 100644
index 0000000..a93ed75
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSUnknownRuleImpl.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSUnknownRule;
+
+
+/**
+ *
+ */
+class CSSUnknownRuleImpl extends CSSRuleImpl implements CSSUnknownRule {
+
+ // TODO: This field is never read
+ String fCssText = null;
+
+ /**
+ *
+ */
+ CSSUnknownRuleImpl() {
+ super();
+ }
+
+ CSSUnknownRuleImpl(CSSUnknownRuleImpl that) {
+ super(that);
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ CSSUnknownRuleImpl cloned = new CSSUnknownRuleImpl(this);
+
+ return cloned;
+ }
+
+ /**
+ * @return short
+ */
+ public short getNodeType() {
+ return UNKNOWNRULE_NODE;
+ }
+
+ /**
+ * The type of the rule, as defined above. The expectation is that
+ * binding-specific casting methods can be used to cast down from an
+ * instance of the <code>CSSRule</code> interface to the specific
+ * derived interface implied by the <code>type</code>.
+ */
+ public short getType() {
+ return UNKNOWN_RULE;
+ }
+
+ /**
+ * @param cssText
+ * java.lang.String
+ */
+ public void setCssText(String cssText) {
+ this.fCssText = cssText;
+
+ super.setCssText(cssText);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CounterImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CounterImpl.java
new file mode 100644
index 0000000..2b921f7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CounterImpl.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICounter;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.Counter;
+
+
+/**
+ *
+ */
+class CounterImpl extends CSSPrimitiveContainer implements ICounter {
+
+ /**
+ *
+ */
+ CounterImpl() {
+ super(CSS_COUNTER);
+ }
+
+ CounterImpl(CounterImpl that) {
+ super(that);
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param deep
+ * boolean
+ */
+ public ICSSNode cloneNode(boolean deep) {
+ CounterImpl cloned = new CounterImpl(this);
+
+ if (deep)
+ cloneChildNodes(cloned, deep);
+
+ return cloned;
+ }
+
+ /**
+ * This method is used to get the Counter value. If this CSS value doesn't
+ * contain a counter value, a <code>DOMException</code> is raised.
+ * Modification to the corresponding style property can be achieved using
+ * the <code>Counter</code> interface.
+ *
+ * @return The Counter value.
+ * @exception DOMException
+ * INVALID_ACCESS_ERR: Raised if the CSS value doesn't
+ * contain a Counter value (e.g. this is not
+ * <code>CSS_COUNTER</code>).
+ */
+ public Counter getCounterValue() throws DOMException {
+ return this;
+ }
+
+ /**
+ * This attribute is used for the identifier of the counter.
+ */
+ public String getIdentifier() {
+ return getAttribute(IDENTIFIER);
+ }
+
+ /**
+ * This attribute is used for the style of the list.
+ */
+ public String getListStyle() {
+ return getAttribute(LISTSTYLE);
+ }
+
+ /**
+ * This attribute is used for the separator of the nested counters.
+ */
+ public String getSeparator() {
+ return getAttribute(SEPARATOR);
+ }
+
+ /**
+ *
+ */
+ protected void initPrimitives() {
+ return;
+ }
+
+ /**
+ * @param identifier
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setIdentifier(String identifier) throws DOMException {
+ setAttribute(IDENTIFIER, identifier);
+ }
+
+ /**
+ * @param listStyle
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setListStyle(String listStyle) throws DOMException {
+ setAttribute(LISTSTYLE, listStyle);
+ }
+
+ /**
+ * @param Separator
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public void setSeparator(String Separator) throws org.w3c.dom.DOMException {
+ setAttribute(SEPARATOR, Separator);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/DOMCSSImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/DOMCSSImpl.java
new file mode 100644
index 0000000..fb7907f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/DOMCSSImpl.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleSheet;
+
+
+/**
+ *
+ */
+public class DOMCSSImpl {
+
+ /**
+ * DOMCSSImpl constructor comment.
+ */
+ public DOMCSSImpl() {
+ super();
+ }
+
+ public static ICSSStyleDeclaration createCSSStyleDeclaration() throws org.w3c.dom.DOMException {
+ CSSStyleDeclarationImpl document = new CSSStyleDeclarationImpl(true);
+
+ return document;
+ }
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleSheet
+ * @param title
+ * java.lang.String
+ * @param media
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public static CSSStyleSheet createCSSStyleSheet(String title, String media) throws org.w3c.dom.DOMException {
+ return new CSSStyleSheetImpl();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/MediaListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/MediaListImpl.java
new file mode 100644
index 0000000..a84b3b1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/MediaListImpl.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ *
+ */
+class MediaListImpl extends CSSRegionContainer implements MediaList {
+
+ int mediumCounter;
+
+ /**
+ * MediaListImpl constructor comment.
+ */
+ MediaListImpl() {
+ super();
+ }
+
+ /**
+ * MediaListImpl constructor comment.
+ */
+ MediaListImpl(MediaListImpl that) {
+ super(that);
+ }
+
+ /**
+ * Adds the medium <code>newMedium</code> to the end of the list. If the
+ * <code>newMedium</code> is already used, it is first removed.
+ *
+ * @param newMediumThe
+ * new medium to add.
+ * @exception DOMException
+ * INVALID_CHARACTER_ERR: If the medium contains characters
+ * that are invalid in the underlying style language. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this list is
+ * readonly.
+ */
+ public void appendMedium(String newMedium) throws DOMException {
+ if (newMedium == null)
+ return;
+
+ CSSNodeListImpl m = getMedia();
+ for (int i = 0; i != m.getLength(); i++) {
+ if (newMedium.equals(item(i)))
+ return;
+ }
+
+ setAttribute("medium" + Integer.toString(mediumCounter++), newMedium);//$NON-NLS-1$
+ }
+
+ public ICSSNode cloneNode(boolean deep) {
+ MediaListImpl cloned = new MediaListImpl(this);
+ return cloned;
+ }
+
+ /**
+ * Deletes the medium indicated by <code>oldMedium</code> from the list.
+ *
+ * @param oldMediumThe
+ * medium to delete in the media list.
+ * @exception DOMException
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this list is
+ * readonly. <br>
+ * NOT_FOUND_ERR: Raised if <code>oldMedium</code> is not
+ * in the list.
+ */
+ public void deleteMedium(String oldMedium) throws DOMException {
+ for (int i = 0; i != getLength(); i++) {
+ if (oldMedium.equals(item(i))) {
+ removeAttributeNode((CSSAttrImpl) fAttrs.item(i));
+ }
+ }
+ }
+
+ /**
+ * The number of media in the list. The range of valid media is
+ * <code>0</code> to <code>length-1</code> inclusive.
+ */
+ public int getLength() {
+ return getMedia().getLength();
+ }
+
+ /**
+ * @return CSSNodeListImpl
+ */
+ CSSNodeListImpl getMedia() {
+ if (fAttrs == null)
+ fAttrs = new CSSNamedNodeMapImpl();
+ return fAttrs;
+ }
+
+ /**
+ * The parsable textual representation of the media list. This is a
+ * comma-separated list of media.
+ *
+ * @exception DOMException
+ * SYNTAX_ERR: Raised if the specified string value has a
+ * syntax error and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this media list
+ * is readonly.
+ */
+ public String getMediaText() {
+ return getCssText();
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/01/17
+ * 18:50:29)
+ *
+ * @return short
+ */
+ public short getNodeType() {
+ return MEDIALIST_NODE;
+ }
+
+ /**
+ * Returns the <code>index</code> th in the list. If <code>index</code>
+ * is greater than or equal to the number of media in the list, this
+ * returns <code>null</code>.
+ *
+ * @param index
+ * Index into the collection.
+ * @return The medium at the <code>index</code> th position in the
+ * <code>MediaList</code>, or <code>null</code> if that is
+ * not a valid index.
+ */
+ public String item(int index) {
+ if (index < 0 || getLength() <= index)
+ return null;
+
+ return ((CSSAttrImpl) getMedia().item(index)).getValue();
+ }
+
+ /**
+ * setMediaText method comment.
+ */
+ public void setMediaText(String mediaText) throws DOMException {
+ setCssText(mediaText);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RGBColorImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RGBColorImpl.java
new file mode 100644
index 0000000..2555027
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RGBColorImpl.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.RGBColor;
+
+
+/**
+ *
+ */
+class RGBColorImpl extends CSSPrimitiveContainer implements RGBColor {
+
+ private CSSPrimitiveValueImpl fRed;
+ private CSSPrimitiveValueImpl fGreen;
+ private CSSPrimitiveValueImpl fBlue;
+
+ /**
+ *
+ */
+ RGBColorImpl() {
+ super(CSS_RGBCOLOR);
+ }
+
+ RGBColorImpl(RGBColorImpl that) {
+ super(that);
+
+ fRed = new CSSPrimitiveValueImpl(that.fRed);
+ appendChild(fRed);
+
+ fGreen = new CSSPrimitiveValueImpl(that.fGreen);
+ appendChild(fGreen);
+
+ fBlue = new CSSPrimitiveValueImpl(that.fBlue);
+ appendChild(fBlue);
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param deep
+ * boolean
+ */
+ public ICSSNode cloneNode(boolean deep) {
+ RGBColorImpl cloned = new RGBColorImpl(this);
+
+ return cloned;
+ }
+
+ /**
+ * This attribute is used for the blue value of the RGB color.
+ */
+ public CSSPrimitiveValue getBlue() {
+ return fBlue;
+ }
+
+ /**
+ * This attribute is used for the green value of the RGB color.
+ */
+ public CSSPrimitiveValue getGreen() {
+ return fGreen;
+ }
+
+ /**
+ * This attribute is used for the red value of the RGB color.
+ */
+ public CSSPrimitiveValue getRed() {
+ return fRed;
+ }
+
+ /**
+ * @return org.w3c.dom.css.RGBColor
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public RGBColor getRGBColorValue() throws org.w3c.dom.DOMException {
+ return this;
+ }
+
+ /**
+ *
+ */
+ protected void initPrimitives() {
+
+ fRed = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fRed);
+
+ fGreen = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fGreen);
+
+ fBlue = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fBlue);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RectImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RectImpl.java
new file mode 100644
index 0000000..a295ea3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/RectImpl.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.Rect;
+
+
+/**
+ *
+ */
+class RectImpl extends CSSPrimitiveContainer implements Rect {
+
+ private CSSPrimitiveValueImpl fTop;
+ private CSSPrimitiveValueImpl fRight;
+ private CSSPrimitiveValueImpl fBottom;
+ private CSSPrimitiveValueImpl fLeft;
+
+ /**
+ *
+ */
+ RectImpl() {
+ super(CSS_RECT);
+ }
+
+ RectImpl(RectImpl that) {
+ super(that);
+
+ fTop = new CSSPrimitiveValueImpl(that.fTop);
+ appendChild(fTop);
+
+ fRight = new CSSPrimitiveValueImpl(that.fRight);
+ appendChild(fRight);
+
+ fBottom = new CSSPrimitiveValueImpl(that.fBottom);
+ appendChild(fBottom);
+
+ fLeft = new CSSPrimitiveValueImpl(that.fLeft);
+ appendChild(fLeft);
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param deep
+ * boolean
+ */
+ public ICSSNode cloneNode(boolean deep) {
+ RectImpl cloned = new RectImpl(this);
+
+ return cloned;
+ }
+
+ /**
+ * This attribute is used for the bottom of the rect.
+ */
+ public CSSPrimitiveValue getBottom() {
+ return fBottom;
+ }
+
+ /**
+ * This attribute is used for the left of the rect.
+ */
+ public CSSPrimitiveValue getLeft() {
+ return fLeft;
+ }
+
+ /**
+ * @return org.w3c.dom.css.Rect
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ public Rect getRectValue() throws org.w3c.dom.DOMException {
+ return this;
+ }
+
+ /**
+ * This attribute is used for the right of the rect.
+ */
+ public CSSPrimitiveValue getRight() {
+ return fRight;
+ }
+
+ /**
+ * This attribute is used for the top of the rect.
+ */
+ public CSSPrimitiveValue getTop() {
+ return fTop;
+ }
+
+ /**
+ *
+ */
+ protected void initPrimitives() {
+
+ fTop = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fTop);
+
+ fRight = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fRight);
+
+ fBottom = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fBottom);
+
+ fLeft = (CSSPrimitiveValueImpl) getOwnerDocument().createCSSPrimitiveValue(CSS_NUMBER);
+ appendChild(fLeft);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/StyleSheetListImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/StyleSheetListImpl.java
new file mode 100644
index 0000000..fea1bfc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/StyleSheetListImpl.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.document;
+
+
+
+import org.w3c.dom.stylesheets.StyleSheet;
+import org.w3c.dom.stylesheets.StyleSheetList;
+
+/**
+ *
+ */
+class StyleSheetListImpl extends AbstractCSSNodeList implements StyleSheetList {
+
+ /**
+ * StyleSheetListImpl constructor comment.
+ */
+ StyleSheetListImpl() {
+ super();
+ }
+
+ /**
+ * Used to retrieve a style sheet by ordinal index. If index is greater
+ * than or equal to the number of style sheets in the list, this returns
+ * <code>null</code>.
+ *
+ * @param indexIndex
+ * into the collection
+ * @return The style sheet at the <code>index</code> position in the
+ * <code>StyleSheetList</code>, or <code>null</code> if that
+ * is not a valid index.
+ */
+ public StyleSheet item(int index) {
+ return (StyleSheet) itemImpl(index);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentCharsetDetector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentCharsetDetector.java
new file mode 100644
index 0000000..51a51e1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentCharsetDetector.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.encoding;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.sse.core.internal.document.DocumentReader;
+import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+
+
+public class CSSDocumentCharsetDetector extends CSSResourceEncodingDetector implements IDocumentCharsetDetector {
+
+ public String getEncodingName(IStructuredDocument structuredDocument) {
+ String result = null;
+ // if the document is empty, then there will be no nodes,
+ // so no need to continue.
+ IStructuredDocumentRegionList nodes = structuredDocument.getRegionList();
+ if (nodes.getLength() > 0) {
+ IStructuredDocumentRegion node = null;
+ // skip any initial whitespace
+ // Note that @charset "encodingname";
+ // must appear at very beginning of document,
+ // to be valid.
+ // May have to test with "damaged" files (e.g.
+ // beginning EOLs, etc., to verify this works
+ // as expected.
+ for (int i = 0; i < nodes.getLength(); i++) {
+ node = nodes.item(i);
+ if (getType(node) != CSSRegionContexts.CSS_S) {
+ break;
+ }
+ }
+ Iterator regions = node.getRegions().iterator();
+ ITextRegion region = getNextRegionOfType(CSSRegionContexts.CSS_CHARSET, regions);
+ if (region != null) {
+ ITextRegion valueRegion = getNextRegionOfType(CSSRegionContexts.CSS_STRING, regions);
+ if (valueRegion == null) {
+ // if didn't find the region, its probably due to ill
+ // formed input, such as
+ // @charset "ISO-8859-6;
+ // so we'll try again for "unknown" region.
+ // If that fails, we'll give up?
+ regions = node.getRegions().iterator();
+ region = getNextRegionOfType(CSSRegionContexts.CSS_CHARSET, regions);
+ if (region != null) {
+ valueRegion = getNextRegionOfType(CSSRegionContexts.CSS_UNKNOWN, regions);
+ if (valueRegion != null) {
+ result = node.getText(valueRegion);
+ }
+ }
+ }
+ else {
+ result = node.getText(valueRegion);
+ }
+ result = StringUtils.stripNonLetterDigits(result);
+ }
+ }
+ return result;
+ }
+
+ public String getEncodingName(IDocument document) {
+ String enc = null;
+ if (document instanceof IStructuredDocument) {
+ enc = getEncodingName((IStructuredDocument) document);
+ }
+ else {
+ // TODO Important: need to implement some "raw" parser for
+ // IDocument level
+ }
+ return enc;
+ }
+
+ private String getType(IStructuredDocumentRegion node) {
+ if (node == null)
+ return null;
+ ITextRegionList regions = node.getRegions();
+ if (regions == null || regions.size() == 0)
+ return null;
+ ITextRegion region = regions.get(0);
+ String result = region.getType();
+ return result;
+ }
+
+ private ITextRegion getNextRegionOfType(String type, Iterator regions) {
+ if (type == null)
+ return null;
+ if (regions == null)
+ return null;
+ ITextRegion result = null;
+ while (regions.hasNext()) {
+ ITextRegion region = (ITextRegion) regions.next();
+ if (region.getType() == type) {
+ result = region;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ */
+
+ public void set(IDocument document) {
+ set(new DocumentReader(document, 0));
+
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentLoader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentLoader.java
new file mode 100644
index 0000000..b46ff08
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/encoding/CSSDocumentLoader.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.encoding;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.wst.css.core.internal.contenttype.EncodingGuesser;
+import org.eclipse.wst.css.core.internal.parser.CSSSourceParser;
+import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
+import org.eclipse.wst.css.core.internal.text.CSSStructuredDocumentReParser;
+import org.eclipse.wst.css.core.internal.text.StructuredTextPartitionerForCSS;
+import org.eclipse.wst.sse.core.internal.document.AbstractDocumentLoader;
+import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
+import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
+import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory;
+import org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences;
+import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
+import org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
+
+
+public class CSSDocumentLoader extends AbstractDocumentLoader {
+ private final static String CSS_ID = ContentTypeIdForCSS.ContentTypeID_CSS;
+ private IDocumentCharsetDetector documentEncodingDetector;
+
+
+ public CSSDocumentLoader() {
+ super();
+ }
+
+ protected String getEncodingNameByGuess(byte[] string, int length) {
+ String ianaEnc = null;
+ ianaEnc = EncodingGuesser.guessEncoding(string, length);
+ return ianaEnc;
+ }
+
+ /**
+ * Default encoding. For CSS there is no spec'd default.
+ */
+ protected String getSpecDefaultEncoding() {
+ return null;
+ }
+
+ protected IEncodedDocument newEncodedDocument() {
+ // DMW: I copied this from CSSModelImple ...
+ // but am not sure its right
+ IStructuredDocument structuredDocument = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser());
+ CSSStructuredDocumentReParser reParser = new CSSStructuredDocumentReParser();
+ reParser.setStructuredDocument(structuredDocument);
+ ((BasicStructuredDocument) structuredDocument).setReParser(reParser);
+ return structuredDocument;
+ }
+
+ public RegionParser getParser() {
+ // return new CSSRegionParser();
+ return new CSSSourceParser();
+ }
+
+ protected String getPreferredNewLineDelimiter(IFile file) {
+ String delimiter = ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(CSS_ID);
+ if (delimiter == null)
+ delimiter = super.getPreferredNewLineDelimiter(file);
+ return delimiter;
+ }
+
+ public IDocumentCharsetDetector getDocumentEncodingDetector() {
+ if (documentEncodingDetector == null) {
+ documentEncodingDetector = new CSSDocumentCharsetDetector();
+ }
+ return documentEncodingDetector;
+ }
+
+ public IDocumentPartitioner getDefaultDocumentPartitioner() {
+ return new StructuredTextPartitionerForCSS();
+ }
+
+ public IDocumentLoader newInstance() {
+ return new CSSDocumentLoader();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleListener.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleListener.java
new file mode 100644
index 0000000..0c77119
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleListener.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.event;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+
+
+
+/**
+ *
+ */
+public interface ICSSStyleListener {
+
+ /**
+ *
+ */
+ void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media);
+
+ /**
+ *
+ */
+ void styleUpdate(ICSSModel srcModel);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleNotifier.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleNotifier.java
new file mode 100644
index 0000000..ba49ee8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/event/ICSSStyleNotifier.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.event;
+
+
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface ICSSStyleNotifier extends ICSSStyleListener {
+
+ /**
+ *
+ */
+ void addStyleListener(ICSSStyleListener listener);
+
+ /**
+ *
+ */
+ List getStyleListeners();
+
+ /**
+ */
+ boolean isRecording();
+
+ /**
+ *
+ */
+ void removeStyleListener(ICSSStyleListener listener);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSEmbededStyleNotifyAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSEmbededStyleNotifyAdapter.java
new file mode 100644
index 0000000..e8031ba
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSEmbededStyleNotifyAdapter.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.eventimpl;
+
+
+
+import org.eclipse.wst.css.core.internal.event.ICSSStyleListener;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+
+public class CSSEmbededStyleNotifyAdapter extends CSSStyleNotifyAdapter {
+
+ /**
+ * CSSEmbeddedStyleNotifyAdapter constructor comment.
+ *
+ * @param model
+ * org.eclipse.wst.css.core.model.interfaces.ICSSModel
+ */
+ public CSSEmbededStyleNotifyAdapter(ICSSModel model) {
+ super(model);
+ }
+
+ /**
+ *
+ */
+ public void styleChanged(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
+ IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
+ if (node != null)
+ return;
+ INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
+ if (adapter instanceof ICSSStyleListener) {
+ ((ICSSStyleListener) adapter).styleChanged(srcModel, removed, added, media);
+ }
+ }
+
+ /**
+ *
+ */
+ public void styleUpdate(ICSSModel srcModel) {
+ IDOMNode node = (IDOMNode) model.getOwnerDOMNode();
+ if (node != null)
+ return;
+ INodeAdapter adapter = node.getAdapterFor(IStyleSheetAdapter.class);
+ if (adapter instanceof ICSSStyleListener) {
+ ((ICSSStyleListener) adapter).styleUpdate(srcModel);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleEventDeliverer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleEventDeliverer.java
new file mode 100644
index 0000000..0760182
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleEventDeliverer.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.eventimpl;
+
+
+
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.event.ICSSStyleListener;
+import org.eclipse.wst.css.core.internal.event.ICSSStyleNotifier;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+
+
+/**
+ *
+ */
+public class CSSStyleEventDeliverer {
+
+ private Vector fVisited = new Vector();
+ private ICSSModel fSrcModel;
+ private ICSSSelector[] fRemoved;
+ private ICSSSelector[] fAdded;
+ private String fMedia;
+
+ /**
+ *
+ */
+ public CSSStyleEventDeliverer() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public void fire(ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
+ if (srcModel == null || srcModel.getStyleListeners() == null)
+ return;
+
+ this.fSrcModel = srcModel;
+ this.fRemoved = removed;
+ this.fAdded = added;
+ this.fMedia = media;
+
+ // prohibit delivering to srcModel
+ fVisited.clear();
+ fVisited.add(srcModel);
+ Object[] listeners = srcModel.getStyleListeners().toArray();
+ for (int i = 0; i < listeners.length; i++) {
+ visit((ICSSStyleListener) listeners[i]);
+ }
+ }
+
+ /**
+ *
+ */
+ public void fireTo(ICSSStyleListener listener, ICSSModel srcModel, ICSSSelector[] removed, ICSSSelector[] added, String media) {
+ this.fSrcModel = srcModel;
+ this.fRemoved = removed;
+ this.fAdded = added;
+ this.fMedia = media;
+
+ // prohibit delivering to srcModel
+ fVisited.clear();
+ // visited.add(srcModel); : because looping problem
+ visit(listener);
+ }
+
+ /**
+ *
+ */
+ public void fireUpdate(ICSSModel srcModel) {
+ if (srcModel == null || srcModel.getStyleListeners() == null)
+ return;
+
+ this.fSrcModel = srcModel;
+
+ // prohibit delivering to srcModel
+ fVisited.clear();
+ fVisited.add(srcModel);
+ Object[] listeners = srcModel.getStyleListeners().toArray();
+ for (int i = 0; i < listeners.length; i++) {
+ visitUpdate((ICSSStyleListener) listeners[i]);
+ }
+ }
+
+ /**
+ *
+ */
+ public void fireUpdateTo(ICSSStyleListener listener, ICSSModel srcModel) {
+ if (srcModel == null || srcModel.getStyleListeners() == null)
+ return;
+
+ this.fSrcModel = srcModel;
+
+ // prohibit delivering to srcModel
+ fVisited.clear();
+ // visited.add(srcModel);
+ visitUpdate(listener);
+ }
+
+ /**
+ *
+ */
+ protected void visit(ICSSStyleListener listener) {
+ if (listener == null || fVisited.contains(listener))
+ return;
+
+ // fire event to listener
+ listener.styleChanged(fSrcModel, fRemoved, fAdded, fMedia);
+ fVisited.add(listener);
+
+ // traverse notifier
+ if (listener instanceof ICSSStyleNotifier) {
+ ICSSStyleNotifier notifier = (ICSSStyleNotifier) listener;
+ if (notifier.getStyleListeners() != null) {
+ Object[] listeners = notifier.getStyleListeners().toArray();
+ for (int i = 0; i < listeners.length; i++) {
+ visit((ICSSStyleListener) listeners[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void visitUpdate(ICSSStyleListener listener) {
+ if (listener == null || fVisited.contains(listener))
+ return;
+
+ // fire event to listener
+ listener.styleUpdate(fSrcModel);
+ fVisited.add(listener);
+
+ // traverse notifier
+ if (listener instanceof ICSSStyleNotifier) {
+ ICSSStyleNotifier notifier = (ICSSStyleNotifier) listener;
+ if (notifier.getStyleListeners() != null) {
+ Object[] listeners = notifier.getStyleListeners().toArray();
+ for (int i = 0; i < listeners.length; i++) {
+ visitUpdate((ICSSStyleListener) listeners[i]);
+ }
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleNotifyAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleNotifyAdapter.java
new file mode 100644
index 0000000..0633b10
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/eventimpl/CSSStyleNotifyAdapter.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.eventimpl;
+
+
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.event.ICSSStyleListener;
+import org.eclipse.wst.css.core.internal.event.ICSSStyleNotifier;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.internal.util.ImportedCollector;
+import org.eclipse.wst.css.core.internal.util.SelectorsCollector;
+
+
+/**
+ *
+ */
+public class CSSStyleNotifyAdapter implements ICSSStyleNotifier {
+
+ protected java.util.Vector listeners;
+ protected final org.eclipse.wst.css.core.internal.provisional.document.ICSSModel model;
+ protected boolean recording = false;
+
+ /**
+ *
+ */
+ public CSSStyleNotifyAdapter(ICSSModel model) {
+ super();
+ this.model = model;
+ }
+
+ /**
+ *
+ */
+ public void addStyleListener(ICSSStyleListener listener) {
+ if (listener == null)
+ return;
+
+ if (listeners == null)
+ listeners = new Vector();
+ if (!listeners.contains(listener)) {
+
+ // send new selectors event to listener
+ ImportedCollector trav = new ImportedCollector();
+ trav.apply(model.getDocument());
+ Iterator it = trav.getExternals().iterator();
+ while (it.hasNext()) {
+ ICSSStyleSheet sheet = (ICSSStyleSheet) it.next();
+ // collect selectors
+ SelectorsCollector selTrav = new SelectorsCollector();
+ selTrav.apply(sheet);
+ int nSel = selTrav.getSelectors().size();
+ ICSSSelector[] added = new ICSSSelector[nSel];
+ for (int i = 0; i < nSel; i++)
+ added[i] = (ICSSSelector) selTrav.getSelectors().get(i);
+
+ // fire event
+ CSSStyleEventDeliverer deliverer = new CSSStyleEventDeliverer();
+ deliverer.fireTo(listener, sheet.getModel(), null, added, null/*
+ * media
+ * will
+ * be
+ * implemented
+ * in
+ * the
+ * future
+ */);
+ }
+
+ // add listener
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ *
+ */
+ public void beginRecording() {
+ recording = true;
+ }
+
+ /**
+ *
+ */
+ public void endRecording() {
+ recording = false;
+ }
+
+ /**
+ *
+ */
+ public void fire(ICSSSelector[] removed, ICSSSelector[] added, String media) {
+ // send selector changed event
+ CSSStyleEventDeliverer deliv = new CSSStyleEventDeliverer();
+ deliv.fire(model, removed, added, null);
+
+ }
+
+ /**
+ *
+ */
+ public java.util.List getStyleListeners() {
+ return listeners;
+ }
+
+ /**
+ */
+ public boolean isRecording() {
+ return recording;
+ }
+
+ /**
+ *
+ */
+ public void removeStyleListener(ICSSStyleListener listener) {
+ if (listener == null)
+ return;
+
+ if (listeners.contains(listener)) {
+ listeners.remove(listener);
+
+ // send old selectors event to listener
+ ImportedCollector trav = new ImportedCollector();
+ trav.apply(model.getDocument());
+ Iterator it = trav.getExternals().iterator();
+ while (it.hasNext()) {
+ ICSSStyleSheet sheet = (ICSSStyleSheet) it.next();
+ // collect selectors
+ SelectorsCollector selTrav = new SelectorsCollector();
+ selTrav.apply(sheet);
+ int nSel = selTrav.getSelectors().size();
+ ICSSSelector[] removed = new ICSSSelector[nSel];
+ for (int i = 0; i < nSel; i++)
+ removed[i] = (ICSSSelector) selTrav.getSelectors().get(i);
+
+ // fire event
+ CSSStyleEventDeliverer deliverer = new CSSStyleEventDeliverer();
+ deliverer.fireTo(listener, sheet.getModel(), removed, null, null/*
+ * media
+ * will
+ * be
+ * implemented
+ * in
+ * the
+ * future
+ */);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void styleChanged(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel srcModel, org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector[] removed, org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector[] added, java.lang.String media) {
+ }
+
+ /**
+ *
+ */
+ public void styleUpdate(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel srcModel) {
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/format/FormatProcessorCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/format/FormatProcessorCSS.java
new file mode 100644
index 0000000..797d076
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/format/FormatProcessorCSS.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.format;
+
+import java.util.List;
+
+import org.eclipse.jface.text.DocumentRewriteSession;
+import org.eclipse.jface.text.DocumentRewriteSessionType;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.wst.css.core.internal.formatter.CSSFormatUtil;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter;
+import org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatterFactory;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor;
+import org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences;
+import org.eclipse.wst.sse.core.internal.format.IStructuredFormatter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Node;
+
+
+public class FormatProcessorCSS extends AbstractStructuredFormatProcessor {
+ /*
+ * Max length of text to be formatted to be considered a "small change"
+ * Used for document rewrite session type.
+ */
+ private final int MAX_SMALL_FORMAT_SIZE = 1000;
+
+ protected String getFileExtension() {
+ return "css"; //$NON-NLS-1$
+ }
+
+ public void formatModel(IStructuredModel structuredModel, int start, int length) {
+ CSSFormatUtil formatUtil = CSSFormatUtil.getInstance();
+ if (structuredModel instanceof ICSSModel) {
+ // BUG102822 take advantage of IDocumentExtension4
+ IDocumentExtension4 docExt4 = null;
+ if (structuredModel.getStructuredDocument() instanceof IDocumentExtension4) {
+ docExt4 = (IDocumentExtension4) structuredModel.getStructuredDocument();
+ }
+ DocumentRewriteSession rewriteSession = null;
+
+ try {
+ DocumentRewriteSessionType rewriteType = (length > MAX_SMALL_FORMAT_SIZE) ? DocumentRewriteSessionType.UNRESTRICTED : DocumentRewriteSessionType.UNRESTRICTED_SMALL;
+ rewriteSession = (docExt4 == null || docExt4.getActiveRewriteSession() != null) ? null : docExt4.startRewriteSession(rewriteType);
+
+ ICSSDocument doc = ((ICSSModel) structuredModel).getDocument();
+ CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) doc);
+ StringBuffer buf = formatter.format(doc);
+ if (buf != null) {
+ int startOffset = ((IndexedRegion) doc).getStartOffset();
+ int endOffset = ((IndexedRegion) doc).getEndOffset();
+ formatUtil.replaceSource(doc.getModel(), startOffset, endOffset - startOffset, buf.toString());
+ }
+ }
+ finally {
+ // BUG102822 take advantage of IDocumentExtension4
+ if (docExt4 != null && rewriteSession != null)
+ docExt4.stopRewriteSession(rewriteSession);
+ }
+ }
+ else if (structuredModel instanceof IDOMModel) {
+ List cssnodes = formatUtil.collectCSSNodes(structuredModel, start, length);
+ if (cssnodes != null && !cssnodes.isEmpty()) {
+ ICSSModel model = null;
+
+ // BUG102822 take advantage of IDocumentExtension4
+ IDocumentExtension4 docExt4 = null;
+ if (structuredModel.getStructuredDocument() instanceof IDocumentExtension4) {
+ docExt4 = (IDocumentExtension4) structuredModel.getStructuredDocument();
+ }
+ DocumentRewriteSession rewriteSession = null;
+
+ try {
+ DocumentRewriteSessionType rewriteType = (length > MAX_SMALL_FORMAT_SIZE) ? DocumentRewriteSessionType.UNRESTRICTED : DocumentRewriteSessionType.UNRESTRICTED_SMALL;
+ rewriteSession = (docExt4 == null || docExt4.getActiveRewriteSession() != null) ? null : docExt4.startRewriteSession(rewriteType);
+
+ for (int i = 0; i < cssnodes.size(); i++) {
+ ICSSNode node = (ICSSNode) cssnodes.get(i);
+ CSSSourceFormatter formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) node);
+ StringBuffer buf = formatter.format(node);
+ if (buf != null) {
+ int startOffset = ((IndexedRegion) node).getStartOffset();
+ int endOffset = ((IndexedRegion) node).getEndOffset();
+ if (model == null) {
+ model = node.getOwnerDocument().getModel();
+ }
+ formatUtil.replaceSource(model, startOffset, endOffset - startOffset, buf.toString());
+ }
+ }
+ }
+ finally {
+ // BUG102822 take advantage of IDocumentExtension4
+ if (docExt4 != null && rewriteSession != null)
+ docExt4.stopRewriteSession(rewriteSession);
+ }
+ }
+ }
+ }
+
+ public IStructuredFormatPreferences getFormatPreferences() {
+ return null;
+ }
+
+ protected IStructuredFormatter getFormatter(Node node) {
+ return null;
+ }
+
+ protected void refreshFormatPreferences() {
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
new file mode 100644
index 0000000..8ceb138
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
@@ -0,0 +1,1021 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategyImpl;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.internal.util.CSSLinkConverter;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.util.Assert;
+
+/**
+ *
+ */
+public abstract class AbstractCSSSourceFormatter implements CSSSourceGenerator {
+
+ protected final static short GENERATE = 0;
+ protected final static short FORMAT = 1;
+ protected final static short CLEANUP = 2;
+ protected static short strategy;
+
+ /**
+ *
+ */
+ AbstractCSSSourceFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void appendDelimBefore(ICSSNode node, CompoundRegion toAppend, StringBuffer source) {
+ if (node == null || source == null)
+ return;
+ if (isCleanup() && !getCleanupStrategy(node).isFormatSource())
+ return; // for not formatting case on cleanup action
+ String delim = getLineDelimiter(node);
+
+ boolean needIndent = !(node instanceof ICSSStyleSheet);
+ if (toAppend == null) {
+ source.append(delim);
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ else {
+ String type = toAppend.getType();
+ if (type == CSSRegionContexts.CSS_COMMENT) {
+ RegionIterator it = new RegionIterator(toAppend.getDocumentRegion(), toAppend.getTextRegion());
+ it.prev();
+ ITextRegion prev = it.prev();
+ int[] result = null;
+ if (prev == null || (prev.getType() == CSSRegionContexts.CSS_S && (result = TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, it.getStructuredDocumentRegion().getText(prev), 0))[0] >= 0)) {
+ // Collapse to one empty line if there's more than one.
+ int offset = result[0] + DefaultLineTracker.DELIMITERS[result[1]].length();
+ if (offset < it.getStructuredDocumentRegion().getText(prev).length() ) {
+ if (TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, it.getStructuredDocumentRegion().getText(prev), offset)[0] >= 0) {
+ source.append(delim);
+ }
+ }
+ source.append(delim);
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ else if (prev.getType() == CSSRegionContexts.CSS_COMMENT) {
+ String fullText = toAppend.getDocumentRegion().getFullText(prev);
+ String trimmedText = toAppend.getDocumentRegion().getText(prev);
+ String whiteSpaces = "";//$NON-NLS-1$
+ if (fullText != null && trimmedText != null)
+ whiteSpaces = fullText.substring(trimmedText.length());
+ int[] delimiterFound = TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, whiteSpaces, 0);
+ if (delimiterFound[0] != -1) {
+ source.append(delim);
+ }
+ else {
+ appendSpaceBefore(node, toAppend.getText(), source);
+
+ /*If two comments can't be adjusted in one line(combined length exceeds line width),
+ * a tab is also appended along with next line delimiter , we need to remove that.
+ */
+ if (source.toString().endsWith(getIndentString())) {
+ source.delete((source.length() - getIndentString().length()), source.length());
+ }
+ }
+ }
+ else {
+ appendSpaceBefore(node, toAppend.getText(), source);
+ }
+ }
+ else if (type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ RegionIterator it = new RegionIterator(toAppend.getDocumentRegion(), toAppend.getTextRegion());
+ it.prev();
+ ITextRegion prev = it.prev();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ if (prev.getType() == CSSRegionContexts.CSS_S && TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, it.getStructuredDocumentRegion().getText(prev), 0)[0] >= 0) {
+ source.append(delim);
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ else if (preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) {
+ int length = getLastLineLength(node, source);
+ int append = 1;
+ if (length + append > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) {
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ }
+ }
+ else if (type == CSSRegionContexts.CSS_RBRACE || type == CSSRegionContexts.CSS_LBRACE) {
+ source.append(delim);
+ source.append(getIndent(node));
+ }
+ else {
+ source.append(delim);
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void appendSpaceBefore(ICSSNode node, CompoundRegion toAppend, StringBuffer source) {
+ if (node == null || toAppend == null || source == null)
+ return;
+ if (isCleanup() && !getCleanupStrategy(node).isFormatSource())
+ return; // for not formatting case on cleanup action
+ String type = toAppend.getType();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ boolean needIndent = !(node instanceof ICSSStyleSheet);
+ if (type == CSSRegionContexts.CSS_COMMENT) {
+ // check whether previous region is 'S' and has CR-LF
+ String delim = getLineDelimiter(node);
+ RegionIterator it = new RegionIterator(toAppend.getDocumentRegion(), toAppend.getTextRegion());
+ it.prev();
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S && TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, it.getStructuredDocumentRegion().getText(prev), 0)[0] >= 0) {
+ source.append(delim);
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ else {
+ appendSpaceBefore(node, toAppend.getText(), source);
+ }
+ }
+ else if (type == CSSRegionContexts.CSS_LBRACE && preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_NEWLINE_ON_OPEN_BRACE)) {
+ String delim = getLineDelimiter(node);
+ source.append(delim);
+ source.append(getIndent(node));
+ // } else if (type == CSSRegionContexts.CSS_CURLY_BRACE_CLOSE) {
+ // } else if (type == CSSRegionContexts.CSS_INCLUDES || type ==
+ // CSSRegionContexts.CSS_DASHMATCH) {
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR && node instanceof ICSSStyleDeclItem) {
+ int n = preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM);
+ // no delimiter case
+ while (n-- > 0)
+ source.append(" ");//$NON-NLS-1$
+ }
+ else if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR || type == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE) {
+ if (preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) {
+ int length = getLastLineLength(node, source);
+ int append = 1;
+ if (length + append > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) {
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ if (needIndent)
+ source.append(getIndentString());
+ }
+ }
+ }
+ else if (CSSRegionContexts.CSS_FOREIGN_ELEMENT == type || CSSRegionContexts.CSS_DECLARATION_DELIMITER == type) {
+ return;
+ }
+ else
+ appendSpaceBefore(node, toAppend.getText(), source);
+ }
+
+ /**
+ *
+ */
+ protected void appendSpaceBefore(ICSSNode node, String toAppend, StringBuffer source) {
+ if (node == null || source == null)
+ return;
+ if (isCleanup() && !getCleanupStrategy(node).isFormatSource())
+ return; // for not formatting case on cleanup action
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (toAppend != null && toAppend.startsWith("{") && preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_NEWLINE_ON_OPEN_BRACE)) {//$NON-NLS-1$
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ return;
+ }
+ else if (/* ! mgr.isOnePropertyPerLine() && */preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) {
+ int n = getLastLineLength(node, source);
+ int append = (toAppend != null) ? TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, toAppend, 0)[0] : 0;
+ if (toAppend != null)
+ append = (append < 0) ? toAppend.length() : append;
+ if (n + append + 1 > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) {
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ source.append(getIndentString());
+ return;
+ }
+ }
+ source.append(" ");//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ public final StringBuffer cleanup(ICSSNode node) {
+ short oldStrategy = strategy;
+ strategy = CLEANUP;
+ StringBuffer source = formatProc(node);
+ strategy = oldStrategy;
+
+ return source;
+ }
+
+ /**
+ *
+ */
+ public final StringBuffer cleanup(ICSSNode node, IRegion region) {
+ short oldStrategy = strategy;
+ strategy = CLEANUP;
+ StringBuffer source = formatProc(node, region);
+ strategy = oldStrategy;
+
+ return source;
+ }
+
+ /**
+ *
+ */
+ protected String decoratedIdentRegion(CompoundRegion region, CSSCleanupStrategy stgy) {
+ if (isFormat())
+ return region.getText();
+
+ String text = null;
+ if (!stgy.isFormatSource())
+ text = region.getFullText();
+ else
+ text = region.getText();
+
+ if (region.getType() == CSSRegionContexts.CSS_STRING || region.getType() == CSSRegionContexts.CSS_URI)
+ return decoratedRegion(region, 0, stgy);
+
+ if (isCleanup()) {
+ if (stgy.getIdentCase() == CSSCleanupStrategy.ASIS || region.getType() == CSSRegionContexts.CSS_COMMENT)
+ return text;
+ else if (stgy.getIdentCase() == CSSCleanupStrategy.UPPER)
+ return text.toUpperCase();
+ else
+ return text.toLowerCase();
+ }
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (region.getType() == CSSRegionContexts.CSS_COMMENT)
+ return text;
+ else if (preferences.getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ return text.toUpperCase();
+ else
+ return text.toLowerCase();
+ }
+
+ /**
+ *
+ */
+ protected String decoratedPropNameRegion(CompoundRegion region, CSSCleanupStrategy stgy) {
+ if (isFormat())
+ return region.getText();
+
+ String text = null;
+ if (!stgy.isFormatSource())
+ text = region.getFullText();
+ else
+ text = region.getText();
+
+ if (region.getType() == CSSRegionContexts.CSS_STRING || region.getType() == CSSRegionContexts.CSS_URI)
+ return decoratedRegion(region, 1, stgy);
+ if (isCleanup()) {
+ if (stgy.getPropNameCase() == CSSCleanupStrategy.ASIS || region.getType() != CSSRegionContexts.CSS_DECLARATION_PROPERTY)
+ return text;
+ else if (stgy.getPropNameCase() == CSSCleanupStrategy.UPPER)
+ return text.toUpperCase();
+ else
+ return text.toLowerCase();
+ }
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ if (region.getType() != CSSRegionContexts.CSS_DECLARATION_PROPERTY)
+ return text;
+ else if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER)
+ return text.toUpperCase();
+ else
+ return text.toLowerCase();
+ }
+
+ /**
+ *
+ */
+ protected String decoratedPropValueRegion(CompoundRegion region, CSSCleanupStrategy stgy) {
+ if (isFormat())
+ return region.getText();
+
+ String text = null;
+ if (!stgy.isFormatSource())
+ text = region.getFullText();
+ else
+ text = region.getText();
+
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_STRING || type == CSSRegionContexts.CSS_URI || type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI)
+ return decoratedRegion(region, 2, stgy);
+ if (isCleanup()) {
+ if (stgy.getPropValueCase() != CSSCleanupStrategy.ASIS) {
+ if (type == CSSRegionContexts.CSS_COMMENT) {
+ }
+ else {
+ if (stgy.getPropValueCase() == CSSCleanupStrategy.UPPER)
+ text = text.toUpperCase();
+ else
+ text = text.toLowerCase();
+ }
+ }
+ }
+ return text;
+ }
+
+ /**
+ *
+ */
+ protected String decoratedRegion(CompoundRegion region, int type, CSSCleanupStrategy stgy) {
+ if (isFormat())
+ return region.getText();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ String text = null;
+ if (!stgy.isFormatSource())
+ text = region.getFullText();
+ else
+ text = region.getText();
+
+ String regionType = region.getType();
+ if (regionType == CSSRegionContexts.CSS_URI || regionType == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ String uri = CSSLinkConverter.stripFunc(text);
+
+ boolean prefIsUpper = preferences.getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER;
+ boolean upper = (type == 0) ? prefIsUpper : ((type == 1) ? preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER : preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER);
+ String func = text.substring(0, 4);
+ if (isCleanup()) {
+ upper = ((type == 0) ? stgy.getIdentCase() : ((type == 1) ? stgy.getPropNameCase() : stgy.getPropValueCase())) == CSSCleanupStrategy.UPPER;
+ func = ((type == 0) ? stgy.getIdentCase() : ((type == 1) ? stgy.getPropNameCase() : stgy.getPropValueCase())) == CSSCleanupStrategy.ASIS ? text.substring(0, 4) : (upper ? "URL(" : "url(");//$NON-NLS-2$//$NON-NLS-1$
+ }
+ if ((!isCleanup() && preferences.getBoolean(CSSCorePreferenceNames.FORMAT_QUOTE_IN_URI)) || (isCleanup() && stgy.isQuoteValues())) {
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ quote = CSSUtil.detectQuote(uri, quote);
+ text = func + quote + uri + quote + ")";//$NON-NLS-1$
+ }
+ else if (isCleanup() && !stgy.isQuoteValues()) {
+ text = func + CSSLinkConverter.removeFunc(text) + ")";//$NON-NLS-1$
+ }
+ else {
+ text = func + uri + ")";//$NON-NLS-1$
+ }
+ }
+ else if (region.getType() == CSSRegionContexts.CSS_STRING && (!isCleanup() || stgy.isQuoteValues())) {
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ // begginning
+ if (!text.startsWith(quote)) {
+ if (text.startsWith("\"") || text.startsWith("\'")) //$NON-NLS-1$ //$NON-NLS-2$
+ text = quote + text.substring(1);
+ else
+ text = quote + text;
+ }
+ // ending
+ if (!text.endsWith(quote)) {
+ if (text.endsWith("\"") || text.endsWith("\'")) //$NON-NLS-1$ //$NON-NLS-2$
+ text = text.substring(0, text.length() - 1) + quote;
+ else
+ text = text + quote;
+ }
+ }
+ return text;
+ }
+
+ /**
+ *
+ */
+ public final StringBuffer format(ICSSNode node) {
+ short oldStrategy = strategy;
+ strategy = FORMAT;
+ StringBuffer source = formatProc(node);
+ strategy = oldStrategy;
+
+ return source;
+ }
+
+ /**
+ *
+ */
+ public final StringBuffer format(ICSSNode node, IRegion region) {
+ short oldStrategy = strategy;
+ strategy = FORMAT;
+ StringBuffer source = formatProc(node, region);
+ strategy = oldStrategy;
+
+ return source;
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ return new StringBuffer(insert && (attr != null) ? attr.getValue() : "");//$NON-NLS-1$
+ }
+
+ /**
+ * Generate or format source between children('child' and its previous
+ * sibling) and append to string buffer
+ */
+ abstract protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor);
+
+ /**
+ * Generate or format source between children('child' and its previous
+ * sibling) and append to string buffer
+ */
+ public final StringBuffer formatBefore(ICSSNode node, ICSSNode child, IRegion exceptFor) {
+ Assert.isTrue(child == null || child.getParentNode() == node);
+ StringBuffer buf = new StringBuffer();
+ formatBefore(node, child, /* (child != null) ? (child.getCssText()) : */"", buf, exceptFor);//$NON-NLS-1$
+ return buf;
+ }
+
+ /**
+ * Generate or format source between children('child' and its previous
+ * sibling) and append to string buffer
+ */
+ protected abstract void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source);
+
+ /**
+ *
+ */
+ protected final void formatChildren(ICSSNode node, StringBuffer source) {
+ ICSSNode child = node.getFirstChild();
+ boolean first = true;
+ while (child != null) {
+ // append child
+ CSSSourceFormatter formatter = (CSSSourceFormatter) ((INodeNotifier) child).getAdapterFor(CSSSourceFormatter.class);
+ if (formatter == null) {
+ formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) child);
+ }
+ StringBuffer childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child);
+ if (!first) {
+ formatBefore(node, child, new String(childSource), source, null);
+ }
+ source.append(childSource);
+ // append between children
+ child = child.getNextSibling();
+ first = false;
+ }
+ }
+
+ /**
+ *
+ */
+ protected final void formatChildren(ICSSNode node, IRegion region, StringBuffer source) {
+ ICSSNode child = node.getFirstChild();
+ int start = region.getOffset();
+ int end = region.getOffset() + region.getLength();
+ boolean first = true;
+ while (child != null) {
+ int curEnd = ((IndexedRegion) child).getEndOffset();
+ StringBuffer childSource = null;
+ boolean toFinish = false;
+ if (start < curEnd) {
+ int curStart = ((IndexedRegion) child).getStartOffset();
+ if (curStart < end) {
+ // append child
+ CSSSourceFormatter formatter = (CSSSourceFormatter) ((INodeNotifier) child).getAdapterFor(CSSSourceFormatter.class);
+ if (formatter == null) {
+ formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) child);
+ }
+ if (includes(region, curStart, curEnd))
+ childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child);
+ else
+ childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child, overlappedRegion(region, curStart, curEnd));
+ }
+ else
+ toFinish = true;
+ }
+ // append between children
+ if (!first) {
+ curEnd = ((IndexedRegion) child).getStartOffset(); // change
+ // only
+ // start
+ if (start < curEnd) {
+ int curStart = ((IndexedRegion) child.getPreviousSibling()).getEndOffset();
+ if (curStart < end) {
+ String toAppend = (childSource != null) ? new String(childSource) : "";//$NON-NLS-1$
+ if (includes(region, curStart, curEnd))
+ formatBefore(node, child, toAppend, source, null);
+ else
+ formatBefore(node, child, overlappedRegion(region, curStart, curEnd), toAppend, source);
+ }
+ }
+ }
+ if (childSource != null) {
+ source.append(childSource);
+ }
+ first = false;
+ if (toFinish)
+ break;
+ child = child.getNextSibling();
+ }
+ }
+
+ /**
+ * Generate or format source after the last child and append to string
+ * buffer
+ */
+ protected abstract void formatPost(ICSSNode node, StringBuffer source);
+
+ /**
+ * Generate or format source after the last child and append to string
+ * buffer
+ */
+ protected abstract void formatPost(ICSSNode node, IRegion region, StringBuffer source);
+
+ /**
+ * Generate or format source before the first child and append to string
+ * buffer
+ */
+ protected abstract void formatPre(ICSSNode node, StringBuffer source);
+
+ /**
+ * Generate or format source before the first child and append to string
+ * buffer
+ */
+ abstract protected void formatPre(ICSSNode node, IRegion region, StringBuffer source);
+
+ /**
+ *
+ * @return java.lang.StringBuffer
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ protected final StringBuffer formatProc(ICSSNode node) {
+ StringBuffer source = new StringBuffer();
+ formatPre(node, source);
+ formatChildren(node, source);
+ formatPost(node, source);
+ return source;
+ }
+
+ /**
+ *
+ * @return java.lang.StringBuffer
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param region
+ * org.eclipse.jface.text.IRegion
+ */
+ protected final StringBuffer formatProc(ICSSNode node, IRegion region) {
+ StringBuffer source = new StringBuffer();
+ int curStart = ((IndexedRegion) node).getStartOffset();
+ int curEnd = ((IndexedRegion) node).getEndOffset();
+ if (node.getChildNodes().getLength() > 0) {
+ curEnd = ((IndexedRegion) node.getFirstChild()).getStartOffset();
+ if (overlaps(region, curStart, curEnd)) {
+ if (includes(region, curStart, curEnd))
+ formatPre(node, source);
+ else
+ formatPre(node, overlappedRegion(region, curStart, curEnd), source);
+ }
+ curStart = curEnd;
+ curEnd = ((IndexedRegion) node.getLastChild()).getEndOffset();
+ if (overlaps(region, curStart, curEnd)) {
+ if (includes(region, curStart, curEnd))
+ formatChildren(node, source);
+ else
+ formatChildren(node, overlappedRegion(region, curStart, curEnd), source);
+ }
+ curStart = curEnd;
+ curEnd = ((IndexedRegion) node).getEndOffset();
+ if (overlaps(region, curStart, curEnd)) {
+ if (includes(region, curStart, curEnd))
+ formatPost(node, source);
+ else
+ formatPost(node, overlappedRegion(region, curStart, curEnd), source);
+ }
+ }
+ else {
+ curEnd = getChildInsertPos(node);
+ if (overlaps(region, curStart, curEnd)) {
+ if (includes(region, curStart, curEnd))
+ formatPre(node, source);
+ else
+ formatPre(node, overlappedRegion(region, curStart, curEnd), source);
+ }
+ curStart = curEnd;
+ curEnd = ((IndexedRegion) node).getEndOffset();
+ if (overlaps(region, curStart, curEnd)) {
+ if (includes(region, curStart, curEnd))
+ formatPost(node, source);
+ else
+ formatPost(node, overlappedRegion(region, curStart, curEnd), source);
+ }
+ }
+ return source;
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ return -1;
+ }
+
+ /**
+ * Insert the method's description here.
+ *
+ * @return org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ protected CSSCleanupStrategy getCleanupStrategy(ICSSNode node) {
+ CSSCleanupStrategy currentStrategy = CSSCleanupStrategyImpl.getInstance();
+ ICSSDocument doc = node.getOwnerDocument();
+ if (doc == null)
+ return currentStrategy;
+ ICSSModel model = doc.getModel();
+ if (model == null)
+ return currentStrategy;
+ if (model.getStyleSheetType() != ICSSModel.EXTERNAL) {
+ // TODO - TRANSITION Nakamori-san, or Kit, how can we move to
+ // "HTML" plugin?
+ // can we subclass?
+ // currentStrategy = CSSInHTMLCleanupStrategyImpl.getInstance();
+ }
+ return currentStrategy;
+ }
+
+ /**
+ *
+ */
+ protected String getIndent(ICSSNode node) {
+ if (node == null)
+ return "";//$NON-NLS-1$
+ ICSSNode parent = node.getParentNode();
+ if (node instanceof ICSSAttr)
+ parent = ((ICSSAttr) node).getOwnerCSSNode();
+ if (parent == null)
+ return "";//$NON-NLS-1$
+ if (node instanceof org.w3c.dom.css.CSSStyleDeclaration)
+ parent = parent.getParentNode();
+ if (parent == null)
+ return "";//$NON-NLS-1$
+
+ String parentIndent = getIndent(parent);
+ if (parent instanceof org.w3c.dom.css.CSSRule)
+ return parentIndent + getIndentString();
+ if (node.getParentNode() instanceof ICSSStyleDeclaration)
+ return parentIndent + getIndentString();
+ return parentIndent;
+ }
+
+ /**
+ *
+ */
+ protected int getLastLineLength(ICSSNode node, StringBuffer source) {
+ if (node == null || source == null)
+ return 0;
+ String delim = getLineDelimiter(node);
+ String str = new String(source);
+ int n = str.lastIndexOf(delim);
+ if (n < 0)
+ return str.length();
+
+ return str.length() - n - delim.length();
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatAfter(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos < 0 || !nnode.contains(insertPos))
+ return 0;
+
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(insertPos);
+ if (flatNode == null)
+ return 0;
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos);
+ if (region == null)
+ return 0;
+ RegionIterator it = new RegionIterator(flatNode, region);
+ boolean found = false;
+ while (it.hasNext()) {
+ region = it.next();
+ // if (region.getType() != CSSRegionContexts.CSS_S &&
+ // region.getType() != CSSRegionContexts.CSS_DELIMITER &&
+ // region.getType() !=
+ // CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ if (region.getType() != CSSRegionContexts.CSS_S) {
+ found = true;
+ break;
+ }
+ }
+ int pos = (found ? it.getStructuredDocumentRegion().getStartOffset(region) : it.getStructuredDocumentRegion().getTextEndOffset(region)) - insertPos;
+ return (pos >= 0) ? pos : 0;
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatBefore(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos <= 0 || !nnode.contains(insertPos - 1))
+ return 0;
+
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(insertPos - 1);
+ if (flatNode == null)
+ return 0;
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos - 1);
+ if (region == null)
+ return 0;
+ RegionIterator it = new RegionIterator(flatNode, region);
+ boolean found = false;
+ while (it.hasPrev()) {
+ region = it.prev();
+ // if (region.getType() != CSSRegionContexts.CSS_S &&
+ // region.getType() != CSSRegionContexts.CSS_DELIMITER &&
+ // region.getType() !=
+ // CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ if (region.getType() != CSSRegionContexts.CSS_S) {
+ found = true;
+ break;
+ }
+ }
+ int pos = insertPos - (found ? it.getStructuredDocumentRegion().getTextEndOffset(region) : it.getStructuredDocumentRegion().getStartOffset(region));
+ // flatNode = it.getStructuredDocumentRegion();
+ // if (found) {
+ // if (region.getLength() != region.getTextLength()) {
+ // pos = insertPos - flatNode.getTextEndOffset(region);
+ // } else {
+ // pos = insertPos - flatNode.getEndOffset(region);
+ // }
+ // } else {
+ // pos = insertPos - flatNode.getStartOffset(region);
+ // }
+ return (pos >= 0) ? pos : 0;
+ }
+
+ /**
+ *
+ */
+ String getLineDelimiter(ICSSNode node) {
+ ICSSModel model = (node != null) ? node.getOwnerDocument().getModel() : null;
+ return (model != null) ? model.getStructuredDocument().getLineDelimiter() : "\n"; //$NON-NLS-1$
+
+ // TODO : check whether to use model.getLineDelimiter() or
+ // model.getStructuredDocument().getLineDelimiter()
+ }
+
+ /**
+ *
+ */
+ protected CompoundRegion[] getOutsideRegions(IStructuredDocument model, IRegion reg) {
+ CompoundRegion[] ret = new CompoundRegion[2];
+ RegionIterator it = new RegionIterator(model, reg.getOffset());
+ it.prev();
+ if (it.hasPrev()) {
+ ITextRegion textRegion = it.prev();
+ IStructuredDocumentRegion documentRegion = it.getStructuredDocumentRegion();
+ ret[0] = new CompoundRegion(documentRegion, textRegion);
+ }
+ else {
+ ret[0] = null;
+ }
+ it.reset(model, reg.getOffset() + reg.getLength());
+ if (it.hasNext()) {
+ ITextRegion textRegion = it.next();
+ IStructuredDocumentRegion documentRegion = it.getStructuredDocumentRegion();
+ ret[1] = new CompoundRegion(documentRegion, textRegion);
+ }
+ else {
+ ret[1] = null;
+ }
+ return ret;
+ }
+
+ /**
+ */
+ protected CSSSourceGenerator getParentFormatter(ICSSNode node) {
+ ICSSNode parent = node.getParentNode();
+ if (parent != null) {
+ CSSSourceGenerator formatter = (CSSSourceGenerator) ((INodeNotifier) parent).getAdapterFor(CSSSourceFormatter.class);
+ if (formatter == null) {
+ formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) parent);
+ }
+ return formatter;
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ protected CompoundRegion[] getRegions(IStructuredDocument model, IRegion reg, IRegion exceptFor, String pickupType) {
+ int start = reg.getOffset();
+ int end = reg.getOffset() + reg.getLength();
+ int startE = (exceptFor != null) ? exceptFor.getOffset() : -1;
+ int endE = (exceptFor != null) ? exceptFor.getOffset() + exceptFor.getLength() : 0;
+
+ ArrayList list = new ArrayList();
+ IStructuredDocumentRegion flatNode = model.getRegionAtCharacterOffset(start);
+ boolean pickuped = false;
+ while (flatNode != null && flatNode.getStartOffset() < end) {
+ ITextRegionList regionList = flatNode.getRegions();
+ Iterator it = regionList.iterator();
+ while (it.hasNext()) {
+ ITextRegion region = (ITextRegion) it.next();
+ if (flatNode.getStartOffset(region) < start)
+ continue;
+ if (end <= flatNode.getStartOffset(region))
+ break;
+ if (startE >= 0 && startE <= flatNode.getStartOffset(region) && flatNode.getEndOffset(region) <= endE)
+ continue;
+ if (region.getType() == CSSRegionContexts.CSS_COMMENT || region.getType() == CSSRegionContexts.CSS_CDC || region.getType() == CSSRegionContexts.CSS_CDO)
+ list.add(new CompoundRegion(flatNode, region));
+ else if (!pickuped && region.getType() == pickupType) {
+ list.add(new CompoundRegion(flatNode, region));
+ pickuped = true;
+ }
+ }
+ flatNode = flatNode.getNext();
+ }
+ if (list.size() > 0) {
+ CompoundRegion[] regions = new CompoundRegion[list.size()];
+ list.toArray(regions);
+ return regions;
+ }
+ return new CompoundRegion[0];
+ }
+
+ /**
+ *
+ */
+ protected CompoundRegion[] getRegionsWithoutWhiteSpaces(IStructuredDocument model, IRegion reg, CSSCleanupStrategy stgy) {
+ int start = reg.getOffset();
+ int end = reg.getOffset() + reg.getLength() - 1;
+ ArrayList list = new ArrayList();
+ IStructuredDocumentRegion flatNode = model.getRegionAtCharacterOffset(start);
+ while (flatNode != null && flatNode.getStartOffset() <= end) {
+ ITextRegionList regionList = flatNode.getRegions();
+ Iterator it = regionList.iterator();
+ while (it.hasNext()) {
+ ITextRegion region = (ITextRegion) it.next();
+ if (flatNode.getStartOffset(region) < start)
+ continue;
+ if (end < flatNode.getStartOffset(region))
+ break;
+ if (region.getType() != CSSRegionContexts.CSS_S || (isCleanup() && !stgy.isFormatSource())) // for
+ // not
+ // formatting
+ // case
+ // on
+ // cleanup
+ // action
+ list.add(new CompoundRegion(flatNode, region));
+ }
+ flatNode = flatNode.getNext();
+ }
+ if (list.size() > 0) {
+ CompoundRegion[] regions = new CompoundRegion[list.size()];
+ list.toArray(regions);
+ return regions;
+ }
+ return new CompoundRegion[0];
+ }
+
+ /**
+ *
+ */
+ public static boolean includes(IRegion region, int start, int end) {
+ if (region == null)
+ return false;
+
+ return (region.getOffset() <= start) && (end <= region.getOffset() + region.getLength());
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ protected static boolean isCleanup() {
+ return strategy == CLEANUP;
+ }
+
+ /**
+ *
+ * @return boolean
+ */
+ protected static boolean isFormat() {
+ return strategy == FORMAT;
+ }
+
+ /**
+ *
+ */
+ protected boolean isIncludesPreEnd(ICSSNode node, IRegion region) {
+ return (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getStartOffset() == (region.getOffset() + region.getLength()));
+ }
+
+ /**
+ *
+ */
+ static protected boolean needS(CompoundRegion region) {
+ return (region != null && region.getType() != CSSRegionContexts.CSS_S);
+ }
+
+ /**
+ *
+ */
+ public static IRegion overlappedRegion(IRegion region, int start, int end) {
+ if (overlaps(region, start, end)) {
+ int offset = (region.getOffset() <= start) ? start : region.getOffset();
+ int length = ((end <= region.getOffset() + region.getLength()) ? end : region.getOffset() + region.getLength()) - offset;
+ return new FormatRegion(offset, length);
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public static boolean overlaps(IRegion region, int start, int end) {
+ if (region == null)
+ return false;
+
+ return (start < region.getOffset() + region.getLength()) && (region.getOffset() < end);
+ }
+
+ private String getIndentString() {
+ StringBuffer indent = new StringBuffer();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (preferences != null) {
+ char indentChar = ' ';
+ String indentCharPref = preferences.getString(CSSCorePreferenceNames.INDENTATION_CHAR);
+ if (CSSCorePreferenceNames.TAB.equals(indentCharPref)) {
+ indentChar = '\t';
+ }
+ int indentationWidth = preferences.getInt(CSSCorePreferenceNames.INDENTATION_SIZE);
+
+ for (int i = 0; i < indentationWidth; i++) {
+ indent.append(indentChar);
+ }
+ }
+ return indent.toString();
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrChangeContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrChangeContext.java
new file mode 100644
index 0000000..924a73e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrChangeContext.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+/**
+ *
+ */
+public class AttrChangeContext {
+
+ public int start, end;
+
+ /**
+ *
+ */
+ public AttrChangeContext() {
+ super();
+ start = end = 0;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrFormatter.java
new file mode 100644
index 0000000..141a9d4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AttrFormatter.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+
+
+/**
+ *
+ */
+public class AttrFormatter extends DefaultCSSSourceFormatter {
+
+ private static AttrFormatter instance;
+
+ /**
+ *
+ */
+ AttrFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ ICSSAttr attr = (ICSSAttr) node;
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int end = ((IndexedRegion) node).getEndOffset();
+ if (end > 0) { // format source
+ int start = ((IndexedRegion) node).getStartOffset();
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+
+ if (attr.getName().equals(ICSSStyleRule.SELECTOR) || attr.getName().equals(ICSSPageRule.SELECTOR)) {
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBetween(node, regions[i - 1], regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+ else if (attr.getName().equals(ICSSImportRule.HREF)) {
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ }
+ else if (attr.getName().equals(ICSSCharsetRule.ENCODING)) {
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ }
+ else if (attr.getName().equals(ICSSStyleDeclItem.IMPORTANT)) {
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ }
+ else if (attr.getName() == null || attr.getName().length() == 0) {
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ }
+ else {
+ // counter attributes
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ }
+ }
+ else { // generate source
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ String value = attr.getValue();
+ if (value == null)
+ value = "";//$NON-NLS-1$
+ if (attr.getName().equals(ICSSStyleRule.SELECTOR) || attr.getName().equals(ICSSPageRule.SELECTOR)) {
+ }
+ else if (attr.getName().equals(ICSSImportRule.HREF)) {
+ String uri = org.eclipse.wst.css.core.internal.util.CSSLinkConverter.stripFunc(value);
+ String func = preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER ? "URL(" : "url(";//$NON-NLS-2$//$NON-NLS-1$
+ if (preferences.getBoolean(CSSCorePreferenceNames.FORMAT_QUOTE_IN_URI)) {
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ quote = CSSUtil.detectQuote(uri, quote);
+ value = func + quote + uri + quote + ")";//$NON-NLS-1$
+ }
+ else {
+ value = func + uri + ")";//$NON-NLS-1$
+ }
+ }
+ else if (attr.getName().equals(ICSSCharsetRule.ENCODING)) {
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ if (!value.startsWith("\"") && !value.startsWith("\'"))//$NON-NLS-2$//$NON-NLS-1$
+ value = quote + value;
+ if (!value.endsWith("\"") && !value.endsWith("\'"))//$NON-NLS-2$//$NON-NLS-1$
+ value = value + quote;
+ }
+ else if (attr.getName().equals(ICSSStyleDeclItem.IMPORTANT)) {
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ value = value.toUpperCase();
+ else
+ value = value.toLowerCase();
+ }
+ else if (attr.getName() == null || attr.getName().length() == 0) {
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ value = value.toUpperCase();
+ else
+ value = value.toLowerCase();
+ }
+ else {
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ value = value.toUpperCase();
+ else
+ value = value.toLowerCase();
+ }
+ source.append(value);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ formatPre(node, source);
+ }
+
+ /**
+ *
+ */
+ public synchronized static AttrFormatter getInstance() {
+ if (instance == null) {
+ instance = new AttrFormatter();
+ }
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSFormatUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSFormatUtil.java
new file mode 100644
index 0000000..8808519
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSFormatUtil.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.provisional.adapters.ICSSModelAdapter;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleDeclarationAdapter;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+
+public class CSSFormatUtil {
+ public List collectCSSNodes(IStructuredModel model, int start, int length) {
+ List nodes = new ArrayList();
+
+ IndexedRegion startNode = model.getIndexedRegion(start);
+ IndexedRegion endNode = model.getIndexedRegion(start + length - 1);
+
+ if (startNode == null || endNode == null) {
+ return nodes;
+ }
+
+ if (model instanceof ICSSModel && startNode instanceof ICSSNode && endNode instanceof ICSSNode) {
+ // CSS model
+ ICSSNode ca = getCommonAncestor((ICSSNode) startNode, (ICSSNode) endNode);
+ if (ca != null) {
+ for (ICSSNode node = ca.getFirstChild(); node != null && start + length < ((IndexedRegion) node).getStartOffset(); node = node.getNextSibling()) {
+ if (start < ((IndexedRegion) node).getEndOffset()) {
+ nodes.add(node);
+ }
+ }
+ }
+ }
+ else if (model instanceof IDOMModel && startNode instanceof IDOMNode && endNode instanceof IDOMNode) {
+ if (startNode instanceof Text) {
+ startNode = (IndexedRegion) ((Text) startNode).getParentNode();
+ }
+ if (endNode instanceof Text) {
+ endNode = (IndexedRegion) ((Text) endNode).getParentNode();
+ }
+ // HTML model, maybe
+ IDOMNode ca = (IDOMNode) getCommonAncestor((Node) startNode, (Node) endNode);
+ findCSS(nodes, ca);
+ }
+
+ return nodes;
+ }
+
+ /**
+ * getCommonAncestor method
+ *
+ * @return org.w3c.dom.Node
+ * @param node
+ * org.w3c.dom.Node
+ */
+ private Node getCommonAncestor(Node node1, Node node2) {
+ if (node1 == null || node2 == null)
+ return null;
+
+ for (Node na = node2; na != null; na = na.getParentNode()) {
+ for (Node ta = node1; ta != null; ta = ta.getParentNode()) {
+ if (ta == na)
+ return ta;
+ }
+ }
+ return null; // not found
+ }
+
+ private void findCSS(List cssNodes, IDOMNode node) {
+ ICSSModelAdapter adapter;
+ adapter = (ICSSModelAdapter) node.getAdapterFor(IStyleSheetAdapter.class);
+ if (adapter != null) {
+ ICSSModel model = adapter.getModel();
+ if (model != null && model.getStyleSheetType() == ICSSModel.EMBEDDED) {
+ cssNodes.add(model.getDocument());
+ }
+ }
+ else {
+ adapter = (ICSSModelAdapter) node.getAdapterFor(IStyleDeclarationAdapter.class);
+ if (adapter != null) {
+ ICSSModel model = adapter.getModel();
+ if (model != null && model.getStyleSheetType() == ICSSModel.INLINE) {
+ cssNodes.add(model.getDocument());
+ }
+ }
+ }
+
+ for (IDOMNode child = (IDOMNode) node.getFirstChild(); child != null; child = (IDOMNode) child.getNextSibling()) {
+ findCSS(cssNodes, child);
+ }
+ }
+
+ private ICSSNode getCommonAncestor(ICSSNode nodeA, ICSSNode nodeB) {
+ if (nodeA == null || nodeB == null) {
+ return null;
+ }
+
+ for (ICSSNode na = nodeA; na != null; na = na.getParentNode()) {
+ for (ICSSNode ta = nodeB; ta != null; ta = ta.getParentNode()) {
+ if (ta == na) {
+ return ta;
+ }
+ }
+ }
+
+ return null; // not found
+ }
+
+ /**
+ */
+ public void replaceSource(IStructuredModel model, int offset, int length, String source) {
+ if (model == null)
+ return;
+ IStructuredDocument structuredDocument = model.getStructuredDocument();
+ if (structuredDocument == null)
+ return;
+ if (offset >= 0 && length >= 0 && offset + length <= structuredDocument.getLength()) {
+ if (structuredDocument.containsReadOnly(offset, length))
+ return;
+ if (source == null)
+ source = new String();
+ // We use 'structuredDocument' as the requester object just so
+ // this and the other
+ // format-related 'repalceText' (in replaceSource) can use the
+ // same requester.
+ // Otherwise, if requester is not identical,
+ // the undo group gets "broken" into multiple pieces based
+ // on the requesters being different. Technically, any unique,
+ // common
+ // requester object would work.
+ structuredDocument.replaceText(structuredDocument, offset, length, source);
+ }
+ }
+
+ public synchronized static CSSFormatUtil getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSFormatUtil();
+ }
+ return fInstance;
+ }
+
+ private CSSFormatUtil() {
+ super();
+ }
+
+ private static CSSFormatUtil fInstance;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatter.java
new file mode 100644
index 0000000..04473a0
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatter.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+
+/**
+ *
+ */
+public interface CSSSourceFormatter {
+
+ /**
+ *
+ */
+ StringBuffer cleanup(ICSSNode node);
+
+ /**
+ *
+ * @return java.lang.StringBuffer
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param region
+ * org.eclipse.jface.text.IRegion
+ */
+ StringBuffer cleanup(ICSSNode node, IRegion region);
+
+ /**
+ *
+ */
+ StringBuffer format(ICSSNode node);
+
+ /**
+ *
+ */
+ StringBuffer format(ICSSNode node, IRegion region);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatterFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatterFactory.java
new file mode 100644
index 0000000..2f689c4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceFormatterFactory.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+
+
+/**
+ *
+ */
+public class CSSSourceFormatterFactory {
+ /**
+ *
+ */
+ private CSSSourceFormatterFactory() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public CSSSourceGenerator getSourceFormatter(INodeNotifier target) {
+ ICSSNode node = (ICSSNode) target;
+ short type = node.getNodeType();
+ switch (type) {
+ case ICSSNode.CHARSETRULE_NODE :
+ return CharsetRuleFormatter.getInstance();
+ case ICSSNode.FONTFACERULE_NODE :
+ return FontFaceRuleFormatter.getInstance();
+ case ICSSNode.IMPORTRULE_NODE :
+ return ImportRuleFormatter.getInstance();
+ case ICSSNode.MEDIALIST_NODE :
+ return MediaListFormatter.getInstance();
+ case ICSSNode.MEDIARULE_NODE :
+ return MediaRuleFormatter.getInstance();
+ case ICSSNode.PRIMITIVEVALUE_NODE :
+ ICSSPrimitiveValue value = (ICSSPrimitiveValue) node;
+ if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_COUNTER)
+ return CounterFormatter.getInstance();
+ else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RECT)
+ return RectFormatter.getInstance();
+ else if (value.getPrimitiveType() == org.w3c.dom.css.CSSPrimitiveValue.CSS_RGBCOLOR)
+ return RGBFormatter.getInstance();
+ else
+ return PrimitiveValueFormatter.getInstance();
+ case ICSSNode.PAGERULE_NODE :
+ return PageRuleFormatter.getInstance();
+ case ICSSNode.STYLEDECLARATION_NODE :
+ return StyleDeclarationFormatter.getInstance();
+ case ICSSNode.STYLEDECLITEM_NODE :
+ return StyleDeclItemFormatter.getInstance();
+ case ICSSNode.STYLERULE_NODE :
+ return StyleRuleFormatter.getInstance();
+ case ICSSNode.STYLESHEET_NODE :
+ return StyleSheetFormatter.getInstance();
+ case ICSSNode.ATTR_NODE :
+ return AttrFormatter.getInstance();
+ default :
+ return UnknownRuleFormatter.getInstance();
+ }
+ }
+
+ public synchronized static CSSSourceFormatterFactory getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSSourceFormatterFactory();
+ }
+ return fInstance;
+ }
+
+ private static CSSSourceFormatterFactory fInstance;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceGenerator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceGenerator.java
new file mode 100644
index 0000000..992e8af
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CSSSourceGenerator.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+
+public interface CSSSourceGenerator extends CSSSourceFormatter {
+
+ /**
+ *
+ */
+ StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext region);
+
+ /**
+ *
+ */
+ StringBuffer formatBefore(ICSSNode node, ICSSNode child, IRegion exceptFor);
+
+ /**
+ *
+ */
+ int getAttrInsertPos(ICSSNode node, String attrName);
+
+ /**
+ *
+ */
+ int getChildInsertPos(ICSSNode node);
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ int getLengthToReformatAfter(ICSSNode node, int insertPos);
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ int getLengthToReformatBefore(ICSSNode node, int insertPos);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CharsetRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CharsetRuleFormatter.java
new file mode 100644
index 0000000..744eedc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CharsetRuleFormatter.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSCharsetRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class CharsetRuleFormatter extends DefaultCSSSourceFormatter {
+
+ public final static java.lang.String CHARSET = "@charset";//$NON-NLS-1$
+ private static CharsetRuleFormatter instance;
+
+ /**
+ *
+ */
+ CharsetRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ if (!ICSSCharsetRule.ENCODING.equalsIgnoreCase(attr.getName()))
+ return buf;
+
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.prev();
+ if (it.hasPrev()) {
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S)
+ context.start = it.getStructuredDocumentRegion().getStartOffset(prev);
+ else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ } else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ } else {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ context.start = flatNode.getStartOffset(region);
+ context.end = flatNode.getStartOffset(region);
+ } else {
+ context.start = flatNode.getEndOffset() + 1;
+ context.end = flatNode.getEndOffset();
+ }
+ }
+ }
+ // generate text
+ if (insert) {
+ appendSpaceBefore(node, attr.getValue(), buf);
+ buf.append(attr.getValue());
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int end = ((IndexedRegion) node).getEndOffset();
+ if (end > 0) { // format source
+ int start = ((IndexedRegion) node).getStartOffset();
+ formatPre(node, new FormatRegion(start, end - start), source);
+ } else { // generate source
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ String str = CHARSET;
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ str = CHARSET.toUpperCase();
+ source.append(str);
+ String enc = ((ICSSCharsetRule) node).getEncoding();
+ quote = CSSUtil.detectQuote(enc, quote);
+ str = quote + ((enc != null) ? enc : "") + quote + ";";//$NON-NLS-1$ //$NON-NLS-2$
+ appendSpaceBefore(node, str, source);
+ source.append(str);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if ((i != 0 || needS(outside[0])) && !regions[i].getType().equals(CSSRegionContexts.CSS_DELIMITER))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ if (!ICSSCharsetRule.ENCODING.equalsIgnoreCase(attrName))
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICSSCharsetRule.ENCODING);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (iNode.getEndOffset() <= 0)
+ return -1;
+
+ CompoundRegion regions[] = getRegionsWithoutWhiteSpaces(node.getOwnerDocument().getModel().getStructuredDocument(), new FormatRegion(iNode.getStartOffset(), iNode.getEndOffset() - iNode.getStartOffset()), stgy);
+ for (int i = regions.length - 1; i >= 0; i--) {
+ if (regions[i].getType() != CSSRegionContexts.CSS_COMMENT)
+ return regions[i].getStartOffset();
+ }
+ return iNode.getEndOffset();
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode.getRegionAtCharacterOffset(n - 1).getType() == CSSRegionContexts.CSS_DELIMITER)
+ return n - 1;
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static CharsetRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new CharsetRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CompoundRegion.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CompoundRegion.java
new file mode 100644
index 0000000..0662feb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CompoundRegion.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+class CompoundRegion {
+
+ CompoundRegion(IStructuredDocumentRegion documentRegion, ITextRegion textRegion) {
+ super();
+ this.fDocumentRegion = documentRegion;
+ this.fTextRegion = textRegion;
+ }
+
+ IStructuredDocumentRegion getDocumentRegion() {
+ return fDocumentRegion;
+ }
+
+ ITextRegion getTextRegion() {
+ return fTextRegion;
+ }
+
+ String getType() {
+ return fTextRegion.getType();
+ }
+
+ String getText() {
+ return fDocumentRegion.getText(fTextRegion);
+ }
+
+ // Bug 218993: Added to get text with whitespace for cleanup
+ // without formatting
+ String getFullText() {
+ return fDocumentRegion.getFullText(fTextRegion);
+ }
+
+ int getStartOffset() {
+ return fDocumentRegion.getStartOffset(fTextRegion);
+ }
+
+ int getEndOffset() {
+ return fDocumentRegion.getEndOffset(fTextRegion);
+ }
+
+
+ private IStructuredDocumentRegion fDocumentRegion;
+ private ITextRegion fTextRegion;
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CounterFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CounterFormatter.java
new file mode 100644
index 0000000..c31725b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/CounterFormatter.java
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICounter;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class CounterFormatter extends DefaultCSSSourceFormatter {
+
+ private static CounterFormatter instance;
+
+ /**
+ *
+ */
+ CounterFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ StringBuffer source = new StringBuffer();
+ if (node == null || attr == null)
+ return source;
+
+ if (!ICounter.IDENTIFIER.equalsIgnoreCase(attr.getName()) && !ICounter.LISTSTYLE.equalsIgnoreCase(attr.getName()) && !ICounter.SEPARATOR.equalsIgnoreCase(attr.getName()))
+ return source;
+
+ // get region to replace
+ IndexedRegion iNode = (IndexedRegion) node;
+ context.start = iNode.getStartOffset();
+ context.end = iNode.getEndOffset();
+
+ ICounter counter = (ICounter) node;
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ String sep = counter.getSeparator();
+ String ident = counter.getIdentifier();
+ String style = counter.getListStyle();
+
+ if (ICounter.IDENTIFIER.equalsIgnoreCase(attr.getName())) {
+ if (insert)
+ ident = attr.getValue();
+ else
+ ident = "";//$NON-NLS-1$
+ }
+ else if (ICounter.LISTSTYLE.equalsIgnoreCase(attr.getName())) {
+ if (insert)
+ style = attr.getValue();
+ else
+ style = null;
+ }
+ else if (ICounter.SEPARATOR.equalsIgnoreCase(attr.getName())) {
+ if (insert)
+ sep = attr.getValue();
+ else
+ sep = null;
+ }
+
+ quote = CSSUtil.detectQuote(sep, quote);
+ sep = (sep == null || sep.length() == 0) ? null : (quote + sep + quote);
+
+ String func = (sep == null || sep.length() == 0) ? "counter(" : "counters(";//$NON-NLS-2$//$NON-NLS-1$
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER) {
+ ident = ident.toUpperCase();
+ style = style.toUpperCase();
+ func = func.toUpperCase();
+ }
+ else {
+ ident = ident.toLowerCase();
+ style = style.toLowerCase();
+ }
+ if (sep == null || sep.length() == 0) {
+ source.append(func);
+ appendSpaceBefore(node, ident, source);
+ source.append(ident);
+ }
+ else {
+ source.append(func);
+ appendSpaceBefore(node, ident, source);
+ source.append(ident);
+ source.append(",");//$NON-NLS-1$
+ appendSpaceBefore(node, sep, source);
+ source.append(sep);
+ }
+
+ if (style != null && style.length() != 0) {
+ source.append(",");//$NON-NLS-1$
+ appendSpaceBefore(node, style, source);
+ }
+ source.append(")");//$NON-NLS-1$
+
+ /*
+ * IStructuredDocument structuredDocument =
+ * node.getOwnerDocument().getModel().getStructuredDocument();
+ * ITextRegion[] regions =
+ * getRegionsWithoutWhiteSpaces(structuredDocument, new
+ * FormatRegion(context.start, context.end - context.start + 1)); int
+ * commas[2]; int numComma = 0; for(int j = 0; j <regions.length; j++) {
+ * if (regions[j].getType() == CSSRegionContexts.COMMA) {
+ * commas[numComma++] = j; if (numComma > 1) break; } }
+ *
+ * if (ICounter.IDENTIFIER.equalsIgnoreCase(attr.getName())) { } else
+ * if (ICounter.LISTSTYLE.equalsIgnoreCase(attr.getName())) { } else
+ * if (ICounter.SEPARATOR.equalsIgnoreCase(attr.getName())) { boolean
+ * skipSpace = false; String func = insert ? "counters(" : "counter(";
+ * if (mgr.isPropValueUpperCase()) func = func.toUpperCase();
+ *
+ * for(int i=0; i <regions.length; i++) { if (regions[i].getType() ==
+ * CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ * source.append(func); else { if (numComma == 2 && commas[1] < i) {
+ * } else if (numComma == 1 && commas[0] < i && insert) {
+ * } else if (numComma == 1 && commas[0] < i && ! insert) { } else if
+ * (numComma == 0 && insert && regions[i].getType ==
+ * CSSRegionContexts.PARENTHESIS_CLOSE) { source.append(",");
+ * appendSpaceBefore(node,attr.getValue(),source);
+ * source.append(attr.getValue()); }
+ *
+ * if (i != 0 && !skipSpace)
+ * appendSpaceBefore(node,regions[i],source);
+ * source.append(decoratedPropValueRegion(regions[i])); } skipSpace =
+ * false;
+ *
+ * if (regions[i].getType() ==
+ * CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) skipSpace = true; } }
+ */
+ return source;
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ boolean skipSpace = false;
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 && !skipSpace)
+ appendSpaceBefore(node, regions[i], source);
+ skipSpace = false;
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ if (regions[i].getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ skipSpace = true;
+ }
+ }
+ else { // generate source
+ ICounter counter = (ICounter) node;
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ String separator = counter.getSeparator();
+ quote = CSSUtil.detectQuote(separator, quote);
+ String sep = (separator == null || separator.length() == 0) ? null : (quote + separator + quote);
+ String ident = counter.getIdentifier();
+ String style = counter.getListStyle();
+ String func = (sep == null || sep.length() == 0) ? "counter(" : "counters(";//$NON-NLS-2$//$NON-NLS-1$
+ // normalize
+ if (ident == null)
+ ident = "";//$NON-NLS-1$
+ if (style == null)
+ style = "";//$NON-NLS-1$
+
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER) {
+ ident = ident.toUpperCase();
+ style = style.toUpperCase();
+ func = func.toUpperCase();
+ }
+ else {
+ ident = ident.toLowerCase();
+ style = style.toLowerCase();
+ }
+ if (sep == null || sep.length() == 0) {
+ source.append(func);
+ appendSpaceBefore(node, ident, source);
+ source.append(ident);
+ }
+ else {
+ source.append(func);
+ appendSpaceBefore(node, ident, source);
+ source.append(ident);
+ source.append(",");//$NON-NLS-1$
+ appendSpaceBefore(node, sep, source);
+ source.append(sep);
+ }
+
+ if (style != null && style.length() != 0) {
+ source.append(",");//$NON-NLS-1$
+ appendSpaceBefore(node, style, source);
+ }
+ source.append(")");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (ICounter.IDENTIFIER.equalsIgnoreCase(attrName)) {
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICounter.IDENTIFIER);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ if (iNode.getEndOffset() <= 0)
+ return -1;
+
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(iNode.getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, flatNode.getRegionAtCharacterOffset(iNode.getEndOffset() - 1));
+ while (it.hasPrev()) {
+ ITextRegion region = it.prev();
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ return it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ return ((IndexedRegion) node).getEndOffset();
+ }
+ else if (ICounter.LISTSTYLE.equalsIgnoreCase(attrName)) {
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICounter.LISTSTYLE);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(iNode.getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, flatNode.getRegionAtCharacterOffset(iNode.getEndOffset() - 1));
+ while (it.hasPrev()) {
+ ITextRegion region = it.prev();
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR)
+ return it.getStructuredDocumentRegion().getEndOffset(region);
+ else if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ return it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ return ((IndexedRegion) node).getEndOffset();
+ }
+ else if (ICounter.SEPARATOR.equalsIgnoreCase(attrName)) {
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICounter.SEPARATOR);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(iNode.getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, flatNode.getRegionAtCharacterOffset(iNode.getEndOffset() - 1));
+ boolean hasComma = false;
+ while (it.hasPrev()) {
+ ITextRegion region = it.prev();
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR) {
+ if (!hasComma)
+ hasComma = true;
+ else
+ return it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ else if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ return it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ return ((IndexedRegion) node).getEndOffset();
+ }
+ else
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static CounterFormatter getInstance() {
+ if (instance == null)
+ instance = new CounterFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DeclContainerFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DeclContainerFormatter.java
new file mode 100644
index 0000000..ea79996
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DeclContainerFormatter.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+
+
+/**
+ *
+ */
+public class DeclContainerFormatter extends DefaultCSSSourceFormatter {
+
+ /**
+ *
+ */
+ DeclContainerFormatter() {
+ super();
+ }
+
+ /**
+ *
+ * @return java.lang.String
+ */
+ protected String decoratedSelectorRegion(CompoundRegion region, CompoundRegion prevRegion, CSSCleanupStrategy stgy) {
+ if (isFormat())
+ return region.getText();
+
+ String text = null;
+ if (!stgy.isFormatSource())
+ text = region.getFullText();
+ else
+ text = region.getText();
+
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE || type == CSSRegionContexts.CSS_SELECTOR_CLASS || type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_ID || type == CSSRegionContexts.CSS_SELECTOR_PSEUDO) {
+ short selCase = stgy.getSelectorTagCase();
+ if (selCase == org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy.UPPER) {
+ return text.toUpperCase();
+ }
+ else if (selCase == org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy.LOWER) {
+ return text.toLowerCase();
+ }
+ return text;
+ }
+
+ return decoratedRegion(region, 0, stgy);
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+ else { // generate source
+ String delim = getLineDelimiter(node);
+ source.append(delim);
+ source.append(getIndent(node));
+ source.append("}");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode.getRegionAtCharacterOffset(n - 1).getType() == CSSRegionContexts.CSS_RBRACE)
+ return n - 1;
+ else
+ return n;
+ }
+ return -1;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java
new file mode 100644
index 0000000..2b27800
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+
+
+/**
+ *
+ */
+public class DefaultCSSSourceFormatter extends AbstractCSSSourceFormatter {
+
+ /**
+ *
+ */
+ DefaultCSSSourceFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void appendSpaceBetween(ICSSNode node, CompoundRegion prev, CompoundRegion next, StringBuffer source) {
+ if (isCleanup() && !getCleanupStrategy(node).isFormatSource())
+ return; // for not formatting case on cleanup action
+
+ // in selector
+ String prevType = prev.getType();
+ String nextType = next.getType();
+
+ if (prevType == CSSRegionContexts.CSS_PAGE || prevType == CSSRegionContexts.CSS_CHARSET || prevType == CSSRegionContexts.CSS_ATKEYWORD || prevType == CSSRegionContexts.CSS_FONT_FACE || prevType == CSSRegionContexts.CSS_IMPORT || prevType == CSSRegionContexts.CSS_MEDIA) {
+ appendSpaceBefore(node, next, source);
+ return;
+ }
+
+ if (prevType == CSSRegionContexts.CSS_UNKNOWN && nextType != CSSRegionContexts.CSS_COMMENT) {
+ if (prev.getEndOffset() != next.getStartOffset()) { // not
+ // sequential
+ appendSpaceBefore(node, next, source);
+ }
+ return;
+ }
+
+ if (prevType == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR || prevType == CSSRegionContexts.CSS_COMMENT || nextType == CSSRegionContexts.CSS_COMMENT || nextType == CSSRegionContexts.CSS_LBRACE || nextType == CSSRegionContexts.CSS_UNKNOWN) {
+ appendSpaceBefore(node, next, source);
+ return;
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0)
+ return n;
+ return -1;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FontFaceRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FontFaceRuleFormatter.java
new file mode 100644
index 0000000..ee46eed
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FontFaceRuleFormatter.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+
+
+/**
+ *
+ */
+public class FontFaceRuleFormatter extends DeclContainerFormatter {
+
+ public final static java.lang.String FONT_FACE = "@font-face";//$NON-NLS-1$
+ private static FontFaceRuleFormatter instance;
+
+ /**
+ *
+ */
+ FontFaceRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+ if (end > 0) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ }
+ else {
+ String str = FONT_FACE;
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ str = FONT_FACE.toUpperCase();
+ source.append(str);
+ appendSpaceBefore(node, "{", source);//$NON-NLS-1$
+ source.append("{");//$NON-NLS-1$
+ }
+ appendDelimBefore(node, null, source);
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ if (needS(outside[1])) {
+ if (isIncludesPreEnd(node, region))
+ appendDelimBefore(node, null, source);
+ else
+ appendSpaceBefore(node, outside[1], source);
+ }
+ }
+
+ /**
+ *
+ */
+ public synchronized static FontFaceRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new FontFaceRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FormatRegion.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FormatRegion.java
new file mode 100644
index 0000000..ff0c9d3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FormatRegion.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+
+/**
+ *
+ */
+class FormatRegion implements IRegion {
+
+ private int fOffset, fLength;
+
+ /**
+ *
+ */
+ FormatRegion(int offset, int length) {
+ super();
+ set(offset, length);
+ }
+
+ /**
+ * Returns the length of the region.
+ *
+ * @return the length of the region
+ */
+ public int getLength() {
+ return fLength;
+ }
+
+ /**
+ * Returns the offset of the region.
+ *
+ * @return the offset of the region
+ */
+ public int getOffset() {
+ return fOffset;
+ }
+
+ /**
+ *
+ */
+ void set(int offset, int length) {
+ this.fOffset = offset;
+ this.fLength = length;
+ }
+
+ /**
+ *
+ */
+ void setLength(int newLength) {
+ fLength = newLength;
+ }
+
+ /**
+ *
+ */
+ void setOffset(int newOffset) {
+ fOffset = newOffset;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FunctionFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FunctionFormatter.java
new file mode 100644
index 0000000..8c47f0e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/FunctionFormatter.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+
+
+/**
+ *
+ */
+abstract public class FunctionFormatter extends AbstractCSSSourceFormatter {
+
+ /**
+ *
+ */
+ FunctionFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+ if (start > 0 && start < end) { // format source
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ String pickupType = CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR;
+ if (prev == null || child == null)
+ pickupType = null;
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, pickupType);
+ }
+ // extract source
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy));
+ }
+ } else if (prev != null && child != null) { // generate source between
+ // parameters
+ source.append(",");//$NON-NLS-1$
+ }
+ appendSpaceBefore(node, toAppend, source);
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode node, java.lang.StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy));
+ }
+ } else { // generate source
+ source.append(")");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+
+ if (end > 0) { // format source
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ } else { // generate source
+ String func = getFunc();
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ func = func.toUpperCase();
+ source.append(func);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode.getRegionAtCharacterOffset(n - 1).getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ return n - 1;
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ protected abstract String getFunc();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/ImportRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/ImportRuleFormatter.java
new file mode 100644
index 0000000..fc75852
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/ImportRuleFormatter.java
@@ -0,0 +1,339 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class ImportRuleFormatter extends AbstractCSSSourceFormatter {
+
+ public final static java.lang.String IMPORT = "@import";//$NON-NLS-1$
+ private static ImportRuleFormatter instance;
+
+ /**
+ *
+ */
+ ImportRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ if (!ICSSImportRule.HREF.equalsIgnoreCase(attr.getName()))
+ return buf;
+
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.prev();
+ if (it.hasPrev()) {
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S)
+ context.start = it.getStructuredDocumentRegion().getStartOffset(prev);
+ else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ it.next();
+ } else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ it.next();
+ it.next();
+ if (it.hasNext()) {
+ ITextRegion next = it.next();
+ if (next.getType() == CSSRegionContexts.CSS_S)
+ context.end = it.getStructuredDocumentRegion().getEndOffset(next);
+ else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ } else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ } else {
+ ICSSNode child = node.getFirstChild();
+ IStructuredDocumentRegion flatNode = null;
+ ITextRegion region = null;
+ if (child == null) {
+ flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ } else {
+ flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) child).getStartOffset() - 1);
+ region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) child).getStartOffset() - 1);
+ }
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ context.start = flatNode.getStartOffset(region);
+ context.end = flatNode.getEndOffset(region);
+ } else {
+ context.start = flatNode.getEndOffset();
+ context.end = flatNode.getEndOffset();
+ }
+ }
+ }
+ // generate text
+ if (insert && attr.getValue() != null && attr.getValue().length() > 0) {
+ appendSpaceBefore(node, attr.getValue(), buf);
+ buf.append(attr.getValue());
+ appendSpaceBefore(node, "", buf);//$NON-NLS-1$
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ // for media-type
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+ if (start > 0 && start < end) { // format source
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ String pickupType = CSSRegionContexts.CSS_MEDIA_SEPARATOR;
+ if (prev == null || child == null)
+ pickupType = null;
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, pickupType);
+ }
+ // extract source
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be
+ // comments
+ }
+ appendSpaceBefore(node, toAppend, source);
+ } else if (prev != null && child != null) { // generate source : ????
+ source.append(",");//$NON-NLS-1$
+ appendSpaceBefore(node, toAppend, source);
+ } else if (child != null) { // generate source : between 'url()' and
+ // media types
+ appendSpaceBefore(node, toAppend, source);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must be
+ // comments
+ }
+ if (needS(outside[1])) {
+ if (((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength())
+ appendSpaceBefore(node, toAppend, source);
+ else
+ appendSpaceBefore(node, outside[1], source);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ } else {
+ source.append(";"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if ((i != 0 || needS(outside[0])) && !regions[i].getType().equals(CSSRegionContexts.CSS_DELIMITER))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+
+ if (end > 0) { // format source
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ String str = regions[i].getText();
+ if (regions[i].getType() == CSSRegionContexts.CSS_IMPORT)
+ str = decoratedIdentRegion(regions[i], stgy);
+ else
+ str = decoratedPropValueRegion(regions[i], stgy);
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(str);
+ }
+ } else { // generate source
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ String str = IMPORT;
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ str = IMPORT.toUpperCase();
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ source.append(str);
+ str = "url(";//$NON-NLS-1$
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ str = str.toUpperCase();
+ String href = ((ICSSImportRule) node).getHref();
+ quote = CSSUtil.detectQuote(href, quote);
+ str = str + quote + href + quote + ")";//$NON-NLS-1$
+ appendSpaceBefore(node, str, source);
+ source.append(str);
+ }
+ ICSSNode child = node.getFirstChild();
+ if (child != null && (child instanceof org.w3c.dom.stylesheets.MediaList) && ((org.w3c.dom.stylesheets.MediaList) child).getLength() > 0) {
+ appendSpaceBefore(node, "", source);//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ String str = regions[i].getText();
+ if (regions[i].getType() == CSSRegionContexts.CSS_IMPORT)
+ str = decoratedIdentRegion(regions[i], stgy);
+ else
+ str = decoratedPropValueRegion(regions[i], stgy);
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(str);
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ if (!ICSSImportRule.HREF.equalsIgnoreCase(attrName))
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICSSImportRule.HREF);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (iNode.getEndOffset() <= 0)
+ return -1;
+
+ FormatRegion formatRegion = null;
+ ICSSNode child = node.getFirstChild();
+ if (child != null && ((IndexedRegion) child).getEndOffset() > 0)
+ formatRegion = new FormatRegion(iNode.getStartOffset(), ((IndexedRegion) child).getStartOffset() - iNode.getStartOffset());
+ else
+ formatRegion = new FormatRegion(iNode.getStartOffset(), iNode.getEndOffset() - iNode.getStartOffset());
+ CompoundRegion regions[] = getRegionsWithoutWhiteSpaces(node.getOwnerDocument().getModel().getStructuredDocument(), formatRegion, getCleanupStrategy(node));
+
+ boolean atrule = false;
+ for (int i = 0; i < regions.length; i++) {
+ if (regions[i].getType() == CSSRegionContexts.CSS_IMPORT) {
+ atrule = true;
+ continue;
+ } else if (!atrule)
+ continue;
+ if (regions[i].getType() != CSSRegionContexts.CSS_COMMENT)
+ return regions[i].getStartOffset();
+ }
+ return (child != null && ((IndexedRegion) child).getEndOffset() > 0) ? ((IndexedRegion) child).getStartOffset() : iNode.getEndOffset();
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode.getRegionAtCharacterOffset(n - 1).getType() == CSSRegionContexts.CSS_DELIMITER)
+ return n - 1;
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static ImportRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new ImportRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaListFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaListFormatter.java
new file mode 100644
index 0000000..f44eb34
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaListFormatter.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ *
+ */
+public class MediaListFormatter extends DefaultCSSSourceFormatter {
+
+ private static MediaListFormatter instance;
+
+ /**
+ *
+ */
+ MediaListFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ boolean first = false, last = false;
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.prev();
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ while (it.hasPrev()) {
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S || prev.getType() == CSSRegionContexts.CSS_MEDIA_SEPARATOR || prev.getType() == CSSRegionContexts.CSS_COMMENT)
+ context.start = it.getStructuredDocumentRegion().getStartOffset(prev);
+ else
+ break;
+ }
+ if (context.start < ((IndexedRegion) node).getStartOffset()) {
+ context.start = ((IndexedRegion) node).getStartOffset();
+ first = true;
+
+ }
+ it.reset(flatNode, region);
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ while (it.hasNext()) {
+ ITextRegion next = it.next();
+ if (next.getType() == CSSRegionContexts.CSS_S || next.getType() == CSSRegionContexts.CSS_MEDIA_SEPARATOR || next.getType() == CSSRegionContexts.CSS_COMMENT)
+ context.end = it.getStructuredDocumentRegion().getEndOffset(next);
+ else
+ break;
+ }
+ if (((IndexedRegion) node).getEndOffset() < context.end) {
+ context.end = ((IndexedRegion) node).getEndOffset();
+ last = true;
+ }
+ } else {
+ last = true;
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, region);
+ context.start = it.getStructuredDocumentRegion().getEndOffset(region);
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ while (it.hasPrev()) {
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S || prev.getType() == CSSRegionContexts.CSS_MEDIA_SEPARATOR || prev.getType() == CSSRegionContexts.CSS_COMMENT)
+ context.start = it.getStructuredDocumentRegion().getStartOffset(prev);
+ else
+ break;
+ }
+ if (context.start < ((IndexedRegion) node).getStartOffset()) {
+ context.start = ((IndexedRegion) node).getStartOffset();
+ first = true;
+ }
+ }
+ }
+ // generate text
+ if (insert && attr.getValue() != null && attr.getValue().length() > 0) {
+ if (!first)
+ buf.append(","); //$NON-NLS-1$
+ appendSpaceBefore(node, attr.getValue(), buf);
+ buf.append(attr.getValue());
+ if (!last) {
+ buf.append(","); //$NON-NLS-1$
+ appendSpaceBefore(node, "", buf); //$NON-NLS-1$
+ }
+ } else if (!first && !last) {
+ buf.append(","); //$NON-NLS-1$
+ appendSpaceBefore(node, "", buf); //$NON-NLS-1$
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ } else { // generate source
+ MediaList list = (MediaList) node;
+ int n = list.getLength();
+ for (int i = 0; i < n; i++) {
+ String medium = list.item(i);
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ medium = medium.toUpperCase();
+ else
+ medium = medium.toLowerCase();
+
+ if (i != 0) {
+ source.append(","); //$NON-NLS-1$
+ appendSpaceBefore(node, medium, source);
+ }
+ source.append(medium);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(attrName);
+
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (iNode.getEndOffset() <= 0)
+ return -1;
+
+ /*
+ * ITextRegion regions[] =
+ * getRegionsWithoutWhiteSpaces(node.getOwnerDocument().getModel().getStructuredDocument(),
+ * new FormatRegion(iNode.getStartOffset(), iNode.getEndOffset() -
+ * iNode.getStartOffset() + 1)); for(int i=regions.length - 1; i >= 0;
+ * i--) { if (regions[i].getType() == CSSRegionContexts.IMPORTANT_SYM)
+ * return regions[i].getStartOffset(); }
+ */
+ return iNode.getEndOffset();
+ }
+
+ /**
+ *
+ */
+ public synchronized static MediaListFormatter getInstance() {
+ if (instance == null)
+ instance = new MediaListFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaRuleFormatter.java
new file mode 100644
index 0000000..e546892
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/MediaRuleFormatter.java
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.w3c.dom.stylesheets.MediaList;
+
+
+/**
+ *
+ */
+public class MediaRuleFormatter extends AbstractCSSSourceFormatter {
+
+ public final static java.lang.String MEDIA = "@media";//$NON-NLS-1$
+ private static MediaRuleFormatter instance;
+
+ /**
+ *
+ */
+ MediaRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+ if (start > 0 && start < end) { // source formatting
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ String pickupType = null;
+ if ((prev != null && prev.getNodeType() == ICSSNode.MEDIALIST_NODE) || (prev == null && (child == null || child.getNodeType() != ICSSNode.MEDIALIST_NODE))) {
+ pickupType = CSSRegionContexts.CSS_LBRACE;
+ }
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, pickupType);
+ }
+ // extract source
+ if (child != null && child.getNodeType() == ICSSNode.MEDIALIST_NODE && ((MediaList) child).getLength() > 0) { // between
+ // "@media" and mediatype
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ appendSpaceBefore(node, toAppend, source);
+ } else if (child != null && (child.getPreviousSibling() == null || child.getPreviousSibling().getNodeType() == ICSSNode.MEDIALIST_NODE)) { // between
+ // mediatype and the first style rule
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ appendDelimBefore(node, null, source);
+ } else { // between styles
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ appendDelimBefore(node, null, source);
+ }
+ } else { // source generation
+ if (child == null && prev != null && prev.getNodeType() != ICSSNode.MEDIALIST_NODE) { // after
+ // the last style rule
+ appendDelimBefore(node.getParentNode(), null, source);
+ } else if (child != null && child.getNodeType() == ICSSNode.MEDIALIST_NODE && ((MediaList) child).getLength() > 0) { // between
+ // "@media" and mediatype
+ appendSpaceBefore(node, toAppend, source);
+ } else if (prev != null && prev.getNodeType() == ICSSNode.MEDIALIST_NODE && ((MediaList) prev).getLength() > 0) { // between
+ // mediatype and the first style rule
+ appendSpaceBefore(node, "{", source);//$NON-NLS-1$
+ source.append("{");//$NON-NLS-1$
+ if (child != null)
+ appendDelimBefore(node, null, source);
+ else
+ appendDelimBefore(node.getParentNode(), null, source);
+ } else { // normal case
+ appendDelimBefore(node, null, source);
+ }
+ }
+
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ if (child != null && child.getNodeType() == ICSSNode.MEDIALIST_NODE) { // between
+ // "@media" and mediatype
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ if (needS(outside[1]) && ((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength()) {
+ appendSpaceBefore(node, toAppend, source);
+ }
+ } else if (child != null && (child.getPreviousSibling() == null || child.getPreviousSibling().getNodeType() == ICSSNode.MEDIALIST_NODE)) { // between
+ // mediatype and the first style rule
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ if (needS(outside[1]) && ((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength()) {
+ appendDelimBefore(node, null, source);
+ }
+ } else { // between styles
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ if (needS(outside[1]) && ((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength()) {
+ appendDelimBefore(node, null, source);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) { // source formatting
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ if (node.getLastChild() == null || node.getLastChild().getNodeType() != ICSSNode.MEDIALIST_NODE) {
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ } else {
+ boolean bInCurlyBrace = false;
+ for (int i = 0; i < regions.length; i++) {
+ if (!bInCurlyBrace)
+ appendSpaceBefore(node, regions[i], source);
+ else
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ if (regions[i].getType() == CSSRegionContexts.CSS_LBRACE)
+ bInCurlyBrace = true;
+ }
+ }
+ } else { // source generation
+ String delim = getLineDelimiter(node);
+ if (node.getLastChild() != null && node.getLastChild().getNodeType() == ICSSNode.MEDIALIST_NODE) {
+ appendSpaceBefore(node, "{", source);//$NON-NLS-1$
+ source.append("{");//$NON-NLS-1$
+ }
+
+ source.append(delim);
+ source.append(getIndent(node));
+ source.append("}");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+ ICSSNode child = node.getFirstChild();
+ if (child != null && (child instanceof MediaList) && ((MediaList) child).getLength() == 0) {
+ if (child.getNextSibling() != null)
+ end = ((IndexedRegion) child.getNextSibling()).getStartOffset();
+ else
+ end = -1;
+ }
+
+ if (end > 0) { // source formatting
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ } else { // source generation
+ String str = MEDIA;
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ str = MEDIA.toUpperCase();
+ source.append(str);
+ }
+
+ if (child != null && (child instanceof MediaList) && ((MediaList) child).getLength() > 0) {
+ appendSpaceBefore(node, "", source);//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode.getRegionAtCharacterOffset(n - 1).getType() == CSSRegionContexts.CSS_LBRACE)
+ return n - 1;
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static MediaRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new MediaRuleFormatter();
+ return instance;
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatAfter(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos <= 0 || !nnode.contains(insertPos - 1))
+ return 0;
+
+ if (node.getFirstChild().getNextSibling() == node.getLastChild()) { // inserted
+ // first style rule
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(insertPos);
+ if (flatNode == null)
+ return 0;
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(insertPos);
+ if (region == null)
+ return 0;
+ RegionIterator it = new RegionIterator(flatNode, region);
+ while (it.hasNext()) {
+ region = it.next();
+ if (region.getType() == CSSRegionContexts.CSS_LBRACE)
+ break;
+ if (nnode.getEndOffset() <= it.getStructuredDocumentRegion().getEndOffset(region))
+ break;
+ }
+ int pos = it.getStructuredDocumentRegion().getStartOffset(region) - insertPos;
+ return (pos >= 0) ? pos : 0;
+
+ }
+ return super.getLengthToReformatAfter(node, insertPos);
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatBefore(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos <= 0 || !nnode.contains(insertPos - 1))
+ return 0;
+
+ if (node.getFirstChild().getNextSibling() == node.getLastChild()) { // inserted
+ // first style rule
+ int pos = ((IndexedRegion) node.getFirstChild()).getEndOffset();
+ if (pos <= 0)
+ pos = ((IndexedRegion) node).getStartOffset() + 6 /*
+ * length
+ * of
+ * "@media"
+ */;
+ return insertPos - pos;
+ }
+ return super.getLengthToReformatBefore(node, insertPos);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PageRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PageRuleFormatter.java
new file mode 100644
index 0000000..fa1f7a3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PageRuleFormatter.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPageRule;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class PageRuleFormatter extends DeclContainerFormatter {
+
+ public final static java.lang.String PAGE = "@page";//$NON-NLS-1$
+ private static PageRuleFormatter instance;
+
+ /**
+ *
+ */
+ PageRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ if (!ICSSPageRule.SELECTOR.equalsIgnoreCase(attr.getName()))
+ return buf;
+
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getEndOffset() - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.next();
+ if (it.hasNext()) {
+ ITextRegion next = it.next();
+ if (next.getType() == CSSRegionContexts.CSS_S)
+ context.end = it.getStructuredDocumentRegion().getEndOffset(next);
+ else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ }
+ else {
+ int pos = getAttrInsertPos(node, attr.getName());
+ context.start = pos;
+ context.end = pos;
+ /*
+ * IStructuredDocumentRegion flatNode =
+ * node.getOwnerDocument().getModel().getStructuredDocument().getNodeAtCharacterOffset(((IndexedRegion)node).getStartOffset());
+ * ITextRegion region =
+ * flatNode.getRegionAtCharacterOffset(((IndexedRegion)node).getStartOffset());
+ * if (region.getType() == CSSRegionContexts.S) {
+ * context.start = region.getStartOffset(); context.end =
+ * region.getEndOffset(); } else { context.start =
+ * flatNode.getEndOffset() + 1; context.end =
+ * flatNode.getEndOffset(); }
+ */}
+ }
+ // generate text
+ if (insert) {
+ String val = attr.getValue();
+ if (val != null && val.length() > 0) {
+ buf.append(val);
+ appendSpaceBefore(node, "", buf);//$NON-NLS-1$
+ }
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBetween(node, regions[i - 1], regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ }
+ else { // generate source
+ String str = PAGE;
+ if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ str = PAGE.toUpperCase();
+ source.append(str);
+ str = ((ICSSPageRule) node).getSelectorText();
+ if (str != null && str.length() > 0) {
+ appendSpaceBefore(node, str, source);
+ source.append(str);
+ }
+ appendSpaceBefore(node, "{", source);//$NON-NLS-1$
+ source.append("{");//$NON-NLS-1$
+ }
+ appendDelimBefore(node, null, source);
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBetween(node, (i == 0) ? outside[0] : regions[i - 1], regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ if (needS(outside[1])) {
+ if (isIncludesPreEnd(node, region))
+ appendDelimBefore(node, null, source);
+ else
+ appendSpaceBetween(node, regions[regions.length - 1], outside[1], source);
+ }
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ if (!ICSSPageRule.SELECTOR.equalsIgnoreCase(attrName))
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICSSPageRule.SELECTOR);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ else if (((IndexedRegion) node).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getStartOffset());
+ RegionIterator it = new RegionIterator(flatNode, region);
+ while (it.hasNext()) {
+ region = it.next();
+ if (region.getType() == CSSRegionContexts.CSS_LBRACE) {
+ return it.getStructuredDocumentRegion().getStartOffset(region);
+ }
+ if (it.getStructuredDocumentRegion().getEndOffset(region) >= ((IndexedRegion) node).getEndOffset())
+ break;
+ }
+ }
+ return ((IndexedRegion) node).getStartOffset();
+ }
+
+ /**
+ *
+ */
+ public synchronized static PageRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new PageRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PrimitiveValueFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PrimitiveValueFormatter.java
new file mode 100644
index 0000000..b215c9d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/PrimitiveValueFormatter.java
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.w3c.dom.css.CSSPrimitiveValue;
+
+
+/**
+ *
+ */
+public class PrimitiveValueFormatter extends DefaultCSSSourceFormatter {
+
+ private static PrimitiveValueFormatter instance;
+
+ /**
+ *
+ */
+ PrimitiveValueFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ boolean appendQuote = regions.length > 1 && node.getParentNode() instanceof ICSSStyleDeclItem && isCleanup() && getCleanupStrategy(node).isQuoteValues() && (((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_FONT) || ((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_FONT_FAMILY) || ((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_VOICE_FAMILY));
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+
+ StringBuffer strBuf = new StringBuffer();
+ boolean skipSpace = false;
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 && !skipSpace)
+ appendSpaceBefore(node, regions[i], strBuf);
+ skipSpace = false;
+ strBuf.append(decoratedPropValueRegion(regions[i], stgy));
+ if (regions[i].getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION)
+ skipSpace = true;
+ }
+
+ if (appendQuote) {
+ source.append(quote);
+ String str = strBuf.toString();
+ str = str.replace('\'', ' ');
+ str = str.replace('\"', ' ');
+ str = str.trim();
+ source.append(str);
+ source.append(quote);
+ }
+ else {
+ source.append(strBuf);
+ }
+ }
+ else { // generate source
+ ICSSPrimitiveValue value = (ICSSPrimitiveValue) node;
+ short type = value.getPrimitiveType();
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+
+ String str = null;
+ switch (type) {
+ case CSSPrimitiveValue.CSS_NUMBER :
+ case CSSPrimitiveValue.CSS_PERCENTAGE :
+ case CSSPrimitiveValue.CSS_EMS :
+ case CSSPrimitiveValue.CSS_EXS :
+ case CSSPrimitiveValue.CSS_PX :
+ case CSSPrimitiveValue.CSS_CM :
+ case CSSPrimitiveValue.CSS_MM :
+ case CSSPrimitiveValue.CSS_IN :
+ case CSSPrimitiveValue.CSS_PT :
+ case CSSPrimitiveValue.CSS_PC :
+ case CSSPrimitiveValue.CSS_DEG :
+ case CSSPrimitiveValue.CSS_RAD :
+ case CSSPrimitiveValue.CSS_GRAD :
+ case CSSPrimitiveValue.CSS_MS :
+ case CSSPrimitiveValue.CSS_S :
+ case CSSPrimitiveValue.CSS_HZ :
+ case CSSPrimitiveValue.CSS_KHZ :
+ case CSSPrimitiveValue.CSS_DIMENSION :
+ case ICSSPrimitiveValue.CSS_INTEGER :
+ if (value.getFloatValue(type) == ((int) value.getFloatValue(type))) {
+ str = Integer.toString((int) value.getFloatValue(type));
+ }
+ else {
+ str = Float.toString(value.getFloatValue(type));
+ }
+ break;
+ case CSSPrimitiveValue.CSS_IDENT :
+ case ICSSPrimitiveValue.CSS_HASH :
+ case ICSSPrimitiveValue.CSS_INHERIT_PRIMITIVE :
+ str = value.getStringValue();
+ if (str != null) {
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ str = str.toUpperCase();
+ else
+ str.toLowerCase();
+ }
+ break;
+ case CSSPrimitiveValue.CSS_STRING :
+ case CSSPrimitiveValue.CSS_URI :
+ case CSSPrimitiveValue.CSS_ATTR :
+ case ICSSPrimitiveValue.CSS_URANGE :
+ case ICSSPrimitiveValue.CSS_FORMAT :
+ case ICSSPrimitiveValue.CSS_LOCAL :
+ case ICSSPrimitiveValue.CSS_COMMA :
+ case ICSSPrimitiveValue.CSS_SLASH :
+ str = value.getStringValue();
+ }
+
+ String preStr = null, postStr = null;
+ switch (type) {
+ case CSSPrimitiveValue.CSS_ATTR :
+ preStr = "attr(";//$NON-NLS-1$
+ postStr = ")";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_CM :
+ postStr = "cm";//$NON-NLS-1$
+ break;
+ // case ICSSPrimitiveValue.CSS_COUNTER:
+ case CSSPrimitiveValue.CSS_DEG :
+ postStr = "deg";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_EMS :
+ postStr = "em";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_EXS :
+ postStr = "ex";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_GRAD :
+ postStr = "grad";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_HZ :
+ postStr = "Hz";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_IN :
+ postStr = "in";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_KHZ :
+ postStr = "kHz";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_MM :
+ postStr = "mm";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_MS :
+ postStr = "ms";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_PC :
+ postStr = "pc";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_PERCENTAGE :
+ postStr = "%";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_PT :
+ postStr = "pt";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_PX :
+ postStr = "px";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_RAD :
+ postStr = "rad";//$NON-NLS-1$
+ break;
+ // case ICSSPrimitiveValue.CSS_RECT:
+ // case ICSSPrimitiveValue.CSS_RGBCOLOR:
+ case CSSPrimitiveValue.CSS_S :
+ postStr = "s";//$NON-NLS-1$
+ break;
+ case CSSPrimitiveValue.CSS_STRING :
+ quote = CSSUtil.detectQuote(str, quote);
+ preStr = quote;
+ postStr = quote;
+ break;
+ case CSSPrimitiveValue.CSS_URI :
+ quote = CSSUtil.detectQuote(str, quote);
+ preStr = "url(" + quote;//$NON-NLS-1$
+ postStr = quote + ")";//$NON-NLS-1$
+ break;
+ // the followings are original primitive values
+ case CSSPrimitiveValue.CSS_IDENT :
+ case CSSPrimitiveValue.CSS_UNKNOWN :
+ // use str
+ case ICSSPrimitiveValue.CSS_INTEGER :
+ case ICSSPrimitiveValue.CSS_HASH :
+ case ICSSPrimitiveValue.CSS_SLASH :
+ case ICSSPrimitiveValue.CSS_COMMA :
+ case CSSPrimitiveValue.CSS_DIMENSION :
+ case CSSPrimitiveValue.CSS_NUMBER :
+ case ICSSPrimitiveValue.CSS_INHERIT_PRIMITIVE :
+ break;
+ case ICSSPrimitiveValue.CSS_URANGE :
+ preStr = "U+";//$NON-NLS-1$
+ break;
+ case ICSSPrimitiveValue.CSS_FORMAT :
+ quote = CSSUtil.detectQuote(str, quote);
+ preStr = "format(" + quote;//$NON-NLS-1$
+ postStr = quote + ")";//$NON-NLS-1$
+ break;
+ case ICSSPrimitiveValue.CSS_LOCAL :
+ quote = CSSUtil.detectQuote(str, quote);
+ preStr = "local(" + quote;//$NON-NLS-1$
+ postStr = quote + ")";//$NON-NLS-1$
+ break;
+ }
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER) {
+ if (preStr != null)
+ preStr = preStr.toUpperCase();
+ if (postStr != null)
+ postStr = postStr.toUpperCase();
+ }
+ if (preStr != null)
+ source.append(preStr);
+ if (str != null)
+ source.append(str);
+ if (postStr != null)
+ source.append(postStr);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public synchronized static PrimitiveValueFormatter getInstance() {
+ if (instance == null)
+ instance = new PrimitiveValueFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RGBFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RGBFormatter.java
new file mode 100644
index 0000000..a6909db
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RGBFormatter.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+/**
+ *
+ */
+public class RGBFormatter extends FunctionFormatter {
+
+ private static RGBFormatter instance;
+
+ /**
+ *
+ */
+ RGBFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected String getFunc() {
+ return "rgb(";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ public synchronized static RGBFormatter getInstance() {
+ if (instance == null)
+ instance = new RGBFormatter();
+ return instance;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RectFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RectFormatter.java
new file mode 100644
index 0000000..f3ec832
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/RectFormatter.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+/**
+ *
+ */
+public class RectFormatter extends FunctionFormatter {
+
+ private static RectFormatter instance;
+
+ /**
+ *
+ */
+ RectFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected String getFunc() {
+ return "rect(";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ public synchronized static RectFormatter getInstance() {
+ if (instance == null)
+ instance = new RectFormatter();
+ return instance;
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclItemFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclItemFormatter.java
new file mode 100644
index 0000000..167c6f0
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclItemFormatter.java
@@ -0,0 +1,406 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class StyleDeclItemFormatter extends DefaultCSSSourceFormatter {
+
+ private static StyleDeclItemFormatter instance;
+
+ /**
+ *
+ */
+ StyleDeclItemFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ private void appendAfterColonSpace(ICSSNode node, StringBuffer source) {
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ int n = preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM);
+
+ if (preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) {
+ int length = getLastLineLength(node, source);
+ int append = getFirstChildRegionLength(node);
+ if (length + n + append > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) {
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ source.append(getIndentString());
+ n = 0; // no space is necessary
+ }
+ }
+ // no delimiter case
+ while (n-- > 0)
+ source.append(" ");//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ private int getFirstChildRegionLength(ICSSNode node) {
+ ICSSNode firstChild = node.getFirstChild();
+ if (firstChild == null)
+ return 1;
+ int start = ((IndexedRegion) firstChild).getStartOffset();
+ RegionIterator itr = new RegionIterator(node.getOwnerDocument().getModel().getStructuredDocument(), start);
+ while (itr.hasNext()) {
+ ITextRegion reg = itr.next();
+ if (reg != null && reg.getType() != CSSRegionContexts.CSS_S)
+ return reg.getTextLength();
+ }
+ return 1;
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ if (!ICSSStyleDeclItem.IMPORTANT.equalsIgnoreCase(attr.getName()))
+ return buf;
+
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getStartOffset());
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.prev();
+ if (it.hasPrev()) {
+ ITextRegion prev = it.prev();
+ if (prev.getType() == CSSRegionContexts.CSS_S)
+ context.start = it.getStructuredDocumentRegion().getStartOffset(prev);
+ else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ } else
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ } else {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getEndOffset() - 1);
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ context.start = flatNode.getStartOffset(region);
+ context.end = flatNode.getEndOffset(region);
+ } else {
+ context.start = flatNode.getEndOffset();
+ context.end = flatNode.getEndOffset();
+ }
+ }
+ }
+ // generate text
+ if (insert && attr.getValue() != null && attr.getValue().length() > 0) {
+ appendSpaceBefore(node, attr.getValue(), buf);
+ buf.append(attr.getValue());
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+ if (start > 0 && start < end) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, null);
+ }
+ // generate source
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy)); // must
+ // be
+ // comments
+ }
+ }
+ if(child != null) {
+ boolean append = true;
+ if (child instanceof ICSSPrimitiveValue) {
+ if (((ICSSPrimitiveValue) child).getPrimitiveType() == ICSSPrimitiveValue.CSS_COMMA)
+ toAppend = ",";//$NON-NLS-1$
+ else if (((ICSSPrimitiveValue) child).getPrimitiveType() == ICSSPrimitiveValue.CSS_SLASH)
+ toAppend = "/";//$NON-NLS-1$
+ ICSSNode prevSibling = child.getPreviousSibling();
+ if (prevSibling instanceof ICSSPrimitiveValue && ((ICSSPrimitiveValue)prevSibling).getPrimitiveType() == ICSSPrimitiveValue.CSS_SLASH)
+ append = false;
+ }
+ if (toAppend != null && !toAppend.equals(",") && !toAppend.equals("/") && append) {//$NON-NLS-1$ //$NON-NLS-2$
+ appendSpaceBefore(node, toAppend, source);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 2, stgy)); // must be
+ // comments
+ }
+ if (needS(outside[1])) {
+ if (((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength()) {
+ if (toAppend != "," && toAppend != "/") //$NON-NLS-1$ //$NON-NLS-2$
+ appendSpaceBefore(node, toAppend, source);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ } else { // generate source
+ // append "!important"
+ String priority = ((ICSSStyleDeclItem) node).getPriority();
+ if (priority != null && priority.length() > 0) {
+ appendSpaceBefore(node, priority, source);
+ source.append(priority);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedIdentRegion(regions[i], stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (end > 0) { // format source
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropNameRegion(regions[i], stgy));
+ }
+ } else { // generatoe source
+ ICSSStyleDeclItem item = (ICSSStyleDeclItem) node;
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER)
+ source.append(item.getPropertyName().toUpperCase());
+ else
+ source.append(item.getPropertyName());
+
+ int k = preferences.getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM);
+ if (preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) {
+ int length = getLastLineLength(node, source);
+ int append = 1;
+ if (length + k + append > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) {
+ source.append(getLineDelimiter(node));
+ source.append(getIndent(node));
+ source.append(getIndentString());
+ k = 0; // no space is necessary
+ }
+ }
+ // no delimiter case
+ while (k-- > 0)
+ source.append(" ");//$NON-NLS-1$
+ source.append(":");//$NON-NLS-1$
+ }
+ if (!isCleanup() || getCleanupStrategy(node).isFormatSource()) {
+ appendAfterColonSpace(node, source);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropNameRegion(regions[i], stgy));
+ }
+ if (needS(outside[1])) {
+ if (isIncludesPreEnd(node, region) && (!isCleanup() || getCleanupStrategy(node).isFormatSource())) {
+ appendAfterColonSpace(node, source);
+ } else
+ appendSpaceBefore(node, outside[1], source);
+ }
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatValue(ICSSNode node) {
+ StringBuffer source = new StringBuffer();
+ formatChildren(node, source);
+
+ return source;
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ if (!ICSSStyleDeclItem.IMPORTANT.equalsIgnoreCase(attrName))
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICSSStyleDeclItem.IMPORTANT);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (iNode.getEndOffset() <= 0)
+ return -1;
+
+ CompoundRegion regions[] = getRegionsWithoutWhiteSpaces(node.getOwnerDocument().getModel().getStructuredDocument(), new FormatRegion(iNode.getStartOffset(), iNode.getEndOffset() - iNode.getStartOffset()), getCleanupStrategy(node));
+ for (int i = regions.length - 1; i >= 0; i--) {
+ if (regions[i].getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT)
+ return regions[i].getStartOffset();
+ }
+ return iNode.getEndOffset();
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n < 0) {
+ return -1;
+ }
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ if (flatNode != null && flatNode.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER) {
+ n -= flatNode.getLength();
+ }
+ if (n > 0) {
+ String important = ((ICSSStyleDeclItem) node).getPriority();
+ if (important != null && important.length() > 0) {
+ // find before "!important" position
+ flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ RegionIterator it = new RegionIterator(flatNode, flatNode.getRegionAtCharacterOffset(n - 1));
+ while (it.hasPrev()) {
+ ITextRegion region = it.prev();
+ if (it.getStructuredDocumentRegion() != flatNode)
+ break;
+ if (region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT)
+ return it.getStructuredDocumentRegion().getStartOffset(region);
+ }
+ }
+ // skip last space
+ flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(n - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(n - 1);
+ if (region != null) {
+ n -= region.getLength() - region.getTextLength();
+ }
+
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static StyleDeclItemFormatter getInstance() {
+ if (instance == null)
+ instance = new StyleDeclItemFormatter();
+ return instance;
+ }
+
+ private String getIndentString() {
+ StringBuffer indent = new StringBuffer();
+
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (preferences != null) {
+ char indentChar = ' ';
+ String indentCharPref = preferences.getString(CSSCorePreferenceNames.INDENTATION_CHAR);
+ if (CSSCorePreferenceNames.TAB.equals(indentCharPref)) {
+ indentChar = '\t';
+ }
+ int indentationWidth = preferences.getInt(CSSCorePreferenceNames.INDENTATION_SIZE);
+
+ for (int i = 0; i < indentationWidth; i++) {
+ indent.append(indentChar);
+ }
+ }
+ return indent.toString();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java
new file mode 100644
index 0000000..56c9287
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+/**
+ *
+ */
+public class StyleDeclarationFormatter extends DefaultCSSSourceFormatter {
+
+ private static StyleDeclarationFormatter instance;
+
+ /**
+ *
+ */
+ StyleDeclarationFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+
+ // check no child
+ if (child == null && prev == null)
+ return;
+
+ if (start > 0 && start < end) { // format source
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration with no
+ // model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ String pickupType = CSSRegionContexts.CSS_DECLARATION_DELIMITER;
+ if (prev == null || child == null)
+ pickupType = null;
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, pickupType);
+ }
+ // extract source
+ for (int i = 0; i < regions.length; i++) {
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be comments
+ }
+ }
+ }
+ } else if (prev != null && child != null) { // generate source :
+ // between two declarations
+ // BUG93037-properties view adds extra ; when add new property
+ boolean semicolonFound = false;
+
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration with no
+ // model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ int prevStart = (prev != null) ? ((IndexedRegion) prev).getStartOffset() : 0;
+ int prevEnd = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(prevStart, prevEnd - prevStart), stgy);
+ int i = regions.length - 1;
+ while (i >= 0 && !semicolonFound) {
+ if (regions[i].getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ semicolonFound = true;
+ --i;
+ }
+ }
+ }
+ if (!semicolonFound)
+ source.append(";");//$NON-NLS-1$
+ } else if (prev == null) { // generate source : before the first
+ // declaration
+ org.eclipse.wst.css.core.internal.util.RegionIterator it = null;
+ if (end > 0) {
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration with
+ // no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ it = new org.eclipse.wst.css.core.internal.util.RegionIterator(structuredDocument, end - 1);
+ }
+ }
+ } else {
+ int pos = getChildInsertPos(node);
+ if (pos >= 0) {
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration
+ // with no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ it = new org.eclipse.wst.css.core.internal.util.RegionIterator(structuredDocument, pos - 1);
+ }
+ }
+ }
+ }
+ if (it != null) {
+ int limit = ((IndexedRegion) ((node.getParentNode() != null) ? node.getParentNode() : node)).getStartOffset();
+ while (it.hasPrev()) {
+ ITextRegion curReg = it.prev();
+ if (curReg.getType() == CSSRegionContexts.CSS_LBRACE || curReg.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ break;
+ if (curReg.getType() != CSSRegionContexts.CSS_S && curReg.getType() != CSSRegionContexts.CSS_COMMENT) {
+ source.append(";");//$NON-NLS-1$
+ break;
+ }
+ if (it.getStructuredDocumentRegion().getStartOffset(curReg) <= limit)
+ break;
+ }
+ }
+ } else if (child == null) { // generate source : after the last
+ // declaration
+ org.eclipse.wst.css.core.internal.util.RegionIterator it = null;
+ if (start > 0) {
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration with
+ // no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ it = new org.eclipse.wst.css.core.internal.util.RegionIterator(structuredDocument, start);
+ }
+ }
+ } else {
+ int pos = getChildInsertPos(node);
+ if (pos >= 0) {
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration
+ // with no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ it = new org.eclipse.wst.css.core.internal.util.RegionIterator(structuredDocument, pos);
+ }
+ }
+ }
+ }
+ if (it != null) {
+ int limit = ((IndexedRegion) ((node.getParentNode() != null) ? node.getParentNode() : node)).getEndOffset();
+ while (it.hasNext()) {
+ ITextRegion curReg = it.next();
+ if (curReg.getType() == CSSRegionContexts.CSS_RBRACE || curReg.getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ break;
+ if (curReg.getType() != CSSRegionContexts.CSS_S && curReg.getType() != CSSRegionContexts.CSS_COMMENT) {
+ // Bug 219004 - Before appending a ;, make sure that there
+ // isn't one already
+ boolean semicolonFound = false;
+ while(it.hasNext() && !semicolonFound) {
+ if(it.next().getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ semicolonFound = true;
+ }
+
+ if(!semicolonFound)
+ source.append(";");//$NON-NLS-1$
+ break;
+ }
+ if (limit <= it.getStructuredDocumentRegion().getEndOffset(curReg))
+ break;
+ }
+ }
+ }
+ if (child == null) {
+ if (((IndexedRegion) node).getEndOffset() <= 0) {
+ // get next region
+ int pos = getChildInsertPos(node);
+ CompoundRegion toAppendRegion = null;
+ if (pos >= 0) {
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration
+ // with no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ IStructuredDocumentRegion flatNode = structuredDocument.getRegionAtCharacterOffset(pos);
+ toAppendRegion = new CompoundRegion(flatNode, flatNode.getRegionAtCharacterOffset(pos));
+ }
+ }
+ }
+ appendDelimBefore(node.getParentNode(), toAppendRegion, source);
+ }
+ } else if ((prev != null || ((IndexedRegion) node).getEndOffset() <= 0)) {
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ if (preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE) && (node.getOwnerDocument() != node || !preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR)))
+ appendDelimBefore(node, null, source);
+ else if (prev != null || node.getOwnerDocument() != node)
+ appendSpaceBefore(node, toAppend, source);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ ICSSModel cssModel = node.getOwnerDocument().getModel();
+ // BUG202615 - it is possible to have a style declaration
+ // with no model associated with it
+ if (cssModel != null) {
+ IStructuredDocument structuredDocument = cssModel.getStructuredDocument();
+ if (structuredDocument != null) {
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be
+ // comments
+ }
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+ if (needS(outside[1])) {
+ if (((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength() && preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE) && (node.getOwnerDocument() != node || !preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR))) {
+ appendDelimBefore(node, null, source);
+ } else
+ appendSpaceBefore(node, toAppend, source);
+ }
+ }
+ }
+ }
+
+ /**
+ * Insert the method's description here.
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ if (node == null)
+ return -1;
+ int pos = super.getChildInsertPos(node);
+ if (pos < 0) {
+ CSSSourceGenerator formatter = getParentFormatter(node);
+ return (formatter != null) ? formatter.getChildInsertPos(node.getParentNode()) : -1;
+ }
+ return pos;
+ }
+
+ /**
+ *
+ */
+ public synchronized static StyleDeclarationFormatter getInstance() {
+ if (instance == null)
+ instance = new StyleDeclarationFormatter();
+ return instance;
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatAfter(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos < 0 || !nnode.contains(insertPos)) {
+ if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
+ CSSSourceGenerator pntFormatter = getParentFormatter(node);
+ if (pntFormatter != null)
+ return pntFormatter.getLengthToReformatAfter(node.getParentNode(), insertPos);
+ }
+ return 0;
+ }
+ return super.getLengthToReformatAfter(node, insertPos);
+ }
+
+ /**
+ *
+ * @return int
+ * @param node
+ * org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param insertPos
+ * int
+ */
+ public int getLengthToReformatBefore(ICSSNode node, int insertPos) {
+ if (node == null)
+ return 0;
+ IndexedRegion nnode = (IndexedRegion) node;
+ if (insertPos <= 0 || !nnode.contains(insertPos - 1)) {
+ if (node.getParentNode() != null && nnode.getEndOffset() <= 0) {
+ CSSSourceGenerator pntFormatter = getParentFormatter(node);
+ if (pntFormatter != null)
+ return pntFormatter.getLengthToReformatBefore(node.getParentNode(), insertPos);
+ }
+ return 0;
+ }
+ return super.getLengthToReformatBefore(node, insertPos);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleRuleFormatter.java
new file mode 100644
index 0000000..fca98b4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleRuleFormatter.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class StyleRuleFormatter extends DeclContainerFormatter {
+
+ private static StyleRuleFormatter instance;
+
+ /**
+ *
+ */
+ StyleRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public StringBuffer formatAttrChanged(ICSSNode node, ICSSAttr attr, boolean insert, AttrChangeContext context) {
+ StringBuffer buf = new StringBuffer();
+ if (node == null || attr == null)
+ return buf;
+
+ if (!ICSSStyleRule.SELECTOR.equalsIgnoreCase(attr.getName()))
+ return buf;
+
+ // get region to replace
+ if (context != null && ((IndexedRegion) node).getEndOffset() > 0) {
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0) {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) attr).getEndOffset() - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) attr).getEndOffset() - 1);
+ RegionIterator it = new RegionIterator(flatNode, region);
+ it.next();
+ if (it.hasNext()) {
+ ITextRegion next = it.next();
+ if (next.getType() == CSSRegionContexts.CSS_S)
+ context.end = it.getStructuredDocumentRegion().getEndOffset(next);
+ else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ }
+ else
+ context.end = it.getStructuredDocumentRegion().getEndOffset(region);
+ context.start = it.getStructuredDocumentRegion().getStartOffset(region);
+ }
+ else {
+ IStructuredDocumentRegion flatNode = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(((IndexedRegion) node).getStartOffset());
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(((IndexedRegion) node).getStartOffset());
+ if (region.getType() == CSSRegionContexts.CSS_S) {
+ context.start = flatNode.getStartOffset(region);
+ context.end = flatNode.getEndOffset(region);
+ }
+ else {
+ context.start = flatNode.getEndOffset();
+ context.end = flatNode.getEndOffset();
+ }
+ }
+ }
+ // generate text
+ if (insert) {
+ buf.append(attr.getValue());
+ appendSpaceBefore(node, "", buf);//$NON-NLS-1$
+ }
+ return buf;
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBetween(node, regions[i - 1], regions[i], source);
+ source.append(decoratedSelectorRegion(regions[i], (i != 0) ? regions[i - 1] : null, stgy));
+ }
+ }
+ else { // generate source
+ String str = ((ICSSStyleRule) node).getSelectorText();
+ // appendSpaceBefore(node,str,source);
+ source.append(str);
+ appendSpaceBefore(node, "{", source);//$NON-NLS-1$
+ source.append("{");//$NON-NLS-1$
+ }
+ appendDelimBefore(node, null, source);
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBetween(node, (i == 0) ? outside[0] : regions[i - 1], regions[i], source);
+ source.append(decoratedSelectorRegion(regions[i], (i != 0) ? regions[i - 1] : null, stgy));
+ }
+ if (needS(outside[1])) {
+ if (isIncludesPreEnd(node, region))
+ appendDelimBefore(node, null, source);
+ else
+ appendSpaceBetween(node, regions[regions.length - 1], outside[1], source);
+ }
+ }
+
+ /**
+ *
+ */
+ public int getAttrInsertPos(ICSSNode node, String attrName) {
+ if (node == null || attrName == null || attrName.length() == 0)
+ return -1;
+
+ if (!ICSSStyleRule.SELECTOR.equalsIgnoreCase(attrName))
+ return -1;
+
+ ICSSAttr attr = (ICSSAttr) node.getAttributes().getNamedItem(ICSSStyleRule.SELECTOR);
+ if (attr != null && ((IndexedRegion) attr).getEndOffset() > 0)
+ return ((IndexedRegion) attr).getStartOffset();
+ else
+ return ((IndexedRegion) node).getStartOffset();
+ }
+
+ /**
+ *
+ */
+ public synchronized static StyleRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new StyleRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleSheetFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleSheetFormatter.java
new file mode 100644
index 0000000..35681d5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleSheetFormatter.java
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ *
+ */
+public class StyleSheetFormatter extends AbstractCSSSourceFormatter {
+
+ private static StyleSheetFormatter instance;
+
+ /**
+ *
+ */
+ StyleSheetFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, String toAppend, StringBuffer source, IRegion exceptFor) {
+ String delim = getLineDelimiter(node);
+ ICSSNode prev = (child != null) ? child.getPreviousSibling() : node.getLastChild();
+ if (prev == null && child == null)
+ return;
+ int start = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ int end = (child != null) ? ((IndexedRegion) child).getStartOffset() : 0;
+ if (start > 0 && start < end) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ // get meaning regions
+ CompoundRegion[] regions = null;
+ if (exceptFor == null)
+ regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ else {
+ String pickupType = CSSRegionContexts.CSS_DELIMITER;
+ if (prev == null)
+ pickupType = null;
+ regions = getRegions(structuredDocument, new FormatRegion(start, end - start), exceptFor, pickupType);
+ }
+ // generate source
+ if (prev != null) {
+ if (regions.length > 0 && !regions[0].getType().equals(CSSRegionContexts.CSS_COMMENT))
+ appendDelimBefore(node, regions[0], source);
+ else if (regions.length == 0) {
+ appendDelimBefore(node, null, source);
+ }
+ }
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must
+ // be
+ // comments
+ // or
+ // semi_colon
+ if (regions[i].getType() == CSSRegionContexts.CSS_DELIMITER) {
+ // append delim after
+ appendDelimBefore(node, null, source);
+ }
+ }
+ if (prev != null)
+ appendDelimBefore(node, null, source);
+ }
+ else if (prev != null && child != null) { // source generation :
+ // between two rules
+ source.append(delim);
+ source.append(delim);
+ }
+ else if (((IndexedRegion) node).getEndOffset() > 0) {
+ if (prev == null) { // source formatting : before the first rule
+ ICSSNode next = child.getNextSibling();
+ int pos = getChildInsertPos(node);
+ if (next != null && ((IndexedRegion) next).getEndOffset() > 0)
+ pos = ((IndexedRegion) next).getStartOffset();
+ if (pos != 0) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] prevRegions = getRegions(structuredDocument, new FormatRegion(0, pos), null, null);
+ if (prevRegions != null && prevRegions.length > 0)
+ appendDelimBefore(node, null, source);
+ }
+ }
+ else if (child == null) { // source formatting : after the last
+ // rule
+ if (start > 0 && start <= ((IndexedRegion) node).getEndOffset()) {
+ appendDelimBefore(node, null, source);
+ }
+ else if (start <= 0) {
+ int pos = getChildInsertPos(node);
+ if (pos < ((IndexedRegion) node).getEndOffset()) {
+ appendDelimBefore(node, null, source);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatBefore(ICSSNode node, ICSSNode child, IRegion region, String toAppend, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy)); // must be
+ // comments
+ }
+ if (needS(outside[1])) {
+ if (((IndexedRegion) child).getStartOffset() == region.getOffset() + region.getLength())
+ appendDelimBefore(node, null, source);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, StringBuffer source) {
+ int end = ((IndexedRegion) node).getEndOffset();
+ int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node);
+ if (end > 0 && start < end) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ if ((regions != null && regions.length > 0 && regions[regions.length - 1].getType() == CSSRegionContexts.CSS_CDC) || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
+ appendDelimBefore(node, null, source);
+ }
+ else { // source generation
+ if (node.getOwnerDocument().getModel() != null && node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
+ appendDelimBefore(node, null, source);
+ return; // nothing
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPost(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode node, java.lang.StringBuffer source) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = (node.getFirstChild() != null && ((IndexedRegion) node.getFirstChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getFirstChild()).getStartOffset() : getChildInsertPos(node);
+ if (end > 0) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || regions[i].getType() == CSSRegionContexts.CSS_CDO || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ if (node.getLastChild() != null && (source.length() > 0 || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)) {
+ appendDelimBefore(node, null, source);
+ }
+ }
+ else if (node.getOwnerDocument().getModel() != null && node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
+ appendDelimBefore(node, null, source);
+ // source.append("<!--");
+ // appendDelimBefore(node,null, source);
+ }
+ else
+ return; // nothing
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, java.lang.StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]) || regions[i].getType() == CSSRegionContexts.CSS_CDO || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED)
+ appendDelimBefore(node, regions[i], source);
+ source.append(decoratedRegion(regions[i], 0, stgy));
+ }
+ if (needS(outside[1])) {
+ if (isIncludesPreEnd(node, region)) {
+ if (source.length() > 0 || node.getOwnerDocument().getModel().getStyleSheetType() == ICSSModel.EMBEDDED) {
+ String delim = getLineDelimiter(node);
+ source.append(delim);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public int getChildInsertPos(ICSSNode node) {
+ int n = ((IndexedRegion) node).getEndOffset();
+ if (n > 0) {
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ IStructuredDocumentRegion flatNode = structuredDocument.getRegionAtCharacterOffset(n - 1);
+ ITextRegion region = flatNode.getRegionAtCharacterOffset(n - 1);
+ RegionIterator it = new RegionIterator(flatNode, region);
+ while (it.hasPrev()) {
+ ITextRegion reg = it.prev();
+ if (reg.getType() == CSSRegionContexts.CSS_CDC)
+ return it.getStructuredDocumentRegion().getStartOffset(reg);
+ }
+ return n;
+ }
+ return -1;
+ }
+
+ /**
+ *
+ */
+ public synchronized static StyleSheetFormatter getInstance() {
+ if (instance == null)
+ instance = new StyleSheetFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/UnknownRuleFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/UnknownRuleFormatter.java
new file mode 100644
index 0000000..81abef8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/UnknownRuleFormatter.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.formatter;
+
+
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.w3c.dom.css.CSSUnknownRule;
+
+
+/**
+ *
+ */
+public class UnknownRuleFormatter extends DefaultCSSSourceFormatter {
+
+ private static UnknownRuleFormatter instance;
+
+ /**
+ *
+ */
+ UnknownRuleFormatter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ int start = ((IndexedRegion) node).getStartOffset();
+ int end = ((IndexedRegion) node).getEndOffset();
+ if (end > 0) { // format source
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0)
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ }
+ else { // generate source
+ CSSUnknownRule rule = (CSSUnknownRule) node;
+ source.append(rule.getCssText());
+ }
+ }
+
+ /**
+ *
+ */
+ protected void formatPre(ICSSNode node, IRegion region, StringBuffer source) {
+ CSSCleanupStrategy stgy = getCleanupStrategy(node);
+
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, region, stgy);
+ CompoundRegion[] outside = getOutsideRegions(structuredDocument, region);
+ for (int i = 0; i < regions.length; i++) {
+ if (i != 0 || needS(outside[0]))
+ appendSpaceBefore(node, regions[i], source);
+ source.append(decoratedPropValueRegion(regions[i], stgy));
+ }
+ if (needS(outside[1]) && !isIncludesPreEnd(node, region))
+ appendSpaceBefore(node, outside[1], source);
+ }
+
+ /**
+ *
+ */
+ public synchronized static UnknownRuleFormatter getInstance() {
+ if (instance == null)
+ instance = new UnknownRuleFormatter();
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCategory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCategory.java
new file mode 100644
index 0000000..12ac146
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCategory.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+public interface CSSMMCategory extends CSSMMNode {
+
+ String getCaption();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCharsetRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCharsetRule.java
new file mode 100644
index 0000000..d86d469
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMCharsetRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMCharsetRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMContainer.java
new file mode 100644
index 0000000..cedb5d5
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMContainer.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMContainer extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMDescriptor.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMDescriptor.java
new file mode 100644
index 0000000..8879792
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMDescriptor.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+import java.util.Iterator;
+
+public interface CSSMMDescriptor extends CSSMMNode {
+
+ Iterator getValues();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFontFaceRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFontFaceRule.java
new file mode 100644
index 0000000..0e8dff2
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFontFaceRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMFontFaceRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFunction.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFunction.java
new file mode 100644
index 0000000..9be706e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMFunction.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMFunction extends CSSMMNode {
+
+ String getFunctionString();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMImportRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMImportRule.java
new file mode 100644
index 0000000..c6bd2af
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMImportRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMImportRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMKeyword.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMKeyword.java
new file mode 100644
index 0000000..60837ff
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMKeyword.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMKeyword extends CSSMMNode {
+
+ String getKeywordString();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMMediaRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMMediaRule.java
new file mode 100644
index 0000000..e16b7d9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMMediaRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMMediaRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNode.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNode.java
new file mode 100644
index 0000000..c6a5866
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNode.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+import java.util.Iterator;
+
+public interface CSSMMNode {
+ String getType();
+
+ String getName();
+
+ String getDescription();
+
+ String getAttribute(String name);
+
+ Iterator getChildNodes();
+
+ Iterator getDescendants();
+
+
+ static final String _PREFIX = "CSSMM."; //$NON-NLS-1$
+ static final String TYPE_KEYWORD = _PREFIX + "Keyword"; //$NON-NLS-1$
+ static final String TYPE_UNIT = _PREFIX + "Unit"; //$NON-NLS-1$
+ static final String TYPE_FUNCTION = _PREFIX + "Function"; //$NON-NLS-1$
+ static final String TYPE_STRING = _PREFIX + "String"; //$NON-NLS-1$
+ static final String TYPE_STYLE_SHEET = _PREFIX + "StyleSheet"; //$NON-NLS-1$
+ static final String TYPE_PROPERTY = _PREFIX + "Property"; //$NON-NLS-1$
+ static final String TYPE_DESCRIPTOR = _PREFIX + "Descriptor"; //$NON-NLS-1$
+ static final String TYPE_CONTAINER = _PREFIX + "Container"; //$NON-NLS-1$
+ static final String TYPE_NUMBER = _PREFIX + "Number"; //$NON-NLS-1$
+ static final String TYPE_SEPARATOR = _PREFIX + "Separator"; //$NON-NLS-1$
+ static final String TYPE_CHARSET_RULE = _PREFIX + "CharsetRule"; //$NON-NLS-1$
+ static final String TYPE_IMPORT_RULE = _PREFIX + "ImportRule"; //$NON-NLS-1$
+ static final String TYPE_STYLE_RULE = _PREFIX + "StyleRule"; //$NON-NLS-1$
+ static final String TYPE_MEDIA_RULE = _PREFIX + "MediaRule"; //$NON-NLS-1$
+ static final String TYPE_PAGE_RULE = _PREFIX + "PageRule"; //$NON-NLS-1$
+ static final String TYPE_FONT_FACE_RULE = _PREFIX + "FontFaceRule"; //$NON-NLS-1$
+ static final String TYPE_CATEGORY = _PREFIX + "Category"; //$NON-NLS-1$
+ static final String TYPE_META_MODEL = _PREFIX + "MetaModel"; //$NON-NLS-1$
+ static final String TYPE_SELECTOR = _PREFIX + "Selector"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNumber.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNumber.java
new file mode 100644
index 0000000..d3c0f55
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMNumber.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMNumber extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMPageRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMPageRule.java
new file mode 100644
index 0000000..57a0845
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMPageRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMPageRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMProperty.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMProperty.java
new file mode 100644
index 0000000..c92f728
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMProperty.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+import java.util.Iterator;
+
+public interface CSSMMProperty extends CSSMMNode {
+
+ String getCategoryName();
+
+ Iterator getValues();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMSelector.java
new file mode 100644
index 0000000..543bbcc
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMSelector.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+public interface CSSMMSelector extends CSSMMNode {
+ String getSelectorType();
+
+ String getSelectorString();
+
+
+ static final String TYPE_EXPRESSION = "Expression"; //$NON-NLS-1$
+ static final String TYPE_PSEUDO_CLASS = "PseudoClass"; //$NON-NLS-1$
+ static final String TYPE_PSEUDO_ELEMENT = "PseudoElement"; //$NON-NLS-1$
+
+ // embedded expression type
+ static final String EXPRESSION_DESCENDANT = "descendant"; //$NON-NLS-1$
+ static final String EXPRESSION_CHILD = "child"; //$NON-NLS-1$
+ static final String EXPRESSION_ADJACENT = "adjacent"; //$NON-NLS-1$
+ static final String EXPRESSION_UNIVERSAL = "universal"; //$NON-NLS-1$
+ static final String EXPRESSION_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMString.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMString.java
new file mode 100644
index 0000000..6d8374d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMString.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMString extends CSSMMNode {
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleRule.java
new file mode 100644
index 0000000..1ad749b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleRule.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMStyleRule extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleSheet.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleSheet.java
new file mode 100644
index 0000000..3f8b2a3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMStyleSheet.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMStyleSheet extends CSSMMNode {
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMUnit.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMUnit.java
new file mode 100644
index 0000000..047d109
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMMUnit.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+public interface CSSMMUnit extends CSSMMNode {
+
+ String getUnitString();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMetaModel.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMetaModel.java
new file mode 100644
index 0000000..337048d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSMetaModel.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+import java.util.Iterator;
+
+public interface CSSMetaModel extends CSSMMNode {
+
+ // public interface CSSMetaModel {
+ CSSMMStyleSheet getStyleSheet();
+
+ /*
+ * Shortcut to access property node
+ */
+ // Iterator getProperties();
+ // Iterator getDescriptors();
+ // CSSMMProperty getProperty(String propertyName);
+ /*
+ * access to category information
+ */
+ Iterator getCategories();
+
+ /*
+ * Utilities
+ */
+ // Iterator collectNodesByType(String type);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfile.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfile.java
new file mode 100644
index 0000000..ebdc9fa
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfile.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+
+
+import java.net.URL;
+
+
+public interface CSSProfile {
+
+ String getProfileID();
+
+ String getProfileName();
+
+ URL getProfileURL();
+
+ CSSMetaModel getMetaModel();
+
+ boolean isDefault();
+
+ String getOwnerPluginID();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfileRegistry.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfileRegistry.java
new file mode 100644
index 0000000..4f261cb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/CSSProfileRegistry.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.css.core.internal.IProductConstants;
+import org.eclipse.wst.css.core.internal.metamodelimpl.RegistryReader;
+
+public class CSSProfileRegistry {
+
+ CSSProfile fDefault = null;
+
+ public synchronized static CSSProfileRegistry getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSProfileRegistry();
+ }
+ return fInstance;
+ }
+
+ static class ProfileNameComparator implements Comparator {
+ static Collator delegate = Collator.getInstance();
+
+ public int compare(Object o1, Object o2) {
+ if (o1 instanceof CSSProfile && o2 instanceof CSSProfile) {
+ if (((CSSProfile) o1).getProfileName() != null && ((CSSProfile) o2).getProfileName() != null) {
+ return delegate.compare(((CSSProfile) o1).getProfileName(), ((CSSProfile) o2).getProfileName());
+ }
+ }
+ return 0;
+ }
+ }
+
+ public Iterator getProfiles() {
+ List values = new ArrayList(fProfiles.values());
+ Collections.sort(values, new ProfileNameComparator());
+ return Collections.unmodifiableCollection(values).iterator();
+ }
+
+ public CSSProfile getProfile(String profileID) {
+ return (CSSProfile) fProfiles.get(profileID);
+ }
+
+ public CSSProfile getDefaultProfile() {
+ if (fDefault != null) {
+ return fDefault;
+ }
+
+ String id = Platform.getProduct().getProperty(IProductConstants.DEFAULT_PROFILE);
+
+ Iterator i = getProfiles();
+ CSSProfile firstDefault = null;
+ while (i.hasNext()) {
+ CSSProfile profile = (CSSProfile) i.next();
+ if (profile.isDefault()) {
+ if (id == null) { // Original scenario
+ fDefault = profile;
+ return profile;
+ }
+ else if (firstDefault == null) { // extension point used, flag the first default in case the id doesn't end up matching
+ firstDefault = profile;
+ }
+ }
+ if (id != null && id.equals(profile.getProfileID())) { // Found the profile for the extension
+ fDefault = profile;
+ return profile;
+ }
+ }
+ return firstDefault;
+ }
+
+ /**
+ * Constructor for CSSProfileRegistry.
+ */
+ private CSSProfileRegistry() {
+ super();
+ fProfiles = new HashMap();
+ Iterator i = new RegistryReader().enumProfiles();
+ while (i.hasNext()) {
+ Object profile = i.next();
+ if (profile instanceof CSSProfile) {
+ fProfiles.put(((CSSProfile) profile).getProfileID(), profile);
+ }
+ }
+ }
+
+
+ private static CSSProfileRegistry fInstance = null;
+ private Map fProfiles = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSFunctionID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSFunctionID.java
new file mode 100644
index 0000000..8a4e165
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSFunctionID.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSFunctionID {
+
+ final static String F_ATTR = "attr"; //$NON-NLS-1$
+ final static String F_COUNTER = "counter"; //$NON-NLS-1$
+ final static String F_RGB = "rgb"; //$NON-NLS-1$
+ final static String F_RECT = "rect"; //$NON-NLS-1$
+ final static String F_URI = "uri"; //$NON-NLS-1$
+ final static String F_FORMAT = "format"; //$NON-NLS-1$
+ final static String F_LOCAL = "local"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSKeywordID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSKeywordID.java
new file mode 100644
index 0000000..b8f898e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSKeywordID.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSKeywordID {
+
+ final static String K_100 = "100"; //$NON-NLS-1$
+ final static String K_200 = "200"; //$NON-NLS-1$
+ final static String K_300 = "300"; //$NON-NLS-1$
+ final static String K_400 = "400"; //$NON-NLS-1$
+ final static String K_500 = "500"; //$NON-NLS-1$
+ final static String K_600 = "600"; //$NON-NLS-1$
+ final static String K_700 = "700"; //$NON-NLS-1$
+ final static String K_800 = "800"; //$NON-NLS-1$
+ final static String K_900 = "900"; //$NON-NLS-1$
+ final static String K_ABOVE = "above"; //$NON-NLS-1$
+ final static String K_ABSOLUTE = "absolute"; //$NON-NLS-1$
+ final static String K_ACTIVEBORDER = "ActiveBorder"; //$NON-NLS-1$
+ final static String K_ACTIVECAPTION = "ActiveCaption"; //$NON-NLS-1$
+ final static String K_ALL = "all"; //$NON-NLS-1$
+ final static String K_ALWAYS = "always"; //$NON-NLS-1$
+ final static String K_APPWORKSPACE = "AppWorkspace"; //$NON-NLS-1$
+ final static String K_AQUA = "aqua"; //$NON-NLS-1$
+ final static String K_ARMENIAN = "armenian"; //$NON-NLS-1$
+ final static String K_AUTO = "auto"; //$NON-NLS-1$
+ final static String K_AVOID = "avoid"; //$NON-NLS-1$
+ final static String K_BACKGROUND = "Background"; //$NON-NLS-1$
+ final static String K_BASELINE = "baseline"; //$NON-NLS-1$
+ final static String K_BEHIND = "behind"; //$NON-NLS-1$
+ final static String K_BELOW = "below"; //$NON-NLS-1$
+ final static String K_BIDI_OVERRIDE = "bidi-override"; //$NON-NLS-1$
+ final static String K_BLACK = "black"; //$NON-NLS-1$
+ final static String K_BLINK = "blink"; //$NON-NLS-1$
+ final static String K_BLOCK = "block"; //$NON-NLS-1$
+ final static String K_BLUE = "blue"; //$NON-NLS-1$
+ final static String K_BOLD = "bold"; //$NON-NLS-1$
+ final static String K_BOLDER = "bolder"; //$NON-NLS-1$
+ final static String K_BOTH = "both"; //$NON-NLS-1$
+ final static String K_BOTTOM = "bottom"; //$NON-NLS-1$
+ final static String K_BUTTONFACE = "ButtonFace"; //$NON-NLS-1$
+ final static String K_BUTTONHIGHLIGHT = "ButtonHighlight"; //$NON-NLS-1$
+ final static String K_BUTTONSHADOW = "ButtonShadow"; //$NON-NLS-1$
+ final static String K_BUTTONTEXT = "ButtonText"; //$NON-NLS-1$
+ final static String K_CAPITALIZE = "capitalize"; //$NON-NLS-1$
+ final static String K_CAPTION = "caption"; //$NON-NLS-1$
+ final static String K_CAPTIONTEXT = "CaptionText"; //$NON-NLS-1$
+ final static String K_CENTER = "center"; //$NON-NLS-1$
+ final static String K_CENTER_LEFT = "center-left"; //$NON-NLS-1$
+ final static String K_CENTER_RIGHT = "center-right"; //$NON-NLS-1$
+ final static String K_CHILD = "child"; //$NON-NLS-1$
+ final static String K_CIRCLE = "circle"; //$NON-NLS-1$
+ final static String K_CJK_IDEOGRAPHIC = "cjk-ideographic"; //$NON-NLS-1$
+ final static String K_CLOSE_QUOTE = "close-quote"; //$NON-NLS-1$
+ final static String K_CODE = "code"; //$NON-NLS-1$
+ final static String K_CONDENSED = "condensed"; //$NON-NLS-1$
+ final static String K_COLLAPSE = "collapse"; //$NON-NLS-1$
+ final static String K_COMPACT = "compact"; //$NON-NLS-1$
+ final static String K_CONTINUOUS = "continuous"; //$NON-NLS-1$
+ final static String K_CROP = "crop"; //$NON-NLS-1$
+ final static String K_CROSS = "cross"; //$NON-NLS-1$
+ final static String K_CROSSHAIR = "crosshair"; //$NON-NLS-1$
+ final static String K_CURSIVE = "cursive"; //$NON-NLS-1$
+ final static String K_DASHED = "dashed"; //$NON-NLS-1$
+ final static String K_DECIMAL = "decimal"; //$NON-NLS-1$
+ final static String K_DECIMAL_LEADING_ZERO = "decimal-leading-zero"; //$NON-NLS-1$
+ final static String K_DEFAULT = "default"; //$NON-NLS-1$
+ final static String K_DIGITS = "digits"; //$NON-NLS-1$
+ final static String K_DISC = "disc"; //$NON-NLS-1$
+ final static String K_DOTTED = "dotted"; //$NON-NLS-1$
+ final static String K_DOUBLE = "double"; //$NON-NLS-1$
+ final static String K_E_RESIZE = "e-resize"; //$NON-NLS-1$
+ final static String K_EMBED = "embed"; //$NON-NLS-1$
+ final static String K_EXPANDED = "expanded"; //$NON-NLS-1$
+ final static String K_EXTRA_CONDENSED = "extra-condensed"; //$NON-NLS-1$
+ final static String K_EXTRA_EXPANDED = "extra-expanded"; //$NON-NLS-1$
+ final static String K_FANTASY = "fantasy"; //$NON-NLS-1$
+ final static String K_FAR_LEFT = "far-left"; //$NON-NLS-1$
+ final static String K_FAR_RIGHT = "far-right"; //$NON-NLS-1$
+ final static String K_FAST = "fast"; //$NON-NLS-1$
+ final static String K_FASTER = "faster"; //$NON-NLS-1$
+ final static String K_FEMALE = "female"; //$NON-NLS-1$
+ final static String K_FIXED = "fixed"; //$NON-NLS-1$
+ final static String K_FUCHSIA = "fuchsia"; //$NON-NLS-1$
+ final static String K_GEORGIAN = "georgian"; //$NON-NLS-1$
+ final static String K_GRAY = "gray"; //$NON-NLS-1$
+ final static String K_GRAYTEXT = "GrayText"; //$NON-NLS-1$
+ final static String K_GREEN = "green"; //$NON-NLS-1$
+ final static String K_GROOVE = "groove"; //$NON-NLS-1$
+ final static String K_HEBREW = "hebrew"; //$NON-NLS-1$
+ final static String K_HELP = "help"; //$NON-NLS-1$
+ final static String K_HIDDEN = "hidden"; //$NON-NLS-1$
+ final static String K_HIDE = "hide"; //$NON-NLS-1$
+ final static String K_HIGH = "high"; //$NON-NLS-1$
+ final static String K_HIGHLIGHT = "Highlight"; //$NON-NLS-1$
+ final static String K_HIGHLIGHTTEXT = "HighlightText"; //$NON-NLS-1$
+ final static String K_HIGHER = "higher"; //$NON-NLS-1$
+ final static String K_HIRAGANA = "hiragana"; //$NON-NLS-1$
+ final static String K_HIRAGANA_IROHA = "hiragana-iroha"; //$NON-NLS-1$
+ final static String K_ICON = "icon"; //$NON-NLS-1$
+ final static String K_INACTIVEBORDER = "InactiveBorder"; //$NON-NLS-1$
+ final static String K_INACTIVECAPTION = "InactiveCaption"; //$NON-NLS-1$
+ final static String K_INACTIVECAPTIONTEXT = "InactiveCaptionText"; //$NON-NLS-1$
+ final static String K_INFOBACKGROUND = "InfoBackground"; //$NON-NLS-1$
+ final static String K_INFOTEXT = "InfoText"; //$NON-NLS-1$
+ final static String K_INLINE = "inline"; //$NON-NLS-1$
+ final static String K_INLINE_TABLE = "inline-table"; //$NON-NLS-1$
+ final static String K_INSET = "inset"; //$NON-NLS-1$
+ final static String K_INSIDE = "inside"; //$NON-NLS-1$
+ final static String K_INVERT = "invert"; //$NON-NLS-1$
+ final static String K_ITALIC = "italic"; //$NON-NLS-1$
+ final static String K_JUSTIFY = "justify"; //$NON-NLS-1$
+ final static String K_KATAKANA = "katakana"; //$NON-NLS-1$
+ final static String K_KATAKANA_IROHA = "katakana-iroha"; //$NON-NLS-1$
+ final static String K_LANDSCAPE = "landscape"; //$NON-NLS-1$
+ final static String K_LARGE = "large"; //$NON-NLS-1$
+ final static String K_LARGER = "larger"; //$NON-NLS-1$
+ final static String K_LEFT = "left"; //$NON-NLS-1$
+ final static String K_LEFT_SIDE = "left-side"; //$NON-NLS-1$
+ final static String K_LEFTWARDS = "leftwards"; //$NON-NLS-1$
+ final static String K_LEVEL = "level"; //$NON-NLS-1$
+ final static String K_LIGHTER = "lighter"; //$NON-NLS-1$
+ final static String K_LIME = "lime"; //$NON-NLS-1$
+ final static String K_LINE_THROUGH = "line-through"; //$NON-NLS-1$
+ final static String K_LIST_ITEM = "list-item"; //$NON-NLS-1$
+ final static String K_LOUD = "loud"; //$NON-NLS-1$
+ final static String K_LOW = "low"; //$NON-NLS-1$
+ final static String K_LOWER = "lower"; //$NON-NLS-1$
+ final static String K_LOWER_ALPHA = "lower-alpha"; //$NON-NLS-1$
+ final static String K_LOWER_GREEK = "lower-greek"; //$NON-NLS-1$
+ final static String K_LOWER_LATIN = "lower-latin"; //$NON-NLS-1$
+ final static String K_LOWER_ROMAN = "lower-roman"; //$NON-NLS-1$
+ final static String K_LOWERCASE = "lowercase"; //$NON-NLS-1$
+ final static String K_LTR = "ltr"; //$NON-NLS-1$
+ final static String K_MALE = "male"; //$NON-NLS-1$
+ final static String K_MARKER = "marker"; //$NON-NLS-1$
+ final static String K_MAROON = "maroon"; //$NON-NLS-1$
+ final static String K_MEDIUM = "medium"; //$NON-NLS-1$
+ final static String K_MENU = "menu"; //$NON-NLS-1$
+ final static String K_MENUTEXT = "MenuText"; //$NON-NLS-1$
+ final static String K_MESSAGE_BOX = "message-box"; //$NON-NLS-1$
+ final static String K_MIDDLE = "middle"; //$NON-NLS-1$
+ final static String K_MIX = "mix"; //$NON-NLS-1$
+ final static String K_MONOSPACE = "monospace"; //$NON-NLS-1$
+ final static String K_MOVE = "move"; //$NON-NLS-1$
+ final static String K_N_RESIZE = "n-resize"; //$NON-NLS-1$
+ final static String K_NARROWER = "narrower"; //$NON-NLS-1$
+ final static String K_NAVY = "navy"; //$NON-NLS-1$
+ final static String K_NE_RESIZE = "ne-resize"; //$NON-NLS-1$
+ final static String K_NO_CLOSE_QUOTE = "no-close-quote"; //$NON-NLS-1$
+ final static String K_NO_OPEN_QUOTE = "no-open-quote"; //$NON-NLS-1$
+ final static String K_NO_REPEAT = "no-repeat"; //$NON-NLS-1$
+ final static String K_NONE = "none"; //$NON-NLS-1$
+ final static String K_NORMAL = "normal"; //$NON-NLS-1$
+ final static String K_NOWRAP = "nowrap"; //$NON-NLS-1$
+ final static String K_NW_RESIZE = "nw-resize"; //$NON-NLS-1$
+ final static String K_OBLIQUE = "oblique"; //$NON-NLS-1$
+ final static String K_OLIVE = "olive"; //$NON-NLS-1$
+ final static String K_ONCE = "once"; //$NON-NLS-1$
+ final static String K_OPEN_QUOTE = "open-quote"; //$NON-NLS-1$
+ final static String K_OUTSET = "outset"; //$NON-NLS-1$
+ final static String K_OUTSIDE = "outside"; //$NON-NLS-1$
+ final static String K_OVERLINE = "overline"; //$NON-NLS-1$
+ final static String K_POINTER = "pointer"; //$NON-NLS-1$
+ final static String K_PORTRAIT = "portrait"; //$NON-NLS-1$
+ final static String K_PRE = "pre"; //$NON-NLS-1$
+ final static String K_PURPLE = "purple"; //$NON-NLS-1$
+ final static String K_RED = "red"; //$NON-NLS-1$
+ final static String K_RELATIVE = "relative"; //$NON-NLS-1$
+ final static String K_REPEAT = "repeat"; //$NON-NLS-1$
+ final static String K_REPEAT_X = "repeat-x"; //$NON-NLS-1$
+ final static String K_REPEAT_Y = "repeat-y"; //$NON-NLS-1$
+ final static String K_RIDGE = "ridge"; //$NON-NLS-1$
+ final static String K_RIGHT = "right"; //$NON-NLS-1$
+ final static String K_RIGHT_SIDE = "right-side"; //$NON-NLS-1$
+ final static String K_RIGHTWARDS = "rightwards"; //$NON-NLS-1$
+ final static String K_RTL = "rtl"; //$NON-NLS-1$
+ final static String K_RUN_IN = "run-in"; //$NON-NLS-1$
+ final static String K_S_RESIZE = "s-resize"; //$NON-NLS-1$
+ final static String K_SANS_SERIF = "sans-serif"; //$NON-NLS-1$
+ final static String K_SCROLL = "scroll"; //$NON-NLS-1$
+ final static String K_SCROLLBAR = "Scrollbar"; //$NON-NLS-1$
+ final static String K_SE_RESIZE = "se-resize"; //$NON-NLS-1$
+ final static String K_SEMI_CONDENSED = "semi-condensed"; //$NON-NLS-1$
+ final static String K_SEMI_EXPANDED = "semi-expanded"; //$NON-NLS-1$
+ final static String K_SEPARATE = "separate"; //$NON-NLS-1$
+ final static String K_SERIF = "serif"; //$NON-NLS-1$
+ final static String K_SHOW = "show"; //$NON-NLS-1$
+ final static String K_SILENT = "silent"; //$NON-NLS-1$
+ final static String K_SILVER = "silver"; //$NON-NLS-1$
+ final static String K_SLOW = "slow"; //$NON-NLS-1$
+ final static String K_SLOWER = "slower"; //$NON-NLS-1$
+ final static String K_SMALL = "small"; //$NON-NLS-1$
+ final static String K_SMALL_CAPS = "small-caps"; //$NON-NLS-1$
+ final static String K_SMALL_CAPTION = "small-caption"; //$NON-NLS-1$
+ final static String K_SMALLER = "smaller"; //$NON-NLS-1$
+ final static String K_SOFT = "soft"; //$NON-NLS-1$
+ final static String K_SOLID = "solid"; //$NON-NLS-1$
+ final static String K_SPELL_OUT = "spell-out"; //$NON-NLS-1$
+ final static String K_SQUARE = "square"; //$NON-NLS-1$
+ final static String K_STATIC = "static"; //$NON-NLS-1$
+ final static String K_STATUS_BAR = "status-bar"; //$NON-NLS-1$
+ final static String K_SUB = "sub"; //$NON-NLS-1$
+ final static String K_SUPER = "super"; //$NON-NLS-1$
+ final static String K_SW_RESIZE = "sw-resize"; //$NON-NLS-1$
+ final static String K_TABLE = "table"; //$NON-NLS-1$
+ final static String K_TABLE_CAPTION = "table-caption"; //$NON-NLS-1$
+ final static String K_TABLE_CELL = "table-cell"; //$NON-NLS-1$
+ final static String K_TABLE_COLUMN = "table-column"; //$NON-NLS-1$
+ final static String K_TABLE_COLUMN_GROUP = "table-column-group"; //$NON-NLS-1$
+ final static String K_TABLE_FOOTER_GROUP = "table-footer-group"; //$NON-NLS-1$
+ final static String K_TABLE_HEADER_GROUP = "table-header-group"; //$NON-NLS-1$
+ final static String K_TABLE_ROW = "table-row"; //$NON-NLS-1$
+ final static String K_TABLE_ROW_GROUP = "table-row-group"; //$NON-NLS-1$
+ final static String K_TEAL = "teal"; //$NON-NLS-1$
+ final static String K_TEXT = "text"; //$NON-NLS-1$
+ final static String K_TEXT_TOP = "text-top"; //$NON-NLS-1$
+ final static String K_TEXT_BOTTOM = "text-bottom"; //$NON-NLS-1$
+ final static String K_THICK = "thick"; //$NON-NLS-1$
+ final static String K_THIN = "thin"; //$NON-NLS-1$
+ final static String K_THREEDDARKSHADOW = "ThreeDDarkShadow"; //$NON-NLS-1$
+ final static String K_THREEDFACE = "ThreeDFace"; //$NON-NLS-1$
+ final static String K_THREEDHIGHLIGHT = "ThreeDHighlight"; //$NON-NLS-1$
+ final static String K_THREEDLIGHTSHADOW = "ThreeDLightShadow"; //$NON-NLS-1$
+ final static String K_THREEDSHADOW = "ThreeDShadow"; //$NON-NLS-1$
+ final static String K_TOP = "top"; //$NON-NLS-1$
+ final static String K_TRANSPARENT = "transparent"; //$NON-NLS-1$
+ final static String K_ULTRA_CONDENSED = "ultra-condensed"; //$NON-NLS-1$
+ final static String K_ULTRA_EXPANDED = "ultra-expanded"; //$NON-NLS-1$
+ final static String K_UNDERLINE = "underline"; //$NON-NLS-1$
+ final static String K_UPPER_ALPHA = "upper-alpha"; //$NON-NLS-1$
+ final static String K_UPPER_LATIN = "upper-latin"; //$NON-NLS-1$
+ final static String K_UPPER_ROMAN = "upper-roman"; //$NON-NLS-1$
+ final static String K_UPPERCASE = "uppercase"; //$NON-NLS-1$
+ final static String K_VISIBLE = "visible"; //$NON-NLS-1$
+ final static String K_W_RESIZE = "w-resize"; //$NON-NLS-1$
+ final static String K_WAIT = "wait"; //$NON-NLS-1$
+ final static String K_WHITE = "white"; //$NON-NLS-1$
+ final static String K_WIDER = "wider"; //$NON-NLS-1$
+ final static String K_WINDOW = "Window"; //$NON-NLS-1$
+ final static String K_WINDOWFRAME = "WindowFrame"; //$NON-NLS-1$
+ final static String K_WINDOWTEXT = "WindowText"; //$NON-NLS-1$
+ final static String K_X_FAST = "x-fast"; //$NON-NLS-1$
+ final static String K_X_HIGH = "x-high"; //$NON-NLS-1$
+ final static String K_X_LARGE = "x-large"; //$NON-NLS-1$
+ final static String K_X_LOUD = "x-loud"; //$NON-NLS-1$
+ final static String K_X_LOW = "x-low"; //$NON-NLS-1$
+ final static String K_X_SLOW = "x-slow"; //$NON-NLS-1$
+ final static String K_X_SMALL = "x-small"; //$NON-NLS-1$
+ final static String K_X_SOFT = "x-soft"; //$NON-NLS-1$
+ final static String K_XX_SMALL = "xx-small"; //$NON-NLS-1$
+ final static String K_XX_LARGE = "xx-large"; //$NON-NLS-1$
+ final static String K_YELLOW = "yellow"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMMTypeCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMMTypeCollector.java
new file mode 100644
index 0000000..c26805c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMMTypeCollector.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+
+public class CSSMMTypeCollector extends CSSMetaModelTraverser {
+
+ /**
+ * Constructor for TypeCollector.
+ */
+ public CSSMMTypeCollector() {
+ super();
+ }
+
+ public void apply(CSSMMNode node, String type) {
+ fType = type;
+ fNodes = new ArrayList();
+ apply(node);
+ }
+
+ public void collectNestedType(boolean nested) {
+ fNested = nested;
+ }
+
+ protected short preNode(CSSMMNode node) {
+ short rc = TRAV_CONT;
+ if (node != null) {
+ if (fType == node.getType()) {
+ if (!fNodes.contains(node)) {
+ fNodes.add(node);
+ }
+ if (!fNested) {
+ rc = TRAV_PRUNE;
+ }
+ }
+ }
+ return rc;
+ }
+
+ public Iterator getNodes() {
+ return fNodes.iterator();
+ }
+
+
+ private boolean fNested = false;
+ private String fType = null;
+ List fNodes = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMediaGroupID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMediaGroupID.java
new file mode 100644
index 0000000..b78cf7e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMediaGroupID.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSMediaGroupID {
+
+ final static String M_CONTINUOUS = "continuous"; //$NON-NLS-1$
+ final static String M_PAGED = "paged"; //$NON-NLS-1$
+
+ final static String M_VISUAL = "visual"; //$NON-NLS-1$
+ final static String M_AURAL = "aural"; //$NON-NLS-1$
+ final static String M_TACTILE = "tactile"; //$NON-NLS-1$
+
+ final static String M_GRID = "grid"; //$NON-NLS-1$
+ final static String M_BITMAP = "bitmap"; //$NON-NLS-1$
+
+ final static String M_INTERACTIVE = "interactive"; //$NON-NLS-1$
+ final static String M_STATIC = "static"; //$NON-NLS-1$
+
+ final static String M_ALL = "all"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelFinder.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelFinder.java
new file mode 100644
index 0000000..2c8859f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelFinder.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.w3c.dom.Node;
+
+
+public class CSSMetaModelFinder {
+ /**
+ * Constructor for CSSMetaModelFinder.
+ */
+ private CSSMetaModelFinder() {
+ super();
+ }
+
+ static synchronized public CSSMetaModelFinder getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSMetaModelFinder();
+ }
+ return fInstance;
+ }
+
+ public CSSMetaModel findMetaModelFor(ICSSNode node) {
+ return CSSProfileFinder.getInstance().findProfileFor(node).getMetaModel();
+ }
+
+ public CSSMetaModel findMetaModelFor(IStructuredModel model) {
+ return CSSProfileFinder.getInstance().findProfileFor(model).getMetaModel();
+
+ }
+
+ /**
+ * Finds the meta model for the node that contains the css model
+ */
+ public CSSMetaModel findMetaModelFor(Node node) {
+ return CSSProfileFinder.getInstance().findProfileFor(node).getMetaModel();
+ }
+
+ // findMetaModelFor(Node) is not used.
+ // Even if it is used, it can be replaced with
+ // findMetaModelFor(IStructuredModel) easily
+
+ public CSSMetaModel findMetaModelFor(String baseLocation) {
+ return CSSProfileFinder.getInstance().findProfileFor(baseLocation).getMetaModel();
+ }
+
+ static private CSSMetaModelFinder fInstance = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelTraverser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelTraverser.java
new file mode 100644
index 0000000..cabedfe
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelTraverser.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+
+
+abstract public class CSSMetaModelTraverser {
+
+ /**
+ * Constructor for Traverser.
+ */
+ public CSSMetaModelTraverser() {
+ super();
+ }
+
+ public final void apply(CSSMMNode node) {
+ fTravStack = new Stack();
+
+ begin(node);
+ traverse(node);
+ end(node);
+ }
+
+ private final short traverse(CSSMMNode node) {
+ if (node == null) {
+ return TRAV_CONT;
+ }
+
+ fTravStack.push(node);
+
+ short rc;
+ rc = preNode(node);
+
+ if (rc == TRAV_CONT) {
+ Iterator i = node.getChildNodes();
+ while (i.hasNext()) {
+ CSSMMNode child = (CSSMMNode) i.next();
+ short rcChild = traverse(child);
+ if (rcChild == TRAV_STOP) {
+ fTravStack.pop();
+ return TRAV_STOP;
+ }
+ }
+ }
+ else if (rc == TRAV_STOP) {
+ fTravStack.pop();
+ return TRAV_STOP;
+ }
+
+ rc = postNode(node);
+
+ fTravStack.pop();
+ return (rc == TRAV_PRUNE) ? TRAV_CONT : rc;
+ }
+
+ protected void begin(CSSMMNode node) {
+
+ }
+
+ protected void end(CSSMMNode node) {
+
+ }
+
+ protected short preNode(CSSMMNode node) {
+ return TRAV_CONT;
+ }
+
+ protected short postNode(CSSMMNode node) {
+ return TRAV_CONT;
+ }
+
+
+ Stack fTravStack = null;
+
+ protected static final short TRAV_CONT = 0;
+ protected static final short TRAV_STOP = 1;
+ protected static final short TRAV_PRUNE = 2;
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelUtil.java
new file mode 100644
index 0000000..33a75ca
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSMetaModelUtil.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMDescriptor;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMProperty;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.w3c.dom.css.CSSFontFaceRule;
+
+
+public class CSSMetaModelUtil {
+ public CSSMetaModelUtil(CSSMetaModel metamodel) {
+ super();
+ fMetaModel = metamodel;
+ }
+
+ public Iterator getProperties() {
+ return collectNodesByType(CSSMMNode.TYPE_PROPERTY);
+ }
+
+ public Iterator getDescriptors() {
+ return collectNodesByType(CSSMMNode.TYPE_DESCRIPTOR);
+ }
+
+ public Iterator collectNodesByType(String type) {
+ CSSMMTypeCollector collector = new CSSMMTypeCollector();
+ collector.apply(fMetaModel, type);
+ return collector.getNodes();
+ }
+
+ public CSSMMProperty getProperty(String propertyName) {
+ Iterator iProperty = getProperties();
+ while (iProperty.hasNext()) {
+ CSSMMNode node = (CSSMMNode) iProperty.next();
+ if (node.getName().equalsIgnoreCase(propertyName)) {
+ return (CSSMMProperty) node;
+ }
+ }
+ return null;
+ }
+
+ public CSSMMDescriptor getDescriptor(String descriptorName) {
+ Iterator iDescriptor = getDescriptors();
+ while (iDescriptor.hasNext()) {
+ CSSMMNode node = (CSSMMNode) iDescriptor.next();
+ if (node.getName().equalsIgnoreCase(descriptorName)) {
+ return (CSSMMDescriptor) node;
+ }
+ }
+ return null;
+ }
+
+ public CSSMMNode getMetaModelNodeFor(ICSSNode node) {
+ if (node instanceof ICSSStyleDeclaration) {
+ node = node.getParentNode();
+ }
+ if (node instanceof ICSSStyleDeclItem) {
+ ICSSNode parent = node.getParentNode();
+ if (parent != null) {
+ parent = parent.getParentNode();
+ }
+ if (parent instanceof ICSSStyleRule) {
+ return getProperty(((ICSSStyleDeclItem) node).getPropertyName());
+ }
+ else if (parent instanceof CSSFontFaceRule) {
+ return getDescriptor(((ICSSStyleDeclItem) node).getPropertyName());
+ }
+ }
+ if (node == null) {
+ return null;
+ }
+
+ if (fTypeMap == null) {
+ fTypeMap = new HashMap();
+ fTypeMap.put(new Short(ICSSNode.STYLERULE_NODE), CSSMMNode.TYPE_STYLE_RULE);
+ fTypeMap.put(new Short(ICSSNode.FONTFACERULE_NODE), CSSMMNode.TYPE_FONT_FACE_RULE);
+ fTypeMap.put(new Short(ICSSNode.PAGERULE_NODE), CSSMMNode.TYPE_PAGE_RULE);
+ }
+
+ String nodeType = (String) fTypeMap.get(new Short(node.getNodeType()));
+ if (nodeType == null) {
+ return null;
+ }
+
+ Iterator iNodes = collectNodesByType(nodeType);
+ if (iNodes.hasNext()) {
+ CSSMMNode targetNode = (CSSMMNode) iNodes.next();
+ if (!iNodes.hasNext()) { // it's only one
+ return targetNode;
+ }
+ }
+
+ return null;
+ }
+
+ public CSSMetaModel getMetaModel() {
+ return fMetaModel;
+ }
+
+
+ private CSSMetaModel fMetaModel = null;
+ private Map fTypeMap = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSNumberID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSNumberID.java
new file mode 100644
index 0000000..bef6983
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSNumberID.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSNumberID {
+
+ final static java.lang.String N_ANGLE = "angle";//$NON-NLS-1$
+ final static java.lang.String N_FREQUENCY = "frequency";//$NON-NLS-1$
+ final static java.lang.String N_INTEGER = "integer";//$NON-NLS-1$
+ final static java.lang.String N_LENGTH = "length";//$NON-NLS-1$
+ final static java.lang.String N_PERCENTAGE = "percentage";//$NON-NLS-1$
+ final static java.lang.String N_TIME = "time";//$NON-NLS-1$
+ final static java.lang.String N_HASH = "hash"; //$NON-NLS-1$
+ final static java.lang.String N_NUM = "number";//$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSProfileFinder.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSProfileFinder.java
new file mode 100644
index 0000000..886bc89
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSProfileFinder.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.css.core.internal.contentproperties.CSSContentProperties;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfile;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.Node;
+
+
+public class CSSProfileFinder {
+ /**
+ * Constructor for CSSProfileFinder.
+ */
+ private CSSProfileFinder() {
+ super();
+ }
+
+ static synchronized public CSSProfileFinder getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSProfileFinder();
+ }
+ return fInstance;
+ }
+
+ public CSSProfile findProfileFor(ICSSNode node) {
+ ICSSModel model = null;
+ if (node != null) {
+ ICSSDocument doc = node.getOwnerDocument();
+ if (doc != null) {
+ model = doc.getModel();
+ }
+ }
+ return findProfileFor(model);
+ }
+
+ public CSSProfile findProfileFor(IStructuredModel model) {
+ String baseLocation = null;
+ if (model instanceof ICSSModel) {
+ Object modelType = ((ICSSModel) model).getStyleSheetType();
+ if (modelType == ICSSModel.EXTERNAL) {
+ baseLocation = model.getBaseLocation();
+ }
+ else if (modelType == ICSSModel.EMBEDDED || modelType == ICSSModel.INLINE) {
+ baseLocation = model.getBaseLocation(); // may be null
+ }
+ }
+ else if (model != null) {
+ baseLocation = model.getBaseLocation();
+ }
+ return findProfileFor(baseLocation);
+ }
+
+ public CSSProfile findProfileFor(Node node) {
+ String baseLocation = null;
+ if (node instanceof IDOMNode) {
+ IDOMModel model = ((IDOMNode) node).getModel();
+ if (model != null) {
+ baseLocation = model.getBaseLocation();
+ }
+ }
+ return findProfileFor(baseLocation);
+ }
+
+ public CSSProfile findProfileFor(String baseLocation) {
+ CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
+ CSSProfile profile = null;
+
+ if (baseLocation != null) {
+ IPath path = new Path(baseLocation);
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ if (resource == null && path.segmentCount() > 1)
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (resource != null) {
+ String profileID = CSSContentProperties.getProperty(CSSContentProperties.CSS_PROFILE, resource, true);
+ if (profileID != null && 0 < profileID.length()) {
+ profile = reg.getProfile(profileID);
+ }
+ }
+ }
+
+ return (profile != null) ? profile : reg.getDefaultProfile();
+ }
+
+ static private CSSProfileFinder fInstance = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSPropertyID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSPropertyID.java
new file mode 100644
index 0000000..550e8e7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSPropertyID.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSPropertyID {
+
+ final static String P_AZIMUTH = "azimuth"; //$NON-NLS-1$
+ final static String P_BG = "background"; //$NON-NLS-1$
+ final static String P_BG_ATTACHMENT = "background-attachment"; //$NON-NLS-1$
+ final static String P_BG_COLOR = "background-color"; //$NON-NLS-1$
+ final static String P_BG_IMAGE = "background-image"; //$NON-NLS-1$
+ final static String P_BG_POSITION = "background-position"; //$NON-NLS-1$
+ final static String P_BG_REPEAT = "background-repeat"; //$NON-NLS-1$
+ final static String P_BORDER = "border"; //$NON-NLS-1$
+ final static String P_BORDER_COLLAPSE = "border-collapse"; //$NON-NLS-1$
+ final static String P_BORDER_COLOR = "border-color"; //$NON-NLS-1$
+ final static String P_BORDER_SPACING = "border-spacing"; //$NON-NLS-1$
+ final static String P_BORDER_STYLE = "border-style"; //$NON-NLS-1$
+ final static String P_BORDER_TOP = "border-top"; //$NON-NLS-1$
+ final static String P_BORDER_RIGHT = "border-right"; //$NON-NLS-1$
+ final static String P_BORDER_BOTTOM = "border-bottom"; //$NON-NLS-1$
+ final static String P_BORDER_LEFT = "border-left"; //$NON-NLS-1$
+ final static String P_BORDER_TOP_COLOR = "border-top-color"; //$NON-NLS-1$
+ final static String P_BORDER_RIGHT_COLOR = "border-right-color"; //$NON-NLS-1$
+ final static String P_BORDER_BOTTOM_COLOR = "border-bottom-color"; //$NON-NLS-1$
+ final static String P_BORDER_LEFT_COLOR = "border-left-color"; //$NON-NLS-1$
+ final static String P_BORDER_TOP_STYLE = "border-top-style"; //$NON-NLS-1$
+ final static String P_BORDER_RIGHT_STYLE = "border-right-style"; //$NON-NLS-1$
+ final static String P_BORDER_BOTTOM_STYLE = "border-bottom-style"; //$NON-NLS-1$
+ final static String P_BORDER_LEFT_STYLE = "border-left-style"; //$NON-NLS-1$
+ final static String P_BORDER_TOP_WIDTH = "border-top-width"; //$NON-NLS-1$
+ final static String P_BORDER_RIGHT_WIDTH = "border-right-width"; //$NON-NLS-1$
+ final static String P_BORDER_BOTTOM_WIDTH = "border-bottom-width"; //$NON-NLS-1$
+ final static String P_BORDER_LEFT_WIDTH = "border-left-width"; //$NON-NLS-1$
+ final static String P_BORDER_WIDTH = "border-width"; //$NON-NLS-1$
+ final static String P_BOTTOM = "bottom"; //$NON-NLS-1$
+ final static String P_CAPTION_SIDE = "caption-side"; //$NON-NLS-1$
+ final static String P_CLEAR = "clear"; //$NON-NLS-1$
+ final static String P_CLIP = "clip"; //$NON-NLS-1$
+ final static String P_COLOR = "color"; //$NON-NLS-1$
+ final static String P_CONTENT = "content"; //$NON-NLS-1$
+ final static String P_COUNTER_INCREMENT = "counter-increment"; //$NON-NLS-1$
+ final static String P_COUNTER_RESET = "counter-reset"; //$NON-NLS-1$
+ final static String P_CUE = "cue"; //$NON-NLS-1$
+ final static String P_CUE_AFTER = "cue-after"; //$NON-NLS-1$
+ final static String P_CUE_BEFORE = "cue-before"; //$NON-NLS-1$
+ final static String P_CURSOR = "cursor"; //$NON-NLS-1$
+ final static String P_DIRECTION = "direction"; //$NON-NLS-1$
+ final static String P_DISPLAY = "display"; //$NON-NLS-1$
+ final static String P_ELEVATION = "elevation"; //$NON-NLS-1$
+ final static String P_EMPTY_CELLS = "empty-cells"; //$NON-NLS-1$
+ final static String P_FLOAT = "float"; //$NON-NLS-1$
+ final static String P_FONT = "font"; //$NON-NLS-1$
+ final static String P_FONT_FAMILY = "font-family"; //$NON-NLS-1$
+ final static String P_FONT_SIZE = "font-size"; //$NON-NLS-1$
+ final static String P_FONT_SIZE_ADJUST = "font-size-adjust"; //$NON-NLS-1$
+ final static String P_FONT_STRETCH = "font-stretch"; //$NON-NLS-1$
+ final static String P_FONT_STYLE = "font-style"; //$NON-NLS-1$
+ final static String P_FONT_VARIANT = "font-variant"; //$NON-NLS-1$
+ final static String P_FONT_WEIGHT = "font-weight"; //$NON-NLS-1$
+ final static String P_HEIGHT = "height"; //$NON-NLS-1$
+ final static String P_LEFT = "left"; //$NON-NLS-1$
+ final static String P_LETTER_SPACING = "letter-spacing"; //$NON-NLS-1$
+ final static String P_LINE_HEIGHT = "line-height"; //$NON-NLS-1$
+ final static String P_LIST_STYLE = "list-style"; //$NON-NLS-1$
+ final static String P_LIST_STYLE_IMAGE = "list-style-image"; //$NON-NLS-1$
+ final static String P_LIST_STYLE_POSITION = "list-style-position"; //$NON-NLS-1$
+ final static String P_LIST_STYLE_TYPE = "list-style-type"; //$NON-NLS-1$
+ final static String P_MARGIN = "margin"; //$NON-NLS-1$
+ final static String P_MARGIN_TOP = "margin-top"; //$NON-NLS-1$
+ final static String P_MARGIN_RIGHT = "margin-right"; //$NON-NLS-1$
+ final static String P_MARGIN_BOTTOM = "margin-bottom"; //$NON-NLS-1$
+ final static String P_MARGIN_LEFT = "margin-left"; //$NON-NLS-1$
+ final static String P_MARKER_OFFSET = "marker-offset"; //$NON-NLS-1$
+ final static String P_MARKS = "marks"; //$NON-NLS-1$
+ final static String P_MAX_HEIGHT = "max-height"; //$NON-NLS-1$
+ final static String P_MAX_WIDTH = "max-width"; //$NON-NLS-1$
+ final static String P_MIN_HEIGHT = "min-height"; //$NON-NLS-1$
+ final static String P_MIN_WIDTH = "min-width"; //$NON-NLS-1$
+ final static String P_ORPHANS = "orphans"; //$NON-NLS-1$
+ final static String P_OUTLINE = "outline"; //$NON-NLS-1$
+ final static String P_OUTLINE_COLOR = "outline-color"; //$NON-NLS-1$
+ final static String P_OUTLINE_STYLE = "outline-style"; //$NON-NLS-1$
+ final static String P_OUTLINE_WIDTH = "outline-width"; //$NON-NLS-1$
+ final static String P_OVERFLOW = "overflow"; //$NON-NLS-1$
+ final static String P_PADDING = "padding"; //$NON-NLS-1$
+ final static String P_PADDING_TOP = "padding-top"; //$NON-NLS-1$
+ final static String P_PADDING_RIGHT = "padding-right"; //$NON-NLS-1$
+ final static String P_PADDING_BOTTOM = "padding-bottom"; //$NON-NLS-1$
+ final static String P_PADDING_LEFT = "padding-left"; //$NON-NLS-1$
+ final static String P_PAGE = "page"; //$NON-NLS-1$
+ final static String P_PAGE_BREAK_AFTER = "page-break-after"; //$NON-NLS-1$
+ final static String P_PAGE_BREAK_BEFORE = "page-break-before"; //$NON-NLS-1$
+ final static String P_PAGE_BREAK_INSIDE = "page-break-inside"; //$NON-NLS-1$
+ final static String P_PAUSE = "pause"; //$NON-NLS-1$
+ final static String P_PAUSE_AFTER = "pause-after"; //$NON-NLS-1$
+ final static String P_PAUSE_BEFORE = "pause-before"; //$NON-NLS-1$
+ final static String P_PITCH = "pitch"; //$NON-NLS-1$
+ final static String P_PITCH_RANGE = "pitch-range"; //$NON-NLS-1$
+ final static String P_PLAY_DURING = "play-during"; //$NON-NLS-1$
+ final static String P_POSITION = "position"; //$NON-NLS-1$
+ final static String P_QUOTES = "quotes"; //$NON-NLS-1$
+ final static String P_RICHNESS = "richness"; //$NON-NLS-1$
+ final static String P_RIGHT = "right"; //$NON-NLS-1$
+ final static String P_SIZE = "size"; //$NON-NLS-1$
+ final static String P_SPEAK = "speak"; //$NON-NLS-1$
+ final static String P_SPEAK_HEADER = "speak-header"; //$NON-NLS-1$
+ final static String P_SPEAK_NUMERAL = "speak-numeral"; //$NON-NLS-1$
+ final static String P_SPEAK_PUNCTUATION = "speak-punctuation"; //$NON-NLS-1$
+ final static String P_SPEECH_RATE = "speech-rate"; //$NON-NLS-1$
+ final static String P_STRESS = "stress"; //$NON-NLS-1$
+ final static String P_TABLE_LAYOUT = "table-layout"; //$NON-NLS-1$
+ final static String P_TEXT_ALIGN = "text-align"; //$NON-NLS-1$
+ final static String P_TEXT_DECORATION = "text-decoration"; //$NON-NLS-1$
+ final static String P_TEXT_INDENT = "text-indent"; //$NON-NLS-1$
+ final static String P_TEXT_SHADOW = "text-shadow"; //$NON-NLS-1$
+ final static String P_TEXT_TRANSFORM = "text-transform"; //$NON-NLS-1$
+ final static String P_TOP = "top"; //$NON-NLS-1$
+ final static String P_UNICODE_BIDI = "unicode-bidi"; //$NON-NLS-1$
+ final static String P_VERTICAL_ALIGN = "vertical-align"; //$NON-NLS-1$
+ final static String P_VISIBILITY = "visibility"; //$NON-NLS-1$
+ final static String P_VOICE_FAMILY = "voice-family"; //$NON-NLS-1$
+ final static String P_VOLUME = "volume"; //$NON-NLS-1$
+ final static String P_WHITE_SPACE = "white-space"; //$NON-NLS-1$
+ final static String P_WIDOWS = "widows"; //$NON-NLS-1$
+ final static String P_WIDTH = "width"; //$NON-NLS-1$
+ final static String P_WORD_SPACING = "word-spacing"; //$NON-NLS-1$
+ final static String P_Z_INDEX = "z-index"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSStringID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSStringID.java
new file mode 100644
index 0000000..6522cfb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSStringID.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSStringID {
+
+ final static String S_ANY = "any"; //$NON-NLS-1$
+ final static String S_COUNTER_IDENTIFIER = "counter-identifier"; //$NON-NLS-1$
+ final static String S_FAMILY_NAME = "family-name"; //$NON-NLS-1$
+ final static String S_FONT_FACE_NAME = "font-face-name"; //$NON-NLS-1$
+ final static String S_PAGE_IDENTIFIER = "page-identifier"; //$NON-NLS-1$
+ final static String S_SPECIFIC_VOICE = "specific-voice"; //$NON-NLS-1$
+ final static String S_URANGE = "urange"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSUnitID.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSUnitID.java
new file mode 100644
index 0000000..0f46d32
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodel/util/CSSUnitID.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodel.util;
+
+public interface CSSUnitID {
+
+ final static String U_CM = "cm";//$NON-NLS-1$
+ final static String U_DEG = "deg";//$NON-NLS-1$
+ final static String U_EMS = "em";//$NON-NLS-1$
+ final static String U_EXS = "ex";//$NON-NLS-1$
+ final static String U_GRAD = "grad";//$NON-NLS-1$
+ final static String U_HASH = "#";//$NON-NLS-1$
+ final static String U_HZ = "Hz";//$NON-NLS-1$
+ final static String U_IN = "in";//$NON-NLS-1$
+ // final static String U_INTEGER = "INTEGER";//$NON-NLS-1$
+ final static String U_KHZ = "kHz";//$NON-NLS-1$
+ final static String U_MM = "mm";//$NON-NLS-1$
+ final static String U_MS = "ms";//$NON-NLS-1$
+ // final static String U_NUMBER = "NUMBER";//$NON-NLS-1$
+ final static String U_PC = "pc";//$NON-NLS-1$
+ final static String U_PERCENTAGE = "%";//$NON-NLS-1$
+ final static String U_PT = "pt";//$NON-NLS-1$
+ final static String U_PX = "px";//$NON-NLS-1$
+ final static String U_RAD = "rad";//$NON-NLS-1$
+ final static String U_S = "s";//$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCategoryImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCategoryImpl.java
new file mode 100644
index 0000000..34b0e6d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCategoryImpl.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMCategory;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMCategoryImpl extends CSSMMNodeImpl implements CSSMMCategory {
+
+ public CSSMMCategoryImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_CATEGORY;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ public String getCaption() {
+ return fCaption;
+ }
+
+ void setCaption(String caption) {
+ fCaption = caption;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getCaption() == null) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+ /*
+ * @see Object#toString()
+ */
+ public String toString() {
+ return getCaption();
+ }
+
+
+ private String fCaption = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCharsetRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCharsetRuleImpl.java
new file mode 100644
index 0000000..a064b51
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMCharsetRuleImpl.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMCharsetRule;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMCharsetRuleImpl extends CSSMMNodeImpl implements CSSMMCharsetRule {
+
+
+ public CSSMMCharsetRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_CHARSET_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ return MetaModelErrors.NO_ERROR;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMContainerImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMContainerImpl.java
new file mode 100644
index 0000000..eae79ea
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMContainerImpl.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMContainer;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMContainerImpl extends CSSMMNodeImpl implements CSSMMContainer {
+
+
+ public CSSMMContainerImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_CONTAINER;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_NUMBER || type == TYPE_KEYWORD || type == TYPE_FUNCTION || type == TYPE_CONTAINER);
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMDescriptorImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMDescriptorImpl.java
new file mode 100644
index 0000000..811d664
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMDescriptorImpl.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMDescriptor;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+
+class CSSMMDescriptorImpl extends CSSMMNodeImpl implements CSSMMDescriptor {
+
+
+ public CSSMMDescriptorImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_DESCRIPTOR;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_NUMBER || type == TYPE_KEYWORD || type == TYPE_FUNCTION || type == TYPE_CONTAINER || type == TYPE_STRING || type == TYPE_SEPARATOR);
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+ /*
+ * @see CSSMMDescriptor#getValues()
+ */
+ public Iterator getValues() {
+ ValueCollector collector = new ValueCollector();
+ collector.apply(this);
+ return collector.getNodes();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFontFaceRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFontFaceRuleImpl.java
new file mode 100644
index 0000000..71d1ca9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFontFaceRuleImpl.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMFontFaceRule;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMFontFaceRuleImpl extends CSSMMNodeImpl implements CSSMMFontFaceRule {
+
+
+ public CSSMMFontFaceRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_FONT_FACE_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return (child != null && child.getType() == TYPE_DESCRIPTOR);
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ return MetaModelErrors.NO_ERROR;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFunctionImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFunctionImpl.java
new file mode 100644
index 0000000..567f216
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMFunctionImpl.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMFunction;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMFunctionImpl extends CSSMMNodeImpl implements CSSMMFunction {
+
+ public CSSMMFunctionImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_FUNCTION;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String getFunctionString() {
+ return fValue;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#postSetAttribute()
+ */
+ // void postSetAttribute() throws BadInitializationException {
+ // super.postSetAttribute();
+ // String name = getName();
+ // if (name == null) { throw new BadInitializationException(); }
+ //
+ // List list = new ArrayList();
+ // list.add(CSSFunctionID.F_ATTR);
+ // list.add(CSSFunctionID.F_COUNTER);
+ // list.add(CSSFunctionID.F_RGB);
+ // list.add(CSSFunctionID.F_RECT);
+ // list.add(CSSFunctionID.F_URI);
+ // list.add(CSSFunctionID.F_FORMAT);
+ // list.add(CSSFunctionID.F_LOCAL);
+ //
+ // if (! list.contains(name.toLowerCase())) {
+ // throw new BadInitializationException();
+ // }
+ // }
+ /*
+ * @see Object#toString()
+ */
+ public String toString() {
+ return getFunctionString();
+ }
+
+ void setFunctionString(String value) {
+ fValue = value;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getFunctionString() == null) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+
+ private String fValue = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMImportRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMImportRuleImpl.java
new file mode 100644
index 0000000..cadfe85
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMImportRuleImpl.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMImportRule;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMImportRuleImpl extends CSSMMNodeImpl implements CSSMMImportRule {
+
+
+ public CSSMMImportRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_IMPORT_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ return MetaModelErrors.NO_ERROR;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMKeywordImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMKeywordImpl.java
new file mode 100644
index 0000000..f8b5594
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMKeywordImpl.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMKeyword;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMKeywordImpl extends CSSMMNodeImpl implements CSSMMKeyword {
+
+ public CSSMMKeywordImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_KEYWORD;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMKeyword#getKeywordString()
+ */
+ public String getKeywordString() {
+ return fValue;
+ }
+
+ /*
+ * @see Object#toString()
+ */
+ public String toString() {
+ return getKeywordString();
+ }
+
+ void setKeywordString(String value) {
+ fValue = value;
+ }
+
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getKeywordString() == null) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+
+ private String fValue = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMMediaRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMMediaRuleImpl.java
new file mode 100644
index 0000000..2dee907
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMMediaRuleImpl.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMMediaRule;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+class CSSMMMediaRuleImpl extends CSSMMNodeImpl implements CSSMMMediaRule {
+
+
+ public CSSMMMediaRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_MEDIA_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ short getError() {
+ return MetaModelErrors.NO_ERROR;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNodeImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNodeImpl.java
new file mode 100644
index 0000000..923d7f7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNodeImpl.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+
+
+abstract class CSSMMNodeImpl implements CSSMMNode {
+
+ public CSSMMNodeImpl() {
+ super();
+ }
+
+ public abstract String getType();
+
+ public String getDescription() {
+ return fDescription;
+ }
+
+ public String getAttribute(String name) {
+ if (fAttributes == null) {
+ return null;
+ }
+ return (String) fAttributes.get(name);
+ }
+
+ public Iterator getChildNodes() {
+ if (fChildNodes == null) {
+ return Collections.EMPTY_LIST.iterator();
+ }
+ else {
+ return Collections.unmodifiableCollection(fChildNodes).iterator();
+ }
+ }
+
+ public Iterator getDescendants() {
+ List descendants = new ArrayList();
+ Iterator iChild = getChildNodes();
+ while (iChild.hasNext()) {
+ CSSMMNode child = (CSSMMNode) iChild.next();
+ Iterator iDescendant = child.getDescendants();
+ if (iDescendant.hasNext()) {
+ while (iDescendant.hasNext()) {
+ CSSMMNode descendant = (CSSMMNode) iDescendant.next();
+ if (!descendants.contains(descendant)) {
+ descendants.add(descendant);
+ }
+ }
+ }
+ else {
+ if (!descendants.contains(child)) {
+ descendants.add(child);
+ }
+ }
+ }
+ return Collections.unmodifiableCollection(descendants).iterator();
+ }
+
+ void appendChild(CSSMMNode child) {
+ if (child == null) {
+ return;
+ }
+ if (fChildNodes == null) {
+ fChildNodes = new ArrayList();
+ }
+ if (!fChildNodes.contains(child)) {
+ fChildNodes.add(child);
+ ((CSSMMNodeImpl) child).fRefCount++;
+ }
+ }
+
+ void removeChild(CSSMMNode child) {
+ if (child == null || fChildNodes == null) {
+ return;
+ }
+ Iterator i = fChildNodes.iterator();
+ while (i.hasNext()) {
+ if (i.next() == child) {
+ i.remove();
+ ((CSSMMNodeImpl) child).fRefCount--;
+ return;
+ }
+ }
+ }
+
+ void removeAllChildNodes() {
+ if (fChildNodes == null) {
+ return;
+ }
+ Iterator i = fChildNodes.iterator();
+ while (i.hasNext()) {
+ ((CSSMMNodeImpl) i.next()).fRefCount--;
+ }
+ fChildNodes.clear();
+ }
+
+ abstract boolean canContain(CSSMMNode child);
+
+ void initializeAttribute(Map attributes) throws IllegalArgumentException {
+ if (fAttributes == null) {
+ fAttributes = new HashMap();
+ }
+ fAttributes.putAll(attributes);
+ postSetAttribute();
+ }
+
+ void setDescription(String description) {
+ fDescription = description;
+ }
+
+ void postSetAttribute() throws IllegalArgumentException {
+ // default : nop
+ }
+
+ abstract short getError();
+
+ int getChildCount() {
+ return (fChildNodes != null) ? fChildNodes.size() : 0;
+ }
+
+ int getReferenceCount() {
+ return fRefCount;
+ }
+
+
+ private List fChildNodes = null;
+ private String fDescription = null;
+ private Map fAttributes = null;
+ private int fRefCount = 0; // for error check
+
+ static final String ATTR_NAME = "name"; //$NON-NLS-1$
+ static final String NAME_NOT_AVAILABLE = ""; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNumberImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNumberImpl.java
new file mode 100644
index 0000000..3aae3e4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMNumberImpl.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNumber;
+
+class CSSMMNumberImpl extends CSSMMNodeImpl implements CSSMMNumber {
+
+
+ public CSSMMNumberImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_NUMBER;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return (child != null && child.getType() == TYPE_UNIT);
+ }
+
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPageRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPageRuleImpl.java
new file mode 100644
index 0000000..e28ccec
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPageRuleImpl.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMPageRule;
+
+class CSSMMPageRuleImpl extends CSSMMNodeImpl implements CSSMMPageRule {
+
+
+ public CSSMMPageRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_PAGE_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_PROPERTY || type == TYPE_SELECTOR);
+ }
+
+ short getError() {
+ if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPropertyImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPropertyImpl.java
new file mode 100644
index 0000000..4b529fd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPropertyImpl.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMProperty;
+
+
+class CSSMMPropertyImpl extends CSSMMNodeImpl implements CSSMMProperty {
+ public CSSMMPropertyImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_PROPERTY;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_NUMBER || type == TYPE_KEYWORD || type == TYPE_FUNCTION || type == TYPE_CONTAINER || type == TYPE_STRING || type == TYPE_SEPARATOR || type == TYPE_PROPERTY);
+ }
+
+ /*
+ * @see CSSMMProperty#getCategoryName()
+ */
+ public String getCategoryName() {
+ return getAttribute(ATTR_CATEGORY);
+ }
+
+ public Iterator getValues() {
+ ValueCollector collector = new ValueCollector();
+ collector.apply(this);
+ return collector.getNodes();
+ }
+
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+
+ static final String ATTR_CATEGORY = "category"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoClassImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoClassImpl.java
new file mode 100644
index 0000000..a495981
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoClassImpl.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+class CSSMMPseudoClassImpl extends CSSMMSelectorImpl {
+
+
+ /**
+ * Constructor for CSSMMPseudoClassImpl.
+ */
+ public CSSMMPseudoClassImpl() {
+ super();
+ }
+
+ /*
+ * @see CSSMMSelector#getSelectorType()
+ */
+ public String getSelectorType() {
+ return TYPE_PSEUDO_CLASS;
+ }
+
+ void setSelectorString(String value) {
+ fValue = ":" + value; //$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoElementImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoElementImpl.java
new file mode 100644
index 0000000..51adb83
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMPseudoElementImpl.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+public class CSSMMPseudoElementImpl extends CSSMMSelectorImpl {
+
+
+ /**
+ * Constructor for CSSMMPseudoElementImpl.
+ */
+ public CSSMMPseudoElementImpl() {
+ super();
+ }
+
+ /*
+ * @see CSSMMSelector#getSelectorType()
+ */
+ public String getSelectorType() {
+ return TYPE_PSEUDO_ELEMENT;
+ }
+
+ void setSelectorString(String value) {
+ String version = getAttribute("version"); //$NON-NLS-1$
+ long v = 0;
+ if (version != null) {
+ try {
+ v = Long.parseLong(version);
+ }
+ catch (Exception e) {}
+ }
+ // Pseudo Elements added since CSS3 are prefixed by two colons
+ fValue = ((v >= 3) ? "::" : ":") + value; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorExpressionImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorExpressionImpl.java
new file mode 100644
index 0000000..c45b4ce
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorExpressionImpl.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+class CSSMMSelectorExpressionImpl extends CSSMMSelectorImpl {
+
+ public CSSMMSelectorExpressionImpl() {
+ super();
+ }
+
+ /*
+ * @see CSSMMSelector#getSelectorType()
+ */
+ public String getSelectorType() {
+ return TYPE_EXPRESSION;
+ }
+
+ void postSetAttribute() throws IllegalArgumentException {
+ super.postSetAttribute();
+ String name = getName();
+ if (name == null) {
+ throw new IllegalArgumentException();
+ }
+
+ Map map = new HashMap();
+ map.put(EXPRESSION_ADJACENT.toLowerCase(), "+"); //$NON-NLS-1$
+ map.put(EXPRESSION_ATTRIBUTE.toLowerCase(), "[]"); //$NON-NLS-1$
+ map.put(EXPRESSION_CHILD.toLowerCase(), ">"); //$NON-NLS-1$
+ map.put(EXPRESSION_DESCENDANT.toLowerCase(), "' '"); //$NON-NLS-1$
+ map.put(EXPRESSION_UNIVERSAL.toLowerCase(), "*"); //$NON-NLS-1$
+
+ fValue = (String) map.get(name.toLowerCase());
+ if (fValue == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorImpl.java
new file mode 100644
index 0000000..aaf243c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMSelectorImpl.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMSelector;
+
+
+abstract class CSSMMSelectorImpl extends CSSMMNodeImpl implements CSSMMSelector {
+
+ /**
+ * Constructor for CSSMMSelectorImpl.
+ */
+ public CSSMMSelectorImpl() {
+ super();
+ }
+
+ /*
+ * @see CSSMMNode#getName()
+ */
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNode#getType()
+ */
+ public String getType() {
+ return TYPE_SELECTOR;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#getError()
+ */
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+ /*
+ * @see CSSMMSelector#getSelectorString()
+ */
+ public String getSelectorString() {
+ return fValue;
+ }
+
+ /*
+ * @see Object#toString()
+ */
+ public String toString() {
+ return getSelectorString();
+ }
+
+
+ protected String fValue = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStringImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStringImpl.java
new file mode 100644
index 0000000..c8cde45
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStringImpl.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMString;
+
+class CSSMMStringImpl extends CSSMMNodeImpl implements CSSMMString {
+
+
+ public CSSMMStringImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_STRING;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+ /*
+ * @see CSSMMNodeImpl#postSetAttribute()
+ */
+ // void postSetAttribute() throws BadInitializationException {
+ // super.postSetAttribute();
+ // String name = getName();
+ // if (name == null) { throw new BadInitializationException(); }
+ //
+ // Map map = new HashMap();
+ // map.put(CSSStringID.S_ANY.toLowerCase(), "<any>"); //$NON-NLS-1$
+ // map.put(CSSStringID.S_COUNTER_IDENTIFIER.toLowerCase(), "<counter>");
+ // //$NON-NLS-1$
+ // map.put(CSSStringID.S_FAMILY_NAME.toLowerCase(), "<family-name>");
+ // //$NON-NLS-1$
+ // map.put(CSSStringID.S_FONT_FACE_NAME.toLowerCase(),
+ // "<font-face-name>"); //$NON-NLS-1$
+ // map.put(CSSStringID.S_PAGE_IDENTIFIER.toLowerCase(),
+ // "<page-identifier>"); //$NON-NLS-1$
+ // map.put(CSSStringID.S_SPECIFIC_VOICE.toLowerCase(),
+ // "<specific-voice>"); //$NON-NLS-1$
+ // map.put(CSSStringID.S_URANGE.toLowerCase(), "<urange>"); //$NON-NLS-1$
+ //
+ // fValue = (String)map.get(name.toLowerCase());
+ // if (fValue == null) { throw new BadInitializationException(); }
+ // }
+ //
+ // /*
+ // * @see Object#toString()
+ // */
+ // public String toString() {
+ // return fValue;
+ // }
+ //
+ // private String fValue = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleRuleImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleRuleImpl.java
new file mode 100644
index 0000000..2c257c3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleRuleImpl.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMStyleRule;
+
+class CSSMMStyleRuleImpl extends CSSMMNodeImpl implements CSSMMStyleRule {
+
+
+ public CSSMMStyleRuleImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_STYLE_RULE;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_PROPERTY || type == TYPE_SELECTOR);
+ }
+
+ short getError() {
+ if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleSheetImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleSheetImpl.java
new file mode 100644
index 0000000..4d7fd00
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMStyleSheetImpl.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMStyleSheet;
+
+class CSSMMStyleSheetImpl extends CSSMMNodeImpl implements CSSMMStyleSheet {
+
+
+ public CSSMMStyleSheetImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_STYLE_SHEET;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_CHARSET_RULE || type == TYPE_IMPORT_RULE || type == TYPE_PAGE_RULE || type == TYPE_MEDIA_RULE || type == TYPE_FONT_FACE_RULE || type == TYPE_STYLE_RULE);
+ }
+
+ short getError() {
+ if (getChildCount() == 0) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMUnitImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMUnitImpl.java
new file mode 100644
index 0000000..9c154a7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMMUnitImpl.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMUnit;
+
+/**
+ * CSSMMUnit : embedded type
+ */
+class CSSMMUnitImpl extends CSSMMNodeImpl implements CSSMMUnit {
+
+ public CSSMMUnitImpl() {
+ super();
+ }
+
+ public String getType() {
+ return TYPE_UNIT;
+ }
+
+ public String getName() {
+ String name = getAttribute(ATTR_NAME);
+ if (name != null) {
+ return name.toLowerCase();
+ }
+ else {
+ return null;
+ }
+ }
+
+ /*
+ * @see CSSMMUnit#getUnitString()
+ */
+ public String getUnitString() {
+ return fValue;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ return false;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#postSetAttribute()
+ */
+ // void postSetAttribute() throws BadInitializationException {
+ // super.postSetAttribute();
+ // String name = getName();
+ // if (name == null) { throw new BadInitializationException(); }
+ // Map map = new HashMap();
+ // map.put(CSSUnitID.U_CM.toLowerCase(), "cm");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_DEG.toLowerCase(), "deg");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_EMS.toLowerCase(), "em");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_EXS.toLowerCase(), "ex");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_GRAD.toLowerCase(), "grad");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_HASH.toLowerCase(), "#");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_HZ.toLowerCase(), "Hz");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_IN.toLowerCase(), "in");//$NON-NLS-1$
+ // // map.put(CSSUnitID.U_INTEGER.toLowerCase(),
+ // "(integer)");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_KHZ.toLowerCase(), "kHz");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_MM.toLowerCase(), "mm");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_MS.toLowerCase(), "ms");//$NON-NLS-1$
+ // // map.put(CSSUnitID.U_NUMBER.toLowerCase(), "(number)");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_PC.toLowerCase(), "pc");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_PERCENTAGE.toLowerCase(), "%");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_PT.toLowerCase(), "pt");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_PX.toLowerCase(), "px");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_RAD.toLowerCase(), "rad");//$NON-NLS-1$
+ // map.put(CSSUnitID.U_S.toLowerCase(), "s");//$NON-NLS-1$
+ // fValue = (String)map.get(name.toLowerCase());
+ // if (fValue == null) { throw new BadInitializationException(); }
+ // }
+ /*
+ * @see Object#toString()
+ */
+ public String toString() {
+ return getUnitString();
+ }
+
+ void setUnitString(String value) {
+ fValue = value;
+ }
+
+ short getError() {
+ if (getName() == null) {
+ return MetaModelErrors.ERROR_NOT_DEFINED;
+ }
+ else if (getUnitString() == null) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+ private String fValue = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMetaModelImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMetaModelImpl.java
new file mode 100644
index 0000000..2240db1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSMetaModelImpl.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMStyleSheet;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+
+
+class CSSMetaModelImpl extends CSSMMNodeImpl implements CSSMetaModel {
+ // class CSSMetaModelImpl implements CSSMetaModel {
+ public CSSMetaModelImpl() {
+ super();
+ fNodePool = new NodePool();
+ }
+
+ public String getType() {
+ return TYPE_META_MODEL;
+ }
+
+ public String getName() {
+ return NAME_NOT_AVAILABLE;
+ }
+
+ /*
+ * @see CSSMMNodeImpl#canContain(CSSMMNode)
+ */
+ boolean canContain(CSSMMNode child) {
+ if (child == null) {
+ return false;
+ }
+ String type = child.getType();
+ return (type == TYPE_STYLE_SHEET || type == TYPE_CATEGORY);
+ }
+
+ public CSSMMStyleSheet getStyleSheet() {
+ Iterator i = getChildNodes();
+ while (i.hasNext()) {
+ CSSMMNode node = (CSSMMNode) i.next();
+ if (node.getType() == TYPE_STYLE_SHEET) {
+ return (CSSMMStyleSheet) node;
+ }
+ }
+ return null;
+ // return fStyleSheet;
+ }
+
+ public Iterator getCategories() {
+ List categories = new ArrayList();
+ Iterator i = getChildNodes();
+ while (i.hasNext()) {
+ CSSMMNode node = (CSSMMNode) i.next();
+ if (node.getType() == TYPE_CATEGORY) {
+ categories.add(node);
+ }
+ }
+ return categories.iterator();
+ }
+
+ void loadCompleted() {
+ fNodePool = null;
+ }
+
+ // List fCategories = null;
+ /*
+ * @see CSSMMNodeImpl#isValid()
+ */
+ short getError() {
+ if (getStyleSheet() != null) {
+ return MetaModelErrors.ERROR_NO_CHILD;
+ }
+ else {
+ return MetaModelErrors.NO_ERROR;
+ }
+ }
+
+ NodePool getNodePool() {
+ return fNodePool;
+ }
+
+
+ private NodePool fNodePool = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileImpl.java
new file mode 100644
index 0000000..9c45f44
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileImpl.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Locale;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfile;
+import org.osgi.framework.Bundle;
+
+
+
+class CSSProfileImpl implements CSSProfile {
+
+ /**
+ * Constructor for CSSMetaModelProfileInfoImpl.
+ */
+ private CSSProfileImpl() {
+ super();
+ }
+
+ /**
+ * Constructor for CSSMetaModelProfileInfoImpl.
+ */
+ public CSSProfileImpl(String id, URL url) {
+ this();
+ fID = id;
+ fURL = url;
+ }
+
+ /**
+ * Constructor for CSSMetaModelProfileInfoImpl.
+ */
+ CSSProfileImpl(String id, URL url, String relativeURI) {
+ super();
+ fID = id;
+ fURL = url;
+ fRelativeURI = relativeURI;
+ }
+
+ /*
+ * @see CSSMetaModelProfileInfo#getProfileID()
+ */
+ public String getProfileID() {
+ return fID;
+ }
+
+ /*
+ * @see CSSMetaModelProfileInfo#getProfileName()
+ */
+ public String getProfileName() {
+ return (fName == null) ? fID : fName;
+ }
+
+ public CSSMetaModel getMetaModel() {
+ if (fMetaModel == null) {
+ try {
+ InputStream input = getProfileURL().openStream();
+ ProfileLoader loader = new ProfileLoader(getResourceBundle(), getLogging());
+ fMetaModel = loader.loadProfile(input);
+ }
+ catch (IOException e) {
+ Logger.logException("Cannot open stream for profile", e); //$NON-NLS-1$
+ }
+ }
+ return fMetaModel;
+ }
+
+ private ResourceBundle getResourceBundle() {
+ ResourceBundle resourceBundle = null;
+
+ Bundle bundle = null;
+ String pluginID = getOwnerPluginID();
+ if (pluginID != null) {
+ bundle = Platform.getBundle(pluginID);
+ if (bundle != null) {
+ // needed to work around FileLocator.openStream not looking for
+ // files with Java naming conventions (BUG103345)
+ IPath[] paths = getResourceBundlePaths();
+ if (paths != null) {
+ InputStream inStream = null;
+ int i = 0;
+ while (i < paths.length && inStream == null) {
+ IPath path = paths[i];
+ try {
+ inStream = FileLocator.openStream(bundle, path, true);
+ if (inStream != null)
+ resourceBundle = new PropertyResourceBundle(inStream);
+ else
+ ++i;
+ }
+ catch (IOException e) {
+ // unable to open stream with current path so just
+ // try next path
+ ++i;
+ }
+ finally {
+ if (inStream != null)
+ try {
+ inStream.close();
+ }
+ catch (IOException e) {
+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+ }
+ return resourceBundle;
+ }
+
+ /**
+ * Returns an array of potential resource bundle paths or null if there
+ * are none
+ *
+ * @return IPath[] or null
+ */
+ private IPath[] getResourceBundlePaths() {
+ IPath[] paths = new IPath[0];
+
+ if (fRelativeURI != null) {
+ // original path = location of profile.xml - profile.xml
+ IPath originalPath = Path.fromOSString(fRelativeURI).removeLastSegments(1);
+
+ String baseName = "cssprofile"; //$NON-NLS-1$
+ Vector names = calculateBundleNames(baseName, Locale.getDefault());
+
+ int a = 0;
+ paths = new IPath[names.size()];
+ for (int i = names.size(); i > 0; --i) {
+ String bundleName = (String) names.get(i - 1);
+ IPath path = originalPath.append(bundleName).addFileExtension("properties"); //$NON-NLS-1$
+ paths[a] = path;
+ ++a;
+ }
+ }
+ return paths;
+ }
+
+ /**
+ * Calculate the bundles along the search path from the base bundle to the
+ * bundle specified by baseName and locale.<br />
+ *
+ * @param baseName
+ * the base bundle name
+ * @param locale
+ * the locale
+ * @param names
+ * the vector used to return the names of the bundles along the
+ * search path.
+ *
+ */
+ private Vector calculateBundleNames(String baseName, Locale locale) {
+ // this method can be deleted after BUG103345 is fixed
+ final Vector result = new Vector(4); // default size 4
+ final String language = locale.getLanguage();
+ final int languageLength = language.length();
+ final String country = locale.getCountry();
+ final int countryLength = country.length();
+ final String variant = locale.getVariant();
+ final int variantLength = variant.length();
+
+ result.addElement(baseName); // at least add base name
+ if (languageLength + countryLength + variantLength == 0) {
+ // The locale is "", "", "".
+ return result;
+ }
+ final StringBuffer temp = new StringBuffer(baseName);
+ temp.append('_');
+ temp.append(language);
+ if (languageLength > 0) {
+ result.addElement(temp.toString());
+ }
+
+ if (countryLength + variantLength == 0) {
+ return result;
+ }
+ temp.append('_');
+ temp.append(country);
+ if (countryLength > 0) {
+ result.addElement(temp.toString());
+ }
+
+ if (variantLength == 0) {
+ return result;
+ }
+ temp.append('_');
+ temp.append(variant);
+ result.addElement(temp.toString());
+
+ return result;
+ }
+
+ /*
+ * @see CSSMetaModelProfileInfo#getProfileURL()
+ */
+ public URL getProfileURL() {
+ return fURL;
+ }
+
+ void setProfileName(String name) {
+ fName = name;
+ }
+
+ public boolean isDefault() {
+ return fDefault;
+ }
+
+ void setDefault(boolean isDefault) {
+ fDefault = isDefault;
+ }
+
+ public String getOwnerPluginID() {
+ return fOwnerPluginID;
+ }
+
+ void setOwnerPluginID(String pluginID) {
+ fOwnerPluginID = pluginID;
+ }
+
+ /**
+ * hidden option : logging
+ */
+ void setLogging(boolean logging) {
+ fLogging = logging;
+ }
+
+ boolean getLogging() {
+ return fLogging;
+ }
+
+
+ String fID = null;
+ String fName = null;
+ URL fURL = null;
+ CSSMetaModel fMetaModel = null;
+ String fOwnerPluginID = null;
+ boolean fDefault = false;
+ boolean fLogging = false;
+ private String fRelativeURI = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileTest.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileTest.java
new file mode 100644
index 0000000..9ab5e32
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/CSSProfileTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfile;
+
+
+class CSSProfileTest {
+
+
+ /**
+ * Test use only
+ */
+ public static void main(String[] args) {
+ if (args.length == 0)
+ return;
+ CSSMetaModel metamodel = null;
+ try {
+ CSSProfile profile = new CSSProfileImpl("test", new URL(args[0])); //$NON-NLS-1$
+ metamodel = profile.getMetaModel();
+ }
+ catch (MalformedURLException e) {
+ Logger.logException(e);
+ }
+ if (metamodel == null) {
+ return;
+ }
+ /*
+ * CSSMMTypeCollector collector = new CSSMMTypeCollector();
+ * collector.apply(metamodel, CSSMMNode.TYPE_PROPERTY); Iterator
+ * iProperty = collector.getNodes(); while (iProperty.hasNext()) {
+ * CSSMMNode node = (CSSMMNode)iProperty.next();
+ * System.out.println("Property " + node.getName() + " can contain:");
+ * //$NON-NLS-2$ //$NON-NLS-1$ Iterator iValue =
+ * node.getDescendants(); while (iValue.hasNext()) {
+ * debugOut((CSSMMNode)iValue.next(), 0, false); } }
+ */
+ debugOut(metamodel, 0, true);
+ }
+
+ static void debugOut(CSSMMNode node, int depth, boolean recursive) {
+ String type = node.getType();
+ for (int i = 0; i < depth; i++) {
+ System.out.print("\t"); //$NON-NLS-1$
+ }
+ System.out.print("[ " + node.getName() + "(" + type + ") ]"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ if (type == CSSMMNode.TYPE_UNIT || type == CSSMMNode.TYPE_KEYWORD || type == CSSMMNode.TYPE_FUNCTION || type == CSSMMNode.TYPE_SELECTOR) {
+ System.out.print(" -> " + node.toString()); //$NON-NLS-1$
+ }
+ System.out.println();
+
+ if (recursive) {
+ java.util.Iterator iNode = node.getChildNodes();
+ while (iNode.hasNext()) {
+ debugOut((CSSMMNode) iNode.next(), depth + 1, true);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/MetaModelErrors.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/MetaModelErrors.java
new file mode 100644
index 0000000..5ca381e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/MetaModelErrors.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+interface MetaModelErrors {
+
+ static final short NO_ERROR = 0;
+
+ // MASK
+ static final short MASK_WARNING = 0x1000;
+ static final short MASK_ERROR = 0x2000;
+
+ // ERROR
+ static final short ERROR_NOT_DEFINED = MASK_ERROR + 0x01;
+ static final short ERROR_INVALID_NAME = MASK_ERROR + 0x04;
+ static final short ERROR_INVAILD_CHILD = MASK_ERROR + 0x02;
+ static final short ERROR_NO_CHILD = MASK_ERROR + 0x08;
+ // static final short ERROR_NO_ESSENTIAL_CHILD = MASK_ERROR + 0x10
+
+ // WARNING
+ static final short WARNING_HAS_NO_CHILD = MASK_WARNING + 0x01;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/NodePool.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/NodePool.java
new file mode 100644
index 0000000..f5cb568
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/NodePool.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.internal.Logger;
+
+
+
+class NodePool {
+
+ NodePool() {
+ super();
+ initializeClassNameTable();
+ }
+
+ CSSMMNodeImpl getNode(String tagName, String nodeName) {
+ if (nodeName != null) {
+ nodeName = nodeName.toLowerCase();
+ }
+ String className = (String) classNames.get(tagName);
+ if (className == null) {
+ return null;
+ }
+ Map nodes = (Map) nodeRegistry.get(className);
+ if (nodes == null) {
+ nodes = new HashMap();
+ nodeRegistry.put(className, nodes);
+ }
+ CSSMMNodeImpl node = (CSSMMNodeImpl) nodes.get(nodeName);
+ if (node == null) {
+ node = createNewNode(className);
+ nodes.put(nodeName, node);
+ }
+ return node;
+ }
+
+ private CSSMMNodeImpl createNewNode(String className) {
+ CSSMMNodeImpl node = null;
+ if (className != null) {
+ className = getPackageName() + "." + className; //$NON-NLS-1$
+ try {
+ node = (CSSMMNodeImpl) Class.forName(className).newInstance();
+ }
+ catch (IllegalAccessException e) {
+ Logger.logException(e);
+ }
+ catch (InstantiationException e) {
+ Logger.logException(e);
+ }
+ catch (ClassNotFoundException e) {
+ Logger.logException(e);
+ }
+ }
+ // System.out.println(className + " is Created");
+ return node;
+ }
+
+ /**
+ * Error check function: find nodes that are not referred by any node
+ */
+ Iterator getStrayNodes() {
+ List strayNodes = new ArrayList();
+ Iterator iMap = nodeRegistry.values().iterator();
+ while (iMap.hasNext()) {
+ Map nodes = (Map) iMap.next();
+ Iterator iNode = nodes.values().iterator();
+ while (iNode.hasNext()) {
+ CSSMMNodeImpl node = (CSSMMNodeImpl) iNode.next();
+ if (node.getReferenceCount() == 0) {
+ strayNodes.add(node);
+ }
+ }
+ }
+ return strayNodes.iterator();
+ }
+
+ // This class must not be inner class :)
+ private String getPackageName() {
+ if (fPackageName == null) {
+ String className = getClass().getName();
+ int pos = className.lastIndexOf('.');
+ if (0 < pos) {
+ fPackageName = className.substring(0, pos);
+ }
+ else {
+ fPackageName = ""; //$NON-NLS-1$
+ }
+ }
+ return fPackageName;
+ }
+
+ void initializeClassNameTable() {
+ classNames.put(ProfileKeywords.STYLESHEET_DEF, CLASS_STYLE_SHEET);
+ classNames.put(ProfileKeywords.CHARSET_RULE_DEF, CLASS_CHARSET_RULE);
+ classNames.put(ProfileKeywords.CHARSET_RULE, CLASS_CHARSET_RULE);
+ classNames.put(ProfileKeywords.FONTFACE_RULE_DEF, CLASS_FONT_FACE_RULE);
+ classNames.put(ProfileKeywords.FONTFACE_RULE, CLASS_FONT_FACE_RULE);
+ classNames.put(ProfileKeywords.IMPORT_RULE_DEF, CLASS_IMPORT_RULE);
+ classNames.put(ProfileKeywords.IMPORT_RULE, CLASS_IMPORT_RULE);
+ classNames.put(ProfileKeywords.MEDIA_RULE_DEF, CLASS_MEDIA_RULE);
+ classNames.put(ProfileKeywords.MEDIA_RULE, CLASS_MEDIA_RULE);
+ classNames.put(ProfileKeywords.PAGE_RULE_DEF, CLASS_PAGE_RULE);
+ classNames.put(ProfileKeywords.PAGE_RULE, CLASS_PAGE_RULE);
+ classNames.put(ProfileKeywords.STYLE_RULE_DEF, CLASS_STYLE_RULE);
+ classNames.put(ProfileKeywords.STYLE_RULE, CLASS_STYLE_RULE);
+ classNames.put(ProfileKeywords.PROPERTY_DEF, CLASS_PROPERTY);
+ classNames.put(ProfileKeywords.PROPERTY, CLASS_PROPERTY);
+ classNames.put(ProfileKeywords.DESCRIPTOR_DEF, CLASS_DESCRIPTOR);
+ classNames.put(ProfileKeywords.DESCRIPTOR, CLASS_DESCRIPTOR);
+ classNames.put(ProfileKeywords.CONTAINER_DEF, CLASS_CONTAINER);
+ classNames.put(ProfileKeywords.CONTAINER, CLASS_CONTAINER);
+ classNames.put(ProfileKeywords.NUMBER_DEF, CLASS_NUMBER);
+ classNames.put(ProfileKeywords.NUMBER, CLASS_NUMBER);
+ classNames.put(ProfileKeywords.KEYWORD_DEF, CLASS_KEYWORD);
+ classNames.put(ProfileKeywords.KEYWORD, CLASS_KEYWORD);
+ classNames.put(ProfileKeywords.UNIT, CLASS_UNIT);
+ classNames.put(ProfileKeywords.UNIT_DEF, CLASS_UNIT);
+ classNames.put(ProfileKeywords.FUNCTION, CLASS_FUNCTION);
+ classNames.put(ProfileKeywords.FUNCTION_DEF, CLASS_FUNCTION);
+ classNames.put(ProfileKeywords.SELECTOR_EXPRESSION, CLASS_SELECTOR_EXPRESSION);
+ classNames.put(ProfileKeywords.PSEUDO_ELEMENT, CLASS_PSEUDO_ELEMENT);
+ classNames.put(ProfileKeywords.PSEUDO_ELEMENT_DEF, CLASS_PSEUDO_ELEMENT);
+ classNames.put(ProfileKeywords.PSEUDO_CLASS, CLASS_PSEUDO_CLASS);
+ classNames.put(ProfileKeywords.PSEUDO_CLASS_DEF, CLASS_PSEUDO_CLASS);
+ classNames.put(ProfileKeywords.STRING, CLASS_STRING);
+ classNames.put(ProfileKeywords.CATEGORY_DEF, CLASS_CATEGORY);
+ }
+
+
+ private String fPackageName;
+ /*
+ * Conversion Tables nodeRegistry : class name -> hash of node instances
+ * classNames : Profile Tag name -> java class name
+ */
+ private Map nodeRegistry = new HashMap();
+ private Map classNames = new HashMap();
+
+ private final static String CLASS_STYLE_SHEET = "CSSMMStyleSheetImpl"; //$NON-NLS-1$
+ private final static String CLASS_CHARSET_RULE = "CSSMMCharsetRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_FONT_FACE_RULE = "CSSMMFontFaceRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_IMPORT_RULE = "CSSMMImportRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_MEDIA_RULE = "CSSMMMediaRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_PAGE_RULE = "CSSMMPageRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_STYLE_RULE = "CSSMMStyleRuleImpl"; //$NON-NLS-1$
+ private final static String CLASS_PROPERTY = "CSSMMPropertyImpl"; //$NON-NLS-1$
+ private final static String CLASS_DESCRIPTOR = "CSSMMDescriptorImpl"; //$NON-NLS-1$
+ private final static String CLASS_CONTAINER = "CSSMMContainerImpl"; //$NON-NLS-1$
+ private final static String CLASS_NUMBER = "CSSMMNumberImpl"; //$NON-NLS-1$
+ private final static String CLASS_KEYWORD = "CSSMMKeywordImpl"; //$NON-NLS-1$
+ private final static String CLASS_UNIT = "CSSMMUnitImpl"; //$NON-NLS-1$
+ private final static String CLASS_FUNCTION = "CSSMMFunctionImpl"; //$NON-NLS-1$
+ private final static String CLASS_STRING = "CSSMMStringImpl"; //$NON-NLS-1$
+ private final static String CLASS_CATEGORY = "CSSMMCategoryImpl"; //$NON-NLS-1$
+ private final static String CLASS_SELECTOR_EXPRESSION = "CSSMMSelectorExpressionImpl"; //$NON-NLS-1$
+ private final static String CLASS_PSEUDO_CLASS = "CSSMMPseudoClassImpl"; //$NON-NLS-1$
+ private final static String CLASS_PSEUDO_ELEMENT = "CSSMMPseudoElementImpl"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileHandler.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileHandler.java
new file mode 100644
index 0000000..1f17105
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileHandler.java
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Stack;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMSelector;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfile;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfileRegistry;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+
+class ProfileHandler extends DefaultHandler {
+
+ private StringBuffer fCharacters = null;
+
+ public ProfileHandler(CSSMetaModelImpl metamodel, ResourceBundle resourceBundle, boolean logging) {
+ super();
+ fMetaModel = metamodel;
+ fNodePool = metamodel.getNodePool();
+ fResourceBundle = resourceBundle;
+ fLogging = logging;
+ }
+
+ public ProfileHandler(CSSMetaModelImpl metamodel, ResourceBundle resourceBundle) {
+ super();
+ fMetaModel = metamodel;
+ fNodePool = metamodel.getNodePool();
+ fResourceBundle = resourceBundle;
+ fLogging = false;
+ }
+
+ private String getResourceString(String key) {
+ if (key.equals("%")) { //$NON-NLS-1$
+ return key;
+ }
+ if (!key.startsWith("%")) { //$NON-NLS-1$
+ return key;
+ }
+ if (key.startsWith("%%")) { //$NON-NLS-1$
+ return key.substring(1);
+ }
+
+ if (fResourceBundle != null) {
+ return fResourceBundle.getString(key.substring(1));
+ }
+ else {
+ return key;
+ }
+ }
+
+ public void startDocument() throws SAXException {
+ // System.out.println("startDocument");
+ // fNodeStack.push(metamodel);
+ // fCurrentNode = null;
+ }
+
+ public void endDocument() throws SAXException {
+ new ErrorCorrector().doCorrect(fMetaModel);
+ if (fLogging) {
+ Iterator i = fNodePool.getStrayNodes();
+ while (i.hasNext()) {
+ CSSMMNode node = (CSSMMNode) i.next();
+ String str = "[CSSProfile Warning] " + node.getName(); //$NON-NLS-1$
+ str += "(" + node.getType() + ") is not referred by any node."; //$NON-NLS-1$ //$NON-NLS-2$
+ Logger.log(Logger.WARNING, str);
+ // System.out.println(str);
+ }
+ }
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ TagNode tagNode = null;
+ CSSMMNodeImpl parentNode = null;
+ if (0 < fNodeStack.size()) {
+ tagNode = (TagNode) fNodeStack.peek();
+ parentNode = tagNode.node;
+ }
+
+ CSSMMNodeImpl node = null;
+ if (qName.equals(ProfileKeywords.PROFILE_IMPORT)) { // import
+ String profileName = attributes.getValue(ATTR_NAME_REFERENCE);
+ importProfile(profileName);
+ }
+ else if (isDefinition(qName)) { // node creation
+ String nodeName = attributes.getValue(ATTR_NAME_DEFINITION);
+ node = fNodePool.getNode(qName, nodeName);
+ if (node != null) {
+ String overwrite = attributes.getValue(ATTR_OVERWRITE);
+ if (overwrite == null || overwrite.equals(ATTR_VALUE_OVERWRITE_FALSE)) {
+ node.removeAllChildNodes();
+ }
+ Map attrMap = new HashMap();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ attrMap.put(attributes.getQName(i), attributes.getValue(i));
+ }
+ try {
+ node.initializeAttribute(attrMap);
+ }
+ catch (IllegalArgumentException e) {
+ Logger.logException(e);
+ }
+ }
+ }
+ else if (node == null) { // node reference
+ String nodeName = attributes.getValue(ATTR_NAME_REFERENCE);
+ node = fNodePool.getNode(qName, nodeName);
+ }
+
+ if (node != null) {
+ if (parentNode != null && parentNode.canContain(node)) {
+ String enabled = attributes.getValue(ATTR_ENABLED);
+ if (enabled != null && enabled.equals(ATTR_VALUE_ENABLED_FALSE)) {
+ parentNode.removeChild(node);
+ }
+ else {
+ parentNode.appendChild(node);
+ }
+ }
+ else if (node.getType() == CSSMMNode.TYPE_STYLE_SHEET || node.getType() == CSSMMNode.TYPE_CATEGORY) {
+ fMetaModel.appendChild(node);
+ }
+ else {
+ if (fLogging && parentNode != null) {
+ Logger.log(Logger.ERROR, parentNode.getType() + " cannot contain " + //$NON-NLS-1$
+ node.getType() + " (" + qName + ")"); //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+ }
+
+ fNodeStack.push(new TagNode(qName, (node != null) ? node : parentNode));
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+
+ TagNode tagNode = (TagNode) fNodeStack.peek();
+ CSSMMNodeImpl node = tagNode.node;
+ String tagName = tagNode.tag;
+ if (fCharacters != null && (tagName.equals(ProfileKeywords.KEYWORD_VALUE) || tagName.equals(ProfileKeywords.UNIT_VALUE) || tagName.equals(ProfileKeywords.FUNCTION_VALUE) || tagName.equals(ProfileKeywords.SELECTOR_VALUE) || tagName.equals(ProfileKeywords.DESCRIPTION) || tagName.equals(ProfileKeywords.CAPTION))) {
+ String value = getResourceString(fCharacters.toString().trim());
+ if (node != null) {
+ if (node.getType() == CSSMMNode.TYPE_KEYWORD && tagName.equals(ProfileKeywords.KEYWORD_VALUE)) {
+ ((CSSMMKeywordImpl) node).setKeywordString(value);
+ }
+ else if (node.getType() == CSSMMNode.TYPE_UNIT && tagName.equals(ProfileKeywords.UNIT_VALUE)) {
+ ((CSSMMUnitImpl) node).setUnitString(value);
+ }
+ else if (node.getType() == CSSMMNode.TYPE_FUNCTION && tagName.equals(ProfileKeywords.FUNCTION_VALUE)) {
+ ((CSSMMFunctionImpl) node).setFunctionString(value);
+ }
+ else if (node.getType() == CSSMMNode.TYPE_SELECTOR && ((CSSMMSelector) node).getSelectorType() == CSSMMSelector.TYPE_PSEUDO_ELEMENT) {
+ ((CSSMMPseudoElementImpl) node).setSelectorString(value);
+ }
+ else if (node.getType() == CSSMMNode.TYPE_SELECTOR && ((CSSMMSelector) node).getSelectorType() == CSSMMSelector.TYPE_PSEUDO_CLASS) {
+ ((CSSMMPseudoClassImpl) node).setSelectorString(value);
+ }
+ else if (node.getType() == CSSMMNode.TYPE_CATEGORY && tagName.equals(ProfileKeywords.CAPTION)) {
+ ((CSSMMCategoryImpl) node).setCaption(value);
+ }
+ else if (tagName.equals(ProfileKeywords.DESCRIPTION)) {
+ node.setDescription(value);
+ }
+ }
+ }
+ fNodeStack.pop();
+ fCharacters = null;
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException {
+
+ TagNode tagNode = (TagNode) fNodeStack.peek();
+ String tagName = tagNode.tag;
+ if (tagName.equals(ProfileKeywords.KEYWORD_VALUE) || tagName.equals(ProfileKeywords.UNIT_VALUE) || tagName.equals(ProfileKeywords.FUNCTION_VALUE) || tagName.equals(ProfileKeywords.SELECTOR_VALUE) || tagName.equals(ProfileKeywords.DESCRIPTION) || tagName.equals(ProfileKeywords.CAPTION)) {
+ if (fCharacters == null) {
+ fCharacters = new StringBuffer(length);
+ }
+ fCharacters.append(ch, start, length);
+ }
+ }
+
+ private boolean isDefinition(String tagName) {
+ return (tagName.equals(ProfileKeywords.STYLESHEET_DEF) || tagName.equals(ProfileKeywords.CHARSET_RULE_DEF) || tagName.equals(ProfileKeywords.IMPORT_RULE_DEF) || tagName.equals(ProfileKeywords.PAGE_RULE_DEF) || tagName.equals(ProfileKeywords.MEDIA_RULE_DEF) || tagName.equals(ProfileKeywords.FONTFACE_RULE_DEF) || tagName.equals(ProfileKeywords.STYLE_RULE_DEF) || tagName.equals(ProfileKeywords.KEYWORD_DEF) || tagName.equals(ProfileKeywords.NUMBER_DEF) || tagName.equals(ProfileKeywords.PROPERTY_DEF) || tagName.equals(ProfileKeywords.DESCRIPTOR_DEF) || tagName.equals(ProfileKeywords.CONTAINER_DEF) || tagName.equals(ProfileKeywords.UNIT_DEF) || tagName.equals(ProfileKeywords.FUNCTION_DEF) || tagName.equals(ProfileKeywords.STRING) || tagName.equals(ProfileKeywords.CATEGORY_DEF) || tagName.equals(ProfileKeywords.PSEUDO_CLASS_DEF) || tagName.equals(ProfileKeywords.PSEUDO_ELEMENT_DEF) || tagName.equals(ProfileKeywords.SELECTOR_EXPRESSION) || tagName.equals(ProfileKeywords.SEPARATOR));
+ }
+
+ private void importProfile(String profileName) {
+ URL profileURL = null;
+ CSSProfileRegistry reg = CSSProfileRegistry.getInstance();
+ CSSProfile profile = reg.getProfile(profileName);
+ if (profile != null) {
+ // first: find URL by ID
+ profileURL = profile.getProfileURL();
+ }
+ else {
+ // second: find URL by filename of profile URL
+ Iterator i = reg.getProfiles();
+ while (i.hasNext()) {
+ profile = (CSSProfile) i.next();
+ URL url = profile.getProfileURL();
+ if (url.getFile().endsWith(profileName)) {
+ profileURL = url;
+ break;
+ }
+ }
+ }
+ if (profileURL == null) {
+ // final: it may be url itself
+ try {
+ profileURL = new URL(profileName);
+ }
+ catch (MalformedURLException e) {
+ Logger.logException(e);
+ }
+ }
+ if (profileURL != null) {
+ try {
+ ProfileLoader.loadProfile(fMetaModel, profileURL.openStream(), fResourceBundle, fLogging);
+ }
+ catch (IOException e) {
+ Logger.logException("Cannot open stream for profile", //$NON-NLS-1$
+ e);
+ }
+ }
+ }
+
+ class TagNode {
+
+ String tag = null;
+ CSSMMNodeImpl node = null;
+
+ TagNode(String tag, CSSMMNodeImpl node) {
+ this.tag = tag;
+ this.node = node;
+ }
+ }
+
+ class ErrorCorrector {
+
+ void doCorrect(CSSMMNodeImpl node) {
+ Iterator i = node.getChildNodes();
+ ArrayList errorNodes = new ArrayList();
+ while (i.hasNext()) {
+ CSSMMNodeImpl child = (CSSMMNodeImpl) i.next();
+ doCorrect(child);
+ short error = child.getError();
+ if (error != MetaModelErrors.NO_ERROR) {
+ // node.removeChild(child);
+ errorNodes.add(child);
+
+ String str = "[CSSProfile Error] " + node.getName(); //$NON-NLS-1$
+ str += "(" + node.getType() + ") contains error node: "; //$NON-NLS-1$ //$NON-NLS-2$
+ str += child.getName() + "(" + child.getType() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ str += " - error code = " + error; //$NON-NLS-1$
+ if (fLogging) {
+ Logger.log(Logger.ERROR, str);
+ // System.out.println(str);
+ }
+ }
+ }
+ int errorSize = errorNodes.size();
+ if (errorSize > 0) {
+ for (int j = 0; j < errorSize; j++) {
+ CSSMMNodeImpl errorNode = (CSSMMNodeImpl) errorNodes.get(j);
+ node.removeChild(errorNode);
+ }
+ }
+ }
+ }
+
+
+ private CSSMetaModelImpl fMetaModel = null;
+ private NodePool fNodePool = null;
+ private Stack fNodeStack = new Stack();
+ boolean fLogging = false;
+ private ResourceBundle fResourceBundle = null;
+
+ private final static String ATTR_NAME_DEFINITION = "name"; //$NON-NLS-1$
+ private final static String ATTR_NAME_REFERENCE = "name"; //$NON-NLS-1$
+ private final static String ATTR_OVERWRITE = "overwrite"; //$NON-NLS-1$
+ private final static String ATTR_ENABLED = "enabled"; //$NON-NLS-1$
+ private final static String ATTR_VALUE_OVERWRITE_FALSE = "false"; //$NON-NLS-1$
+ private final static String ATTR_VALUE_ENABLED_FALSE = "false"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileKeywords.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileKeywords.java
new file mode 100644
index 0000000..a377136
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileKeywords.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+interface ProfileKeywords {
+
+ final static String CSS_PROFILE = "css-profile"; //$NON-NLS-1$
+ final static String PROFILE_IMPORT = "profile-import"; //$NON-NLS-1$
+ final static String STYLESHEET_DEF = "stylesheet-def"; //$NON-NLS-1$
+ final static String CHARSET_RULE = "charset-rule"; //$NON-NLS-1$
+ final static String IMPORT_RULE = "import-rule"; //$NON-NLS-1$
+ final static String PAGE_RULE = "page-rule"; //$NON-NLS-1$
+ final static String MEDIA_RULE = "media-rule"; //$NON-NLS-1$
+ final static String FONTFACE_RULE = "fontface-rule"; //$NON-NLS-1$
+ final static String STYLE_RULE = "style-rule"; //$NON-NLS-1$
+ final static String CHARSET_RULE_DEF = "charset-rule-def"; //$NON-NLS-1$
+ final static String IMPORT_RULE_DEF = "import-rule-def"; //$NON-NLS-1$
+ final static String PAGE_RULE_DEF = "page-rule-def"; //$NON-NLS-1$
+ final static String MEDIA_RULE_DEF = "media-rule-def"; //$NON-NLS-1$
+ final static String FONTFACE_RULE_DEF = "fontface-rule-def"; //$NON-NLS-1$
+ final static String STYLE_RULE_DEF = "style-rule-def"; //$NON-NLS-1$
+ final static String FUNCTION_DEF = "function-def"; //$NON-NLS-1$
+ final static String FUNCTION_VALUE = "function-value"; //$NON-NLS-1$
+ final static String KEYWORD_DEF = "keyword-def"; //$NON-NLS-1$
+ final static String KEYWORD_VALUE = "keyword-value"; //$NON-NLS-1$
+ final static String DESCRIPTION = "description"; //$NON-NLS-1$
+ final static String NUMBER_DEF = "number-def"; //$NON-NLS-1$
+ final static String UNIT = "unit"; //$NON-NLS-1$
+ final static String UNIT_DEF = "unit-def"; //$NON-NLS-1$
+ final static String UNIT_VALUE = "unit-value"; //$NON-NLS-1$
+ final static String CONTAINER_DEF = "container-def"; //$NON-NLS-1$
+ final static String CATEGORY_DEF = "category-def"; //$NON-NLS-1$
+ final static String CAPTION = "caption"; //$NON-NLS-1$
+ final static String PROPERTY_DEF = "property-def"; //$NON-NLS-1$
+ final static String DESCRIPTOR_DEF = "descriptor-def"; //$NON-NLS-1$
+ final static String SELECTOR_EXPRESSION = "selector-expression"; //$NON-NLS-1$
+ final static String PSEUDO_CLASS = "pseudo-class"; //$NON-NLS-1$
+ final static String PSEUDO_ELEMENT = "pseudo-element"; //$NON-NLS-1$
+ final static String PSEUDO_CLASS_DEF = "pseudo-class-def"; //$NON-NLS-1$
+ final static String PSEUDO_ELEMENT_DEF = "pseudo-element-def"; //$NON-NLS-1$
+ final static String SELECTOR_VALUE = "selector-value"; //$NON-NLS-1$
+ final static String NUMBER = "number"; //$NON-NLS-1$
+ final static String KEYWORD = "keyword"; //$NON-NLS-1$
+ final static String FUNCTION = "function"; //$NON-NLS-1$
+ final static String CONTAINER = "container"; //$NON-NLS-1$
+ final static String STRING = "string"; //$NON-NLS-1$
+ final static String SEPARATOR = "separator"; //$NON-NLS-1$
+ final static String PROPERTY = "property"; //$NON-NLS-1$
+ final static String DESCRIPTOR = "descriptor"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileLoader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileLoader.java
new file mode 100644
index 0000000..3442ab8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ProfileLoader.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ResourceBundle;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.metamodel.CSSMetaModel;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+
+
+class ProfileLoader {
+
+
+ /**
+ * Constructor for ProfileLoader.
+ */
+ private ProfileLoader() {
+ super();
+ }
+
+ ProfileLoader(ResourceBundle resourceBundle, boolean logging) {
+ this();
+ fResourceBundle = resourceBundle;
+ fLogging = logging;
+ }
+
+ static void loadProfile(CSSMetaModelImpl metamodel, InputStream input, ResourceBundle resourceBundle, boolean logging) {
+ try {
+ XMLReader xmlReader = XMLReaderUtil.createXMLReader(PARSER_NAME);
+ // XMLReaderFactory.createXMLReader(PARSER_NAME);
+ xmlReader.setContentHandler(new ProfileHandler(metamodel, resourceBundle, logging));
+ xmlReader.parse(new InputSource(input));
+ }
+ catch (IOException e) {
+ Logger.logException(e);
+ }
+ catch (SAXException e) {
+ Logger.logException(e);
+ }
+ }
+
+ CSSMetaModel loadProfile(InputStream input) {
+ if (fMetaModel == null) {
+ fMetaModel = new CSSMetaModelImpl();
+ }
+ loadProfile(fMetaModel, input, fResourceBundle, fLogging);
+ fMetaModel.loadCompleted();
+ return fMetaModel;
+ }
+
+
+ CSSMetaModelImpl fMetaModel = null;
+ private final static String PARSER_NAME = "org.apache.xerces.parsers.SAXParser"; //$NON-NLS-1$
+ private ResourceBundle fResourceBundle = null;
+ private boolean fLogging = false;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/RegistryReader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/RegistryReader.java
new file mode 100644
index 0000000..e4483df
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/RegistryReader.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.metamodel.CSSProfile;
+import org.osgi.framework.Bundle;
+
+
+
+public class RegistryReader {
+
+ //
+ private String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
+ private String EXTENSION_POINT_ID = "cssprofile"; //$NON-NLS-1$
+ private String TAG_NAME = "profile"; //$NON-NLS-1$
+ private String ATT_ID = "id"; //$NON-NLS-1$
+ private String ATT_NAME = "name"; //$NON-NLS-1$
+ private String ATT_URI = "uri"; //$NON-NLS-1$
+ private String ATT_DEFAULT = "default"; //$NON-NLS-1$
+ private String ATT_LOGGING = "logging"; // Hidden Option //$NON-NLS-1$
+
+ /**
+ * Constructor for CSSMetaModelRegistryReader.
+ */
+ public RegistryReader() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected CSSProfile readElement(IConfigurationElement element) {
+ CSSProfileImpl info = null;
+ if (element.getName().equals(TAG_NAME)) {
+ String strID = element.getAttribute(ATT_ID);
+ String strNAME = element.getAttribute(ATT_NAME);
+ String strURI = element.getAttribute(ATT_URI);
+
+ if (strID != null || strURI != null) {
+ Bundle bundle = null;
+ String pluginId = element.getContributor().getName();
+ bundle = Platform.getBundle(pluginId);
+ if (bundle != null) {
+ Path path = new Path(strURI);
+ URL url = FileLocator.find(bundle, path, null);
+ if (url != null) {
+ try {
+ url = FileLocator.toFileURL(url);
+ info = new CSSProfileImpl(strID, url, strURI);
+ info.setProfileName(strNAME);
+ info.setDefault((element.getAttribute(ATT_DEFAULT) != null));
+ info.setLogging((element.getAttribute(ATT_LOGGING) != null));
+ info.setOwnerPluginID(pluginId);
+ }
+ catch (java.io.IOException e) {
+ // through
+ }
+ }
+ }
+ }
+
+ if (info == null) {
+ Logger.log(Logger.ERROR, "Error reading CSS Profile: " + strID); //$NON-NLS-1$
+ }
+ }
+ return info;
+ }
+
+ /**
+ * We simply require an 'add' method, of what ever it is we are to read
+ * into
+ */
+ public Iterator enumProfiles() {
+ Set set = new HashSet();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
+ if (point != null) {
+ IConfigurationElement[] elements = point.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ CSSProfile info = readElement(elements[i]);
+ // null can be returned if there's an error reading the
+ // element
+ if (info != null) {
+ set.add(info);
+ }
+ }
+ }
+ return set.iterator();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ValueCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ValueCollector.java
new file mode 100644
index 0000000..7bb47ac
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/ValueCollector.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.metamodel.CSSMMNode;
+import org.eclipse.wst.css.core.internal.metamodel.util.CSSMetaModelTraverser;
+
+
+
+class ValueCollector extends CSSMetaModelTraverser {
+ public void begin(CSSMMNode node) {
+ fNodes = new ArrayList();
+ }
+
+ protected short preNode(CSSMMNode node) {
+ short rc = TRAV_CONT;
+ if (node != null) {
+ String type = node.getType();
+ if (type == CSSMMNode.TYPE_PROPERTY || type == CSSMMNode.TYPE_DESCRIPTOR || type == CSSMMNode.TYPE_CONTAINER) {
+ rc = TRAV_CONT;
+ }
+ else {
+ if (!fNodes.contains(node)) {
+ fNodes.add(node);
+ rc = TRAV_PRUNE;
+ }
+ }
+ }
+ return rc;
+ }
+
+ public Iterator getNodes() {
+ return fNodes.iterator();
+ }
+
+
+ private List fNodes = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/XMLReaderUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/XMLReaderUtil.java
new file mode 100644
index 0000000..b303190
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/metamodelimpl/XMLReaderUtil.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.metamodelimpl;
+
+
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+
+class XMLReaderUtil {
+
+ static public XMLReader createXMLReader(String className) throws SAXException {
+ try {
+ return SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+ }
+ catch (ParserConfigurationException e) {
+ Logger.logException(e);
+ }
+ catch (FactoryConfigurationError e) {
+ Logger.logException(e);
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/CSSModelLoader.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/CSSModelLoader.java
new file mode 100644
index 0000000..122a306
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/CSSModelLoader.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.modelhandler;
+
+
+import org.eclipse.wst.css.core.internal.document.CSSModelImpl;
+import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader;
+import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
+import org.eclipse.wst.sse.core.internal.model.AbstractModelLoader;
+import org.eclipse.wst.sse.core.internal.provisional.IModelLoader;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+
+/**
+ *
+ */
+public class CSSModelLoader extends AbstractModelLoader {
+ /**
+ * CSSLoader constructor comment.
+ */
+ public CSSModelLoader() {
+ super();
+ }
+
+ /*
+ * @see IModelLoader#newModel()
+ */
+ public IStructuredModel newModel() {
+ IStructuredModel model = new CSSModelImpl();
+ // now done in create
+ // model.setStructuredDocument(createNewStructuredDocument());
+ // model.setFactoryRegistry(defaultFactoryRegistry());
+ return model;
+ }
+
+ public IModelLoader newInstance() {
+ return new CSSModelLoader();
+ }
+
+ public IDocumentLoader getDocumentLoader() {
+ if (documentLoaderInstance == null) {
+ documentLoaderInstance = new CSSDocumentLoader();
+ }
+ return documentLoaderInstance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/ModelHandlerForCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/ModelHandlerForCSS.java
new file mode 100644
index 0000000..42003b4
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/modelhandler/ModelHandlerForCSS.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.modelhandler;
+
+import org.eclipse.wst.css.core.internal.encoding.CSSDocumentCharsetDetector;
+import org.eclipse.wst.css.core.internal.encoding.CSSDocumentLoader;
+import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector;
+import org.eclipse.wst.sse.core.internal.document.IDocumentLoader;
+import org.eclipse.wst.sse.core.internal.ltk.modelhandler.AbstractModelHandler;
+import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
+import org.eclipse.wst.sse.core.internal.provisional.IModelLoader;
+
+
+public class ModelHandlerForCSS extends AbstractModelHandler implements IModelHandler {
+
+ /**
+ * Needs to match what's in plugin registry. In fact, can be overwritten
+ * at run time with what's in registry! (so should never be 'final')
+ */
+ static String AssociatedContentTypeID = "org.eclipse.wst.css.core.csssource"; //$NON-NLS-1$
+ /**
+ * Needs to match what's in plugin registry. In fact, can be overwritten
+ * at run time with what's in registry! (so should never be 'final')
+ */
+ private static String ModelHandlerID = "org.eclipse.wst.css.core.modelhandler"; //$NON-NLS-1$
+
+ public ModelHandlerForCSS() {
+ super();
+ setId(ModelHandlerID);
+ setAssociatedContentTypeId(AssociatedContentTypeID);
+ }
+
+ public IDocumentCharsetDetector getEncodingDetector() {
+ return new CSSDocumentCharsetDetector();
+ }
+
+ public IDocumentLoader getDocumentLoader() {
+ return new CSSDocumentLoader();
+ }
+
+ /*
+ * @see ContentTypeDescription#getModelLoader()
+ */
+ public IModelLoader getModelLoader() {
+ return new CSSModelLoader();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSRegionUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSRegionUtil.java
new file mode 100644
index 0000000..1f12b95
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSRegionUtil.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parser;
+
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+
+
+public class CSSRegionUtil {
+
+ /**
+ */
+ public static boolean isDeclarationValueType(String type) {
+ return (type == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION || type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION || type == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH || type == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT || type == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || type == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR || type == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE || type == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE || type == CSSRegionContexts.CSS_DECLARATION_VALUE_S || type == CSSRegionContexts.CSS_DECLARATION_VALUE_STRING || type == CSSRegionContexts.CSS_DECLARATION_VALUE_UNICODE_RANGE || type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI);
+ }
+
+ /**
+ * these type can be beggining of selector
+ */
+ public static boolean isSelectorBegginingType(String type) {
+ return (type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_UNIVERSAL || type == CSSRegionContexts.CSS_SELECTOR_PSEUDO || type == CSSRegionContexts.CSS_SELECTOR_CLASS || type == CSSRegionContexts.CSS_SELECTOR_ID || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START);
+ }
+
+
+ /**
+ *
+ * @param type
+ * @return
+ */
+ public static boolean isDeclarationType(String type) {
+ return (type == CSSRegionContexts.CSS_DECLARATION_PROPERTY || type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR || isDeclarationValueType(type) || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER);
+ }
+
+ /**
+ * These types consist selector region
+ *
+ * @param type
+ * @return
+ */
+ public static boolean isSelectorType(String type) {
+ return (type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_END || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_NAME || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_OPERATOR || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_VALUE || type == CSSRegionContexts.CSS_SELECTOR_CLASS || type == CSSRegionContexts.CSS_SELECTOR_COMBINATOR || type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_ID || type == CSSRegionContexts.CSS_SELECTOR_PSEUDO || type == CSSRegionContexts.CSS_SELECTOR_SEPARATOR || type == CSSRegionContexts.CSS_SELECTOR_UNIVERSAL);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSSourceParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSSourceParser.java
new file mode 100644
index 0000000..831336f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSSourceParser.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parser;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.util.Debug;
+
+
+public class CSSSourceParser implements RegionParser {
+ public static final int MODE_STYLESHEET = 0;
+ public static final int MODE_DECLARATION = 1;
+ public static final int MODE_DECLARATION_VALUE = 2;
+
+ private long fStartTime;
+ private long fStopTime;
+ private ICSSTokenizer fTokenizer;
+
+ public void setParserMode(int mode) {
+ int initialState;
+ int bufsize;
+ switch (mode) {
+ case MODE_STYLESHEET :
+ initialState = CSSTokenizer.YYINITIAL;
+ bufsize = CSSTokenizer.BUFFER_SIZE_NORMAL;
+ break;
+ case MODE_DECLARATION :
+ initialState = CSSTokenizer.ST_DECLARATION;
+ bufsize = CSSTokenizer.BUFFER_SIZE_NORMAL;
+ break;
+ case MODE_DECLARATION_VALUE :
+ initialState = CSSTokenizer.ST_DECLARATION_PRE_VALUE;
+ bufsize = CSSTokenizer.BUFFER_SIZE_SMALL;
+ break;
+ default :
+ return;
+ }
+ if (0 < initialState) {
+ ICSSTokenizer tokenizer = getTokenizer();
+ tokenizer.setInitialState(initialState);
+ tokenizer.setInitialBufferSize(bufsize);
+ }
+ }
+
+ public IStructuredDocumentRegion getDocumentRegions() {
+ IStructuredDocumentRegion headnode = null;
+ if (headnode == null) {
+ if (Debug.perfTest) {
+ fStartTime = System.currentTimeMillis();
+ }
+ headnode = parseNodes();
+ if (Debug.perfTest) {
+ fStopTime = System.currentTimeMillis();
+ System.out.println(" -- creating nodes of IStructuredDocument -- "); //$NON-NLS-1$
+ System.out.println(" Time parse and init all regions: " + (fStopTime - fStartTime) + " (msecs)"); //$NON-NLS-2$//$NON-NLS-1$
+ // System.out.println(" for " + fRegions.size() + "
+ // Regions");//$NON-NLS-2$//$NON-NLS-1$
+ System.out.println(" and " + _countNodes(headnode) + " Nodes"); //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+ return headnode;
+ }
+
+ public List getRegions() {
+ IStructuredDocumentRegion headNode = null;
+ if (!getTokenizer().isEOF()) {
+ headNode = getDocumentRegions();
+ // throw new IllegalStateException("parsing has not finished");
+ }
+ // for memory recovery, we assume if someone
+ // requests all regions, we can reset our big
+ // memory consuming objects
+ // but the new "getRegions" method is then more expensive.
+ // I don't think its used much, though.
+ List localRegionsList = getRegions(headNode);
+ primReset();
+ return localRegionsList;
+ }
+
+ /**
+ * Method getRegions.
+ *
+ * @param headNode
+ * @return List
+ */
+ protected List getRegions(IStructuredDocumentRegion headNode) {
+ List allRegions = new ArrayList();
+ IStructuredDocumentRegion currentNode = headNode;
+ while (currentNode != null) {
+ ITextRegionList nodeRegions = currentNode.getRegions();
+ for (int i = 0; i < nodeRegions.size(); i++) {
+ allRegions.add(nodeRegions.get(i));
+ }
+ currentNode = currentNode.getNext();
+ }
+ return allRegions;
+ }
+
+ public void reset(Reader reader) {
+ primReset();
+ getTokenizer().reset(reader, 0);
+ }
+
+ public void reset(Reader reader, int offset) {
+ reset(reader);
+ }
+
+ public void reset(String input) {
+ reset(new StringReader(input));
+ }
+
+ public void reset(String input, int offset) {
+ reset(input);
+ }
+
+ public RegionParser newInstance() {
+ return new CSSSourceParser();
+ }
+
+ private IStructuredDocumentRegion parseNodes() {
+ // regions are initially reported as complete offsets within the
+ // scanned input
+ // they are adjusted here to be indexes from the currentNode's start
+ // offset
+ IStructuredDocumentRegion headNode = null;
+ IStructuredDocumentRegion lastNode = null;
+ ITextRegion region = null;
+ IStructuredDocumentRegion currentNode = null;
+ String type = null;
+ String currentRegionType = null;
+
+ while ((region = getNextRegion()) != null) {
+ type = region.getType();
+ if (mustBeStart(type, currentRegionType) && currentNode != null) {
+ currentNode.setEnded(true);
+ }
+
+ if ((currentNode != null && currentNode.isEnded()) || currentNode == null) {
+ if (currentNode != null && !currentNode.isEnded()) {
+ currentNode.setEnded(true);
+ }
+ lastNode = currentNode;
+ currentNode = createStructuredDocumentRegion(type);
+ currentRegionType = type;
+ if (lastNode != null) {
+ lastNode.setNext(currentNode);
+ }
+ currentNode.setPrevious(lastNode);
+ currentNode.setStart(region.getStart());
+ }
+
+ currentNode.addRegion(region);
+ currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
+ region.adjustStart(-currentNode.getStart());
+
+ if (mustBeEnd(type)) {
+ currentNode.setEnded(true);
+ }
+
+ if (headNode == null && currentNode != null) {
+ headNode = currentNode;
+ }
+ }
+
+ if (currentNode != null && !currentNode.isEnded()) {
+ currentNode.setEnded(true);
+ }
+
+ primReset();
+ return headNode;
+ }
+
+ private IStructuredDocumentRegion createStructuredDocumentRegion(String type) {
+ return CSSStructuredDocumentRegionFactory.createRegion(type);
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ protected boolean mustBeStart(String type, String docRegionType) {
+ return ((type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_LBRACE || type == CSSRegionContexts.CSS_RBRACE || type == CSSRegionContexts.CSS_IMPORT || type == CSSRegionContexts.CSS_PAGE || type == CSSRegionContexts.CSS_MEDIA || type == CSSRegionContexts.CSS_FONT_FACE || type == CSSRegionContexts.CSS_CHARSET || type == CSSRegionContexts.CSS_ATKEYWORD || type == CSSRegionContexts.CSS_DECLARATION_PROPERTY || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER) || (docRegionType == CSSRegionContexts.CSS_DECLARATION_PROPERTY && type == CSSRegionContexts.CSS_S) || (!CSSRegionUtil.isSelectorBegginingType(docRegionType) && (type == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || type == CSSRegionContexts.CSS_SELECTOR_UNIVERSAL || type == CSSRegionContexts.CSS_SELECTOR_PSEUDO || type == CSSRegionContexts.CSS_SELECTOR_CLASS || type == CSSRegionContexts.CSS_SELECTOR_ID || type == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START)));
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ protected boolean mustBeEnd(String type) {
+ return (type == CSSRegionContexts.CSS_DELIMITER || type == CSSRegionContexts.CSS_LBRACE || type == CSSRegionContexts.CSS_RBRACE || type == CSSRegionContexts.CSS_DECLARATION_DELIMITER);
+ }
+
+ private ITextRegion getNextRegion() {
+ ITextRegion region = null;
+ try {
+ region = getTokenizer().getNextToken();
+ // DMW: 2/12/03 Removed state
+ // if (region != null) {
+ // fRegions.add(region);
+ // }
+ return region;
+ }
+ catch (StackOverflowError e) {
+ Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset(), e); //$NON-NLS-1$
+ throw e;
+ }
+ catch (Exception e) {
+ Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset() + " (" + e.getLocalizedMessage() + ")", e); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+ return null;
+ }
+
+ private void primReset() {
+
+ getTokenizer().reset(new char[0]);
+ }
+ /**
+ * currently public but may be made default access protected in future.
+ */
+ public ICSSTokenizer getTokenizer() {
+ if (fTokenizer == null) {
+ fTokenizer = new CSSTokenizer();
+ }
+ return fTokenizer;
+ }
+
+
+ /**
+ * This is a simple utility to count nodes. Used only for debug
+ * statements.
+ */
+ private int _countNodes(IStructuredDocumentRegion nodes) {
+ int result = 0;
+ IStructuredDocumentRegion countNode = nodes;
+ while (countNode != null) {
+ result++;
+ countNode = countNode.getNext();
+ }
+ return result;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSStructuredDocumentRegionFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSStructuredDocumentRegionFactory.java
new file mode 100644
index 0000000..bd9f233
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSStructuredDocumentRegionFactory.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parser;
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion;
+
+public class CSSStructuredDocumentRegionFactory {
+ public static IStructuredDocumentRegion createRegion(String type) {
+ IStructuredDocumentRegion instance = null;
+ if (type != null) {
+ instance = new BasicStructuredDocumentRegion();
+ }
+ else {
+
+ }
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSTokenizer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSTokenizer.java
new file mode 100644
index 0000000..a7acd5d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/CSSTokenizer.java
@@ -0,0 +1,1942 @@
+/* The following code was generated by JFlex 1.4.2 on 12/21/10 5:05 PM */
+
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*nlsXXX*/
+package org.eclipse.wst.css.core.internal.parser;
+
+import java.io.CharArrayReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.parser.regions.CSSTextRegionFactory;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+
+/**
+ * This class is a scanner generated by
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.2
+ * on 12/21/10 5:05 PM from the specification file
+ * <tt>D:/dev/workspaces/helios/org.eclipse.wst.sse.core/DevTimeSupport/SedModel/CSSTokenizer/devel/CSSTokenizer.jflex</tt>
+ */
+public class CSSTokenizer implements CSSRegionContexts, ICSSTokenizer {
+
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+ private static final int ZZ_BUFFERSIZE = 16384;
+
+ /** lexical states */
+ public static final int ST_SELECTOR_ATTRIBUTE_NAME = 26;
+ public static final int ST_IMPORT_DELIMITER = 10;
+ public static final int ST_DECLARATION_PRE_VALUE = 38;
+ public static final int ST_SELECTOR = 22;
+ public static final int ST_CHARSET_DELIMITER = 4;
+ public static final int ST_DECLARATION_VALUE = 40;
+ public static final int ST_PAGE_PSEUDO_PAGE = 16;
+ public static final int ST_IMPORT_URI = 6;
+ public static final int ST_SELECTOR_ATTRIBUTE_END = 32;
+ public static final int ST_SELECTOR_ATTRIBUTE_OPERATOR = 28;
+ public static final int ST_DECLARATION = 34;
+ public static final int ST_PAGE_DELIMITER = 18;
+ public static final int ST_SELECTOR_ATTRIBUTE_VALUE = 30;
+ public static final int ST_MEDIA_MEDIUM = 12;
+ public static final int ST_CHARSET_NAME = 2;
+ public static final int ST_IMPORT_MEDIUM = 8;
+ public static final int ST_DECLARATION_SEPARATOR = 36;
+ public static final int ST_FONT_FACE_DELIMITER = 20;
+ public static final int ST_MEDIA_DELIMITER = 14;
+ public static final int ST_SELECTOR_MODIFIER = 24;
+ public static final int YYINITIAL = 0;
+
+ /**
+ * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+ * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+ * at the beginning of a line
+ * l is of the form l = 2*k, k a non negative integer
+ */
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
+ 8, 8, 9, 9, 9, 9, 0, 0, 10, 10, 11, 11, 12, 12, 13, 13,
+ 14, 14, 15, 15, 16, 16, 17, 17, 18, 18
+ };
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\12\1\17\1\0\1\4\1\20\22\0\1\6\1\31\1\11"+
+ "\1\21\1\16\1\73\1\16\1\5\1\25\1\13\1\35\1\15\1\55"+
+ "\1\10\1\14\1\34\12\1\1\62\1\50\1\30\1\70\1\32\1\27"+
+ "\1\36\1\43\1\26\1\40\1\57\1\46\1\64\1\61\1\41\1\51"+
+ "\2\66\1\24\1\52\1\65\1\54\1\53\1\66\1\23\1\44\1\47"+
+ "\1\22\5\66\1\67\1\3\1\72\1\16\1\2\1\16\1\42\1\7"+
+ "\1\37\1\56\1\45\1\63\1\61\1\41\1\51\2\66\1\24\1\52"+
+ "\1\65\1\54\1\53\1\66\1\23\1\44\1\47\1\22\5\66\1\60"+
+ "\1\71\1\33\1\71\1\0\uff80\2";
+
+ /**
+ * Translates characters to character classes
+ */
+ private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+ /**
+ * Translates DFA states to action switch labels.
+ */
+ private static final int [] ZZ_ACTION = zzUnpackAction();
+
+ private static final String ZZ_ACTION_PACKED_0 =
+ "\23\0\1\1\1\2\1\1\1\3\4\1\1\4\1\1"+
+ "\1\5\1\1\1\6\1\7\3\1\1\10\3\1\1\11"+
+ "\2\1\1\12\1\13\2\1\1\14\1\15\1\16\2\1"+
+ "\1\17\1\1\1\3\1\20\1\21\1\22\2\1\1\23"+
+ "\1\1\1\24\1\25\4\1\1\26\3\1\1\27\1\30"+
+ "\1\31\1\32\4\1\1\33\3\1\1\32\1\1\2\34"+
+ "\1\3\1\0\1\2\1\0\1\35\1\0\1\36\10\0"+
+ "\1\6\4\0\1\37\4\0\1\40\4\0\1\11\1\0"+
+ "\1\13\1\0\1\16\1\0\1\41\1\0\1\22\1\0"+
+ "\1\25\2\0\1\25\3\0\1\26\1\0\1\42\3\0"+
+ "\1\43\1\0\1\32\1\44\1\32\2\0\1\45\2\0"+
+ "\1\31\1\46\2\0\1\32\2\0\1\47\1\2\1\50"+
+ "\1\35\1\36\10\0\1\6\1\0\1\37\2\0\1\37"+
+ "\2\0\1\40\2\0\1\40\2\0\1\11\1\13\1\16"+
+ "\1\22\1\25\1\0\1\25\2\0\1\25\1\0\1\26"+
+ "\1\42\1\32\1\0\1\32\1\0\1\45\2\0\1\45"+
+ "\1\0\1\46\1\51\1\32\1\0\1\2\1\35\1\36"+
+ "\1\52\1\53\5\0\2\6\5\0\1\11\1\13\1\16"+
+ "\1\22\1\25\2\0\1\26\1\42\2\32\2\0\1\46"+
+ "\1\51\1\0\1\44\1\0\1\2\1\35\1\36\3\0"+
+ "\1\54\1\0\1\6\10\0\1\55\1\11\1\13\1\16"+
+ "\1\22\1\25\2\0\1\26\1\42\2\32\2\0\1\46"+
+ "\2\51\5\0\1\56\1\0\1\2\1\35\1\36\2\0"+
+ "\1\57\1\0\1\6\6\0\1\55\2\0\1\11\1\13"+
+ "\1\16\1\22\1\25\2\0\1\26\1\42\2\32\2\0"+
+ "\1\46\2\51\2\0\1\56\3\0\1\2\1\35\1\36"+
+ "\1\0\1\60\1\0\1\6\13\0\1\11\1\13\1\16"+
+ "\1\22\1\25\2\0\1\26\1\42\2\32\2\0\1\46"+
+ "\2\51\10\0\1\35\1\36\1\61\1\0\1\6\6\0"+
+ "\1\55\1\0\1\55\2\0\1\42\1\32\2\0\1\46"+
+ "\2\51\2\0\1\56\1\0\1\56\5\0\1\32\1\51"+
+ "\4\0\1\62\3\0\1\51\3\0\1\63\12\0";
+
+ private static int [] zzUnpackAction() {
+ int [] result = new int[426];
+ int offset = 0;
+ offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAction(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /**
+ * Translates a state to a row index in the transition table
+ */
+ private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+ private static final String ZZ_ROWMAP_PACKED_0 =
+ "\0\0\0\74\0\170\0\264\0\360\0\u012c\0\u0168\0\u01a4"+
+ "\0\u01e0\0\u021c\0\u0258\0\u0294\0\u02d0\0\u030c\0\u0348\0\u0384"+
+ "\0\u03c0\0\u03fc\0\u0438\0\u0474\0\u04b0\0\u04ec\0\u0528\0\u0564"+
+ "\0\u05a0\0\u05dc\0\u0618\0\u0474\0\u0654\0\u0474\0\u0690\0\u06cc"+
+ "\0\u0474\0\u0708\0\u0744\0\u0780\0\u0474\0\u07bc\0\u07f8\0\u0834"+
+ "\0\u0870\0\u08ac\0\u08e8\0\u0474\0\u0924\0\u0960\0\u099c\0\u0474"+
+ "\0\u0474\0\u09d8\0\u0a14\0\u0a50\0\u0474\0\u0a8c\0\u0ac8\0\u0474"+
+ "\0\u0474\0\u0b04\0\u0b40\0\u0b7c\0\u0474\0\u0bb8\0\u0474\0\u0bf4"+
+ "\0\u0c30\0\u0c6c\0\u0ca8\0\u0ce4\0\u0d20\0\u0d5c\0\u0d98\0\u0dd4"+
+ "\0\u0474\0\u0474\0\u0e10\0\u0e4c\0\u0e88\0\u0ec4\0\u0f00\0\u0f3c"+
+ "\0\u0474\0\u0f78\0\u0fb4\0\u0ff0\0\u102c\0\u1068\0\u0654\0\u0474"+
+ "\0\u10a4\0\u04ec\0\u10e0\0\u111c\0\u05a0\0\u1158\0\u05dc\0\u1194"+
+ "\0\u11d0\0\u120c\0\u1248\0\u1284\0\u12c0\0\u12fc\0\u1338\0\u1374"+
+ "\0\u13b0\0\u13ec\0\u0708\0\u1428\0\u0474\0\u0780\0\u1464\0\u07bc"+
+ "\0\u14a0\0\u0474\0\u07f8\0\u14dc\0\u1518\0\u08ac\0\u1554\0\u0960"+
+ "\0\u1590\0\u0a14\0\u15cc\0\u1608\0\u0474\0\u0b40\0\u1644\0\u0c30"+
+ "\0\u1680\0\u0c6c\0\u16bc\0\u0474\0\u0ce4\0\u16f8\0\u0d5c\0\u1734"+
+ "\0\u1770\0\u17ac\0\u17e8\0\u1824\0\u0f78\0\u0474\0\u0e88\0\u1860"+
+ "\0\u0474\0\u189c\0\u0ec4\0\u18d8\0\u0474\0\u0f3c\0\u1914\0\u1950"+
+ "\0\u0ff0\0\u198c\0\u19c8\0\u1a04\0\u1068\0\u1a40\0\u0474\0\u1a7c"+
+ "\0\u0474\0\u1ab8\0\u1af4\0\u1b30\0\u1b6c\0\u1ba8\0\u1be4\0\u1c20"+
+ "\0\u1c5c\0\u1c98\0\u1cd4\0\u1d10\0\u1d4c\0\u0708\0\u1d88\0\u1dc4"+
+ "\0\u0780\0\u1e00\0\u1e3c\0\u07bc\0\u1e78\0\u1eb4\0\u07f8\0\u1ef0"+
+ "\0\u1f2c\0\u1f68\0\u1fa4\0\u1fe0\0\u201c\0\u2058\0\u2094\0\u0c6c"+
+ "\0\u20d0\0\u210c\0\u0ce4\0\u2148\0\u2184\0\u21c0\0\u21fc\0\u2238"+
+ "\0\u2274\0\u22b0\0\u0ec4\0\u22ec\0\u2328\0\u0f3c\0\u2364\0\u23a0"+
+ "\0\u23dc\0\u2418\0\u2454\0\u2490\0\u24cc\0\u2508\0\u0474\0\u0474"+
+ "\0\u2544\0\u2580\0\u25bc\0\u25f8\0\u2634\0\u0474\0\u2670\0\u26ac"+
+ "\0\u26e8\0\u2724\0\u2760\0\u279c\0\u27d8\0\u2814\0\u2850\0\u288c"+
+ "\0\u28c8\0\u2904\0\u2940\0\u297c\0\u29b8\0\u29f4\0\u2a30\0\u2a6c"+
+ "\0\u2aa8\0\u2ae4\0\u2b20\0\u2b5c\0\u2b98\0\u2bd4\0\u2c10\0\u2c4c"+
+ "\0\u2c88\0\u2cc4\0\u2d00\0\u2d3c\0\u0474\0\u2d78\0\u2db4\0\u2df0"+
+ "\0\u2e2c\0\u2e68\0\u2ea4\0\u2ee0\0\u2f1c\0\u2f58\0\u2f94\0\u0474"+
+ "\0\u2fd0\0\u300c\0\u3048\0\u3084\0\u30c0\0\u30fc\0\u3138\0\u3174"+
+ "\0\u31b0\0\u31ec\0\u3228\0\u3264\0\u32a0\0\u32dc\0\u3318\0\u3354"+
+ "\0\u3390\0\u33cc\0\u2b98\0\u3408\0\u3444\0\u0474\0\u3480\0\u34bc"+
+ "\0\u34f8\0\u3534\0\u3570\0\u35ac\0\u0474\0\u35e8\0\u3624\0\u3660"+
+ "\0\u369c\0\u36d8\0\u3714\0\u3750\0\u378c\0\u2ee0\0\u37c8\0\u3804"+
+ "\0\u3840\0\u387c\0\u38b8\0\u38f4\0\u3930\0\u396c\0\u39a8\0\u39e4"+
+ "\0\u3a20\0\u3a5c\0\u3a98\0\u3ad4\0\u3b10\0\u3b4c\0\u3b88\0\u3bc4"+
+ "\0\u3c00\0\u3c3c\0\u3390\0\u3c78\0\u3cb4\0\u3cf0\0\u3d2c\0\u3d68"+
+ "\0\u3da4\0\u3de0\0\u0474\0\u3e1c\0\u3e58\0\u3e94\0\u3ed0\0\u3f0c"+
+ "\0\u3f48\0\u3f84\0\u3fc0\0\u3ffc\0\u4038\0\u4074\0\u40b0\0\u40ec"+
+ "\0\u4128\0\u4164\0\u41a0\0\u41dc\0\u4218\0\u4254\0\u4290\0\u42cc"+
+ "\0\u4308\0\u4344\0\u4380\0\u43bc\0\u43f8\0\u4434\0\u4470\0\u44ac"+
+ "\0\u44e8\0\u4524\0\u4560\0\u459c\0\u45d8\0\u4614\0\u4650\0\u468c"+
+ "\0\u46c8\0\u4704\0\u0474\0\u4740\0\u477c\0\u47b8\0\u47f4\0\u4830"+
+ "\0\u486c\0\u48a8\0\u48e4\0\u2f58\0\u4920\0\u2f94\0\u495c\0\u4998"+
+ "\0\u49d4\0\u4a10\0\u4a4c\0\u4a88\0\u4ac4\0\u4b00\0\u4b3c\0\u4b78"+
+ "\0\u4bb4\0\u3408\0\u4bf0\0\u3444\0\u4c2c\0\u4c68\0\u4ca4\0\u4ce0"+
+ "\0\u4d1c\0\u4d58\0\u4d94\0\u4dd0\0\u4e0c\0\u4e48\0\u4e84\0\u0474"+
+ "\0\u4ec0\0\u4efc\0\u4f38\0\u0474\0\u4f74\0\u4fb0\0\u4fec\0\u0474"+
+ "\0\u5028\0\u5064\0\u50a0\0\u50dc\0\u5118\0\u5154\0\u5190\0\u51cc"+
+ "\0\u5208\0\u5244";
+
+ private static int [] zzUnpackRowMap() {
+ int [] result = new int[426];
+ int offset = 0;
+ offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int high = packed.charAt(i++) << 16;
+ result[j++] = high | packed.charAt(i++);
+ }
+ return j;
+ }
+
+ /**
+ * The transition table of the DFA
+ */
+ private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+ private static final String ZZ_TRANS_PACKED_0 =
+ "\2\24\1\25\1\26\1\27\1\24\1\27\1\25\1\30"+
+ "\1\24\1\27\1\24\1\31\2\24\2\27\1\32\3\25"+
+ "\1\24\1\25\1\24\1\33\2\24\1\34\1\35\1\36"+
+ "\1\37\11\25\1\24\4\25\1\24\2\25\1\24\1\25"+
+ "\1\40\4\25\1\41\10\24\1\27\1\42\1\27\1\24"+
+ "\1\43\1\44\1\27\4\24\2\27\7\24\1\33\2\24"+
+ "\1\34\1\35\1\24\1\37\41\24\1\27\1\24\1\27"+
+ "\1\24\1\43\1\24\1\27\4\24\2\27\7\24\1\33"+
+ "\2\24\1\34\1\35\1\24\1\37\11\24\1\45\27\24"+
+ "\1\27\1\46\1\27\1\24\1\43\1\47\1\27\4\24"+
+ "\2\27\1\24\1\50\5\24\1\33\2\24\1\34\1\35"+
+ "\1\24\1\37\11\24\1\45\25\24\1\51\1\52\1\27"+
+ "\1\24\1\27\1\51\1\53\1\24\1\27\4\24\2\27"+
+ "\1\24\3\51\1\24\1\51\1\24\1\33\2\24\1\34"+
+ "\1\35\1\24\1\37\11\51\1\45\4\51\1\24\2\51"+
+ "\1\24\1\51\1\24\4\51\11\24\1\27\1\24\1\27"+
+ "\1\24\1\43\1\24\1\27\4\24\2\27\7\24\1\33"+
+ "\2\24\1\34\1\35\1\24\1\37\11\24\1\45\4\24"+
+ "\1\54\20\24\1\55\1\56\1\27\1\24\1\27\1\55"+
+ "\1\57\1\24\1\27\4\24\2\27\1\24\3\55\1\24"+
+ "\1\55\1\24\1\33\2\24\1\34\1\35\1\24\1\37"+
+ "\11\55\1\24\4\55\1\24\2\55\1\60\1\55\1\24"+
+ "\4\55\11\24\1\27\1\24\1\27\1\24\1\43\1\24"+
+ "\1\27\4\24\2\27\7\24\1\33\2\24\1\34\1\35"+
+ "\1\24\1\37\16\24\1\61\2\24\1\60\15\24\1\62"+
+ "\1\63\1\27\1\24\1\27\1\62\1\64\1\24\1\27"+
+ "\4\24\2\27\1\24\3\62\1\24\1\62\1\24\1\33"+
+ "\2\24\1\34\1\35\1\24\1\37\11\62\1\24\4\62"+
+ "\1\24\2\62\1\65\1\62\1\66\4\62\11\24\1\27"+
+ "\1\24\1\27\1\24\1\43\1\24\1\27\4\24\2\27"+
+ "\7\24\1\33\2\24\1\34\1\35\1\24\1\37\21\24"+
+ "\1\65\17\24\1\67\1\24\1\67\1\24\1\43\1\24"+
+ "\1\67\1\24\1\31\1\70\1\24\2\67\1\32\6\24"+
+ "\1\33\1\24\1\70\1\34\1\35\1\36\1\37\16\24"+
+ "\1\71\2\24\1\65\1\24\1\40\4\24\1\41\6\24"+
+ "\1\72\1\73\1\27\1\24\1\27\1\72\1\74\1\24"+
+ "\1\27\4\24\2\27\1\24\3\72\1\24\1\72\1\24"+
+ "\1\33\2\24\1\34\1\35\1\24\1\37\11\72\1\24"+
+ "\4\72\1\24\2\72\1\24\1\72\1\24\4\72\11\24"+
+ "\1\27\1\24\1\27\1\24\1\43\1\24\1\27\4\24"+
+ "\2\27\7\24\1\33\2\24\1\34\1\35\1\24\1\37"+
+ "\31\24\1\75\1\76\1\77\3\24\1\100\1\101\1\27"+
+ "\1\102\1\27\1\100\1\103\1\104\1\27\4\24\2\27"+
+ "\1\24\3\100\1\24\1\100\1\24\1\33\2\24\1\34"+
+ "\1\35\1\24\1\37\11\100\1\24\4\100\1\24\2\100"+
+ "\1\24\1\100\1\24\4\100\11\24\1\27\1\24\1\27"+
+ "\1\24\1\43\1\24\1\27\4\24\2\27\7\24\1\33"+
+ "\2\24\1\34\1\35\1\24\1\37\33\24\1\77\3\24"+
+ "\1\105\1\106\1\27\1\24\1\27\1\105\1\107\1\24"+
+ "\1\27\4\24\2\27\1\24\3\105\1\24\1\105\1\24"+
+ "\1\33\2\24\1\34\1\35\1\110\1\37\11\105\1\111"+
+ "\4\105\1\24\2\105\1\24\1\105\1\24\4\105\11\24"+
+ "\1\27\1\24\1\27\1\24\1\43\1\24\1\27\4\24"+
+ "\2\27\7\24\1\33\2\24\1\34\1\35\1\24\1\37"+
+ "\11\24\1\111\11\24\1\112\12\24\1\113\1\114\1\115"+
+ "\1\27\1\116\1\27\1\114\1\117\1\120\1\27\1\121"+
+ "\1\122\1\123\1\24\2\27\1\124\1\125\2\114\1\24"+
+ "\1\114\1\24\1\33\1\126\1\24\1\34\1\127\1\24"+
+ "\1\37\11\114\1\111\4\114\1\130\2\114\1\24\1\114"+
+ "\1\24\4\114\6\24\1\113\1\114\1\115\1\131\1\116"+
+ "\1\131\1\114\1\117\1\120\1\131\1\121\1\122\1\123"+
+ "\1\24\2\131\1\124\1\125\2\114\1\24\1\114\1\24"+
+ "\1\33\1\126\1\24\1\34\1\127\1\24\1\37\11\114"+
+ "\1\111\4\114\1\130\2\114\1\24\1\114\1\24\4\114"+
+ "\5\24\75\0\2\25\1\132\3\0\2\25\11\0\3\25"+
+ "\1\0\1\25\10\0\11\25\1\0\4\25\1\0\2\25"+
+ "\1\0\1\25\1\0\4\25\6\0\1\133\2\25\1\0"+
+ "\2\25\1\133\2\25\1\0\4\25\2\0\16\25\1\133"+
+ "\2\25\1\133\2\25\1\133\10\25\1\133\4\25\1\133"+
+ "\10\25\4\0\1\27\1\0\1\27\3\0\1\27\4\0"+
+ "\2\27\55\0\1\25\1\132\3\0\1\25\1\134\11\0"+
+ "\3\25\1\0\1\25\10\0\11\25\1\0\4\25\1\0"+
+ "\2\25\1\0\1\25\1\0\4\25\6\0\2\135\1\136"+
+ "\3\0\2\135\11\0\3\135\1\0\1\135\10\0\11\135"+
+ "\1\0\4\135\1\0\2\135\1\0\1\135\1\0\4\135"+
+ "\6\0\2\137\1\140\3\0\2\137\11\0\3\137\1\0"+
+ "\1\137\10\0\11\137\1\0\4\137\1\0\2\137\1\0"+
+ "\1\137\1\0\4\137\36\0\1\141\77\0\1\142\75\0"+
+ "\2\143\10\0\1\144\1\145\1\146\7\0\2\147\11\0"+
+ "\1\150\1\151\3\0\1\150\1\152\11\0\3\150\1\0"+
+ "\1\150\10\0\11\150\1\0\4\150\1\0\2\150\1\0"+
+ "\1\150\1\0\4\150\6\0\2\153\1\154\1\0\1\155"+
+ "\11\153\2\0\53\153\10\0\1\134\64\0\2\156\1\157"+
+ "\1\0\4\156\1\155\5\156\2\0\53\156\1\0\2\160"+
+ "\1\161\1\0\1\162\11\160\2\0\53\160\1\0\2\163"+
+ "\1\164\1\0\4\163\1\162\5\163\2\0\53\163\23\0"+
+ "\1\165\51\0\2\51\1\166\3\0\2\51\11\0\3\51"+
+ "\1\0\1\51\10\0\11\51\1\0\4\51\1\0\2\51"+
+ "\1\0\1\51\1\0\4\51\6\0\1\167\2\51\1\0"+
+ "\2\51\1\167\2\51\1\0\4\51\2\0\16\51\1\167"+
+ "\2\51\1\167\2\51\1\167\10\51\1\167\4\51\1\167"+
+ "\10\51\2\0\1\51\1\166\3\0\1\51\1\134\11\0"+
+ "\3\51\1\0\1\51\10\0\11\51\1\0\4\51\1\0"+
+ "\2\51\1\0\1\51\1\0\4\51\6\0\2\55\1\170"+
+ "\3\0\2\55\11\0\3\55\1\0\1\55\10\0\11\55"+
+ "\1\0\4\55\1\0\2\55\1\0\1\55\1\0\4\55"+
+ "\6\0\1\171\2\55\1\0\2\55\1\171\2\55\1\0"+
+ "\4\55\2\0\16\55\1\171\2\55\1\171\2\55\1\171"+
+ "\10\55\1\171\4\55\1\171\10\55\2\0\1\55\1\170"+
+ "\3\0\1\55\1\134\11\0\3\55\1\0\1\55\10\0"+
+ "\11\55\1\0\4\55\1\0\2\55\1\0\1\55\1\0"+
+ "\4\55\6\0\2\62\1\172\3\0\2\62\11\0\3\62"+
+ "\1\0\1\62\10\0\11\62\1\0\4\62\1\0\2\62"+
+ "\1\0\1\62\1\0\4\62\6\0\1\173\2\62\1\0"+
+ "\2\62\1\173\2\62\1\0\4\62\2\0\16\62\1\173"+
+ "\2\62\1\173\2\62\1\173\10\62\1\173\4\62\1\173"+
+ "\10\62\2\0\1\62\1\172\3\0\1\62\1\134\11\0"+
+ "\3\62\1\0\1\62\10\0\11\62\1\0\4\62\1\0"+
+ "\2\62\1\0\1\62\1\0\4\62\7\0\1\62\1\172"+
+ "\3\0\1\62\1\174\11\0\3\62\1\0\1\62\10\0"+
+ "\11\62\1\0\4\62\1\0\2\62\1\0\1\62\1\0"+
+ "\4\62\5\0\4\175\1\67\1\175\1\67\3\175\1\67"+
+ "\2\175\1\0\1\175\2\67\11\175\1\0\1\175\1\0"+
+ "\20\175\1\0\2\175\1\0\13\175\1\0\2\72\1\176"+
+ "\3\0\2\72\11\0\3\72\1\0\1\72\10\0\11\72"+
+ "\1\0\4\72\1\0\2\72\1\0\1\72\1\0\4\72"+
+ "\6\0\1\177\2\72\1\0\2\72\1\177\2\72\1\0"+
+ "\4\72\2\0\16\72\1\177\2\72\1\177\2\72\1\177"+
+ "\10\72\1\177\4\72\1\177\10\72\2\0\1\72\1\176"+
+ "\3\0\1\72\1\134\11\0\3\72\1\0\1\72\10\0"+
+ "\11\72\1\0\4\72\1\0\2\72\1\0\1\72\1\0"+
+ "\4\72\75\0\1\75\4\0\2\100\1\200\3\0\2\100"+
+ "\11\0\3\100\1\0\1\100\10\0\11\100\1\0\4\100"+
+ "\1\0\2\100\1\0\1\100\1\0\4\100\6\0\1\201"+
+ "\2\100\1\0\2\100\1\201\2\100\1\0\4\100\2\0"+
+ "\16\100\1\201\2\100\1\201\2\100\1\201\10\100\1\201"+
+ "\4\100\1\201\10\100\1\0\2\202\1\203\1\0\1\204"+
+ "\11\202\2\0\53\202\2\0\1\100\1\200\3\0\1\100"+
+ "\1\134\11\0\3\100\1\0\1\100\10\0\11\100\1\0"+
+ "\4\100\1\0\2\100\1\0\1\100\1\0\4\100\6\0"+
+ "\2\205\1\206\1\0\4\205\1\204\5\205\2\0\53\205"+
+ "\1\0\2\105\1\207\3\0\2\105\11\0\3\105\1\0"+
+ "\1\105\10\0\11\105\1\0\4\105\1\0\2\105\1\0"+
+ "\1\105\1\0\4\105\6\0\1\210\2\105\1\0\2\105"+
+ "\1\210\2\105\1\0\4\105\2\0\16\105\1\210\2\105"+
+ "\1\210\2\105\1\210\10\105\1\210\4\105\1\210\10\105"+
+ "\2\0\1\105\1\207\3\0\1\105\1\134\11\0\3\105"+
+ "\1\0\1\105\10\0\11\105\1\0\4\105\1\0\2\105"+
+ "\1\0\1\105\1\0\4\105\7\0\1\105\1\207\3\0"+
+ "\1\105\1\211\11\0\3\105\1\0\1\105\10\0\11\105"+
+ "\1\0\4\105\1\0\2\105\1\0\1\105\1\0\4\105"+
+ "\6\0\1\113\1\212\1\213\3\0\1\212\1\214\3\0"+
+ "\1\215\5\0\3\212\1\0\1\212\10\0\11\212\1\0"+
+ "\4\212\1\0\2\212\1\0\1\212\1\0\4\212\4\0"+
+ "\1\216\1\0\2\114\1\217\3\0\2\114\3\0\1\220"+
+ "\5\0\3\114\1\221\1\114\10\0\11\114\1\0\4\114"+
+ "\1\0\2\114\1\0\1\114\1\0\4\114\6\0\1\222"+
+ "\2\114\1\0\2\114\1\222\2\114\1\0\4\114\2\0"+
+ "\16\114\1\222\2\114\1\222\2\114\1\222\10\114\1\222"+
+ "\4\114\1\222\10\114\1\0\2\223\1\224\1\0\1\225"+
+ "\11\223\2\0\53\223\1\0\1\113\1\114\1\217\3\0"+
+ "\1\114\1\134\3\0\1\215\5\0\3\114\1\0\1\114"+
+ "\10\0\11\114\1\0\4\114\1\0\2\114\1\0\1\114"+
+ "\1\0\4\114\6\0\2\226\1\227\1\0\4\226\1\225"+
+ "\5\226\2\0\53\226\1\0\1\230\73\0\1\113\12\0"+
+ "\1\215\60\0\2\231\1\232\3\0\2\231\11\0\3\231"+
+ "\1\0\1\231\10\0\11\231\1\0\4\231\1\0\2\231"+
+ "\1\0\1\231\1\0\4\231\6\0\2\114\1\217\3\0"+
+ "\2\114\3\0\1\220\1\233\4\0\1\114\1\234\1\114"+
+ "\1\221\1\114\10\0\11\114\1\0\4\114\1\0\2\114"+
+ "\1\0\1\114\1\0\4\114\11\0\1\235\1\0\1\235"+
+ "\3\0\1\235\4\0\2\235\30\0\1\236\22\0\4\237"+
+ "\1\131\1\237\1\131\3\237\1\131\4\237\2\131\12\237"+
+ "\1\0\14\237\1\0\23\237\1\0\1\240\1\25\1\132"+
+ "\1\25\1\0\1\25\1\240\1\25\1\0\1\25\4\0"+
+ "\2\25\1\0\3\25\1\0\1\25\10\0\1\240\2\25"+
+ "\1\240\2\25\1\240\2\25\1\0\4\25\1\0\1\240"+
+ "\1\25\1\0\1\25\1\0\1\240\3\25\37\0\1\241"+
+ "\42\0\1\242\2\135\1\0\2\135\1\242\2\135\1\0"+
+ "\4\135\2\0\16\135\1\242\2\135\1\242\2\135\1\242"+
+ "\10\135\1\242\4\135\1\242\10\135\1\0\1\243\2\137"+
+ "\1\0\2\137\1\243\2\137\1\0\4\137\2\0\16\137"+
+ "\1\243\2\137\1\243\2\137\1\243\10\137\1\243\4\137"+
+ "\1\243\10\137\10\0\1\244\63\0\35\142\1\245\36\142"+
+ "\41\0\1\246\104\0\1\247\66\0\2\250\67\0\2\251"+
+ "\104\0\1\252\20\0\2\150\1\151\3\0\2\150\11\0"+
+ "\3\150\1\253\1\150\10\0\11\150\1\0\4\150\1\0"+
+ "\2\150\1\0\1\150\1\0\4\150\6\0\1\254\2\150"+
+ "\1\0\2\150\1\254\2\150\1\0\4\150\2\0\16\150"+
+ "\1\254\2\150\1\254\2\150\1\254\10\150\1\254\4\150"+
+ "\1\254\10\150\2\0\1\150\1\151\3\0\1\150\12\0"+
+ "\3\150\1\0\1\150\10\0\11\150\1\0\4\150\1\0"+
+ "\2\150\1\0\1\150\1\0\4\150\6\0\1\255\1\153"+
+ "\1\154\1\153\1\256\1\153\1\255\10\153\1\257\16\153"+
+ "\1\255\2\153\1\255\2\153\1\255\10\153\1\255\4\153"+
+ "\1\255\10\153\1\0\1\260\1\156\1\157\3\156\1\260"+
+ "\1\156\1\261\6\156\1\262\16\156\1\260\2\156\1\260"+
+ "\2\156\1\260\10\156\1\260\4\156\1\260\10\156\1\0"+
+ "\1\263\1\160\1\161\1\160\1\264\1\160\1\263\10\160"+
+ "\1\265\16\160\1\263\2\160\1\263\2\160\1\263\10\160"+
+ "\1\263\4\160\1\263\10\160\1\0\1\266\1\163\1\164"+
+ "\3\163\1\266\1\163\1\267\6\163\1\270\16\163\1\266"+
+ "\2\163\1\266\2\163\1\266\10\163\1\266\4\163\1\266"+
+ "\10\163\24\0\1\271\50\0\1\272\1\51\1\166\1\51"+
+ "\1\0\1\51\1\272\1\51\1\0\1\51\4\0\2\51"+
+ "\1\0\3\51\1\0\1\51\10\0\1\272\2\51\1\272"+
+ "\2\51\1\272\2\51\1\0\4\51\1\0\1\272\1\51"+
+ "\1\0\1\51\1\0\1\272\3\51\6\0\1\273\1\55"+
+ "\1\170\1\55\1\0\1\55\1\273\1\55\1\0\1\55"+
+ "\4\0\2\55\1\0\3\55\1\0\1\55\10\0\1\273"+
+ "\2\55\1\273\2\55\1\273\2\55\1\0\4\55\1\0"+
+ "\1\273\1\55\1\0\1\55\1\0\1\273\3\55\6\0"+
+ "\1\274\1\62\1\172\1\62\1\0\1\62\1\274\1\62"+
+ "\1\0\1\62\4\0\2\62\1\0\3\62\1\0\1\62"+
+ "\10\0\1\274\2\62\1\274\2\62\1\274\2\62\1\0"+
+ "\4\62\1\0\1\274\1\62\1\0\1\62\1\0\1\274"+
+ "\3\62\7\0\1\62\1\172\3\0\1\62\12\0\3\62"+
+ "\1\0\1\62\10\0\11\62\1\0\4\62\1\0\2\62"+
+ "\1\0\1\62\1\0\4\62\6\0\1\275\1\72\1\176"+
+ "\1\72\1\0\1\72\1\275\1\72\1\0\1\72\4\0"+
+ "\2\72\1\0\3\72\1\0\1\72\10\0\1\275\2\72"+
+ "\1\275\2\72\1\275\2\72\1\0\4\72\1\0\1\275"+
+ "\1\72\1\0\1\72\1\0\1\275\3\72\6\0\1\276"+
+ "\1\100\1\200\1\100\1\0\1\100\1\276\1\100\1\0"+
+ "\1\100\4\0\2\100\1\0\3\100\1\0\1\100\10\0"+
+ "\1\276\2\100\1\276\2\100\1\276\2\100\1\0\4\100"+
+ "\1\0\1\276\1\100\1\0\1\100\1\0\1\276\3\100"+
+ "\6\0\1\277\1\202\1\203\1\202\1\300\1\202\1\277"+
+ "\10\202\1\301\16\202\1\277\2\202\1\277\2\202\1\277"+
+ "\10\202\1\277\4\202\1\277\10\202\1\0\1\302\1\205"+
+ "\1\206\3\205\1\302\1\205\1\303\6\205\1\304\16\205"+
+ "\1\302\2\205\1\302\2\205\1\302\10\205\1\302\4\205"+
+ "\1\302\10\205\1\0\1\305\1\105\1\207\1\105\1\0"+
+ "\1\105\1\305\1\105\1\0\1\105\4\0\2\105\1\0"+
+ "\3\105\1\0\1\105\10\0\1\305\2\105\1\305\2\105"+
+ "\1\305\2\105\1\0\4\105\1\0\1\305\1\105\1\0"+
+ "\1\105\1\0\1\305\3\105\7\0\1\105\1\207\3\0"+
+ "\1\105\12\0\3\105\1\0\1\105\10\0\11\105\1\0"+
+ "\4\105\1\0\2\105\1\0\1\105\1\0\4\105\6\0"+
+ "\2\212\1\213\3\0\2\212\11\0\3\212\1\0\1\212"+
+ "\10\0\11\212\1\0\4\212\1\0\2\212\1\0\1\212"+
+ "\1\0\4\212\6\0\1\306\2\212\1\0\2\212\1\306"+
+ "\2\212\1\0\4\212\2\0\16\212\1\306\2\212\1\306"+
+ "\2\212\1\306\10\212\1\306\4\212\1\306\10\212\2\0"+
+ "\1\212\1\213\3\0\1\212\12\0\3\212\1\0\1\212"+
+ "\10\0\11\212\1\0\4\212\1\0\2\212\1\0\1\212"+
+ "\1\0\4\212\6\0\2\307\1\310\3\0\2\307\11\0"+
+ "\3\307\1\0\1\307\10\0\11\307\1\0\4\307\1\0"+
+ "\2\307\1\0\1\307\1\0\4\307\6\0\1\311\1\114"+
+ "\1\217\1\114\1\0\1\114\1\311\1\114\1\0\1\114"+
+ "\1\0\1\220\2\0\2\114\1\0\3\114\1\221\1\114"+
+ "\10\0\1\311\2\114\1\311\2\114\1\311\2\114\1\0"+
+ "\4\114\1\0\1\311\1\114\1\0\1\114\1\0\1\311"+
+ "\3\114\6\0\1\312\1\223\1\224\1\223\1\313\1\223"+
+ "\1\312\10\223\1\314\16\223\1\312\2\223\1\312\2\223"+
+ "\1\312\10\223\1\312\4\223\1\312\10\223\1\0\1\315"+
+ "\1\226\1\227\3\226\1\315\1\226\1\316\6\226\1\317"+
+ "\16\226\1\315\2\226\1\315\2\226\1\315\10\226\1\315"+
+ "\4\226\1\315\10\226\1\0\1\230\1\212\1\213\3\0"+
+ "\1\212\1\214\11\0\3\212\1\0\1\212\10\0\11\212"+
+ "\1\0\4\212\1\0\2\212\1\0\1\212\1\0\4\212"+
+ "\4\0\1\216\1\0\1\320\2\231\1\0\2\231\1\320"+
+ "\2\231\1\0\4\231\2\0\16\231\1\320\2\231\1\320"+
+ "\2\231\1\320\10\231\1\320\4\231\1\320\10\231\1\0"+
+ "\1\321\5\0\1\321\16\0\2\321\7\0\2\321\1\0"+
+ "\2\321\1\0\2\321\7\0\2\321\3\0\2\321\10\0"+
+ "\2\114\1\217\3\0\2\114\3\0\1\220\5\0\2\114"+
+ "\1\322\1\221\1\114\10\0\11\114\1\0\4\114\1\0"+
+ "\2\114\1\0\1\114\1\0\4\114\57\0\1\323\22\0"+
+ "\1\324\1\25\1\132\1\25\1\0\1\25\1\324\1\25"+
+ "\1\0\1\25\4\0\2\25\1\0\3\25\1\0\1\25"+
+ "\10\0\1\324\2\25\1\324\2\25\1\324\2\25\1\0"+
+ "\4\25\1\0\1\324\1\25\1\0\1\25\1\0\1\324"+
+ "\3\25\6\0\1\325\1\135\1\136\1\135\1\0\1\135"+
+ "\1\325\1\135\1\0\1\135\4\0\2\135\1\0\3\135"+
+ "\1\0\1\135\10\0\1\325\2\135\1\325\2\135\1\325"+
+ "\2\135\1\0\4\135\1\0\1\325\1\135\1\0\1\135"+
+ "\1\0\1\325\3\135\6\0\1\326\1\137\1\140\1\137"+
+ "\1\0\1\137\1\326\1\137\1\0\1\137\4\0\2\137"+
+ "\1\0\3\137\1\0\1\137\10\0\1\326\2\137\1\326"+
+ "\2\137\1\326\2\137\1\0\4\137\1\0\1\326\1\137"+
+ "\1\0\1\137\1\0\1\326\3\137\15\0\1\327\63\0"+
+ "\34\142\1\330\1\245\36\142\42\0\2\331\103\0\1\332"+
+ "\76\0\2\333\75\0\1\334\77\0\1\335\7\0\1\253"+
+ "\2\0\1\253\1\0\3\253\1\0\1\253\1\336\1\0"+
+ "\1\253\1\0\2\253\1\0\3\253\1\0\1\253\10\0"+
+ "\11\253\1\0\4\253\1\0\2\253\1\0\1\253\1\0"+
+ "\4\253\6\0\1\337\1\150\1\151\1\150\1\0\1\150"+
+ "\1\337\1\150\1\0\1\150\4\0\2\150\1\0\3\150"+
+ "\1\253\1\150\10\0\1\337\2\150\1\337\2\150\1\337"+
+ "\2\150\1\0\4\150\1\0\1\337\1\150\1\0\1\150"+
+ "\1\0\1\337\3\150\6\0\1\340\1\153\1\154\1\153"+
+ "\1\155\1\153\1\340\27\153\1\340\2\153\1\340\2\153"+
+ "\1\340\10\153\1\340\4\153\1\340\10\153\1\0\2\153"+
+ "\1\154\1\0\1\155\12\153\1\0\53\153\1\0\1\341"+
+ "\1\156\1\157\3\156\1\341\1\156\1\155\25\156\1\341"+
+ "\2\156\1\341\2\156\1\341\10\156\1\341\4\156\1\341"+
+ "\10\156\1\0\2\156\1\157\1\0\4\156\1\155\6\156"+
+ "\1\0\53\156\1\0\1\342\1\160\1\161\1\160\1\162"+
+ "\1\160\1\342\27\160\1\342\2\160\1\342\2\160\1\342"+
+ "\10\160\1\342\4\160\1\342\10\160\1\0\2\160\1\161"+
+ "\1\0\1\162\12\160\1\0\53\160\1\0\1\343\1\163"+
+ "\1\164\3\163\1\343\1\163\1\162\25\163\1\343\2\163"+
+ "\1\343\2\163\1\343\10\163\1\343\4\163\1\343\10\163"+
+ "\1\0\2\163\1\164\1\0\4\163\1\162\6\163\1\0"+
+ "\53\163\25\0\1\344\47\0\1\345\1\51\1\166\1\51"+
+ "\1\0\1\51\1\345\1\51\1\0\1\51\4\0\2\51"+
+ "\1\0\3\51\1\0\1\51\10\0\1\345\2\51\1\345"+
+ "\2\51\1\345\2\51\1\0\4\51\1\0\1\345\1\51"+
+ "\1\0\1\51\1\0\1\345\3\51\6\0\1\346\1\55"+
+ "\1\170\1\55\1\0\1\55\1\346\1\55\1\0\1\55"+
+ "\4\0\2\55\1\0\3\55\1\0\1\55\10\0\1\346"+
+ "\2\55\1\346\2\55\1\346\2\55\1\0\4\55\1\0"+
+ "\1\346\1\55\1\0\1\55\1\0\1\346\3\55\6\0"+
+ "\1\347\1\62\1\172\1\62\1\0\1\62\1\347\1\62"+
+ "\1\0\1\62\4\0\2\62\1\0\3\62\1\0\1\62"+
+ "\10\0\1\347\2\62\1\347\2\62\1\347\2\62\1\0"+
+ "\4\62\1\0\1\347\1\62\1\0\1\62\1\0\1\347"+
+ "\3\62\6\0\1\350\1\72\1\176\1\72\1\0\1\72"+
+ "\1\350\1\72\1\0\1\72\4\0\2\72\1\0\3\72"+
+ "\1\0\1\72\10\0\1\350\2\72\1\350\2\72\1\350"+
+ "\2\72\1\0\4\72\1\0\1\350\1\72\1\0\1\72"+
+ "\1\0\1\350\3\72\6\0\1\351\1\100\1\200\1\100"+
+ "\1\0\1\100\1\351\1\100\1\0\1\100\4\0\2\100"+
+ "\1\0\3\100\1\0\1\100\10\0\1\351\2\100\1\351"+
+ "\2\100\1\351\2\100\1\0\4\100\1\0\1\351\1\100"+
+ "\1\0\1\100\1\0\1\351\3\100\6\0\1\352\1\202"+
+ "\1\203\1\202\1\204\1\202\1\352\27\202\1\352\2\202"+
+ "\1\352\2\202\1\352\10\202\1\352\4\202\1\352\10\202"+
+ "\1\0\2\202\1\203\1\0\1\204\12\202\1\0\53\202"+
+ "\1\0\1\353\1\205\1\206\3\205\1\353\1\205\1\204"+
+ "\25\205\1\353\2\205\1\353\2\205\1\353\10\205\1\353"+
+ "\4\205\1\353\10\205\1\0\2\205\1\206\1\0\4\205"+
+ "\1\204\6\205\1\0\53\205\1\0\1\354\1\105\1\207"+
+ "\1\105\1\0\1\105\1\354\1\105\1\0\1\105\4\0"+
+ "\2\105\1\0\3\105\1\0\1\105\10\0\1\354\2\105"+
+ "\1\354\2\105\1\354\2\105\1\0\4\105\1\0\1\354"+
+ "\1\105\1\0\1\105\1\0\1\354\3\105\6\0\1\355"+
+ "\1\212\1\213\1\212\1\0\1\212\1\355\1\212\1\0"+
+ "\1\212\4\0\2\212\1\0\3\212\1\0\1\212\10\0"+
+ "\1\355\2\212\1\355\2\212\1\355\2\212\1\0\4\212"+
+ "\1\0\1\355\1\212\1\0\1\212\1\0\1\355\3\212"+
+ "\6\0\2\307\1\310\3\0\2\307\3\0\1\220\5\0"+
+ "\3\307\1\0\1\307\10\0\11\307\1\0\4\307\1\0"+
+ "\2\307\1\0\1\307\1\0\4\307\6\0\1\356\2\307"+
+ "\1\0\2\307\1\356\2\307\1\0\4\307\2\0\16\307"+
+ "\1\356\2\307\1\356\2\307\1\356\10\307\1\356\4\307"+
+ "\1\356\10\307\1\0\1\357\1\114\1\217\1\114\1\0"+
+ "\1\114\1\357\1\114\1\0\1\114\1\0\1\220\2\0"+
+ "\2\114\1\0\3\114\1\221\1\114\10\0\1\357\2\114"+
+ "\1\357\2\114\1\357\2\114\1\0\4\114\1\0\1\357"+
+ "\1\114\1\0\1\114\1\0\1\357\3\114\6\0\1\360"+
+ "\1\223\1\224\1\223\1\225\1\223\1\360\27\223\1\360"+
+ "\2\223\1\360\2\223\1\360\10\223\1\360\4\223\1\360"+
+ "\10\223\1\0\2\223\1\224\1\0\1\225\12\223\1\0"+
+ "\53\223\1\0\1\361\1\226\1\227\3\226\1\361\1\226"+
+ "\1\225\25\226\1\361\2\226\1\361\2\226\1\361\10\226"+
+ "\1\361\4\226\1\361\10\226\1\0\2\226\1\227\1\0"+
+ "\4\226\1\225\6\226\1\0\53\226\1\0\1\362\1\231"+
+ "\1\232\1\231\1\0\1\231\1\362\1\231\1\0\1\231"+
+ "\4\0\2\231\1\0\3\231\1\0\1\231\10\0\1\362"+
+ "\2\231\1\362\2\231\1\362\2\231\1\0\4\231\1\0"+
+ "\1\362\1\231\1\0\1\231\1\0\1\362\3\231\6\0"+
+ "\1\363\5\0\1\363\1\364\15\0\2\363\7\0\2\363"+
+ "\1\0\2\363\1\0\2\363\7\0\2\363\3\0\2\363"+
+ "\10\0\2\114\1\217\3\0\2\114\3\0\1\220\5\0"+
+ "\3\114\1\365\1\114\10\0\11\114\1\0\4\114\1\0"+
+ "\2\114\1\0\1\114\1\0\4\114\60\0\1\366\21\0"+
+ "\1\367\1\25\1\132\1\25\1\0\1\25\1\367\1\25"+
+ "\1\0\1\25\4\0\2\25\1\0\3\25\1\0\1\25"+
+ "\10\0\1\367\2\25\1\367\2\25\1\367\2\25\1\0"+
+ "\4\25\1\0\1\367\1\25\1\0\1\25\1\0\1\367"+
+ "\3\25\6\0\1\370\1\135\1\136\1\135\1\0\1\135"+
+ "\1\370\1\135\1\0\1\135\4\0\2\135\1\0\3\135"+
+ "\1\0\1\135\10\0\1\370\2\135\1\370\2\135\1\370"+
+ "\2\135\1\0\4\135\1\0\1\370\1\135\1\0\1\135"+
+ "\1\0\1\370\3\135\6\0\1\371\1\137\1\140\1\137"+
+ "\1\0\1\137\1\371\1\137\1\0\1\137\4\0\2\137"+
+ "\1\0\3\137\1\0\1\137\10\0\1\371\2\137\1\371"+
+ "\2\137\1\371\2\137\1\0\4\137\1\0\1\371\1\137"+
+ "\1\0\1\137\1\0\1\371\3\137\30\0\1\372\124\0"+
+ "\1\373\70\0\1\374\67\0\2\375\74\0\1\376\25\0"+
+ "\1\377\1\150\1\151\1\150\1\0\1\150\1\377\1\150"+
+ "\1\0\1\150\4\0\2\150\1\0\3\150\1\253\1\150"+
+ "\10\0\1\377\2\150\1\377\2\150\1\377\2\150\1\0"+
+ "\4\150\1\0\1\377\1\150\1\0\1\150\1\0\1\377"+
+ "\3\150\6\0\1\u0100\1\153\1\154\1\153\1\155\1\153"+
+ "\1\u0100\27\153\1\u0100\2\153\1\u0100\2\153\1\u0100\10\153"+
+ "\1\u0100\4\153\1\u0100\10\153\1\0\1\u0101\1\156\1\157"+
+ "\3\156\1\u0101\1\156\1\155\25\156\1\u0101\2\156\1\u0101"+
+ "\2\156\1\u0101\10\156\1\u0101\4\156\1\u0101\10\156\1\0"+
+ "\1\u0102\1\160\1\161\1\160\1\162\1\160\1\u0102\27\160"+
+ "\1\u0102\2\160\1\u0102\2\160\1\u0102\10\160\1\u0102\4\160"+
+ "\1\u0102\10\160\1\0\1\u0103\1\163\1\164\3\163\1\u0103"+
+ "\1\163\1\162\25\163\1\u0103\2\163\1\u0103\2\163\1\u0103"+
+ "\10\163\1\u0103\4\163\1\u0103\10\163\1\0\2\u0104\1\u0105"+
+ "\1\344\1\u0106\1\344\2\u0104\1\u0107\1\344\1\u0108\3\u0104"+
+ "\2\344\4\u0104\1\0\46\u0104\1\0\1\u0109\1\51\1\166"+
+ "\1\51\1\0\1\51\1\u0109\1\51\1\0\1\51\4\0"+
+ "\2\51\1\0\3\51\1\0\1\51\10\0\1\u0109\2\51"+
+ "\1\u0109\2\51\1\u0109\2\51\1\0\4\51\1\0\1\u0109"+
+ "\1\51\1\0\1\51\1\0\1\u0109\3\51\6\0\1\u010a"+
+ "\1\55\1\170\1\55\1\0\1\55\1\u010a\1\55\1\0"+
+ "\1\55\4\0\2\55\1\0\3\55\1\0\1\55\10\0"+
+ "\1\u010a\2\55\1\u010a\2\55\1\u010a\2\55\1\0\4\55"+
+ "\1\0\1\u010a\1\55\1\0\1\55\1\0\1\u010a\3\55"+
+ "\6\0\1\u010b\1\62\1\172\1\62\1\0\1\62\1\u010b"+
+ "\1\62\1\0\1\62\4\0\2\62\1\0\3\62\1\0"+
+ "\1\62\10\0\1\u010b\2\62\1\u010b\2\62\1\u010b\2\62"+
+ "\1\0\4\62\1\0\1\u010b\1\62\1\0\1\62\1\0"+
+ "\1\u010b\3\62\6\0\1\u010c\1\72\1\176\1\72\1\0"+
+ "\1\72\1\u010c\1\72\1\0\1\72\4\0\2\72\1\0"+
+ "\3\72\1\0\1\72\10\0\1\u010c\2\72\1\u010c\2\72"+
+ "\1\u010c\2\72\1\0\4\72\1\0\1\u010c\1\72\1\0"+
+ "\1\72\1\0\1\u010c\3\72\6\0\1\u010d\1\100\1\200"+
+ "\1\100\1\0\1\100\1\u010d\1\100\1\0\1\100\4\0"+
+ "\2\100\1\0\3\100\1\0\1\100\10\0\1\u010d\2\100"+
+ "\1\u010d\2\100\1\u010d\2\100\1\0\4\100\1\0\1\u010d"+
+ "\1\100\1\0\1\100\1\0\1\u010d\3\100\6\0\1\u010e"+
+ "\1\202\1\203\1\202\1\204\1\202\1\u010e\27\202\1\u010e"+
+ "\2\202\1\u010e\2\202\1\u010e\10\202\1\u010e\4\202\1\u010e"+
+ "\10\202\1\0\1\u010f\1\205\1\206\3\205\1\u010f\1\205"+
+ "\1\204\25\205\1\u010f\2\205\1\u010f\2\205\1\u010f\10\205"+
+ "\1\u010f\4\205\1\u010f\10\205\1\0\1\u0110\1\105\1\207"+
+ "\1\105\1\0\1\105\1\u0110\1\105\1\0\1\105\4\0"+
+ "\2\105\1\0\3\105\1\0\1\105\10\0\1\u0110\2\105"+
+ "\1\u0110\2\105\1\u0110\2\105\1\0\4\105\1\0\1\u0110"+
+ "\1\105\1\0\1\105\1\0\1\u0110\3\105\6\0\1\u0111"+
+ "\1\212\1\213\1\212\1\0\1\212\1\u0111\1\212\1\0"+
+ "\1\212\4\0\2\212\1\0\3\212\1\0\1\212\10\0"+
+ "\1\u0111\2\212\1\u0111\2\212\1\u0111\2\212\1\0\4\212"+
+ "\1\0\1\u0111\1\212\1\0\1\212\1\0\1\u0111\3\212"+
+ "\6\0\1\u0112\1\307\1\310\1\307\1\0\1\307\1\u0112"+
+ "\1\307\1\0\1\307\1\0\1\220\2\0\2\307\1\0"+
+ "\3\307\1\0\1\307\10\0\1\u0112\2\307\1\u0112\2\307"+
+ "\1\u0112\2\307\1\0\4\307\1\0\1\u0112\1\307\1\0"+
+ "\1\307\1\0\1\u0112\3\307\6\0\1\u0113\1\114\1\217"+
+ "\1\114\1\0\1\114\1\u0113\1\114\1\0\1\114\1\0"+
+ "\1\220\2\0\2\114\1\0\3\114\1\221\1\114\10\0"+
+ "\1\u0113\2\114\1\u0113\2\114\1\u0113\2\114\1\0\4\114"+
+ "\1\0\1\u0113\1\114\1\0\1\114\1\0\1\u0113\3\114"+
+ "\6\0\1\u0114\1\223\1\224\1\223\1\225\1\223\1\u0114"+
+ "\27\223\1\u0114\2\223\1\u0114\2\223\1\u0114\10\223\1\u0114"+
+ "\4\223\1\u0114\10\223\1\0\1\u0115\1\226\1\227\3\226"+
+ "\1\u0115\1\226\1\225\25\226\1\u0115\2\226\1\u0115\2\226"+
+ "\1\u0115\10\226\1\u0115\4\226\1\u0115\10\226\1\0\1\u0116"+
+ "\1\231\1\232\1\231\1\0\1\231\1\u0116\1\231\1\0"+
+ "\1\231\4\0\2\231\1\0\3\231\1\0\1\231\10\0"+
+ "\1\u0116\2\231\1\u0116\2\231\1\u0116\2\231\1\0\4\231"+
+ "\1\0\1\u0116\1\231\1\0\1\231\1\0\1\u0116\3\231"+
+ "\6\0\1\u0117\5\0\1\u0117\1\364\15\0\2\u0117\7\0"+
+ "\2\u0117\1\0\2\u0117\1\0\2\u0117\7\0\2\u0117\3\0"+
+ "\2\u0117\10\0\1\u0118\5\0\1\u0118\16\0\2\u0118\7\0"+
+ "\2\u0118\1\0\2\u0118\1\0\2\u0118\7\0\2\u0118\3\0"+
+ "\2\u0118\10\0\2\u0119\1\u011a\1\u011b\1\u011c\1\u011b\2\u0119"+
+ "\1\u011d\1\u011b\1\u011e\3\u0119\2\u011b\4\u0119\1\0\46\u0119"+
+ "\54\0\1\u011f\20\0\1\u0120\1\25\1\132\1\25\1\0"+
+ "\1\25\1\u0120\1\25\1\0\1\25\4\0\2\25\1\0"+
+ "\3\25\1\0\1\25\10\0\1\u0120\2\25\1\u0120\2\25"+
+ "\1\u0120\2\25\1\0\4\25\1\0\1\u0120\1\25\1\0"+
+ "\1\25\1\0\1\u0120\3\25\6\0\1\u0121\1\135\1\136"+
+ "\1\135\1\0\1\135\1\u0121\1\135\1\0\1\135\4\0"+
+ "\2\135\1\0\3\135\1\0\1\135\10\0\1\u0121\2\135"+
+ "\1\u0121\2\135\1\u0121\2\135\1\0\4\135\1\0\1\u0121"+
+ "\1\135\1\0\1\135\1\0\1\u0121\3\135\6\0\1\u0122"+
+ "\1\137\1\140\1\137\1\0\1\137\1\u0122\1\137\1\0"+
+ "\1\137\4\0\2\137\1\0\3\137\1\0\1\137\10\0"+
+ "\1\u0122\2\137\1\u0122\2\137\1\u0122\2\137\1\0\4\137"+
+ "\1\0\1\u0122\1\137\1\0\1\137\1\0\1\u0122\3\137"+
+ "\51\0\1\u0123\52\0\1\u0124\112\0\2\u0125\40\0\1\u0126"+
+ "\64\0\1\u0127\1\150\1\151\1\150\1\0\1\150\1\u0127"+
+ "\1\150\1\0\1\150\4\0\2\150\1\0\3\150\1\253"+
+ "\1\150\10\0\1\u0127\2\150\1\u0127\2\150\1\u0127\2\150"+
+ "\1\0\4\150\1\0\1\u0127\1\150\1\0\1\150\1\0"+
+ "\1\u0127\3\150\6\0\1\u0128\1\153\1\154\1\153\1\155"+
+ "\1\153\1\u0128\27\153\1\u0128\2\153\1\u0128\2\153\1\u0128"+
+ "\10\153\1\u0128\4\153\1\u0128\10\153\1\0\1\u0129\1\156"+
+ "\1\157\3\156\1\u0129\1\156\1\155\25\156\1\u0129\2\156"+
+ "\1\u0129\2\156\1\u0129\10\156\1\u0129\4\156\1\u0129\10\156"+
+ "\1\0\1\u012a\1\160\1\161\1\160\1\162\1\160\1\u012a"+
+ "\27\160\1\u012a\2\160\1\u012a\2\160\1\u012a\10\160\1\u012a"+
+ "\4\160\1\u012a\10\160\1\0\1\u012b\1\163\1\164\3\163"+
+ "\1\u012b\1\163\1\162\25\163\1\u012b\2\163\1\u012b\2\163"+
+ "\1\u012b\10\163\1\u012b\4\163\1\u012b\10\163\1\0\2\u0104"+
+ "\1\u0105\1\u012c\1\0\3\u0104\1\0\1\u012c\1\u0108\3\u0104"+
+ "\2\u012c\4\u0104\1\0\46\u0104\1\0\1\u012d\1\u0104\1\u0105"+
+ "\1\u012c\2\u0104\1\u012d\2\u0104\1\u012c\1\u012e\3\u0104\2\u012c"+
+ "\16\u0104\1\u012d\2\u0104\1\u012d\2\u0104\1\u012d\10\u0104\1\u012d"+
+ "\4\u0104\1\u012d\10\u0104\1\0\2\u0106\1\u012f\1\0\1\u012c"+
+ "\11\u0106\2\0\53\u0106\1\0\2\u0107\1\u0130\1\0\4\u0107"+
+ "\1\u012c\5\u0107\2\0\53\u0107\1\0\1\u0131\1\51\1\166"+
+ "\1\51\1\0\1\51\1\u0131\1\51\1\0\1\51\4\0"+
+ "\2\51\1\0\3\51\1\0\1\51\10\0\1\u0131\2\51"+
+ "\1\u0131\2\51\1\u0131\2\51\1\0\4\51\1\0\1\u0131"+
+ "\1\51\1\0\1\51\1\0\1\u0131\3\51\6\0\1\u0132"+
+ "\1\55\1\170\1\55\1\0\1\55\1\u0132\1\55\1\0"+
+ "\1\55\4\0\2\55\1\0\3\55\1\0\1\55\10\0"+
+ "\1\u0132\2\55\1\u0132\2\55\1\u0132\2\55\1\0\4\55"+
+ "\1\0\1\u0132\1\55\1\0\1\55\1\0\1\u0132\3\55"+
+ "\6\0\1\u0133\1\62\1\172\1\62\1\0\1\62\1\u0133"+
+ "\1\62\1\0\1\62\4\0\2\62\1\0\3\62\1\0"+
+ "\1\62\10\0\1\u0133\2\62\1\u0133\2\62\1\u0133\2\62"+
+ "\1\0\4\62\1\0\1\u0133\1\62\1\0\1\62\1\0"+
+ "\1\u0133\3\62\6\0\1\u0134\1\72\1\176\1\72\1\0"+
+ "\1\72\1\u0134\1\72\1\0\1\72\4\0\2\72\1\0"+
+ "\3\72\1\0\1\72\10\0\1\u0134\2\72\1\u0134\2\72"+
+ "\1\u0134\2\72\1\0\4\72\1\0\1\u0134\1\72\1\0"+
+ "\1\72\1\0\1\u0134\3\72\6\0\1\u0135\1\100\1\200"+
+ "\1\100\1\0\1\100\1\u0135\1\100\1\0\1\100\4\0"+
+ "\2\100\1\0\3\100\1\0\1\100\10\0\1\u0135\2\100"+
+ "\1\u0135\2\100\1\u0135\2\100\1\0\4\100\1\0\1\u0135"+
+ "\1\100\1\0\1\100\1\0\1\u0135\3\100\6\0\1\u0136"+
+ "\1\202\1\203\1\202\1\204\1\202\1\u0136\27\202\1\u0136"+
+ "\2\202\1\u0136\2\202\1\u0136\10\202\1\u0136\4\202\1\u0136"+
+ "\10\202\1\0\1\u0137\1\205\1\206\3\205\1\u0137\1\205"+
+ "\1\204\25\205\1\u0137\2\205\1\u0137\2\205\1\u0137\10\205"+
+ "\1\u0137\4\205\1\u0137\10\205\1\0\1\u0138\1\105\1\207"+
+ "\1\105\1\0\1\105\1\u0138\1\105\1\0\1\105\4\0"+
+ "\2\105\1\0\3\105\1\0\1\105\10\0\1\u0138\2\105"+
+ "\1\u0138\2\105\1\u0138\2\105\1\0\4\105\1\0\1\u0138"+
+ "\1\105\1\0\1\105\1\0\1\u0138\3\105\6\0\1\u0139"+
+ "\1\212\1\213\1\212\1\0\1\212\1\u0139\1\212\1\0"+
+ "\1\212\4\0\2\212\1\0\3\212\1\0\1\212\10\0"+
+ "\1\u0139\2\212\1\u0139\2\212\1\u0139\2\212\1\0\4\212"+
+ "\1\0\1\u0139\1\212\1\0\1\212\1\0\1\u0139\3\212"+
+ "\6\0\1\u013a\1\307\1\310\1\307\1\0\1\307\1\u013a"+
+ "\1\307\1\0\1\307\1\0\1\220\2\0\2\307\1\0"+
+ "\3\307\1\0\1\307\10\0\1\u013a\2\307\1\u013a\2\307"+
+ "\1\u013a\2\307\1\0\4\307\1\0\1\u013a\1\307\1\0"+
+ "\1\307\1\0\1\u013a\3\307\6\0\1\u013b\1\114\1\217"+
+ "\1\114\1\0\1\114\1\u013b\1\114\1\0\1\114\1\0"+
+ "\1\220\2\0\2\114\1\0\3\114\1\221\1\114\10\0"+
+ "\1\u013b\2\114\1\u013b\2\114\1\u013b\2\114\1\0\4\114"+
+ "\1\0\1\u013b\1\114\1\0\1\114\1\0\1\u013b\3\114"+
+ "\6\0\1\u013c\1\223\1\224\1\223\1\225\1\223\1\u013c"+
+ "\27\223\1\u013c\2\223\1\u013c\2\223\1\u013c\10\223\1\u013c"+
+ "\4\223\1\u013c\10\223\1\0\1\u013d\1\226\1\227\3\226"+
+ "\1\u013d\1\226\1\225\25\226\1\u013d\2\226\1\u013d\2\226"+
+ "\1\u013d\10\226\1\u013d\4\226\1\u013d\10\226\1\0\1\u013e"+
+ "\1\231\1\232\1\231\1\0\1\231\1\u013e\1\231\1\0"+
+ "\1\231\4\0\2\231\1\0\3\231\1\0\1\231\10\0"+
+ "\1\u013e\2\231\1\u013e\2\231\1\u013e\2\231\1\0\4\231"+
+ "\1\0\1\u013e\1\231\1\0\1\231\1\0\1\u013e\3\231"+
+ "\6\0\1\u013f\5\0\1\u013f\1\364\15\0\2\u013f\7\0"+
+ "\2\u013f\1\0\2\u013f\1\0\2\u013f\7\0\2\u013f\3\0"+
+ "\2\u013f\10\0\1\u0140\5\0\1\u0140\16\0\2\u0140\7\0"+
+ "\2\u0140\1\0\2\u0140\1\0\2\u0140\7\0\2\u0140\3\0"+
+ "\2\u0140\10\0\2\u0119\1\u011a\1\u0141\1\0\3\u0119\1\0"+
+ "\1\u0141\1\u011e\3\u0119\2\u0141\4\u0119\1\0\46\u0119\1\0"+
+ "\1\u0142\1\u0119\1\u011a\1\u0141\2\u0119\1\u0142\2\u0119\1\u0141"+
+ "\1\u0143\3\u0119\2\u0141\16\u0119\1\u0142\2\u0119\1\u0142\2\u0119"+
+ "\1\u0142\10\u0119\1\u0142\4\u0119\1\u0142\10\u0119\1\0\2\u011c"+
+ "\1\u0144\1\0\1\u0141\11\u011c\2\0\53\u011c\1\0\2\u011d"+
+ "\1\u0145\1\0\4\u011d\1\u0141\5\u011d\2\0\53\u011d\23\0"+
+ "\1\u0146\51\0\1\u0147\1\25\1\132\1\25\1\0\1\25"+
+ "\1\u0147\1\25\1\0\1\25\4\0\2\25\1\0\3\25"+
+ "\1\0\1\25\10\0\1\u0147\2\25\1\u0147\2\25\1\u0147"+
+ "\2\25\1\0\4\25\1\0\1\u0147\1\25\1\0\1\25"+
+ "\1\0\1\u0147\3\25\6\0\1\u0148\1\135\1\136\1\135"+
+ "\1\0\1\135\1\u0148\1\135\1\0\1\135\4\0\2\135"+
+ "\1\0\3\135\1\0\1\135\10\0\1\u0148\2\135\1\u0148"+
+ "\2\135\1\u0148\2\135\1\0\4\135\1\0\1\u0148\1\135"+
+ "\1\0\1\135\1\0\1\u0148\3\135\6\0\1\u0149\1\137"+
+ "\1\140\1\137\1\0\1\137\1\u0149\1\137\1\0\1\137"+
+ "\4\0\2\137\1\0\3\137\1\0\1\137\10\0\1\u0149"+
+ "\2\137\1\u0149\2\137\1\u0149\2\137\1\0\4\137\1\0"+
+ "\1\u0149\1\137\1\0\1\137\1\0\1\u0149\3\137\52\0"+
+ "\2\u014a\74\0\1\u014b\107\0\2\u014c\10\0\1\u014d\1\150"+
+ "\1\151\1\150\1\0\1\150\1\u014d\1\150\1\0\1\150"+
+ "\4\0\2\150\1\0\3\150\1\253\1\150\10\0\1\u014d"+
+ "\2\150\1\u014d\2\150\1\u014d\2\150\1\0\4\150\1\0"+
+ "\1\u014d\1\150\1\0\1\150\1\0\1\u014d\3\150\6\0"+
+ "\1\u014e\1\153\1\154\1\153\1\155\1\153\1\u014e\27\153"+
+ "\1\u014e\2\153\1\u014e\2\153\1\u014e\10\153\1\u014e\4\153"+
+ "\1\u014e\10\153\1\0\1\u014f\1\156\1\157\3\156\1\u014f"+
+ "\1\156\1\155\25\156\1\u014f\2\156\1\u014f\2\156\1\u014f"+
+ "\10\156\1\u014f\4\156\1\u014f\10\156\1\0\1\u0150\1\160"+
+ "\1\161\1\160\1\162\1\160\1\u0150\27\160\1\u0150\2\160"+
+ "\1\u0150\2\160\1\u0150\10\160\1\u0150\4\160\1\u0150\10\160"+
+ "\1\0\1\u0151\1\163\1\164\3\163\1\u0151\1\163\1\162"+
+ "\25\163\1\u0151\2\163\1\u0151\2\163\1\u0151\10\163\1\u0151"+
+ "\4\163\1\u0151\10\163\4\0\1\u012c\1\0\1\u012c\3\0"+
+ "\1\u012c\1\u0108\3\0\2\u012c\54\0\1\u0152\1\u0104\1\u0105"+
+ "\1\u0104\1\0\1\u0104\1\u0152\1\u0104\1\0\1\u0104\1\u0108"+
+ "\11\u0104\1\0\11\u0104\1\u0152\2\u0104\1\u0152\2\u0104\1\u0152"+
+ "\10\u0104\1\u0152\4\u0104\1\u0152\10\u0104\1\0\1\u0153\1\u0106"+
+ "\1\u012f\1\u0106\1\u0154\1\u0106\1\u0153\10\u0106\1\u0155\16\u0106"+
+ "\1\u0153\2\u0106\1\u0153\2\u0106\1\u0153\10\u0106\1\u0153\4\u0106"+
+ "\1\u0153\10\u0106\1\0\1\u0156\1\u0107\1\u0130\3\u0107\1\u0156"+
+ "\1\u0107\1\u0157\6\u0107\1\u0158\16\u0107\1\u0156\2\u0107\1\u0156"+
+ "\2\u0107\1\u0156\10\u0107\1\u0156\4\u0107\1\u0156\10\u0107\1\0"+
+ "\1\u0159\1\51\1\166\1\51\1\0\1\51\1\u0159\1\51"+
+ "\1\0\1\51\4\0\2\51\1\0\3\51\1\0\1\51"+
+ "\10\0\1\u0159\2\51\1\u0159\2\51\1\u0159\2\51\1\0"+
+ "\4\51\1\0\1\u0159\1\51\1\0\1\51\1\0\1\u0159"+
+ "\3\51\6\0\1\u015a\1\55\1\170\1\55\1\0\1\55"+
+ "\1\u015a\1\55\1\0\1\55\4\0\2\55\1\0\3\55"+
+ "\1\0\1\55\10\0\1\u015a\2\55\1\u015a\2\55\1\u015a"+
+ "\2\55\1\0\4\55\1\0\1\u015a\1\55\1\0\1\55"+
+ "\1\0\1\u015a\3\55\6\0\1\u015b\1\62\1\172\1\62"+
+ "\1\0\1\62\1\u015b\1\62\1\0\1\62\4\0\2\62"+
+ "\1\0\3\62\1\0\1\62\10\0\1\u015b\2\62\1\u015b"+
+ "\2\62\1\u015b\2\62\1\0\4\62\1\0\1\u015b\1\62"+
+ "\1\0\1\62\1\0\1\u015b\3\62\6\0\1\u015c\1\72"+
+ "\1\176\1\72\1\0\1\72\1\u015c\1\72\1\0\1\72"+
+ "\4\0\2\72\1\0\3\72\1\0\1\72\10\0\1\u015c"+
+ "\2\72\1\u015c\2\72\1\u015c\2\72\1\0\4\72\1\0"+
+ "\1\u015c\1\72\1\0\1\72\1\0\1\u015c\3\72\6\0"+
+ "\1\u015d\1\100\1\200\1\100\1\0\1\100\1\u015d\1\100"+
+ "\1\0\1\100\4\0\2\100\1\0\3\100\1\0\1\100"+
+ "\10\0\1\u015d\2\100\1\u015d\2\100\1\u015d\2\100\1\0"+
+ "\4\100\1\0\1\u015d\1\100\1\0\1\100\1\0\1\u015d"+
+ "\3\100\6\0\1\u015e\1\202\1\203\1\202\1\204\1\202"+
+ "\1\u015e\27\202\1\u015e\2\202\1\u015e\2\202\1\u015e\10\202"+
+ "\1\u015e\4\202\1\u015e\10\202\1\0\1\u015f\1\205\1\206"+
+ "\3\205\1\u015f\1\205\1\204\25\205\1\u015f\2\205\1\u015f"+
+ "\2\205\1\u015f\10\205\1\u015f\4\205\1\u015f\10\205\1\0"+
+ "\1\u0160\1\105\1\207\1\105\1\0\1\105\1\u0160\1\105"+
+ "\1\0\1\105\4\0\2\105\1\0\3\105\1\0\1\105"+
+ "\10\0\1\u0160\2\105\1\u0160\2\105\1\u0160\2\105\1\0"+
+ "\4\105\1\0\1\u0160\1\105\1\0\1\105\1\0\1\u0160"+
+ "\3\105\6\0\1\u0161\1\212\1\213\1\212\1\0\1\212"+
+ "\1\u0161\1\212\1\0\1\212\4\0\2\212\1\0\3\212"+
+ "\1\0\1\212\10\0\1\u0161\2\212\1\u0161\2\212\1\u0161"+
+ "\2\212\1\0\4\212\1\0\1\u0161\1\212\1\0\1\212"+
+ "\1\0\1\u0161\3\212\6\0\1\u0162\1\307\1\310\1\307"+
+ "\1\0\1\307\1\u0162\1\307\1\0\1\307\1\0\1\220"+
+ "\2\0\2\307\1\0\3\307\1\0\1\307\10\0\1\u0162"+
+ "\2\307\1\u0162\2\307\1\u0162\2\307\1\0\4\307\1\0"+
+ "\1\u0162\1\307\1\0\1\307\1\0\1\u0162\3\307\6\0"+
+ "\1\u0163\1\114\1\217\1\114\1\0\1\114\1\u0163\1\114"+
+ "\1\0\1\114\1\0\1\220\2\0\2\114\1\0\3\114"+
+ "\1\221\1\114\10\0\1\u0163\2\114\1\u0163\2\114\1\u0163"+
+ "\2\114\1\0\4\114\1\0\1\u0163\1\114\1\0\1\114"+
+ "\1\0\1\u0163\3\114\6\0\1\u0164\1\223\1\224\1\223"+
+ "\1\225\1\223\1\u0164\27\223\1\u0164\2\223\1\u0164\2\223"+
+ "\1\u0164\10\223\1\u0164\4\223\1\u0164\10\223\1\0\1\u0165"+
+ "\1\226\1\227\3\226\1\u0165\1\226\1\225\25\226\1\u0165"+
+ "\2\226\1\u0165\2\226\1\u0165\10\226\1\u0165\4\226\1\u0165"+
+ "\10\226\1\0\1\u0166\1\231\1\232\1\231\1\0\1\231"+
+ "\1\u0166\1\231\1\0\1\231\4\0\2\231\1\0\3\231"+
+ "\1\0\1\231\10\0\1\u0166\2\231\1\u0166\2\231\1\u0166"+
+ "\2\231\1\0\4\231\1\0\1\u0166\1\231\1\0\1\231"+
+ "\1\0\1\u0166\3\231\6\0\1\u0167\5\0\1\u0167\1\364"+
+ "\15\0\2\u0167\7\0\2\u0167\1\0\2\u0167\1\0\2\u0167"+
+ "\7\0\2\u0167\3\0\2\u0167\10\0\1\u0168\5\0\1\u0168"+
+ "\16\0\2\u0168\7\0\2\u0168\1\0\2\u0168\1\0\2\u0168"+
+ "\7\0\2\u0168\3\0\2\u0168\13\0\1\u0141\1\0\1\u0141"+
+ "\3\0\1\u0141\1\u011e\3\0\2\u0141\54\0\1\u0169\1\u0119"+
+ "\1\u011a\1\u0119\1\0\1\u0119\1\u0169\1\u0119\1\0\1\u0119"+
+ "\1\u011e\11\u0119\1\0\11\u0119\1\u0169\2\u0119\1\u0169\2\u0119"+
+ "\1\u0169\10\u0119\1\u0169\4\u0119\1\u0169\10\u0119\1\0\1\u016a"+
+ "\1\u011c\1\u0144\1\u011c\1\u016b\1\u011c\1\u016a\10\u011c\1\u016c"+
+ "\16\u011c\1\u016a\2\u011c\1\u016a\2\u011c\1\u016a\10\u011c\1\u016a"+
+ "\4\u011c\1\u016a\10\u011c\1\0\1\u016d\1\u011d\1\u0145\3\u011d"+
+ "\1\u016d\1\u011d\1\u016e\6\u011d\1\u016f\16\u011d\1\u016d\2\u011d"+
+ "\1\u016d\2\u011d\1\u016d\10\u011d\1\u016d\4\u011d\1\u016d\10\u011d"+
+ "\47\0\1\u0170\25\0\2\25\1\132\1\25\1\0\3\25"+
+ "\1\0\1\25\4\0\2\25\1\0\3\25\1\0\1\25"+
+ "\10\0\11\25\1\0\4\25\1\0\2\25\1\0\1\25"+
+ "\1\0\4\25\6\0\1\u0171\1\135\1\136\1\135\1\0"+
+ "\1\135\1\u0171\1\135\1\0\1\135\4\0\2\135\1\0"+
+ "\3\135\1\0\1\135\10\0\1\u0171\2\135\1\u0171\2\135"+
+ "\1\u0171\2\135\1\0\4\135\1\0\1\u0171\1\135\1\0"+
+ "\1\135\1\0\1\u0171\3\135\6\0\1\u0172\1\137\1\140"+
+ "\1\137\1\0\1\137\1\u0172\1\137\1\0\1\137\4\0"+
+ "\2\137\1\0\3\137\1\0\1\137\10\0\1\u0172\2\137"+
+ "\1\u0172\2\137\1\u0172\2\137\1\0\4\137\1\0\1\u0172"+
+ "\1\137\1\0\1\137\1\0\1\u0172\3\137\54\0\1\u0173"+
+ "\66\0\2\u0174\31\0\1\u0175\1\150\1\151\1\150\1\0"+
+ "\1\150\1\u0175\1\150\1\0\1\150\4\0\2\150\1\0"+
+ "\3\150\1\253\1\150\10\0\1\u0175\2\150\1\u0175\2\150"+
+ "\1\u0175\2\150\1\0\4\150\1\0\1\u0175\1\150\1\0"+
+ "\1\150\1\0\1\u0175\3\150\6\0\1\u0176\1\153\1\154"+
+ "\1\153\1\155\1\153\1\u0176\27\153\1\u0176\2\153\1\u0176"+
+ "\2\153\1\u0176\10\153\1\u0176\4\153\1\u0176\10\153\1\0"+
+ "\1\u0177\1\156\1\157\3\156\1\u0177\1\156\1\155\25\156"+
+ "\1\u0177\2\156\1\u0177\2\156\1\u0177\10\156\1\u0177\4\156"+
+ "\1\u0177\10\156\1\0\1\u0178\1\160\1\161\1\160\1\162"+
+ "\1\160\1\u0178\27\160\1\u0178\2\160\1\u0178\2\160\1\u0178"+
+ "\10\160\1\u0178\4\160\1\u0178\10\160\1\0\1\u0179\1\163"+
+ "\1\164\3\163\1\u0179\1\163\1\162\25\163\1\u0179\2\163"+
+ "\1\u0179\2\163\1\u0179\10\163\1\u0179\4\163\1\u0179\10\163"+
+ "\1\0\1\u017a\1\u0104\1\u0105\1\u0104\1\0\1\u0104\1\u017a"+
+ "\1\u0104\1\0\1\u0104\1\u0108\11\u0104\1\0\11\u0104\1\u017a"+
+ "\2\u0104\1\u017a\2\u0104\1\u017a\10\u0104\1\u017a\4\u0104\1\u017a"+
+ "\10\u0104\1\0\1\u017b\1\u0106\1\u012f\1\u0106\1\u012c\1\u0106"+
+ "\1\u017b\27\u0106\1\u017b\2\u0106\1\u017b\2\u0106\1\u017b\10\u0106"+
+ "\1\u017b\4\u0106\1\u017b\10\u0106\1\0\2\u0106\1\u012f\2\u012c"+
+ "\1\u0154\3\u0106\1\u0154\1\u017c\3\u0106\2\u012c\53\u0106\1\0"+
+ "\2\u0106\1\u012f\1\0\1\u012c\12\u0106\1\0\53\u0106\1\0"+
+ "\1\u017d\1\u0107\1\u0130\3\u0107\1\u017d\1\u0107\1\u012c\25\u0107"+
+ "\1\u017d\2\u0107\1\u017d\2\u0107\1\u017d\10\u0107\1\u017d\4\u0107"+
+ "\1\u017d\10\u0107\1\0\2\u0107\1\u0130\1\u012c\1\u0107\1\u0157"+
+ "\2\u0107\1\u012c\1\u0157\1\u017e\3\u0107\2\u012c\53\u0107\1\0"+
+ "\2\u0107\1\u0130\1\0\4\u0107\1\u012c\6\u0107\1\0\53\u0107"+
+ "\1\0\2\51\1\166\1\51\1\0\3\51\1\0\1\51"+
+ "\4\0\2\51\1\0\3\51\1\0\1\51\10\0\11\51"+
+ "\1\0\4\51\1\0\2\51\1\0\1\51\1\0\4\51"+
+ "\6\0\2\55\1\170\1\55\1\0\3\55\1\0\1\55"+
+ "\4\0\2\55\1\0\3\55\1\0\1\55\10\0\11\55"+
+ "\1\0\4\55\1\0\2\55\1\0\1\55\1\0\4\55"+
+ "\6\0\2\62\1\172\1\62\1\0\3\62\1\0\1\62"+
+ "\4\0\2\62\1\0\3\62\1\0\1\62\10\0\11\62"+
+ "\1\0\4\62\1\0\2\62\1\0\1\62\1\0\4\62"+
+ "\6\0\2\72\1\176\1\72\1\0\3\72\1\0\1\72"+
+ "\4\0\2\72\1\0\3\72\1\0\1\72\10\0\11\72"+
+ "\1\0\4\72\1\0\2\72\1\0\1\72\1\0\4\72"+
+ "\6\0\2\100\1\200\1\100\1\0\3\100\1\0\1\100"+
+ "\4\0\2\100\1\0\3\100\1\0\1\100\10\0\11\100"+
+ "\1\0\4\100\1\0\2\100\1\0\1\100\1\0\4\100"+
+ "\6\0\1\u017f\1\202\1\203\1\202\1\204\1\202\1\u017f"+
+ "\27\202\1\u017f\2\202\1\u017f\2\202\1\u017f\10\202\1\u017f"+
+ "\4\202\1\u017f\10\202\1\0\1\u0180\1\205\1\206\3\205"+
+ "\1\u0180\1\205\1\204\25\205\1\u0180\2\205\1\u0180\2\205"+
+ "\1\u0180\10\205\1\u0180\4\205\1\u0180\10\205\1\0\2\105"+
+ "\1\207\1\105\1\0\3\105\1\0\1\105\4\0\2\105"+
+ "\1\0\3\105\1\0\1\105\10\0\11\105\1\0\4\105"+
+ "\1\0\2\105\1\0\1\105\1\0\4\105\6\0\1\u0181"+
+ "\1\212\1\213\1\212\1\0\1\212\1\u0181\1\212\1\0"+
+ "\1\212\4\0\2\212\1\0\3\212\1\0\1\212\10\0"+
+ "\1\u0181\2\212\1\u0181\2\212\1\u0181\2\212\1\0\4\212"+
+ "\1\0\1\u0181\1\212\1\0\1\212\1\0\1\u0181\3\212"+
+ "\6\0\1\u0182\1\307\1\310\1\307\1\0\1\307\1\u0182"+
+ "\1\307\1\0\1\307\1\0\1\220\2\0\2\307\1\0"+
+ "\3\307\1\0\1\307\10\0\1\u0182\2\307\1\u0182\2\307"+
+ "\1\u0182\2\307\1\0\4\307\1\0\1\u0182\1\307\1\0"+
+ "\1\307\1\0\1\u0182\3\307\6\0\2\114\1\217\1\114"+
+ "\1\0\3\114\1\0\1\114\1\0\1\220\2\0\2\114"+
+ "\1\0\3\114\1\221\1\114\10\0\11\114\1\0\4\114"+
+ "\1\0\2\114\1\0\1\114\1\0\4\114\6\0\1\u0183"+
+ "\1\223\1\224\1\223\1\225\1\223\1\u0183\27\223\1\u0183"+
+ "\2\223\1\u0183\2\223\1\u0183\10\223\1\u0183\4\223\1\u0183"+
+ "\10\223\1\0\1\u0184\1\226\1\227\3\226\1\u0184\1\226"+
+ "\1\225\25\226\1\u0184\2\226\1\u0184\2\226\1\u0184\10\226"+
+ "\1\u0184\4\226\1\u0184\10\226\1\0\1\u0185\1\231\1\232"+
+ "\1\231\1\0\1\231\1\u0185\1\231\1\0\1\231\4\0"+
+ "\2\231\1\0\3\231\1\0\1\231\10\0\1\u0185\2\231"+
+ "\1\u0185\2\231\1\u0185\2\231\1\0\4\231\1\0\1\u0185"+
+ "\1\231\1\0\1\231\1\0\1\u0185\3\231\6\0\1\u0186"+
+ "\5\0\1\u0186\1\364\15\0\2\u0186\7\0\2\u0186\1\0"+
+ "\2\u0186\1\0\2\u0186\7\0\2\u0186\3\0\2\u0186\10\0"+
+ "\1\u0187\5\0\1\u0187\16\0\2\u0187\7\0\2\u0187\1\0"+
+ "\2\u0187\1\0\2\u0187\7\0\2\u0187\3\0\2\u0187\10\0"+
+ "\1\u0188\1\u0119\1\u011a\1\u0119\1\0\1\u0119\1\u0188\1\u0119"+
+ "\1\0\1\u0119\1\u011e\11\u0119\1\0\11\u0119\1\u0188\2\u0119"+
+ "\1\u0188\2\u0119\1\u0188\10\u0119\1\u0188\4\u0119\1\u0188\10\u0119"+
+ "\1\0\1\u0189\1\u011c\1\u0144\1\u011c\1\u0141\1\u011c\1\u0189"+
+ "\27\u011c\1\u0189\2\u011c\1\u0189\2\u011c\1\u0189\10\u011c\1\u0189"+
+ "\4\u011c\1\u0189\10\u011c\1\0\2\u011c\1\u0144\2\u0141\1\u016b"+
+ "\3\u011c\1\u016b\1\u018a\3\u011c\2\u0141\53\u011c\1\0\2\u011c"+
+ "\1\u0144\1\0\1\u0141\12\u011c\1\0\53\u011c\1\0\1\u018b"+
+ "\1\u011d\1\u0145\3\u011d\1\u018b\1\u011d\1\u0141\25\u011d\1\u018b"+
+ "\2\u011d\1\u018b\2\u011d\1\u018b\10\u011d\1\u018b\4\u011d\1\u018b"+
+ "\10\u011d\1\0\2\u011d\1\u0145\1\u0141\1\u011d\1\u016e\2\u011d"+
+ "\1\u0141\1\u016e\1\u018c\3\u011d\2\u0141\53\u011d\1\0\2\u011d"+
+ "\1\u0145\1\0\4\u011d\1\u0141\6\u011d\1\0\53\u011d\42\0"+
+ "\2\u018d\31\0\2\135\1\136\1\135\1\0\3\135\1\0"+
+ "\1\135\4\0\2\135\1\0\3\135\1\0\1\135\10\0"+
+ "\11\135\1\0\4\135\1\0\2\135\1\0\1\135\1\0"+
+ "\4\135\6\0\2\137\1\140\1\137\1\0\3\137\1\0"+
+ "\1\137\4\0\2\137\1\0\3\137\1\0\1\137\10\0"+
+ "\11\137\1\0\4\137\1\0\2\137\1\0\1\137\1\0"+
+ "\4\137\44\0\2\u018e\34\0\2\150\1\151\1\150\1\0"+
+ "\3\150\1\0\1\150\4\0\2\150\1\0\3\150\1\253"+
+ "\1\150\10\0\11\150\1\0\4\150\1\0\2\150\1\0"+
+ "\1\150\1\0\4\150\6\0\2\153\1\154\1\153\1\155"+
+ "\66\153\1\0\2\156\1\157\5\156\1\155\62\156\1\0"+
+ "\2\160\1\161\1\160\1\162\66\160\1\0\2\163\1\164"+
+ "\5\163\1\162\62\163\1\0\1\u018f\1\u0104\1\u0105\1\u0104"+
+ "\1\0\1\u0104\1\u018f\1\u0104\1\0\1\u0104\1\u0108\11\u0104"+
+ "\1\0\11\u0104\1\u018f\2\u0104\1\u018f\2\u0104\1\u018f\10\u0104"+
+ "\1\u018f\4\u0104\1\u018f\10\u0104\1\0\1\u0190\1\u0106\1\u012f"+
+ "\1\u0106\1\u012c\1\u0106\1\u0190\27\u0106\1\u0190\2\u0106\1\u0190"+
+ "\2\u0106\1\u0190\10\u0106\1\u0190\4\u0106\1\u0190\10\u0106\1\0"+
+ "\1\u0191\1\u0107\1\u0130\3\u0107\1\u0191\1\u0107\1\u012c\25\u0107"+
+ "\1\u0191\2\u0107\1\u0191\2\u0107\1\u0191\10\u0107\1\u0191\4\u0107"+
+ "\1\u0191\10\u0107\1\0\2\202\1\203\1\202\1\204\66\202"+
+ "\1\0\2\205\1\206\5\205\1\204\62\205\1\0\2\212"+
+ "\1\213\1\212\1\0\3\212\1\0\1\212\4\0\2\212"+
+ "\1\0\3\212\1\0\1\212\10\0\11\212\1\0\4\212"+
+ "\1\0\2\212\1\0\1\212\1\0\4\212\6\0\1\u0192"+
+ "\1\307\1\310\1\307\1\0\1\307\1\u0192\1\307\1\0"+
+ "\1\307\1\0\1\220\2\0\2\307\1\0\3\307\1\0"+
+ "\1\307\10\0\1\u0192\2\307\1\u0192\2\307\1\u0192\2\307"+
+ "\1\0\4\307\1\0\1\u0192\1\307\1\0\1\307\1\0"+
+ "\1\u0192\3\307\6\0\2\223\1\224\1\223\1\225\66\223"+
+ "\1\0\2\226\1\227\5\226\1\225\62\226\1\0\2\231"+
+ "\1\232\1\231\1\0\3\231\1\0\1\231\4\0\2\231"+
+ "\1\0\3\231\1\0\1\231\10\0\11\231\1\0\4\231"+
+ "\1\0\2\231\1\0\1\231\1\0\4\231\15\0\1\364"+
+ "\64\0\1\u0193\5\0\1\u0193\16\0\2\u0193\7\0\2\u0193"+
+ "\1\0\2\u0193\1\0\2\u0193\7\0\2\u0193\3\0\2\u0193"+
+ "\10\0\1\u0194\1\u0119\1\u011a\1\u0119\1\0\1\u0119\1\u0194"+
+ "\1\u0119\1\0\1\u0119\1\u011e\11\u0119\1\0\11\u0119\1\u0194"+
+ "\2\u0119\1\u0194\2\u0119\1\u0194\10\u0119\1\u0194\4\u0119\1\u0194"+
+ "\10\u0119\1\0\1\u0195\1\u011c\1\u0144\1\u011c\1\u0141\1\u011c"+
+ "\1\u0195\27\u011c\1\u0195\2\u011c\1\u0195\2\u011c\1\u0195\10\u011c"+
+ "\1\u0195\4\u011c\1\u0195\10\u011c\1\0\1\u0196\1\u011d\1\u0145"+
+ "\3\u011d\1\u0196\1\u011d\1\u0141\25\u011d\1\u0196\2\u011d\1\u0196"+
+ "\2\u011d\1\u0196\10\u011d\1\u0196\4\u011d\1\u0196\10\u011d\65\0"+
+ "\1\u0197\53\0\2\u0198\26\0\1\u0199\1\u0104\1\u0105\1\u0104"+
+ "\1\0\1\u0104\1\u0199\1\u0104\1\0\1\u0104\1\u0108\11\u0104"+
+ "\1\0\11\u0104\1\u0199\2\u0104\1\u0199\2\u0104\1\u0199\10\u0104"+
+ "\1\u0199\4\u0104\1\u0199\10\u0104\1\0\1\u019a\1\u0106\1\u012f"+
+ "\1\u0106\1\u012c\1\u0106\1\u019a\27\u0106\1\u019a\2\u0106\1\u019a"+
+ "\2\u0106\1\u019a\10\u0106\1\u019a\4\u0106\1\u019a\10\u0106\1\0"+
+ "\1\u019b\1\u0107\1\u0130\3\u0107\1\u019b\1\u0107\1\u012c\25\u0107"+
+ "\1\u019b\2\u0107\1\u019b\2\u0107\1\u019b\10\u0107\1\u019b\4\u0107"+
+ "\1\u019b\10\u0107\1\0\2\307\1\310\1\307\1\0\3\307"+
+ "\1\0\1\307\1\0\1\220\2\0\2\307\1\0\3\307"+
+ "\1\0\1\307\10\0\11\307\1\0\4\307\1\0\2\307"+
+ "\1\0\1\307\1\0\4\307\6\0\1\u019c\5\0\1\u019c"+
+ "\16\0\2\u019c\7\0\2\u019c\1\0\2\u019c\1\0\2\u019c"+
+ "\7\0\2\u019c\3\0\2\u019c\10\0\1\u019d\1\u0119\1\u011a"+
+ "\1\u0119\1\0\1\u0119\1\u019d\1\u0119\1\0\1\u0119\1\u011e"+
+ "\11\u0119\1\0\11\u0119\1\u019d\2\u0119\1\u019d\2\u0119\1\u019d"+
+ "\10\u0119\1\u019d\4\u0119\1\u019d\10\u0119\1\0\1\u019e\1\u011c"+
+ "\1\u0144\1\u011c\1\u0141\1\u011c\1\u019e\27\u011c\1\u019e\2\u011c"+
+ "\1\u019e\2\u011c\1\u019e\10\u011c\1\u019e\4\u011c\1\u019e\10\u011c"+
+ "\1\0\1\u019f\1\u011d\1\u0145\3\u011d\1\u019f\1\u011d\1\u0141"+
+ "\25\u011d\1\u019f\2\u011d\1\u019f\2\u011d\1\u019f\10\u011d\1\u019f"+
+ "\4\u011d\1\u019f\10\u011d\47\0\1\u01a0\25\0\1\u01a1\1\u0104"+
+ "\1\u0105\1\u0104\1\0\1\u0104\1\u01a1\1\u0104\1\0\1\u0104"+
+ "\1\u0108\11\u0104\1\0\11\u0104\1\u01a1\2\u0104\1\u01a1\2\u0104"+
+ "\1\u01a1\10\u0104\1\u01a1\4\u0104\1\u01a1\10\u0104\1\0\1\u01a2"+
+ "\1\u0106\1\u012f\1\u0106\1\u012c\1\u0106\1\u01a2\27\u0106\1\u01a2"+
+ "\2\u0106\1\u01a2\2\u0106\1\u01a2\10\u0106\1\u01a2\4\u0106\1\u01a2"+
+ "\10\u0106\1\0\1\u01a3\1\u0107\1\u0130\3\u0107\1\u01a3\1\u0107"+
+ "\1\u012c\25\u0107\1\u01a3\2\u0107\1\u01a3\2\u0107\1\u01a3\10\u0107"+
+ "\1\u01a3\4\u0107\1\u01a3\10\u0107\1\0\1\u01a4\1\u0119\1\u011a"+
+ "\1\u0119\1\0\1\u0119\1\u01a4\1\u0119\1\0\1\u0119\1\u011e"+
+ "\11\u0119\1\0\11\u0119\1\u01a4\2\u0119\1\u01a4\2\u0119\1\u01a4"+
+ "\10\u0119\1\u01a4\4\u0119\1\u01a4\10\u0119\1\0\1\u01a5\1\u011c"+
+ "\1\u0144\1\u011c\1\u0141\1\u011c\1\u01a5\27\u011c\1\u01a5\2\u011c"+
+ "\1\u01a5\2\u011c\1\u01a5\10\u011c\1\u01a5\4\u011c\1\u01a5\10\u011c"+
+ "\1\0\1\u01a6\1\u011d\1\u0145\3\u011d\1\u01a6\1\u011d\1\u0141"+
+ "\25\u011d\1\u01a6\2\u011d\1\u01a6\2\u011d\1\u01a6\10\u011d\1\u01a6"+
+ "\4\u011d\1\u01a6\10\u011d\1\0\2\u0104\1\u0105\1\u0104\1\0"+
+ "\3\u0104\1\0\1\u0104\1\u0108\11\u0104\1\0\46\u0104\1\0"+
+ "\1\u01a7\1\u0106\1\u012f\1\u0106\1\u012c\1\u0106\1\u01a7\27\u0106"+
+ "\1\u01a7\2\u0106\1\u01a7\2\u0106\1\u01a7\10\u0106\1\u01a7\4\u0106"+
+ "\1\u01a7\10\u0106\1\0\1\u01a8\1\u0107\1\u0130\3\u0107\1\u01a8"+
+ "\1\u0107\1\u012c\25\u0107\1\u01a8\2\u0107\1\u01a8\2\u0107\1\u01a8"+
+ "\10\u0107\1\u01a8\4\u0107\1\u01a8\10\u0107\1\0\2\u0119\1\u011a"+
+ "\1\u0119\1\0\3\u0119\1\0\1\u0119\1\u011e\11\u0119\1\0"+
+ "\46\u0119\1\0\1\u01a9\1\u011c\1\u0144\1\u011c\1\u0141\1\u011c"+
+ "\1\u01a9\27\u011c\1\u01a9\2\u011c\1\u01a9\2\u011c\1\u01a9\10\u011c"+
+ "\1\u01a9\4\u011c\1\u01a9\10\u011c\1\0\1\u01aa\1\u011d\1\u0145"+
+ "\3\u011d\1\u01aa\1\u011d\1\u0141\25\u011d\1\u01aa\2\u011d\1\u01aa"+
+ "\2\u011d\1\u01aa\10\u011d\1\u01aa\4\u011d\1\u01aa\10\u011d\1\0"+
+ "\2\u0106\1\u012f\1\u0106\1\u012c\66\u0106\1\0\2\u0107\1\u0130"+
+ "\5\u0107\1\u012c\62\u0107\1\0\2\u011c\1\u0144\1\u011c\1\u0141"+
+ "\66\u011c\1\0\2\u011d\1\u0145\5\u011d\1\u0141\62\u011d";
+
+ private static int [] zzUnpackTrans() {
+ int [] result = new int[21120];
+ int offset = 0;
+ offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ value--;
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+ /**
+ * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
+ */
+ private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+ private static final String ZZ_ATTRIBUTE_PACKED_0 =
+ "\23\0\1\11\7\1\1\11\1\1\1\11\2\1\1\11"+
+ "\3\1\1\11\6\1\1\11\3\1\2\11\3\1\1\11"+
+ "\2\1\2\11\3\1\1\11\1\1\1\11\11\1\2\11"+
+ "\6\1\1\11\6\1\1\11\1\1\1\0\1\1\1\0"+
+ "\1\1\1\0\1\1\10\0\1\1\4\0\1\11\4\0"+
+ "\1\11\4\0\1\1\1\0\1\1\1\0\1\1\1\0"+
+ "\1\11\1\0\1\1\1\0\1\1\2\0\1\11\3\0"+
+ "\1\1\1\0\1\1\3\0\1\11\1\0\1\1\1\11"+
+ "\1\1\2\0\1\11\2\0\2\1\2\0\1\1\2\0"+
+ "\1\11\1\1\1\11\2\1\10\0\1\1\1\0\1\1"+
+ "\2\0\1\1\2\0\1\1\2\0\1\1\2\0\5\1"+
+ "\1\0\1\1\2\0\1\1\1\0\3\1\1\0\1\1"+
+ "\1\0\1\1\2\0\1\1\1\0\3\1\1\0\3\1"+
+ "\2\11\5\0\1\11\1\1\5\0\5\1\2\0\4\1"+
+ "\2\0\2\1\1\0\1\1\1\0\3\1\3\0\1\11"+
+ "\1\0\1\1\10\0\1\11\5\1\2\0\4\1\2\0"+
+ "\3\1\5\0\1\11\1\0\3\1\2\0\1\11\1\0"+
+ "\1\1\6\0\1\1\2\0\5\1\2\0\4\1\2\0"+
+ "\3\1\2\0\1\1\3\0\3\1\1\0\1\11\1\0"+
+ "\1\1\13\0\5\1\2\0\4\1\2\0\3\1\10\0"+
+ "\2\1\1\11\1\0\1\1\6\0\1\1\1\0\1\1"+
+ "\2\0\2\1\2\0\3\1\2\0\1\1\1\0\1\1"+
+ "\5\0\2\1\4\0\1\11\3\0\1\11\3\0\1\11"+
+ "\12\0";
+
+ private static int [] zzUnpackAttribute() {
+ int [] result = new int[426];
+ int offset = 0;
+ offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+ return result;
+ }
+
+ private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ int i = 0; /* index in packed string */
+ int j = offset; /* index in unpacked array */
+ int l = packed.length();
+ while (i < l) {
+ int count = packed.charAt(i++);
+ int value = packed.charAt(i++);
+ do result[j++] = value; while (--count > 0);
+ }
+ return j;
+ }
+
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /* user code: */
+ private final static String UNDEFINED = "undefined";
+ private String fBufferedContext = null;
+ private int fBufferedStart;
+// private int fBufferedTextLength;
+ private int fBufferedLength;
+// private StringBuffer fBufferedText = null;
+ private CSSTextRegionFactory fRegionFactory = CSSTextRegionFactory.getInstance();
+ private int fInitialState = YYINITIAL;
+ public final static int BUFFER_SIZE_NORMAL = 16384;
+ public final static int BUFFER_SIZE_SMALL = 256;
+ private int fInitialBufferSize = BUFFER_SIZE_NORMAL;
+
+ public void setInitialState(int state) {
+ fInitialState = state;
+ }
+
+ public void setInitialBufferSize(int size) {
+ fInitialBufferSize = size;
+ }
+
+ /* user method */
+ public final ITextRegion getNextToken() throws IOException {
+ String context;
+ String nextTokenType;
+ boolean spaceFollows;
+// StringBuffer text;
+ int start;
+ int textLength;
+ int length;
+ if (fBufferedContext != null) {
+ context = fBufferedContext;
+// text = fBufferedText;
+ start = fBufferedStart;
+ textLength = length = fBufferedLength;
+
+ fBufferedContext = null;
+ } else {
+ context = primGetNextToken();
+// text = new StringBuffer(yytext());
+ start = yychar;
+ textLength = length = yylength();
+ }
+
+ if (context != null) {
+ if (context == UNDEFINED) {
+ // undef -> concatenate undef's
+ nextTokenType = primGetNextToken();
+ while (nextTokenType == UNDEFINED) {
+// text.append(yytext());
+ textLength += yylength();
+ length = textLength;
+ nextTokenType = primGetNextToken();
+ }
+ fBufferedContext = nextTokenType;
+// fBufferedText = new StringBuffer(yytext());
+ fBufferedStart = yychar;
+ fBufferedLength = yylength();
+ } else {
+ nextTokenType = null;
+ spaceFollows = false;
+ if (CSSRegionUtil.isDeclarationValueType(context)) { // declaration value can contain VALUE_S
+ nextTokenType = primGetNextToken();
+ spaceFollows = (nextTokenType == CSS_DECLARATION_VALUE_S);
+ } else if (canContainSpace(context)) {
+ nextTokenType = primGetNextToken();
+ spaceFollows = (nextTokenType == CSS_S);
+ }
+ if (nextTokenType != null) { // nextToken is retrieved
+ if (spaceFollows && (context != CSS_COMMENT)) {
+ // next is space -> append
+// text.append(yytext());
+ length += yylength();
+ } else {
+ // next is NOT space -> push this for next time, return itself
+ fBufferedContext = nextTokenType;
+// fBufferedText = new StringBuffer(yytext());
+ fBufferedStart = yychar;
+ fBufferedLength = yylength();
+ }
+ }
+ }
+ }
+
+ if (context != null) {
+ if (context == UNDEFINED) {
+ context = CSS_UNKNOWN;
+ }
+ return fRegionFactory.createRegion(context, start, textLength, length);
+ } else {
+ return null;
+ }
+ }
+
+ /* user method */
+ /* for standalone use */
+ public final List parseText() throws IOException {
+ List tokens = new ArrayList();
+
+ CSSTextToken token;
+ for (String kind = primGetNextToken(); kind != null; kind = primGetNextToken()) {
+ token = new CSSTextToken();
+ token.kind = kind;
+ token.start = yychar;
+ token.length = yylength();
+ token.image = yytext();
+ tokens.add(token);
+ }
+
+ return tokens;
+ }
+
+ /* user method */
+ private boolean canContainSpace(String type) {
+ if (type == CSS_DELIMITER || type == CSS_RBRACE || type == CSS_DECLARATION_DELIMITER) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /* user method */
+ public final int getOffset() {
+ return yychar;
+ }
+
+ /* user method */
+ public final boolean isEOF() {
+ return zzAtEOF;
+ }
+
+ /* user method */
+ public void reset(char[] charArray) {
+ reset(new CharArrayReader(charArray), 0);
+ }
+
+ /* user method */
+ public final void reset(java.io.Reader in, int newOffset) {
+ /** the input device */
+ zzReader = in;
+
+ /** the current state of the DFA */
+ zzState = 0;
+
+ /** the current lexical state */
+ zzLexicalState = fInitialState; //YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ if (zzBuffer.length != fInitialBufferSize) {
+ zzBuffer = new char[fInitialBufferSize];
+ }
+ java.util.Arrays.fill(zzBuffer, (char)0);
+
+ /** the textposition at the last accepting state */
+ zzMarkedPos = 0;
+
+ /** the textposition at the last state to be included in yytext */
+// yy_pushbackPos = 0;
+
+ /** the current text position in the buffer */
+ zzCurrentPos = 0;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ zzStartRead = 0;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ zzEndRead = 0;
+
+ /** number of newlines encountered up to the start of the matched text */
+ yyline = 0;
+
+ /** the number of characters up to the start of the matched text */
+ yychar = 0;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+// yycolumn = 0;
+
+ /**
+ * yy_atBOL == true <=> the scanner is currently at the beginning of a line
+ */
+// yy_atBOL = false;
+
+ /** zzAtEOF == true <=> the scanner has returned a value for EOF */
+ zzAtEOF = false;
+
+ /* user variables */
+ // fUndefined.delete(0, fUndefined.length());
+ }
+
+ /* user method */
+ public CSSTokenizer() {
+ super();
+ }
+
+ /**
+ * Added to workaround stricter compilation options without creating
+ * an alternate skeleton file
+ */
+ void _usePrivates() {
+ System.out.print(yycolumn);
+ System.out.print(yyline);
+ System.out.print(Boolean.toString(zzAtBOL));
+ }
+
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+ public CSSTokenizer(java.io.Reader in) {
+ this.zzReader = in;
+ }
+
+ /**
+ * Creates a new scanner.
+ * There is also java.io.Reader version of this constructor.
+ *
+ * @param in the java.io.Inputstream to read input from.
+ */
+ public CSSTokenizer(java.io.InputStream in) {
+ this(new java.io.InputStreamReader(in));
+ }
+
+ /**
+ * Unpacks the compressed character translation table.
+ *
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
+ */
+ private static char [] zzUnpackCMap(String packed) {
+ char [] map = new char[0x10000];
+ int i = 0; /* index in packed string */
+ int j = 0; /* index in unpacked array */
+ while (i < 170) {
+ int count = packed.charAt(i++);
+ char value = packed.charAt(i++);
+ do map[j++] = value; while (--count > 0);
+ }
+ return map;
+ }
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return <code>false</code>, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * <b>cannot</b> be reused (internal buffer is discarded and lost).
+ * Lexical state is set to <tt>ZZ_INITIAL</tt>.
+ *
+ * @param reader the new input stream
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yyline = yychar = yycolumn = 0;
+ zzLexicalState = YYINITIAL;
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position <tt>pos</tt> from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+ private void zzScanError(int errorCode) {
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+ throw new Error(message);
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+ public void yypushback(int number) {
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ public String primGetNextToken() throws java.io.IOException {
+ int zzInput;
+ int zzAction;
+
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+ int [] zzTransL = ZZ_TRANS;
+ int [] zzRowMapL = ZZ_ROWMAP;
+ int [] zzAttrL = ZZ_ATTRIBUTE;
+
+ while (true) {
+ zzMarkedPosL = zzMarkedPos;
+
+ yychar+= zzMarkedPosL-zzStartRead;
+
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+ zzState = ZZ_LEXSTATE[zzLexicalState];
+
+
+ zzForAction: {
+ while (true) {
+
+ if (zzCurrentPosL < zzEndReadL)
+ zzInput = zzBufferL[zzCurrentPosL++];
+ else if (zzAtEOF) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ // store back cached positions
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
+ boolean eof = zzRefill();
+ // get translated positions and possibly new buffer
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
+ if (eof) {
+ zzInput = YYEOF;
+ break zzForAction;
+ }
+ else {
+ zzInput = zzBufferL[zzCurrentPosL++];
+ }
+ }
+ int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ if (zzNext == -1) break zzForAction;
+ zzState = zzNext;
+
+ int zzAttributes = zzAttrL[zzState];
+ if ( (zzAttributes & 1) == 1 ) {
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+ if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+
+ switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+ case 32:
+ { yybegin(ST_IMPORT_MEDIUM); return CSS_STRING;
+ }
+ case 52: break;
+ case 34:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_DIMENSION;
+ }
+ case 53: break;
+ case 39:
+ // lookahead expression with fixed lookahead length
+ yypushback(1);
+ { return CSS_DECLARATION_VALUE_S;
+ }
+ case 54: break;
+ case 36:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_FUNCTION;
+ }
+ case 55: break;
+ case 20:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_ATTRIBUTE_END;
+ }
+ case 56: break;
+ case 1:
+ { return UNDEFINED;
+ }
+ case 57: break;
+ case 9:
+ { yybegin(ST_IMPORT_DELIMITER); return CSS_MEDIUM;
+ }
+ case 58: break;
+ case 37:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_STRING;
+ }
+ case 59: break;
+ case 29:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_CLASS;
+ }
+ case 60: break;
+ case 12:
+ { yybegin(YYINITIAL); return CSS_LBRACE;
+ }
+ case 61: break;
+ case 4:
+ { yybegin(YYINITIAL); return CSS_RBRACE;
+ }
+ case 62: break;
+ case 11:
+ { yybegin(ST_MEDIA_DELIMITER); return CSS_MEDIUM;
+ }
+ case 63: break;
+ case 10:
+ { yybegin(ST_IMPORT_MEDIUM); return CSS_MEDIA_SEPARATOR;
+ }
+ case 64: break;
+ case 24:
+ { yybegin(ST_DECLARATION_PRE_VALUE); return CSS_DECLARATION_SEPARATOR;
+ }
+ case 65: break;
+ case 50:
+ { yybegin(ST_FONT_FACE_DELIMITER); return CSS_FONT_FACE;
+ }
+ case 66: break;
+ case 49:
+ { yybegin(ST_CHARSET_NAME); return CSS_CHARSET;
+ }
+ case 67: break;
+ case 45:
+ { yybegin(ST_IMPORT_MEDIUM); return CSS_URI;
+ }
+ case 68: break;
+ case 19:
+ { yybegin(ST_SELECTOR_ATTRIBUTE_VALUE); return CSS_SELECTOR_ATTRIBUTE_OPERATOR;
+ }
+ case 69: break;
+ case 40:
+ { return CSS_CDC;
+ }
+ case 70: break;
+ case 15:
+ { yybegin(ST_DECLARATION); return CSS_LBRACE;
+ }
+ case 71: break;
+ case 5:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_UNIVERSAL;
+ }
+ case 72: break;
+ case 7:
+ { yybegin(ST_SELECTOR_ATTRIBUTE_NAME); return CSS_SELECTOR_ATTRIBUTE_START;
+ }
+ case 73: break;
+ case 42:
+ { return CSS_CDO;
+ }
+ case 74: break;
+ case 8:
+ { yybegin(YYINITIAL); return CSS_DELIMITER;
+ }
+ case 75: break;
+ case 18:
+ { yybegin(ST_SELECTOR_ATTRIBUTE_OPERATOR); return CSS_SELECTOR_ATTRIBUTE_NAME;
+ }
+ case 76: break;
+ case 38:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_HASH;
+ }
+ case 77: break;
+ case 44:
+ { yybegin(ST_PAGE_PSEUDO_PAGE); return CSS_PAGE;
+ }
+ case 78: break;
+ case 2:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_ELEMENT_NAME;
+ }
+ case 79: break;
+ case 31:
+ { yybegin(ST_CHARSET_DELIMITER); return CSS_STRING;
+ }
+ case 80: break;
+ case 25:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_NUMBER;
+ }
+ case 81: break;
+ case 16:
+ { yybegin(ST_SELECTOR); return CSS_SELECTOR_COMBINATOR;
+ }
+ case 82: break;
+ case 33:
+ // lookahead expression with fixed lookahead length
+ yypushback(1);
+ { yybegin(ST_SELECTOR); return CSS_SELECTOR_COMBINATOR;
+ }
+ case 83: break;
+ case 41:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_UNICODE_RANGE;
+ }
+ case 84: break;
+ case 35:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_PERCENTAGE;
+ }
+ case 85: break;
+ case 13:
+ { yybegin(ST_MEDIA_MEDIUM); return CSS_MEDIA_SEPARATOR;
+ }
+ case 86: break;
+ case 26:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_IDENT;
+ }
+ case 87: break;
+ case 14:
+ { yybegin(ST_PAGE_DELIMITER); return CSS_PAGE_SELECTOR;
+ }
+ case 88: break;
+ case 28:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_OPERATOR;
+ }
+ case 89: break;
+ case 43:
+ { return CSS_COMMENT;
+ }
+ case 90: break;
+ case 51:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_IMPORTANT;
+ }
+ case 91: break;
+ case 21:
+ { yybegin(ST_SELECTOR_ATTRIBUTE_END); return CSS_SELECTOR_ATTRIBUTE_VALUE;
+ }
+ case 92: break;
+ case 17:
+ { yybegin(ST_SELECTOR); return CSS_SELECTOR_SEPARATOR;
+ }
+ case 93: break;
+ case 3:
+ { return CSS_S;
+ }
+ case 94: break;
+ case 30:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_ID;
+ }
+ case 95: break;
+ case 48:
+ { yybegin(ST_IMPORT_URI); return CSS_IMPORT;
+ }
+ case 96: break;
+ case 27:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE;
+ }
+ case 97: break;
+ case 47:
+ { yybegin(ST_MEDIA_MEDIUM); return CSS_MEDIA;
+ }
+ case 98: break;
+ case 23:
+ { yybegin(ST_DECLARATION); return CSS_DECLARATION_DELIMITER;
+ }
+ case 99: break;
+ case 22:
+ { yybegin(ST_DECLARATION_SEPARATOR); return CSS_DECLARATION_PROPERTY;
+ }
+ case 100: break;
+ case 6:
+ { yybegin(ST_SELECTOR_MODIFIER); return CSS_SELECTOR_PSEUDO;
+ }
+ case 101: break;
+ case 46:
+ { yybegin(ST_DECLARATION_VALUE); return CSS_DECLARATION_VALUE_URI;
+ }
+ case 102: break;
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+ return null;
+ }
+ else {
+ zzScanError(ZZ_NO_MATCH);
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/ICSSTokenizer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/ICSSTokenizer.java
new file mode 100644
index 0000000..9715ecb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/ICSSTokenizer.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parser;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+/**
+ * currently provide this interface but may be removed in future.
+ */
+public interface ICSSTokenizer {
+
+ void setInitialState(int initialState);
+
+ void setInitialBufferSize(int bufsize);
+
+ boolean isEOF();
+
+ void reset(Reader reader, int i);
+
+ ITextRegion getNextToken() throws IOException;
+
+ void reset(char[] cs);
+
+ int getOffset();
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/regions/CSSTextRegionFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/regions/CSSTextRegionFactory.java
new file mode 100644
index 0000000..927ff40
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parser/regions/CSSTextRegionFactory.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parser.regions;
+
+import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+public class CSSTextRegionFactory {
+ public synchronized static CSSTextRegionFactory getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSTextRegionFactory();
+ }
+ return fInstance;
+ }
+
+ public ITextRegion createRegion(String context, int start, int textLength, int length) {
+ ITextRegion region = null;
+ region = new ContextRegion(context, start, textLength, length);
+ return region;
+ }
+
+ private CSSTextRegionFactory() {
+ super();
+ }
+
+ private static CSSTextRegionFactory fInstance = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSRegionContexts.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSRegionContexts.java
new file mode 100644
index 0000000..0027359
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSRegionContexts.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parserz;
+
+/**
+ */
+public interface CSSRegionContexts {
+ public static final String CSS_COMMENT = "COMMENT"; //$NON-NLS-1$
+ public static final String CSS_CDO = "CDO"; //$NON-NLS-1$
+ public static final String CSS_CDC = "CDC"; //$NON-NLS-1$
+ public static final String CSS_S = "S"; //$NON-NLS-1$
+
+ public static final String CSS_DELIMITER = "DELIMITER"; //$NON-NLS-1$
+ public static final String CSS_LBRACE = "LBRACE"; //$NON-NLS-1$
+ public static final String CSS_RBRACE = "RBRACE"; //$NON-NLS-1$
+
+ public static final String CSS_IMPORT = "IMPORT"; //$NON-NLS-1$
+ public static final String CSS_PAGE = "PAGE"; //$NON-NLS-1$
+ public static final String CSS_MEDIA = "MEDIA"; //$NON-NLS-1$
+ public static final String CSS_FONT_FACE = "FONT_FACE"; //$NON-NLS-1$
+ public static final String CSS_CHARSET = "CHARSET"; //$NON-NLS-1$
+ public static final String CSS_ATKEYWORD = "ATKEYWORD"; //$NON-NLS-1$
+
+ public static final String CSS_STRING = "STRING"; //$NON-NLS-1$
+ public static final String CSS_URI = "URI"; //$NON-NLS-1$
+ public static final String CSS_MEDIUM = "MEDIUM"; //$NON-NLS-1$
+ public static final String CSS_MEDIA_SEPARATOR = "MEDIA_SEPARATOR"; //$NON-NLS-1$
+
+ public static final String CSS_CHARSET_NAME = "CHARSET_NAME"; //$NON-NLS-1$
+
+ public static final String CSS_PAGE_SELECTOR = "CSS_PAGE_SELECTOR"; //$NON-NLS-1$
+
+ public static final String CSS_SELECTOR_ELEMENT_NAME = "SELECTOR_ELEMENT_NAME"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_UNIVERSAL = "SELECTOR_UNIVERSAL"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_PSEUDO = "SELECTOR_PSEUDO"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_CLASS = "SELECTOR_CLASS"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_ID = "SELECTOR_ID"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_COMBINATOR = "SELECTOR_COMBINATOR"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_SEPARATOR = "SELECTOR_SEPARATOR"; //$NON-NLS-1$
+
+ public static final String CSS_SELECTOR_ATTRIBUTE_START = "SELECTOR_ATTRIBUTE_START"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_ATTRIBUTE_END = "SELECTOR_ATTRIBUTE_END"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_ATTRIBUTE_NAME = "SELECTOR_ATTRIBUTE_NAME"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_ATTRIBUTE_VALUE = "SELECTOR_ATTRIBUTE_VALUE"; //$NON-NLS-1$
+ public static final String CSS_SELECTOR_ATTRIBUTE_OPERATOR = "SELECTOR_ATTRIBUTE_OPERATOR"; //$NON-NLS-1$
+
+ public static final String CSS_DECLARATION_PROPERTY = "DECLARATION_PROPERTY"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_SEPARATOR = "DECLARATION_SEPARATOR"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_DELIMITER = "DECLARATION_DELIMITER"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_IDENT = "DECLARATION_VALUE_IDENT"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_DIMENSION = "DECLARATION_VALUE_DIMENSION"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_PERCENTAGE = "DECLARATION_VALUE_PERCENTAGE"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_NUMBER = "DECLARATION_VALUE_NUMBER"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_FUNCTION = "DECLARATION_VALUE_FUNCTION"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE = "DECLARATION_VALUE_PARENTHESIS_CLOSE"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_STRING = "DECLARATION_VALUE_STRING"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_URI = "DECLARATION_VALUE_URI"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_HASH = "DECLARATION_VALUE_HASH"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_UNICODE_RANGE = "DECLARATION_VALUE_UNICODE_RANGE"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_IMPORTANT = "CSS_DECLARATION_VALUE_IMPORTANT"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_OPERATOR = "DECLARATION_VALUE_OPERATOR"; //$NON-NLS-1$
+ public static final String CSS_DECLARATION_VALUE_S = "DECLARATION_VALUE_S"; //$NON-NLS-1$
+
+ public static final String CSS_UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
+
+ // For null object : CSSTokenizer never set this value
+ public static final String CSS_UNDEFINED = "UNDEFINED"; //$NON-NLS-1$
+ /**
+ * currently provided this field but may be removed in future.
+ */
+ public static final String CSS_FOREIGN_ELEMENT = "FOREIGN_ELEMENT"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextParser.java
new file mode 100644
index 0000000..1253614
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextParser.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parserz;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.parser.CSSTokenizer;
+
+
+
+public class CSSTextParser {
+ public static final int MODE_STYLESHEET = 0;
+ public static final int MODE_DECLARATION = 1;
+ public static final int MODE_DECLARATION_VALUE = 2;
+
+ public CSSTextParser(int parserMode) {
+ initializeParserMode(parserMode);
+ }
+
+ public CSSTextParser(int parserMode, Reader reader) {
+ initializeParserMode(parserMode);
+ reset(reader);
+ }
+
+ public CSSTextParser(int parserMode, String input) {
+ initializeParserMode(parserMode);
+ reset(input);
+ }
+
+ public void reset(Reader reader) {
+ getTokenizer().reset(reader, 0);
+ }
+
+ public void reset(String input) {
+ getTokenizer().reset(new StringReader(input), 0);
+ }
+
+ public CSSTextToken[] getTokens() {
+ List tokenList = getTokenList();
+ CSSTextToken[] tokens = new CSSTextToken[tokenList.size()];
+ return (CSSTextToken[]) tokenList.toArray(tokens);
+ }
+
+ public List getTokenList() {
+ List tokens;
+ try {
+ tokens = getTokenizer().parseText();
+ }
+ catch (IOException e) {
+ tokens = Collections.EMPTY_LIST;
+ }
+ return tokens;
+ }
+
+ private void initializeParserMode(int parserMode) {
+ int initialState;
+ int bufsize;
+ switch (parserMode) {
+ case MODE_STYLESHEET :
+ initialState = CSSTokenizer.YYINITIAL;
+ bufsize = CSSTokenizer.BUFFER_SIZE_NORMAL;
+ break;
+ case MODE_DECLARATION :
+ initialState = CSSTokenizer.ST_DECLARATION;
+ bufsize = CSSTokenizer.BUFFER_SIZE_NORMAL;
+ break;
+ case MODE_DECLARATION_VALUE :
+ initialState = CSSTokenizer.ST_DECLARATION_PRE_VALUE;
+ bufsize = CSSTokenizer.BUFFER_SIZE_SMALL;
+ break;
+ default :
+ return;
+ }
+ if (0 < initialState) {
+ CSSTokenizer tokenizer = getTokenizer();
+ tokenizer.setInitialState(initialState);
+ tokenizer.setInitialBufferSize(bufsize);
+ }
+ }
+
+ private CSSTokenizer getTokenizer() {
+ if (fTokenizer == null) {
+ fTokenizer = new CSSTokenizer();
+ }
+ return fTokenizer;
+ }
+
+ private CSSTokenizer fTokenizer = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextToken.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextToken.java
new file mode 100644
index 0000000..fcc9078
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/parserz/CSSTextToken.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.parserz;
+
+
+public class CSSTextToken {
+ public String kind;
+ public String image;
+ public int start;
+ public int length;
+
+ public String toString() {
+ return (image != null) ? image : ""; //$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceInitializer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceInitializer.java
new file mode 100644
index 0000000..b624d16
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceInitializer.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
+import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
+
+/**
+ * Sets default values for CSS Core preferences
+ */
+public class CSSCorePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences node = new DefaultScope().getNode(CSSCorePlugin.getDefault().getBundle().getSymbolicName());
+
+ // formatting preferences
+ node.putInt(CSSCorePreferenceNames.LINE_WIDTH, 72);
+ node.putBoolean(CSSCorePreferenceNames.CLEAR_ALL_BLANK_LINES, false);
+ node.put(CSSCorePreferenceNames.INDENTATION_CHAR, CSSCorePreferenceNames.TAB);
+ node.putInt(CSSCorePreferenceNames.INDENTATION_SIZE, 1);
+
+ // cleanup preferences
+ node.putBoolean(CSSCorePreferenceNames.QUOTE_ATTR_VALUES, true);
+ node.putBoolean(CSSCorePreferenceNames.FORMAT_SOURCE, true);
+
+ // code generation preferences
+ node.put(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
+ String defaultEnc = "UTF-8";//$NON-NLS-1$
+ String systemEnc = System.getProperty("file.encoding"); //$NON-NLS-1$
+ if (systemEnc != null) {
+ defaultEnc = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, "UTF-8");//$NON-NLS-1$
+ }
+ node.put(CommonEncodingPreferenceNames.OUTPUT_CODESET, defaultEnc);
+ node.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
+
+ // this could be made smarter by actually looking up the content
+ // type's valid extensions
+ node.put(CSSCorePreferenceNames.DEFAULT_EXTENSION, "css"); //$NON-NLS-1$
+
+ // additional css core preferences
+ node.putInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM, 0);
+ node.putInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM, 1);
+ node.put(CSSCorePreferenceNames.FORMAT_QUOTE, "\"");//$NON-NLS-1$
+ node.put(CSSCorePreferenceNames.FORMAT_BETWEEN_VALUE, " ");//$NON-NLS-1$
+ node.putBoolean(CSSCorePreferenceNames.FORMAT_QUOTE_IN_URI, true);
+ node.putBoolean(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE, true);
+ node.putBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR, true);
+ node.putBoolean(CSSCorePreferenceNames.WRAPPING_NEWLINE_ON_OPEN_BRACE, false);
+ node.putInt(CSSCorePreferenceNames.CASE_IDENTIFIER, CSSCorePreferenceNames.UPPER);
+ node.putInt(CSSCorePreferenceNames.CASE_SELECTOR, CSSCorePreferenceNames.LOWER);
+ node.putInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME, CSSCorePreferenceNames.LOWER);
+ node.putInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE, CSSCorePreferenceNames.LOWER);
+
+ // CSS cleanup preferences
+ node.putInt(CSSCorePreferenceNames.CLEANUP_CASE_IDENTIFIER, CSSCorePreferenceNames.ASIS);
+ node.putInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_NAME, CSSCorePreferenceNames.ASIS);
+ node.putInt(CSSCorePreferenceNames.CLEANUP_CASE_PROPERTY_VALUE, CSSCorePreferenceNames.ASIS);
+ node.putInt(CSSCorePreferenceNames.CLEANUP_CASE_SELECTOR, CSSCorePreferenceNames.ASIS);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceNames.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceNames.java
new file mode 100644
index 0000000..d6fdf06
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/preferences/CSSCorePreferenceNames.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.preferences;
+
+/**
+ * CSS core preference keys.
+ *
+ * @plannedfor 1.0
+ */
+public class CSSCorePreferenceNames {
+ private CSSCorePreferenceNames() {
+ // empty private constructor so users cannot instantiate class
+ }
+
+ public static final String CASE_IDENTIFIER = "identifierCase"; //$NON-NLS-1$
+ public static final String CASE_SELECTOR = "selectorCase"; //$NON-NLS-1$
+ public static final String CASE_PROPERTY_NAME = "propNameCase"; //$NON-NLS-1$
+ public static final String CASE_PROPERTY_VALUE = "propValueCase"; //$NON-NLS-1$
+ public static final String FORMAT_BETWEEN_VALUE = "betweenValue"; //$NON-NLS-1$
+ public static final String FORMAT_PROP_POST_DELIM = "postDelim"; //$NON-NLS-1$
+ public static final String FORMAT_PROP_PRE_DELIM = "preDelim"; //$NON-NLS-1$
+ public static final String FORMAT_QUOTE = "quote"; //$NON-NLS-1$
+ public static final String FORMAT_QUOTE_IN_URI = "quoteInURI"; //$NON-NLS-1$
+ public static final String WRAPPING_NEWLINE_ON_OPEN_BRACE = "newLineOnOpenBrace"; //$NON-NLS-1$
+ public static final String WRAPPING_ONE_PER_LINE = "onePropertyPerLine"; //$NON-NLS-1$
+ public static final String WRAPPING_PROHIBIT_WRAP_ON_ATTR = "prohibitWrapOnAttr"; //$NON-NLS-1$
+
+ // CSS cleanup preference names
+ public static final String CLEANUP_CASE_IDENTIFIER = "cleanupIdentifierCase"; //$NON-NLS-1$
+ public static final String CLEANUP_CASE_PROPERTY_NAME = "cleanupPropNameCase"; //$NON-NLS-1$
+ public static final String CLEANUP_CASE_PROPERTY_VALUE = "cleanupPropValueCase"; //$NON-NLS-1$
+ public static final String CLEANUP_CASE_SELECTOR = "cleanupSelectorCase"; //$NON-NLS-1$
+
+ /**
+ * The default extension to use when none is specified in the New CSS File
+ * Wizard.
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ */
+ public static final String DEFAULT_EXTENSION = "defaultExtension"; //$NON-NLS-1$
+
+ /**
+ * The maximum width of a line before a line split is needed.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ */
+ public static final String LINE_WIDTH = "lineWidth";//$NON-NLS-1$
+
+ /**
+ * Indicates if all blanks lines should be cleared during formatting.
+ * Blank lines will be kept when false.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String CLEAR_ALL_BLANK_LINES = "clearAllBlankLines";//$NON-NLS-1$
+
+ /**
+ * The number of #INDENTATION_CHAR for 1 indentation.
+ * <p>
+ * Value is of type <code>Integer</code>.
+ * </p>
+ */
+ public static final String INDENTATION_SIZE = "indentationSize";//$NON-NLS-1$
+
+ /**
+ * The character used for indentation.
+ * <p>
+ * Value is of type <code>String</code>.<br />
+ * Possible values: {TAB, SPACE}
+ * </p>
+ */
+ public static final String INDENTATION_CHAR = "indentationChar";//$NON-NLS-1$
+
+ /**
+ * Possible value for the preference #INDENTATION_CHAR. Indicates to use
+ * tab character when formatting.
+ *
+ * @see #SPACE
+ * @see #INDENTATION_CHAR
+ */
+ public static final String TAB = "tab"; //$NON-NLS-1$
+
+ /**
+ * Possible value for the preference #INDENTATION_CHAR. Indicates to use
+ * space character when formatting.
+ *
+ * @see #TAB
+ * @see #INDENTATION_CHAR
+ */
+ public static final String SPACE = "space"; //$NON-NLS-1$
+
+ /**
+ * Indicates whether or not to quote all attribute values during cleanup.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
+
+ /**
+ * Indicates whether or not cleanup processor should format source.
+ * <p>
+ * Value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public static final String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
+
+ /**
+ * Possible value for the case preferences Indicates to leave case as is.
+ *
+ * @see #LOWER
+ * @see #UPPER
+ */
+ public static final int ASIS = 0;
+
+ /**
+ * Possible value for the case preferences Indicates to make name
+ * lowercase.
+ *
+ * @see #ASIS
+ * @see #UPPER
+ */
+ public static final int LOWER = 1;
+
+ /**
+ * Possible value for the case preferences Indicates to make name
+ * uppercase.
+ *
+ * @see #LOWER
+ * @see #ASIS
+ */
+ public static final int UPPER = 2;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/ICSSModelAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/ICSSModelAdapter.java
new file mode 100644
index 0000000..f018816
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/ICSSModelAdapter.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+
+
+/**
+ */
+public interface ICSSModelAdapter extends INodeAdapter {
+
+ ICSSModel getModel();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IModelProvideAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IModelProvideAdapter.java
new file mode 100644
index 0000000..d1f94d2
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IModelProvideAdapter.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+/**
+ *
+ */
+public interface IModelProvideAdapter extends INodeAdapter {
+
+ /**
+ *
+ */
+ void modelProvided(IStructuredModel newModel);
+
+ /**
+ */
+ void modelReleased(IStructuredModel newModel);
+
+ /**
+ */
+ void modelRemoved(IStructuredModel newModel);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleDeclarationAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleDeclarationAdapter.java
new file mode 100644
index 0000000..436a937
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleDeclarationAdapter.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+
+/**
+ */
+public interface IStyleDeclarationAdapter extends ICSSModelAdapter {
+
+ /**
+ */
+ public CSSStyleDeclaration getStyle();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSelectorAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSelectorAdapter.java
new file mode 100644
index 0000000..d0e2977
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSelectorAdapter.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.w3c.dom.Element;
+
+
+/**
+ *
+ */
+public interface IStyleSelectorAdapter extends INodeAdapter {
+
+ /**
+ * @return boolean
+ * @param element
+ * org.w3c.dom.Element
+ * @param pseudoName
+ * java.lang.String
+ */
+ boolean match(ICSSSimpleSelector selector, Element element, String pseudoName);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetAdapter.java
new file mode 100644
index 0000000..814752d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetAdapter.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import org.w3c.dom.Element;
+import org.w3c.dom.stylesheets.StyleSheet;
+
+/**
+ */
+public interface IStyleSheetAdapter extends ICSSModelAdapter {
+
+ /**
+ * Returns HTML/XML element that is the owner of this adapter
+ */
+ Element getElement();
+
+ /**
+ * Returns CSS document that is related to this element
+ */
+ public StyleSheet getSheet();
+
+ /**
+ * This is called at the time of releasing HTML/XML model
+ */
+ public void released();
+
+ /**
+ * This is called at the time of removing this Element from the document
+ */
+ public void removed();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetListAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetListAdapter.java
new file mode 100644
index 0000000..8e63889
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/adapters/IStyleSheetListAdapter.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.adapters;
+
+
+
+import java.util.Enumeration;
+
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.w3c.dom.Element;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.stylesheets.StyleSheetList;
+
+/**
+ */
+public interface IStyleSheetListAdapter extends INodeAdapter {
+
+ /**
+ */
+ Enumeration getClasses();
+
+ /**
+ */
+ public CSSStyleDeclaration getOverrideStyle(Element element, String pseudoName);
+
+ /**
+ */
+ public StyleSheetList getStyleSheets();
+
+ /**
+ */
+ public void releaseStyleSheets();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/contenttype/ContentTypeIdForCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/contenttype/ContentTypeIdForCSS.java
new file mode 100644
index 0000000..79622cf
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/contenttype/ContentTypeIdForCSS.java
@@ -0,0 +1,30 @@
+package org.eclipse.wst.css.core.internal.provisional.contenttype;
+
+
+/**
+ * This class, with its one field, is a convience to provide compile-time
+ * safety when refering to a contentType ID. The value of the contenttype id
+ * field must match what is specified in plugin.xml file.
+ */
+
+public class ContentTypeIdForCSS {
+ /**
+ * The value of the contenttype id field must match what is specified in
+ * plugin.xml file. Note: this value is intentially set with default
+ * protected method so it will not be inlined.
+ */
+ public final static String ContentTypeID_CSS = getConstantString();
+
+ /**
+ * Don't allow instantiation.
+ */
+ private ContentTypeIdForCSS() {
+ super();
+ }
+
+ static String getConstantString() {
+ return "org.eclipse.wst.css.core.csssource"; //$NON-NLS-1$
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAccess.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAccess.java
new file mode 100644
index 0000000..9d2afa2
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAccess.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import java.util.Vector;
+
+/**
+ *
+ */
+public interface ICSSAccess {
+
+ /**
+ * @return java.util.Vector
+ */
+ Vector getClassNames();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAttr.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAttr.java
new file mode 100644
index 0000000..cd80a8c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSAttr.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSAttr extends ICSSNode {
+
+ /**
+ * @return java.lang.String
+ */
+ String getName();
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ */
+ ICSSNode getOwnerCSSNode();
+
+ /**
+ * @return java.lang.String
+ */
+ String getValue();
+
+ /**
+ * @param newValue
+ * java.lang.String
+ */
+ void setValue(String newValue);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSCharsetRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSCharsetRule.java
new file mode 100644
index 0000000..1a34ed1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSCharsetRule.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSCharsetRule;
+
+/**
+ *
+ */
+public interface ICSSCharsetRule extends ICSSNode, CSSCharsetRule {
+
+ java.lang.String ENCODING = "encoding"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSDocument.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSDocument.java
new file mode 100644
index 0000000..a56c0d9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSDocument.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSFontFaceRule;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSUnknownRule;
+import org.w3c.dom.stylesheets.MediaList;
+
+/**
+ *
+ */
+public interface ICSSDocument extends ICSSNode {
+
+ /**
+ * @return org.w3c.dom.css.CSSCharsetRule
+ */
+ ICSSCharsetRule createCSSCharsetRule();
+
+ /**
+ * @return org.w3c.dom.css.CSSFontFaceRule
+ */
+ CSSFontFaceRule createCSSFontFaceRule();
+
+ /**
+ * @return org.w3c.dom.css.CSSImportRule
+ */
+ ICSSImportRule createCSSImportRule();
+
+ /**
+ * @return org.w3c.dom.css.ICSSMediaRule
+ */
+ ICSSMediaRule createCSSMediaRule();
+
+ /**
+ * @return org.w3c.dom.css.CSSPageRule
+ */
+ ICSSPageRule createCSSPageRule();
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ */
+ ICSSPrimitiveValue createCSSPrimitiveValue(short primitiveType);
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * java.lang.String
+ */
+ CSSRule createCSSRule(String rule);
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleDeclaration
+ */
+ ICSSStyleDeclaration createCSSStyleDeclaration();
+
+ /**
+ * @param propertyName
+ * java.lang.String
+ */
+ ICSSStyleDeclItem createCSSStyleDeclItem(String propertyName);
+
+ /**
+ * @return org.w3c.dom.css.CSSStyleRule
+ */
+ ICSSStyleRule createCSSStyleRule();
+
+ /**
+ * @return org.w3c.dom.css.CSSUnknownRule
+ */
+ CSSUnknownRule createCSSUnknownRule();
+
+ /**
+ * @return org.w3c.dom.stylesheets.MediaList
+ */
+ MediaList createMediaList();
+
+ ICSSModel getModel();
+
+ /**
+ * @return boolean
+ */
+ boolean isDocument();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSImportRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSImportRule.java
new file mode 100644
index 0000000..21d90d1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSImportRule.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSImportRule;
+
+/**
+ *
+ */
+public interface ICSSImportRule extends ICSSNode, CSSImportRule {
+
+ java.lang.String HREF = "href"; //$NON-NLS-1$
+
+ /**
+ *
+ */
+ void refreshStyleSheet();
+
+ /**
+ * @param href
+ * java.lang.String
+ */
+ void setHref(String href);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSMediaRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSMediaRule.java
new file mode 100644
index 0000000..c840336
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSMediaRule.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSMediaRule;
+
+/**
+ *
+ */
+public interface ICSSMediaRule extends ICSSNode, ICSSRuleContainer, CSSMediaRule {
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSModel.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSModel.java
new file mode 100644
index 0000000..596e571
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSModel.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.eclipse.wst.css.core.internal.event.ICSSStyleNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.w3c.dom.Node;
+
+
+/**
+ *
+ */
+public interface ICSSModel extends ICSSStyleNotifier, IStructuredModel {
+
+ public static final String EXTERNAL = "externalCSS"; //$NON-NLS-1$
+ public static final String EMBEDDED = "embeddedCSS"; //$NON-NLS-1$
+ public static final String INLINE = "inlineCSS"; //$NON-NLS-1$
+
+ ICSSDocument getDocument();
+
+ /**
+ * @return org.w3c.dom.Node
+ */
+ Node getOwnerDOMNode();
+
+ /**
+ *
+ * @return java.lang.Object
+ */
+ Object getStyleSheetType();
+
+ /**
+ * cleanup -> rebuild CSS Nodes This is pre-beta fix for 178176.
+ */
+ void refreshNodes();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNamedNodeMap.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNamedNodeMap.java
new file mode 100644
index 0000000..82869c2
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNamedNodeMap.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSNamedNodeMap extends ICSSNodeList {
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNode
+ * @param name
+ * java.lang.String
+ */
+ ICSSNode getNamedItem(String name);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNode.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNode.java
new file mode 100644
index 0000000..eb17e53
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNode.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSNode {
+
+ short ATTR_NODE = -1;
+ short UNKNOWNRULE_NODE = 0;
+ short STYLERULE_NODE = 1;
+ short CHARSETRULE_NODE = 2;
+ short IMPORTRULE_NODE = 3;
+ short MEDIARULE_NODE = 4;
+ short FONTFACERULE_NODE = 5;
+ short PAGERULE_NODE = 6;
+ short STYLESHEET_NODE = 7;
+ short STYLEDECLARATION_NODE = 8;
+ short STYLEDECLITEM_NODE = 9;
+ short VALUELIST_NODE = 10;
+ short PRIMITIVEVALUE_NODE = 11;
+ short MEDIALIST_NODE = 12;
+ short DOCUMENTCSSSTYLE_NODE = 13;
+ short LINKSTYLE_NODE = 14;
+ short ELEMENTCSSINLINESTYLE_NODE = 15;
+
+ ICSSNode cloneNode(boolean deep);
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSNamedNodeMap
+ */
+ ICSSNamedNodeMap getAttributes();
+
+ ICSSNodeList getChildNodes();
+
+ ICSSNode getFirstChild();
+
+ ICSSNode getLastChild();
+
+ ICSSNode getNextSibling();
+
+ /**
+ * @return short
+ */
+ short getNodeType();
+
+ ICSSDocument getOwnerDocument();
+
+ ICSSNode getParentNode();
+
+ ICSSNode getPreviousSibling();
+
+ /**
+ * @return boolean
+ */
+ boolean hasChildNodes();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNodeList.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNodeList.java
new file mode 100644
index 0000000..310dfbb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSNodeList.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSNodeList {
+
+ /**
+ * @return int
+ */
+ int getLength();
+
+ ICSSNode item(int index);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPageRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPageRule.java
new file mode 100644
index 0000000..96a24a0
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPageRule.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSPageRule;
+
+public interface ICSSPageRule extends ICSSNode, CSSPageRule {
+
+ java.lang.String SELECTOR = "selector"; //$NON-NLS-1$
+
+ ICSSSelectorList getSelectors();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPrimitiveValue.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPrimitiveValue.java
new file mode 100644
index 0000000..ebeacb8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSPrimitiveValue.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSPrimitiveValue;
+
+/**
+ *
+ */
+public interface ICSSPrimitiveValue extends ICSSNode, ICSSValue, CSSPrimitiveValue {
+
+ short CSS_INTEGER = 26;
+ short CSS_HASH = 27;
+ short CSS_URANGE = 28;
+ short CSS_FORMAT = 29;
+ short CSS_LOCAL = 30;
+ short CSS_SLASH = 31;
+ short CSS_COMMA = 32;
+ short CSS_INHERIT_PRIMITIVE = 33;
+
+ /**
+ * @param floatValue
+ * float
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ void setValue(float floatValue) throws org.w3c.dom.DOMException;
+
+ /**
+ * @param stringValue
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ void setValue(String stringValue) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSRuleContainer.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSRuleContainer.java
new file mode 100644
index 0000000..29ae596
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSRuleContainer.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.css.CSSRule;
+
+/**
+ *
+ */
+public interface ICSSRuleContainer {
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ CSSRule appendRule(CSSRule rule) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newRule
+ * org.w3c.dom.css.CSSRule
+ * @param refRule
+ * org.w3c.dom.css.CSSRule
+ */
+ CSSRule insertRuleBefore(CSSRule newRule, CSSRule refRule) throws DOMException;
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param rule
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ CSSRule removeRule(CSSRule rule) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.css.CSSRule
+ * @param newChild
+ * org.w3c.dom.css.CSSRule
+ * @param oldChild
+ * org.w3c.dom.css.CSSRule
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ CSSRule replaceRule(CSSRule newRule, CSSRule oldRule) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelector.java
new file mode 100644
index 0000000..3e9541c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelector.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import java.util.Iterator;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ */
+public interface ICSSSelector {
+
+ ICSSSelectorItem getItem(int index);
+
+ /**
+ * @return java.util.Iterator
+ */
+ Iterator getIterator();
+
+ /**
+ * @return int
+ */
+ int getLength();
+
+ /**
+ * @return int
+ */
+ int getSpecificity();
+
+ /**
+ * @return java.lang.String
+ */
+ String getString();
+
+ /**
+ * @return boolean
+ * @param element
+ * org.w3c.dom.Element
+ */
+ boolean match(Element element, String pseudoName);
+
+ /**
+ *
+ */
+ Iterator getErrors();
+
+ /**
+ *
+ */
+ int getErrorCount();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorCombinator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorCombinator.java
new file mode 100644
index 0000000..fe443c0
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorCombinator.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSSelectorCombinator extends ICSSSelectorItem {
+
+ public static final char DESCENDANT = ' ';
+ public static final char CHILD = '>';
+ public static final char ADJACENT = '+';
+ public static final char UNKNOWN = '?'; // error case
+
+ /**
+ * @return int
+ */
+ char getCombinatorType();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorItem.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorItem.java
new file mode 100644
index 0000000..34fe8f8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorItem.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSSelectorItem {
+
+ public static final int SIMPLE = 1;
+ public static final int COMBINATOR = 2;
+
+ /**
+ * @return int
+ */
+ int getItemType();
+
+ /**
+ * @return java.lang.String
+ */
+ String getString();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorList.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorList.java
new file mode 100644
index 0000000..077fd0c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSelectorList.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import java.util.Iterator;
+
+import org.w3c.dom.Element;
+
+/**
+ *
+ */
+public interface ICSSSelectorList {
+
+ /**
+ * @return java.util.Iterator
+ */
+ Iterator getIterator();
+
+ /**
+ * @return int
+ */
+ int getLength();
+
+ /**
+ * @return java.util.Vector
+ * @param index
+ * int
+ */
+ ICSSSelector getSelector(int index);
+
+ /**
+ * @return java.lang.String
+ */
+ String getString();
+
+ /**
+ *
+ */
+ int getErrorCount();
+
+ /**
+ *
+ */
+ Iterator getErrors();
+
+ /**
+ * @return boolean
+ * @param element
+ * org.w3c.dom.Element
+ */
+ boolean match(Element element, String pseudoName);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSimpleSelector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSimpleSelector.java
new file mode 100644
index 0000000..5d9fb82
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSSimpleSelector.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+/**
+ *
+ */
+public interface ICSSSimpleSelector extends ICSSSelectorItem {
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ String getAttribute(int index);
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ String getClass(int index);
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ String getID(int index);
+
+ /**
+ * @return java.lang.String
+ */
+ String getName();
+
+ /**
+ * @return boolean
+ */
+ int getNumOfAttributes();
+
+ /**
+ * @return boolean
+ */
+ int getNumOfClasses();
+
+ /**
+ * @return boolean
+ */
+ int getNumOfIDs();
+
+ /**
+ * @return boolean
+ */
+ int getNumOfPseudoNames();
+
+ /**
+ * @return java.lang.String
+ * @param index
+ * int
+ */
+ String getPseudoName(int index);
+
+ /**
+ * @return boolean
+ */
+ boolean isUniversal();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclItem.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclItem.java
new file mode 100644
index 0000000..029cd6b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclItem.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSValue;
+
+/**
+ *
+ */
+public interface ICSSStyleDeclItem extends ICSSNode, ICSSValueList {
+
+ java.lang.String IMPORTANT = "important"; //$NON-NLS-1$
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ ICSSPrimitiveValue appendValue(ICSSPrimitiveValue value) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.css.CSSValue
+ */
+ CSSValue getCSSValue();
+
+ /**
+ * @return java.lang.String
+ */
+ String getPriority();
+
+ /**
+ * @return java.lang.String
+ */
+ String getPropertyName();
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ ICSSPrimitiveValue removeValue(ICSSPrimitiveValue value) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param newValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @param oldValue
+ * org.w3c.dom.css.CSSPrimitiveValue
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ ICSSPrimitiveValue replaceValue(ICSSPrimitiveValue newValue, ICSSPrimitiveValue oldValue) throws org.w3c.dom.DOMException;
+
+ /**
+ * @param priority
+ * java.lang.String
+ */
+ void setPriority(String priority);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclaration.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclaration.java
new file mode 100644
index 0000000..7e87366
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleDeclaration.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+public interface ICSSStyleDeclaration extends ICSSDocument, CSSStyleDeclaration {
+
+ ICSSStyleDeclItem getDeclItemNode(String propertyName);
+
+ ICSSStyleDeclItem removeDeclItemNode(ICSSStyleDeclItem oldDecl) throws org.w3c.dom.DOMException;
+
+ ICSSStyleDeclItem setDeclItemNode(ICSSStyleDeclItem newDecl) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleRule.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleRule.java
new file mode 100644
index 0000000..ac4e1a6
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleRule.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSStyleRule;
+
+public interface ICSSStyleRule extends ICSSNode, CSSStyleRule {
+
+ java.lang.String SELECTOR = "selector"; //$NON-NLS-1$
+
+ ICSSSelectorList getSelectors();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleSheet.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleSheet.java
new file mode 100644
index 0000000..51a82bb
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSStyleSheet.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.css.CSSStyleSheet;
+import org.w3c.dom.stylesheets.StyleSheetList;
+
+/**
+ *
+ */
+public interface ICSSStyleSheet extends ICSSDocument, ICSSRuleContainer, CSSStyleSheet {
+
+ /**
+ * @return org.w3c.dom.NodeList
+ */
+ NodeList getOwnerNodes();
+
+ /**
+ * @return org.w3c.dom.NodeList
+ * @param doc
+ * org.w3c.dom.Document
+ */
+ NodeList getOwnerNodes(Document doc);
+
+ /**
+ * @return org.w3c.dom.css.CSSRuleList
+ */
+ CSSRuleList getOwnerRules();
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheetList
+ */
+ StyleSheetList getParentStyleSheets();
+
+ /**
+ * The list of all CSS rules contained within the stylesheet and, if requested, the rules
+ * from imported stylesheets are merged into the rule list.
+ * @param shouldImport indicates if rules from imported stylesheets should be returned
+ * @return the list of all of the rules in the stylesheet, and if requested,
+ * any rules from imported stylesheets
+ */
+ CSSRuleList getCssRules(boolean shouldImport);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValue.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValue.java
new file mode 100644
index 0000000..1769140
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValue.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSValue;
+
+/**
+ *
+ */
+public interface ICSSValue extends CSSValue {
+
+ /**
+ * @return java.lang.String
+ */
+ String getCSSValueText();
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValueList.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValueList.java
new file mode 100644
index 0000000..b49c575
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICSSValueList.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.CSSValueList;
+
+/**
+ *
+ */
+public interface ICSSValueList extends ICSSValue, CSSValueList {
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ ICSSPrimitiveValue appendValue(ICSSPrimitiveValue value);
+
+ /**
+ * @return org.w3c.dom.css.CSSPrimitiveValue
+ * @param value
+ * org.w3c.dom.css.CSSPrimitiveValue
+ */
+ ICSSPrimitiveValue removeValue(ICSSPrimitiveValue value);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICounter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICounter.java
new file mode 100644
index 0000000..ff824b8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/ICounter.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.Counter;
+
+/**
+ *
+ */
+public interface ICounter extends ICSSNode, Counter {
+
+ java.lang.String IDENTIFIER = "identifier"; //$NON-NLS-1$
+ java.lang.String LISTSTYLE = "liststyle"; //$NON-NLS-1$
+ java.lang.String SEPARATOR = "separator"; //$NON-NLS-1$
+
+ /**
+ * @param identifier
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ void setIdentifier(String identifier) throws org.w3c.dom.DOMException;
+
+ /**
+ * @param listStyle
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ void setListStyle(String listStyle) throws org.w3c.dom.DOMException;
+
+ /**
+ * @param Separator
+ * java.lang.String
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ void setSeparator(String separator) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDOMImplementationCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDOMImplementationCSS.java
new file mode 100644
index 0000000..dc44e98
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDOMImplementationCSS.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.css.DOMImplementationCSS;
+
+/**
+ *
+ */
+public interface IDOMImplementationCSS extends DOMImplementationCSS {
+
+ ICSSStyleDeclaration createCSSStyleDeclaration() throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDocumentStyle.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDocumentStyle.java
new file mode 100644
index 0000000..6a46066
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/document/IDocumentStyle.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.document;
+
+
+
+import org.w3c.dom.stylesheets.DocumentStyle;
+import org.w3c.dom.stylesheets.StyleSheet;
+
+/**
+ *
+ */
+public interface IDocumentStyle extends DocumentStyle {
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheet
+ * @param newSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ StyleSheet appendSheet(StyleSheet newSheet) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheet
+ * @param newSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @param refSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ StyleSheet insertSheetBefore(StyleSheet newSheet, StyleSheet refSheet) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheet
+ * @param oldSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ StyleSheet removeSheet(StyleSheet oldSheet) throws org.w3c.dom.DOMException;
+
+ /**
+ * @return org.w3c.dom.stylesheets.StyleSheet
+ * @param newSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @param oldSheet
+ * org.w3c.dom.stylesheets.StyleSheet
+ * @exception org.w3c.dom.DOMException
+ * The exception description.
+ */
+ StyleSheet replaceSheet(StyleSheet newSheet, StyleSheet oldSheet) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/preferences/CSSPreferenceHelper.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/preferences/CSSPreferenceHelper.java
new file mode 100644
index 0000000..e1fafe6
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/preferences/CSSPreferenceHelper.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.preferences;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+
+/**
+ * @deprecated just access preferences directly
+ */
+public class CSSPreferenceHelper {
+
+ /**
+ *
+ */
+ public synchronized static CSSPreferenceHelper getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSPreferenceHelper();
+ }
+ return fInstance;
+ }
+
+ /**
+ *
+ */
+ public String getBetweenValueString() {
+ return getPreferences().getString(CSSCorePreferenceNames.FORMAT_BETWEEN_VALUE);
+ }
+
+ /**
+ *
+ */
+ public String getIndentString() {
+ StringBuffer indent = new StringBuffer();
+
+ Preferences preferences = getPreferences();
+ if (preferences != null) {
+ char indentChar = ' ';
+ String indentCharPref = preferences.getString(CSSCorePreferenceNames.INDENTATION_CHAR);
+ if (CSSCorePreferenceNames.TAB.equals(indentCharPref)) {
+ indentChar = '\t';
+ }
+ int indentationWidth = preferences.getInt(CSSCorePreferenceNames.INDENTATION_SIZE);
+
+ for (int i = 0; i < indentationWidth; i++) {
+ indent.append(indentChar);
+ }
+ }
+ return indent.toString();
+ }
+
+ /**
+ *
+ */
+ public int getMaxLineWidth() {
+ Preferences prefs = getPreferences();
+ return prefs.getInt(CSSCorePreferenceNames.LINE_WIDTH);
+ }
+
+ /**
+ *
+ */
+ public String getQuoteString(ICSSModel model) {
+ // nakamori_TODO css pref transition
+ return getPreferences().getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ }
+
+ /**
+ *
+ */
+ public int getSpacesPostDelimiter() {
+ return getPreferences().getInt(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM);
+ }
+
+ /**
+ *
+ */
+ public int getSpacesPreDelimiter() {
+ return getPreferences().getInt(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM);
+ }
+
+ /**
+ *
+ */
+ public boolean isIdentUpperCase() {
+ if (getPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean isNewLineOnOpenBrace() {
+ return getPreferences().getBoolean(CSSCorePreferenceNames.WRAPPING_NEWLINE_ON_OPEN_BRACE);
+ }
+
+ /**
+ *
+ */
+ public boolean isOnePropertyPerLine() {
+ return getPreferences().getBoolean(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE);
+ }
+
+ /**
+ *
+ */
+ public boolean isProhibitWrapOnAttr() {
+ return getPreferences().getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR);
+ }
+
+ /**
+ *
+ */
+ public boolean isPropNameUpperCase() {
+ if (getPreferences().getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER)
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean isPropValueUpperCase() {
+ if (getPreferences().getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean isQuoteInURI() {
+ return getPreferences().getBoolean(CSSCorePreferenceNames.FORMAT_QUOTE_IN_URI);
+ }
+
+ /**
+ *
+ */
+ protected void setBetweenValueString(String newBetweenValueString) {
+ getPreferences().setValue(CSSCorePreferenceNames.FORMAT_BETWEEN_VALUE, newBetweenValueString);
+ }
+
+ /**
+ *
+ */
+ protected void setIdentUpperCase(boolean newIdentUpperCase) {
+ int theCase = CSSCorePreferenceNames.LOWER;
+ if (newIdentUpperCase)
+ theCase = CSSCorePreferenceNames.UPPER;
+ getPreferences().setValue(CSSCorePreferenceNames.CASE_IDENTIFIER, theCase);
+ }
+
+ /**
+ *
+ */
+ protected void setOnePropertyPerLine(boolean newOnePropertyPerLine) {
+ getPreferences().setValue(CSSCorePreferenceNames.WRAPPING_ONE_PER_LINE, newOnePropertyPerLine);
+ }
+
+ /**
+ *
+ */
+ protected void setProhibitWrapOnAttr(boolean newProhibitWrapOnAttr) {
+ getPreferences().setValue(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR, newProhibitWrapOnAttr);
+ }
+
+ /**
+ *
+ */
+ protected void setPropNameUpperCase(boolean newPropNameUpperCase) {
+ int theCase = CSSCorePreferenceNames.LOWER;
+ if (newPropNameUpperCase)
+ theCase = CSSCorePreferenceNames.UPPER;
+ getPreferences().setValue(CSSCorePreferenceNames.CASE_PROPERTY_NAME, theCase);
+ }
+
+ /**
+ *
+ */
+ protected void setPropValueUpperCase(boolean newPropValueUpperCase) {
+ int theCase = CSSCorePreferenceNames.LOWER;
+ if (newPropValueUpperCase)
+ theCase = CSSCorePreferenceNames.UPPER;
+ getPreferences().setValue(CSSCorePreferenceNames.CASE_PROPERTY_VALUE, theCase);
+ }
+
+ /**
+ *
+ */
+ public void setQuoteString(String quote) {
+ getPreferences().setValue(CSSCorePreferenceNames.FORMAT_QUOTE, quote);
+ }
+
+ /**
+ *
+ */
+ public void setSpacesPostDelimiter(int num) {
+ getPreferences().setValue(CSSCorePreferenceNames.FORMAT_PROP_POST_DELIM, num);
+ }
+
+ /**
+ *
+ */
+ public void setSpacesPreDelimiter(int num) {
+ getPreferences().setValue(CSSCorePreferenceNames.FORMAT_PROP_PRE_DELIM, num);
+ }
+
+ private Preferences getPreferences() {
+ CSSCorePlugin cssModelPlugin = CSSCorePlugin.getDefault();
+ return cssModelPlugin.getPluginPreferences();
+ }
+
+ private CSSPreferenceHelper() {
+ super();
+ }
+
+ private static CSSPreferenceHelper fInstance = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/text/ICSSPartitionTypes.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/text/ICSSPartitionTypes.java
new file mode 100644
index 0000000..54fcf46
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/provisional/text/ICSSPartitionTypes.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.provisional.text;
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitionTypes;
+
+/**
+ * This interface is not intended to be implemented. It defines the
+ * partitioning for CSS and all its partitions. Clients should reference the
+ * partition type Strings defined here directly.
+ *
+ * @deprecated org.eclipse.wst.css.core.text.ICSSPartitions
+ */
+public interface ICSSPartitionTypes extends IStructuredPartitionTypes {
+
+ String STYLE = "org.eclipse.wst.css.STYLE"; //$NON-NLS-1$
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/tasks/CSSFileTaskScanner.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/tasks/CSSFileTaskScanner.java
new file mode 100644
index 0000000..db9bfc6
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/tasks/CSSFileTaskScanner.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.tasks;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.tasks.StructuredFileTaskScanner;
+
+public class CSSFileTaskScanner extends StructuredFileTaskScanner {
+ public CSSFileTaskScanner() {
+ super();
+ }
+
+ protected String getCommentedText(IDocument document, int begin, int length) throws BadLocationException {
+ String text = super.getCommentedText(document, begin, length);
+ if (text != null && text.endsWith("*/")) { //$NON-NLS-1$
+ text = text.substring(0, text.length() - 2);
+ }
+ return text;
+ }
+
+ protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) {
+ return textRegion.getType().equals(CSSRegionContexts.CSS_COMMENT);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentReParser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentReParser.java
new file mode 100644
index 0000000..260374f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentReParser.java
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.parser.CSSRegionUtil;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.util.CSSUtil;
+import org.eclipse.wst.css.core.internal.util.RegionIterator;
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextReParser;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser;
+
+
+/**
+ * This class provides a centralized place to put "reparsing" logic. This is
+ * the logic that reparses the text incrementally, as a user types in new
+ * characters, or DOM nodes are inserted or deleted. Note: it is not a thread
+ * safe class.
+ */
+public class CSSStructuredDocumentReParser extends StructuredDocumentReParser {
+
+ class ReparseRange {
+ ReparseRange() {
+ reset();
+ }
+
+ ReparseRange(int start, int end) {
+ fRangeStart = start;
+ fRangeEnd = end;
+ }
+
+ void setStart(int start) {
+ fRangeStart = start;
+ }
+
+ void setEnd(int end) {
+ fRangeEnd = end;
+ }
+
+ int getStart() {
+ return fRangeStart;
+ }
+
+ int getEnd() {
+ return fRangeEnd;
+ }
+
+ boolean isValid() {
+ return (0 < fRangeEnd - fRangeStart) ? true : false;
+ }
+
+ void reset() {
+ fRangeStart = Integer.MAX_VALUE;
+ fRangeEnd = 0;
+ }
+
+ void expand(ReparseRange range) {
+ if (range == null || !range.isValid()) {
+ return;
+ }
+ int start = range.getStart();
+ if (start < fRangeStart) {
+ fRangeStart = start;
+ }
+ int end = range.getEnd();
+ if (fRangeEnd < end) {
+ fRangeEnd = end;
+ }
+ }
+
+ private int fRangeStart;
+ private int fRangeEnd;
+ }
+
+ /**
+ *
+ */
+ public CSSStructuredDocumentReParser() {
+ super();
+ }
+
+ /**
+ *
+ */
+ // public StructuredDocumentEvent
+ // checkForCrossStructuredDocumentRegionBoundryCases2() {
+ // StructuredDocumentEvent result = specialPositionUpdate(fStart, fStart +
+ // fLengthToReplace - 1);
+ // if (result == null) {
+ // result = checkInsideBrace();
+ // }
+ // return result;
+ // }
+ protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionSyntax() {
+ int checkStart = fStart;
+ int checkEnd = fStart + fLengthToReplace - 1;
+ IStructuredDocumentRegion endRegion = fStructuredDocument.getRegionAtCharacterOffset(checkEnd);
+ if (endRegion != null) {
+ checkEnd = endRegion.getEndOffset();
+ }
+
+ ReparseRange range = new ReparseRange(checkStart, checkEnd);
+
+ range.expand(getUpdateRangeForDelimiter(range.getStart(), range.getEnd()));
+ range.expand(getUpdateRangeForUnknownRegion(range.getStart(), range.getEnd()));
+
+ range.expand(getUpdateRangeForQuotes(range.getStart(), range.getEnd()));
+ range.expand(getUpdateRangeForComments(range.getStart(), range.getEnd()));
+ range.expand(getUpdateRangeForBraces(range.getStart(), range.getEnd()));
+
+ StructuredDocumentEvent result;
+
+ result = checkInsideBrace(range.getStart(), range.getEnd());
+
+ if (result == null) {
+ result = reparse(range.getStart(), range.getEnd());
+ }
+
+ return result;
+ }
+
+ private ReparseRange getUpdateRangeForUnknownRegion(int start, int end) {
+ int newStart = start;
+ RegionIterator iterator = new RegionIterator(fStructuredDocument, start - 1);
+ if (iterator.hasPrev()) {
+ iterator.prev(); // skip myself
+ }
+ while (iterator.hasPrev()) {
+ ITextRegion region = iterator.prev();
+ if (region != null && region.getType() == CSSRegionContexts.CSS_UNKNOWN) {
+ newStart = iterator.getStructuredDocumentRegion().getStartOffset(region);
+ }
+ else {
+ break;
+ }
+ }
+
+ if (start != newStart) {
+ return new ReparseRange(newStart, end);
+ }
+
+ return null;
+ }
+
+ private ReparseRange getUpdateRangeForDelimiter(int start, int end) {
+ if (dirtyStart != null && dirtyStart.getStart() < start) {
+ start = dirtyStart.getStart();
+ }
+ IStructuredDocumentRegion docRegion = fStructuredDocument.getRegionAtCharacterOffset(start);
+ if (docRegion == null) {
+ return null;
+ }
+ if (docRegion.getType() == CSSRegionContexts.CSS_DELIMITER) {
+ IStructuredDocumentRegion prevRegion = docRegion.getPrevious();
+ if (prevRegion != null) {
+ return new ReparseRange(prevRegion.getStart(), end);
+ }
+ }
+
+ return null;
+ }
+
+ private ReparseRange getUpdateRangeForQuotes(int start, int end) {
+ ReparseRange range = new ReparseRange();
+
+ range.expand(getUpdateRangeForPair(start, end, '\"', '\"'));
+ range.expand(getUpdateRangeForPair(start, end, '\'', '\''));
+
+ return (range.isValid()) ? range : null;
+ }
+
+ private ReparseRange getUpdateRangeForComments(int start, int end) {
+ ReparseRange range = new ReparseRange();
+
+ range.expand(getUpdateRangeForPair(start, end, "/*", "*/")); //$NON-NLS-2$//$NON-NLS-1$
+ range.expand(getUpdateRangeForPair(start, end, "<%", "%>")); //$NON-NLS-2$//$NON-NLS-1$
+
+ return (range.isValid()) ? range : null;
+ }
+
+ private ReparseRange getUpdateRangeForBraces(int start, int end) {
+ ReparseRange range = new ReparseRange();
+
+ range.expand(getUpdateRangeForPair(start, end, '[', ']'));
+ range.expand(getUpdateRangeForPair(start, end, '(', ')'));
+ range.expand(getUpdateRangeForPair(start, end, '{', '}'));
+
+ return (range.isValid()) ? range : null;
+ }
+
+ private StructuredDocumentEvent checkInsideBrace(int start, int end) {
+ StructuredDocumentEvent result = null;
+ IStructuredDocumentRegion region = fStructuredDocument.getRegionAtCharacterOffset(start);
+ if (region == null) {
+ return null;
+ }
+ boolean bDeclaration = false;
+ String type = region.getType();
+ if (CSSRegionUtil.isDeclarationType(type) || type == CSSRegionContexts.CSS_LBRACE || type == CSSRegionContexts.CSS_RBRACE) {
+ bDeclaration = true;
+ }
+ if (!bDeclaration) {
+ IStructuredDocumentRegion prevRegion = CSSUtil.findPreviousSignificantNode(region);
+ if (prevRegion != null) {
+ type = prevRegion.getType();
+ if (CSSRegionUtil.isDeclarationType(type) || type == CSSRegionContexts.CSS_LBRACE) {
+ bDeclaration = true;
+ }
+ }
+ }
+ if (!bDeclaration) {
+ IStructuredDocumentRegion nextRegion = CSSUtil.findNextSignificantNode(region);
+ if (nextRegion != null) {
+ type = nextRegion.getType();
+ if (CSSRegionUtil.isDeclarationType(type) || type == CSSRegionContexts.CSS_RBRACE) {
+ bDeclaration = true;
+ }
+ }
+ }
+
+ if (bDeclaration) {
+ IStructuredDocumentRegion startRegion = findRuleStart(region);
+ if (startRegion != null) {
+ IStructuredDocumentRegion endRegion = fStructuredDocument.getRegionAtCharacterOffset(end);
+ if (endRegion != null) {
+ result = reparse(startRegion, endRegion);
+ }
+ }
+ }
+ return result;
+ }
+
+ private IStructuredDocumentRegion findRuleStart(IStructuredDocumentRegion startRegion) {
+ IStructuredDocumentRegion region = startRegion;
+ // find '{'
+ while (region != null && region.getType() != CSSRegionContexts.CSS_LBRACE) {
+ region = region.getPrevious();
+ }
+ // if (region == startRegion) {
+ // return null;
+ // }
+ // else
+ if (region != null) { // '{' is found
+ region = region.getPrevious();
+ if (isLeadingDeclarationType(region.getType())) {
+ return region;
+ }
+ }
+ return null;
+ }
+
+ private boolean isLeadingDeclarationType(String type) {
+ return (type == CSSRegionContexts.CSS_PAGE || type == CSSRegionContexts.CSS_FONT_FACE || CSSRegionUtil.isSelectorType(type));
+ }
+
+ // public StructuredDocumentEvent
+ // checkForCrossStructuredDocumentRegionBoundryCases() {
+ // return specialPositionUpdate(fStart, fStart + fLengthToReplace - 1);
+ // }
+ /**
+ *
+ */
+ private ReparseRange getUpdateRangeForPair(int start, int end, String opener, String closer) {
+ StringBuffer deletionBuf = new StringBuffer();
+ StringBuffer insertionBuf = new StringBuffer();
+ int quoteLen = Math.max(opener.length(), closer.length());
+ if (1 < quoteLen) {
+ /**
+ * ex) opener = "ABC", closer = "XYZ" model: ABCDEF.......UVWXYZ
+ * deletion: CDEF.......UVWX pre/post: AB / YZ
+ */
+ int addStart = start - (quoteLen - 1);
+ if (0 <= addStart) {
+ String addStr = fStructuredDocument.get(addStart, quoteLen - 1);
+ deletionBuf.append(addStr);
+ insertionBuf.append(addStr);
+ }
+ deletionBuf.append(fDeletedText);
+ insertionBuf.append(fChanges);
+ if (end + (quoteLen - 1) < fStructuredDocument.getLength()) {
+ String addStr = fStructuredDocument.get(end + 1, quoteLen - 1);
+ deletionBuf.append(addStr);
+ insertionBuf.append(addStr);
+ }
+ }
+ else {
+ deletionBuf.append(fDeletedText);
+ insertionBuf.append(fChanges);
+ }
+ String deletion = deletionBuf.toString();
+ String insertion = insertionBuf.toString();
+
+ int rangeStart = start;
+ int rangeEnd = end;
+
+ if (0 <= deletion.indexOf(opener) || 0 <= deletion.indexOf(closer) || 0 <= insertion.indexOf(opener) || 0 <= insertion.indexOf(closer)) {
+ int s, e;
+ try {
+ if (start <= fStructuredDocument.getLength()) {
+ IRegion startRegion = getFindReplaceDocumentAdapter().find(start - 1, opener, false, false, false, false);
+ if (startRegion != null) {
+ s = startRegion.getOffset();
+ }
+ else {
+ s = -1;
+ }
+ }
+ else {
+ s = -1;
+ }
+ if (end < fStructuredDocument.getLength() - 1) {
+ IRegion endRegion = getFindReplaceDocumentAdapter().find(end + 1, closer, true, false, false, false);
+ if (endRegion != null) {
+ e = endRegion.getOffset();
+ }
+ else {
+ e = -1;
+ }
+ }
+ else {
+ e = -1;
+ }
+ }
+ catch (BadLocationException ex) {
+ Logger.logException(ex);
+ return null;
+ }
+ if (0 <= s) {
+ rangeStart = Math.min(rangeStart, s);
+ }
+ if (0 <= e) {
+ rangeEnd = Math.max(rangeEnd, e);
+ }
+ }
+
+ if (rangeStart < start || end < rangeEnd) {
+ return new ReparseRange(rangeStart, rangeEnd);
+ }
+ else {
+ return null;
+ }
+ }
+
+ private int findChar(char c, int start, boolean forward) throws BadLocationException {
+ int stop = forward ? fStructuredDocument.getLength() : 0;
+ if (forward) {
+ for (; start < stop; start++) {
+ if (fStructuredDocument.getChar(start) == c)
+ return start;
+ }
+ }
+ else {
+ for (; start >= stop; start--) {
+ if (fStructuredDocument.getChar(start) == c)
+ return start;
+ }
+ }
+ return -1;
+ }
+
+ ReparseRange getUpdateRangeForPair(int start, int end, char opener, char closer) {
+ StringBuffer deletionBuf = new StringBuffer();
+ StringBuffer insertionBuf = new StringBuffer();
+ deletionBuf.append(fDeletedText);
+ insertionBuf.append(fChanges);
+ String deletion = deletionBuf.toString();
+ String insertion = insertionBuf.toString();
+
+ int rangeStart = start;
+ int rangeEnd = end;
+
+ if (0 <= deletion.indexOf(opener) || 0 <= deletion.indexOf(closer) || 0 <= insertion.indexOf(opener) || 0 <= insertion.indexOf(closer)) {
+ int s = -1, e = -1;
+ try {
+ if (start <= fStructuredDocument.getLength()) {
+ s = findChar(opener, start - 1, false);
+ }
+ if (end < fStructuredDocument.getLength() - 1) {
+ e = findChar(closer, end + 1, true);
+ }
+ }
+ catch (BadLocationException ex) {
+ Logger.logException(ex);
+ return null;
+ }
+ if (0 <= s) {
+ rangeStart = Math.min(rangeStart, s);
+ }
+ if (0 <= e) {
+ rangeEnd = Math.max(rangeEnd, e);
+ }
+ }
+
+ if (rangeStart < start || end < rangeEnd) {
+ return new ReparseRange(rangeStart, rangeEnd);
+ }
+ else {
+ return null;
+ }
+ }
+
+ public IStructuredTextReParser newInstance() {
+ return new CSSStructuredDocumentReParser();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentRegionFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentRegionFactory.java
new file mode 100644
index 0000000..6dc83a1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/CSSStructuredDocumentRegionFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.text;
+
+
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion;
+
+/**
+ *
+ */
+public class CSSStructuredDocumentRegionFactory {
+
+ public static final int CSS_GENERIC = 101109;
+
+ /**
+ *
+ */
+ public static IStructuredDocumentRegion createStructuredDocumentRegion(int type) {
+ IStructuredDocumentRegion instance = null;
+ switch (type) {
+ case CSS_GENERIC :
+ instance = new BasicStructuredDocumentRegion();
+ break;
+ default :
+ break;
+ }
+ return instance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredDocumentWalker.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredDocumentWalker.java
new file mode 100644
index 0000000..43cfc3e
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredDocumentWalker.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.text;
+
+
+
+import java.util.Enumeration;
+
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
+import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.util.Utilities;
+
+public class StructuredDocumentWalker {
+
+ IStructuredDocumentRegionList fOldStructuredDocumentRegionList = null;
+ IStructuredDocument fStructuredDocument = null;
+ String fOriginalChanges = null;
+ int fOriginalOffset = 0;
+ int fOriginalLengthToReplace = 0;
+ int fLengthDifference = 0;
+
+ /**
+ *
+ */
+ public StructuredDocumentWalker() {
+ }
+
+ /**
+ *
+ */
+ public StructuredDocumentWalker(StructuredDocumentEvent event) {
+ initialize(event);
+ }
+
+ /**
+ *
+ */
+ public IStructuredDocument getStructuredDocument() {
+ return fStructuredDocument;
+ }
+
+ /**
+ * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
+ * ---[C1]-----[C2]-----[C3]-----[C4]---
+ *
+ * Input: O1 -> Output: O2 Input: O2 -> Output: O3 Input: O3 -> Output: C4
+ * Input: Cn -> Output: Cn+1
+ */
+ public IStructuredDocumentRegion getNextNode(IStructuredDocumentRegion node) {
+ IStructuredDocumentRegion nextNode = null;
+ if (node != null) {
+ nextNode = node.getNext();
+ if (nextNode == null) {
+ if (isOldNode(node)) {
+ // this may be the end of old flatnodes
+ int newStart = node.getEnd() + fLengthDifference;
+ nextNode = fStructuredDocument.getRegionAtCharacterOffset(newStart);
+ }
+ }
+ }
+ return nextNode;
+ }
+
+ /**
+ * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
+ * ---[C1]-----[C2]-----[C3]-----[C4]---
+ *
+ * Input: O* -> Output: C4 Input: Cn -> Output: Cn+1
+ */
+ public IStructuredDocumentRegion getNextNodeInCurrent(IStructuredDocumentRegion node) {
+ IStructuredDocumentRegion nextNode = null;
+ if (isOldNode(node)) {
+ IStructuredDocumentRegion oldEndNode = fOldStructuredDocumentRegionList.item(fOldStructuredDocumentRegionList.getLength() - 1);
+ int newStart = oldEndNode.getEnd() + fLengthDifference;
+ nextNode = fStructuredDocument.getRegionAtCharacterOffset(newStart);
+ }
+ else if (node != null) {
+ nextNode = node.getNext();
+ }
+ return nextNode;
+ }
+
+ /**
+ * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
+ * ---[C1]-----[C2]-----[C3]-----[C4]---
+ *
+ * Input: O1 -> Output: C1 Input: O2 -> Output: O1 Input: O3 -> Output: O2
+ * Input: Cn -> Output: Cn-1
+ */
+ public IStructuredDocumentRegion getPrevNode(IStructuredDocumentRegion node) {
+ IStructuredDocumentRegion prevNode = null;
+ if (node != null) {
+ prevNode = node.getPrevious();
+ if (prevNode == null) {
+ if (isOldNode(node)) {
+ // this may be the start of old flatnodes
+ int newEnd = node.getStart() - 1;
+ prevNode = fStructuredDocument.getRegionAtCharacterOffset(newEnd);
+ }
+ }
+ }
+ return prevNode;
+ }
+
+ /**
+ * Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
+ * ---[C1]-----[C2]-----[C3]-----[C4]---
+ *
+ * Input: O* -> Output: C1 Input: Cn -> Output: Cn-1
+ */
+ public IStructuredDocumentRegion getPrevNodeInCurrent(IStructuredDocumentRegion node) {
+ IStructuredDocumentRegion prevNode = null;
+ if (isOldNode(node)) {
+ IStructuredDocumentRegion oldStartNode = fOldStructuredDocumentRegionList.item(0);
+ int newEnd = oldStartNode.getStart() - 1;
+ prevNode = fStructuredDocument.getRegionAtCharacterOffset(newEnd);
+ }
+ else if (node != null) {
+ prevNode = node.getPrevious();
+ }
+ return prevNode;
+ }
+
+ /**
+ *
+ */
+ public void initialize(StructuredDocumentEvent event) {
+ fStructuredDocument = event.getStructuredDocument();
+ fOriginalChanges = event.getText();
+ fOriginalOffset = event.getOffset();
+ fOriginalLengthToReplace = event.getLength();
+ fLengthDifference = Utilities.calculateLengthDifference(fOriginalChanges, fOriginalLengthToReplace);
+
+ if (event instanceof StructuredDocumentRegionsReplacedEvent) {
+ fOldStructuredDocumentRegionList = ((StructuredDocumentRegionsReplacedEvent) event).getOldStructuredDocumentRegions();
+ }
+ else {
+ fOldStructuredDocumentRegionList = null;
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean isOldNode(IStructuredDocumentRegion node) {
+ boolean bOld = false;
+ if (fOldStructuredDocumentRegionList != null) {
+ Enumeration e = fOldStructuredDocumentRegionList.elements();
+ while (e.hasMoreElements()) {
+ if (e.nextElement() == node) {
+ bOld = true;
+ break;
+ }
+ }
+ }
+ return bOld;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredTextPartitionerForCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredTextPartitionerForCSS.java
new file mode 100644
index 0000000..f78ac0a
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/text/StructuredTextPartitionerForCSS.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.text;
+
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.text.ICSSPartitions;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner;
+import org.eclipse.wst.sse.core.text.IStructuredPartitions;
+
+public class StructuredTextPartitionerForCSS extends StructuredTextPartitioner {
+
+ public final static String[] legalTypes = new String[]{ICSSPartitions.STYLE, ICSSPartitions.COMMENT, IStructuredPartitions.DEFAULT_PARTITION};
+
+ public StructuredTextPartitionerForCSS() {
+ super();
+ }
+
+ public String getDefaultPartitionType() {
+ return ICSSPartitions.STYLE;
+ }
+
+ public String[] getLegalContentTypes() {
+ return legalTypes;
+ }
+
+ public IDocumentPartitioner newInstance() {
+ return new StructuredTextPartitionerForCSS();
+ }
+
+ /**
+ * <p>This partitioner breaks CSS into only two types of partitions depending on the region type:<br />
+ * <code>COMMENT</code><br />
+ * <code>STYLE</code></p>
+ *
+ * @see org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner#getPartitionType(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, int)
+ */
+ public String getPartitionType(ITextRegion region, int offset) {
+ String partitionType;
+
+ String regionType = region.getType();
+
+ if(regionType == CSSRegionContexts.CSS_COMMENT) {
+ partitionType = ICSSPartitions.COMMENT;
+ } else {
+ partitionType = super.getPartitionType(region, offset);
+ }
+
+ return partitionType;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/AbstractCssTraverser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/AbstractCssTraverser.java
new file mode 100644
index 0000000..c611b58
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/AbstractCssTraverser.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+import java.util.ArrayList;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+
+
+
+/**
+ *
+ */
+public abstract class AbstractCssTraverser {
+
+ public static short TRAV_CONT = 0;
+ public static short TRAV_PRUNE = 1;
+ public static short TRAV_STOP = 2;
+ protected java.util.Stack travStack;
+ private boolean fTraverseImported = false;
+ private boolean fTraverseImportFirst = false;
+ private java.util.Vector traversedSheets;
+
+ /**
+ * CssPropCMNode constructor comment.
+ */
+ public AbstractCssTraverser() {
+ super();
+ }
+
+ /**
+ * @param model
+ * org.eclipse.wst.css.core.model.interfaces.ICSSModel
+ */
+ public final void apply(ICSSModel model) {
+ apply(model.getDocument());
+ }
+
+ public final void apply(ICSSNode root) {
+ travStack = new Stack();
+ if (fTraverseImported) {
+ traversedSheets = new Vector();
+ if (root != null && root.getOwnerDocument() != null && root.getOwnerDocument().getNodeType() == ICSSNode.STYLESHEET_NODE) {
+ traversedSheets.add(root.getOwnerDocument());
+ }
+ }
+
+ // first call begin()
+ begin(root);
+
+ // traverse
+ traverse(root);
+
+ // last call end()
+ end(root);
+ }
+
+
+ protected void begin(ICSSNode node) {
+ }
+
+
+ protected void end(ICSSNode node) {
+ }
+
+ /**
+ * @return boolean
+ */
+ public final boolean isTraverseImported() {
+ return fTraverseImported;
+ }
+
+
+ protected short postNode(ICSSNode node) {
+ return (short) 0;
+ }
+
+
+ protected short preNode(ICSSNode node) {
+ return (short) 0;
+ }
+
+ /**
+ * @param newTraverseImported
+ * boolean
+ */
+ public final void setTraverseImported(boolean newTraverseImported) {
+ fTraverseImported = newTraverseImported;
+ }
+
+ /**
+ * @param newTraverseImportFirst
+ * boolean
+ */
+ public final void setTraverseImportFirst(boolean newTraverseImportFirst) {
+ fTraverseImportFirst = newTraverseImportFirst;
+ }
+
+
+ private final short traverse(ICSSNode node) {
+ if (node == null)
+ return TRAV_CONT;
+
+ travStack.push(node);
+
+ // pre-action
+ short ret = preNode(node);
+
+ if (ret == TRAV_CONT) {
+ if (fTraverseImported && (node.getNodeType() == ICSSNode.IMPORTRULE_NODE)) {
+ ICSSImportRule rule = (ICSSImportRule) node;
+ // traverse external style-sheet
+ ICSSStyleSheet sheet = (ICSSStyleSheet) rule.getStyleSheet();
+ if (sheet != null && !traversedSheets.contains(sheet)) { // prevent
+ // loop
+ traversedSheets.add(sheet);
+ short retExt = traverse(sheet);
+ if (retExt == TRAV_STOP) {
+ travStack.pop();
+ return retExt;
+ }
+ }
+ }
+
+ // collect children
+ ArrayList children = new ArrayList();
+ ICSSNode child = node.getFirstChild();
+ if (fTraverseImportFirst) {
+ ArrayList others = new ArrayList();
+
+ while (child != null) {
+ if (child.getNodeType() == ICSSNode.IMPORTRULE_NODE)
+ children.add(child);
+ else
+ others.add(child);
+ child = child.getNextSibling();
+ }
+ children.addAll(others);
+ }
+ else {
+ while (child != null) {
+ children.add(child);
+ child = child.getNextSibling();
+ }
+ }
+
+ // traverse children
+ for (int i = 0; i < children.size(); i++) {
+ child = (ICSSNode) children.get(i);
+ short retChild = traverse(child);
+ if (retChild == TRAV_STOP) {
+ travStack.pop();
+ return retChild;
+ }
+ }
+ }
+ else if (ret == TRAV_STOP) {
+ travStack.pop();
+ return ret;
+ }
+
+ // post-action
+ ret = postNode(node);
+
+ travStack.pop();
+ return (ret == TRAV_PRUNE) ? TRAV_CONT : ret;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSClassTraverser.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSClassTraverser.java
new file mode 100644
index 0000000..87a353d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSClassTraverser.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+
+
+/**
+ *
+ */
+public class CSSClassTraverser extends AbstractCssTraverser {
+
+ ArrayList fClassNames;
+
+ /**
+ *
+ */
+ public CSSClassTraverser() {
+ super();
+ }
+
+ /**
+ *
+ */
+ private void addClassNames(ICSSStyleRule rule) {
+ ICSSSelectorList selectorList = rule.getSelectors();
+ Iterator iSelector = selectorList.getIterator();
+ while (iSelector.hasNext()) {
+ ICSSSelector selector = (ICSSSelector) iSelector.next();
+ Iterator iItem = selector.getIterator();
+ while (iItem.hasNext()) {
+ ICSSSelectorItem item = (ICSSSelectorItem) iItem.next();
+ if (item.getItemType() == ICSSSelectorItem.SIMPLE) {
+ ICSSSimpleSelector sel = (ICSSSimpleSelector) item;
+ int nClasses = sel.getNumOfClasses();
+ for (int iClass = 0; iClass < nClasses; iClass++) {
+ String className = sel.getClass(iClass);
+ if (!fClassNames.contains(className))
+ fClassNames.add(className);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void begin(ICSSNode node) {
+ if (fClassNames == null)
+ fClassNames = new ArrayList();
+ }
+
+ /**
+ *
+ */
+ protected void end(ICSSNode node) {
+ }
+
+ /**
+ *
+ */
+ public Collection getClassNames() {
+ return (fClassNames != null) ? fClassNames : Collections.EMPTY_LIST;
+ }
+
+ /**
+ *
+ */
+ protected short postNode(ICSSNode node) {
+ return TRAV_CONT;
+ }
+
+ /**
+ *
+ */
+ protected short preNode(ICSSNode node) {
+ short ret;
+ if (node instanceof ICSSStyleRule) {
+ addClassNames((ICSSStyleRule) node);
+ ret = TRAV_PRUNE;
+ }
+ else if (node instanceof ICSSStyleSheet || node instanceof ICSSMediaRule || node instanceof ICSSImportRule) {
+ ret = TRAV_CONT;
+ }
+ else {
+ ret = TRAV_PRUNE;
+ }
+ return ret;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSLinkConverter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSLinkConverter.java
new file mode 100644
index 0000000..377dcd3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSLinkConverter.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.wst.css.core.internal.CSSCorePlugin;
+import org.eclipse.wst.css.core.internal.preferences.CSSCorePreferenceNames;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ *
+ */
+public class CSSLinkConverter extends org.eclipse.wst.css.core.internal.util.AbstractCssTraverser {
+ private static final String URL_BEGIN = "url("; //$NON-NLS-1$
+ private static final String URL_END = ")"; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+ private static final String D_QUOTE = "\""; //$NON-NLS-1$
+ private static final String S_QUOTE = "\'"; //$NON-NLS-1$
+
+ IStructuredModel baseModel;
+
+ /**
+ *
+ */
+ public CSSLinkConverter(IStructuredModel model) {
+ super();
+ baseModel = model;
+ if (model instanceof ICSSModel && ((ICSSModel) model).getStyleSheetType() != ICSSModel.EXTERNAL) {
+ IDOMNode node = (IDOMNode) ((ICSSModel) model).getOwnerDOMNode();
+ baseModel = node.getModel();
+ }
+ }
+
+ /**
+ *
+ */
+ public static String addFunc(String value) {
+ if (!value.trim().toLowerCase().startsWith(URL_BEGIN)) {
+ // pa_TODO css pref
+ Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
+
+ String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
+ value = CSSUtil.stripQuotes(value);
+ quote = CSSUtil.detectQuote(value, quote);
+ String str = URL_BEGIN;
+ if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
+ str = str.toUpperCase();
+ StringBuffer buf = new StringBuffer(str);
+ buf.append(quote);
+ buf.append(value);
+ buf.append(quote);
+ buf.append(URL_END);
+ return buf.toString();
+ }
+ return value;
+ }
+
+
+
+ /**
+ *
+ */
+ protected void begin(ICSSNode node) {
+ if (baseModel == null) {
+ baseModel = node.getOwnerDocument().getModel();
+ if (baseModel instanceof ICSSModel && ((ICSSModel) baseModel).getStyleSheetType() != ICSSModel.EXTERNAL) {
+ IDOMNode xmlNode = (IDOMNode) ((ICSSModel) baseModel).getOwnerDOMNode();
+ baseModel = xmlNode.getModel();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static boolean isUrl(String source) {
+ if (source == null)
+ return false;
+ source = source.trim().toLowerCase();
+ return source.startsWith(URL_BEGIN);
+ }
+
+ /**
+ *
+ */
+ protected short preNode(ICSSNode node) {
+ if (node.getNodeType() == ICSSNode.PRIMITIVEVALUE_NODE) {
+ toAbsolute((CSSValue) node);
+ } else if (node.getNodeType() == ICSSNode.IMPORTRULE_NODE) {
+ ICSSImportRule iRule = (ICSSImportRule) node;
+ iRule.setHref(toAbsolute(addFunc(iRule.getHref())));
+ }
+ return TRAV_CONT;
+ }
+
+ /**
+ *
+ * @return java.lang.String
+ * @param value
+ * java.lang.String
+ */
+ public static String removeFunc(String value) {
+ if (value == null)
+ return EMPTY;
+ String field = value.trim();
+ // first : tear "url(....)"
+ if (field.toLowerCase().startsWith(URL_BEGIN)) {
+ int url = field.toLowerCase().indexOf(URL_BEGIN);
+ int endParenthesis = field.lastIndexOf(URL_END);
+ if (endParenthesis > url) {
+ field = field.substring(url + 4, endParenthesis);
+ } else
+ field = field.substring(url + 4);
+ }
+ return field.trim();
+ }
+
+ /**
+ *
+ */
+ public static String stripFunc(String value) {
+ if (value == null)
+ return EMPTY;
+ // first : tear "url(....)"
+ String field = removeFunc(value);
+ // second : tear quotations
+ if (field.toLowerCase().startsWith(D_QUOTE)) {
+ int quote = field.indexOf(D_QUOTE);
+ int end = field.lastIndexOf(D_QUOTE);
+ if (end > quote) {
+ field = field.substring(quote + 1, end);
+ } else
+ field = field.substring(quote + 1);
+ } else if (field.toLowerCase().startsWith(S_QUOTE)) {
+ int quote = field.indexOf(S_QUOTE);
+ int end = field.lastIndexOf(S_QUOTE);
+ if (end > quote) {
+ field = field.substring(quote + 1, end);
+ } else
+ field = field.substring(quote + 1);
+ }
+
+ return field.trim();
+ }
+
+ /**
+ *
+ */
+ public String toAbsolute(String source) {
+ if (isUrl(source)) {
+ String url = CSSPathService.getAbsoluteURL(baseModel, stripFunc(source));
+ return (url != null) ? addFunc(url) : (URL_BEGIN + URL_END);
+ }
+ return source;
+ }
+
+ /**
+ *
+ */
+ public boolean toAbsolute(CSSValue node) {
+ if (node instanceof ICSSPrimitiveValue) {
+ ICSSPrimitiveValue value = (ICSSPrimitiveValue) node;
+ if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
+ value.setValue(stripFunc(toAbsolute(URL_BEGIN + value.getStringValue() + URL_END)));
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSPathService.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSPathService.java
new file mode 100644
index 0000000..8532819
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSPathService.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+/**
+ *
+ */
+public class CSSPathService {
+
+ // Constants
+ private static final String FILEURLSCHEME = "file";//$NON-NLS-1$
+ private static final String URLCOLON = ":"; //$NON-NLS-1$
+ private static final String FILEURLPREFIX = FILEURLSCHEME + URLCOLON + "//";//$NON-NLS-1$
+ private static final String URLSEPARATOR = "/"; //$NON-NLS-1$
+
+ /**
+ * @return java.lang.String
+ */
+ public static String getAbsoluteURL(IStructuredModel baseModel, String ref) {
+ String absLink = URLModelProviderCSS.resolveURI(baseModel, ref, true);
+ String url = absLink;
+ if (absLink != null) { // if it has not scheme, we must add "file"
+ // scheme
+ try {
+ new java.net.URL(absLink);
+ }
+ catch (java.net.MalformedURLException e) {
+ IPath path = new Path(absLink);
+ if (path != null)
+ url = toURL(path);
+ }
+ }
+ return url;
+ }
+
+ /**
+ *
+ * @return org.eclipse.core.resources.IFile
+ * @param location
+ * java.lang.String
+ */
+ public static IFile location2File(String location) {
+ Path path = new Path(location);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ if (file == null && path.segmentCount() > 1)
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ return file;
+ }
+
+ /**
+ * Gets a file URL for the path.
+ */
+ private static String toURL(IPath path) {
+ path = new Path(path.toFile().getAbsolutePath());
+ if (path.isUNC() == true) {
+ // it's UNC. return file://host/foo/bar/baz.html
+ return FILEURLSCHEME + URLCOLON + path.toString();
+ }
+ return FILEURLPREFIX + URLSEPARATOR + path.toString();
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSSelectorListFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSSelectorListFactory.java
new file mode 100644
index 0000000..82c7b81
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSSelectorListFactory.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+import org.eclipse.wst.css.core.internal.document.CSSSelectorListImpl;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+
+
+public class CSSSelectorListFactory {
+ static synchronized public CSSSelectorListFactory getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSSelectorListFactory();
+ }
+ return fInstance;
+ }
+
+ public ICSSSelectorList createSelectorList(String selectorString) {
+ return new CSSSelectorListImpl(selectorString);
+ }
+
+
+ private CSSSelectorListFactory() {
+ super();
+ }
+
+ private static CSSSelectorListFactory fInstance;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSStyleDeclarationFactory.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSStyleDeclarationFactory.java
new file mode 100644
index 0000000..ab98a09
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSStyleDeclarationFactory.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import org.eclipse.wst.css.core.internal.document.CSSStyleDeclarationFactoryContext;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+
+
+/**
+ *
+ */
+public class CSSStyleDeclarationFactory extends CSSStyleDeclarationFactoryContext {
+
+ private static CSSStyleDeclarationFactory fInstance = null;
+
+ /**
+ * CSSStyleDeclarationFactory constructor comment.
+ */
+ private CSSStyleDeclarationFactory() {
+ super();
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.model.interfaces.ICSSStyleDeclaration
+ * @param decl
+ * org.eclipse.wst.css.core.model.interfaces.ICSSStyleDeclaration
+ */
+ public ICSSStyleDeclaration createStyleDeclaration(ICSSStyleDeclaration decl) {
+ if (decl == null) {
+ return null;
+ }
+ ICSSStyleDeclaration newNode = createStyleDeclaration();
+
+ if (newNode == null) {
+ return null;
+ }
+ fOwnerDocument = newNode;
+ cloneChildNodes(decl, newNode);
+ return newNode;
+ }
+
+ /**
+ *
+ */
+ public synchronized static CSSStyleDeclarationFactory getInstance() {
+ if (fInstance == null) {
+ fInstance = new CSSStyleDeclarationFactory();
+ }
+ return fInstance;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSUtil.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSUtil.java
new file mode 100644
index 0000000..237c1b9
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/CSSUtil.java
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.Logger;
+import org.eclipse.wst.css.core.internal.parser.CSSRegionUtil;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+
+
+public class CSSUtil {
+
+ /**
+ *
+ */
+ public static void debugOut(String str) {
+ Logger.log(Logger.WARNING, "css warning: " + str); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ // public static Vector extractMediaContents(Vector regions) {
+ // Vector media = new Vector();
+ // if (regions == null) { return media; }
+ //
+ // boolean bReady = true;
+ // for (Iterator i = regions.iterator(); i.hasNext(); ) {
+ // ITextRegion region = (ITextRegion)i.next();
+ // if (region == null) { continue; }
+ // String type = region.getType();
+ // if (bReady) {
+ // if (type == IDENT) {
+ // media.addElement(region.getText());
+ // bReady = false;
+ // }
+ // } else {
+ // if (type == COMMA) {
+ // bReady = true;
+ // }
+ // }
+ // }
+ //
+ // return media;
+ // }
+ /**
+ *
+ */
+ public static String extractStringContents(String text) {
+ return stripQuotes(text);
+ }
+
+ /**
+ *
+ */
+ public static String extractUriContents(String text) {
+ String contents = text.trim();
+ if (contents.toLowerCase().startsWith("url(") && //$NON-NLS-1$
+ contents.toLowerCase().endsWith(")")) {//$NON-NLS-1$
+ // strip "url(", ")"
+ contents = contents.substring(4, contents.length() - 1);
+ }
+ contents = stripQuotes(contents);
+
+ return contents;
+ }
+
+ /**
+ *
+ */
+ public static IStructuredDocumentRegion findNextSignificantNode(IStructuredDocumentRegion startNode) {
+ if (startNode == null) {
+ return null;
+ }
+ IStructuredDocumentRegion node = startNode.getNext();
+ while (node != null) {
+ String type = getStructuredDocumentRegionType(node);
+ if (type != CSSRegionContexts.CSS_S && type != CSSRegionContexts.CSS_COMMENT && type != CSSRegionContexts.CSS_CDO && type != CSSRegionContexts.CSS_CDC) {
+ return node;
+ }
+ node = node.getNext();
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public static IStructuredDocumentRegion findNodeBackward(IStructuredDocumentRegion startNode, IStructuredDocumentRegion endNode, String type) {
+ IStructuredDocumentRegion node;
+ for (node = startNode; node != null; node = node.getPrevious()) {
+ if (node.getStartOffset() < endNode.getStartOffset()) {
+ node = null;
+ break;
+ }
+ else if (getStructuredDocumentRegionType(node) == type) {
+ break;
+ }
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ public static IStructuredDocumentRegion findNodeForward(IStructuredDocumentRegion startNode, IStructuredDocumentRegion endNode, String type) {
+ IStructuredDocumentRegion node;
+ for (node = startNode; node != null; node = node.getNext()) {
+ if (endNode.getStartOffset() < node.getStartOffset()) {
+ node = null;
+ break;
+ }
+ else if (getStructuredDocumentRegionType(node) == type) {
+ break;
+ }
+ }
+ return node;
+ }
+
+ /**
+ *
+ */
+ public static IStructuredDocumentRegion findPreviousSignificantNode(IStructuredDocumentRegion startNode) {
+ if (startNode == null) {
+ return null;
+ }
+ IStructuredDocumentRegion node = startNode.getPrevious();
+ while (node != null) {
+ String type = getStructuredDocumentRegionType(node);
+ if (type != CSSRegionContexts.CSS_S && type != CSSRegionContexts.CSS_COMMENT && type != CSSRegionContexts.CSS_CDO && type != CSSRegionContexts.CSS_CDC) {
+ return node;
+ }
+ node = node.getPrevious();
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public static String getClassString(Object object) {
+ if (object == null) {
+ return "null"; //$NON-NLS-1$
+ }
+ else {
+ String name = object.getClass().toString();
+ int lastPeriod = name.lastIndexOf('.');
+ return name.substring(lastPeriod + 1);
+ }
+ }
+
+ /**
+ *
+ */
+ public static String getStructuredDocumentRegionType(IStructuredDocumentRegion flatNode) {
+ if (flatNode == null) {
+ return CSSRegionContexts.CSS_UNDEFINED;
+ }
+ ITextRegionList regions = flatNode.getRegions();
+ if (regions == null || regions.size() == 0) {
+ return CSSRegionContexts.CSS_UNDEFINED;
+ }
+ ITextRegion region = regions.get(0);
+ return region.getType();
+ }
+
+ /**
+ *
+ */
+ public static int getLengthDifference(IStructuredDocumentRegionList newNodes, IStructuredDocumentRegionList oldNodes) {
+ int newLen = getTextLength(newNodes);
+ int oldLen = getTextLength(oldNodes);
+ return newLen - oldLen;
+ }
+
+ /**
+ *
+ */
+ public static String getRegionText(IStructuredDocumentRegion flatNode, ITextRegionList regions) {
+ StringBuffer buf = new StringBuffer();
+ if (regions != null) {
+ for (Iterator i = regions.iterator(); i.hasNext();) {
+ ITextRegion region = (ITextRegion) i.next();
+ if (region == null) {
+ continue;
+ }
+ buf.append(flatNode.getText(region));
+ }
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ *
+ */
+ public static int getTextLength(IStructuredDocumentRegionList nodes) {
+ int length = 0;
+
+ if (nodes != null) {
+ for (Enumeration e = nodes.elements(); e.hasMoreElements();) {
+ IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) e.nextElement();
+ if (flatNode != null) {
+ length += flatNode.getText().length();
+ }
+ }
+ }
+
+ return length;
+ }
+
+ /**
+ *
+ * @param token
+ * @return
+ */
+ public static boolean isLength(CSSTextToken token) {
+ if (token == null)
+ return false;
+ if (token.kind == CSSRegionContexts.CSS_DECLARATION_VALUE_DIMENSION)
+ return true;
+ if (token.kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ double number = Double.parseDouble(token.image);
+ if (number == 0.0)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static boolean isSelectorText(IStructuredDocumentRegion region) {
+ String type = getStructuredDocumentRegionType(region);
+ if (CSSRegionUtil.isSelectorBegginingType(type)) {
+ return true;
+ }
+ else if (type == CSSRegionContexts.CSS_UNKNOWN) {
+ // String text = flatNode.getText();
+ // if (text != null && text.indexOf('.') == 0) {
+ return true;
+ // }
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static String stripQuotes(String text) {
+ if (text == null)
+ return null;
+ String contents = text.trim();
+ if (2 <= contents.length()) {
+ char first = contents.charAt(0);
+ char last = contents.charAt(contents.length() - 1);
+ if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
+ contents = contents.substring(1, contents.length() - 1);
+ }
+ }
+ return contents;
+ }
+
+ public static String detectQuote(String source, String defaultQuote) {
+ if (source == null)
+ return defaultQuote;
+ final String D_QUOTE = "\""; //$NON-NLS-1$
+ final String S_QUOTE = "\'"; //$NON-NLS-1$
+
+ int dIndex = source.indexOf(D_QUOTE);
+ int sIndex = source.indexOf(S_QUOTE);
+ if (dIndex < 0 && sIndex < 0) {
+ return defaultQuote;
+ }
+ else if (dIndex < 0) {
+ return D_QUOTE;
+ }
+ else if (sIndex < 0) {
+ return S_QUOTE;
+ }
+ else if (dIndex < sIndex) {
+ return S_QUOTE;
+ }
+ else {
+ return D_QUOTE;
+ }
+ }
+
+ /**
+ *
+ */
+ public static void stripSurroundingSpace(ITextRegionList regions) {
+ if (regions == null) {
+ return;
+ }
+ while (!regions.isEmpty()) {
+ ITextRegion region = regions.get(0);
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
+ regions.remove(0);
+ }
+ else {
+ break;
+ }
+ }
+ while (!regions.isEmpty()) {
+ ITextRegion region = regions.get(regions.size() - 1);
+ String type = region.getType();
+ if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
+ regions.remove(region);
+ }
+ else {
+ break;
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportRuleCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportRuleCollector.java
new file mode 100644
index 0000000..a2c915c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportRuleCollector.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSImportRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+
+
+/**
+ *
+ */
+public class ImportRuleCollector extends org.eclipse.wst.css.core.internal.util.AbstractCssTraverser {
+
+ protected java.util.Vector rules = new Vector();
+ protected ICSSStyleSheet target = null;
+
+ /**
+ *
+ */
+ public ImportRuleCollector() {
+ super();
+ setTraverseImported(false);
+ }
+
+ /**
+ *
+ */
+ public ImportRuleCollector(ICSSStyleSheet sheet) {
+ super();
+ target = sheet;
+ }
+
+ /**
+ *
+ */
+ public java.util.Vector getRules() {
+ return rules;
+ }
+
+ /**
+ *
+ */
+ protected short preNode(ICSSNode node) {
+ if (node.getNodeType() == ICSSNode.MEDIARULE_NODE || node.getNodeType() == ICSSNode.STYLESHEET_NODE) {
+ return TRAV_CONT;
+ }
+ if (node.getNodeType() == ICSSNode.IMPORTRULE_NODE) {
+ if (target != null) {
+ ICSSImportRule imp = (ICSSImportRule) node;
+ if (imp.getStyleSheet() != target)
+ return TRAV_PRUNE;
+ }
+ if (!rules.contains(node))
+ rules.add(node);
+ }
+ return TRAV_PRUNE;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportedCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportedCollector.java
new file mode 100644
index 0000000..1f2a7aa
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/ImportedCollector.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+
+
+/**
+ *
+ */
+public class ImportedCollector extends org.eclipse.wst.css.core.internal.util.AbstractCssTraverser {
+
+ protected java.util.Vector externals = new Vector();
+
+ /**
+ *
+ */
+ public ImportedCollector() {
+ super();
+ setTraverseImported(true);
+ }
+
+ /**
+ *
+ */
+ public List getExternals() {
+ return externals;
+ }
+
+ /**
+ *
+ */
+ protected short preNode(ICSSNode node) {
+ if (node.getNodeType() == ICSSNode.MEDIARULE_NODE) {
+ return TRAV_CONT;
+ }
+ if (node.getNodeType() == ICSSNode.STYLESHEET_NODE) {
+ if (!externals.contains(node)) {
+ externals.add(node);
+ }
+ return TRAV_CONT;
+ }
+ if (node.getNodeType() == ICSSNode.IMPORTRULE_NODE) {
+ return TRAV_CONT;
+ }
+ return TRAV_PRUNE;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/RegionIterator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/RegionIterator.java
new file mode 100644
index 0000000..44d0022
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/RegionIterator.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+
+/**
+ *
+ */
+public class RegionIterator {
+
+ private IStructuredDocumentRegion documentRegion = null;
+ private IStructuredDocumentRegion curDocumentRegion = null;
+ private int current = -1;
+
+ /**
+ *
+ */
+ public RegionIterator(IStructuredDocument structuredDocument, int index) {
+ super();
+
+ reset(structuredDocument, index);
+ }
+
+ /**
+ *
+ */
+ public RegionIterator(IStructuredDocumentRegion flatNode, ITextRegion region) {
+ super();
+ reset(flatNode, region);
+ }
+
+ /**
+ *
+ */
+ public IStructuredDocumentRegion getStructuredDocumentRegion() {
+ return curDocumentRegion;
+ }
+
+ /**
+ *
+ */
+ public boolean hasNext() {
+ if (documentRegion == null)
+ return false;
+ if (current < 0)
+ return false;
+ if (current < documentRegion.getRegions().size())
+ return true;
+ return false;
+ }
+
+ /**
+ *
+ */
+ public boolean hasPrev() {
+ // the same as hasNext()
+ return hasNext();
+ }
+
+ /**
+ *
+ */
+ public ITextRegion next() {
+ if (documentRegion == null)
+ return null;
+ if (current < 0 || documentRegion.getRegions() == null || documentRegion.getRegions().size() <= current)
+ return null;
+
+ ITextRegion region = documentRegion.getRegions().get(current);
+ curDocumentRegion = documentRegion;
+
+ if (current >= documentRegion.getRegions().size() - 1) {
+ documentRegion = documentRegion.getNext();
+ current = -1;
+ }
+ current++;
+
+ return region;
+ }
+
+ /**
+ *
+ */
+ public ITextRegion prev() {
+ if (documentRegion == null)
+ return null;
+ if (current < 0 || documentRegion.getRegions() == null || documentRegion.getRegions().size() <= current)
+ return null;
+
+ ITextRegion region = documentRegion.getRegions().get(current);
+ curDocumentRegion = documentRegion;
+
+ if (current == 0) {
+ documentRegion = documentRegion.getPrevious();
+ if (documentRegion != null)
+ current = documentRegion.getRegions().size();
+ else
+ current = 0;
+ }
+ current--;
+
+ return region;
+ }
+
+ /**
+ *
+ */
+ public void reset(IStructuredDocument structuredDocument, int index) {
+ documentRegion = structuredDocument.getRegionAtCharacterOffset(index);
+ curDocumentRegion = documentRegion;
+ if (documentRegion != null) {
+ ITextRegion region = documentRegion.getRegionAtCharacterOffset(index);
+ current = documentRegion.getRegions().indexOf(region);
+ }
+ }
+
+ /**
+ *
+ */
+ public void reset(IStructuredDocumentRegion flatNode, ITextRegion region) {
+ if (region != null && flatNode != null) {
+ this.documentRegion = flatNode;
+ curDocumentRegion = flatNode;
+ current = flatNode.getRegions().indexOf(region);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectionCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectionCollector.java
new file mode 100644
index 0000000..2e44ca8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectionCollector.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+
+
+/**
+ */
+public class SelectionCollector extends org.eclipse.wst.css.core.internal.util.AbstractCssTraverser {
+
+ int start, end;
+ List selectedNodes;
+
+ /**
+ * SelectionCollector constructor comment.
+ */
+ public SelectionCollector() {
+ super();
+ }
+
+ /**
+ */
+ protected void begin(ICSSNode node) {
+ selectedNodes = new ArrayList();
+ }
+
+ /**
+ */
+ public List getSelectedNodes() {
+ if (selectedNodes == null)
+ return new ArrayList();
+ else
+ return new ArrayList(selectedNodes);
+ }
+
+ /**
+ */
+ protected short preNode(ICSSNode node) {
+ IndexedRegion iNode = (IndexedRegion) node;
+ if (iNode.getStartOffset() <= end && start < iNode.getEndOffset()) {
+ if (node.getNodeType() != ICSSNode.STYLESHEET_NODE) {
+ IndexedRegion iFirstChild = (IndexedRegion) node.getFirstChild();
+ IndexedRegion iLastChild = (IndexedRegion) node.getLastChild();
+ if (iFirstChild == null || start < iFirstChild.getStartOffset() || iLastChild.getEndOffset() <= end)
+ selectedNodes.add(node);
+ }
+ return TRAV_CONT;
+ }
+ if (iNode.getStartOffset() > end)
+ return TRAV_STOP;
+ else
+ return TRAV_PRUNE;
+ }
+
+ /**
+ */
+ public void setRegion(int newStart, int newEnd) {
+ start = newStart;
+ end = newEnd;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorValidator.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorValidator.java
new file mode 100644
index 0000000..0d52e16
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorValidator.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import org.eclipse.wst.css.core.internal.document.CSSSelectorListImpl;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorItem;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSimpleSelector;
+
+
+public class SelectorValidator {
+
+ /**
+ * Constructor for SelectorValidator.
+ */
+ public SelectorValidator(String text) {
+ super();
+ fText = text;
+ }
+
+ /**
+ * Returns true if the text consists of one CLASS selector. syntax check
+ * is a little loose (.123 is passed)
+ *
+ * ".class" -> true ".123" -> true ".class , .class2" -> false
+ * ".class.class2" -> false ".123{}" -> false
+ */
+ public boolean isClass() {
+ ICSSSimpleSelector selector = getOnlyOneSimpleSelector();
+ if (selector != null) {
+ return (selector.getName().length() == 0 && selector.getNumOfAttributes() == 0 && selector.getNumOfClasses() == 1 && selector.getNumOfIDs() == 0 && selector.getNumOfPseudoNames() == 0);
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if the text consists of one ID selector.
+ *
+ * "#ID" -> true "H1#myID" -> false "#abc{}" -> false
+ */
+ public boolean isID() {
+ ICSSSimpleSelector selector = getOnlyOneSimpleSelector();
+ if (selector != null) {
+ return (selector.getName().length() == 0 && selector.getNumOfAttributes() == 0 && selector.getNumOfClasses() == 0 && selector.getNumOfIDs() == 1 && selector.getNumOfPseudoNames() == 0);
+ }
+ return false;
+ }
+
+ /**
+ * overall check
+ *
+ * "P#hoge98 + *:hover > A:link, A.external:visited" -> true "H1 H2 {}" ->
+ * false
+ */
+ public boolean isValid() {
+ parse();
+ return (fSelectorList != null && fSelectorList.getErrorCount() == 0);
+ }
+
+ private ICSSSimpleSelector getOnlyOneSimpleSelector() {
+ parse();
+ if (fSelectorList != null && fSelectorList.getLength() == 1) {
+ ICSSSelector selector = fSelectorList.getSelector(0);
+ int nItem = selector.getLength();
+ if (nItem == 1) {
+ ICSSSelectorItem item = selector.getItem(0);
+ if (item instanceof ICSSSimpleSelector) {
+ return (ICSSSimpleSelector) item;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void parse() {
+ if (fSelectorList == null) {
+ if (fText != null) {
+ fSelectorList = new CSSSelectorListImpl(fText);
+ }
+ }
+ }
+
+
+ private String fText = null;
+ private ICSSSelectorList fSelectorList = null;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorsCollector.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorsCollector.java
new file mode 100644
index 0000000..0593ff8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/SelectorsCollector.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelector;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSSelectorList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+
+
+/**
+ *
+ */
+public class SelectorsCollector extends AbstractCssTraverser {
+
+ protected Vector selectors = new Vector();
+ protected Vector selectorsToAvoid = null;
+
+ /**
+ *
+ */
+ public SelectorsCollector() {
+ super();
+ setTraverseImported(false);
+ }
+
+ /**
+ *
+ */
+ public void addSelectorToAvoid(ICSSSelector selToAvoid) {
+ if (selToAvoid == null)
+ return;
+ if (selectorsToAvoid == null)
+ selectorsToAvoid = new Vector();
+
+ if (!selectorsToAvoid.contains(selToAvoid))
+ selectorsToAvoid.add(selToAvoid);
+ }
+
+ /**
+ *
+ */
+ public void addSelectorToAvoid(ICSSStyleRule rule) {
+ ICSSSelectorList list = rule.getSelectors();
+ Iterator it = list.getIterator();
+ while (it.hasNext()) {
+ ICSSSelector sel = (ICSSSelector) it.next();
+ addSelectorToAvoid(sel);
+ }
+ }
+
+ /**
+ *
+ */
+ public java.util.List getSelectors() {
+ return selectors;
+ }
+
+ /**
+ *
+ */
+ protected short preNode(ICSSNode node) {
+ if (node.getNodeType() == ICSSNode.STYLERULE_NODE) {
+ ICSSStyleRule rule = (ICSSStyleRule) node;
+ ICSSSelectorList list = rule.getSelectors();
+ Iterator it = list.getIterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (selectorsToAvoid != null && selectorsToAvoid.contains(obj))
+ continue;
+ if (!selectors.contains(obj))
+ selectors.add(obj);
+ }
+ return TRAV_PRUNE;
+ }
+ else if (node.getNodeType() == ICSSNode.STYLESHEET_NODE) {
+ return TRAV_CONT;
+ }
+ return TRAV_PRUNE;
+ }
+
+ /**
+ *
+ */
+ public void setSelectorsToAvoid(java.util.Vector newSelectorsToAvoid) {
+ selectorsToAvoid = newSelectorsToAvoid;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLHelper.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLHelper.java
new file mode 100644
index 0000000..7d5e106
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLHelper.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.wst.sse.core.internal.util.PathHelper;
+
+/**
+ * Hyperlink manager. Proved useful services like link conversion An utility
+ * class to help other parsre modules to convert links
+ */
+public class URLHelper {
+
+ private static final String FILE_PROTOCOL_SEARCH_SIG = "file:/";//$NON-NLS-1$
+ private static final String FILE_PROTOCOL_SIG = "file:///";//$NON-NLS-1$
+ private static String RELATIVE_PATH_SIG = "..";//$NON-NLS-1$
+ private static final String FORWARD_SLASH = "/";//$NON-NLS-1$
+ private URL fBaseUrl = null; // base url. assumed to a absulute url
+ private String fBaseUrlString = null;
+ private URL fDocRoot = null;
+ private String fDocRootString = null;
+
+ public URLHelper(String baseUrl) {
+ initialize(baseUrl, null);
+ }
+
+ public URLHelper(String baseUrl, String docRoot) {
+ initialize(baseUrl, docRoot);
+ }
+
+ /**
+ * Special adujust for file url
+ */
+ public String adjustFileProtocolUrl(String url) {
+ if (url.startsWith(FILE_PROTOCOL_SEARCH_SIG)) {
+ url = FILE_PROTOCOL_SIG + url.substring(FILE_PROTOCOL_SEARCH_SIG.length());
+ }
+ return url;
+ }
+
+ private String convert(String url, URL baseUrl, String urlString) {
+ String absUrl = url;
+ if (baseUrl != null) {
+ try {
+ // do special thing file protocol
+ if (baseUrl.getProtocol().equalsIgnoreCase("file")) {//$NON-NLS-1$
+ // remove the fist
+ if (url.startsWith("/"))//$NON-NLS-1$
+ url = url.substring(1);
+ // empty string causes malformed exception
+ String tempUrl = url;
+ if ("".equals(url))//$NON-NLS-1$
+ tempUrl = " ";//$NON-NLS-1$
+ URL newUrl = new URL(baseUrl, tempUrl);
+ // do extra math for file protocol to support ie based
+ absUrl = adjustFileProtocolUrl(newUrl.toString());
+ }
+ else {
+ URL newUrl = new URL(fBaseUrl, url);
+ absUrl = newUrl.toString();
+ }
+ }
+ catch (MalformedURLException me) {
+ }
+ // convert everything to forward slash
+ absUrl = PathHelper.switchToForwardSlashes(absUrl);
+ }
+ else {
+ // the given may be based on file
+ if (urlString != null) {
+ // swich the url to proper direction
+ url = PathHelper.removeLeadingSeparator(url);
+ File fle = new File(urlString, url);
+ absUrl = fle.getPath();
+
+ }
+ // convert everything to forward slash
+ absUrl = PathHelper.switchToForwardSlashes(absUrl);
+
+ // if the path ends with ".." we need to add a terminating slash
+ // or
+ // else the link will not be resolved correctly. (it will look
+ // like
+ // /url/path/to/somewhere/.. instead of /url/path/to/
+ if (absUrl.endsWith(FORWARD_SLASH + RELATIVE_PATH_SIG)) {
+ absUrl += FORWARD_SLASH;
+ }
+ }
+
+ // resolve relative path to absolute
+ absUrl = PathHelper.adjustPath(absUrl);
+ return absUrl;
+ }
+
+ private void initialize(String baseUrl, String docRoot) {
+ //
+ // Find out whether baes url is a url or file name
+ //
+ try {
+ String temp = PathHelper.appendTrailingURLSlash(baseUrl);
+ fBaseUrl = new URL(temp);
+ }
+ catch (MalformedURLException mue) {
+ }
+ if (fBaseUrl == null) {
+ // it is a file based url
+ fBaseUrlString = baseUrl;
+ }
+
+ // do the same for doc root
+ if (docRoot != null) {
+ try {
+ String temp = PathHelper.appendTrailingURLSlash(docRoot);
+ fDocRoot = new URL(temp);
+
+ }
+ catch (MalformedURLException mue) {
+ }
+ if (fDocRoot == null) {
+ // it is a file based url
+ fDocRootString = docRoot;
+ }
+ }
+ }
+
+ /**
+ * Convert the given url to a abolute url using the base url Input url can
+ * be of any othe following format Absolute urls -------------- .
+ * http://www.foo.com/ . http://www.foo.com . http://www.foo.com/folder .
+ * http://www.foo.com/folder/ . http://www.foo.com/index.html .
+ * http://www.foo.com/folder/index.html .
+ * http://www.foo.com/folder/../index.html Url relative on document root
+ * ------------------------- . / . /folder . /index.html .
+ * /folder/index.html . /folder/../index.html
+ *
+ * Self relative ------------------------- . index.html . ./index.html .
+ * ../index.html . folder/index.html . folder/../index.html
+ *
+ * file based url adds another dimension since it doesn't have a document
+ * root So uses fDocRoot if provided
+ */
+ public String toAbsolute(String url) {
+ String absUrl = url;
+
+ URL newUrl = null;
+ // try to see it is a absolute url
+ try {
+ newUrl = new URL(url);
+ }
+ catch (MalformedURLException me) {
+ }
+ // if document root is provided
+ // do special case
+ if (newUrl == null) {
+ if (fDocRoot == null && fDocRootString == null) {
+ // try to check relative url
+ absUrl = convert(url, fBaseUrl, fBaseUrlString);
+ }
+ else {
+ // doc root is provided
+ // if the url is a doc root based use doc root
+
+ if (url.startsWith("/"))//$NON-NLS-1$
+ absUrl = convert(url, fDocRoot, fDocRootString);
+ else
+ absUrl = convert(url, fBaseUrl, fBaseUrlString);
+
+ }
+ }
+ return absUrl;
+ }
+
+ /**
+ * Convert from an absolute url to relative url based on the given url
+ * Both are assumed to be ablsute url
+ */
+ public String toRelative(String url, String documentUrl) {
+ String output = url;
+ // assuming both urls are absolute
+ try {
+ URL inputUrl = new URL(url);
+ URL docUrl = new URL(documentUrl);
+ // filter out if the urls are not fro the same domain
+ if (!inputUrl.getProtocol().equals(docUrl.getProtocol()) || !inputUrl.getHost().equals(docUrl.getHost()) || inputUrl.getPort() != docUrl.getPort())
+ return output;
+ // both url are coming form the same place
+ // strip off the domain parts
+ String inputName = inputUrl.getFile();
+ String docName = docUrl.getFile();
+ output = PathHelper.convertToRelative(inputName, docName);
+ }
+ catch (MalformedURLException me) {
+ output = null;
+ }
+ return output;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLModelProviderCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLModelProviderCSS.java
new file mode 100644
index 0000000..ef180d7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/URLModelProviderCSS.java
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util;
+
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.UnsupportedCharsetException;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.encoding.EncodingRule;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceAlreadyExists;
+import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse;
+import org.eclipse.wst.sse.core.internal.util.PathHelper;
+import org.eclipse.wst.sse.core.internal.util.ProjectResolver;
+import org.eclipse.wst.sse.core.internal.util.URIResolver;
+
+/**
+ */
+public class URLModelProviderCSS {
+
+ private static final int GET_MODEL_FOR_READ = 1;
+ // private static final int GET_NEW_MODEL_FOR_READ = 2;
+ private static final int GET_MODEL_FOR_EDIT = 3;
+ // private static final int GET_NEW_MODEL_FOR_EDIT = 4;
+ // private static final int READ_BUFFER_SIZE = 4096;
+ // IModelManager
+ private IModelManager modelManager = null;
+
+ /**
+ */
+ public URLModelProviderCSS() {
+ super();
+
+ // obtain model manager
+ modelManager = StructuredModelManager.getModelManager();
+ }
+
+ /**
+ * Calculate ID from a filename. This must be same as
+ * FileModelProvider.calculateId(IFile)
+ */
+ private static String calculateId(IPath fullIPath) {
+ return fullIPath.toString();
+ }
+
+ /**
+ * <code>baseModel</code>: the model containing the link
+ * <code>ref</code>: the link URL string
+ */
+ private IStructuredModel getCommonModelFor(final IStructuredModel baseModel, final String ref, final int which) throws IOException {
+ // first, create absolute url
+ String absURL = resolveURI(baseModel, ref, true);
+ if ((absURL == null) || (absURL.length() == 0)) {
+ return null;
+ }
+
+ // need to remove file:// scheme if necessary
+ try {
+ final URL aURL = new URL(absURL);
+ // An actual URL was given, only file:/// is supported
+ // resolve it by finding the file it points to
+ if (!aURL.getProtocol().equals("platform")) { //$NON-NLS-1$
+ if (aURL.getProtocol().equals("file") && (aURL.getHost().equals("localhost") || aURL.getHost().length() == 0)) { //$NON-NLS-2$//$NON-NLS-1$
+ absURL = aURL.getFile();
+ final IPath ipath = new Path(absURL);
+ // if path has a device, and if it begins with
+ // IPath.SEPARATOR, remove it
+ final String device = ipath.getDevice();
+ if ((device != null) && (device.length() > 0)) {
+ if (device.charAt(0) == IPath.SEPARATOR) {
+ final String newDevice = device.substring(1);
+ absURL = ipath.setDevice(newDevice).toString();
+ }
+ }
+
+ }
+ }
+ }
+ catch (MalformedURLException mfuExc) {
+ }
+
+ // next, decide project
+ IProject project = null;
+ final IPath fullIPath = new Path(absURL);
+ IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
+ IContainer container = workspace.getContainerForLocation(fullIPath);
+ if (container != null) {
+ // fullIPath doesn't exist in workspace
+ project = container.getProject();
+ }
+
+ // If HTML document has a link to an extern CSS which is not in
+ // IProject
+ // workspace.getContainerForLoation() may return null. We need to take
+ // care
+ // of this case
+
+ // now, get absURL's IFile
+ if ((project != null) && (project.getLocation().isPrefixOf(fullIPath) == false)) {
+ // it's at outside of Project
+ return null;
+ }
+
+ IStructuredModel model = null;
+ if (project != null) {
+ IPath filePath = fullIPath.removeFirstSegments(project.getLocation().segmentCount());
+ IFile file = (filePath != null && !filePath.isEmpty()) ? project.getFile(filePath) : null;
+ if (file == null) {
+ return null;
+ }
+
+ // obtain model
+ if (which == GET_MODEL_FOR_EDIT) {
+ model = getModelForEdit(file);
+ }
+ else if (which == GET_MODEL_FOR_READ) {
+ model = getModelForRead(file);
+ }
+
+ // setting synchronization stamp is IModelManager's client's
+ // responsibility
+ if (model != null && model.getSynchronizationStamp() == IResource.NULL_STAMP)
+ model.resetSynchronizationStamp(file);
+ }
+ else {
+ String id = null;
+ InputStream inStream = null;
+ // obtain resolver
+ URIResolver resolver = (project != null) ? (URIResolver) project.getAdapter(URIResolver.class) : null;
+ if (resolver == null) {
+ // ProjectResolver can take care of the case if project is
+ // null.
+ resolver = new ProjectResolver(project);
+ }
+ if (resolver == null) {
+ return null;
+ }
+
+ // there is no project. we can't expect IProject help to create
+ // id/inputStream
+ File file = fullIPath.toFile();
+
+ // obatin id
+ id = calculateId(fullIPath);
+
+ // obtain InputStream
+ try {
+ inStream = new FileInputStream(file);
+ }
+ catch (FileNotFoundException fnfe) {
+ // the file does not exist, or we don't have read permission
+ return null;
+ }
+
+ // obtain model
+ try {
+ if (which == GET_MODEL_FOR_EDIT) {
+ model = getModelManager().getModelForEdit(id, inStream, resolver);
+ }
+ else if (which == GET_MODEL_FOR_READ) {
+ model = getModelManager().getModelForRead(id, inStream, resolver);
+ }
+ }
+ catch (UnsupportedEncodingException ue) {
+ }
+ catch (IOException ioe) {
+ }
+ finally {
+ // close now !
+ if (inStream != null) {
+ inStream.close();
+ }
+ }
+ }
+
+ // set locationid
+ if (model != null && model.getBaseLocation() == null) {
+ model.setBaseLocation(fullIPath.toString());
+ }
+
+ return model;
+ }
+
+ /**
+ * <code>baseModel</code>: the model containing the link
+ * <code>ref</code>: the link URL string
+ */
+ public IStructuredModel getModelForEdit(IStructuredModel baseModel, String ref) throws IOException {
+ return getCommonModelFor(baseModel, ref, GET_MODEL_FOR_EDIT);
+ }
+
+ /**
+ */
+ private IStructuredModel getModelForEdit(IFile file) throws IOException {
+ if (file == null)
+ return null;
+ IModelManager manager = getModelManager();
+
+ // create a fake InputStream
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForEdit(file);
+ }
+ catch (UnsupportedCharsetException ex) {
+ try {
+ model = manager.getModelForEdit(file, EncodingRule.FORCE_DEFAULT);
+ }
+ catch (IOException ioe) {
+ }
+ catch (CoreException ce) {
+ }
+ }
+ catch (CoreException ce) {
+ }
+ return model;
+ }
+
+ /**
+ * <code>baseModel</code>: the model containing the link
+ * <code>ref</code>: the link URL string
+ */
+ public IStructuredModel getModelForRead(IStructuredModel baseModel, String ref) throws UnsupportedEncodingException, IOException {
+ return getCommonModelFor(baseModel, ref, GET_MODEL_FOR_READ);
+ }
+
+ /**
+ */
+ private IStructuredModel getModelForRead(IFile file) throws IOException {
+ if (file == null)
+ return null;
+ IModelManager manager = getModelManager();
+
+ // create a fake InputStream
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ }
+ catch (UnsupportedCharsetException ex) {
+ try {
+ model = manager.getModelForRead(file, EncodingRule.FORCE_DEFAULT);
+ }
+ catch (IOException ioe) {
+ }
+ catch (CoreException ce) {
+ }
+ }
+ catch (CoreException ce) {
+ }
+ return model;
+ }
+
+ /**
+ */
+ private IModelManager getModelManager() {
+ return modelManager;
+ }
+
+ public IStructuredModel getNewModelForEdit(IFile iFile) {
+ if (iFile == null)
+ return null;
+ IModelManager manager = getModelManager();
+ if (manager == null)
+ return null;
+
+ IStructuredModel model = null;
+ try {
+ model = manager.getNewModelForEdit(iFile, false);
+ }
+ catch (IOException ex) {
+ }
+ catch (ResourceInUse riu) {
+ }
+ catch (ResourceAlreadyExists rae) {
+ }
+ catch (CoreException ce) {
+ }
+ return model;
+ }
+
+ public IStructuredModel getNewModelForRead(IFile iFile) {
+ if (iFile == null)
+ return null;
+ IModelManager manager = getModelManager();
+ if (manager == null)
+ return null;
+
+ IStructuredModel model = null;
+ try {
+ model = manager.getNewModelForEdit(iFile, false);
+ }
+ catch (IOException ex) {
+ }
+ catch (ResourceInUse riu) {
+ }
+ catch (ResourceAlreadyExists rae) {
+ }
+ catch (CoreException ce) {
+ }
+ return model;
+ }
+
+ /**
+ * <code>baseModel</code>: the model containing the link
+ * <code>ref</code>: the link URL string
+ * <code>resolveCrossProjectLinks</code>: If resolveCrossProjectLinks
+ * is set to true, then this method will properly resolve the URI if it is
+ * a valid URI pointing to another (appropriate) project.
+ */
+ public static String resolveURI(IStructuredModel baseModel, String ref, boolean resolveCrossProjectLinks) {
+ if (baseModel == null)
+ return null;
+
+ // get resolver in Model
+ final URIResolver resolver = baseModel.getResolver();
+
+ // resolve to absolute url
+ final String absurl = (resolver != null) ? resolver.getLocationByURI(ref, resolveCrossProjectLinks) : null;
+ if ((resolver != null) && (absurl == null) && (ref != null) && (ref.trim().length() > 0) && (ref.trim().charAt(0) == '/')) {
+ // to reach here means :
+ // ref is a Docroot relative
+ // resolver can't resolve ref
+ // so that href is a broken and should not create model
+ return null;
+ }
+ if ((absurl != null) && (absurl.length() > 0)) {
+ return absurl;
+ }
+
+ // maybe ref is at outside of the Project
+ // obtain docroot;
+ final IContainer container = (resolver != null) ? resolver.getRootLocation() : null;
+ String docroot = null;
+ if (container != null) {
+ docroot = container.getLocation().toString();
+ }
+ if (docroot == null) {
+ docroot = baseModel.getBaseLocation();
+ }
+ if (docroot == null) {
+ // should not be
+ return null;
+ }
+
+ // obtain document url
+ String modelBaseLocation = baseModel.getBaseLocation();
+ if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) {
+ // fallback...
+ modelBaseLocation = baseModel.getId();
+ }
+ if ((modelBaseLocation == null) || (modelBaseLocation.length() == 0)) {
+ // i can't resolve uri !
+ return null;
+ }
+
+ // resolve url
+ URLHelper helper = new URLHelper(PathHelper.getContainingFolderPath(modelBaseLocation), PathHelper.getContainingFolderPath(PathHelper.appendTrailingURLSlash(docroot)));
+ return helper.toAbsolute(ref);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionXSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionXSubStyleAdapter.java
new file mode 100644
index 0000000..968013b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionXSubStyleAdapter.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.contentmodel.IValID;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMUtil;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ * for horizontal value of 'background-position'
+ */
+public class BackgroundPositionXSubStyleAdapter implements ISubPropertyAdapter {
+
+ /**
+ *
+ */
+ public BackgroundPositionXSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected CSSTextToken[] correctMeaningToken(CSSTextToken[] src) {
+ java.util.ArrayList list = new java.util.ArrayList();
+ for (int i = 0; i < src.length; i++) {
+ if (src[i].kind != CSSRegionContexts.CSS_S && src[i].kind != CSSRegionContexts.CSS_DECLARATION_VALUE_S && src[i].kind != CSSRegionContexts.CSS_COMMENT)
+ list.add(src[i]);
+ }
+ CSSTextToken[] ret = new CSSTextToken[list.size()];
+ list.toArray(ret);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public String get(ICSS2Properties properties) {
+ String str = null;
+ Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
+ if (obj != null) {
+ PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
+ PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
+ if (obj instanceof ICSSValueList) {
+ ICSSValueList list = (ICSSValueList) obj;
+ ICSSValue value = (ICSSValue) list.item(0);
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
+ if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
+ // check not top or bottom
+ if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
+ // case order is vertical -> horizontal
+ value = (ICSSValue) list.item(1);
+ }
+ }
+ }
+ str = value.getCSSValueText();
+ }
+ else if (obj instanceof ICSSValue) {
+ str = ((ICSSValue) obj).getCSSValueText();
+ if (str.equalsIgnoreCase(IValID.V_BOTTOM) || str.equalsIgnoreCase(IValID.V_TOP))
+ str = "";//$NON-NLS-1$
+ }
+ else {
+ str = obj.toString();
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
+ CSSTextToken[] tokens = parser.getTokens();
+
+ tokens = correctMeaningToken(tokens);
+ if (tokens.length == 0)
+ str = "";//$NON-NLS-1$
+ else if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
+ str = "";//$NON-NLS-1$
+ else
+ str = tokens[0].image;
+ }
+ }
+ return (str != null) ? str : "";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String newValue = null;
+ String valH = value;
+ String valV = properties.getBackgroundPositionY();
+ if (valV == null || valV.length() == 0)
+ newValue = valH;
+ else if (valH == null || valH.length() == 0) {
+ Collection valX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X).getValues();
+ Collection valY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y).getValues();
+ PropCMUtil.minus(valY, valX);
+ Iterator it = valY.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj.toString().equals(valV.toLowerCase())) {
+ // need not compensate for ...
+ newValue = valV;
+ break;
+ }
+ }
+ // compensate for Horizontal value
+ if (newValue == null) {
+ // check valV is length or not
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, valV.trim());
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens != null && tokens.length > 0 && tokens[0].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ newValue = IValID.V_LEFT + " " + valV;//$NON-NLS-1$
+ }
+ else
+ newValue = "0% " + valV;//$NON-NLS-1$
+ }
+ }
+ else
+ newValue = valH + " " + valV;//$NON-NLS-1$
+ properties.setBackgroundPosition(newValue);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionYSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionYSubStyleAdapter.java
new file mode 100644
index 0000000..948df9b
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundPositionYSubStyleAdapter.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.contentmodel.IValID;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMUtil;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValueList;
+import org.w3c.dom.css.CSSPrimitiveValue;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ * for vertical value of 'background-position'
+ */
+public class BackgroundPositionYSubStyleAdapter implements ISubPropertyAdapter {
+
+ /**
+ *
+ */
+ public BackgroundPositionYSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ protected CSSTextToken[] correctMeaningToken(CSSTextToken[] src) {
+ java.util.ArrayList list = new java.util.ArrayList();
+ for (int i = 0; i < src.length; i++) {
+ if (src[i].kind != CSSRegionContexts.CSS_S && src[i].kind != CSSRegionContexts.CSS_DECLARATION_VALUE_S && src[i].kind != CSSRegionContexts.CSS_COMMENT)
+ list.add(src[i]);
+ }
+ CSSTextToken[] ret = new CSSTextToken[list.size()];
+ list.toArray(ret);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public String get(ICSS2Properties properties) {
+ String str = null;
+ Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
+ if (obj != null) {
+ PropCMProperty propX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
+ PropCMProperty propY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
+ if (obj instanceof ICSSValueList) {
+ ICSSValueList list = (ICSSValueList) obj;
+ int index = 1;
+ ICSSValue value = (ICSSValue) list.item(0);
+ if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value;
+ if (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
+ // check not top or bottom
+ if (!propX.canHave(prim.getStringValue()) && propY.canHave(prim.getStringValue())) {
+ // case order is vertical -> horizontal
+ index = 0;
+ }
+ }
+ }
+ str = ((ICSSValue) list.item(index)).getCSSValueText();
+ }
+ else if (obj instanceof ICSSValue) {
+ str = ((ICSSValue) obj).getCSSValueText();
+ if (!str.equalsIgnoreCase(IValID.V_BOTTOM) && !str.equalsIgnoreCase(IValID.V_TOP))
+ str = "";//$NON-NLS-1$
+ }
+ else {
+ str = obj.toString();
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, str);
+ CSSTextToken[] tokens = parser.getTokens();
+
+ tokens = correctMeaningToken(tokens);
+ if (tokens.length == 1 && (tokens[0].image.equalsIgnoreCase(IValID.V_BOTTOM) || tokens[0].image.equalsIgnoreCase(IValID.V_TOP)))
+ str = tokens[0].image;
+ else if (tokens.length > 1)
+ str = tokens[1].image;
+ else
+ str = "";//$NON-NLS-1$
+ }
+ }
+ return (str != null) ? str : "";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String newValue = null;
+ String valH = properties.getBackgroundPositionX();
+ String valV = value;
+ if (valH != null && (valH.trim().equals("0%") /* default value */|| //$NON-NLS-1$
+ valH.trim().equalsIgnoreCase(IValID.V_LEFT) /*
+ * another
+ * default
+ * value
+ */))
+ valH = null;
+ if (valV == null || valV.length() == 0)
+ newValue = valH;
+ else if (valH == null || valH.length() == 0) {
+ Collection valX = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X).getValues();
+ Collection valY = PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y).getValues();
+ PropCMUtil.minus(valY, valX);
+ Iterator it = valY.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (obj.toString().equals(valV.toLowerCase())) {
+ // need not compensate for ...
+ newValue = valV;
+ break;
+ }
+ }
+ // compensate for Horizontal value
+ if (newValue == null) {
+ // check valV is length or not
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, valV.trim());
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens != null && tokens.length > 0 && tokens[0].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ newValue = IValID.V_LEFT + " " + valV;//$NON-NLS-1$
+ }
+ else
+ newValue = "0% " + valV;//$NON-NLS-1$
+ }
+ }
+ else
+ newValue = valH + " " + valV;//$NON-NLS-1$
+ properties.setBackgroundPosition(newValue);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundShorthandAdapter.java
new file mode 100644
index 0000000..9ead299
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BackgroundShorthandAdapter.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'background' property 'background' will be expanded to
+ * 'background-attachment', 'background-color', 'background-image',
+ * 'background-position', 'background-repeat',
+ */
+public class BackgroundShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BackgroundShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", image = "", repeat = "", attach = "", pos = "";//$NON-NLS-5$//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR);
+ PropCMProperty propImage = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE);
+ PropCMProperty propRepeat = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT);
+ PropCMProperty propAttach = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT);
+ PropCMProperty propPos = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ else if (propImage.canHave(tokens[i].image))
+ image = tokens[i].image;
+ else if (propRepeat.canHave(tokens[i].image))
+ repeat = tokens[i].image;
+ else if (propAttach.canHave(tokens[i].image))
+ attach = tokens[i].image;
+ else if (propPos.canHave(tokens[i].image)) {
+ if (pos == null || pos.length() <= 0)
+ pos = tokens[i].image;
+ else
+ pos = pos + " " + tokens[i].image;//$NON-NLS-1$
+ }
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) {
+ if (pos == null || pos.length() <= 0)
+ pos = tokens[i].image;
+ else
+ pos = pos + " " + tokens[i].image;//$NON-NLS-1$
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ image = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propImage.getName(), image);
+ dest.set(propRepeat.getName(), repeat);
+ dest.set(propAttach.getName(), attach);
+ dest.set(propPos.getName(), pos);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, image = null, repeat = null, attach = null, pos = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR);
+ PropCMProperty propImage = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE);
+ PropCMProperty propRepeat = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT);
+ PropCMProperty propAttach = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT);
+ PropCMProperty propPos = PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ else if (propImage.canHave(tokens[i].image))
+ image = tokens[i].image;
+ else if (propRepeat.canHave(tokens[i].image))
+ repeat = tokens[i].image;
+ else if (propAttach.canHave(tokens[i].image))
+ attach = tokens[i].image;
+ else if (propPos.canHave(tokens[i].image)) {
+ if (pos == null)
+ pos = tokens[i].image;
+ else
+ pos = pos + " " + tokens[i].image;//$NON-NLS-1$
+ }
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) {
+ if (pos == null)
+ pos = tokens[i].image;
+ else
+ pos = pos + " " + tokens[i].image;//$NON-NLS-1$
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ image = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propImage == propDest)
+ return image;
+ else if (propRepeat == propDest)
+ return repeat;
+ else if (propAttach == propDest)
+ return attach;
+ else if (propPos == propDest)
+ return pos;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderBottomShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderBottomShorthandAdapter.java
new file mode 100644
index 0000000..1107e27
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderBottomShorthandAdapter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-bottom' property 'border-bottom' will be expanded to
+ * 'border-bottom-color', 'border-bottom-style', 'border-bottom-width',
+ */
+public class BorderBottomShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderBottomShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", style = "", width = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propStyle.getName(), style);
+ dest.set(propWidth.getName(), width);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, style = null, width = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propStyle == propDest)
+ return style;
+ else if (propWidth == propDest)
+ return width;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderColorShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderColorShorthandAdapter.java
new file mode 100644
index 0000000..d8cc676
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderColorShorthandAdapter.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-color' property 'border-color' will be expanded to
+ * 'border-top-color', 'border-right-color', 'border-bottom-color',
+ * 'border-left-color',
+ */
+public class BorderColorShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderColorShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH)
+ idents[j++] = tokens[i].image;
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ idents[j++] = buf.toString();
+ }
+ if (j == 4)
+ break;
+ }
+
+ String[] dests = new String[4];
+ if (j == 0)
+ return true;
+ else if (j == 1) {
+ dests[0] = dests[1] = dests[2] = dests[3] = idents[0];
+ }
+ else if (j == 2) {
+ dests[0] = dests[2] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ }
+ else if (j == 3) {
+ dests[0] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ dests[2] = idents[2];
+ }
+ else {
+ for (int k = 0; k < 4; k++)
+ dests[k] = idents[k];
+ }
+ dest.set(PropCMProperty.P_BORDER_TOP_COLOR, dests[0]);
+ dest.set(PropCMProperty.P_BORDER_RIGHT_COLOR, dests[1]);
+ dest.set(PropCMProperty.P_BORDER_BOTTOM_COLOR, dests[2]);
+ dest.set(PropCMProperty.P_BORDER_LEFT_COLOR, dests[3]);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH)
+ idents[j++] = tokens[i].image;
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ idents[j++] = buf.toString();
+ }
+ if (j == 4)
+ break;
+ }
+
+ if (j == 0)
+ return null;
+ else if (j == 1)
+ return idents[0];
+ else if (j == 2) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_COLOR || propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_COLOR)
+ return idents[0];
+ else
+ return idents[1];
+ }
+ else if (j == 3) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_COLOR)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_COLOR)
+ return idents[2];
+ else
+ return idents[1];
+ }
+ else {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_COLOR)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_RIGHT_COLOR)
+ return idents[1];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_COLOR)
+ return idents[2];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_LEFT_COLOR)
+ return idents[3];
+ else
+ return null;
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderLeftShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderLeftShorthandAdapter.java
new file mode 100644
index 0000000..f8b7239
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderLeftShorthandAdapter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-left' property 'border-left' will be expanded to
+ * 'border-left-color', 'border-left-style', 'border-left-width',
+ */
+public class BorderLeftShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderLeftShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", style = "", width = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propStyle.getName(), style);
+ dest.set(propWidth.getName(), width);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, style = null, width = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propStyle == propDest)
+ return style;
+ else if (propWidth == propDest)
+ return width;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderRightShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderRightShorthandAdapter.java
new file mode 100644
index 0000000..50a5fc6
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderRightShorthandAdapter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-right' property 'border-right' will be expanded to
+ * 'border-right-color', 'border-right-style', 'border-right-width',
+ */
+public class BorderRightShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderRightShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", style = "", width = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propStyle.getName(), style);
+ dest.set(propWidth.getName(), width);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, style = null, width = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propStyle == propDest)
+ return style;
+ else if (propWidth == propDest)
+ return width;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderShorthandAdapter.java
new file mode 100644
index 0000000..12718a1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderShorthandAdapter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border' property 'border' will be expanded to 'border-color',
+ * 'border-style', 'border-width',
+ */
+public class BorderShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", style = "", width = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propStyle.getName(), style);
+ dest.set(propWidth.getName(), width);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, style = null, width = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propStyle == propDest)
+ return style;
+ else if (propWidth == propDest)
+ return width;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderStyleShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderStyleShorthandAdapter.java
new file mode 100644
index 0000000..0e409c1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderStyleShorthandAdapter.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-style' property 'border-style' will be expanded to
+ * 'border-top-style', 'border-right-style', 'border-bottom-style',
+ * 'border-left-style',
+ */
+public class BorderStyleShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderStyleShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ String[] dests = new String[4];
+ if (j == 0)
+ return true;
+ else if (j == 1) {
+ dests[0] = dests[1] = dests[2] = dests[3] = idents[0];
+ }
+ else if (j == 2) {
+ dests[0] = dests[2] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ }
+ else if (j == 3) {
+ dests[0] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ dests[2] = idents[2];
+ }
+ else {
+ for (int k = 0; k < 4; k++)
+ dests[k] = idents[k];
+ }
+ dest.set(PropCMProperty.P_BORDER_TOP_STYLE, dests[0]);
+ dest.set(PropCMProperty.P_BORDER_RIGHT_STYLE, dests[1]);
+ dest.set(PropCMProperty.P_BORDER_BOTTOM_STYLE, dests[2]);
+ dest.set(PropCMProperty.P_BORDER_LEFT_STYLE, dests[3]);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ if (j == 0)
+ return null;
+ else if (j == 1)
+ return idents[0];
+ else if (j == 2) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_STYLE || propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_STYLE)
+ return idents[0];
+ else
+ return idents[1];
+ }
+ else if (j == 3) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_STYLE)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_STYLE)
+ return idents[2];
+ else
+ return idents[1];
+ }
+ else {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_STYLE)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_RIGHT_STYLE)
+ return idents[1];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_STYLE)
+ return idents[2];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_LEFT_STYLE)
+ return idents[3];
+ else
+ return null;
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderTopShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderTopShorthandAdapter.java
new file mode 100644
index 0000000..e8738f7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderTopShorthandAdapter.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-top' property 'border-top' will be expanded to
+ * 'border-top-color', 'border-top-style', 'border-top-width',
+ */
+public class BorderTopShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderTopShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String color = "", style = "", width = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ dest.set(propColor.getName(), color);
+ dest.set(propStyle.getName(), style);
+ dest.set(propWidth.getName(), width);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String color = null, style = null, width = null;
+ PropCMProperty propColor = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE);
+ PropCMProperty propWidth = PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propWidth.canHave(tokens[i].image))
+ width = tokens[i].image;
+ else if (propColor.canHave(tokens[i].image))
+ color = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER) {
+ width = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_HASH) {
+ color = tokens[i].image;
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) {
+ StringBuffer buf = new StringBuffer();
+ while (i < tokens.length) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT) {
+ i++;
+ continue;
+ }
+ buf.append(tokens[i].image);
+ if (tokens[i++].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PARENTHESIS_CLOSE)
+ break;
+ }
+ i--;
+ color = buf.toString();
+ }
+ }
+
+ if (propColor == propDest)
+ return color;
+ else if (propStyle == propDest)
+ return style;
+ else if (propWidth == propDest)
+ return width;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderWidthShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderWidthShorthandAdapter.java
new file mode 100644
index 0000000..7198eb1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/BorderWidthShorthandAdapter.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'border-width' property 'border-width' will be expanded to
+ * 'border-top-width', 'border-right-width', 'border-bottom-width',
+ * 'border-left-width',
+ */
+public class BorderWidthShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public BorderWidthShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ String[] dests = new String[4];
+ if (j == 0)
+ return true;
+ else if (j == 1) {
+ dests[0] = dests[1] = dests[2] = dests[3] = idents[0];
+ }
+ else if (j == 2) {
+ dests[0] = dests[2] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ }
+ else if (j == 3) {
+ dests[0] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ dests[2] = idents[2];
+ }
+ else {
+ for (int k = 0; k < 4; k++)
+ dests[k] = idents[k];
+ }
+ dest.set(PropCMProperty.P_BORDER_TOP_WIDTH, dests[0]);
+ dest.set(PropCMProperty.P_BORDER_RIGHT_WIDTH, dests[1]);
+ dest.set(PropCMProperty.P_BORDER_BOTTOM_WIDTH, dests[2]);
+ dest.set(PropCMProperty.P_BORDER_LEFT_WIDTH, dests[3]);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ if (j == 0)
+ return null;
+ else if (j == 1)
+ return idents[0];
+ else if (j == 2) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_WIDTH || propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_WIDTH)
+ return idents[0];
+ else
+ return idents[1];
+ }
+ else if (j == 3) {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_WIDTH)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_WIDTH)
+ return idents[2];
+ else
+ return idents[1];
+ }
+ else {
+ if (propDest.getName() == PropCMProperty.P_BORDER_TOP_WIDTH)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_RIGHT_WIDTH)
+ return idents[1];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_BOTTOM_WIDTH)
+ return idents[2];
+ else if (propDest.getName() == PropCMProperty.P_BORDER_LEFT_WIDTH)
+ return idents[3];
+ else
+ return null;
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/CSSPropertyContext.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/CSSPropertyContext.java
new file mode 100644
index 0000000..1b83a8f
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/CSSPropertyContext.java
@@ -0,0 +1,2997 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.w3c.dom.css.CSSValue;
+
+
+/**
+ *
+ */
+public class CSSPropertyContext implements ICSS2Properties {
+
+ protected Hashtable fProperties = new Hashtable();
+ HashSet fModified = null;
+ private static java.util.Hashtable subPropertyAdapters;
+ private static java.util.Hashtable shorthandAdapters;
+
+ /**
+ *
+ */
+ public CSSPropertyContext() {
+ super();
+ initShorthandAdapters();
+ initSubPropertyAdapters();
+ }
+
+ /**
+ *
+ */
+ public CSSPropertyContext(ICSSStyleDeclaration decl) {
+ super();
+ initShorthandAdapters();
+ initSubPropertyAdapters();
+ initialize(decl);
+ }
+
+ /**
+ * This function exports all property/value pairs to 'decl' declaration
+ */
+ public void applyFull(ICSSStyleDeclaration decl) {
+ if (decl == null)
+ return;
+ Enumeration keys = fProperties.keys();
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ Object val = fProperties.get(key);
+ String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : val.toString();
+
+ if (value == null || value.length() <= 0)
+ decl.removeProperty(key.toString());
+ else
+ decl.setProperty(key.toString(), value.trim(), (val instanceof ValueData && ((ValueData) val).important) ? "!important" : "");//$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * This function exports modified property/value pairs to 'decl'
+ * declaration
+ */
+ public void applyModified(ICSSStyleDeclaration decl) {
+ if (decl == null || fModified == null)
+ return;
+ Iterator it = fModified.iterator();
+ while (it.hasNext()) {
+ Object key = it.next();
+ Object val = fProperties.get(key);
+ String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : ((val != null) ? val.toString() : null);
+
+ if (value == null || value.length() <= 0)
+ decl.removeProperty(key.toString());
+ else
+ decl.setProperty(key.toString(), value.trim(), (val instanceof ValueData && ((ValueData) val).important) ? "!important" : "");//$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * create clone of this context
+ */
+ public Object clone() {
+ CSSPropertyContext clone = new CSSPropertyContext();
+ if (this.fModified != null)
+ clone.fModified = (HashSet) this.fModified.clone();
+ else
+ clone.fModified = null;
+ clone.fProperties = (Hashtable) this.fProperties.clone();
+ return clone;
+ }
+
+ /**
+ * This function expands a short-hand property's value to each leaf
+ * property's value and set them to 'foreign'
+ *
+ * For example, given [prop=border-top, value="solid 1px yellow"] will be
+ * expanded to [border-top-color=yellow, border-top-style=solid,
+ * border-top-width=1px] and they are stored to 'foreign' context.
+ *
+ * Note that recursively shorthanded property like 'border' will be
+ * expanded to all descendant leaf properties like
+ * 'border-[top/right/bottom/left]-[color/style/width]'
+ *
+ * @param prop
+ * org.eclipse.wst.css.core.contentmodel.PropCMProperty
+ * @param value
+ * java.lang.String
+ * @param foreign
+ * org.eclipse.wst.css.core.util.declaration.CSSPropertyContext
+ */
+ protected static void expandToLeaf(PropCMProperty prop, String value, CSSPropertyContext foreign) {
+ // expand shorthand property
+ if (value != null && value.trim().length() > 0) {
+ IShorthandAdapter adapter = (IShorthandAdapter) shorthandAdapters.get(prop);
+ if (adapter != null) {
+ adapter.expand(value, foreign);
+ foreign.set(prop.getName(), "");//$NON-NLS-1$
+ for (int i = 0; i < prop.getNumChild(); i++) {
+ Object obj = prop.getChildAt(i);
+ if (obj instanceof PropCMProperty && !(obj instanceof PropCMSubProperty)) {
+ PropCMProperty expandedProp = (PropCMProperty) obj;
+ value = foreign.get(expandedProp.getName());
+ expandToLeaf(expandedProp, value, foreign);
+ }
+ }
+ }
+ else if (!value.equals(foreign.get(prop.getName()))) {
+ foreign.set(prop.getName(), value);
+ }
+ }
+ }
+
+ /**
+ * This function returns value of 'prop'. Querying value mechanism checks
+ * short-hand properties.
+ *
+ * For example, given "background=fixed white" is set in this insatnce and
+ * param "prop=background-color", the return value will be "white".
+ *
+ */
+ public java.lang.String get(org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty prop) {
+ if (prop instanceof PropCMSubProperty) {
+ ISubPropertyAdapter adapter = (ISubPropertyAdapter) subPropertyAdapters.get(prop.getName());
+ if (adapter != null)
+ return adapter.get(this);
+ }
+ String str = get(prop.getName());
+ if ((str == null || str.length() == 0) && prop.getShorthandContainerCount() > 0) {
+ // get expanded property
+ for (int i = 0; i < prop.getShorthandContainerCount(); i++) {
+ PropCMProperty propParent = prop.shorthandContainerAt(i);
+ String strParent = get(propParent);
+ if (strParent != null && strParent.trim().length() > 0) {
+ IShorthandAdapter adapter = (IShorthandAdapter) shorthandAdapters.get(propParent);
+ if (adapter != null) {
+ String extractedValue = adapter.extract(strParent, prop);
+ return (extractedValue != null) ? extractedValue : "";//$NON-NLS-1$
+ }
+ }
+ }
+ }
+ return str;
+ }
+
+ /**
+ * This function returns value of 'prop'. Querying value mechanism does
+ * not care shorthand properties.
+ */
+ protected String get(String propName) {
+ String str = null;
+ Object obj = fProperties.get(propName);
+ if (obj != null) {
+ if (obj instanceof ICSSValue)
+ str = ((ICSSValue) obj).getCSSValueText();
+ else
+ str = obj.toString();
+ }
+ return (str != null) ? str : "";//$NON-NLS-1$
+ }
+
+ /**
+ * See the azimuth property definition in CSS2.
+ *
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getAzimuth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_AZIMUTH));
+ }
+
+ /**
+ * See the background property definition in CSS2.
+ *
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackground() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG));
+ }
+
+ /**
+ * See the background-attachment property definition in CSS2.
+ *
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackgroundAttachment() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT));
+ }
+
+ /**
+ * See the background-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackgroundColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR));
+ }
+
+ /**
+ * See the background-image property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackgroundImage() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE));
+ }
+
+ /**
+ * See the background-position property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackgroundPosition() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION));
+ }
+
+ /**
+ *
+ */
+ public java.lang.String getBackgroundPositionX() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X));
+ /*
+ * String str = null; Object obj =
+ * fProperties.get(PropCMProperty.P_BG_POSITION); if (obj != null) {
+ * PropCMProperty propX =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
+ * PropCMProperty propY =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
+ * if (obj instanceof ICSSValueList) { ICSSValueList list =
+ * (ICSSValueList) obj; ICSSValue value = (ICSSValue) list.item(0); if
+ * (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
+ * ICSSPrimitiveValue prim = (ICSSPrimitiveValue) value; if
+ * (prim.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { // check
+ * not top or bottom if (!propX.canHave(prim.getStringValue()) &&
+ * propY.canHave(prim.getStringValue())) { // case order is vertical ->
+ * horizontal value = (ICSSValue) list.item(1); } } } str =
+ * value.getCSSValueText(); } else if (obj instanceof ICSSValue) { str =
+ * ((ICSSValue)obj).getCSSValueText(); } else str = obj.toString(); }
+ * return (str != null) ? str : "";
+ */
+ }
+
+ /**
+ *
+ */
+ public java.lang.String getBackgroundPositionY() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y));
+ /*
+ * String str = null; Object obj =
+ * fProperties.get(PropCMProperty.P_BG_POSITION); if (obj != null) {
+ * PropCMProperty propX =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X);
+ * PropCMProperty propY =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y);
+ * if (obj instanceof ICSSValueList) { ICSSValueList list =
+ * (ICSSValueList) obj; int index = 1; ICSSValue value = (ICSSValue)
+ * list.item(0); if (value.getCssValueType() ==
+ * CSSValue.CSS_PRIMITIVE_VALUE) { ICSSPrimitiveValue prim =
+ * (ICSSPrimitiveValue) value; if (prim.getPrimitiveType() ==
+ * CSSPrimitiveValue.CSS_IDENT) { // check not top or bottom if
+ * (!propX.canHave(prim.getStringValue()) &&
+ * propY.canHave(prim.getStringValue())) { // case order is vertical ->
+ * horizontal index = 0; } } } str =
+ * ((ICSSValue)list.item(index)).getCSSValueText(); } else if (obj
+ * instanceof ICSSValue) { // do nothing --- value is null } else str =
+ * obj.toString(); } return (str != null) ? str : "";
+ */
+ }
+
+ /**
+ * See the background-repeat property definition in CSS2.
+ *
+ * @exception org.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBackgroundRepeat() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT));
+ }
+
+ /**
+ * See the border property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorder() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER));
+ }
+
+ /**
+ * See the border-bottom property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderBottom() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM));
+ }
+
+ /**
+ * See the border-bottom-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderBottomColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR));
+ }
+
+ /**
+ * See the border-bottom-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderBottomStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE));
+ }
+
+ /**
+ * See the border-bottom-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderBottomWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH));
+ }
+
+ /**
+ * See the border-collapse property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderCollapse() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLLAPSE));
+ }
+
+ /**
+ * See the border-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR));
+ }
+
+ /**
+ * See the border-left property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderLeft() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT));
+ }
+
+ /**
+ * See the border-left-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderLeftColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR));
+ }
+
+ /**
+ * See the border-left-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderLeftStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE));
+ }
+
+ /**
+ * See the border-left-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderLeftWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH));
+ }
+
+ /**
+ * See the border-right property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderRight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT));
+ }
+
+ /**
+ * See the border-right-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderRightColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR));
+ }
+
+ /**
+ * See the border-right-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderRightStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE));
+ }
+
+ /**
+ * See the border-right-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderRightWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH));
+ }
+
+ /**
+ * See the border-spacing property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderSpacing() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_SPACING));
+ }
+
+ /**
+ * See the border-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE));
+ }
+
+ /**
+ * See the border-top property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderTop() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP));
+ }
+
+ /**
+ * See the border-top-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderTopColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR));
+ }
+
+ /**
+ * See the border-top-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderTopStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE));
+ }
+
+ /**
+ * See the border-top-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderTopWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH));
+ }
+
+ /**
+ * See the border-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBorderWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH));
+ }
+
+ /**
+ * See the bottom property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getBottom() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_BOTTOM));
+ }
+
+ /**
+ * See the caption-side property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCaptionSide() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CAPTION_SIDE));
+ }
+
+ /**
+ * See the clear property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getClear() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CLEAR));
+ }
+
+ /**
+ * See the clip property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getClip() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ }
+
+ /**
+ *
+ */
+ public String getClipBottom() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM));
+ }
+
+ /**
+ *
+ */
+ public String getClipLeft() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT));
+ }
+
+ /**
+ *
+ */
+ public String getClipRight() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT));
+ }
+
+ /**
+ *
+ */
+ public String getClipTop() {
+ return get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP));
+ }
+
+ /**
+ * See the color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_COLOR));
+ }
+
+ /**
+ * See the content property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getContent() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CONTENT));
+ }
+
+ /**
+ * See the counter-increment property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCounterIncrement() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_INCREMENT));
+ }
+
+ /**
+ * See the counter-reset property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCounterReset() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_RESET));
+ }
+
+ /**
+ * See the float property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCssFloat() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FLOAT));
+ }
+
+ /**
+ * See the cue property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCue() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE));
+ }
+
+ /**
+ * See the cue-after property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCueAfter() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER));
+ }
+
+ /**
+ * See the cue-before property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCueBefore() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE));
+ }
+
+ /**
+ * See the cursor property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getCursor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_CURSOR));
+ }
+
+ /**
+ * See the direction property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getDirection() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_DIRECTION));
+ }
+
+ /**
+ * See the display property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getDisplay() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_DISPLAY));
+ }
+
+ /**
+ * See the elevation property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getElevation() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_ELEVATION));
+ }
+
+ /**
+ * See the empty-cells property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getEmptyCells() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_EMPTY_CELLS));
+ }
+
+ /**
+ * See the font property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFont() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT));
+ }
+
+ /**
+ * See the font-family property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontFamily() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY));
+ }
+
+ /**
+ * See the font-size property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontSize() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE));
+ }
+
+ /**
+ * See the font-size-adjust property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontSizeAdjust() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE_ADJUST));
+ }
+
+ /**
+ * See the font-stretch property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontStretch() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STRETCH));
+ }
+
+ /**
+ * See the font-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE));
+ }
+
+ /**
+ * See the font-variant property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontVariant() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT));
+ }
+
+ /**
+ * See the font-weight property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getFontWeight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT));
+ }
+
+ /**
+ * See the height property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getHeight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_HEIGHT));
+ }
+
+ /**
+ * See the left property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getLeft() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LEFT));
+ }
+
+ /**
+ * See the letter-spacing property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getLetterSpacing() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LETTER_SPACING));
+ }
+
+ /**
+ * See the line-height property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getLineHeight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT));
+ }
+
+ /**
+ * See the list-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getListStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE));
+ }
+
+ /**
+ * See the list-style-image property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getListStyleImage() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE));
+ }
+
+ /**
+ * See the list-style-position property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getListStylePosition() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION));
+ }
+
+ /**
+ * See the list-style-type property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getListStyleType() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE));
+ }
+
+ /**
+ * See the margin property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMargin() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN));
+ }
+
+ /**
+ * See the margin-bottom property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarginBottom() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM));
+ }
+
+ /**
+ * See the margin-left property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarginLeft() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT));
+ }
+
+ /**
+ * See the margin-right property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarginRight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT));
+ }
+
+ /**
+ * See the margin-top property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarginTop() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP));
+ }
+
+ /**
+ * See the marker-offset property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarkerOffset() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARKER_OFFSET));
+ }
+
+ /**
+ * See the marks property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMarks() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MARKS));
+ }
+
+ /**
+ * See the max-height property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMaxHeight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_HEIGHT));
+ }
+
+ /**
+ * See the max-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMaxWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_WIDTH));
+ }
+
+ /**
+ * See the min-height property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMinHeight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_HEIGHT));
+ }
+
+ /**
+ * See the min-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getMinWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_WIDTH));
+ }
+
+ /**
+ * See the orphans property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOrphans() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_ORPHANS));
+ }
+
+ /**
+ * See the outline property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOutline() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE));
+ }
+
+ /**
+ * See the outline-color property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOutlineColor() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR));
+ }
+
+ /**
+ * See the outline-style property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOutlineStyle() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE));
+ }
+
+ /**
+ * See the outline-width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOutlineWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH));
+ }
+
+ /**
+ * See the overflow property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getOverflow() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_OVERFLOW));
+ }
+
+ /**
+ * See the padding property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPadding() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING));
+ }
+
+ /**
+ * See the padding-bottom property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPaddingBottom() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM));
+ }
+
+ /**
+ * See the padding-left property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPaddingLeft() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT));
+ }
+
+ /**
+ * See the padding-right property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPaddingRight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT));
+ }
+
+ /**
+ * See the padding-top property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPaddingTop() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP));
+ }
+
+ /**
+ * See the page property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPage() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE));
+ }
+
+ /**
+ * See the page-break-after property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPageBreakAfter() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_AFTER));
+ }
+
+ /**
+ * See the page-break-before property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPageBreakBefore() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_BEFORE));
+ }
+
+ /**
+ * See the page-break-inside property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPageBreakInside() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_INSIDE));
+ }
+
+ /**
+ * See the pause property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPause() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE));
+ }
+
+ /**
+ * See the pause-after property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPauseAfter() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_AFTER));
+ }
+
+ /**
+ * See the pause-before property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPauseBefore() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_BEFORE));
+ }
+
+ /**
+ * See the pitch property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPitch() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH));
+ }
+
+ /**
+ * See the pitch-range property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPitchRange() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH_RANGE));
+ }
+
+ /**
+ * See the play-during property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPlayDuring() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_PLAY_DURING));
+ }
+
+ /**
+ * See the position property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getPosition() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_POSITION));
+ }
+
+ /**
+ * See the quotes property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getQuotes() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_QUOTES));
+ }
+
+ /**
+ * See the richness property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getRichness() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_RICHNESS));
+ }
+
+ /**
+ * See the right property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getRight() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_RIGHT));
+ }
+
+ /**
+ * @return org.eclipse.wst.css.core.util.declaration.IShorthandAdapter
+ * @param org.eclipse.wst.css.core.contentmodel.PropCMProperty
+ */
+ public static IShorthandAdapter getShorthandAdapter(PropCMProperty prop) {
+ return (IShorthandAdapter) shorthandAdapters.get(prop);
+ }
+
+ /**
+ * See the size property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSize() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SIZE));
+ }
+
+ /**
+ * See the speak property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSpeak() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK));
+ }
+
+ /**
+ * See the speak-header property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSpeakHeader() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_HEADER));
+ }
+
+ /**
+ * See the speak-numeral property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSpeakNumeral() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_NUMERAL));
+ }
+
+ /**
+ * See the speak-punctuation property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSpeakPunctuation() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_PUNCTUATION));
+ }
+
+ /**
+ * See the speech-rate property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getSpeechRate() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEECH_RATE));
+ }
+
+ /**
+ * See the stress property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getStress() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_STRESS));
+ }
+
+ /**
+ * See the table-layout property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTableLayout() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TABLE_LAYOUT));
+ }
+
+ /**
+ * See the text-align property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTextAlign() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_ALIGN));
+ }
+
+ /**
+ * See the text-decoration property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTextDecoration() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_DECORATION));
+ }
+
+ /**
+ * See the text-indent property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTextIndent() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_INDENT));
+ }
+
+ /**
+ * See the text-shadow property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTextShadow() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_SHADOW));
+ }
+
+ /**
+ * See the text-transform property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTextTransform() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_TRANSFORM));
+ }
+
+ /**
+ * See the top property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getTop() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_TOP));
+ }
+
+ /**
+ * See the unicode-bidi property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getUnicodeBidi() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_UNICODE_BIDI));
+ }
+
+ /**
+ * See the vertical-align property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getVerticalAlign() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_VERTICAL_ALIGN));
+ }
+
+ /**
+ * See the visibility property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getVisibility() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_VISIBILITY));
+ }
+
+ /**
+ * See the voice-family property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getVoiceFamily() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_VOICE_FAMILY));
+ }
+
+ /**
+ * See the volume property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getVolume() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_VOLUME));
+ }
+
+ /**
+ * See the white-space property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getWhiteSpace() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_WHITE_SPACE));
+ }
+
+ /**
+ * See the widows property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getWidows() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_WIDOWS));
+ }
+
+ /**
+ * See the width property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getWidth() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_WIDTH));
+ }
+
+ /**
+ * See the word-spacing property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getWordSpacing() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_WORD_SPACING));
+ }
+
+ /**
+ * See the z-index property definition in CSS2.
+ *
+ * @exceptionorg.w3c.dom.DOMException
+ * SYNTAX_ERR: Raised if the new value has a syntax error
+ * and is unparsable. <br>
+ * NO_MODIFICATION_ALLOWED_ERR: Raised if this property is
+ * readonly.
+ */
+ public String getZIndex() {
+ return get(PropCMProperty.getInstanceOf(PropCMProperty.P_Z_INDEX));
+ }
+
+ /**
+ *
+ */
+ public void initialize(ICSSStyleDeclaration decl) {
+ fProperties.clear();
+ if (fModified != null)
+ fModified.clear();
+ if (decl == null)
+ return;
+
+ int nProperties = decl.getLength();
+ for (int i = 0; i < nProperties; i++) {
+ String propName = decl.item(i);
+ if (propName != null) {
+ String propN = propName.trim().toLowerCase();
+ if (propN.length() != 0) {
+ CSSValue val = decl.getPropertyCSSValue(propName);
+ if (val != null)
+ fProperties.put(propN, val);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ static void initShorthandAdapters() {
+ if (shorthandAdapters == null) {
+ shorthandAdapters = new Hashtable();
+ // register
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BG), new BackgroundShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER), new BorderShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR), new BorderColorShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE), new BorderStyleShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH), new BorderWidthShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP), new BorderTopShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT), new BorderRightShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM), new BorderBottomShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT), new BorderLeftShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT), new FontShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE), new ListStyleShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN), new MarginShorthandAdapter());
+ shorthandAdapters.put(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING), new PaddingShorthandAdapter());
+
+ }
+ }
+
+ /**
+ *
+ */
+ static void initSubPropertyAdapters() {
+ if (subPropertyAdapters == null) {
+ subPropertyAdapters = new Hashtable();
+
+ // register
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_BG_POSITION_X, new BackgroundPositionXSubStyleAdapter());
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_BG_POSITION_Y, new BackgroundPositionYSubStyleAdapter());
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_CLIP_TOP, new ClipTopSubStyleAdapter());
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_CLIP_RIGHT, new ClipRightSubStyleAdapter());
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_CLIP_BOTTOM, new ClipBottomSubStyleAdapter());
+ subPropertyAdapters.put(PropCMSubProperty.PSUB_CLIP_LEFT, new ClipLeftSubStyleAdapter());
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean isModified() {
+ return (fModified != null && fModified.size() != 0);
+ }
+
+ /**
+ *
+ */
+ public Enumeration properties() {
+ return fProperties.keys();
+ }
+
+ /**
+ *
+ */
+ public Iterator propertiesModified() {
+ if (fModified != null) {
+ return ((Collection) fModified.clone()).iterator();
+ }
+ else
+ return new Iterator() {
+ public boolean hasNext() {
+ return false;
+ }
+
+ public Object next() {
+ return null;
+ }
+
+ public void remove() {
+ }
+ };
+ }
+
+ /**
+ * This function expands the value of shorthand 'prop' to 'foreign'
+ * context. Note that if this has parent shorthand properties of 'prop',
+ * they are all expanded to 'foreign' context.
+ */
+ protected void recursiveExtract(PropCMProperty prop, CSSPropertyContext foreign) {
+ // expand shorthand property
+ for (int i = 0; i < prop.getShorthandContainerCount(); i++) {
+ recursiveExtract(prop.shorthandContainerAt(i), foreign);
+ }
+ String str = get(prop.getName());
+ if (str == null || str.trim().length() == 0)
+ str = foreign.get(prop.getName());
+ if (str != null && str.trim().length() > 0) {
+ IShorthandAdapter adapter = (IShorthandAdapter) shorthandAdapters.get(prop);
+ if (adapter != null) {
+ adapter.expand(str, foreign);
+ foreign.set(prop.getName(), "");//$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void removeDescendants(PropCMProperty prop) {
+ if (prop.isShorthand()) {
+ // remove properties
+ int n = prop.getNumChild();
+ for (int i = 0; i < n; i++) {
+ Object obj = prop.getChildAt(i);
+ if (obj instanceof PropCMProperty) {
+ removeDescendants((PropCMProperty) obj);
+
+ String str = get(obj.toString());
+ if (str != null && str.length() > 0)
+ set(obj.toString(), "");//$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void resetModified() {
+ if (fModified != null)
+ fModified.clear();
+ }
+
+ /**
+ * This function sets the pair of 'prop'/'value'. If shorthand properties
+ * related to 'prop' are already defined, they will be expanded to avoid
+ * property confliction. If descendant properties of 'prop' are already
+ * defined, they will be removed to avoid property confliction.
+ *
+ */
+ public void set(org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty prop, java.lang.String value) throws org.w3c.dom.DOMException {
+ if (prop instanceof PropCMSubProperty) {
+ ISubPropertyAdapter adapter = (ISubPropertyAdapter) subPropertyAdapters.get(prop.getName());
+ if (adapter != null) {
+ adapter.set(this, value);
+ return;
+ }
+ }
+ if (prop.getShorthandContainerCount() > 0) {
+ // expand shorthand property
+ CSSPropertyContext context = new CSSPropertyContext();
+ for (int i = 0; i < prop.getShorthandContainerCount(); i++) {
+ recursiveExtract(prop.shorthandContainerAt(i), context);
+ }
+ Enumeration properties = context.properties();
+ while (properties.hasMoreElements()) {
+ String propForeign = properties.nextElement().toString();
+ set(propForeign, context.get(propForeign));
+ }
+ }
+
+ removeDescendants(prop);
+
+ set(prop.getName(), value);
+ }
+
+ /**
+ * This function sets the pair of 'propName'/'value' regardless of its
+ * shorthand properties.
+ */
+ protected void set(String propName, String value) throws org.w3c.dom.DOMException {
+ String key = propName;
+ if (value == null)
+ fProperties.remove(key);
+ else
+ fProperties.put(key, value);
+ if (fModified == null)
+ fModified = new HashSet();
+ fModified.add(key);
+ }
+
+ /**
+ *
+ */
+ public void setAzimuth(String azimuth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_AZIMUTH), azimuth);
+ }
+
+ /**
+ *
+ */
+ public void setBackground(String background) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG), background);
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundAttachment(String backgroundAttachment) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_ATTACHMENT), backgroundAttachment);
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundColor(String backgroundColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_COLOR), backgroundColor);
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundImage(String backgroundImage) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_IMAGE), backgroundImage);
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundPosition(String backgroundPosition) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_POSITION), backgroundPosition);
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundPositionX(java.lang.String backgroundPositionX) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X), backgroundPositionX);
+ /*
+ * String newValue = null; String valH = backgroundPositionX; String
+ * valV = getBackgroundPositionY(); if (valV == null ||
+ * valV.length()== 0) newValue = valH; else if (valH == null ||
+ * valH.length() == 0) { Collection valX =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X).getValues();
+ * Collection valY =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y).getValues();
+ * PropCMUtil.minus(valY,valX); Iterator it = valY.iterator();
+ * while(it.hasNext()) { Object obj = it.next(); if
+ * (obj.toString().equals(valV.toLowerCase())) { // need not
+ * compensate for ... newValue = valV; break; } } // compensate for
+ * Horizontal value if (newValue == null) newValue = "0% " + valV; }
+ * else newValue = valH + " " + valV; setBackgroundPosition(newValue);
+ */
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundPositionY(java.lang.String backgroundPositionY) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y), backgroundPositionY);
+ /*
+ * String newValue = null; String valH = getBackgroundPositionX();
+ * String valV = backgroundPositionY; if (valV == null ||
+ * valV.length()== 0) newValue = valH; else if (valH == null ||
+ * valH.length() == 0) { Collection valX =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_X).getValues();
+ * Collection valY =
+ * PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_BG_POSITION_Y).getValues();
+ * PropCMUtil.minus(valY,valX); Iterator it = valY.iterator();
+ * while(it.hasNext()) { Object obj = it.next(); if
+ * (obj.toString().equals(valV.toLowerCase())) { // need not
+ * compensate for ... newValue = valV; break; } } // compensate for
+ * Horizontal value if (newValue == null) newValue = "0% " + valV; }
+ * else newValue = valH + " " + valV; setBackgroundPosition(newValue);
+ */
+ }
+
+ /**
+ *
+ */
+ public void setBackgroundRepeat(String backgroundRepeat) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BG_REPEAT), backgroundRepeat);
+ }
+
+ /**
+ *
+ */
+ public void setBorder(String border) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER), border);
+ }
+
+ /**
+ *
+ */
+ public void setBorderBottom(String borderBottom) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM), borderBottom);
+ }
+
+ /**
+ *
+ */
+ public void setBorderBottomColor(String borderBottomColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_COLOR), borderBottomColor);
+ }
+
+ /**
+ *
+ */
+ public void setBorderBottomStyle(String borderBottomStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_STYLE), borderBottomStyle);
+ }
+
+ /**
+ *
+ */
+ public void setBorderBottomWidth(String borderBottomWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_BOTTOM_WIDTH), borderBottomWidth);
+ }
+
+ /**
+ *
+ */
+ public void setBorderCollapse(String borderCollapse) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLLAPSE), borderCollapse);
+ }
+
+ /**
+ *
+ */
+ public void setBorderColor(String borderColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_COLOR), borderColor);
+ }
+
+ /**
+ *
+ */
+ public void setBorderLeft(String borderLeft) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT), borderLeft);
+ }
+
+ /**
+ *
+ */
+ public void setBorderLeftColor(String borderLeftColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_COLOR), borderLeftColor);
+ }
+
+ /**
+ *
+ */
+ public void setBorderLeftStyle(String borderLeftStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_STYLE), borderLeftStyle);
+ }
+
+ /**
+ *
+ */
+ public void setBorderLeftWidth(String borderLeftWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_LEFT_WIDTH), borderLeftWidth);
+ }
+
+ /**
+ *
+ */
+ public void setBorderRight(String borderRight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT), borderRight);
+ }
+
+ /**
+ *
+ */
+ public void setBorderRightColor(String borderRightColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_COLOR), borderRightColor);
+ }
+
+ /**
+ *
+ */
+ public void setBorderRightStyle(String borderRightStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_STYLE), borderRightStyle);
+ }
+
+ /**
+ *
+ */
+ public void setBorderRightWidth(String borderRightWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_RIGHT_WIDTH), borderRightWidth);
+ }
+
+ /**
+ *
+ */
+ public void setBorderSpacing(String borderSpacing) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_SPACING), borderSpacing);
+ }
+
+ /**
+ *
+ */
+ public void setBorderStyle(String borderStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_STYLE), borderStyle);
+ }
+
+ /**
+ *
+ */
+ public void setBorderTop(String borderTop) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP), borderTop);
+ }
+
+ /**
+ *
+ */
+ public void setBorderTopColor(String borderTopColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_COLOR), borderTopColor);
+ }
+
+ /**
+ *
+ */
+ public void setBorderTopStyle(String borderTopStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_STYLE), borderTopStyle);
+ }
+
+ /**
+ *
+ */
+ public void setBorderTopWidth(String borderTopWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_TOP_WIDTH), borderTopWidth);
+ }
+
+ /**
+ *
+ */
+ public void setBorderWidth(String borderWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BORDER_WIDTH), borderWidth);
+ }
+
+ /**
+ *
+ */
+ public void setBottom(String bottom) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_BOTTOM), bottom);
+ }
+
+ /**
+ *
+ */
+ public void setCaptionSide(String captionSide) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CAPTION_SIDE), captionSide);
+ }
+
+ /**
+ *
+ */
+ public void setClear(String clear) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CLEAR), clear);
+ }
+
+ /**
+ *
+ */
+ public void setClip(String clip) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP), clip);
+ }
+
+ /**
+ *
+ */
+ public void setClipBottom(java.lang.String clip) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM), clip);
+ }
+
+ /**
+ *
+ */
+ public void setClipLeft(java.lang.String clip) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT), clip);
+ }
+
+ /**
+ *
+ */
+ public void setClipRight(java.lang.String clip) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT), clip);
+ }
+
+ /**
+ *
+ */
+ public void setClipTop(java.lang.String clip) throws org.w3c.dom.DOMException {
+ set(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP), clip);
+ }
+
+ /**
+ *
+ */
+ public void setColor(String color) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_COLOR), color);
+ }
+
+ /**
+ *
+ */
+ public void setContent(String content) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CONTENT), content);
+ }
+
+ /**
+ *
+ */
+ public void setCounterIncrement(String counterIncrement) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_INCREMENT), counterIncrement);
+ }
+
+ /**
+ *
+ */
+ public void setCounterReset(String counterReset) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_COUNTER_RESET), counterReset);
+ }
+
+ /**
+ *
+ */
+ public void setCssFloat(String cssFloat) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FLOAT), cssFloat);
+ }
+
+ /**
+ *
+ */
+ public void setCue(String cue) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE), cue);
+ }
+
+ /**
+ *
+ */
+ public void setCueAfter(String cueAfter) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_AFTER), cueAfter);
+ }
+
+ /**
+ *
+ */
+ public void setCueBefore(String cueBefore) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CUE_BEFORE), cueBefore);
+ }
+
+ /**
+ *
+ */
+ public void setCursor(String cursor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_CURSOR), cursor);
+ }
+
+ /**
+ *
+ */
+ public void setDirection(String direction) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_DIRECTION), direction);
+ }
+
+ /**
+ *
+ */
+ public void setDisplay(String display) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_DISPLAY), display);
+ }
+
+ /**
+ *
+ */
+ public void setElevation(String elevation) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_ELEVATION), elevation);
+ }
+
+ /**
+ *
+ */
+ public void setEmptyCells(String emptyCells) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_EMPTY_CELLS), emptyCells);
+ }
+
+ /**
+ *
+ */
+ public void setFont(String font) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT), font);
+ }
+
+ /**
+ *
+ */
+ public void setFontFamily(String fontFamily) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY), fontFamily);
+ }
+
+ /**
+ *
+ */
+ public void setFontSize(String fontSize) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE), fontSize);
+ }
+
+ /**
+ *
+ */
+ public void setFontSizeAdjust(String fontSizeAdjust) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE_ADJUST), fontSizeAdjust);
+ }
+
+ /**
+ *
+ */
+ public void setFontStretch(String fontStretch) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STRETCH), fontStretch);
+ }
+
+ /**
+ *
+ */
+ public void setFontStyle(String fontStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE), fontStyle);
+ }
+
+ /**
+ *
+ */
+ public void setFontVariant(String fontVariant) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT), fontVariant);
+ }
+
+ /**
+ *
+ */
+ public void setFontWeight(String fontWeight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT), fontWeight);
+ }
+
+ /**
+ *
+ */
+ public void setHeight(String height) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_HEIGHT), height);
+ }
+
+ /**
+ *
+ */
+ public void setLeft(String left) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LEFT), left);
+ }
+
+ /**
+ *
+ */
+ public void setLetterSpacing(String letterSpacing) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LETTER_SPACING), letterSpacing);
+ }
+
+ /**
+ *
+ */
+ public void setLineHeight(String lineHeight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT), lineHeight);
+ }
+
+ /**
+ *
+ */
+ public void setListStyle(String listStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE), listStyle);
+ }
+
+ /**
+ *
+ */
+ public void setListStyleImage(String listStyleImage) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE), listStyleImage);
+ }
+
+ /**
+ *
+ */
+ public void setListStylePosition(String listStylePosition) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION), listStylePosition);
+ }
+
+ /**
+ *
+ */
+ public void setListStyleType(String listStyleType) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE), listStyleType);
+ }
+
+ /**
+ *
+ */
+ public void setMargin(String margin) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN), margin);
+ }
+
+ /**
+ *
+ */
+ public void setMarginBottom(String marginBottom) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_BOTTOM), marginBottom);
+ }
+
+ /**
+ *
+ */
+ public void setMarginLeft(String marginLeft) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_LEFT), marginLeft);
+ }
+
+ /**
+ *
+ */
+ public void setMarginRight(String marginRight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_RIGHT), marginRight);
+ }
+
+ /**
+ *
+ */
+ public void setMarginTop(String marginTop) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARGIN_TOP), marginTop);
+ }
+
+ /**
+ *
+ */
+ public void setMarkerOffset(String markerOffset) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARKER_OFFSET), markerOffset);
+ }
+
+ /**
+ *
+ */
+ public void setMarks(String marks) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MARKS), marks);
+ }
+
+ /**
+ *
+ */
+ public void setMaxHeight(String maxHeight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_HEIGHT), maxHeight);
+ }
+
+ /**
+ *
+ */
+ public void setMaxWidth(String maxWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MAX_WIDTH), maxWidth);
+ }
+
+ /**
+ *
+ */
+ public void setMinHeight(String minHeight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_HEIGHT), minHeight);
+ }
+
+ /**
+ *
+ */
+ public void setMinWidth(String minWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_MIN_WIDTH), minWidth);
+ }
+
+ /**
+ *
+ */
+ public void setOrphans(String orphans) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_ORPHANS), orphans);
+ }
+
+ /**
+ *
+ */
+ public void setOutline(String outline) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE), outline);
+ }
+
+ /**
+ *
+ */
+ public void setOutlineColor(String outlineColor) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_COLOR), outlineColor);
+ }
+
+ /**
+ *
+ */
+ public void setOutlineStyle(String outlineStyle) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_STYLE), outlineStyle);
+ }
+
+ /**
+ *
+ */
+ public void setOutlineWidth(String outlineWidth) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_OUTLINE_WIDTH), outlineWidth);
+ }
+
+ /**
+ *
+ */
+ public void setOverflow(String overflow) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_OVERFLOW), overflow);
+ }
+
+ /**
+ *
+ */
+ public void setPadding(String padding) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING), padding);
+ }
+
+ /**
+ *
+ */
+ public void setPaddingBottom(String paddingBottom) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_BOTTOM), paddingBottom);
+ }
+
+ /**
+ *
+ */
+ public void setPaddingLeft(String paddingLeft) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_LEFT), paddingLeft);
+ }
+
+ /**
+ *
+ */
+ public void setPaddingRight(String paddingRight) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_RIGHT), paddingRight);
+ }
+
+ /**
+ *
+ */
+ public void setPaddingTop(String paddingTop) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PADDING_TOP), paddingTop);
+ }
+
+ /**
+ *
+ */
+ public void setPage(String page) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE), page);
+ }
+
+ /**
+ *
+ */
+ public void setPageBreakAfter(String pageBreakAfter) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_AFTER), pageBreakAfter);
+ }
+
+ /**
+ *
+ */
+ public void setPageBreakBefore(String pageBreakBefore) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_BEFORE), pageBreakBefore);
+ }
+
+ /**
+ *
+ */
+ public void setPageBreakInside(String pageBreakInside) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAGE_BREAK_INSIDE), pageBreakInside);
+ }
+
+ /**
+ *
+ */
+ public void setPause(String pause) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE), pause);
+ }
+
+ /**
+ *
+ */
+ public void setPauseAfter(String pauseAfter) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_AFTER), pauseAfter);
+ }
+
+ /**
+ *
+ */
+ public void setPauseBefore(String pauseBefore) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PAUSE_BEFORE), pauseBefore);
+ }
+
+ /**
+ *
+ */
+ public void setPitch(String pitch) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH), pitch);
+ }
+
+ /**
+ *
+ */
+ public void setPitchRange(String pitchRange) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PITCH_RANGE), pitchRange);
+ }
+
+ /**
+ *
+ */
+ public void setPlayDuring(String playDuring) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_PLAY_DURING), playDuring);
+ }
+
+ /**
+ *
+ */
+ public void setPosition(String position) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_POSITION), position);
+ }
+
+ /**
+ *
+ */
+ public void setQuotes(String quotes) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_QUOTES), quotes);
+ }
+
+ /**
+ *
+ */
+ public void setRichness(String richness) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_RICHNESS), richness);
+ }
+
+ /**
+ *
+ */
+ public void setRight(String right) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_RIGHT), right);
+ }
+
+ /**
+ *
+ */
+ public void setSize(String size) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SIZE), size);
+ }
+
+ /**
+ *
+ */
+ public void setSpeak(String speak) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK), speak);
+ }
+
+ /**
+ *
+ */
+ public void setSpeakHeader(String speakHeader) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_HEADER), speakHeader);
+ }
+
+ /**
+ *
+ */
+ public void setSpeakNumeral(String speakNumeral) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_NUMERAL), speakNumeral);
+ }
+
+ /**
+ *
+ */
+ public void setSpeakPunctuation(String speakPunctuation) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEAK_PUNCTUATION), speakPunctuation);
+ }
+
+ /**
+ *
+ */
+ public void setSpeechRate(String speechRate) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_SPEECH_RATE), speechRate);
+ }
+
+ /**
+ *
+ */
+ public void setStress(String stress) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_STRESS), stress);
+ }
+
+ /**
+ *
+ */
+ public void setTableLayout(String tableLayout) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TABLE_LAYOUT), tableLayout);
+ }
+
+ /**
+ *
+ */
+ public void setTextAlign(String textAlign) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_ALIGN), textAlign);
+ }
+
+ /**
+ *
+ */
+ public void setTextDecoration(String textDecoration) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_DECORATION), textDecoration);
+ }
+
+ /**
+ *
+ */
+ public void setTextIndent(String textIndent) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_INDENT), textIndent);
+ }
+
+ /**
+ *
+ */
+ public void setTextShadow(String textShadow) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_SHADOW), textShadow);
+ }
+
+ /**
+ *
+ */
+ public void setTextTransform(String textTransform) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TEXT_TRANSFORM), textTransform);
+ }
+
+ /**
+ *
+ */
+ public void setTop(String top) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_TOP), top);
+ }
+
+ /**
+ *
+ */
+ public void setUnicodeBidi(String unicodeBidi) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_UNICODE_BIDI), unicodeBidi);
+ }
+
+ /**
+ *
+ */
+ public void setVerticalAlign(String verticalAlign) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_VERTICAL_ALIGN), verticalAlign);
+ }
+
+ /**
+ *
+ */
+ public void setVisibility(String visibility) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_VISIBILITY), visibility);
+ }
+
+ /**
+ *
+ */
+ public void setVoiceFamily(String voiceFamily) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_VOICE_FAMILY), voiceFamily);
+ }
+
+ /**
+ *
+ */
+ public void setVolume(String volume) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_VOLUME), volume);
+ }
+
+ /**
+ *
+ */
+ public void setWhiteSpace(String whiteSpace) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_WHITE_SPACE), whiteSpace);
+ }
+
+ /**
+ *
+ */
+ public void setWidows(String widows) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_WIDOWS), widows);
+ }
+
+ /**
+ *
+ */
+ public void setWidth(String width) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_WIDTH), width);
+ }
+
+ /**
+ *
+ */
+ public void setWordSpacing(String wordSpacing) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_WORD_SPACING), wordSpacing);
+ }
+
+ /**
+ *
+ */
+ public void setZIndex(String zIndex) throws org.w3c.dom.DOMException {
+ set(PropCMProperty.getInstanceOf(PropCMProperty.P_Z_INDEX), zIndex);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipBottomSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipBottomSubStyleAdapter.java
new file mode 100644
index 0000000..930dae1
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipBottomSubStyleAdapter.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+
+/**
+ * For bottom value of 'clip' property's rect() function
+ */
+public class ClipBottomSubStyleAdapter extends ClipSubStyleAdapter {
+
+ /**
+ *
+ */
+ public ClipBottomSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ String get(org.w3c.dom.css.Rect rect) {
+ return rect.getBottom().getCssText();
+ }
+
+ /**
+ *
+ */
+ int index() {
+ return 2;
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String top = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP));
+ String right = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT));
+ String left = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT));
+
+ set(properties, top, right, value, left, value == null || value.length() == 0);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipLeftSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipLeftSubStyleAdapter.java
new file mode 100644
index 0000000..982b994
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipLeftSubStyleAdapter.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+
+/**
+ * For left value of 'clip' property's rect() function
+ */
+public class ClipLeftSubStyleAdapter extends ClipSubStyleAdapter {
+
+ /**
+ *
+ */
+ public ClipLeftSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ String get(org.w3c.dom.css.Rect rect) {
+ return rect.getLeft().getCssText();
+ }
+
+ /**
+ *
+ */
+ int index() {
+ return 3;
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String top = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP));
+ String right = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT));
+ String bottom = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM));
+
+ set(properties, top, right, bottom, value, value == null || value.length() == 0);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipRightSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipRightSubStyleAdapter.java
new file mode 100644
index 0000000..cfd1e23
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipRightSubStyleAdapter.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+
+/**
+ * For right value of 'clip' property's rect() function
+ */
+public class ClipRightSubStyleAdapter extends ClipSubStyleAdapter {
+
+ /**
+ *
+ */
+ public ClipRightSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ String get(org.w3c.dom.css.Rect rect) {
+ return rect.getRight().getCssText();
+ }
+
+ /**
+ *
+ */
+ int index() {
+ return 1;
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String top = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_TOP));
+ String bottom = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM));
+ String left = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT));
+
+ set(properties, top, value, bottom, left, value == null || value.length() == 0);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipSubStyleAdapter.java
new file mode 100644
index 0000000..92e96bd
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipSubStyleAdapter.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.IValID;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSValue;
+import org.w3c.dom.css.Rect;
+
+
+/**
+ * Abstract class for clip sub-properties
+ */
+abstract public class ClipSubStyleAdapter implements ISubPropertyAdapter {
+
+ /**
+ *
+ */
+ public ClipSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public String get(ICSS2Properties properties) {
+ String str = null;
+ Object obj = properties.get(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP));
+ if (obj != null) {
+ if (obj instanceof org.w3c.dom.css.Rect) {
+ str = get((org.w3c.dom.css.Rect) obj);
+ }
+ else {
+ if (obj instanceof ICSSValue) {
+ str = ((ICSSValue) obj).getCSSValueText();
+ }
+ else {
+ str = obj.toString();
+ }
+ str = str.trim().toLowerCase();
+ int pos = str.indexOf("rect(");//$NON-NLS-1$
+ if (pos >= 0) {
+ String subStr = null;
+ pos += 5;
+ int i = 0;
+ do {
+ int posEnd = str.indexOf(",", pos);//$NON-NLS-1$
+ if (posEnd < 0)
+ posEnd = str.indexOf(")", pos);//$NON-NLS-1$
+ if (posEnd < 0 && pos < str.length())
+ posEnd = str.length();
+ if (posEnd >= pos) {
+ subStr = str.substring(pos, posEnd);
+ pos = posEnd + 1;
+ }
+ else
+ pos = -1;
+ }
+ while (i++ < index() && pos > 0);
+
+ if (pos > 0)
+ str = subStr.trim();
+ else
+ str = null;
+ }
+ else
+ str = null;
+ }
+ }
+ return (str != null) ? str : "";//$NON-NLS-1$
+ }
+
+ /**
+ *
+ */
+ abstract String get(Rect rect);
+
+ /**
+ *
+ */
+ abstract int index();
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ }
+
+ /**
+ * Insert the method's description here. Creation date: (2001/10/04
+ * 19:25:46)
+ *
+ * @param properties
+ * org.eclipse.wst.css.core.util.declaration.ICSS2Properties
+ * @param top
+ * java.lang.String
+ * @param right
+ * java.lang.String
+ * @param bottom
+ * java.lang.String
+ * @param left
+ * java.lang.String
+ * @param removeCheck
+ * boolean
+ */
+ void set(ICSS2Properties properties, String top, String right, String bottom, String left, boolean removeCheck) {
+ if (top == null || top.length() == 0)
+ top = IValID.V_AUTO;
+ if (right == null || right.length() == 0)
+ right = IValID.V_AUTO;
+ if (bottom == null || bottom.length() == 0)
+ bottom = IValID.V_AUTO;
+ if (left == null || left.length() == 0)
+ left = IValID.V_AUTO;
+
+ if (removeCheck && top.trim().equalsIgnoreCase(IValID.V_AUTO) && right.trim().equalsIgnoreCase(IValID.V_AUTO) && bottom.trim().equalsIgnoreCase(IValID.V_AUTO) && left.trim().equalsIgnoreCase(IValID.V_AUTO)) {
+ properties.set(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP), null);
+ }
+ else
+ properties.set(PropCMProperty.getInstanceOf(PropCMProperty.P_CLIP), "rect(" + top + ", " + right + ", " + bottom + ", " + left + ")");//$NON-NLS-5$//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipTopSubStyleAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipTopSubStyleAdapter.java
new file mode 100644
index 0000000..915c107
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ClipTopSubStyleAdapter.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMSubProperty;
+
+/**
+ * For top value of 'clip' property's rect() function
+ */
+public class ClipTopSubStyleAdapter extends ClipSubStyleAdapter {
+
+ /**
+ *
+ */
+ public ClipTopSubStyleAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ String get(org.w3c.dom.css.Rect rect) {
+ return rect.getTop().getCssText();
+ }
+
+ /**
+ *
+ */
+ int index() {
+ return 0;
+ }
+
+ /**
+ *
+ */
+ public void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException {
+ String right = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_RIGHT));
+ String bottom = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_BOTTOM));
+ String left = properties.get(PropCMSubProperty.getInstanceOf(PropCMSubProperty.PSUB_CLIP_LEFT));
+
+ set(properties, value, right, bottom, left, value == null || value.length() == 0);
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/FontShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/FontShorthandAdapter.java
new file mode 100644
index 0000000..4e848e3
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/FontShorthandAdapter.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.IValID;
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'font' property 'font' will be expanded to 'font-family', 'font-size',
+ * 'font-style', 'font-variant', 'font-weight', 'line-height',
+ */
+public class FontShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public FontShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String style = null, variant = null, weight = null, size = null, height = null, family = null;
+ PropCMProperty propFont = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE);
+ PropCMProperty propVariant = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT);
+ PropCMProperty propWeight = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT);
+ PropCMProperty propSize = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE);
+ boolean bNormalSpecified = false;
+
+ int i = 0;
+ for (; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ // first of all, check font idents
+ if (i == 0) {
+ for (int j = 0; j < propFont.getNumChild(); j++) {
+ Object obj = propFont.getChildAt(i);
+ if (obj instanceof String && tokens[i].image.compareToIgnoreCase(obj.toString()) == 0)
+ return false;
+ }
+ }
+ // value "normal" is shared !!
+ if (tokens[i].image.equalsIgnoreCase(IValID.V_NORMAL)) {
+ bNormalSpecified = true;
+ }
+ else {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propVariant.canHave(tokens[i].image))
+ variant = tokens[i].image;
+ else if (propWeight.canHave(tokens[i].image))
+ weight = tokens[i].image;
+ else if (propSize.canHave(tokens[i].image)) {
+ size = tokens[i].image;
+ break; // if size found, break loop
+ }
+ }
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER && weight == null && propWeight.canHave(tokens[i].image)) {
+ weight = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) {
+ size = tokens[i].image;
+ break; // if size found, break loop
+ }
+ }
+
+ if (bNormalSpecified) {
+ if (style == null)
+ style = IValID.V_NORMAL;
+ if (variant == null)
+ variant = IValID.V_NORMAL;
+ if (weight == null)
+ weight = IValID.V_NORMAL;
+ }
+
+ // skip whitespace
+ for (i++; i < tokens.length; i++) {
+ if (tokens[i].kind != CSSRegionContexts.CSS_S || tokens[i].kind != CSSRegionContexts.CSS_DECLARATION_VALUE_S)
+ break;
+ }
+
+ // line-height ?
+ if (i < tokens.length && tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && tokens[i].image.equals("/")) { //$NON-NLS-1$
+ for (i++; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ height = tokens[i++].image;
+ break;
+ }
+ }
+ }
+
+ // font-family
+ StringBuffer buf = new StringBuffer();
+ for (; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT)
+ buf.append(" ");//$NON-NLS-1$
+ else
+ buf.append(tokens[i].image);
+ }
+ family = buf.toString().trim();
+
+ dest.set(PropCMProperty.P_FONT_STYLE, style);
+ dest.set(PropCMProperty.P_FONT_VARIANT, variant);
+ dest.set(PropCMProperty.P_FONT_WEIGHT, weight);
+ dest.set(PropCMProperty.P_FONT_SIZE, size);
+ dest.set(PropCMProperty.P_LINE_HEIGHT, height);
+ dest.set(PropCMProperty.P_FONT_FAMILY, family);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String style = null, variant = null, weight = null, size = null, height = null, family = null;
+ PropCMProperty propFont = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT);
+ PropCMProperty propStyle = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_STYLE);
+ PropCMProperty propVariant = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_VARIANT);
+ PropCMProperty propWeight = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_WEIGHT);
+ PropCMProperty propSize = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_SIZE);
+ PropCMProperty propHeight = PropCMProperty.getInstanceOf(PropCMProperty.P_LINE_HEIGHT);
+ PropCMProperty propFamily = PropCMProperty.getInstanceOf(PropCMProperty.P_FONT_FAMILY);
+ boolean bNormalSpecified = false;
+
+ int i = 0;
+ for (; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ // first of all, check font idents
+ if (i == 0) {
+ for (int j = 0; j < propFont.getNumChild(); j++) {
+ Object obj = propFont.getChildAt(i);
+ if (obj instanceof String && tokens[i].image.compareToIgnoreCase(obj.toString()) == 0)
+ return null;
+ }
+ }
+ // value "normal" is shared !!
+ if (tokens[i].image.equalsIgnoreCase(IValID.V_NORMAL)) {
+ bNormalSpecified = true;
+ }
+ else {
+ if (propStyle.canHave(tokens[i].image))
+ style = tokens[i].image;
+ else if (propVariant.canHave(tokens[i].image))
+ variant = tokens[i].image;
+ else if (propWeight.canHave(tokens[i].image))
+ weight = tokens[i].image;
+ else if (propSize.canHave(tokens[i].image)) {
+ size = tokens[i].image;
+ break; // if size found, break loop
+ }
+ }
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER && weight == null && propWeight.canHave(tokens[i].image)) {
+ weight = tokens[i].image;
+ }
+ else if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE) {
+ size = tokens[i].image;
+ break; // if size found, break loop
+ }
+ }
+
+ if (bNormalSpecified) {
+ if (style == null)
+ style = IValID.V_NORMAL;
+ if (variant == null)
+ variant = IValID.V_NORMAL;
+ if (weight == null)
+ weight = IValID.V_NORMAL;
+ }
+
+ // skip whitespace
+ for (i++; i < tokens.length; i++) {
+ if (tokens[i].kind != CSSRegionContexts.CSS_S || tokens[i].kind != CSSRegionContexts.CSS_DECLARATION_VALUE_S)
+ break;
+ }
+
+ // line-height ?
+ if (i < tokens.length && tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_OPERATOR && tokens[i].image.equals("/")) { //$NON-NLS-1$
+ for (i++; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ height = tokens[i++].image;
+ break;
+ }
+ }
+ }
+
+ // font-family
+ StringBuffer buf = new StringBuffer();
+ for (; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_COMMENT)
+ buf.append(" ");//$NON-NLS-1$
+ else
+ buf.append(tokens[i].image);
+ }
+ family = buf.toString().trim();
+
+ if (propStyle == propDest)
+ return style;
+ else if (propVariant == propDest)
+ return variant;
+ else if (propWeight == propDest)
+ return weight;
+ else if (propSize == propDest)
+ return size;
+ else if (propHeight == propDest)
+ return height;
+ else if (propFamily == propDest)
+ return family;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ICSS2Properties.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ICSS2Properties.java
new file mode 100644
index 0000000..0bf6432
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ICSS2Properties.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.w3c.dom.css.CSS2Properties;
+
+
+/**
+ *
+ */
+public interface ICSS2Properties extends CSS2Properties {
+
+ /**
+ *
+ */
+ void applyFull(ICSSStyleDeclaration decl);
+
+ /**
+ *
+ */
+ void applyModified(ICSSStyleDeclaration decl);
+
+ /**
+ *
+ */
+ String get(PropCMProperty prop);
+
+ /**
+ *
+ */
+ String getBackgroundPositionX();
+
+ /**
+ *
+ */
+ String getBackgroundPositionY();
+
+ /**
+ *
+ */
+ String getClipBottom();
+
+ /**
+ *
+ */
+ String getClipLeft();
+
+ /**
+ *
+ */
+ String getClipRight();
+
+ /**
+ *
+ */
+ String getClipTop();
+
+ /**
+ *
+ */
+ boolean isModified();
+
+ /**
+ *
+ */
+ Enumeration properties();
+
+ /**
+ *
+ */
+ Iterator propertiesModified();
+
+ /**
+ *
+ */
+ void resetModified();
+
+ /**
+ *
+ */
+ void set(PropCMProperty prop, String value) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setBackgroundPositionX(String backgroundPosition) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setBackgroundPositionY(String backgroundPosition) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setClipBottom(String backgroundPosition) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setClipLeft(String backgroundPosition) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setClipRight(String backgroundPosition) throws org.w3c.dom.DOMException;
+
+ /**
+ *
+ */
+ void setClipTop(String backgroundPosition) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/IShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/IShorthandAdapter.java
new file mode 100644
index 0000000..a1d405c
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/IShorthandAdapter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+
+/**
+ *
+ */
+public interface IShorthandAdapter {
+
+ /**
+ *
+ */
+ boolean expand(String source, CSSPropertyContext dest);
+
+ /**
+ *
+ */
+ String extract(String source, PropCMProperty propDest);
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ISubPropertyAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ISubPropertyAdapter.java
new file mode 100644
index 0000000..e169f0d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ISubPropertyAdapter.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+/**
+ *
+ */
+public interface ISubPropertyAdapter {
+
+ /**
+ *
+ */
+ String get(ICSS2Properties properties);
+
+ /**
+ *
+ */
+ void set(ICSS2Properties properties, String value) throws org.w3c.dom.DOMException;
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ListStyleShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ListStyleShorthandAdapter.java
new file mode 100644
index 0000000..9713274
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ListStyleShorthandAdapter.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'list-style' property 'list-style' will be expanded to
+ * 'list-style-image', 'list-style-position', 'list-style-type',
+ */
+public class ListStyleShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public ListStyleShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String image = "", pos = "", type = "";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ PropCMProperty propPos = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION);
+ PropCMProperty propType = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE);
+ PropCMProperty propImage = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propPos.canHave(tokens[i].image))
+ pos = tokens[i].image;
+ else { // value="none" is shared !!
+ if (propType.canHave(tokens[i].image))
+ type = tokens[i].image;
+ if (propImage.canHave(tokens[i].image))
+ image = tokens[i].image;
+ }
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ image = tokens[i].image;
+ }
+ }
+
+ dest.set(propPos.getName(), pos);
+ dest.set(propType.getName(), type);
+ dest.set(propImage.getName(), image);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String image = null, pos = null, type = null;
+ PropCMProperty propPos = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_POSITION);
+ PropCMProperty propType = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_TYPE);
+ PropCMProperty propImage = PropCMProperty.getInstanceOf(PropCMProperty.P_LIST_STYLE_IMAGE);
+
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT) {
+ if (propPos.canHave(tokens[i].image))
+ pos = tokens[i].image;
+ else { // value="none" is shared !!
+ if (propType.canHave(tokens[i].image))
+ type = tokens[i].image;
+ if (propImage.canHave(tokens[i].image))
+ image = tokens[i].image;
+ }
+ }
+ else if (tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
+ image = tokens[i].image;
+ }
+ }
+
+ if (propPos == propDest)
+ return pos;
+ else if (propType == propDest)
+ return type;
+ else if (propImage == propDest)
+ return image;
+ else
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/MarginShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/MarginShorthandAdapter.java
new file mode 100644
index 0000000..d3cf1e7
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/MarginShorthandAdapter.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'margin' property 'margin' will be expanded to 'margin-top',
+ * 'margin-right', 'margin-bottom', 'margin-left',
+ */
+public class MarginShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public MarginShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ String[] dests = new String[4];
+ if (j == 0)
+ return true;
+ else if (j == 1) {
+ dests[0] = dests[1] = dests[2] = dests[3] = idents[0];
+ }
+ else if (j == 2) {
+ dests[0] = dests[2] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ }
+ else if (j == 3) {
+ dests[0] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ dests[2] = idents[2];
+ }
+ else {
+ for (int k = 0; k < 4; k++)
+ dests[k] = idents[k];
+ }
+ dest.set(PropCMProperty.P_MARGIN_TOP, dests[0]);
+ dest.set(PropCMProperty.P_MARGIN_RIGHT, dests[1]);
+ dest.set(PropCMProperty.P_MARGIN_BOTTOM, dests[2]);
+ dest.set(PropCMProperty.P_MARGIN_LEFT, dests[3]);
+
+ return true;
+
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_IDENT || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ if (j == 0)
+ return null;
+ else if (j == 1)
+ return idents[0];
+ else if (j == 2) {
+ if (propDest.getName() == PropCMProperty.P_MARGIN_TOP || propDest.getName() == PropCMProperty.P_MARGIN_BOTTOM)
+ return idents[0];
+ else
+ return idents[1];
+ }
+ else if (j == 3) {
+ if (propDest.getName() == PropCMProperty.P_MARGIN_TOP)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_MARGIN_BOTTOM)
+ return idents[2];
+ else
+ return idents[1];
+ }
+ else {
+ if (propDest.getName() == PropCMProperty.P_MARGIN_TOP)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_MARGIN_RIGHT)
+ return idents[1];
+ else if (propDest.getName() == PropCMProperty.P_MARGIN_BOTTOM)
+ return idents[2];
+ else if (propDest.getName() == PropCMProperty.P_MARGIN_LEFT)
+ return idents[3];
+ else
+ return null;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/PaddingShorthandAdapter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/PaddingShorthandAdapter.java
new file mode 100644
index 0000000..ce2436d
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/PaddingShorthandAdapter.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+import org.eclipse.wst.css.core.internal.contentmodel.PropCMProperty;
+import org.eclipse.wst.css.core.internal.parserz.CSSRegionContexts;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextParser;
+import org.eclipse.wst.css.core.internal.parserz.CSSTextToken;
+
+
+/**
+ * For 'padding' property 'padding' will be expanded to 'padding-top',
+ * 'padding-right', 'padding-bottom', 'padding-left',
+ */
+public class PaddingShorthandAdapter implements IShorthandAdapter {
+
+ /**
+ *
+ */
+ public PaddingShorthandAdapter() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public boolean expand(String source, CSSPropertyContext dest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return false;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ String[] dests = new String[4];
+ if (j == 0)
+ return true;
+ else if (j == 1) {
+ dests[0] = dests[1] = dests[2] = dests[3] = idents[0];
+ }
+ else if (j == 2) {
+ dests[0] = dests[2] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ }
+ else if (j == 3) {
+ dests[0] = idents[0];
+ dests[1] = dests[3] = idents[1];
+ dests[2] = idents[2];
+ }
+ else {
+ for (int k = 0; k < 4; k++)
+ dests[k] = idents[k];
+ }
+ dest.set(PropCMProperty.P_PADDING_TOP, dests[0]);
+ dest.set(PropCMProperty.P_PADDING_RIGHT, dests[1]);
+ dest.set(PropCMProperty.P_PADDING_BOTTOM, dests[2]);
+ dest.set(PropCMProperty.P_PADDING_LEFT, dests[3]);
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public String extract(String source, PropCMProperty propDest) {
+ CSSTextParser parser = new CSSTextParser(CSSTextParser.MODE_DECLARATION_VALUE, source);
+ CSSTextToken[] tokens = parser.getTokens();
+ if (tokens.length <= 0) {
+ return null;
+ }
+ String[] idents = new String[4];
+ int j = 0;
+ for (int i = 0; i < tokens.length; i++) {
+ if (org.eclipse.wst.css.core.internal.util.CSSUtil.isLength(tokens[i]) || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_NUMBER || tokens[i].kind == CSSRegionContexts.CSS_DECLARATION_VALUE_PERCENTAGE)
+ idents[j++] = tokens[i].image;
+ if (j == 4)
+ break;
+ }
+
+ if (j == 0)
+ return null;
+ else if (j == 1)
+ return idents[0];
+ else if (j == 2) {
+ if (propDest.getName() == PropCMProperty.P_PADDING_TOP || propDest.getName() == PropCMProperty.P_PADDING_BOTTOM)
+ return idents[0];
+ else
+ return idents[1];
+ }
+ else if (j == 3) {
+ if (propDest.getName() == PropCMProperty.P_PADDING_TOP)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_PADDING_BOTTOM)
+ return idents[2];
+ else
+ return idents[1];
+ }
+ else {
+ if (propDest.getName() == PropCMProperty.P_PADDING_TOP)
+ return idents[0];
+ else if (propDest.getName() == PropCMProperty.P_PADDING_RIGHT)
+ return idents[1];
+ else if (propDest.getName() == PropCMProperty.P_PADDING_BOTTOM)
+ return idents[2];
+ else if (propDest.getName() == PropCMProperty.P_PADDING_LEFT)
+ return idents[3];
+ else
+ return null;
+ }
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ValueData.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ValueData.java
new file mode 100644
index 0000000..c5282f8
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/util/declaration/ValueData.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.internal.util.declaration;
+
+
+
+/**
+ *
+ */
+public class ValueData {
+
+ public String value;
+ public boolean important = false;
+
+ /**
+ *
+ */
+ public ValueData() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public ValueData(String val, boolean imp) {
+ super();
+ value = val;
+ important = imp;
+ }
+
+ /**
+ *
+ */
+ public String toString() {
+ return value;
+ }
+}
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/text/ICSSPartitions.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/text/ICSSPartitions.java
new file mode 100644
index 0000000..ea73d73
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/text/ICSSPartitions.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.css.core.text;
+
+
+/**
+ * This interface is not intended to be implemented. It defines the
+ * partitioning for CSS and all its partitions. Clients should reference the
+ * partition type Strings defined here directly.
+ *
+ * @since 1.1
+ */
+public interface ICSSPartitions {
+
+ String STYLE = "org.eclipse.wst.css.STYLE"; //$NON-NLS-1$
+ String COMMENT = "org.eclipse.wst.css.COMMENT"; //$NON-NLS-1$
+}