# HG changeset patch # User Eugene Ostroukhov # Date 1262901966 28800 # Node ID 1a02e8a8be9c1e1f1310240a1c5a4460ce3bcdad # Parent 03c1ce55e5efcfa01bb74c2d14ff5fddaef0b16d# Parent d3477de62514e96826c0ae51a6a45851e5e07a87 Branches merged diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/.classpath --- a/org.symbian.tools.wrttools/.classpath Thu Jan 07 14:00:45 2010 -0800 +++ b/org.symbian.tools.wrttools/.classpath Thu Jan 07 14:06:06 2010 -0800 @@ -3,5 +3,8 @@ + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools/.settings/org.eclipse.jdt.core.prefs Thu Jan 07 14:00:45 2010 -0800 +++ b/org.symbian.tools.wrttools/.settings/org.eclipse.jdt.core.prefs Thu Jan 07 14:06:06 2010 -0800 @@ -1,4 +1,4 @@ -#Mon Dec 21 14:49:08 PST 2009 +#Thu Jan 07 13:06:13 PST 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/Copy of .classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/Copy of .classpath Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,7 @@ + + + + + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/Copy of .project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/Copy of .project Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,28 @@ + + + org.symbian.tools.wrttools + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/Copy of build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/Copy of build.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/Copy of plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/Copy of plugin.xml Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creates a new widget based on existing project workspaces. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Thu Jan 07 14:00:45 2010 -0800 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Thu Jan 07 14:06:06 2010 -0800 @@ -9,10 +9,26 @@ org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.emf.common, - org.eclipse.emf.ecore + org.eclipse.emf.ecore, + org.eclipse.core.databinding;bundle-version="1.2.0", + org.eclipse.core.databinding.beans;bundle-version="1.2.0", + org.eclipse.core.databinding.property;bundle-version="1.2.0", + org.eclipse.jface.databinding;bundle-version="1.3.0", + org.eclipse.wst.jsdt.ui;bundle-version="1.0.200", + org.eclipse.wst.jsdt.core;bundle-version="1.0.200", + org.eclipse.wst.css.core;bundle-version="1.1.300", + org.eclipse.ui.ide;bundle-version="3.5.0", + org.eclipse.wst.validation;bundle-version="1.2.102" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy -Import-Package: org.chromium.debug.core, +Import-Package: org.apache.velocity;version="1.5.0", + org.apache.velocity.app;version="1.5.0", + org.apache.velocity.context;version="1.5.0", + org.apache.velocity.convert;version="1.5.0", + org.apache.velocity.io;version="1.5.0", + org.apache.velocity.runtime;version="1.5.0", + org.apache.velocity.util;version="1.5.0", + org.chromium.debug.core, org.chromium.debug.core.model, org.chromium.debug.core.util, org.chromium.sdk, @@ -33,3 +49,5 @@ org.eclipse.ui.internal.ide, org.eclipse.ui.internal.ide.dialogs, org.eclipse.ui.wizards.newresource +Bundle-ClassPath: lib/tagsoup-1.2.jar, + . diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/Activator.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/Activator.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/core/ProjectTemplate.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/core/ProjectTemplate.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/core/internal/validation/CssBuildValidator.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/projects/ProjectUtils.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/projects/ProjectUtils.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/Helper.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/Helper.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/Unzip.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/Unzip.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage$NonEmptyStringValidator.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage$NonEmptyStringValidator.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$1.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$10.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$10.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$11.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$11.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$12.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$12.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$13.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$13.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$14.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$14.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$15.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$15.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$16.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$16.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$17.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$17.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$2.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$3.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$3.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$4.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$4.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$5.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$5.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$6.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$6.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$7.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$7.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$8.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$8.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$9.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$9.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$ProjectLabelProvider.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$ProjectLabelProvider.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$ProjectRecord.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$ProjectRecord.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage$Factory.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage$Factory.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/IWizardPageFactory.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/IWizardPageFactory.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage$Factory.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage$Factory.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectDetailsWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectDetailsWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectFilesWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectFilesWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$1.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$2.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$3.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$3.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$ProjectTemplateLabelProvider.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$ProjectTemplateLabelProvider.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard$1.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard$2.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectWizard.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WizardContext.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WizardContext.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard$1.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard$2.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/.cvsignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/.cvsignore Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,2 @@ +observer-response.xsd +properties.zip diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareExplicitWeight.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareExplicitWeight.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareOrderSpecified.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareOrderSpecified.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareSpecificity.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CompareSpecificity.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CssCascadingOrder.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CssCascadingOrder.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CssParser.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CssParser.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CssRuleList.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CssRuleList.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/CssStyleRule.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/CssStyleRule.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/DocumentParser.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/DocumentParser.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/Makefile Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,39 @@ +SRCS = CssCascadingOrder.java StyleSheetCom.java \ +CssParser.java StyleSheetGenerator.java \ +StyleSheetParser.java StyleSheet.java\ +HTMLStyleSheetParser.java StyleSheetXMLParser.java \ + + +OBJS = $(SRCS:.java=.class) + +PACKAGE = org.w3c.css.css +JAVAC = jc -val +JAVADOC = javadoc +JAVADOCFLAGS = -version -d docs -protected +JAVACFLAGS = +MAKEDEPEND = jmakedepend + +.SUFFIXES: .class .java +.java.class:; $(JAVAC) $(JAVACFLAGS) $< + +all: $(OBJS) html.properties.ja html.properties.zh-cn + +javadoc:; $(JAVADOC) $(JAVADOCFLAGS) $(PACKAGE) + +clean:; -rm -f $(OBJS) *~ core + +depend:; $(MAKEDEPEND) $(SRCS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. +StyleSheetParser.class:: StyleSheetParser.java +StyleSheetCom.class:: StyleSheetCom.java +StyleSheetGenerator.class:: StyleSheetGenerator.java +CssParser.class:: CssParser.java +CssCascadingOrder.class:: CssCascadingOrder.java +HTMLStyleSheetParser.class:: HTMLStyleSheetParser.java +StyleSheet.class:: StyleSheet.java + +html.properties.ja: html.properties.ja.EUCJIS + native2ascii -encoding EUCJIS html.properties.ja.EUCJIS html.properties.ja +html.properties.zh-cn: html.properties.zh-cn.GB + native2ascii -encoding euc-cn html.properties.zh-cn.GB html.properties.zh-cn diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleReport.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleReport.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheet.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheet.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheetOrigin.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheetOrigin.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheetParser.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/StyleSheetParser.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/TagSoupStyleSheetHandler.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/TagSoupStyleSheetHandler.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/XMLStyleSheetHandler.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/css/XMLStyleSheetHandler.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/format.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/format.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,9 @@ +# Available output format for the StyleSheetGeneratorHTML & StyleSheetGenerator(text) + +xhtml: xhtml.properties +xml: xml.properties +text: text.properties +soap12: soap12.properties +json: json.properties +ucn: ucn.properties +gnu: gnu.properties diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/gnu.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/gnu.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,13 @@ +#foreach ( $error_content in $errors_content ) +#set ( $err = $error_content.get("Error") ) +#set ( $error_msg = $error_content.get("ErrorMsg") ) +#set ( $context_name = $error_content.get("CtxName") ) +#set ( $context_msg = $error_content.get("CtxMsg") ) +#set ( $class_name = $error_content.get("ClassName") ) +$err.SourceFile:$err.Line:$context_msg:$error_msg +#end +#foreach ( $warning in $warnings_list ) +#if ( $warning.Level <= $warning_level ) +$warning.SourceFile:$warning.Line: #if ( $warning.Context ) $warning.Context - #end :$warning.WarningMessage +#end +#end diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/json.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/json.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,13 @@ +{ + "cssvalidation" : { + "uri" : "$file_title", + "checkedby" : "http://www.w3.org/2005/07/css-validator", + "csslevel" : "$cssversion", + "date" : "$currentdate", + "validity" : $is_valid, + "result" : { + "errorcount" : $errors_count, + "warningcount" : $warnings_count + } + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/soap12.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/soap12.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,117 @@ + + + + + $file_title + http://jigsaw.w3.org/css-validator/ + $cssversion + $currentdate + $is_valid + + + $errors_count +#set ( $sf = "" ) +#if ( $errors_count > 0 ) + #foreach ( $error_content in $errors_content ) + #set ( $err = $error_content.get("Error") ) + #set ( $error_msg = $error_content.get("ErrorMsg") ) + #set ( $class_name = $error_content.get("ClassName") ) + #set ( $context_msg = $error_content.get("CtxMsg") ) + #if ( $error_content.get("link_value_parse_error") ) + #set ( $before_link = $error_content.get("link_before_parse_error") ) + #set ( $link_value = $error_content.get("link_value_parse_error") ) + #else + #set ( $link_value = false ) + #end + #if ( $error_content.get("span_value_parse_error") ) + #set ( $span_value = $error_content.get("span_value_parse_error") ) + #else + #set ( $span_value = false ) + #end + #if ( $sf != $err.SourceFile ) + #if ( $open ) + + + #end + #set ( $sf = $err.SourceFileEscaped ) + + + $sf + #set ( $open = true ) + #end + + + $err.Line + $class_name + #if ( $context_msg ) $context_msg #end + #if ( $span_value ) + #set ( $span_class = $error_content.get("span_class_parse_error") ) + + + $span_class + + + $span_value + + #end + + + #if ( $link_value ) + #set ( $link_name = $error_content.get("link_name_parse_error") ) + + $before_link : $link_name ($link_value) + #end + + $error_msg + + + #end + #if ( $open ) + + + #end +#end + + + + $warnings_count +#if ( $warnings_count > 0 ) + #set ( $sf = "" ) + #set ( $open = false ) + #foreach ( $warning in $warnings_list ) + #if ( $sf != $warning.SourceFile ) + #if ( $open ) + + + #end + #set ( $sf = $warning.SourceFileEscaped ) + + + $sf + #set ( $open = true ) + #end + #if ( $warning.Level <= $warning_level ) + + + $warning.Line + $warning.Level + $warning.WarningMessageEscaped +#if ( $warning.Context ) + $warning.Context.Escaped +#end + + #end + #end + #if ( $open ) + + + #end +#end + + + + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/text.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/text.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,135 @@ +$W3C_validator_results $file_title + +#if ( !$no_errors_report ) + #if ($errors_count == 0) +$congrats + +$doc_validates_before_link $css $doc_validates_after_link + #if ( !$file_title.trim().startsWith("file://localhost") ) + +$no_errors_interoperable_msg + +

+ + $valid_CSS + +

+($no_errors_close_tags_msg) +$no_errors_dl_local_msg +$no_errors_create_link_msg + http://jigsaw.w3.org/css-validator/validator$link +or http://jigsaw.w3.org/css-validator/check/referer ($no_errors_forHTML_only_msg) +($no_errors_bookmark_msg) + #end + #else + #if ( $hook_html_validator ) + +$hook_html_validator + #end + #set ( $sf = "" ) + #set ( $open = false ) + +$errors_sorry_msg ($errors_count) + #if ( $request ) + +$request + #end + +#foreach ( $error_content in $errors_content ) +#set ( $err = $error_content.get("Error") ) +#set ( $error_msg = $error_content.get("ErrorMsg") ) +#set ( $context_name = $error_content.get("CtxName") ) +#set ( $context_msg = $error_content.get("CtxMsg") ) +#set ( $class_name = $error_content.get("ClassName") ) +#if ( $error_content.get("link_value_parse_error") ) + #set ( $before_link = $error_content.get("link_before_parse_error") ) + #set ( $link_value = $error_content.get("link_value_parse_error") ) +#else + #set ( $link_value = false ) +#end +#if ( !$link_value && $error_content.get("span_value_parse_error") ) + #set ( $span_value = $error_content.get("span_value_parse_error") ) +#else + #set ( $span_value = false ) +#end +#if ( $sf != $err.SourceFile ) + #set ( $sf = $err.SourceFile ) + +URI : $sf + +#set ( $open = true ) +#end +Line : $err.Line $context_msg +#if ( $link_value ) +#set ( $link_name = $error_content.get("link_name_parse_error") ) + ($before_link : $link_name ($link_value)) +#end + $error_msg +#if ( $span_value ) +#set ( $span_class = $error_content.get("span_class_parse_error") ) + $span_value +#end +#end + +#end +#end +#if ($warnings_count > 0) + +$warnings ($warnings_count) +#set ( $sf = "" ) +#set ( $open = false ) +#foreach ( $warning in $warnings_list ) +#if ( $sf != $warning.SourceFile ) +#set ( $sf = $warning.SourceFile ) + +URI : $sf + +#set ( $open = true ) +#end +#if ( $warning.Level <= $warning_level ) +Line : $warning.Line - #if ( $warning.Context ) $warning.Context - #end $warning.WarningMessage +#end +#end + +#end + +#if ( $rules_count > 0 ) + +$valid_CSS_info + #if ($style_charset) + +@charset "$style_charset"; + #end + + #foreach ( $rules in $at_rules_list ) +#if ( $rules.AtRule != "" ) + +$rules.AtRule +#if ( !$rules.Empty ) +{ + #end + #end + #foreach ( $rule in $rules.StyleRules ) + #if ( $rule.Selectors ) + $rule.Selectors + { + #end +#foreach ( $property in $rule.Properties ) + $property.PropertyName : $property; +#end + #if ( $rule.Selectors ) + } + #end + #end + #if ( $rules.AtRule != "" ) +#if ( !$rules.Empty ) + +} + #end + #end + #end +#else +$CSS_not_found +#end diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/ucn.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/ucn.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,154 @@ + + + $file_title + http://jigsaw.w3.org/css-validator/ + $cssversion + $currentdate + $is_valid + + + $errors_count +#if ( $errors_count > 0 ) + #set ( $sf = "" ) + #set ( $open = false ) + #foreach ( $error_content in $errors_content ) + #set ( $err = $error_content.get("Error") ) + #if ( $sf != $err.SourceFile ) + #if ( $open ) + + #end + #set ( $sf = $err.SourceFileEscaped ) + + #set ( $open = true ) + #if ( $fake_input ) + $file_title + #else + $sf + #end + #end + + #set ( $error_msg = $error_content.get("ErrorMsg") ) + #set ( $context_name = $error_content.get("CtxName") ) + #set ( $context_msg = $error_content.get("CtxMsg") ) + #set ( $class_name = $error_content.get("ClassName") ) + #if ( $error_content.get("link_value_parse_error") ) + #set ( $before_link = $error_content.get("link_before_parse_error") ) + #set ( $link_value = $error_content.get("link_value_parse_error") ) + #else + #set ( $link_value = false ) + #end + #if ( $error_content.get("span_value_parse_error") ) + #set ( $span_value = $error_content.get("span_value_parse_error") ) + #else + #set ( $span_value = false ) + #end + + + $err.Line + #if ( $context_msg ) $context_msg #end + $class_name + + #if ( $link_value ) + #set ( $link_name = $error_content.get("link_name_parse_error") ) + $before_link : $link_name ($link_value) + #end + $error_msg + #if ( $span_value ) + #set ( $span_class = $error_content.get("span_class_parse_error") ) + $span_value + #end + + + + #end + #if ( $open ) + + #end +#end + + + + + + $warnings_count +#if ( $warnings_count > 0 ) + #set ( $sf = "" ) + #set ( $open = false ) + #foreach ( $warning in $warnings_list ) + #if ( $sf != $warning.SourceFile ) + #if ( $open ) + + #end + #set ( $sf = $warning.SourceFileEscaped ) + + #set ( $open = true ) + #if ( $fake_input ) + $file_title + #else + $sf + #end + + #end + #if ( $warning.Level <= $warning_level ) + + #if ( $warning.Level ) + $warning.Level + #end + $warning.Line + #if ( $warning.Context ) $warning.Context.Escaped #end + $warning.WarningMessageEscaped + + #end + #end + #if ( $open ) + + #end +#end + + + + +#if ( $errors_count == 0 ) + + 1 + + $file_title + + $doc_validates_before_link $css $doc_validates_after_link + + $no_errors_interoperable_msg + + + $valid_CSS + <p> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" + src="http://jigsaw.w3.org/css-validator/images/vcss" + alt="$valid_CSS" /> + </a> +</p> + + + $valid_CSS + <p> + <a href="http://jigsaw.w3.org/css-validator/check/referer"> + <img style="border:0;width:88px;height:31px" + src="http://jigsaw.w3.org/css-validator/images/vcss-blue" + alt="$valid_CSS" /> + </a> +</p> + + + ($no_errors_close_tags_msg) + + + $no_errors_dl_local_msg + + + + +#end + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/urls.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/urls.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,120 @@ +@url-base_css1 : http://www.w3.org/TR/REC-CSS1/ +@url-base_css2 : http://www.w3.org/TR/REC-CSS2/ +@url-base_css21 : http://www.w3.org/TR/CSS21/ +@url-base_css3 : http://www.w3.org/Style/CSS/current-work.html +azimuth : aural.html#propdef-azimuth +background : colors.html#propdef-background +background-attachment : colors.html#propdef-background-attachment +background-color : colors.html#propdef-background-color +background-image : colors.html#propdef-background-image +background-position : colors.html#propdef-background-position +background-repeat : colors.html#propdef-background-repeat +border : box.html#propdef-border +border-bottom : box.html#propdef-border-bottom +border-bottom-color : box.html#propdef-border-bottom-color +border-bottom-style : box.html#propdef-border-bottom-style +border-bottom-width : box.html#propdef-border-bottom-width +border-color : box.html#propdef-border-color +border-left : box.html#propdef-border-left +border-left-color : box.html#propdef-border-left-color +border-left-style : box.html#propdef-border-left-style +border-left-width : box.html#propdef-border-left-width +border-right : box.html#propdef-border-right +border-right-color : box.html#propdef-border-right-color +border-right-style : box.html#propdef-border-right-style +border-right-width : box.html#propdef-border-right-width +border-spacing : tables.html#propdef-border-spacing +border-style : box.html#propdef-border-style +border-top : box.html#propdef-border-top +border-top-color : box.html#propdef-border-top-color +border-top-style : box.html#propdef-border-top-style +border-top-width : box.html#propdef-border-top-width +border-width : box.html#propdef-border-width +bottom : visuren.html#propdef-bottom +caption-side : tables.html#propdef-caption-side +clear : visuren.html#propdef-clear +clip : visufx.html#propdef-clip +color : colors.html#propdef-color +column-span : tables.html#propdef-column-span +content : generate.html#propdef-content +counter-increment : generate.html#propdef-counter-increment +counter-reset : generate.html#propdef-counter-reset +cue : aural.html#propdef-cue +cue-after : aural.html#propdef-cue-after +cue-before : aural.html#propdef-cue-before +cursor : ui.html#propdef-cursor +direction : visuren.html#propdef-direction +display : visuren.html#propdef-display +elevation : aural.html#propdef-elevation +float : visuren.html#propdef-float +font : fonts.html#propdef-font +font-family : fonts.html#propdef-font-family +font-size : fonts.html#propdef-font-size +font-size-adjust : fonts.html#propdef-font-size-adjust +font-style : fonts.html#propdef-font-style +font-variant : fonts.html#propdef-font-variant +font-weight : fonts.html#propdef-font-weight +height : visudet.html#propdef-height +left : visuren.html#propdef-left +letter-spacing : text.html#propdef-letter-spacing +line-height : visudet.html#propdef-line-height +list-style : generate.html#propdef-list-style +list-style-image : generate.html#propdef-list-style-image +list-style-position : generate.html#propdef-list-style-position +list-style-type : generate.html#propdef-list-style-type +margin : box.html#propdef-margin +margin-bottom : box.html#propdef-margin-bottom +margin-left : box.html#propdef-margin-left +margin-right : box.html#propdef-margin-right +margin-top : box.html#propdef-margin-top +marks : page.html#propdef-marks +max-height : visudet.html#propdef-max-height +max-width : visudet.html#propdef-max-width +min-height : visudet.html#propdef-min-height +min-width : visudet.html#propdef-min-width +orphans : page.html#propdef-orphans +overflow : visufx.html#propdef-overflow +padding : box.html#propdef-padding +padding-bottom : box.html#propdef-padding-bottom +padding-left : box.html#propdef-padding-left +padding-right : box.html#propdef-padding-right +padding-top : box.html#propdef-padding-top +page-break-after : page.html#propdef-page-break-after +page-break-before : page.html#propdef-page-break-before +pause : aural.html#propdef-pause +pause-after : aural.html#propdef-pause-after +pause-before : aural.html#propdef-pause-before +pitch : aural.html#propdef-pitch +pitch-range : aural.html#propdef-pitch-range +play-during : aural.html#propdef-play-during +position : visuren.html#propdef-position +quotes : generate.html#propdef-quotes +richness : aural.html#propdef-richness +right : visuren.html#propdef-right +row-span : tables.html#propdef-row-span +size : page.html#propdef-size +speak : aural.html#propdef-speak +speak-date : aural.html#propdef-speak-date +speak-header : tables.html#propdef-speak-header +speak-numeral : aural.html#propdef-speak-numeral +speak-punctuation : aural.html#propdef-speak-punctuation +speak-time : aural.html#propdef-speak-time +speech-rate : aural.html#propdef-speech-rate +stress : aural.html#propdef-stress +table-layout : tables.html#propdef-table-layout +text-align : text.html#propdef-text-align +text-decoration : text.html#propdef-text-decoration +text-indent : text.html#propdef-text-indent +text-shadow : text.html#propdef-text-shadow +text-transform : text.html#propdef-text-transform +top : visuren.html#propdef-top +unicode-bidi : visuren.html#propdef-unicode-bidi +vertical-align : visudet.html#propdef-vertical-align +visibility : visufx.html#propdef-visibility +voice-family : aural.html#propdef-voice-family +volume : aural.html#propdef-volume +white-space : text.html#propdef-white-space +widows : page.html#propdef-widows +width : visudet.html#propdef-width +word-spacing : text.html#propdef-word-spacing +z-index : visuren.html#propdef-z-index diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/xhtml.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/xhtml.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,363 @@ + + + + + + + +#if ( !$css ) #set ( $css = $cssversion ) #end + $W3C_validator_results $file_title ($css) + + + + + + + +#if ( $errors_count > 0 || $warnings_count > 0 || $rules_count > 0 ) + +#end +
+#if ($file_title.trim().startsWith("http://")) +

$W3C_validator_results $file_title ($css)

+#else +

$W3C_validator_results $file_title ($css)

+#end +#if ( !$no_errors_report ) + #if ($errors_count == 0) + +
+

$congrats

+

+ $doc_validates_before_link $css $doc_validates_after_link +

+

+ $no_errors_interoperable_msg +

+ $valid_CSS +
+<p>
+    <a href="http://jigsaw.w3.org/css-validator/check/referer">
+        <img style="border:0;width:88px;height:31px"
+            src="http://jigsaw.w3.org/css-validator/images/vcss"
+            alt="$valid_CSS" />
+    </a>
+</p>
+            
+ $valid_CSS +
+<p>
+<a href="http://jigsaw.w3.org/css-validator/check/referer">
+    <img style="border:0;width:88px;height:31px"
+        src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
+        alt="$valid_CSS" />
+</a>
+</p>
+        
+

($no_errors_close_tags_msg)

+ +
+ + + +

+ $no_errors_dl_local_msg +

+ #if ( !$file_title.trim().startsWith("file://localhost") ) +

+ $no_errors_create_link_msg +

+
http://jigsaw.w3.org/css-validator/validator$link
+or
+http://jigsaw.w3.org/css-validator/check/referer ($no_errors_forHTML_only_msg)
+
+

($no_errors_bookmark_msg)

+ #end + +
+

↑ $top

+ #else + + + #if ( $hook_html_validator ) + + $hook_html_validator + #end + #set ( $sf = "" ) + #set ( $open = false ) + +
+

$errors_sorry_msg ($errors_count)

+ #if ( $request ) + +

$request

+ #end +
+ #foreach ( $error_content in $errors_content ) + #set ( $err = $error_content.get("Error") ) + #set ( $error_msg = $error_content.get("ErrorMsg") ) + #set ( $context_name = $error_content.get("CtxName") ) + #set ( $context_msg = $error_content.get("CtxMsg") ) + #set ( $class_name = $error_content.get("ClassName") ) + #if ( $error_content.get("link_value_parse_error") ) + #set ( $before_link = $error_content.get("link_before_parse_error") ) + #set ( $link_value = $error_content.get("link_value_parse_error") ) + #else + #set ( $link_value = false ) + #end + #if ( $error_content.get("span_value_parse_error") ) + #set ( $span_value = $error_content.get("span_value_parse_error") ) + #else + #set ( $span_value = false ) + #end + #if ( $sf != $err.SourceFile ) + #if ( $open ) + + + +
+ #end + #set ( $sf = $err.SourceFileEscaped ) + +
+ #if ( $fake_input ) +

URI : $file_title

+ #else +

URI : $sf

+ #end + + #set ( $open = true ) + #end + + + + + + + #end + #if ( $open ) + +
$err.Line#if ( $context_msg ) $context_msg #end + #if ( $link_value ) + #set ( $link_name = $error_content.get("link_name_parse_error") ) + + $before_link : $link_name + #end + + $error_msg + #if ( $span_value ) + #set ( $span_class = $error_content.get("span_class_parse_error") ) + + + $span_value + + #end + +
+
+ #end + +
+
+

↑ $top

+ #end +#end +#if ($errors_count > 0) +
+ +#end + +#if ($warnings_count > 0) + +
+

$warnings ($warnings_count)

+
+ #set ( $sf = "" ) + #set ( $open = false ) + #foreach ( $warning in $warnings_list ) + #if ( $sf != $warning.SourceFile ) + #if ( $open ) + + + +
+ #end + #set ( $sf = $warning.SourceFileEscaped ) + +
+ #if ( $fake_input ) +

URI : $file_title

+ #else +

URI : $sf

+ #end + + #set ( $open = true ) + #end + #if ( $warning.Level <= $warning_level ) + + + + + + + #end + #end + #if ( $open ) + +
$warning.Line#if ( $warning.Context ) $warning.Context.Escaped #end$warning.WarningMessageEscaped
+
+ #end + +
+ +

↑ $top

+#end + +#if ( $rules_count > 0 ) +
+

$valid_CSS_info

+
+ #if ($style_charset) + +
@charset "$style_charset";
+ #end + + #foreach ( $rules in $at_rules_list ) + #if ( $rules.AtRule != "" ) + + #if ( $rules.Empty ) +
$rules.AtRuleEscaped + #else +
+ + $rules.AtRuleEscaped + + { + #end + #end + +
+ #foreach ( $rule in $rules.StyleRules ) + +
+ #if ( $rule.Selectors ) + + $rule.SelectorsEscaped + + { + #end +
+ #foreach ( $property in $rule.Properties ) + +
+ $property.PropertyNameEscaped : + $property.Escaped#if ( $property.Important ) !important #end; +
+ #end + +
+ #if ( $rule.Selectors ) + } + #end +
+ #end + +
+ #if ( $rules.AtRule != "" ) + #if ( !$rules.Empty ) + + } + #end + +
+ #end + #end + +
+
+

↑ $top

+#else +

$CSS_not_found

+#end +
+ + +#if ($file_title.trim().startsWith("http://") || $file_title.trim().equals("file://localhost/TextArea")) +
    + #foreach ( $language in $languages ) + #set ( $name = $language.get("name") ) + #if ( $language.get("real") ) + #set ( $real = $language.get("real") ) + #else + #set ( $real = $language.get("name") ) + #end + +
  • $real +
  • + #end + +
+#end + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/css/xml.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/css/xml.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,61 @@ + + + + + + +#if ( $rules_count > 0 ) + #if ($style_charset) + + @charset + #end + + #foreach ( $rules in $at_rules_list ) + #if ( $rules.AtRule != "" ) + + + $rules.AtRule + #elseif ( !$rules.Empty ) + + + #end + #foreach ( $rule in $rules.StyleRules ) + + + $rule.Selectors + + #foreach ( $property in $rule.Properties ) + + + + + + #end + + + + #end + #if ( $rules.AtRule != "" ) + + + #elseif ( !$rules.Empty ) + + + #end + #end +#else + $CSS_not_found +#end + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRule.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRule.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleFontFace.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleFontFace.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleImport.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleImport.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMedia.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMedia.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMediaCSS1.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMediaCSS1.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMediaCSS2.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleMediaCSS2.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleNamespace.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRuleNamespace.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePage.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePage.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePhoneticAlphabet.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePhoneticAlphabet.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePreference.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/AtRulePreference.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssError.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssError.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssErrorToken.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssErrorToken.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssFouffa.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssFouffa.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssParseException.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssParseException.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssPrinterStyle.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssPrinterStyle.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssPropertyFactory.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssPropertyFactory.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssSelectors.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssSelectors.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssSelectorsConstant.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssSelectorsConstant.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssStyle.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssStyle.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssValidatorListener.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/CssValidatorListener.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/Elements.dtd4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/parser/Elements.dtd4 Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,91 @@ +A: false +ABBR: false +ACRONYM:false +ADDRESS: true +APPLET:false +AREA:false +B: false +BASE: false +BASEFONT:false +BDO: false +BIG: false +BLOCKQUOTE: true +BODY:true +BR: false +BUTTON: false +CAPTION: false +CENTER: true +CITE: false +CODE: false +COL: false +COLGROUP: false +DD: false +DEL: false +DFN: false +DIR: true +DIV: true +DL: true +DT: false +EM: false +FIELDSET: true +FONT: false +FORM: true +FRAME: false +FRAMESET: false +H1: true +H2: true +H3: true +H4: true +H5: true +H6: true +HEAD: false +HR: true +HTML: true +I: false +IFRAME: false +IMG: false +INPUT: false +INS: false +ISINDEX: true +KBD: false +LABEL: false +LEGEND: false +LI: true +LINK: false +MAP: false +MENU: true +META: false +NOFRAMES: true +NOSCRIPT: true +OBJECT: false +OL: true +OPTION: false +P: true +PARAM: false +PRE: true +Q: false +S: false +SAMP: false +SCRIPT: false +SELECT: false +SMALL: false +SPAN: false +STRIKE: false +STRONG: false +STYLE: false +SUB: false +SUP: false +TABLE: true +TBODY: false +TD: false +TEXTAREA: false +TFOOT: false +TH: false +THEAD: false +TITLE: false +TR: false +TT: false +U: false +UL: true +VAR: false +SCRIPT: false diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/Errors.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/Errors.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/Frame.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/Frame.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/parser/Makefile Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,35 @@ +SRCS = CssFouffa.java Errors.java\ +CssError.java CssValidatorListener.java Frame.java\ +CssErrorDeclaration.java \ +CssErrorToken.java CssSelectors.java\ +CssStyle.java CssPrinterStyle.java CssParseException.java + +OBJS = $(SRCS:.java=.class) + +PACKAGE = org.w3c.css.parser +JAVAC = jc -val +JAVADOC = javadoc +JAVADOCFLAGS = -version -d docs -protected +JAVACFLAGS = +MAKEDEPEND = jmakedepend + +.SUFFIXES: .class .java +.java.class:; $(JAVAC) $(JAVACFLAGS) $< + +all: $(OBJS) + +javadoc:; $(JAVADOC) $(JAVADOCFLAGS) $(PACKAGE) + +clean:; -rm -f $(OBJS) *~ core + +depend:; $(MAKEDEPEND) $(SRCS) +# DO NOT DELETE THIS LINE -- make depend depends on it. +CssErrorToken.class:: CssErrorToken.java +Frame.class:: Frame.java +CssError.class:: CssError.java +CssValidatorListener.class:: CssValidatorListener.java +Errors.class:: Errors.java +CssFouffa.class:: CssFouffa.java +CssStyle.class:: CssStyle.java +CssParseException.class:: CssParseException.java +CssPrinterStyle.class:: CssPrinterStyle.java diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/MediaEnumeration.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/MediaEnumeration.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CommentSkipperInputStream.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CommentSkipperInputStream.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/Couple.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/Couple.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser$JJCalls.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser$JJCalls.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser$LookaheadSuccess.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser$LookaheadSuccess.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser.class Binary file org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser.class has changed diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser.jj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/bin/org/w3c/css/parser/analyzer/CssParser.jj Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,2425 @@ +/* -*-java-extended-*- + * + * (c) COPYRIGHT MIT and INRIA, 1997. + * Please first read the full copyright statement in file COPYRIGHT.html + * + * $Id: CssParser.jj,v 1.69 2009-10-11 09:19:37 ylafon Exp $ + * + */ + +options { + IGNORE_CASE = true; + STATIC = false; + UNICODE_INPUT = true; + /* + DEBUG_TOKEN_MANAGER = true; + DEBUG_PARSER = true; + */ +} + +PARSER_BEGIN(CssParser) + +package org.w3c.css.parser.analyzer; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.Vector; +import java.util.Enumeration; +import java.net.URL; + +import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssString; +import org.w3c.css.values.CssURL; +import org.w3c.css.values.CssLength; +import org.w3c.css.values.CssNumber; +import org.w3c.css.values.CssColor; +import org.w3c.css.values.CssIdent; +import org.w3c.css.values.CssPercentage; +import org.w3c.css.values.CssFrequency; +import org.w3c.css.values.CssTime; +import org.w3c.css.values.CssDate; +import org.w3c.css.values.CssAngle; +import org.w3c.css.values.CssFunction; +import org.w3c.css.values.CssUnicodeRange; +import org.w3c.css.values.CssResolution; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.parser.Frame; +import org.w3c.css.util.ApplContext; +import org.w3c.css.parser.CssError; +import org.w3c.css.parser.CssSelectors; +import org.w3c.css.parser.CssParseException; +import org.w3c.css.parser.AtRule; +import org.w3c.css.parser.AtRuleMedia; +import org.w3c.css.parser.AtRuleFontFace; +import org.w3c.css.parser.AtRulePage; +import org.w3c.css.parser.AtRulePreference; +import org.w3c.css.parser.AtRulePhoneticAlphabet; +import org.w3c.css.properties.svg.AtRuleColorProfile; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.util.Util; +import org.w3c.css.util.Messages; +import org.w3c.css.css.StyleSheetCom; + +import org.w3c.css.selectors.AdjacentSiblingSelector; +import org.w3c.css.selectors.AttributeSelector; +import org.w3c.css.selectors.ChildSelector; +import org.w3c.css.selectors.ClassSelector; +import org.w3c.css.selectors.DescendantSelector; +import org.w3c.css.selectors.GeneralSiblingSelector; +import org.w3c.css.selectors.IdSelector; +import org.w3c.css.selectors.TypeSelector; +import org.w3c.css.selectors.UniversalSelector; +import org.w3c.css.selectors.attributes.AttributeAny; +import org.w3c.css.selectors.attributes.AttributeBegin; +import org.w3c.css.selectors.attributes.AttributeExact; +import org.w3c.css.selectors.attributes.AttributeOneOf; +import org.w3c.css.selectors.attributes.AttributeStart; +import org.w3c.css.selectors.attributes.AttributeSubstr; +import org.w3c.css.selectors.attributes.AttributeSuffix; + +/** + * A CSS3 parser + * + * @author Philippe Le Hegaret and Sijtsche Smeman + * @version $Revision: 1.69 $ + */ +public abstract class CssParser { + + private static char hexdigits[] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f' }; + // the current atRule + protected AtRule atRule; + protected String mediaDeclaration = "off"; + + /** + * The URL of the document + */ + protected URL url; + + protected ApplContext ac; + + protected boolean incompatible_error; + + /** + * The current context recognized by the parser (for errors). + */ + protected Vector currentContext; + + /** + * The current property recognized by the parser (for errors). + */ + protected String currentProperty; + + /** + * true if the parser should recognized Aural properties, + * false otherwise. + */ + protected boolean mode; + + /** + * true if the parser had recognize a rule, + * false otherwise. + */ + protected boolean markRule; + + private boolean reinited = false; + private boolean charsetdeclared = false; + + static StringBuilder SPACE = new StringBuilder(" "); + + // to be able to remove a ruleset if the selector is not valid + protected boolean validSelector = true; + + /** + * The ac for handling errors and warnings. + * + * @param ac the new ac for the parser. + */ + public final void setApplContext(ApplContext ac) { + this.ac = ac; + } + + /** + * Set the attribute atRule + * + * @param atRule the new value for the attribute + */ + public void setAtRule(AtRule atRule) { + this.atRule = atRule; + } + + /** + * Set the attribute mediaDeclaration + * + * @param mediaDeclaration indicator if in a media expression list or not + */ + public void setMediaDeclaration(String mediadeclaration) { + this.mediaDeclaration = mediadeclaration; + } + + /** + * Returns the attribute mediaDeclaration + * + * @return the value of the attribute + */ + public String getMediaDeclaration() { + return mediaDeclaration; + } + + /** + * Returns the attribute atRule + * + * @return the value of the attribute + */ + public AtRule getAtRule() { + return atRule; + } + + /** + * Reinitialized the parser. + * + * @param stream the stream data to parse. + * @param ac the new ac to use for parsing. + */ + public void ReInitWithAc(InputStream stream, ApplContext ac, + String charset) + { + InputStream is = /*new CommentSkipperInputStream(stream);*/stream; + if (charset == null) { + charset = "iso-8859-1"; + } + InputStreamReader isr = null; + try { + isr = new InputStreamReader(is, charset); + } catch (UnsupportedEncodingException uex) { + isr = new InputStreamReader(is); + } + // reinit, it can not happen... + // ...in theory ;) + ReInit(isr); + markRule = false; + reinited = true; + setApplContext(ac); + } + + /* utilities for a parser */ + + /** + * Call by the import statement. + * + * @param url The style sheet where this import statement appears. + * @param file the file name in the import + */ + public abstract void handleImport(URL url, String file, + boolean is_url, AtRuleMedia media); + + /** + * Call by the namespace declaration statement. + * + * @param url The style sheet where this namespace statement appears. + * @param file the file/url name in the namespace declaration + */ + public abstract void handleNamespaceDeclaration(URL url, String prefix, + String file, + boolean is_url); + + /** + * Call by the at-rule statement. + * + * @param ident The ident for this at-rule (for example: 'font-face') + * @param string The string associate to this at-rule + * @see org.w3c.css.parser.Analyzer.Couple + */ + public abstract void handleAtRule(String ident, String string); + + /* added by Sijtsche Smeman */ + public abstract void addCharSet(String charset); + public abstract void newAtRule(AtRule atRule); + public abstract void endOfAtRule(); + public abstract void setImportant(boolean important); + public abstract void setSelectorList(Vector selectors); + public abstract void addProperty(Vector properties); + public abstract void endOfRule(); + public abstract void removeThisRule(); + public abstract void removeThisAtRule(); + + /** + * Assign an expression to a property. This function create a new property + * with property and assign to it the expression with the + * importance. Don't forget to set informations too. + *

+ * A subclass must provide an implementation of this method. + * + * @param property the name of the property + * @param values the expression representation of values + * @param important true if values are important + * + * @return nullor a property + * + * @see org.w3c.css.css.CssProperty + */ + public abstract CssProperty handleDeclaration(String property, + CssExpression values, + boolean important) + throws InvalidParamException; + + /** + * Adds a vector of properties to a selector. + *

+ * A subclass must provide an implementation of this method. + * + * @param selector the selector + * @param declarations Properties to associate with contexts + */ + public abstract void handleRule(CssSelectors selector, + Vector declarations); + + /*Added by Sijtsche Smeman */ + + /** + * Returns the source file of the style sheet + */ + public final String getSourceFile() { + return getURL().toString(); + } + + /** + * Returns the current line in the style sheet + */ + public final int getLine() { + //return token.beginLine; + return 0; + } + + /** + * Set the URL of the style sheet. + * + * @param URL The URL for the style sheet + */ + public final void setURL(URL url) { + this.url = url; + } + + public final URL getURL() { + return url; + } + + /** + * Return the next selector from the inputstream + */ + public CssSelectors parseSelector() throws ParseException { + return externalSelector(); + } + + /* + * Add a value to an expression + */ + private void setValue(CssValue v, CssExpression expr, + char operator, Token n, int token) + throws ParseException { + if (n != null) { + if (ac.getCssVersion().equals("css1") && + (n.image).equals("inherit")) { + incompatible_error = true; + } + String val = (operator == ' ') ? n.image : operator+n.image; + + if (n.kind == CssParserConstants.IDENT) { + v.set(convertIdent(val), ac); + } else if (n.kind == CssParserConstants.STRING) { + v.set(val, ac); + } else { + v.set(val, ac); + } + } + expr.addValue(v); + } + + /* + * Error control + */ + private void addError(Exception e, String skippedText) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + CssParseException ex = new CssParseException(e); + ex.setSkippedString(skippedText); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + } + + /* + * Error control 2 + */ + private void addError(Exception e, CssExpression exp) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + + // if ((exp != null) && (exp.getCount() != 0)) { + CssParseException ex = new CssParseException(e); + ex.setExp(exp); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + // } + } +} + +PARSER_END(CssParser) + +/* + * The tokenizer + */ + + +SPECIAL_TOKEN : +{ + < COMMENT : "/*" ( ~["*"] )* ( "*" )+ ( ~["/", "*"] ( ~["*"] )* ( "*" )+ )* "/" > +} + + + TOKEN [IGNORE_CASE] : /* basic tokens */ +{ + < #H : ["0"-"9", "a"-"f"] > + | < #NONASCII : ["\200"-"\377"] > + | < #UNICODE : "\\" ( )? ( )? ( )? ( )? ( )? + ( "\r\n" | [ " ", "\t" , "\n" , "\r", "\f" ] )? > + | < #ESCAPE : | ( "\\" ~[ "\r", "\n", "\f", "0"-"9", "a"-"f" ] ) > + | < #NMSTART : [ "a"-"z", "_" ] | | > + | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > + | < #STRING1 : "\"" ( ~[ "\n", "\r", "\f", "\\", "\"" ] | "\\" | )* "\"" > + | < #STRING2 : "\'" ( ~[ "\n", "\r", "\f", "\\", "\'" ] | "\\" | )* "\'" > + | < #INVALID1 : "\"" ( ~[ "\n", "\r", "\f", "\\", "\"" ] | "\\" | )* > + | < #INVALID2 : "\'" ( ~[ "\n", "\r", "\f", "\\", "\'" ] | "\\" | )* > + | < #_IDENT : ( )? ( )* > + | < #NAME : ( )+ > + | < #NUM : ( ["0"-"9"] )+ | ( ["0"-"9"] )* "." ( ["0"-"9"] )+ > + | < #_STRING : | > + | < #_INVALID : | > + | < #_URL : ( [ "!", "#", "$", "%", "&", "*"-"[", "]"-"~" ] | | )* > + | < #_S : ( [ " ", "\t" , "\n" , "\r", "\f" ] ) ( | [ " ", "\t" , "\n" , "\r", "\f" ] )* > + | < #_W : ( <_S> )? > + | < #NL : ( "\n" | "\r\n" | "\r" | "\f" ) > +} +/* + * The _S definition is not ( [ " ", "\t" , "\n" , "\r", "\f" ] ) + as we need to add support + * for the unput(' ') (see http://www.w3.org/TR/CSS21/grammar.html#scanner ) + */ + + +TOKEN : +{ + < S : ( <_S> ) > +} + + + TOKEN : +{ + < CDO : "" > + | < INCLUDES : "=" > + | < DASHMATCH : "|=" > +} + + +TOKEN : +{ + < LBRACE : <_W> "{" > + | < PLUS : <_W> "+" > + | < GREATER : <_W> ">" > + | < COMMA : <_W> "," > + | < TILDE : <_W> "~" > +} + + +TOKEN [IGNORE_CASE] : +{ + < AND : "and" > +} + + +TOKEN : +{ + > + | > + | > + | > + | > +} + + +TOKEN : +{ + < RBRACE : "}"> + | < PREFIXMATCH : "^=" > + | < SUFFIXMATCH : "$=" > + | < SUBSTRINGMATCH : "*=" > + | < EQ : "=" > + | < MINUS : "-" > + | < SEMICOLON : ";" > + | < DIV : "/" > + | < LBRACKET : "[" > + | < RBRACKET : "]" > + | < ANY : "*" > + | < DOT : "." > + | < LPARAN : ")" > + | < RPARAN : "("> +} + + + TOKEN : +{ + < COLON : ":" > +} + + +TOKEN [IGNORE_CASE] : +{ + < MEDIARESTRICTOR : "only" | "not" > +} + + +TOKEN [IGNORE_CASE] : +{ + < URL : "url(" ( )* ( | <_URL> ) ( )* ")" > +} + + +TOKEN [IGNORE_CASE] : +{ + < LENGTH : "pt" + | "mm" + | "cm" + | "pc" + | "in" + | "gd" + | "px" > + | < EMS : "em" > + | < EXS : "ex" > + | < ANGLE : ( "deg" | "grad" | "rad" ) > + | < TIME : ( "ms" | "s" ) > + | < FREQ : "Hz" | "kHz" > + | < RESOLUTION : "dpi" | "dpcm" > + | < DATE : "/" "/" > + | < DIMEN : ( )* > + | < PERCENTAGE : "%" > + | < NUMBER : > +} + + +TOKEN [IGNORE_CASE] : +{ + < IMPORTANT_SYM : "!" ( <_W> )* "important" > +} + + +TOKEN : +{ + +} + +/* RESERVED ATRULE WORDS */ + +TOKEN : +{ + < CHARSET_SYM : "@charset" > +} + + +TOKEN [IGNORE_CASE] : +{ + < IMPORT_SYM : "@import"> + | < NAMESPACE_SYM : "@namespace"> + | < MEDIA_SYM : "@media" > + | < PAGE_SYM : "@page" > + | < FONT_FACE_SYM : "@font-face" > + | < PREF_SYM : "@preference" > + | < COLOR_PROFILE : "@color-profile" > + | < ATTOP : "@top" > + | < ATRIGHT : "@right" > + | < ATBOTTOM : "@bottom" > + | < ATLEFT : "@left" > + | < ATCOUNTER : "@counter" > + | < PHONETIC_ALPHABET_SYM : "@phonetic-alphabet" > + | < ATKEYWORD : "@" > +} + + +TOKEN [IGNORE_CASE] : +{ + < #RANGE0 : > + | < #RANGE1 : ( "?" )? > + | < #RANGE2 : ( "?" )? ( "?" )? > + | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE : | | + | | | | > + | < #UNI : ( )? ( )? ( )? ( )? ( )? > + | < UNICODERANGE : "U+" | "U+" "-" > +} + + + TOKEN: +{ + < CLASS : "." > +} + +/* FIXED, added a spacial case for lang pseudoclass */ + +TOKEN [IGNORE_CASE] : +{ + < FUNCTIONLANG : "lang(" > +} + + +TOKEN [IGNORE_CASE] : +{ + < FUNCTIONNOT : ":not(" > +} + + + + TOKEN : +{ + < FUNCTION : "(" > +} + +/* Quick and dirty way to catch HTML tags starting CSS documents + (common mistake) */ + + TOKEN: +{ + )* ( )* + ( "=" ( | ) ( )* )* + ">" > + | )* ( )* ">" > +} + +// +//TOKEN : +//{ /* avoid token manager error */ +// < UNKNOWN : ~[] > +//} + +/* + * The grammar of CSS2 + */ + +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ +void parserUnit() : +{ + Token n = null; +} +{ + try { + // used as an error recovery for HTML tags in CSS pages + ( ( n= | n= ) { + addError ( +new ParseException(ac.getMsg().getString("generator.dontmixhtml")), n.image); + } + )* + ( charset() )* // * instead of ? to capture the reinit part + ( | | )* + ( importDeclaration() ( ignoreStatement() ) )* + ( namespaceDeclaration() ( ignoreStatement() ) )* + afterImportDeclaration() + + } catch (TokenMgrError err) { + addError (new ParseException(ac.getMsg().getString("generator.unrecognize")), + err.getMessage()); + } +} + +void charset() : +{ + Token n = null; + Token charsetToken = null; + Token space1Token = null; + Token space2Token = null; + Token semicolonToken = null; + int nb_S = 0; +} +{ + try { + charsetToken= ( space1Token= { nb_S++;} )* + n= ( space2Token= )* semicolonToken= + { + if (charsetdeclared && !reinited) { + throw new ParseException( + ac.getMsg().getString("parser.charset")); + } + // the @charset must be at the beginning of the document + if(charsetToken.beginLine != 1 || + charsetToken.beginColumn != 1) { + throw new ParseException( + ac.getMsg().getString("parser.charset")); + } + if ("css1".equals(ac.getCssVersion())) { + throw new ParseException(ac.getMsg().getString( + "parser.charsetcss1")); + } + // stricter rule for CSS21 and soon for CSS3 + if ("css21".equals(ac.getCssVersion())) { + // single space before + // case sensitive + // no space before ; + // no comments + // string must start with " + if ( (nb_S != 1) || + (!"@charset".equals(charsetToken.image)) || + (!" ".equals(space1Token.image)) || + (space2Token != null && + !"".equals(space2Token.image)) || + (space1Token.specialToken != null) || + (n.specialToken != null) || + (semicolonToken.specialToken != null) || + (n.image.charAt(0) != '\"') + ) { + throw new ParseException(ac.getMsg().getString( + "parser.charsetspecial")); + } + } + if (!charsetdeclared) { + addCharSet(n.image.substring(1, n.image.length()-1)); + charsetdeclared = true; + } else { + reinited = false; + } + } + } catch (Exception e) { + String skip = charsetToken + + ((space1Token == null) ? "" : space1Token.image) + + n + + ((space2Token == null) ? "" : space2Token.image) + + ";"; + addError(e, skip); + } +} + +void afterImportDeclaration() : +{String ret; } +{ + ( ( ruleSet() | media() | page() | fontFace() | preference() | + colorprofile() | phoneticAlphabet() | ret=skipStatement() + { if ((ret == null) || (ret.length() == 0)) { + return; + } + // quite ugly but necessary to avoid probably a lot of changes in the + // grammar, still having a beautiful error message + else if (ret.startsWith("@charset")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.charset")); + addError(e, ret); + } else if (ret.startsWith("@import")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.import_not_allowed")); + addError(e, ret); + } else { + ParseException e = + new ParseException(ac.getMsg().getString("generator.unrecognize")); + addError(e, ret); + } + } + ) ignoreStatement() )* +} + +void ignoreStatement() : +{} +{ + ( ( | | atRuleDeclaration() ) ( )* )* +} + +void namespaceDeclaration() : +{ + Token n=null; + Token v=null; + boolean is_url; /* for formatting */ + String nsname; + String prefix = null; + CssValue val; +} +{ + // FIXME add namespaces in context to match when a definition happens + ( + ( )* + ( n= { + prefix = convertIdent(n.image); + } + ( )* )? + ( v= { + is_url = false; + nsname = v.image.substring(1, v.image.length()-1); + } + | v= { + is_url = true; + val = new CssURL(); + ((CssURL) val).set(v.image, ac, url); + nsname = (String) val.get(); + if ((nsname.charAt(0) == '"') + || (nsname.charAt(0) == '\'')) { + nsname = nsname.substring(1, nsname.length()-1); + } + } + ) + ( )* + + ( )* + ) { + if (!ac.getCssVersion().equals("css3")) { + addError(new InvalidParamException("at-rule", "@namespace", ac), + (n==null)?"default":n.toString()); + } else { + if (v != null) { + handleNamespaceDeclaration(getURL(), prefix, nsname, is_url); + } + } + } +} +/** + * The import statement + * + * @exception ParseException exception during the parse + */ +void importDeclaration() : +{Token n; + AtRuleMedia media = new AtRuleMedia(); + CssValue val; + String importFile; + boolean is_url = false; +} +{ + try { + ( )* + ( n= { + importFile = n.image.substring(1, n.image.length() -1); + is_url = false; + } + | n= { + val = new CssURL(); + ((CssURL) val).set(n.image, ac, url); + importFile = (String) val.get(); + if ((importFile.charAt(0) == '"') + || (importFile.charAt(0) == '\'')) { + importFile = importFile.substring(1, importFile.length()-1); + } + is_url = true; + } + ) + ( )* + ( medium(media) + ( ( )* medium(media) + )* )? + ( )* + { + handleImport(getURL(), importFile, is_url, media); + } + } catch (ParseException e) { + addError(e, skipStatement()); + } +} + +/** + * @exception ParseException exception during the parse + */ +void media() : +{ + AtRule old = getAtRule(); + AtRuleMedia newRule = new AtRuleMedia(); + setAtRule(newRule); + Token n; + CssProperty p = null; +} +{ + try { + ( )* + // + (n= { newRule.addMediaRestrictor(convertIdent(n.image), ac); } ( )+)? + medium(newRule) + // + ( ( )* medium(newRule) )* + // + ( ( )* ( )* p=mediadeclaration() { newRule.addMediaFeature(p); } ( )* )* + // + + { + String media = getAtRule().toString(); + if (ac.getMedium() != null && + !(media.equals(ac.getMedium())) && + !(ac.getMedium().equals("all"))) { + + ac.getFrame().addWarning("noothermedium", + getAtRule().toString()); + } + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + } + ( )* ( ruleSet() )* ( )* + { + if (!ac.getCssVersion().equals("css1")) { + endOfAtRule(); + } + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +/** + * @exception ParseException exception during the parse + */ +void medium(AtRuleMedia media) : /* tv, projection, screen, ... */ +{Token n;} +{ + n= ( )* + { + try { + media.addMedia(convertIdent(n.image), ac); + } catch (InvalidParamException e) { + CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void page() : +{ + Vector v ; + Token n = null ; + Vector collectv = new Vector() ; + CssSelectors s = new CssSelectors(ac); + AtRule old = getAtRule() ; + AtRulePage newRule = new AtRulePage() ; + setAtRule(newRule); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + // FIXME ? + ( n= { newRule.setIdent(convertIdent(n.image)); } + ( )* )? + // + ( pseudo_page(newRule) )? ( )* ( v=pageContent() + { + collectv = v; + } + ) ( )* + { + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + if (!ac.getCssVersion().equals("css1")) { + addProperty(collectv); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, collectv); + } + } + } catch (InvalidParamException ie) { + if (!ac.getCssVersion().equals("css1")) { + skipStatement(); + removeThisAtRule(); + ac.getFrame().addError(new CssError(ie)); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + removeThisAtRule(); + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +Vector pageContent() : +{ CssProperty prop; + Vector v = new Vector(); +} +{ + // ?? FIXME + v=prefAtRule() { return v;} + // + | + v=declarations() { return v;} /* FIXME moved here as it can match empty string */ +} + +Vector prefAtRule() : +{ Token n; + Vector v; +} +{ + try { + (n= | n= | n= | n= ) ( )* + ( )* v=declarations() ( )* + { + return v; + } + } catch (ParseException e) { + addError(e, skipStatement()); + } +} + +void pseudo_page(AtRulePage page) : +{ Token n; } +{ + ":" n= ( )* + { + try { + page.setName(":" + convertIdent(n.image), ac); + } catch (InvalidParamException e) { + throw new InvalidParamException("pseudo", n.image, ac ); + /*CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); */ + } + } +} + +void fontFace() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleFontFace()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, v); + } + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +void colorprofile() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleColorProfile()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (!ac.getCssVersion().equals("svg")) { + skipStatement(); + addError(new InvalidParamException("onlysvg", "", ac), + getAtRule().toString()); + } + if (ac.getCssVersion().equals("svg")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (ac.getCssVersion().equals("svg")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + //ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } + } + catch (ParseException e) { + if (ac.getCssVersion().equals("svg")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + + +void preference() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRulePreference()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } + } + catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +void phoneticAlphabet() : +{ + Vector v; + AtRule old = getAtRule(); + AtRulePhoneticAlphabet alphabetrule = new AtRulePhoneticAlphabet(); + setAtRule(alphabetrule); + Token n; +} +{ + try { + ( )* n= ( )* ";" + { + if (!ac.getCssVersion().equals("css3")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + + alphabetrule.addAlphabet(convertIdent(n.image), ac); + + if (!ac.getCssVersion().equals("css1") && !ac.getCssVersion().equals("css2")) { + newAtRule(getAtRule()); + } + + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +/** + * @exception ParseException exception during the parse + */ +void atRuleDeclaration() : +{Token n;} +{ + n= + { + //ac.getFrame().addWarning("at-rule", token.toString()); + ac.getFrame().addError( + new CssError(new InvalidParamException("at-rule", + token, ac))); + skipStatement(); + } +} + +/** + * @exception ParseException exception during the parse + */ +void operator(CssExpression expr) : +{} +{ + ( (

{ if (expr.getCount() > 0) expr.setOperator('/'); } + | { if (expr.getCount() > 0) expr.setOperator(','); } + ) ( )* )? +} + +/** + * @exception ParseException exception during the parse + */ +char combinator() : +{ + char connector = ' '; +} +{ + ( ( { connector = '+' ; } + | { connector = '>' ; } + | { connector = '~' ; } + ) ( )* + | ( )+ { connector = ' ' ; } + ) + { + return connector; + } +} + +/** + * @exception ParseException exception during the parse + */ +char unaryOperator() : +{} +{ + // FIXME | ? warning as is <_W>? "+" + "-" { return '-'; } + | { return '+'; } +} + +/** + * @exception ParseException exception during the parse + */ +String property() : +{Token n; } +{ + n= ( )* { currentProperty = convertIdent(n.image); + return currentProperty; } +} + +/** + * @exception ParseException exception during the parse + */ +void ruleSet() : +{ CssSelectors contextual; + Vector context_set = new Vector(); + Vector value_set = null; + currentContext = context_set; +} +{ + try { + contextual=selector() + { + if (contextual != null) { + context_set.addElement(contextual); + } + } + + ( ( )* + contextual=selector() + { + if (contextual != null) { + context_set.addElement(contextual); + } + } + )* + { + validSelector = (context_set.size() > 0); + } + ( )* + value_set=declarations() + ( )* + { + markRule = true; + + /* if (value_set == null) { + ac.getFrame().addWarning("no-declaration"); + } else {*/ + if (value_set != null) { + boolean first = true; + CssSelectors sel = null; + Enumeration e = context_set.elements(); + while (e.hasMoreElements()) { + sel = e.nextElement(); + if (first) { + handleRule(sel, value_set); + first = false; + } else { + // we need to duplicate properties in that case + // as property holds reference to the selectors and it interact + // badly with conflict detection + int vsize = value_set.size(); + Vector v = new Vector(vsize); + for (int i=0; i declarations() : +{ + if(!validSelector) { + validSelector = true; + skip_to_matching_brace(); + return null; + } + + CssProperty values; + Vector value_set = new Vector(); + boolean wrong_value = true; +} +{ + ( values=declaration() + { if (values != null) { + value_set.addElement(values); + wrong_value = false; + } /* else { + wrong_value = true; + } */ + currentProperty = null; + } + )? + ( ";" ( )* + ( values=declaration() + { if (values != null) { + value_set.addElement(values); + wrong_value = false; + }/* else { + wrong_value = true; + }*/ + currentProperty = null; + } + )? )* + { + if (!wrong_value) { + addProperty(value_set); + return value_set; + } else { + return null; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +CssSelectors selector() : +{ char comb; + CssSelectors current; } +{ + try { + current=simple_selector(null) + ( + comb=combinator() { + if (ac.getProfile() != null) { + if (ac.getProfile().equals("mobile") || + getAtRule().toString().equals("@media atsc-tv") || + ac.getCssVersion().equals("css1")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + if (comb == '>') + throw new InvalidParamException("nocomb", ">", ac); + } else if (ac.getProfile().equals("tv")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + + } + } + if (!ac.getCssVersion().equals("css3")) { + if (comb == '~') { + throw new InvalidParamException("nocomb", "~", ac); + } + } + switch(comb) { + case '+': + current.addAdjacentSibling(new AdjacentSiblingSelector()); + break; + case '>': + current.addChild(new ChildSelector()); + break; + case '~': + current.addGeneralSibling(new GeneralSiblingSelector()); + break; + default: + current.addDescendant(new DescendantSelector()); + } + //current.setConnector(comb); + } + current=simple_selector(current) + )* + { return current; } + } + catch (InvalidParamException ie) { + // skipStatement(); + // removeThisRule(); + ac.getFrame().addError(new CssError(ie)); + Token t = getToken(1); + StringBuilder s = new StringBuilder(); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + return null; + } + catch (ParseException e) { + // validSelector = false; + Token t = getToken(1); + StringBuilder s = new StringBuilder("["); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + s.append(']'); + // if (validSelector) { + addError(e, s.toString()); + // } else { + // addError(e,""); + // } + validSelector = true; + return null; + } +} + +/** + * I made this rule to parse a selector from a document. Combinator are avoid. + * @exception ParseException exception during the parse + */ +CssSelectors externalSelector() : +{ + CssSelectors current; } +{ + current=simple_selector(null) + ( ( )+ + current=simple_selector(current) + )* + { return current; } +} + +/** + * @exception ParseException exception during the parse + */ +CssSelectors simple_selector(CssSelectors next) : +{ CssSelectors selector = new CssSelectors(ac, next); + selector.setAtRule(getAtRule()); + //selector.setUserMedium(getUserMedium()); +} +{ + + element_name(selector) ( hash(selector) | _class(selector) + | attrib(selector) | pseudo(selector) + | negation(selector) )* + { + return selector; + } + | ( hash(selector) | _class(selector) | attrib(selector) + | pseudo(selector) | negation(selector) )+ + { + return selector; + } +} + +/** + * @exception ParseException exception during the parse + */ +void _class(CssSelectors s) : +{Token n; } +{ + /* "." n= { */ + n= { + try { + s.addClass(new ClassSelector(convertClassIdent(n.image.substring(1)))); + // s.addAttribute("class", convertIdent(n.image.substring(1)), + // CssSelectors.ATTRIBUTE_CLASS_SEL); + } catch (InvalidParamException e) { + // removeThisRule(); + ac.getFrame().addError(new CssError(e)); + throw new ParseException(e.getMessage()); + } + } + /* FIXME n=deprecated_class() ... ?? (DONE-> to be tested) */ + | ( n=deprecated_class() ) { + if (n.image.charAt(0) == '.') { + n.image = n.image.substring(1); + + // the class with the first digit escaped + String cl = "."+hexEscapeFirst(n.image); + + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + if(!profile.equals("css1")) { + StringBuilder sb = new StringBuilder(); + Vector param_err = new Vector(2); + param_err.add(n.image); + param_err.add(cl); + sb.append(ac.getMsg().getString("parser.old_class", param_err)); + throw new ParseException(sb.toString()); + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + CssLength length = new CssLength(); + boolean isLength = false; + try { + length.set(n.image, ac); + isLength = true; + } + catch(Exception e) { + isLength = false; + } + if(isLength) { + StringBuilder sb = new StringBuilder(); + sb.append(ac.getMsg().getString("parser.class_dim")); + sb.append(n.image); + throw new ParseException(sb.toString()); + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + try { + // for css > 1, we add the rule to have a context, + // and we then remove it + s.addClass(new ClassSelector(n.image)); + ac.getFrame().addWarning("old_class"); + } catch (InvalidParamException e) { + throw new ParseException(e.getMessage()); + //ac.getFrame().addError(new CssError(e)); + //removeThisRule(); + } + } + } + } else { + throw new ParseException("Unrecognized "); + } + } +} + +Token deprecated_class() : +{ + Token n; +} +{ + ( n= + | n= + | n= + | n= + | n=
+

↑ $top

+#end + +#if ( $rules_count > 0 ) +
+

$valid_CSS_info

+
+ #if ($style_charset) + +
@charset "$style_charset";
+ #end + + #foreach ( $rules in $at_rules_list ) + #if ( $rules.AtRule != "" ) + + #if ( $rules.Empty ) +
$rules.AtRuleEscaped + #else +
+ + $rules.AtRuleEscaped + + { + #end + #end + +
+ #foreach ( $rule in $rules.StyleRules ) + +
+ #if ( $rule.Selectors ) + + $rule.SelectorsEscaped + + { + #end +
+ #foreach ( $property in $rule.Properties ) + +
+ $property.PropertyNameEscaped : + $property.Escaped#if ( $property.Important ) !important #end; +
+ #end + +
+ #if ( $rule.Selectors ) + } + #end +
+ #end + +
+ #if ( $rules.AtRule != "" ) + #if ( !$rules.Empty ) + + } + #end + +
+ #end + #end + +
+
+

↑ $top

+#else +

$CSS_not_found

+#end +
+ + +#if ($file_title.trim().startsWith("http://") || $file_title.trim().equals("file://localhost/TextArea")) +
    + #foreach ( $language in $languages ) + #set ( $name = $language.get("name") ) + #if ( $language.get("real") ) + #set ( $real = $language.get("real") ) + #else + #set ( $real = $language.get("name") ) + #end + +
  • $real +
  • + #end + +
+#end + + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/css/xml.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/css/xml.properties Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,61 @@ + + + + + + +#if ( $rules_count > 0 ) + #if ($style_charset) + + @charset + #end + + #foreach ( $rules in $at_rules_list ) + #if ( $rules.AtRule != "" ) + + + $rules.AtRule + #elseif ( !$rules.Empty ) + + + #end + #foreach ( $rule in $rules.StyleRules ) + + + $rule.Selectors + + #foreach ( $property in $rule.Properties ) + + + + + + #end + + + + #end + #if ( $rules.AtRule != "" ) + + + #elseif ( !$rules.Empty ) + + + #end + #end +#else + $CSS_not_found +#end + + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRule.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,37 @@ +// +// $Id: AtRule.java,v 1.5 2009-02-13 14:03:36 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRule.java + * $Id: AtRule.java,v 1.5 2009-02-13 14:03:36 ylafon Exp $ + */ +package org.w3c.css.parser; + +/** + * @version $Revision: 1.5 $ + * @author Philippe Le Hegaret + */ +public abstract class AtRule { + + /** + * Returns the at rule keyword + */ + public abstract String keyword(); + + /** + * The second must be exactly the same of this one + */ + public abstract boolean canApply(AtRule atRule); + + /** + * The second must only match this one + */ + public abstract boolean canMatched(AtRule atRule); + + public boolean isEmpty() { + return false; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleFontFace.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleFontFace.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,70 @@ +// +// $Id: AtRuleFontFace.java,v 1.4 2007-11-26 05:07:17 ot Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleFontFace.java + * $Id: AtRuleFontFace.java,v 1.4 2007-11-26 05:07:17 ot Exp $ + */ +package org.w3c.css.parser; + +/** + * This class manages all media defines by CSS2 + * + * @version $Revision: 1.4 $ + * @author Philippe Le Hegaret + */ +public class AtRuleFontFace extends AtRule { + static int internal = 0; + int hash; + + /** + * Create a new AtRuleFontFace + */ + public AtRuleFontFace() { + hash = ++internal; + } + + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "font-face"; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + return (atRule instanceof AtRuleFontFace); + } + + /** + * Return true if other is an instance of AtRUleFontFace + */ + public boolean equals(Object other) { + return (other instanceof AtRuleFontFace); + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + return (atRule instanceof AtRuleFontFace); + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + return "@" + keyword(); + } + + public int hashCode() { + return hash; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleImport.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleImport.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,81 @@ +// +// $Id: AtRuleImport.java,v 1.1 2009-02-13 14:03:36 ylafon Exp $ +// +// (c) COPYRIGHT MIT, Keio University and ERCIM, 2009. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleMedia.java + * $Id: AtRuleImport.java,v 1.1 2009-02-13 14:03:36 ylafon Exp $ + */ +package org.w3c.css.parser; + +import java.net.URL; + +/** + * This class manages all imports + * + * @version $Revision: 1.1 $ + * @author Philippe Le Hegaret + */ +public class AtRuleImport extends AtRule { + + boolean is_url = false; + String linkname = null; + AtRuleMedia media = null; + + public String keyword() { + return "import"; + } + + public boolean isEmpty() { + return true; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + return false; + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + return false; + } + + + /** + * Returns a string representation of the object. + */ + public String toString() { + StringBuilder ret = new StringBuilder(); + + ret.append('@'); + ret.append(keyword()); + ret.append(' '); + if (is_url) { + ret.append("url(\'"); + ret.append(linkname); + ret.append("\')"); + } else { + ret.append('\"'); + ret.append(linkname); + ret.append('\"'); + } + if (media != null && !media.isEmpty()) { + ret.append(' '); + ret.append(media.getValueString()); + } + ret.append(';'); + return ret.toString(); + } + + public AtRuleImport(String linkname, boolean is_url, AtRuleMedia media) { + this.media = media; + this.linkname = linkname; + this.is_url = is_url; + } +} + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMedia.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMedia.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,198 @@ +// +// $Id: AtRuleMedia.java,v 1.13 2009-02-12 21:26:34 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleMedia.java + * $Id: AtRuleMedia.java,v 1.13 2009-02-12 21:26:34 ylafon Exp $ + */ +package org.w3c.css.parser; + +import java.util.Enumeration; +import java.util.Vector; + +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; + +/** + * This class manages all media defines by CSS2 + * + * @version $Revision: 1.13 $ + * @author Philippe Le Hegaret + */ +public class AtRuleMedia extends AtRule { + + static final String[] mediaCSS3 = { + "all", "aural", "braille", "embossed", "handheld", "print", + "projection", "screen", "tty", "tv", "presentation", "atsc-tv" + }; + + String restrictor = new String(); + String[] media = new String[mediaCSS3.length]; + // media list coming from the stylesheet (ie. with case) + String[] originalMedia = new String[mediaCSS3.length]; + Vector mediafeatures = new Vector(); + + boolean empty = true; + + /** + * Adds a medium. + * + * @exception InvalidParamException the medium doesn't exist + */ + public AtRuleMedia addMedia(String medium, + ApplContext ac) throws InvalidParamException { + + //This medium didn't exist for CSS2 + // if ((!cssversion.equals("css3")) && medium.equals("presentation")) { + // throw new InvalidParamException("media", medium, ac); + //} + + for (int i = 0; i < mediaCSS3.length; i++) { + if (medium.toLowerCase().equals(mediaCSS3[i])) { + media[i] = mediaCSS3[i]; + originalMedia[i] = medium; + empty = false; + return this; + } + } + + throw new InvalidParamException("media", medium, ac); + } + + public void addMediaRestrictor(String restrictor, ApplContext ac) { + if (restrictor.toUpperCase().equals("ONLY") || + restrictor.toUpperCase().equals("NOT")) { + this.restrictor = restrictor; + } + } + + public void addMediaFeature(CssProperty prop) { + if (prop != null) { + StringBuilder expression = new StringBuilder(prop.getPropertyName()); + String propval = prop.toString(); + if (propval != null) { + expression.append(" : ").append(propval); + } + mediafeatures.addElement(expression.toString()); + } + } + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "media"; + } + + public boolean isEmpty() { + return empty; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + AtRuleMedia second = (AtRuleMedia) atRule; + + for (int i = 0; i < media.length; i++) { + // strings are exactly the same so I don't have to use equals + if (media[i] != second.media[i]) { + return false; + } + } + return true; + } else { + return false; + } + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + AtRuleMedia second = (AtRuleMedia) atRule; + + for (int i = 0; i < media.length; i++) { + // strings are exactly the same so I don't have to use equals + if (media[i] == second.media[i]) { + return true; + } + } + return false; + } else { + return false; + } + } + + public Enumeration elements() { + return new MediaEnumeration(this); + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + StringBuilder ret = new StringBuilder(); + + ret.append('@'); + ret.append(keyword()); + ret.append(' '); + if (!restrictor.equals("")) { + ret.append(restrictor); + ret.append(' '); + } + boolean f = true; + for (int i = 0; i < media.length; i++) { + if (originalMedia[i] != null) { + if (!f) { + ret.append(','); + ret.append(' '); + } else { + f = false; + } + ret.append(originalMedia[i]); + } + } + + for (int i = 0; i < mediafeatures.size(); i++) { + ret.append(" and ("); + ret.append(mediafeatures.elementAt(i)); + ret.append(')'); + } + return ret.toString(); + } + + public String getValueString() { + StringBuilder ret = new StringBuilder(); + if (!restrictor.equals("")) { + ret.append(restrictor); + ret.append(' '); + } + boolean f = true; + for (int i = 0; i < media.length; i++) { + if (originalMedia[i] != null) { + if (!f) { + ret.append(','); + ret.append(' '); + } else { + f = false; + } + ret.append(originalMedia[i]); + } + } + + for (int i = 0; i < mediafeatures.size(); i++) { + ret.append(" and ("); + ret.append(mediafeatures.elementAt(i)); + ret.append(')'); + } + return ret.toString(); + } +} + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMediaCSS1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMediaCSS1.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,99 @@ +// +// $Id: AtRuleMediaCSS1.java,v 1.5 2007-11-26 05:07:17 ot Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleMedia.java + * $Id: AtRuleMediaCSS1.java,v 1.5 2007-11-26 05:07:17 ot Exp $ + */ +package org.w3c.css.parser; + +import java.util.Enumeration; + +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; + +/** + * This class manages all media defines by CSS2 + * + * @version $Revision: 1.5 $ + * @author Philippe Le Hegaret + */ +public class AtRuleMediaCSS1 extends AtRuleMedia { + + static final String[] mediaCSS1 = { + "all" + }; + + String[] media = new String[mediaCSS1.length]; + + boolean empty = true; + + /** + * Creates a new AtRuleMediaCSS1 + */ + public AtRuleMediaCSS1() { + media[0] = mediaCSS1[0]; + } + + + /** + * Adds a medium. + * + * @exception InvalidParamException the medium doesn't exist + */ + public AtRuleMedia addMedia(String medium, + ApplContext ac) throws InvalidParamException { + + // do nothing + return this; + } + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "media"; + } + + public boolean isEmpty() { + return false; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + return true; + } else { + return false; + } + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + return true; + } else { + return false; + } + } + + public Enumeration elements() { + return new MediaEnumeration(this); + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + return "@" + keyword() + " all "; + } + + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMediaCSS2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleMediaCSS2.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,127 @@ +// +// $Id: AtRuleMediaCSS2.java,v 1.5 2007-11-26 05:07:17 ot Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleMedia.java + * $Id: AtRuleMediaCSS2.java,v 1.5 2007-11-26 05:07:17 ot Exp $ + */ +package org.w3c.css.parser; + +import java.util.Enumeration; + +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; + +/** + * This class manages all media defines by CSS2 + * + * @version $Revision: 1.5 $ + * @author Philippe Le Hegaret + */ +public class AtRuleMediaCSS2 extends AtRuleMedia { + + static final String[] mediaCSS2 = { + "all", "aural", "braille", "embossed", "handheld", "print", "projection", + "screen", "tty", "tv", "presentation" + }; + + String[] media = new String[mediaCSS2.length]; + + boolean empty = true; + + /** + * Adds a medium. + * + * @exception InvalidParamException the medium doesn't exist + */ + public AtRuleMedia addMedia(String medium, + ApplContext ac) throws InvalidParamException { + + //This medium didn't exist for CSS2 + // if ((!cssversion.equals("css3")) && medium.equals("presentation")) { + // throw new InvalidParamException("media", medium, ac); + //} + + for (int i = 0; i < mediaCSS2.length; i++) { + if (medium.equals(mediaCSS2[i])) { + media[i] = mediaCSS2[i]; + empty = false; + return this; + } + } + + throw new InvalidParamException("media", medium, ac); + } + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "media"; + } + + public boolean isEmpty() { + return empty; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + AtRuleMedia second = (AtRuleMedia) atRule; + + for (int i = 0; i < media.length; i++) { + // strings are exactly the same so I don't have to use equals + if (media[i] != second.media[i]) { + return false; + } + } + return true; + } else { + return false; + } + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + if (atRule instanceof AtRuleMedia) { + AtRuleMedia second = (AtRuleMedia) atRule; + + for (int i = 0; i < media.length; i++) { + // strings are exactly the same so I don't have to use equals + if (media[i] == second.media[i]) { + return true; + } + } + return false; + } else { + return false; + } + } + + public Enumeration elements() { + return new MediaEnumeration(this); + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + String ret = ""; + for (int i = 0; i < media.length; i++) { + if (media[i] != null) { + ret += ", " + media[i]; + } + } + return "@" + keyword() + " " + ret.substring(2); + } + + +} + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleNamespace.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRuleNamespace.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,75 @@ +// +// $Id: AtRuleNamespace.java,v 1.1 2009-02-13 14:03:36 ylafon Exp $ +// +// (c) COPYRIGHT MIT, Keio University and ERCIM, 2009. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRuleMedia.java + * $Id: AtRuleNamespace.java,v 1.1 2009-02-13 14:03:36 ylafon Exp $ + */ +package org.w3c.css.parser; + +/** + * This class manages all imports + * + * @version $Revision: 1.1 $ + * @author Philippe Le Hegaret + */ +public class AtRuleNamespace extends AtRule { + + boolean is_default = false; + boolean is_url = false; + String prefix = null; + String nsname = null; + + public String keyword() { + return "namespace"; + } + + public boolean isEmpty() { + return true; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + return false; + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + return false; + } + + + /** + * Returns a string representation of the object. + */ + public String toString() { + StringBuilder ret = new StringBuilder(); + + ret.append('@'); + ret.append(keyword()); + ret.append(' '); + if (!is_default) { + ret.append(prefix); + ret.append(' '); + } + ret.append((is_url) ? "url(\"" : '\"'); + ret.append(nsname); + ret.append((is_url) ? "\")" : '\"'); + ret.append(';'); + return ret.toString(); + } + + public AtRuleNamespace(String prefix, String nsname, boolean is_url) { + this.prefix = prefix; + is_default = (prefix == null); + this.nsname = nsname; + this.is_url = is_url; + } +} + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePage.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,164 @@ +// +// $Id: AtRulePage.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRulePage.java + * $Id: AtRulePage.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ + */ +package org.w3c.css.parser; + +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; + + +/** + * This class manages all media defines by CSS2 + * + * @version $Revision: 1.4 $ + * @author Philippe Le H�garet + */ +public class AtRulePage extends AtRule { + + static final String[] pseudo = { + ":left", ":right", ":first" + }; + + String name; + + String ident; + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "page"; + } + + /** + * Sets the name of the page + * name will be a pseudo name :first, :left, :right + * or a random name without semi-colon at the beginning + */ + public AtRulePage setName(String name, ApplContext ac) + throws InvalidParamException { + if (name.charAt(0) == ':') { + for (int i = 0; i < pseudo.length; i++) { + if (name.equals(pseudo[i])) { + this.name = pseudo[i]; + return this; + } + } + throw new InvalidParamException("page", name, ac); + } else { + this.name = name; + } + + return this; + } + + public AtRulePage setIdent(String ident) { + this.ident = ident; + return this; + } + + public String getIdent() { + return ident; + } + + /** + * Return true if atRule is exactly the same as current + */ + public boolean equals(Object atRule) { + if (atRule instanceof AtRulePage) { + AtRulePage other = (AtRulePage) atRule; + boolean res = true; + if ((name != null) && (other.name != null)) { + res = res && name.equals(other.name); + } else { + if ((name != null) || (other.name != null)) { + return false; + } + } + if ((ident != null) && (other.ident != null)) { + res = res && ident.equals(((AtRulePage) atRule).ident); + } else { + if ((ident != null) || (other.ident != null)) { + return false; + } + } + return res; + } else { + return false; + } + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + if (atRule instanceof AtRulePage) { + AtRulePage other = (AtRulePage) atRule; + boolean res = true; + if ((name != null) && (other.name != null)) { + res = res && name.equals(other.name); + } else { + if ((name != null) || (other.name != null)) { + return false; + } + } + if ((ident != null) && (other.ident != null)) { + res = res && ident.equals(((AtRulePage) atRule).ident); + } else { + if ((ident != null) || (other.ident != null)) { + return false; + } + } + return res; + } else { + return false; + } + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + if (atRule instanceof AtRulePage) { + boolean res = true; + if (name != null) { + res = res && name.equals(((AtRulePage) atRule).name); + } + if (ident != null) { + res = res && ident.equals(((AtRulePage) atRule).ident); + } + return res; + } else { + return false; + } + } + + + public String getName() { + return name; + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + String ret = "@" + keyword() ; + if (ident!=null) { + ret += " " + ident; + if (name!=null) { + ret += name; + } + } else if (name != null) { + ret += " " + name; + } + return ret; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePhoneticAlphabet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePhoneticAlphabet.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,80 @@ +// +// $Id: AtRulePhoneticAlphabet.java,v 1.2 2007-11-26 05:07:17 ot Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + * AtRulePhoneticAlphabet.java + * $Id: AtRulePhoneticAlphabet.java,v 1.2 2007-11-26 05:07:17 ot Exp $ + */ +package org.w3c.css.parser; + +import org.w3c.css.util.ApplContext; + +/** + * + * @version $Revision: 1.2 $ + * @author Philippe Le Hegaret + */ +public class AtRulePhoneticAlphabet extends AtRule { + static int internal = 0; + int hash; + String alphabet = "ipa"; + + /** + * Create a new AtRulePhoneticAlphabet + */ + public AtRulePhoneticAlphabet() { + hash = ++internal; + } + + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "phonetic-alphabet"; + } + + public void addAlphabet(String alphabet, ApplContext ac) { + this.alphabet = alphabet; + } + + /** + * The second must be exactly the same of this one + */ + public boolean canApply(AtRule atRule) { + return (atRule instanceof AtRulePhoneticAlphabet); + } + + /** + * Return true if other is an instance of AtRUlePhoneticAlphabet + */ + public boolean equals(Object other) { + return (other instanceof AtRulePhoneticAlphabet); + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + return (atRule instanceof AtRulePhoneticAlphabet); + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + return "@" + keyword() + " " + alphabet; + } + + public int hashCode() { + return hash; + } + + public boolean isEmpty() { + return true; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePreference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/AtRulePreference.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,63 @@ +// +// $Id: AtRulePreference.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ +// From Sijtsche de Jong (sy.de.jong@let.rug.nl) +// +// (c) COPYRIGHT 1995-2000 World Wide Web Consortium (MIT, INRIA, Keio University) +// Please first read the full copyright statement at +// http://www.w3.org/Consortium/Legal/copyright-software-19980720 + +package org.w3c.css.parser; + + +public class AtRulePreference extends AtRule { + + static int internal = 0; + int hash; + + /** + * Create a new AtRulePreference + */ + public AtRulePreference() { + hash = ++internal; + } + + /** + * Returns the at rule keyword + */ + public String keyword() { + return "preference"; + } + + /** + * The second must be exactly the same as this one + */ + public boolean canApply(AtRule atRule) { + return (atRule instanceof AtRuleFontFace); + } + + /** + * Return true if other is an instance of AtRulePreference + */ + public boolean equals(Object other) { + return (other instanceof AtRulePreference); + } + + /** + * The second must only match this one + */ + public boolean canMatched(AtRule atRule) { + return (atRule instanceof AtRulePreference); + } + + /** + * Returns a string representation of the object + */ + public String toString() { + return "@" + keyword(); + } + + public int hashCode() { + return hash; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssError.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssError.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,90 @@ +// +// $Id: CssError.java,v 1.6 2009-02-25 20:44:49 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import org.w3c.css.util.Messages; + +/** + * This class represents an unknown error during the parse. + * + * @version $Revision: 1.6 $ + */ +public class CssError { + + /** + * The source file + */ + String sourceFile; + + /** + * The line number in the file + */ + int line; + + /** + * The unknown error + */ + Throwable error; + + /** + * Create a new CssError + */ + public CssError() { + } + + /** + * Create a new CssError + * + * @param sourceFile The source file + * @param line The error line number + * @param error The exception + */ + public CssError(String sourceFile, int line, Throwable error) { + this.sourceFile = sourceFile; + this.line = line; + this.error = error; + } + + /** + * Create a new CssError + * + * @param error The exception + */ + public CssError(Throwable error) { + this.error = error; + } + + /** + * Get the source file + */ + public String getSourceFile() { + return sourceFile; + } + + /** + * Get the source file + */ + public String getSourceFileEscaped() { + return Messages.escapeString(sourceFile); + } + + + /** + * get the line number + */ + public int getLine() { + return line; + } + + /** + * get the unknown error + */ + public Throwable getException() { + return error; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssErrorToken.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssErrorToken.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,89 @@ +// +// $Id: CssErrorToken.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.Vector; + +/** + * @version $Revision: 1.4 $ + */ +public class CssErrorToken extends CssError { + + /** + * The list of context when the error appears + */ + Vector context; + + /** + * the property name + */ + String property; + + /** + * the string description of the error + */ + String errorString; + + /** + * the expected text + */ + String[] expectedTokens; + + /** + * the skipped text + */ + String skippedString; + + /** + * Create a new CssErrorToken. + * + * @param lin The line number + * @param error The string description of the error + * @param expected The expected text + */ + CssErrorToken(int lin, String error, String[] expected) { + line = lin; + errorString = error; + expectedTokens = expected; + } + + /** + * Get contexts + */ + public Vector getContexts() { + return context; + } + + /** + * Get the name of the property. + */ + public String getPropertyName() { + return property; + } + + /** + * Get the string description of the error. + */ + public String getErrorDescription() { + return errorString; + } + + /** + * Get the expected text. + */ + public String[] getExpected() { + return expectedTokens; + } + + /** + * Get the skipped text. + */ + public String getSkippedString() { + return skippedString; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssFouffa.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssFouffa.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,973 @@ +// +// $Id: CssFouffa.java,v 1.52 2009-02-16 17:53:39 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT, ERCIM and Keio, 2003. +// Please first read the full copyright statement in file COPYRIGHT.html +/* + This class is the front end of the CSS parser +*/ + +package org.w3c.css.parser; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.Enumeration; +import java.util.Vector; + +import java.nio.charset.Charset; + +import org.w3c.css.css.StyleSheetOrigin; +import org.w3c.css.parser.analyzer.CssParser; +import org.w3c.css.parser.analyzer.CssParserTokenManager; +import org.w3c.css.parser.analyzer.ParseException; +import org.w3c.css.parser.analyzer.TokenMgrError; +import org.w3c.css.properties.PropertiesLoader; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.HTTPURL; +import org.w3c.css.util.InvalidParamException; +// import org.w3c.css.util.Utf8Properties; +import org.w3c.css.util.Util; +import org.w3c.css.values.CssExpression; + +/** + * This class is a front end of the CSS1 parser. + * + *

+ * Example:
+ * + * CssFouffa parser = + * new CssFouffa(new URL("http://www.w3.org/drafts.css"));
+ * CssValidatorListener myListener = new MyParserListener();
+ *
+ * parser.addListener(myListener);
+ * parser.parseStyle();
+ *
+ * + * @version $Revision: 1.52 $ + */ +public final class CssFouffa extends CssParser { + + // all properties + CssPropertyFactory properties = null; + + // static CssPropertyFactory __s_nullprop = null; + // + // static CssPropertyFactory __s_css1prop = null; + // + // static CssPropertyFactory __s_asc_tvprop = null; + // + // static CssPropertyFactory __s_css2prop = null; + // + // static CssPropertyFactory __s_css2mobileprop = null; + // + // static CssPropertyFactory __s_css2tvprop = null; + // + // static CssPropertyFactory __s_css3prop = null; + // + // static CssPropertyFactory __s_svgprop = null; + // + // static CssPropertyFactory __s_svgtinyprop = null; + // + // static CssPropertyFactory __s_svgbasicprop = null; + // + // static private Utf8Properties config = null; + + // all listeners + Vector listeners; + + // all errors + Errors errors; + + // origin of the style sheet + int origin; + + Vector visited = null; + + /** + * Create a new CssFouffa with a data input and a begin line number. + * + * @param input + * data input + * @param file + * The source file (use for errors, warnings and import) + * @param beginLine + * The begin line number in the file. (used for HTML for example) + * @exception IOException + * if an I/O error occurs. + */ + public CssFouffa(ApplContext ac, InputStream input, String charset, + URL file, int beginLine) + throws IOException + { + super(new InputStreamReader(input, (charset == null) ? + "iso-8859-1" : charset)); + if (ac.getOrigin() == -1) { + setOrigin(StyleSheetOrigin.AUTHOR); // default is user + } else { + setOrigin(ac.getOrigin()); // default is user + } + ac.setFrame(new Frame(this, file.toString(), beginLine, + ac.getWarningLevel())); + setApplContext(ac); + // @@this is a default media ... + /* + * AtRuleMedia media = new AtRuleMedia(); + * + * if (ac.getMedium() == null) { try { media.addMedia("all", ac); } + * catch (InvalidParamException e) {} //ignore } else { try { + * media.addMedia(ac.getMedium(), ac); } catch (Exception e) { + * System.err.println(e.getMessage()); try { media.addMedia("all", ac); } + * catch (InvalidParamException ex) {} //ignore } } setAtRule(media); + */ + setURL(file); + if (Util.onDebug) { + System.err.println("[DEBUG] CSS version " + ac.getCssVersion() + + " medium " + ac.getMedium() + " at-rule " + + getAtRule() + " profile " + ac.getProfile()); + } + + String profile = ac.getProfile(); + if (profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + // loadConfig(ac.getCssVersion(), ac.getProfile()); + // load the CssStyle + String classStyle = PropertiesLoader.config.getProperty(profile); + if (classStyle == null) { + classStyle = PropertiesLoader.config.getProperty("css2"); + } + + Class style; + try { + style = Class.forName(classStyle); + ac.setCssSelectorsStyle(style); + } catch (ClassNotFoundException e) { + System.err.println("org.w3c.css.parser.CssFouffa: couldn't" + + " load the style"); + e.printStackTrace(); + } + + properties = new CssPropertyFactory(profile); + listeners = new Vector(); + } + + /** + * Create a new CssFouffa with a data input. + * + * @param input + * data input + * @param file + * The source file (use for errors, warnings and import) + * @exception IOException + * if an I/O error occurs. + */ + public CssFouffa(ApplContext ac, InputStream input, URL file) + throws IOException + { + this(ac, input, (ac.getCharsetForURL(file) != null) ? + ac.getCharsetForURL(file):"iso-8859-1", file, 0); + } + + /** + * Create a new CssFouffa. + * + * @param file + * The source file (use for data input, errors, warnings and + * import) + * @exception IOException + * if an I/O error occurs. + */ + public CssFouffa(ApplContext ac, URL file) throws IOException { + this(ac, HTTPURL.getConnection(file, ac)); + + } + + /** + * Create a new CssFouffa. internal, to get the URLCOnnection and fill the + * URL with the relevant one + */ + + private CssFouffa(ApplContext ac, URLConnection uco) throws IOException { + this(ac, HTTPURL.getInputStream(ac, uco), + HTTPURL.getCharacterEncoding(ac,uco), uco.getURL(), 0); + String httpCL = uco.getHeaderField("Content-Location"); + if (httpCL != null) { + setURL(HTTPURL.getURL(getURL(), httpCL)); + } + } + + /** + * Create a new CssFouffa. Used by handleImport. + * + * @param file + * The source file (use for data input, errors, warnings and + * import) + * @param listeners + * Works with this listeners + * @exception IOException + * if an I/O error occurs. + */ + private CssFouffa(ApplContext ac, InputStream in, URL url, + Vector listeners, + Vector urlvisited, + CssPropertyFactory cssfactory, boolean mode) + throws IOException + { + this(ac, in, ac.getCharsetForURL(url), url, 0); + this.visited = urlvisited; + setURL(url); + ac.setFrame(new Frame(this, url.toString(), ac.getWarningLevel())); + setApplContext(ac); + this.listeners = listeners; + this.properties = cssfactory; + this.mode = mode; + } + + private void ReInit(ApplContext ac, InputStream input, + URL file, Frame frame) { + // reinitialize the parser with a new data input + // and a new frame for errors and warnings + super.ReInitWithAc(input, ac, ac.getCharsetForURL(file)); + // @@this is a default media ... + // AtRuleMedia media; + // if ("css1".equals(ac.getCssVersion())) { + // media = new AtRuleMediaCSS1(); + // } else if ("css2".equals(ac.getCssVersion())) { + // media = new AtRuleMediaCSS2(); + // } else { + // media = new AtRuleMediaCSS2(); + // } + /* + * if (ac.getMedium() == null) { try { media.addMedia("all", ac); } + * catch (InvalidParamException e) {} //ignore } else { try { + * media.addMedia(ac.getMedium(), ac); } catch (Exception e) { + * System.err.println(e.getMessage()); try { media.addMedia("all", ac); } + * catch (InvalidParamException ex) {} //ignore } } setAtRule(media); + */ + setURL(file); + if (Util.onDebug) { + System.err.println("[DEBUG] CSS version " + ac.getCssVersion() + " medium " + ac.getMedium() + " profile " + + ac.getProfile()); + } + + String profile = ac.getProfile(); + if (profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + // load the CssStyle + String classStyle = PropertiesLoader.config.getProperty(profile); + if (classStyle == null) { + classStyle = PropertiesLoader.config.getProperty("css2"); + } + + Class style; + try { + style = Class.forName(classStyle); + ac.setCssSelectorsStyle(style); + } catch (ClassNotFoundException e) { + System.err.println("org.w3c.css.parser.CssFouffa: couldn't" + " load the style"); + e.printStackTrace(); + } + + properties = new CssPropertyFactory(profile); + // loadConfig(ac.getCssVersion(), ac.getProfile()); + } + + /** + * Reinitializes a new CssFouffa with a data input and a begin line number. + * + * @param input + * data input + * @param file + * The source file (use for errors, warnings and import) + * @param beginLine + * The begin line number in the file. (used for HTML for example) + * @exception IOException + * if an I/O error occurs. + */ + public void ReInit(ApplContext ac, InputStream input, URL file, + int beginLine) + throws IOException + { + Frame f = new Frame(this, file.toString(), beginLine, + ac.getWarningLevel()); + ac.setFrame(f); + ReInit(ac, input, file, f); + } + + /** + * Reinitializes a new CssFouffa with a data input. + * + * @param input + * data input + * @param file + * The source file (use for errors, warnings and import) + * @exception IOException + * if an I/O error occurs. + */ + public void ReInit(ApplContext ac, InputStream input, URL file) + throws IOException + { + Frame f = new Frame(this, file.toString(), ac.getWarningLevel()); + ac.setFrame(f); + ReInit(ac, input, file, f); + } + + /** + * Reinitializes a new CssFouffa. + * + * @param file + * The source file (use for data input, errors, warnings and + * import) + * @exception IOException + * if an I/O error occurs. + */ + public void ReInit(ApplContext ac, URL file) throws IOException { + InputStream is; + URL url; + Frame f; + + f = new Frame(this, file.toString(), ac.getWarningLevel()); + ac.setFrame(f); + if (ac.isInputFake()) { + is = ac.getFakeInputStream(file); + url = file; + } else { + URLConnection urlC = HTTPURL.getConnection(file, ac); + is = HTTPURL.getInputStream(ac, urlC); + url = urlC.getURL(); + } + ReInit(ac, is, url, f); + } + + /** + * Set the attribute origin + * + * @param origin + * the new value for the attribute + */ + private final void setOrigin(int origin) { + this.origin = origin; + } + + /** + * Returns the attribute origin + * + * @return the value of the attribute + */ + public final int getOrigin() { + return origin; + } + + /** + * Adds a listener to the parser. + * + * @param listener + * The listener + * @see org.w3c.css.parser.CssValidatorListener + */ + public final void addListener(CssValidatorListener listener) { + listeners.addElement(listener); + } + + /** + * Removes a listener from the parser + * + * @param listener + * The listener + * @see org.w3c.css.parser.CssValidatorListener + */ + public final void removeListener(CssValidatorListener listener) { + listeners.removeElement(listener); + } + + /** + * Parse the style sheet. This is the main function of this parser. + * + *

+ * Example:
+ * + * CssFouffa parser = new CssFouffa(new + * URL("http://www.w3.org/drafts.css"));
+ * CssValidatorListener myListener = new MyParserListener();
+ *
+ * parser.addListener(myListener);
+ * parser.parseStyle();
+ *
+ * + * @see org.w3c.css.parser.CssFouffa#addListener + */ + public void parseStyle() { + try { + parserUnit(); + } catch (TokenMgrError e) { + throw e; + } catch (Throwable e) { + if (Util.onDebug) { + e.printStackTrace(); + } + RuntimeException ne = new RuntimeException(e.getMessage()); + ne.fillInStackTrace(); + throw (ne); + } + + // That's all folks, notify all errors and warnings + for (Enumeration e = listeners.elements(); + e.hasMoreElements();) { + CssValidatorListener listener; + listener = e.nextElement(); + listener.notifyErrors(ac.getFrame().getErrors()); + listener.notifyWarnings(ac.getFrame().getWarnings()); + } + } + + /** + * Call the namespace declaration statement + * @param url, the style sheet where this declaration statement appears. + * @param prefix, the namespace prefix + * @param nsname, the file/url name in the declaration statement + * @param is_url, if the nsname is a file or an url + */ + public void handleNamespaceDeclaration(URL url, String prefix, + String nsname, + boolean is_url) { + AtRuleNamespace nsrule = new AtRuleNamespace(prefix, nsname, is_url); + newAtRule(nsrule); + endOfAtRule(); + // add the NS in the global context definition + ac.setNamespace(url, prefix, nsname); + } + /** + * Call by the import statement. + * + * @param url + * The style sheet where this import statement appears. + * @param file + * the file name in the import statement + */ + public void handleImport(URL url, String file, boolean is_url, + AtRuleMedia media) { + // CssError cssError = null; + AtRuleImport importrule = new AtRuleImport(file, is_url, media); + newAtRule(importrule); + endOfAtRule(); + + //if it's not permitted to import... (direct input) + if (url.getProtocol().equals("file")) { + ac.getFrame().addWarning("unsupported-import"); + return; + } + + try { + URL importedURL = HTTPURL.getURL(url, file); + String surl = importedURL.toString(); + + if (visited == null) { + visited = new Vector(2); + } else { + // check that we didn't already got this URL, or that the + // number of imports is not exploding + if (visited.contains(surl)) { + CssError cerr = new CssError(new Exception("Import loop" + + " detected in "+ + surl)); + ac.getFrame().addError(cerr); + return; + } else if (visited.size() > 42) { + CssError cerr = new CssError(new Exception("Maximum number"+ + " of imports " + + "reached")); + ac.getFrame().addError(cerr); + return; + } + } + Vector newVisited = new Vector(visited); + newVisited.addElement(surl); + + if (Util.importSecurity) { + throw new FileNotFoundException("[SECURITY] You can't " + + "import URL sorry."); + } + + URLConnection importURL = HTTPURL.getConnection(importedURL, ac); + String charset = HTTPURL.getCharacterEncoding(ac, importURL); + + if (importURL instanceof HttpURLConnection) { + HttpURLConnection httpURL = (HttpURLConnection) importURL; + String httpCL = httpURL.getHeaderField("Content-Location"); + if (httpCL != null) { + importedURL = HTTPURL.getURL(importedURL, httpCL); + } + String mtype = httpURL.getContentType(); + if (mtype == null) { + throw new FileNotFoundException(importURL.getURL() + + "No Media Type defined"); + } else { + if (mtype.toLowerCase().indexOf("text/html") != -1) { + throw new FileNotFoundException(importURL.getURL() + + ": You can't import" + + " an HTML document"); + } + } + } + Frame f = ac.getFrame(); + try { + CssFouffa cssFouffa = new CssFouffa(ac, + HTTPURL.getInputStream(ac, importURL), + importedURL, listeners, newVisited, + properties, mode); + cssFouffa.setOrigin(getOrigin()); + if (!media.isEmpty()) { + cssFouffa.setAtRule(media); + } else { + cssFouffa.setAtRule(getAtRule()); + } + cssFouffa.parseStyle(); + } finally { + ac.setFrame(f); + } + } catch (Exception e) { + if (!Util.noErrorTrace) { + ac.getFrame().addError(new CssError(e)); + } + } + } + + /** + * Call by the at-rule statement. + * + * @param ident + * The ident for this at-rule (for example: 'font-face') + * @param string + * The string representation of this at-rule + */ + public void handleAtRule(String ident, String string) { + if (mode) { + Enumeration e = listeners.elements(); + while (e.hasMoreElements()) { + CssValidatorListener listener = e.nextElement(); + listener.handleAtRule(ac, ident, string); + } + } else { + if (!Util.noErrorTrace) { + // only @import ; or @import ; are valids in CSS1 + ParseException error = new ParseException("at-rules are not implemented in CSS1"); + ac.getFrame().addError(new CssError(error)); + } + } + } + + /** + * Assign an expression to a property. This function create a new property + * with property and assign to it the expression with the + * importance. + * + * @param property + * the name of the property + * @param expression + * The expression representation of expression + * @param important + * true if expression id important + * @param InvalidParamException + * An error appears during the property creation. + * @return a CssProperty + */ + public CssProperty handleDeclaration(String property, CssExpression expression, boolean important) + throws InvalidParamException { + CssProperty prop; + if (Util.onDebug) { + System.err.println("Creating " + property + ": " + expression); + } + + try { + if (getMediaDeclaration().equals("on") && (getAtRule() instanceof AtRuleMedia)) { + prop = properties.createMediaFeature(ac, getAtRule(), property, expression); + } else { + prop = properties.createProperty(ac, getAtRule(), property, expression); + } + + } catch (InvalidParamException e) { + throw e; + } catch (Exception e) { + if (Util.onDebug) { + e.printStackTrace(); + } + throw new InvalidParamException(e.toString(), ac); + } + + // set the importance + if (important) { + prop.setImportant(); + } + prop.setOrigin(origin); + // set informations for errors and warnings + prop.setInfo(ac.getFrame().getLine(), ac.getFrame().getSourceFile()); + + // ok, return the new property + return prop; + + } + + /** + * Parse only a list of declarations. This is useful to parse the + * STYLE attribute in a HTML document. + * + *

+ * Example:
+ * + * CssFouffa parser = + * new CssFouffa(new URL("http://www.w3.org/drafts.css"));
+ * CssValidatorListener myListener = new MyParserListener();
+ * CssSelector selector = new CssSelector(); + * selector.setElement("H1"); + *
+ * parser.addListener(myListener);
+ * parser.parseDeclarations(selector);
+ *
+ * + * @param context + * The current context + * @see org.w3c.css.parser.CssFouffa#addListener + * @see org.w3c.css.parser.CssSelectors#setElement + */ + public void parseDeclarations(CssSelectors context) { + // here we have an example for reusing the parser. + try { + Vector properties = declarations(); + + if (properties != null && properties.size() != 0) { + handleRule(context, properties); + } + } catch (ParseException e) { + if (!Util.noErrorTrace) { + CssParseException ex = new CssParseException(e); + ex.skippedString = ""; + ex.property = currentProperty; + ex.contexts = currentContext; + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + } + } + + if (!Util.noErrorTrace) { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + CssValidatorListener listener = e.nextElement(); + listener.notifyErrors(ac.getFrame().getErrors()); + listener.notifyWarnings(ac.getFrame().getWarnings()); + } + } + } + + /** + * used for the output of the stylesheet + * + * @param atRule + * the + * @rule that just has been found by the parser in the stylesheet, it is + * added to the storage for the output + */ + public void newAtRule(AtRule atRule) { + for (Enumeration e = listeners.elements(); + e.hasMoreElements();) { + e.nextElement().newAtRule(atRule); + } + } + + /** + * used for the output of the stylesheet + * + * @param charset + * the + * @charset rule that has been found by the parser + */ + public void addCharSet(String charset) { + for (Enumeration e = listeners.elements(); + e.hasMoreElements();) { + e.nextElement().addCharSet(charset); + } + Charset c = null; + try { + c = Charset.forName(charset); + } catch (Exception ex) { + return; + } + Charset originalCharset = ac.getCharsetObjForURL(getURL()); + if (originalCharset == null) { + ac.setCharsetForURL(getURL(), c); + try { + ReInit(ac, getURL()); + } catch (IOException ioex) {} + } else if (c.compareTo(originalCharset) != 0) { + Exception ex = new Exception("Conflicting charset definition "+ + "between network and @charset "+ + originalCharset+" and "+charset); + CssError cerr = new CssError(ex); + ac.getFrame().addError(cerr); + } + } + + /** + * used for the output of the stylesheet the + * + * @rule that had been found before is closed here after the content that's + * in it. + */ + public void endOfAtRule() { + for (Enumeration e = listeners.elements(); + e.hasMoreElements();) { + e.nextElement().endOfAtRule(); + } + } + + /** + * used for the output of the stylesheet + * + * @param important + * true if the rule was declared important in the stylesheet + */ + public void setImportant(boolean important) { + for (Enumeration e = listeners.elements(); + e.hasMoreElements();) { + e.nextElement().setImportant(important); + } + } + + /** + * used for the output of the stylesheet + * + * @param selectors + * a list of one or more selectors to be added to the output + * stylesheet + */ + public void setSelectorList(Vector selectors) { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().setSelectorList(selectors); + } + } + + /** + * used for the output of the stylesheet + * + * @param properties + * A list of properties that are following eachother in the + * stylesheet (for example: all properties in an + * @rule) + */ + public void addProperty(Vector properties) { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().setProperty(properties); + } + } + + /** + * used for the output of the stylesheet used to close a rule when it has + * been read by the parser + */ + public void endOfRule() { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().endOfRule(); + } + } + + /** + * used for the output of the stylesheet if an error is found this function + * is used to remove the whole stylerule from the memorystructure so that it + * won't appear on the screen + */ + public void removeThisRule() { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().removeThisRule(); + } + } + + /** + * used for the output of the stylesheet if an error is found this function + * is used to remove the whole + * + * @rule from the memorystructure so that it won't appear on the screen + */ + public void removeThisAtRule() { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().removeThisAtRule(); + } + } + + /** + * Adds a vector of properties to a selector. + * + * @param selector + * the selector + * @param declarations + * Properties to associate with contexts + */ + public void handleRule(CssSelectors selector, Vector declarations) { + for (Enumeration e = listeners.elements(); e.hasMoreElements();) { + e.nextElement().handleRule(ac, selector, declarations); + } + } + + /** + * Return the class name for a property + * + * @param property + * the property name ('font-size' for example) + * @return the class name ('org.w3c.css.properties.CssFontSize' for example) + */ + public String getProperty(String property) { + return properties.getProperty(property); + } + + /** + * Set the style + */ + public void setStyle(Class style) { + ac.setCssSelectorsStyle(style); + } + + /** + * Load the parser properties configuration. + * + *

+ * By default, the parser is configure for cascading style sheet 1. + * + *

    + * You have three parser properties : + *
  1. style: the class name of your CssStyle. + *
  2. properties: the file name where the parser can find all CSS + * properties names. + *
  3. extended-parser: true if you want to parse cascading + * style sheet 2 or 3. + *
      + */ + /* + * public void loadConfig(String version, String profile) { try { + * + * URL allprops = CssFouffa.class.getResource("allcss.properties"); URL url = + * null; + * + * if (version == null) { // load the CssStyle String classStyle = + * config.getProperty("style2"); Class style = Class.forName(classStyle); + * ac.setCssSelectorsStyle(style); + * + * properties = __s_nullprop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * (version.equals("css1")) { // load the CssStyle String classStyle = + * config.getProperty("style1"); Class style = Class.forName(classStyle); + * ac.setCssSelectorsStyle(style); + * + * if (__s_css1prop == null) { // css1 url = + * style.getResource(config.getProperty("properties1")); __s_css1prop = new + * CssPropertyFactory(url, allprops); } // load properties properties = + * __s_css1prop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * ("atsc-tv".equals(profile)) { String classStyle = + * config.getProperty("styleatsc"); Class style = Class.forName(classStyle); + * ac.setCssSelectorsStyle(style); if (__s_asc_tvprop == null) { url = + * style.getResource(config.getProperty("atsc-tv")); __s_asc_tvprop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_asc_tvprop.getClone(); } else if (version.equals("css2")) { // load + * the CssStyle String classStyle = config.getProperty("style2"); Class + * style = Class.forName(classStyle); ac.setCssSelectorsStyle(style); + * // load properties if (profile == null || "".equals(profile)) { + * properties = __s_css2prop.getClone(); } else if + * (profile.equals("mobile")) { if (__s_css2mobileprop == null) { url = + * style.getResource(config.getProperty("mobile")); __s_css2mobileprop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_css2mobileprop.getClone(); } else if (profile.equals("tv")) { if + * (__s_css2tvprop == null) { // css2-tv url = + * style.getResource(config.getProperty("tv")); __s_css2tvprop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_css2tvprop.getClone(); } + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * (version.equals("css3")) { // load the CssStyle String classStyle = + * config.getProperty("style3"); Class style = Class.forName(classStyle); + * ac.setCssSelectorsStyle(style); + * // load properties if (__s_css3prop == null) { url = + * style.getResource(config.getProperty("properties3")); __s_css3prop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_css3prop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * (version.equals("svg")) { // load the CssStyle String classStyle = + * config.getProperty("svgstyle"); Class style = Class.forName(classStyle); + * ac.setCssSelectorsStyle(style); + * + * if (__s_svgprop == null) { url = + * style.getResource(config.getProperty("svg")); __s_svgprop = new + * CssPropertyFactory(url, allprops); } properties = __s_svgprop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * (version.equals("svgtiny")) { // load the CssStyle String classStyle = + * config.getProperty("svgtinystyle"); Class style = + * Class.forName(classStyle); ac.setCssSelectorsStyle(style); + * + * if (__s_svgtinyprop == null) { url = + * style.getResource(config.getProperty("svgtiny")); __s_svgtinyprop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_svgtinyprop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } else if + * (version.equals("svgbasic")) { // load the CssStyle String classStyle = + * config.getProperty("svgbasicstyle"); Class style = + * Class.forName(classStyle); ac.setCssSelectorsStyle(style); + * + * if (__s_svgbasicprop == null) { url = + * style.getResource(config.getProperty("svgbasic")); __s_svgbasicprop = new + * CssPropertyFactory(url, allprops); } properties = + * __s_svgbasicprop.getClone(); + * // aural mode String mode0 = config.getProperty("extended-parser"); if + * (mode0 != null) { mode = mode0.equals("true"); } } + * } catch (Exception e) { + * System.err.println("org.w3c.css.parser.CssFouffa: couldn't" + " load the + * style"); e.printStackTrace(); } } + */ + + /* config by default! */ + /* + * static { try { config = new Utf8Properties(); URL url = + * CssFouffa.class.getResource("Config.properties"); java.io.InputStream f = + * url.openStream(); config.load(f); f.close(); // null URL allprops = + * CssFouffa.class.getResource("allcss.properties"); String classStyle = + * config.getProperty("style2"); Class style = Class.forName(classStyle); + * url = style.getResource(config.getProperty("properties2")); __s_nullprop = + * new CssPropertyFactory(url, allprops); + * // css2 // classStyle = config.getProperty("style2"); // style = + * Class.forName(classStyle); // url = + * style.getResource(config.getProperty("properties2")); // __s_css2prop = + * new CssPropertyFactory(url, allprops); __s_css2prop = __s_nullprop; + * } catch (Exception e) { + * System.err.println("org.w3c.css.parser.CssFouffa: couldn't" + " load the + * config"); e.printStackTrace(); } } + */ + + public CssFouffa(java.io.InputStream stream) { + super(stream); + properties = new CssPropertyFactory("css2"); + // loadConfig("css2", null); + } + + public CssFouffa(java.io.Reader stream) { + super(stream); + properties = new CssPropertyFactory("css2"); + // loadConfig("css2", null); + } + + public CssFouffa(CssParserTokenManager tm) { + super(tm); + properties = new CssPropertyFactory("css2"); + // loadConfig("css2", null); + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssParseException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssParseException.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,150 @@ +// +// $Id: CssParseException.java,v 1.5 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.Vector; + +import org.w3c.css.parser.analyzer.ParseException; +import org.w3c.css.values.CssExpression; + +/** + * @version $Revision: 1.5 $ + */ +public class CssParseException extends ParseException { + + /** + * The list of context when the error appears + */ + Vector contexts; + + /** + * the property name + */ + String property; + + /** + * the skipped text + */ + String skippedString; + + /** + * An expression + */ + CssExpression exp; + + /** + * The real exception + */ + Exception parseException; + + private boolean error; + + /** + * Create a new CssParseException + */ + public CssParseException(Exception exc) { + parseException = exc; + if (parseException instanceof ParseException) { + ParseException e = (ParseException) exc; + error = (e.currentToken != null + && e.expectedTokenSequences != null + && e.tokenImage != null); + } + } + + public Exception getException() { + return parseException; + } + + public boolean isParseException() { + return (parseException instanceof ParseException); + } + + /** + * Get the exception message + */ + public String getMessage() { + if (!error) { + return parseException.getMessage(); + } else { + return null; + } + } + + /** + * Set the attribute contexts + * + * @param contexts the new value for the attribute + */ + public void setContexts(Vector contexts) { + this.contexts = contexts; + } + + /** + * Returns the attribute contexts + * + * @return the value of the attribute + */ + public Vector getContexts() { + return contexts; + } + + /** + * Set the attribute property + * + * @param property the new value for the attribute + */ + public void setProperty(String property) { + this.property = property; + } + + /** + * Returns the attribute property + * + * @return the value of the attribute + */ + public String getProperty() { + return property; + } + + /** + * Set the attribute skippedString + * + * @param skippedString the new value for the attribute + */ + public void setSkippedString(String skippedString) { + this.skippedString = skippedString; + } + + /** + * Returns the attribute skippedString + * + * @return the value of the attribute + */ + public String getSkippedString() { + return skippedString; + } + + /** + * Set the attribute exp + * + * @param exp the new value for the attribute + */ + public void setExp(CssExpression exp) { + this.exp = exp; + } + + /** + * Returns the attribute exp + * + * @return the value of the attribute + */ + public CssExpression getExp() { + return exp; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssPrinterStyle.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssPrinterStyle.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,28 @@ +// +// $Id: CssPrinterStyle.java,v 1.4 2005-09-08 12:23:33 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import org.w3c.css.properties.css1.CssProperty; + +/** + * This class is invoke by all propperties when a print is required. + * + * @version $Revision: 1.4 $ + * @see org.w3c.css.parser.CssStyle#print + */ +public interface CssPrinterStyle { + + /** + * Print this property. + * + * @param property The property to print. + * @see org.w3c.css.properties.css1.CssProperty#toString + * @see org.w3c.css.properties.css1.CssProperty#getPropertyName + */ + public void print(CssProperty property); +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssPropertyFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssPropertyFactory.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,266 @@ +// +// $Id: CssPropertyFactory.java,v 1.23 2008-12-10 15:22:58 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.StringTokenizer; +import java.util.Vector; + +import org.w3c.css.properties.PropertiesLoader; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.util.Utf8Properties; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; + +/** + * @version $Revision: 1.23 $ + * @author Philippe Le Hegaret + */ +public class CssPropertyFactory implements Cloneable { + + // all recognized properties are here. + private Utf8Properties properties; + + //all used profiles are here (in the priority order) + private static String[] SORTEDPROFILES = PropertiesLoader.getProfiles(); + + // private Utf8Properties allprops; + + // does not seem to be used + // private String usermedium; + + public CssPropertyFactory getClone() { + try { + return (CssPropertyFactory) clone(); + } catch (CloneNotSupportedException ex) { + ex.printStackTrace(); + return null; + } + } + + /** + * Create a new CssPropertyFactory + */ + /* + * public CssPropertyFactory(URL url, URL allprop_url) { properties = new + * Utf8Properties(); InputStream f = null; try { f = url.openStream(); + * properties.load(f); } catch (IOException e) { e.printStackTrace(); } + * finally { try { if (f != null) f.close(); } catch (Exception e) { + * e.printStackTrace(); } // ignore } + * // list of all properties allprops = new Utf8Properties(); InputStream + * f_all = null; try { f_all = allprop_url.openStream(); + * allprops.load(f_all); } catch (IOException e) { e.printStackTrace(); } + * finally { try { if (f_all != null) f_all.close(); } catch (Exception e) { + * e.printStackTrace(); } // ignore } } + */ + + public CssPropertyFactory(String profile) { + properties = PropertiesLoader.getProfile(profile); + // It's not good to have null properties :-/ + if (properties == null) { + throw new NullPointerException(); + } + } + + public String getProperty(String name) { + return properties.getProperty(name); + } + + private Vector getVector(String media) { + Vector list = new Vector(4); + String medium = new String(); + StringTokenizer tok = new StringTokenizer(media, ","); + + while (tok.hasMoreTokens()) { + medium = tok.nextToken(); + medium = medium.trim(); + list.addElement(medium); + } + + return list; + } + + // public void setUserMedium(String usermedium) { + // this.usermedium = usermedium; + // } + + // bug: FIXME + // @media screen and (min-width: 400px) and (max-width: 700px), print { + // a { + // border: 0; + // } + // } + public synchronized CssProperty createMediaFeature(ApplContext ac, AtRule atRule, String property, + CssExpression expression) throws Exception { + // String result = "ok"; + String media = atRule.toString(); + int pos = -1; + int pos2 = media.toUpperCase().indexOf("AND"); + + if (pos2 == -1) { + pos2 = media.length(); + } + + if (media.toUpperCase().indexOf("NOT") != -1) { + pos = media.toUpperCase().indexOf("NOT"); + media = media.substring(pos + 4, pos2); + } else if (media.toUpperCase().indexOf("ONLY") != -1) { + pos = media.toUpperCase().indexOf("ONLY"); + media = media.substring(pos + 4, pos2); + } else { + pos = media.indexOf(" "); + media = media.substring(pos + 1, pos2); + } + + media = media.trim(); + + String classname = properties.getProperty("mediafeature" + "." + property); + + if (classname == null) { + if (atRule instanceof AtRuleMedia && (!media.equals("all"))) { + // I don't know this property + throw new InvalidParamException("noexistence-media", property, media, ac); + // ac.getFrame().addWarning("noexistence-media", property); + // classname = allprops.getProperty(property); + } else { + // I don't know this property + throw new InvalidParamException("noexistence", property, media, ac); + } + } + + try { + // create an instance of your property class + Class expressionclass = new CssExpression().getClass(); + if (expression != null) { + expressionclass = expression.getClass(); + } + // Maybe it will be necessary to add the check parameter as for + // create property, so... FIXME + Class[] parametersType = { ac.getClass(), expressionclass }; + Constructor constructor = Class.forName(classname).getConstructor(parametersType); + Object[] parameters = { ac, expression }; + // invoke the constructor + return (CssProperty) constructor.newInstance(parameters); + } catch (InvocationTargetException e) { + // catch InvalidParamException + InvocationTargetException iv = e; + Exception ex = (Exception) iv.getTargetException(); + throw ex; + } + + } + + public synchronized CssProperty createProperty(ApplContext ac, AtRule atRule, String property, + CssExpression expression) throws Exception { + String classname = null; + String media = atRule.toString(); + int pos = -1; + String upperMedia = media.toUpperCase(); + int pos2 = upperMedia.indexOf("AND "); + + if (pos2 == -1) { + pos2 = media.length(); + } + + if ((pos = upperMedia.indexOf("NOT")) != -1) { + media = media.substring(pos + 4, pos2); + } else if ((pos = upperMedia.indexOf("ONLY")) != -1) { + media = media.substring(pos + 4, pos2); + } else { + pos = media.indexOf(' '); + media = media.substring(pos + 1, pos2); + } + + media = media.trim(); + + classname = setClassName(atRule, media, ac, property); + + // the property does not exist in this profile + // this is an error... or a warning if it exists in another profile + if (classname == null) { + ArrayList pfsOk = new ArrayList(); + + for (int i=0; i 0) { + /* + // This should be uncommented when no-profile in enabled + if (ac.getProfile().equals("none")) { + // the last one should be the best one to use + String pf = (String) pfsOk.get(pfsOk.size()-1), + old_pf = ac.getCssVersion(); + ac.setCssVersion(pf); + ac.getFrame().addWarning("noexistence", new String[] { property, ac.getMsg().getString(old_pf), pfsOk.toString() }); + classname = setClassName(atRule, media, ac, property); + ac.setCssVersion(old_pf); + } + else + */ + throw new InvalidParamException("noexistence", new String[] { property, ac.getMsg().getString(ac.getCssVersion()), pfsOk.toString() }, ac); + } else { + throw new InvalidParamException("noexistence-at-all", property, ac); + } + } + + CssIdent initial = new CssIdent("initial"); + + try { + if (expression.getValue().equals(initial) && ac.getCssVersion().equals("css3")) { + // create an instance of your property class + Class[] parametersType = {}; + Constructor constructor = Class.forName(classname).getConstructor(parametersType); + Object[] parameters = {}; + // invoke the constructor + return (CssProperty) constructor.newInstance(parameters); + } else { + // create an instance of your property class + Class[] parametersType = { ac.getClass(), expression.getClass(), boolean.class }; + Constructor constructor = Class.forName(classname).getConstructor(parametersType); + Object[] parameters = { ac, expression, new Boolean(true) }; + // invoke the constructor + return (CssProperty) constructor.newInstance(parameters); + + } + } catch (InvocationTargetException e) { + // catch InvalidParamException + InvocationTargetException iv = e; + Exception ex = (Exception) iv.getTargetException(); + throw ex; + } + } + + private String setClassName(AtRule atRule, String media, ApplContext ac, String property) { + String className; + Vector list = new Vector(getVector(media)); + if (atRule instanceof AtRuleMedia) { + className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty(property); + // a list of media has been specified + if (className != null && !media.equals("all")) { + String propMedia = PropertiesLoader.mediaProperties.getProperty(property); + for (int i = 0; i < list.size(); i++) { + String medium = list.elementAt(i); + if (propMedia.indexOf(medium.toLowerCase()) == -1 && !propMedia.equals("all")) { + ac.getFrame().addWarning("noexistence-media", new String[] { property, medium + " (" + propMedia + ")" }); + } + } + } + } else { + className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty("@" + atRule.keyword() + "." + property); + } + return className; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssSelectors.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssSelectors.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,628 @@ +// +// $Id: CssSelectors.java,v 1.28 2009-02-25 20:44:49 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.ArrayList; +import java.util.Enumeration; + +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.selectors.AdjacentSiblingSelector; +import org.w3c.css.selectors.AttributeSelector; +import org.w3c.css.selectors.ChildSelector; +import org.w3c.css.selectors.DescendantSelector; +import org.w3c.css.selectors.GeneralSiblingSelector; +import org.w3c.css.selectors.PseudoClassSelector; +import org.w3c.css.selectors.PseudoElementSelector; +import org.w3c.css.selectors.PseudoFactory; +import org.w3c.css.selectors.Selector; +import org.w3c.css.selectors.SelectorsList; +import org.w3c.css.selectors.TypeSelector; +import org.w3c.css.selectors.attributes.AttributeExact; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionContains; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionLang; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNot; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthChild; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthLastChild; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthLastOfType; +import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthOfType; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.util.Messages; +import org.w3c.css.util.Util; +import org.w3c.css.util.Warnings; + +/** + * This class manages all contextual selector. + * + *

      + * Note:
      + * Invoke a set function to change the selector clears all + * properties ! + * + * @version $Revision: 1.28 $ + */ +public final class CssSelectors extends SelectorsList + implements CssSelectorsConstant { + + ApplContext ac; + + /** + * At rule statement + */ + AtRule atRule; + + /** + * The element. + */ + String element; + + char connector = DESCENDANT; + + /** + * The next context. + */ + protected CssSelectors next; + + // true if the element is a block-level element + private boolean isBlock; + + CssStyle properties; + + // all hashCode (for performance) + private int hashElement; + + //private int hashGeneral; + + // The CssStyle to use + private static Class style; + + // see isEmpty and addProperty + private boolean Init; + + private String cachedRepresentation = null; + private boolean isFinal = false; + + /** + * Create a new CssSelectors with no previous selector. + */ + public CssSelectors(ApplContext ac) { + super(ac); + style = ac.getCssSelectorsStyle(); + try { + properties = (CssStyle) style.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + this.ac = ac; + } + + private CssSelectors(Class style) { + super(); + CssSelectors.style = style; + try { + properties = (CssStyle) style.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + this.ac = null; + } + + /** + * Create a new CssSelectors with a previous selector. + * + * @param next + * the next selector + */ + public CssSelectors(CssSelectors next) { + this(CssSelectors.style); + this.next = next; + } + + /** + * Create a new CssSelectors with a previous selector. + * + * @param next + * the next selector + */ + public CssSelectors(ApplContext ac, CssSelectors next) { + this(ac); + this.next = next; + } + + /** + * Set the style for all contexts. Don't forget to invoke this method if you + * want a style ! + * + * @param style0 + * the style + */ + public void setStyle(Class style0) { + Util.verbose("Style is : " + style0); + style = style0; + } + + /** + * Set the attribute atRule + * + * @param atRule + * the new value for the attribute + */ + public void setAtRule(AtRule atRule) { + this.atRule = atRule; + } + + /** + * Returns the attribute atRule + * + * @return the value of the attribute + */ + public final AtRule getAtRule() { + return atRule; + } + + /** + * Get the element. + */ + public final String getElement() { + return element; + } + + /** + * Returns true if the element is a block level element (HTML + * only) + */ + public final boolean isBlockLevelElement() { + return isBlock; + } + + public void addPseudoClass(String pseudo) throws InvalidParamException { + if(pseudo == null) { + return; + } + + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + // is it a pseudo-class? + String[] ps = PseudoFactory.getPseudoClass(profile); + if(ps != null) { + for(int i = 0; i < ps.length; i++) { + if(pseudo.equals(ps[i])) { + addPseudoClass(new PseudoClassSelector(pseudo)); + return; + } + } + } + // it's not a pseudo-class, maybe one pseudo element exception + ps = PseudoFactory.getPseudoElementExceptions(profile); + if(ps != null) { + for(int i = 0; i < ps.length; i++) { + if(pseudo.equals(ps[i])) { + addPseudoClass(new PseudoClassSelector(pseudo)); + return; + } + } + } + throw new InvalidParamException("pseudo", ":" + pseudo, ac); + } + + public void addPseudoElement(String pseudo) throws InvalidParamException { + if(pseudo == null) { + return; + } + + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + // is it a pseudo-element? + String[] ps = PseudoFactory.getPseudoElement(profile); + if(ps != null) { + for(int i = 0; i < ps.length; i++) { + if(pseudo.equals(ps[i])) { + addPseudoElement(new PseudoElementSelector(pseudo)); + return; + } + } + } + + // the ident isn't a valid pseudo-something + throw new InvalidParamException("pseudo", "::" + pseudo, ac); + } + + public void setPseudoFun(String pseudo, String param) + throws InvalidParamException { + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + String[] ps = PseudoFactory.getPseudoFunction(profile); + if(ps != null) { + for(int i = 0; i < ps.length; i++) { + if(pseudo.equals(ps[i])) { + addPseudoFunction( + PseudoFactory.newPseudoFunction(pseudo, + param, + ac)); + return; + } + } + throw new InvalidParamException("pseudo", ":" + pseudo, ac); + } + } + + public void addType(TypeSelector type) throws InvalidParamException { + super.addType(type); + element = type.getName(); + hashElement = element.hashCode(); + } + + public void addDescendant(DescendantSelector descendant) + throws InvalidParamException { + super.addDescendant(descendant); + connector = DESCENDANT; + } + + public void addChild(ChildSelector child) throws InvalidParamException { + super.addChild(child); + connector = CHILD; + } + + public void addAdjacentSibling(AdjacentSiblingSelector adjacent) + throws InvalidParamException { + super.addAdjacentSibling(adjacent); + connector = ADJACENT_SIBLING; + } + + public void addGeneralSibling(GeneralSiblingSelector sibling) + throws InvalidParamException { + super.addGeneralSibling(sibling); + connector = GENERAL_SIBLING; + } + + + public void addAttribute(AttributeSelector attribute) + throws InvalidParamException { + int _s = size(); + for(int i = 0; i < _s; i++) { + Selector s = (Selector) getSelector(i); + // add warnings if some selectors are incompatible + // e.g. [lang=en][lang=fr] + if(s instanceof AttributeSelector) { + ((AttributeSelector) s).applyAttribute(ac, attribute); + } + } + super.addAttribute(attribute); + } + + /** + * Adds a property to this selector. + * + * @param property + * The property. + * @param warnings + * For warning report. + */ + public void addProperty(CssProperty property, Warnings warnings) { + Init = true; + if (properties != null) { + properties.setProperty(ac, property, warnings); + } else { + System.err.println("[ERROR] Invalid state in " + + "org.w3c.css.parser.CssSelectors#addProperty"); + System.err.println("[ERROR] Please report BUG"); + } + } + + public CssStyle getStyle() { + return properties; + } + + /** + * Returns a string representation of the object. + */ + public String toString() { + // I'm in reverse order, so compute the next before the current + if (isToStringCached()) { + return cachedRepresentation; + } + StringBuilder sbrep = new StringBuilder(); + if (next != null) { + sbrep.append(next.toString()); + } + sbrep.append(super.toString()); + cachedRepresentation = sbrep.toString(); + return cachedRepresentation; + } + /** + * return XML escaped string + */ + public String getEscaped() { + return Messages.escapeString(toString()); + } + + public boolean isToStringCached() { + if (cachedRepresentation == null) { + return false; + } + if (isFinal) { + return true; + } + if (next != null) { + return super.isToStringCached() && next.isToStringCached(); + } + return super.isToStringCached(); + } + + /* + we are doing this in two steps, as it is possible to have some + calls to toString() and do modifications, then at some point + everything is frozen (like when StyleSheet.findConflict is called) + marking as final (ie: no more modifications) triggers more + optimizations. Things could be better optimized if we were sure + that no calls to toString were done before everything is frozen + */ + + /* + * Mark as final, ie: no more modification to the structure. + */ + public void markAsFinal() { + // if something has been changed, reset to force recomputing + if (!isFinal) { + if (!isToStringCached()) { + cachedRepresentation = null; + if (next != null) { + next.markAsFinal(); + } + } + isFinal = true; + } + } + + /** + * Get a hashCode. + */ + /*public int hashCode() { + if (hashGeneral == 0) { + if (atRule instanceof AtRuleFontFace) { + hashGeneral = atRule.hashCode(); + } else { + String s = toString(); + hashGeneral = s.hashCode(); + for (int i = 0; i < s.length(); i++) { + hashGeneral += (int) s.charAt(i); + } + } + } + return hashGeneral; + }*/ + + /** + * Returns true if the selector is equals to an another. + * + * @param selector + * The selector to compare + */ + public boolean equals(Object selector) { + if ((selector == null) || !(selector instanceof CssSelectors)) { + return false; + } + CssSelectors s = (CssSelectors) selector; + + if ((atRule instanceof AtRulePage) + || (atRule instanceof AtRuleFontFace)) { + return atRule.equals(s.atRule); + } + if (hashCode() == s.hashCode()) { + if (atRule == null) { + return (s.getAtRule() == null); + } else { + return atRule.canApply(s.getAtRule()); + } + } else { + return false; + } + } + + /** + * Set the previous selector. + * + * @param next + * the previous selector. + */ + public void setNext(CssSelectors next) { + this.next = next; + Invalidate(); + } + + /** + * Get the previous selector. + */ + public CssSelectors getNext() { + return next; + } + + /** + * Returns true if there is no property in this document. + */ + public boolean isEmpty() { + return !Init; + } + + public void addAttribute(String attName, String value) + throws InvalidParamException { + if (ac.getProfile() != null && !"".equals(ac.getProfile())) { + if (ac.getProfile().equals("mobile")) { + throw new InvalidParamException("notformobile", "attributes", + ac); + } + } else { + addAttribute(new AttributeExact(attName, value)); + Invalidate(); + } + } + + void Invalidate() { + // invalidate all pre-computation in this selectors + setSpecificity(0); + //hashGeneral = 0; + + if (Init) { + // yes I invalidate all properties too ! + try { + properties = (CssStyle) style.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + final boolean canApply(ArrayList attrs, ArrayList attrs2) { + if(attrs.size() > 0) { + for(int i = 0; i < attrs.size(); i++) { + Selector selector = attrs.get(i); + + Selector other = null; + int j = 0; + for(; j < attrs2.size(); j++) { + other = attrs2.get(j); + if(!other.equals(selector)) { + other = null; + } + else { + break; + } + } + if (other != null) { + if (!selector.canApply(other)) { + return false; + } + } else { + return false; + } + } + return true; + } + return true; + + } + + /** + * Returns true if the selector can matched this selector. + * + *

      + * Examples:
      + *

        + *
      1. H1.canApply(HTML BODY H1) returns true + *
      2. H1.canApply(HTML BODY H1 EM) returns + * false + *
      3. (H1 EM).canApply(HTML BODY H2 EM) returns + * false + *
      4. (HTML EM).canApply(HTML BODY H2 EM) returns + * true + *
      + * + *

      + * Note:
      + * In principle, if you work with a HTML document, your selector should + * start with HTML BODY. Because you are always in this context when you + * parse the text in a HTML document. + * + * @param selector + * the selector to match + * @see org.w3c.css.css.CssCascadingOrder#order + */ + public boolean canApply(CssSelectors selector) { + if ((atRule instanceof AtRulePage) + || (atRule instanceof AtRuleFontFace)) { + return atRule.canApply(selector.atRule); + } + // current work - don't touch + Util.verbose(getSpecificity() + " canApply this " + this + + " selector: " + selector); + Util.verbose("connector " + connector); + Util.verbose(getSelectors().toString()); + Util.verbose(selector.getSelectors().toString()); + + if ((hashElement != selector.hashElement) && hashElement != 0) { + // here we are in this case : + // H1 and HTML BODY H1 EM + // don't do anything ! + // the cascading order algorithm resolves this case like this : + // + // if (for all contexts) !canApply(selector) + // go and see canApply(selector.getNext()) + // + // for further informations, + // see org.w3c.css.css.CssCascadingOrder#order + Util.verbose("canApply RETURNS FALSE"); + return false; + } else { + if (next == null || selector.next == null) { + boolean result = canApply(getSelectors(), selector.getSelectors()); + Util.verbose("canApply RETURNS " + result); + return result; + } else { + return next.canMatch(selector.next); + } + } + } + + /** + * Returns true if the selector can matched another selector. called by + * canApply + * + * @param selector + * The selector to compare + */ + private boolean canMatch(CssSelectors selector) { + boolean result = canApply(getSelectors(), selector.getSelectors()); + // current work + Util.verbose("canMatched this " + this + " selector: " + selector); + Util.verbose("connector " + connector); + Util.verbose(getSelectors().toString()); + Util.verbose(selector.getSelectors().toString()); + Util.verbose("canMatched for attributes :" + result); + + if ((hashElement != selector.hashElement) && hashElement != 0) { + if ((connector == DESCENDANT) && (selector.next != null)) { + // here we are in this case : + // H1 and HTML BODY H1 EM + // H1 can't matched EM but EM have next + return canMatch(selector.next); + } else { + // here we are in this case : + // H1 and HTML + // H1 can't matched HTML and HTML don't have next + Util.verbose("canMatched RETURN FALSE"); + return false; + } + } + + if (next == null || selector.next == null) { + // here we are in this case : + // H1 and BODY HTML H1 + // or : + // HTML BODY and BODY (this case won't appear in principle) + Util.verbose("canMatched RETURN " + result); + return canApply(getSelectors(), selector.getSelectors()); + } else { + // here we are in this case : + // BODY H1 and HTML BODY H1 + return next.canMatch(selector.next); + } + } + + public void findConflicts(ApplContext ac, Warnings warnings, + CssSelectors[] allSelectors) { + CssStyle style = getStyle(); + style.findConflicts(ac, warnings, this, allSelectors); + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssSelectorsConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssSelectorsConstant.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,44 @@ +// +// $Id: CssSelectorsConstant.java,v 1.10 2009-02-12 10:32:51 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// Updated September 20th 2000 Sijtsche de Jong (sy.de.jong@let.rug.nl) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +/** + * @version $Revision: 1.10 $ + */ +public interface CssSelectorsConstant { + + /** [lang="fr"] */ + public static final int ATTRIBUTE_EXACT = ' '; + /** [lang~="fr"] */ + public static final int ATTRIBUTE_ONE_OF = '~'; + /** class selector == like [lang~="fr"] */ + public static final int ATTRIBUTE_CLASS_SEL = '.'; + /** [lang|="fr"] */ + public static final int ATTRIBUTE_BEGIN = '|'; + /** [lang] */ + public static final int ATTRIBUTE_ANY = -1; + /** [foo^="bar"] */ + public static final int ATTRIBUTE_START = '^'; + /** [foo$="bar"] */ + public static final int ATTRIBUTE_SUFFIX = '$'; + /** [foo*="bar"] */ + public static final int ATTRIBUTE_SUBSTR = '*'; + + /** Maximun of ATTRIBUTE_ONE_OF */ + public static final int ATTRIBUTE_LENGTH = 10; + + /** descendant connector */ + public static final char DESCENDANT = ' '; + /** child connector */ + public static final char CHILD = '>'; + /** adjacent sibling connector */ + public static final char ADJACENT_SIBLING = '+'; + /** general sibling connector */ + public static final char GENERAL_SIBLING = '~'; +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssStyle.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssStyle.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,104 @@ +// +// $Id: CssStyle.java,v 1.9 2008-03-28 16:36:46 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.Enumeration; + +import org.w3c.css.css.StyleSheet; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.Warning; +import org.w3c.css.util.Warnings; + +/** + * This class represents a class for one context + * + * @version $Revision: 1.9 $ + */ +public class CssStyle { + + /** + * For warnings report. + */ + protected Warnings warnings; + + /** + * The entire style sheet. + */ + protected StyleSheet style; + + /** + * The context of this style. + */ + protected CssSelectors selector; + + /** + * Set the context of this style. + * + * @param selectors The context. + */ + public final void setSelector(CssSelectors selectors) { + this.selector = selectors; + } +//public String toString() { +// String res = ""; +// res += selector; +// res+=style; +// return res; +//} + /** + * Set the style sheet of this style. + * + * @param style The style sheet. + */ + public final void setStyleSheet(StyleSheet style) { + this.style = style; + } + + /** + * Add a warning definition to this style. + * + * @param property The property. + */ + public final void addRedefinitionWarning(ApplContext ac, + CssProperty property) { + warnings.addWarning(new Warning(property, "redefinition", 2, ac)); + } + + /** + * Add a property to this style + * + * @param property the property to add + * @param warnings where to add warnings if required + */ + public final void setProperty(ApplContext ac, CssProperty property, Warnings warnings) { + this.warnings = warnings; + property.addToStyle(ac, this); + } + + /** + * Print this style. + * Overrides this method to create your own style. + * + * @param printer The printer interface. + */ + public void print(CssPrinterStyle printer) { + // nothing to do + } + + /** + * Find conflicts in this Style + * + * @param warnings For warnings reports. + * @param allSelectors All contexts is the entire style sheet. + */ + public void findConflicts(ApplContext ac, Warnings warnings, + CssSelectors selector, CssSelectors[] allSelectors) { + // nothing to do + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssValidatorListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/CssValidatorListener.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,86 @@ +// +// $Id: CssValidatorListener.java,v 1.6 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.Vector; + +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.Warnings; + +/** + * Implements this interface if you want to use the CSS1 parser. + * + * @version $Revision: 1.6 $ + */ +public interface CssValidatorListener { + + /** + * Adds a vector of properties to a selector. + * + * @param selector the selector + * @param declarations Properties to associate with contexts + */ + public void handleRule(ApplContext ac, CssSelectors selector, + Vector declarations); + + /** + * Handles an at-rule. + * + *

      The parameter value can be : + *

      + *
      CssString + *
      The value coming from a string. + *
      CssURL + *
      The value coming from an URL. + *
      Vector + *
      The value is a vector of declarations (it contains Couple). + *
      + * + * @param ident The ident for this at-rule (for example: 'font-face') + * @param value The string representation of this at-rule + * @see org.w3c.css.parser.analyzer.Couple + */ + public void handleAtRule(ApplContext ac, String ident, String string); + + /** + * Notify all errors + * + * @param errors All errors in the style sheet + * @see CssError + * @see CssErrorDeclaration + * @see CssErrorToken + */ + public void notifyErrors(Errors errors); + + /** + * Notify all warnings + * + * @param warnings All warnings in the style sheet + * @see org.w3c.css.util.Warning + */ + public void notifyWarnings(Warnings warnings); + + public void addCharSet(String charset); + + public void newAtRule(AtRule atRule); + + public void endOfAtRule(); + + public void setImportant(boolean important); + + public void setSelectorList(Vector selectors); + + public void setProperty(Vector properties); + + public void endOfRule(); + + public void removeThisRule(); + + public void removeThisAtRule(); + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Elements.dtd4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Elements.dtd4 Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,91 @@ +A: false +ABBR: false +ACRONYM:false +ADDRESS: true +APPLET:false +AREA:false +B: false +BASE: false +BASEFONT:false +BDO: false +BIG: false +BLOCKQUOTE: true +BODY:true +BR: false +BUTTON: false +CAPTION: false +CENTER: true +CITE: false +CODE: false +COL: false +COLGROUP: false +DD: false +DEL: false +DFN: false +DIR: true +DIV: true +DL: true +DT: false +EM: false +FIELDSET: true +FONT: false +FORM: true +FRAME: false +FRAMESET: false +H1: true +H2: true +H3: true +H4: true +H5: true +H6: true +HEAD: false +HR: true +HTML: true +I: false +IFRAME: false +IMG: false +INPUT: false +INS: false +ISINDEX: true +KBD: false +LABEL: false +LEGEND: false +LI: true +LINK: false +MAP: false +MENU: true +META: false +NOFRAMES: true +NOSCRIPT: true +OBJECT: false +OL: true +OPTION: false +P: true +PARAM: false +PRE: true +Q: false +S: false +SAMP: false +SCRIPT: false +SELECT: false +SMALL: false +SPAN: false +STRIKE: false +STRONG: false +STYLE: false +SUB: false +SUP: false +TABLE: true +TBODY: false +TD: false +TEXTAREA: false +TFOOT: false +TH: false +THEAD: false +TITLE: false +TR: false +TT: false +U: false +UL: true +VAR: false +SCRIPT: false diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Errors.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Errors.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,86 @@ +// +// $Id: Errors.java,v 1.5 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import java.util.Vector; + +/** + * Controls all errors in the validator + * @version $Revision: 1.5 $ + * @see Vector.java + */ +public final class Errors { + + private CssError[] errorData = new CssError[10]; + private int errorCount; + + private final static int capacityIncrement = 10; + + /** + * Add an error. + * + * @param error The new error. + */ + public final void addError(CssError error) { + int oldCapacity = errorData.length; + if (errorCount + 1 > oldCapacity) { + CssError oldData[] = errorData; + errorData = new CssError[oldCapacity + capacityIncrement]; + System.arraycopy(oldData, 0, errorData, 0, errorCount); + } + errorData[errorCount++] = error; + } + + /** + * Add errors. + * + * @param errors All errors + */ + public final void addErrors(Errors errors) { + int oldCapacity = errorData.length; + if (errorCount + errors.errorCount + 1 > oldCapacity) { + CssError oldData[] = errorData; + errorData = + new CssError[oldCapacity + errors.errorCount + capacityIncrement]; + System.arraycopy(oldData, 0, errorData, 0, errorCount); + } + System.arraycopy(errors.errorData, 0, errorData, + errorCount, errors.errorCount); + errorCount += errors.errorCount; + } + + /** + * Get the number of errors. + */ + public final int getErrorCount() { + return errorCount; + } + + /** + * Get an array with all errors. + */ + public final CssError[] getErrors() { + int oldCapacity = errorData.length; + if (errorCount < oldCapacity) { + CssError oldData[] = errorData; + errorData = new CssError[errorCount]; + System.arraycopy(oldData, 0, errorData, 0, errorCount); + } + return errorData; + } + + /** + * Get an error with an index. + * + * @param index the error index. + */ + public final CssError getErrorAt(int index) { + return errorData[index]; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Frame.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Frame.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,150 @@ +// +// $Id: Frame.java,v 1.11 2009-02-14 09:05:03 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser; + +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.Warning; +import org.w3c.css.util.Warnings; + +/** + * @version $Revision: 1.11 $ + */ +public class Frame { + + public ApplContext ac; + private Errors errors; + private Warnings warnings; + private CssFouffa cssFouffa; + + private String sourceFile; + private int line; + + /** + * Create a new Frame. + * + * @param cssFouffa The current parser. + * @param sourceFile The name of the source file. + */ + public Frame(CssFouffa cssFouffa, String sourceFile, int warningLevel) { + this.sourceFile = sourceFile; + this.cssFouffa = cssFouffa; + errors = new Errors(); + warnings = new Warnings(warningLevel); + } + + /** + * Create a new Frame with a line number. + * + * @param cssFouffa The current parser. + * @param sourceFile The name of the source file. + * @param beginLine The begin line + */ + public Frame(CssFouffa cssFouffa, String sourceFile, int beginLine, + int warningLevel) + { + this(cssFouffa, sourceFile, warningLevel); + line = beginLine; + } + + /** + * Adds an error to this frame. + * + * @param error The new error. + */ + public void addError(CssError error) { + error.sourceFile = getSourceFile(); + error.line = getLine(); + errors.addError(error); + } + + /** + * Returns all errors. + */ + public Errors getErrors() { + return errors; + } + + /** + * Adds a warning to this frame. + * + * @param warningMessage the warning message + * (see org.w3c.css.util.Messages.properties). + * @see org.w3c.css.util.Warning + */ + public void addWarning(String warningMessage) { + warnings.addWarning(new Warning(getSourceFile(), getLine(), + warningMessage, 0, ac)); + } + + /** + * Adds a warning to this frame with a message. + * + * @param warningMessage the warning message + * (see org.w3c.css.util.Messages.properties). + * @param message An add-on message. + * @see org.w3c.css.util.Warning + */ + public void addWarning(String warningMessage, String message) { + warnings.addWarning(new Warning(getSourceFile(), getLine(), + warningMessage, 0, + new String[] { message }, ac)); + } + + /** + * Adds a warning to this frame with a message. + * + * @param warningMessage the warning message + * (see org.w3c.css.util.Messages.properties). + * @param messages Some add-on messages. + * @see org.w3c.css.util.Warning + */ + public void addWarning(String warningMessage, String[] messages) { + warnings.addWarning(new Warning(getSourceFile(), getLine(), + warningMessage, 0, messages, ac)); + } + + /** + * Get all warnings. + */ + public Warnings getWarnings() { + return warnings; + } + + /** + * Get the name of the source file. + */ + public String getSourceFile() { + return sourceFile; + } + + /** + * Get the begin line. + */ + public int getBeginLine() { + return line; + } + + /** + * Get the current line. + */ + public int getLine() { + //return line; //+ cssFouffa.token.beginLine; + return line + cssFouffa.token.beginLine; + } + + /** + * Merge two frames. + * + * @param frame The other frame for merging. + */ + public void join(Frame frame) { + errors.addErrors(frame.errors); + warnings.addWarnings(frame.warnings); + } +} + diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/Makefile Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,35 @@ +SRCS = CssFouffa.java Errors.java\ +CssError.java CssValidatorListener.java Frame.java\ +CssErrorDeclaration.java \ +CssErrorToken.java CssSelectors.java\ +CssStyle.java CssPrinterStyle.java CssParseException.java + +OBJS = $(SRCS:.java=.class) + +PACKAGE = org.w3c.css.parser +JAVAC = jc -val +JAVADOC = javadoc +JAVADOCFLAGS = -version -d docs -protected +JAVACFLAGS = +MAKEDEPEND = jmakedepend + +.SUFFIXES: .class .java +.java.class:; $(JAVAC) $(JAVACFLAGS) $< + +all: $(OBJS) + +javadoc:; $(JAVADOC) $(JAVADOCFLAGS) $(PACKAGE) + +clean:; -rm -f $(OBJS) *~ core + +depend:; $(MAKEDEPEND) $(SRCS) +# DO NOT DELETE THIS LINE -- make depend depends on it. +CssErrorToken.class:: CssErrorToken.java +Frame.class:: Frame.java +CssError.class:: CssError.java +CssValidatorListener.class:: CssValidatorListener.java +Errors.class:: Errors.java +CssFouffa.class:: CssFouffa.java +CssStyle.class:: CssStyle.java +CssParseException.class:: CssParseException.java +CssPrinterStyle.class:: CssPrinterStyle.java diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/MediaEnumeration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/MediaEnumeration.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2001 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * + * $Id: MediaEnumeration.java,v 1.3 2005-09-14 15:14:18 ylafon Exp $ + */ +package org.w3c.css.parser; + +import java.util.Enumeration; + +public class MediaEnumeration implements Enumeration { + + String [] media; + int current = 0; + + MediaEnumeration(AtRuleMedia media) { + this.media = media.media; + while ((current < this.media.length) + && (this.media[current] != null)) { + current++; + } + } + + public boolean hasMoreElements() { + while (current < media.length) { + if (media[current] != null) { + return true; + } + current++; + } + + return false; + } + + public Object nextElement() { + return media[current]; + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CommentSkipperInputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CommentSkipperInputStream.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2001 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * + * $Id: CommentSkipperInputStream.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ + */ +package org.w3c.css.parser.analyzer; + +import java.io.IOException; +import java.io.InputStream; + + +/** + * @version $Revision: 1.4 $ + * @author Philippe Le Hegaret + */ +public class CommentSkipperInputStream extends InputStream { + + int previous; + InputStream in; + /** + * Creates a new CommentSkipperInputStream + */ + public CommentSkipperInputStream(InputStream input) { + in = input; + } + + + public int read() throws IOException { + int c; + if (previous != 0) { + c = previous; + previous = 0; + return c; + } + + c = in.read(); + + if (c != '/') { + return c; + } + previous = in.read(); + + if (previous != '*') { + return c; + } + previous = 0; + do { + do { + c = in.read(); + } while ((c != -1) && (c != '*')); + c = in.read(); + } while ((c != -1) && (c != '/')); + if (c == '/') { + return read(); + } else { + return -1; + } + } + + public void close() throws IOException { + in.close(); + } +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/Couple.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/Couple.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,69 @@ +// +// $Id: Couple.java,v 1.4 2005-09-14 15:14:18 ylafon Exp $ +// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// +// (c) COPYRIGHT MIT and INRIA, 1997. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.parser.analyzer; + +import org.w3c.css.values.CssExpression; + +/** + * This class represents a couple : an at-rule property and an at-rule + * expression. + * + * @version $Revision: 1.4 $ + */ +public class Couple { + + /** + * The at-rule property. + */ + protected String property; + + /** + * The at-rule expression. + */ + protected CssExpression expression; + + /** + * Is this at-rule is important + */ + protected boolean important; + + /** + * Create a new Couple + * + * @param property The at-rule property. + * @param expression The at-rule expression. + * @param important Is this at-rule is important + */ + public Couple(String property, CssExpression expression, boolean important) { + this.property = property; + this.expression = expression; + this.important = important; + } + + /** + * Get the at-rule property + */ + public final String getProperty() { + return property; + } + + /** + * get the at-rule expression + */ + public final CssExpression getExpression() { + return expression; + } + + /** + * Is this at-rule is important + */ + public final boolean getImportant() { + return important; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CssParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CssParser.java Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,4007 @@ +/* Generated By:JavaCC: Do not edit this line. CssParser.java */ +package org.w3c.css.parser.analyzer; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.Vector; +import java.util.Enumeration; +import java.net.URL; + +import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssString; +import org.w3c.css.values.CssURL; +import org.w3c.css.values.CssLength; +import org.w3c.css.values.CssNumber; +import org.w3c.css.values.CssColor; +import org.w3c.css.values.CssIdent; +import org.w3c.css.values.CssPercentage; +import org.w3c.css.values.CssFrequency; +import org.w3c.css.values.CssTime; +import org.w3c.css.values.CssDate; +import org.w3c.css.values.CssAngle; +import org.w3c.css.values.CssFunction; +import org.w3c.css.values.CssUnicodeRange; +import org.w3c.css.values.CssResolution; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.parser.Frame; +import org.w3c.css.util.ApplContext; +import org.w3c.css.parser.CssError; +import org.w3c.css.parser.CssSelectors; +import org.w3c.css.parser.CssParseException; +import org.w3c.css.parser.AtRule; +import org.w3c.css.parser.AtRuleMedia; +import org.w3c.css.parser.AtRuleFontFace; +import org.w3c.css.parser.AtRulePage; +import org.w3c.css.parser.AtRulePreference; +import org.w3c.css.parser.AtRulePhoneticAlphabet; +import org.w3c.css.properties.svg.AtRuleColorProfile; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.util.Util; +import org.w3c.css.util.Messages; + +import org.w3c.css.selectors.AdjacentSiblingSelector; +import org.w3c.css.selectors.AttributeSelector; +import org.w3c.css.selectors.ChildSelector; +import org.w3c.css.selectors.ClassSelector; +import org.w3c.css.selectors.DescendantSelector; +import org.w3c.css.selectors.GeneralSiblingSelector; +import org.w3c.css.selectors.IdSelector; +import org.w3c.css.selectors.TypeSelector; +import org.w3c.css.selectors.UniversalSelector; +import org.w3c.css.selectors.attributes.AttributeAny; +import org.w3c.css.selectors.attributes.AttributeBegin; +import org.w3c.css.selectors.attributes.AttributeExact; +import org.w3c.css.selectors.attributes.AttributeOneOf; +import org.w3c.css.selectors.attributes.AttributeStart; +import org.w3c.css.selectors.attributes.AttributeSubstr; +import org.w3c.css.selectors.attributes.AttributeSuffix; + +/** + * A CSS3 parser + * + * @author Philippe Le Hegaret and Sijtsche Smeman + * @version $Revision: 1.68 $ + */ +public abstract class CssParser implements CssParserConstants { + + private static char hexdigits[] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f' }; + // the current atRule + protected AtRule atRule; + protected String mediaDeclaration = "off"; + + /** + * The URL of the document + */ + protected URL url; + + protected ApplContext ac; + + protected boolean incompatible_error; + + /** + * The current context recognized by the parser (for errors). + */ + protected Vector currentContext; + + /** + * The current property recognized by the parser (for errors). + */ + protected String currentProperty; + + /** + * true if the parser should recognized Aural properties, + * false otherwise. + */ + protected boolean mode; + + /** + * true if the parser had recognize a rule, + * false otherwise. + */ + protected boolean markRule; + + private boolean reinited = false; + private boolean charsetdeclared = false; + + static StringBuilder SPACE = new StringBuilder(" "); + + // to be able to remove a ruleset if the selector is not valid + protected boolean validSelector = true; + + /** + * The ac for handling errors and warnings. + * + * @param ac the new ac for the parser. + */ + public final void setApplContext(ApplContext ac) { + this.ac = ac; + } + + /** + * Set the attribute atRule + * + * @param atRule the new value for the attribute + */ + public void setAtRule(AtRule atRule) { + this.atRule = atRule; + } + + /** + * Set the attribute mediaDeclaration + * + * @param mediaDeclaration indicator if in a media expression list or not + */ + public void setMediaDeclaration(String mediadeclaration) { + this.mediaDeclaration = mediadeclaration; + } + + /** + * Returns the attribute mediaDeclaration + * + * @return the value of the attribute + */ + public String getMediaDeclaration() { + return mediaDeclaration; + } + + /** + * Returns the attribute atRule + * + * @return the value of the attribute + */ + public AtRule getAtRule() { + return atRule; + } + + /** + * Reinitialized the parser. + * + * @param stream the stream data to parse. + * @param ac the new ac to use for parsing. + */ + public void ReInitWithAc(InputStream stream, ApplContext ac, + String charset) + { + InputStream is = /*new CommentSkipperInputStream(stream);*/stream; + if (charset == null) { + charset = "iso-8859-1"; + } + InputStreamReader isr = null; + try { + isr = new InputStreamReader(is, charset); + } catch (UnsupportedEncodingException uex) { + isr = new InputStreamReader(is); + } + // reinit, it can not happen... + // ...in theory ;) + ReInit(isr); + markRule = false; + reinited = true; + setApplContext(ac); + } + + /* utilities for a parser */ + + /** + * Call by the import statement. + * + * @param url The style sheet where this import statement appears. + * @param file the file name in the import + */ + public abstract void handleImport(URL url, String file, + boolean is_url, AtRuleMedia media); + + /** + * Call by the namespace declaration statement. + * + * @param url The style sheet where this namespace statement appears. + * @param file the file/url name in the namespace declaration + */ + public abstract void handleNamespaceDeclaration(URL url, String prefix, + String file, + boolean is_url); + + /** + * Call by the at-rule statement. + * + * @param ident The ident for this at-rule (for example: 'font-face') + * @param string The string associate to this at-rule + * @see org.w3c.css.parser.Analyzer.Couple + */ + public abstract void handleAtRule(String ident, String string); + + /* added by Sijtsche Smeman */ + public abstract void addCharSet(String charset); + public abstract void newAtRule(AtRule atRule); + public abstract void endOfAtRule(); + public abstract void setImportant(boolean important); + public abstract void setSelectorList(Vector selectors); + public abstract void addProperty(Vector properties); + public abstract void endOfRule(); + public abstract void removeThisRule(); + public abstract void removeThisAtRule(); + + /** + * Assign an expression to a property. This function create a new property + * with property and assign to it the expression with the + * importance. Don't forget to set informations too. + *

      + * A subclass must provide an implementation of this method. + * + * @param property the name of the property + * @param values the expression representation of values + * @param important true if values are important + * + * @return nullor a property + * + * @see org.w3c.css.css.CssProperty + */ + public abstract CssProperty handleDeclaration(String property, + CssExpression values, + boolean important) + throws InvalidParamException; + + /** + * Adds a vector of properties to a selector. + *

      + * A subclass must provide an implementation of this method. + * + * @param selector the selector + * @param declarations Properties to associate with contexts + */ + public abstract void handleRule(CssSelectors selector, + Vector declarations); + + /*Added by Sijtsche Smeman */ + + /** + * Returns the source file of the style sheet + */ + public final String getSourceFile() { + return getURL().toString(); + } + + /** + * Returns the current line in the style sheet + */ + public final int getLine() { + //return token.beginLine; + return 0; + } + + /** + * Set the URL of the style sheet. + * + * @param URL The URL for the style sheet + */ + public final void setURL(URL url) { + this.url = url; + } + + public final URL getURL() { + return url; + } + + /** + * Return the next selector from the inputstream + */ + public CssSelectors parseSelector() throws ParseException { + return externalSelector(); + } + + /* + * Add a value to an expression + */ + private void setValue(CssValue v, CssExpression expr, + char operator, Token n, int token) + throws ParseException { + if (n != null) { + if (ac.getCssVersion().equals("css1") && + (n.image).equals("inherit")) { + incompatible_error = true; + } + String val = (operator == ' ') ? n.image : operator+n.image; + + if (n.kind == CssParserConstants.IDENT) { + v.set(convertIdent(val), ac); + } else if (n.kind == CssParserConstants.STRING) { + v.set(val, ac); + } else { + v.set(val, ac); + } + } + expr.addValue(v); + } + + /* + * Error control + */ + private void addError(Exception e, String skippedText) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + CssParseException ex = new CssParseException(e); + ex.setSkippedString(skippedText); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + } + + /* + * Error control 2 + */ + private void addError(Exception e, CssExpression exp) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + + // if ((exp != null) && (exp.getCount() != 0)) { + CssParseException ex = new CssParseException(e); + ex.setExp(exp); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + // } + } + +// +//TOKEN : +//{ /* avoid token manager error */ +// < UNKNOWN : ~[] > +//} + +/* + * The grammar of CSS2 + */ + +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ + final public void parserUnit() throws ParseException { + Token n = null; + try { + label_1: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HTMLSTARTTAG: + case HTMLENDTAG: + ; + break; + default: + jj_la1[0] = jj_gen; + break label_1; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HTMLSTARTTAG: + n = jj_consume_token(HTMLSTARTTAG); + break; + case HTMLENDTAG: + n = jj_consume_token(HTMLENDTAG); + break; + default: + jj_la1[1] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + addError ( +new ParseException(ac.getMsg().getString("generator.dontmixhtml")), n.image); + } + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CHARSET_SYM: + ; + break; + default: + jj_la1[2] = jj_gen; + break label_2; + } + charset(); + } + label_3: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case CDO: + case CDC: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_3; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + jj_consume_token(S); + break; + case CDO: + jj_consume_token(CDO); + break; + case CDC: + jj_consume_token(CDC); + break; + default: + jj_la1[4] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + label_4: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORT_SYM: + ; + break; + default: + jj_la1[5] = jj_gen; + break label_4; + } + importDeclaration(); + ignoreStatement(); + } + label_5: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NAMESPACE_SYM: + ; + break; + default: + jj_la1[6] = jj_gen; + break label_5; + } + namespaceDeclaration(); + ignoreStatement(); + } + afterImportDeclaration(); + jj_consume_token(0); + } catch (TokenMgrError err) { + addError (new ParseException(ac.getMsg().getString("generator.unrecognize")), + err.getMessage()); + } + } + + final public void charset() throws ParseException { + Token n = null; + Token charsetToken = null; + Token space1Token = null; + Token space2Token = null; + Token semicolonToken = null; + int nb_S = 0; + try { + charsetToken = jj_consume_token(CHARSET_SYM); + label_6: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[7] = jj_gen; + break label_6; + } + space1Token = jj_consume_token(S); + nb_S++; + } + n = jj_consume_token(STRING); + label_7: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[8] = jj_gen; + break label_7; + } + space2Token = jj_consume_token(S); + } + semicolonToken = jj_consume_token(SEMICOLON); + if (charsetdeclared && !reinited) { + {if (true) throw new ParseException( + ac.getMsg().getString("parser.charset"));} + } + // the @charset must be at the beginning of the document + if(charsetToken.beginLine != 1 || + charsetToken.beginColumn != 1) { + {if (true) throw new ParseException( + ac.getMsg().getString("parser.charset"));} + } + if ("css1".equals(ac.getCssVersion())) { + {if (true) throw new ParseException(ac.getMsg().getString( + "parser.charsetcss1"));} + } + // stricter rule for CSS21 and soon for CSS3 + if ("css21".equals(ac.getCssVersion())) { + // single space before + // case sensitive + // no space before ; + // no comments + // string must start with " + if ( (nb_S != 1) || + (!"@charset".equals(charsetToken.image)) || + (!" ".equals(space1Token.image)) || + (space2Token != null && + !"".equals(space2Token.image)) || + (space1Token.specialToken != null) || + (n.specialToken != null) || + (semicolonToken.specialToken != null) || + (n.image.charAt(0) != '\"') + ) { + {if (true) throw new ParseException(ac.getMsg().getString( + "parser.charsetspecial"));} + } + } + if (!charsetdeclared) { + addCharSet(n.image.substring(1, n.image.length()-1)); + charsetdeclared = true; + } else { + reinited = false; + } + } catch (Exception e) { + String skip = charsetToken + + ((space1Token == null) ? "" : space1Token.image) + + n + + ((space2Token == null) ? "" : space2Token.image) + + ";"; + addError(e, skip); + } + } + + final public void afterImportDeclaration() throws ParseException { + String ret; + label_8: + while (true) { + ; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + case HASHIDENT: + case HASH: + case LBRACKET: + case ANY: + case COLON: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case PSEUDOELEMENT_SYM: + case CLASS: + case FUNCTIONNOT: + case 98: + ruleSet(); + break; + case MEDIA_SYM: + media(); + break; + case PAGE_SYM: + page(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + case PREF_SYM: + preference(); + break; + case COLOR_PROFILE: + colorprofile(); + break; + case PHONETIC_ALPHABET_SYM: + phoneticAlphabet(); + break; + default: + jj_la1[9] = jj_gen; + ret = skipStatement(); + if ((ret == null) || (ret.length() == 0)) { + {if (true) return;} + } + // quite ugly but necessary to avoid probably a lot of changes in the + // grammar, still having a beautiful error message + else if (ret.startsWith("@charset")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.charset")); + addError(e, ret); + } else if (ret.startsWith("@import")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.import_not_allowed")); + addError(e, ret); + } else { + ParseException e = + new ParseException(ac.getMsg().getString("generator.unrecognize")); + addError(e, ret); + } + } + ignoreStatement(); + } + } + + final public void ignoreStatement() throws ParseException { + label_9: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: + case CDC: + case ATKEYWORD: + ; + break; + default: + jj_la1[10] = jj_gen; + break label_9; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: + jj_consume_token(CDO); + break; + case CDC: + jj_consume_token(CDC); + break; + case ATKEYWORD: + atRuleDeclaration(); + break; + default: + jj_la1[11] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_10: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[12] = jj_gen; + break label_10; + } + jj_consume_token(S); + } + } + } + + final public void namespaceDeclaration() throws ParseException { + Token n=null; + Token v=null; + boolean is_url; /* for formatting */ + String nsname; + String prefix = null; + CssValue val; + jj_consume_token(NAMESPACE_SYM); + label_11: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[13] = jj_gen; + break label_11; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + prefix = convertIdent(n.image); + label_12: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[14] = jj_gen; + break label_12; + } + jj_consume_token(S); + } + break; + default: + jj_la1[15] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + v = jj_consume_token(STRING); + is_url = false; + nsname = v.image.substring(1, v.image.length()-1); + break; + case URL: + v = jj_consume_token(URL); + is_url = true; + val = new CssURL(); + ((CssURL) val).set(v.image, ac, url); + nsname = (String) val.get(); + if ((nsname.charAt(0) == '"') + || (nsname.charAt(0) == '\'')) { + nsname = nsname.substring(1, nsname.length()-1); + } + break; + default: + jj_la1[16] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_13: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[17] = jj_gen; + break label_13; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + label_14: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[18] = jj_gen; + break label_14; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("css3")) { + addError(new InvalidParamException("at-rule", "@namespace", ac), + (n==null)?"default":n.toString()); + } else { + if (v != null) { + handleNamespaceDeclaration(getURL(), prefix, nsname, is_url); + } + } + } + +/** + * The import statement + * + * @exception ParseException exception during the parse + */ + final public void importDeclaration() throws ParseException { + Token n; + AtRuleMedia media = new AtRuleMedia(); + CssValue val; + String importFile; + boolean is_url = false; + try { + jj_consume_token(IMPORT_SYM); + label_15: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[19] = jj_gen; + break label_15; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + importFile = n.image.substring(1, n.image.length() -1); + is_url = false; + break; + case URL: + n = jj_consume_token(URL); + val = new CssURL(); + ((CssURL) val).set(n.image, ac, url); + importFile = (String) val.get(); + if ((importFile.charAt(0) == '"') + || (importFile.charAt(0) == '\'')) { + importFile = importFile.substring(1, importFile.length()-1); + } + is_url = true; + break; + default: + jj_la1[20] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_16: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[21] = jj_gen; + break label_16; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + medium(media); + label_17: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[22] = jj_gen; + break label_17; + } + jj_consume_token(COMMA); + label_18: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[23] = jj_gen; + break label_18; + } + jj_consume_token(S); + } + medium(media); + } + break; + default: + jj_la1[24] = jj_gen; + ; + } + jj_consume_token(SEMICOLON); + label_19: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[25] = jj_gen; + break label_19; + } + jj_consume_token(S); + } + handleImport(getURL(), importFile, is_url, media); + } catch (ParseException e) { + addError(e, skipStatement()); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void media() throws ParseException { + AtRule old = getAtRule(); + AtRuleMedia newRule = new AtRuleMedia(); + setAtRule(newRule); + Token n; + CssProperty p = null; + try { + jj_consume_token(MEDIA_SYM); + label_20: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[26] = jj_gen; + break label_20; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case MEDIARESTRICTOR: + n = jj_consume_token(MEDIARESTRICTOR); + newRule.addMediaRestrictor(convertIdent(n.image), ac); + label_21: + while (true) { + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[27] = jj_gen; + break label_21; + } + } + break; + default: + jj_la1[28] = jj_gen; + ; + } + medium(newRule); + label_22: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[29] = jj_gen; + break label_22; + } + jj_consume_token(COMMA); + label_23: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[30] = jj_gen; + break label_23; + } + jj_consume_token(S); + } + medium(newRule); + } + label_24: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case AND: + ; + break; + default: + jj_la1[31] = jj_gen; + break label_24; + } + jj_consume_token(AND); + label_25: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[32] = jj_gen; + break label_25; + } + jj_consume_token(S); + } + jj_consume_token(RPARAN); + label_26: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[33] = jj_gen; + break label_26; + } + jj_consume_token(S); + } + p = mediadeclaration(); + newRule.addMediaFeature(p); + jj_consume_token(LPARAN); + label_27: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[34] = jj_gen; + break label_27; + } + jj_consume_token(S); + } + } + String media = getAtRule().toString(); + if (ac.getMedium() != null && + !(media.equals(ac.getMedium())) && + !(ac.getMedium().equals("all"))) { + + ac.getFrame().addWarning("noothermedium", + getAtRule().toString()); + } + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + jj_consume_token(LBRACE); + label_28: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[35] = jj_gen; + break label_28; + } + jj_consume_token(S); + } + label_29: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + case HASHIDENT: + case HASH: + case LBRACKET: + case ANY: + case COLON: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case PSEUDOELEMENT_SYM: + case CLASS: + case FUNCTIONNOT: + case 98: + ; + break; + default: + jj_la1[36] = jj_gen; + break label_29; + } + ruleSet(); + } + jj_consume_token(RBRACE); + label_30: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[37] = jj_gen; + break label_30; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("css1")) { + endOfAtRule(); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void medium(AtRuleMedia media) throws ParseException { + Token n; + n = jj_consume_token(IDENT); + label_31: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[38] = jj_gen; + break label_31; + } + jj_consume_token(S); + } + try { + media.addMedia(convertIdent(n.image), ac); + } catch (InvalidParamException e) { + CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void page() throws ParseException { + Vector v ; + Token n = null ; + Vector collectv = new Vector() ; + CssSelectors s = new CssSelectors(ac); + AtRule old = getAtRule() ; + AtRulePage newRule = new AtRulePage() ; + setAtRule(newRule); + s.setAtRule(getAtRule()); + try { + jj_consume_token(PAGE_SYM); + label_32: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[39] = jj_gen; + break label_32; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + newRule.setIdent(convertIdent(n.image)); + label_33: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[40] = jj_gen; + break label_33; + } + jj_consume_token(S); + } + break; + default: + jj_la1[41] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + pseudo_page(newRule); + break; + default: + jj_la1[42] = jj_gen; + ; + } + jj_consume_token(LBRACE); + label_34: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[43] = jj_gen; + break label_34; + } + jj_consume_token(S); + } + v = pageContent(); + collectv = v; + jj_consume_token(RBRACE); + label_35: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[44] = jj_gen; + break label_35; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + if (!ac.getCssVersion().equals("css1")) { + addProperty(collectv); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, collectv); + } + } catch (InvalidParamException ie) { + if (!ac.getCssVersion().equals("css1")) { + skipStatement(); + removeThisAtRule(); + ac.getFrame().addError(new CssError(ie)); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + removeThisAtRule(); + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + + final public Vector pageContent() throws ParseException { + CssProperty prop; + Vector v = new Vector(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ATTOP: + case ATRIGHT: + case ATBOTTOM: + case ATLEFT: + // ?? FIXME + v = prefAtRule(); + {if (true) return v;} + break; + default: + jj_la1[45] = jj_gen; + v = declarations(); + {if (true) return v;} + } + throw new Error("Missing return statement in function"); + } + + final public Vector prefAtRule() throws ParseException { + Token n; + Vector v; + try { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ATTOP: + n = jj_consume_token(ATTOP); + break; + case ATBOTTOM: + n = jj_consume_token(ATBOTTOM); + break; + case ATLEFT: + n = jj_consume_token(ATLEFT); + break; + case ATRIGHT: + n = jj_consume_token(ATRIGHT); + break; + default: + jj_la1[46] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_36: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[47] = jj_gen; + break label_36; + } + jj_consume_token(S); + } + jj_consume_token(LBRACE); + label_37: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[48] = jj_gen; + break label_37; + } + jj_consume_token(S); + } + v = declarations(); + jj_consume_token(RBRACE); + label_38: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[49] = jj_gen; + break label_38; + } + jj_consume_token(S); + } + {if (true) return v;} + } catch (ParseException e) { + addError(e, skipStatement()); + } + throw new Error("Missing return statement in function"); + } + + final public void pseudo_page(AtRulePage page) throws ParseException { + Token n; + jj_consume_token(COLON); + n = jj_consume_token(IDENT); + label_39: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[50] = jj_gen; + break label_39; + } + jj_consume_token(S); + } + try { + page.setName(":" + convertIdent(n.image), ac); + } catch (InvalidParamException e) { + {if (true) throw new InvalidParamException("pseudo", n.image, ac );} + /*CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); */ + } + } + + final public void fontFace() throws ParseException { + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleFontFace()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); + try { + jj_consume_token(FONT_FACE_SYM); + label_40: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[51] = jj_gen; + break label_40; + } + jj_consume_token(S); + } + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + jj_consume_token(LBRACE); + label_41: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[52] = jj_gen; + break label_41; + } + jj_consume_token(S); + } + v = declarations(); + jj_consume_token(RBRACE); + label_42: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[53] = jj_gen; + break label_42; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, v); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + + final public void colorprofile() throws ParseException { + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleColorProfile()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); + try { + jj_consume_token(COLOR_PROFILE); + label_43: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[54] = jj_gen; + break label_43; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("svg")) { + skipStatement(); + addError(new InvalidParamException("onlysvg", "", ac), + getAtRule().toString()); + } + if (ac.getCssVersion().equals("svg")) { + newAtRule(getAtRule()); + } + jj_consume_token(LBRACE); + label_44: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[55] = jj_gen; + break label_44; + } + jj_consume_token(S); + } + v = declarations(); + jj_consume_token(RBRACE); + label_45: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[56] = jj_gen; + break label_45; + } + jj_consume_token(S); + } + if (ac.getCssVersion().equals("svg")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + //ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } catch (ParseException e) { + if (ac.getCssVersion().equals("svg")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + + final public void preference() throws ParseException { + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRulePreference()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); + try { + jj_consume_token(PREF_SYM); + label_46: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[57] = jj_gen; + break label_46; + } + jj_consume_token(S); + } + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + jj_consume_token(LBRACE); + label_47: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[58] = jj_gen; + break label_47; + } + jj_consume_token(S); + } + v = declarations(); + jj_consume_token(RBRACE); + label_48: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[59] = jj_gen; + break label_48; + } + jj_consume_token(S); + } + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + + final public void phoneticAlphabet() throws ParseException { + Vector v; + AtRule old = getAtRule(); + AtRulePhoneticAlphabet alphabetrule = new AtRulePhoneticAlphabet(); + setAtRule(alphabetrule); + Token n; + try { + jj_consume_token(PHONETIC_ALPHABET_SYM); + label_49: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[60] = jj_gen; + break label_49; + } + jj_consume_token(S); + } + n = jj_consume_token(STRING); + label_50: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[61] = jj_gen; + break label_50; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + if (!ac.getCssVersion().equals("css3")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + + alphabetrule.addAlphabet(convertIdent(n.image), ac); + + if (!ac.getCssVersion().equals("css1") && !ac.getCssVersion().equals("css2")) { + newAtRule(getAtRule()); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void atRuleDeclaration() throws ParseException { + Token n; + n = jj_consume_token(ATKEYWORD); + //ac.getFrame().addWarning("at-rule", token.toString()); + ac.getFrame().addError( + new CssError(new InvalidParamException("at-rule", + token, ac))); + skipStatement(); + } + +/** + * @exception ParseException exception during the parse + */ + final public void operator(CssExpression expr) throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + case DIV: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DIV: + jj_consume_token(DIV); + if (expr.getCount() > 0) expr.setOperator('/'); + break; + case COMMA: + jj_consume_token(COMMA); + if (expr.getCount() > 0) expr.setOperator(','); + break; + default: + jj_la1[62] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_51: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[63] = jj_gen; + break label_51; + } + jj_consume_token(S); + } + break; + default: + jj_la1[64] = jj_gen; + ; + } + } + +/** + * @exception ParseException exception during the parse + */ + final public char combinator() throws ParseException { + char connector = ' '; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case GREATER: + case TILDE: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + connector = '+' ; + break; + case GREATER: + jj_consume_token(GREATER); + connector = '>' ; + break; + case TILDE: + jj_consume_token(TILDE); + connector = '~' ; + break; + default: + jj_la1[65] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_52: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[66] = jj_gen; + break label_52; + } + jj_consume_token(S); + } + break; + case S: + label_53: + while (true) { + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[67] = jj_gen; + break label_53; + } + } + connector = ' ' ; + break; + default: + jj_la1[68] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return connector;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public char unaryOperator() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case MINUS: + jj_consume_token(MINUS); + {if (true) return '-';} + break; + case PLUS: + jj_consume_token(PLUS); + {if (true) return '+';} + break; + default: + jj_la1[69] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public String property() throws ParseException { + Token n; + n = jj_consume_token(IDENT); + label_54: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[70] = jj_gen; + break label_54; + } + jj_consume_token(S); + } + currentProperty = convertIdent(n.image); + {if (true) return currentProperty;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public void ruleSet() throws ParseException { + CssSelectors contextual; + Vector context_set = new Vector(); + Vector value_set = null; + currentContext = context_set; + try { + contextual = selector(); + if (contextual != null) { + context_set.addElement(contextual); + } + label_55: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[71] = jj_gen; + break label_55; + } + jj_consume_token(COMMA); + label_56: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[72] = jj_gen; + break label_56; + } + jj_consume_token(S); + } + contextual = selector(); + if (contextual != null) { + context_set.addElement(contextual); + } + } + jj_consume_token(LBRACE); + validSelector = (context_set.size() > 0); + label_57: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[73] = jj_gen; + break label_57; + } + jj_consume_token(S); + } + value_set = declarations(); + jj_consume_token(RBRACE); + label_58: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[74] = jj_gen; + break label_58; + } + jj_consume_token(S); + } + markRule = true; + + /* if (value_set == null) { + ac.getFrame().addWarning("no-declaration"); + } else {*/ + if (value_set != null) { + boolean first = true; + CssSelectors sel = null; + Enumeration e = context_set.elements(); + while (e.hasMoreElements()) { + sel = e.nextElement(); + if (first) { + handleRule(sel, value_set); + first = false; + } else { + // we need to duplicate properties in that case + // as property holds reference to the selectors and it interact + // badly with conflict detection + int vsize = value_set.size(); + Vector v = new Vector(vsize); + for (int i=0; i declarations() throws ParseException { + if(!validSelector) { + validSelector = true; + skip_to_matching_brace(); + return null; + } + + CssProperty values; + Vector value_set = new Vector(); + boolean wrong_value = true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + values = declaration(); + if (values != null) { + value_set.addElement(values); + wrong_value = false; + } /* else { + wrong_value = true; + } */ + currentProperty = null; + break; + default: + jj_la1[75] = jj_gen; + ; + } + label_59: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[76] = jj_gen; + break label_59; + } + jj_consume_token(SEMICOLON); + label_60: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[77] = jj_gen; + break label_60; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + values = declaration(); + if (values != null) { + value_set.addElement(values); + wrong_value = false; + }/* else { + wrong_value = true; + }*/ + currentProperty = null; + break; + default: + jj_la1[78] = jj_gen; + ; + } + } + if (!wrong_value) { + addProperty(value_set); + {if (true) return value_set;} + } else { + {if (true) return null;} + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public CssSelectors selector() throws ParseException { + char comb; + CssSelectors current; + try { + current = simple_selector(null); + label_61: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case PLUS: + case GREATER: + case TILDE: + ; + break; + default: + jj_la1[79] = jj_gen; + break label_61; + } + comb = combinator(); + if (ac.getProfile() != null) { + if (ac.getProfile().equals("mobile") || + getAtRule().toString().equals("@media atsc-tv") || + ac.getCssVersion().equals("css1")) { + if (comb == '+') + {if (true) throw new InvalidParamException("nocomb", "+", ac);} + if (comb == '>') + {if (true) throw new InvalidParamException("nocomb", ">", ac);} + } else if (ac.getProfile().equals("tv")) { + if (comb == '+') + {if (true) throw new InvalidParamException("nocomb", "+", ac);} + + } + } + if (!ac.getCssVersion().equals("css3")) { + if (comb == '~') { + {if (true) throw new InvalidParamException("nocomb", "~", ac);} + } + } + switch(comb) { + case '+': + current.addAdjacentSibling(new AdjacentSiblingSelector()); + break; + case '>': + current.addChild(new ChildSelector()); + break; + case '~': + current.addGeneralSibling(new GeneralSiblingSelector()); + break; + default: + current.addDescendant(new DescendantSelector()); + } + //current.setConnector(comb); + + current = simple_selector(current); + } + {if (true) return current;} + } catch (InvalidParamException ie) { + // skipStatement(); + // removeThisRule(); + ac.getFrame().addError(new CssError(ie)); + Token t = getToken(1); + StringBuilder s = new StringBuilder(); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + {if (true) return null;} + } catch (ParseException e) { + // validSelector = false; + Token t = getToken(1); + StringBuilder s = new StringBuilder("["); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + s.append(']'); + // if (validSelector) { + addError(e, s.toString()); + // } else { + // addError(e,""); + // } + validSelector = true; + {if (true) return null;} + } + throw new Error("Missing return statement in function"); + } + +/** + * I made this rule to parse a selector from a document. Combinator are avoid. + * @exception ParseException exception during the parse + */ + final public CssSelectors externalSelector() throws ParseException { + CssSelectors current; + current = simple_selector(null); + label_62: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[80] = jj_gen; + break label_62; + } + label_63: + while (true) { + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[81] = jj_gen; + break label_63; + } + } + current = simple_selector(current); + } + {if (true) return current;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public CssSelectors simple_selector(CssSelectors next) throws ParseException { + CssSelectors selector = new CssSelectors(ac, next); + selector.setAtRule(getAtRule()); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + case ANY: + case 98: + element_name(selector); + label_64: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + case HASH: + case LBRACKET: + case COLON: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case PSEUDOELEMENT_SYM: + case CLASS: + case FUNCTIONNOT: + ; + break; + default: + jj_la1[82] = jj_gen; + break label_64; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + case HASH: + hash(selector); + break; + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case CLASS: + _class(selector); + break; + case LBRACKET: + attrib(selector); + break; + case COLON: + case PSEUDOELEMENT_SYM: + pseudo(selector); + break; + case FUNCTIONNOT: + negation(selector); + break; + default: + jj_la1[83] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + {if (true) return selector;} + break; + case HASHIDENT: + case HASH: + case LBRACKET: + case COLON: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case PSEUDOELEMENT_SYM: + case CLASS: + case FUNCTIONNOT: + label_65: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + case HASH: + hash(selector); + break; + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case CLASS: + _class(selector); + break; + case LBRACKET: + attrib(selector); + break; + case COLON: + case PSEUDOELEMENT_SYM: + pseudo(selector); + break; + case FUNCTIONNOT: + negation(selector); + break; + default: + jj_la1[84] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + case HASH: + case LBRACKET: + case COLON: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case PSEUDOELEMENT_SYM: + case CLASS: + case FUNCTIONNOT: + ; + break; + default: + jj_la1[85] = jj_gen; + break label_65; + } + } + {if (true) return selector;} + break; + default: + jj_la1[86] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public void _class(CssSelectors s) throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CLASS: + /* "." n= { */ + n = jj_consume_token(CLASS); + try { + s.addClass(new ClassSelector(convertClassIdent(n.image.substring(1)))); + // s.addAttribute("class", convertIdent(n.image.substring(1)), + // CssSelectors.ATTRIBUTE_CLASS_SEL); + } catch (InvalidParamException e) { + // removeThisRule(); + ac.getFrame().addError(new CssError(e)); + {if (true) throw new ParseException(e.getMessage());} + } + break; + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + n = deprecated_class(); + if (n.image.charAt(0) == '.') { + n.image = n.image.substring(1); + + // the class with the first digit escaped + String cl = "."+hexEscapeFirst(n.image); + + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + if(!profile.equals("css1")) { + StringBuilder sb = new StringBuilder(); + Vector param_err = new Vector(2); + param_err.add(n.image); + param_err.add(cl); + sb.append(ac.getMsg().getString("parser.old_class", param_err)); + {if (true) throw new ParseException(sb.toString());} + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + CssLength length = new CssLength(); + boolean isLength = false; + try { + length.set(n.image, ac); + isLength = true; + } + catch(Exception e) { + isLength = false; + } + if(isLength) { + StringBuilder sb = new StringBuilder(); + sb.append(ac.getMsg().getString("parser.class_dim")); + sb.append(n.image); + {if (true) throw new ParseException(sb.toString());} + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + try { + // for css > 1, we add the rule to have a context, + // and we then remove it + s.addClass(new ClassSelector(n.image)); + ac.getFrame().addWarning("old_class"); + } catch (InvalidParamException e) { + {if (true) throw new ParseException(e.getMessage());} + //ac.getFrame().addError(new CssError(e)); + //removeThisRule(); + } + } + } + } else { + {if (true) throw new ParseException("Unrecognized ");} + } + break; + default: + jj_la1[87] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public Token deprecated_class() throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LENGTH: + n = jj_consume_token(LENGTH); + break; + case EMS: + n = jj_consume_token(EMS); + break; + case EXS: + n = jj_consume_token(EXS); + break; + case ANGLE: + n = jj_consume_token(ANGLE); + break; + case TIME: + n = jj_consume_token(TIME); + break; + case FREQ: + n = jj_consume_token(FREQ); + break; + case RESOLUTION: + n = jj_consume_token(RESOLUTION); + break; + case DIMEN: + n = jj_consume_token(DIMEN); + break; + default: + jj_la1[88] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return n;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public void element_name(CssSelectors s) throws ParseException { + Token n=null; + Token p=null; + String prefix = null; + if (jj_2_1(2)) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + case ANY: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + break; + case ANY: + n = jj_consume_token(ANY); + break; + default: + jj_la1[89] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[90] = jj_gen; + ; + } + p = jj_consume_token(98); + } else { + ; + } + // FIXME namespace, check versions of CSS in a better way. + if (p != null) { + if (!ac.getCssVersion().equals("css3")) { + StringBuilder sb = new StringBuilder("namespace \""); + if (n != null) sb.append(n.toString()); + sb.append("\""); + ac.getFrame().addError(new CssError(new + InvalidParamException("notversion", + "namespace", + ac.getCssVersion(), + ac))); + removeThisRule(); + } else if (n!=null) { + prefix = convertIdent(n.image); + if (!ac.isNamespaceDefined(getURL(), prefix)) { + // ns is not defined + addError(new ParseException("Undefined namespace"), + ": The namespace \""+prefix + +"\" is not defined. " + + prefix ); + removeThisRule(); + } + } else { + prefix = ""; + } + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + // s.setElement(convertIdent(n.image), ac); + s.addType(new TypeSelector(prefix, convertIdent(n.image))); + break; + case ANY: + jj_consume_token(ANY); + if (!ac.getCssVersion().equals("css1")) { + // s.setElement(null); + s.addUniversal(new UniversalSelector(prefix)); + } else { + ac.getFrame().addError(new CssError(new InvalidParamException("notversion", + "*", ac.getCssVersion(), ac))); + } + break; + default: + jj_la1[91] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void attrib(CssSelectors s) throws ParseException { + Token att = null; + Token val = null; + int selectorType = CssSelectors.ATTRIBUTE_ANY; + jj_consume_token(LBRACKET); + label_66: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[92] = jj_gen; + break label_66; + } + jj_consume_token(S); + } + att = jj_consume_token(IDENT); + label_67: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[93] = jj_gen; + break label_67; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INCLUDES: + case DASHMATCH: + case PREFIXMATCH: + case SUFFIXMATCH: + case SUBSTRINGMATCH: + case EQ: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQ: + jj_consume_token(EQ); + selectorType = CssSelectors.ATTRIBUTE_EXACT; + break; + case INCLUDES: + jj_consume_token(INCLUDES); + selectorType = CssSelectors.ATTRIBUTE_ONE_OF; + break; + case DASHMATCH: + jj_consume_token(DASHMATCH); + selectorType = CssSelectors.ATTRIBUTE_BEGIN; + break; + case PREFIXMATCH: + jj_consume_token(PREFIXMATCH); + selectorType = CssSelectors.ATTRIBUTE_START; + break; + case SUFFIXMATCH: + jj_consume_token(SUFFIXMATCH); + selectorType = CssSelectors.ATTRIBUTE_SUFFIX; + break; + case SUBSTRINGMATCH: + jj_consume_token(SUBSTRINGMATCH); + selectorType = CssSelectors.ATTRIBUTE_SUBSTR; + break; + default: + jj_la1[94] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_68: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[95] = jj_gen; + break label_68; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + val = jj_consume_token(IDENT); + val.image = convertIdent(val.image); + break; + case STRING: + val = jj_consume_token(STRING); + val.image = convertStringIndex(val.image, 1, val.image.length() -1, false); + break; + default: + jj_la1[96] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_69: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[97] = jj_gen; + break label_69; + } + jj_consume_token(S); + } + break; + default: + jj_la1[98] = jj_gen; + ; + } + jj_consume_token(RBRACKET); + if ("css1".equals(ac.getCssVersion())) { + StringBuilder reason; + CssParseException cp; + ParseException p; + reason = new StringBuilder(" ["); + if (att != null) { + reason.append(convertIdent(att.image)); + } + if (val != null ) { + reason.append('=').append(val.image); + } + reason.append(']'); + p = new ParseException(ac.getMsg().getString("parser.attrcss1")+ + reason.toString()); + cp = new CssParseException(p); + ac.getFrame().addError(new CssError(cp)); + removeThisRule(); + } + if (selectorType == CssSelectors.ATTRIBUTE_ANY) { + try { + s.addAttribute(new AttributeAny(att.image.toLowerCase())); +// s.addAttribute(att.image.toLowerCase(), null, selectorType); + } catch (InvalidParamException e) { + removeThisRule(); + ac.getFrame().addError(new CssError(e)); + } + } else { + AttributeSelector attribute; + switch(selectorType) { + case CssSelectors.ATTRIBUTE_BEGIN: + attribute = new AttributeBegin(att.image.toLowerCase(), + val.image); + break; + case CssSelectors.ATTRIBUTE_EXACT: + attribute = new AttributeExact(att.image.toLowerCase(), + val.image); + break; + case CssSelectors.ATTRIBUTE_ONE_OF: + attribute = new AttributeOneOf(att.image.toLowerCase(), + val.image); + break; + case CssSelectors.ATTRIBUTE_START: + attribute = new AttributeStart(att.image.toLowerCase(), + val.image); + break; + case CssSelectors.ATTRIBUTE_SUBSTR: + attribute = new AttributeSubstr(att.image.toLowerCase(), + val.image); + break; + case CssSelectors.ATTRIBUTE_SUFFIX: + attribute = new AttributeSuffix(att.image.toLowerCase(), + val.image); + break; + default: + attribute = new AttributeExact(att.image.toLowerCase(), + val.image); + break; + } + try { + s.addAttribute(attribute); +// s.addAttribute(att.image.toLowerCase(), val.image, +// selectorType); + } catch (InvalidParamException e) { + removeThisRule(); + ac.getFrame().addError(new CssError(e)); + } + } + } + + final public void negation(CssSelectors s) throws ParseException { + Token n; + CssSelectors ns = new CssSelectors(ac, null); + jj_consume_token(FUNCTIONNOT); + label_70: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[99] = jj_gen; + break label_70; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + case ANY: + case 98: + element_name(ns); + break; + case HASHIDENT: + case HASH: + hash(ns); + break; + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DIMEN: + case CLASS: + _class(ns); + break; + case LBRACKET: + attrib(ns); + break; + case COLON: + case PSEUDOELEMENT_SYM: + pseudo(ns); + break; + default: + jj_la1[100] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_71: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[101] = jj_gen; + break label_71; + } + jj_consume_token(S); + } + jj_consume_token(LPARAN); + s.setPseudoFun("not", ns.toString()); + } + +/** + * @exception ParseException exception during the parse + */ + final public void pseudo(CssSelectors s) throws ParseException { + Token n; +Token language = null; +CssExpression param = null; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PSEUDOELEMENT_SYM: + jj_consume_token(PSEUDOELEMENT_SYM); + n = jj_consume_token(IDENT); + try { + if (ac.getCssVersion().equals("css3")) { + s.addPseudoElement(convertIdent(n.image).toLowerCase()); + } else { + {if (true) throw new InvalidParamException("pseudo-element", + "::" + convertIdent(n.image).toLowerCase() , + ac.getCssVersion() ,ac);} + } + } catch(InvalidParamException e) { + // removeThisRule(); + // ac.getFrame().addError(new CssError(e)); + validSelector = false; + {if (true) throw new ParseException(e.getMessage());} + } + break; + case COLON: + jj_consume_token(COLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + try { + s.addPseudoClass(convertIdent(n.image).toLowerCase()); + } catch(InvalidParamException e) { + removeThisRule(); + ac.getFrame().addError(new CssError(e)); + } + break; + case FUNCTIONLANG: + case FUNCTION: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case FUNCTIONLANG: + n = jj_consume_token(FUNCTIONLANG); + label_72: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[102] = jj_gen; + break label_72; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NUMBER: + language = jj_consume_token(NUMBER); + break; + case IDENT: + language = jj_consume_token(IDENT); + break; + case STRING: + language = jj_consume_token(STRING); + break; + default: + jj_la1[103] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_73: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[104] = jj_gen; + break label_73; + } + jj_consume_token(S); + } + try { + s.setPseudoFun(convertStringIndex(n.image, 0, + n.image.length() -1, false).toLowerCase(), + convertIdent(language.image)); + } catch(InvalidParamException e) { + removeThisRule(); + ac.getFrame().addError(new CssError(e)); + } + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + label_74: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[105] = jj_gen; + break label_74; + } + jj_consume_token(S); + } + param = expression(); + try { + s.setPseudoFun(convertStringIndex(n.image, 0, + n.image.length() -1, + false).toLowerCase(), + param.toString()); + } catch(InvalidParamException e) { + removeThisRule(); + ac.getFrame().addError(new CssError(e)); + } + break; + default: + jj_la1[106] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(LPARAN); + break; + default: + jj_la1[107] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[108] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public void hash(CssSelectors s) throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + n = jj_consume_token(HASHIDENT); + n.image = n.image.substring(1); + if(Character.isDigit(n.image.charAt(0))) { + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + if(!profile.equals("css1")) { + // the id with the first digit escaped + String cl = "\\" + Integer.toString(n.image.charAt(0), 16); + cl += n.image.substring(1); + + addError(new ParseException(ac.getMsg().getString( + "parser.old_id")), + "To make \"." + n.image + "\" a valid id, CSS2" + + " requires the first digit to be escaped " + + "(\"#" + cl + "\")"); + // for css > 1, we add the rule to have a context, + // and we then remove it + s.addId(new IdSelector(n.image)); + removeThisRule(); + } + else { + CssLength length = new CssLength(); + boolean isLength = false; + try { + length.set(n.image, ac); + isLength = true; + } + catch(Exception e) { + isLength = false; + } + if(isLength) { + addError(new ParseException(ac.getMsg().getString( + "parser.id_dim")), n.image); + // we add the rule to have a context, and then we remove it + s.addId(new IdSelector(n.image)); + removeThisRule(); + } + else { + try { + s.addId(new IdSelector(n.image)); + ac.getFrame().addWarning("old_id"); + } catch (InvalidParamException e) { + ac.getFrame().addError(new CssError(e)); + removeThisRule(); + } + } + } + } + else { + try { + s.addId(new IdSelector(n.image)); + } catch (InvalidParamException e) { + ac.getFrame().addError(new CssError(e)); + removeThisRule(); + } + } + break; + case HASH: + n = jj_consume_token(HASH); + {if (true) throw new ParseException(ac.getMsg().getString("parser.invalid_id_selector"));} + break; + default: + jj_la1[109] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public CssProperty mediadeclaration() throws ParseException { + String string_property; + CssExpression values = null; + boolean important = false; + setMediaDeclaration("on"); + try { + string_property = property(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_75: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[110] = jj_gen; + break label_75; + } + jj_consume_token(S); + } + values = expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[111] = jj_gen; + ; + } + break; + default: + jj_la1[112] = jj_gen; + ; + } + try { + + setImportant(important); + + if (incompatible_error) { + {if (true) throw new InvalidParamException("notforcss1", "inherit", ac);} + } + + CssProperty p = handleDeclaration(string_property.toLowerCase(), + values, important); + {if (true) return p;} + + } catch (InvalidParamException e) { + incompatible_error = false; + if (null != values) { + values.starts(); + } + addError(e, (CssExpression) values); + } + {if (true) return null;} + } catch (NumberFormatException e) { + skipAfterExpression(e); + {if (true) return null;} + } catch (ParseException e) { + skipAfterExpression(e); + {if (true) return null;} + } finally { + setMediaDeclaration("off"); + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public CssProperty declaration() throws ParseException { + String string_property; + CssExpression values; + boolean important = false; + try { + string_property = property(); + jj_consume_token(COLON); + label_76: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[113] = jj_gen; + break label_76; + } + jj_consume_token(S); + } + values = expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[114] = jj_gen; + ; + } + try { + + setImportant(important); + + if (incompatible_error) { + {if (true) throw new InvalidParamException("notforcss1", "inherit", ac);} + } + + if (values.getCount() != 0) { + CssProperty p = handleDeclaration(string_property.toLowerCase(), + values, important); + // Did the property recognize all values in the expression ? + + if (!values.end() && ac.getMedium() == null) { + addError(new InvalidParamException("unrecognize", "", ac), + values); + } else { + // ok, return the new property + {if (true) return p;} + } + } + } catch (InvalidParamException e) { + incompatible_error = false; + values.starts(); + addError(e, (CssExpression) values); + } + {if (true) return null;} + } catch (NumberFormatException e) { + skipAfterExpression(e); + {if (true) return null;} + } catch (ParseException e) { + skipAfterExpression(e); + {if (true) return null;} + } catch (NullPointerException e) { + // NullPointerException happen if in handling a property + // something bad happen (like setting values on sub properties + // that had not been initialized (for an unknown reason yet). + skipAfterExpression(e); + {if (true) return null;} + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public boolean prio() throws ParseException { + jj_consume_token(IMPORTANT_SYM); + label_77: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[115] = jj_gen; + break label_77; + } + jj_consume_token(S); + } + {if (true) return true;} + throw new Error("Missing return statement in function"); + } + + final public CssExpression expression() throws ParseException { + CssExpression exp = new CssExpression(); + char operator = ' '; + Token n = null; + label_78: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + jj_consume_token(PLUS); + operator = '+' ; + break; + case MINUS: + jj_consume_token(MINUS); + operator = '-'; + break; + case NUMBER: + n = jj_consume_token(NUMBER); + setValue(new CssNumber(), exp, operator, n, NUMBER); + break; + case DIMEN: + n = jj_consume_token(DIMEN); + setValue(new CssIdent(), exp, operator, n, IDENT); + break; + case STRING: + n = jj_consume_token(STRING); + setValue(new CssString(), exp, operator, n, STRING); + break; + case IDENT: + n = jj_consume_token(IDENT); + setValue(new CssIdent(), exp, operator, n, IDENT); + break; + default: + jj_la1[116] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_79: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[117] = jj_gen; + break label_79; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case STRING: + case IDENT: + case MINUS: + case DIMEN: + case NUMBER: + ; + break; + default: + jj_la1[118] = jj_gen; + break label_78; + } + } + {if (true) return exp;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public CssExpression expr() throws ParseException { + CssExpression values = new CssExpression(); + term(values); + label_80: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case COMMA: + case STRING: + case IDENT: + case HASHIDENT: + case HASH: + case MINUS: + case DIV: + case URL: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DATE: + case DIMEN: + case PERCENTAGE: + case NUMBER: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[119] = jj_gen; + break label_80; + } + operator(values); + term(values); + } + {if (true) return values;} + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public void term(CssExpression exp) throws ParseException { + Token n; + char operator = ' '; + CssValue func; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case LENGTH: + case EMS: + case EXS: + case ANGLE: + case TIME: + case FREQ: + case RESOLUTION: + case DATE: + case DIMEN: + case PERCENTAGE: + case NUMBER: + case FUNCTION: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + operator = unaryOperator(); + break; + default: + jj_la1[120] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NUMBER: + n = jj_consume_token(NUMBER); + setValue(new CssNumber(), exp, operator, n, NUMBER); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + setValue(new CssPercentage(), exp, operator, n, + PERCENTAGE); + break; + case LENGTH: + n = jj_consume_token(LENGTH); + setValue(new CssLength(), exp, operator, n, LENGTH); + break; + case EMS: + n = jj_consume_token(EMS); + setValue(new CssLength(), exp, operator, n, EMS); + break; + case EXS: + n = jj_consume_token(EXS); + setValue(new CssLength(), exp, operator, n, EXS); + break; + case ANGLE: + n = jj_consume_token(ANGLE); + setValue(new CssAngle(), exp, operator, n, ANGLE); + break; + case TIME: + n = jj_consume_token(TIME); + setValue(new CssTime(), exp, operator, n, TIME); + break; + case FREQ: + n = jj_consume_token(FREQ); + setValue(new CssFrequency(), exp, operator, n, FREQ); + break; + case RESOLUTION: + n = jj_consume_token(RESOLUTION); + setValue(new CssResolution(), exp, operator, n, RESOLUTION); + break; + case DATE: + n = jj_consume_token(DATE); + setValue(new CssDate(), exp, operator, n, DATE); + break; + case DIMEN: + n = jj_consume_token(DIMEN); + addError(new ParseException(ac.getMsg().getString("parser.unknown-dimension")), n.image); + break; + case FUNCTION: + func = function(); + setValue(func, exp, operator, null, FUNCTION); + break; + default: + jj_la1[121] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_81: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[122] = jj_gen; + break label_81; + } + jj_consume_token(S); + } + break; + case STRING: + case IDENT: + case HASHIDENT: + case HASH: + case URL: + case UNICODERANGE: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + setValue(new CssString(), exp, operator, n, STRING); + break; + case IDENT: + n = jj_consume_token(IDENT); + /* + * Common error : + * H1 { + * color : black + * background : white + * } + */ + Token t = getToken(1); + Token semicolon = new Token(); + semicolon.kind = SEMICOLON; + semicolon.image = ";"; + if (t.kind == COLON) { + /* @@SEEME. (generate a warning?) */ + /* @@SEEME if expression is a single ident, + generate an error ? */ + addError(new ParseException(ac.getMsg().getString("parser.semi-colon")), + (CssExpression) null); + rejectToken(semicolon); + } else { + setValue(new CssIdent(), exp, operator, n, IDENT); + } + break; + case HASHIDENT: + case HASH: + hexcolor(exp); + break; + case URL: + n = jj_consume_token(URL); + CssURL _u = new CssURL(); + _u.set(n.image, ac, url); + exp.addValue(_u); + break; + case UNICODERANGE: + n = jj_consume_token(UNICODERANGE); + setValue(new CssUnicodeRange(), exp, operator, n, + UNICODERANGE); + break; + default: + jj_la1[123] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_82: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[124] = jj_gen; + break label_82; + } + jj_consume_token(S); + } + break; + default: + jj_la1[125] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + +/** + * @exception ParseException exception during the parse + */ + final public CssValue function() throws ParseException { + Token n; + CssExpression exp; + org.w3c.css.values.CssColor color = new org.w3c.css.values.CssColor(); + org.w3c.css.values.ATSCColor colorATSC = new org.w3c.css.values.ATSCColor(); + n = jj_consume_token(FUNCTION); + label_83: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[126] = jj_gen; + break label_83; + } + jj_consume_token(S); + } + exp = expr(); + jj_consume_token(LPARAN); + String funcname = n.image.toLowerCase(); + if (funcname.equals("rgb(")) { + if (!getAtRule().toString().equals("@media atsc-tv")) { + color.setRGBColor(exp, ac); + {if (true) return color;} + } else { + colorATSC.setRGBColor(exp, ac); + {if (true) return colorATSC;} + } + } else if (n.image.toLowerCase().equals("atsc-rgba(")) { + if (getAtRule().toString().equals("@media atsc-tv")) { + colorATSC.setATSCrgba(exp, ac); + {if (true) return colorATSC;} + } else { + addError(new InvalidParamException("onlyATSC", "", ac), + getAtRule().toString()); + {if (true) return null;} + } + } else { + CssFunction f = new CssFunction(); + f.set(n.image.substring(0, n.image.length() - 1), + exp); + {if (true) return f;} + } + throw new Error("Missing return statement in function"); + } + +/** + * @exception ParseException exception during the parse + */ + final public void hexcolor(CssExpression exp) throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASHIDENT: + n = jj_consume_token(HASHIDENT); + break; + case HASH: + n = jj_consume_token(HASH); + break; + default: + jj_la1[127] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + n.image = Util.strip(n.image); + setValue(new org.w3c.css.values.CssColor(), exp, ' ', n, HASH); + } + + String skipStatement() throws ParseException { + StringBuilder s = new StringBuilder(); + Token tok = getToken(0); + boolean first = true; + + if (tok.image != null) { + s.append(tok.image); + } + /* FIXME here, two option, we skip during an error, or outside + an error, currently both can fail with a TokenMgrError, should + we catch all, or only when filling message for errors? + + -> taking the "always skip" approach. + */ + while (true) { + try { + tok = getToken(1); + if (tok.kind == EOF) { + if (first) { + return null; + } else { + break; + } + } + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if ((tok.kind == RBRACE) || (tok.kind == SEMICOLON)) { + getNextToken(); + tok = getToken(1); + break; + } + getNextToken(); + } catch (TokenMgrError tokenerror) { + // read one char at a time, and loop + try { + s.append(jj_input_stream.readChar()); + continue; + } catch (java.io.IOException ioex) { + return s.toString().trim(); + } + } + first = false; + } + + // skip white space + while (tok.kind == S) { + getNextToken(); + tok = getToken(1); + } + String statement = s.toString().trim(); + return statement; + } + + String skip_to_matching_brace() throws ParseException { + StringBuilder s = new StringBuilder(); + Token tok; + int nesting = 1; + /* FIXME + same as above */ + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + break; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + nesting++; + } else if (tok.kind == RBRACE) { + nesting--; + if (nesting == 0) { + break; + } + } + getNextToken(); + } + return s.toString(); + } + + void rejectToken(Token t) throws ParseException { + Token fakeToken = new Token(); + t.next = token; + fakeToken.next = t; + token = fakeToken; + } + + void skipAfterExpression(Exception e) throws ParseException { + StringBuilder s = new StringBuilder(); + s.append(getToken(0).image); + while (true) { + try { + Token t = getToken(1); + if (t.kind == LBRACE) { + s.append(t.image); + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + t = getToken(1); + continue; + } + if ((t.kind == SEMICOLON) || (t.kind == RBRACE) + || (t.kind == EOF)) { + break; + } + s.append(t.image); + getNextToken(); + t = getToken(1); + } catch (TokenMgrError tmerr) { + try { + s.append(jj_input_stream.readChar()); + continue; + } catch (java.io.IOException ioex) { + ioex.printStackTrace(); + break; + } + } + } + String statement = s.toString().trim(); + addError(e, s.toString()); + } + + String convertStringIndex(String s, int start, int len, boolean escapeFirst) throws ParseException { + int index = start; + int t; + int maxCount = 0; + if ((start == 0) && (len == s.length()) && (s.indexOf('\\') == -1)) { + return s; + } + StringBuilder buf = new StringBuilder(len); + + while (index < len) { + char c = s.charAt(index); + if (c == '\\') { + if (++index < len) { + c = s.charAt(index); + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + int numValue = Character.digit(c, 16); + int count = 1; + if (maxCount == 0) { + maxCount = (ac.getCssVersion().equals("css1") ? + 4 : 6); + } + while (index + 1 < len) { + c = s.charAt(index+1); + t = Character.digit(c, 16); + if (t != -1 && count++ < maxCount) { + numValue = (numValue<<4) | t; + index++; + } else { + if (c == ' ' || c == '\t' || + c == '\n' || c == '\f' ) { + // skip the latest white space + index++; + } else if ( c == '\r' ) { + index++; + // special case for \r\n + if (index+1 < len) { + if (s.charAt(index + 1) == '\n') { + index++; + } + } + } + break; + } + } + if (!escapeFirst && numValue < 255 && numValue>31) { + if (! ( (numValue>96 && numValue<123) // [a-z] + || (numValue>64 && numValue<91) // [A-Z] + || (numValue>47 && numValue<58) // [0-9] + || (numValue == 95) // _ + || (numValue == 45) // - + ) + ) { + buf.append('\\'); + } + buf.append((char) numValue); + break; + } + char b[] = new char[maxCount]; + t = maxCount; + while (t > 0) { + b[--t] = hexdigits[numValue & 0xF]; + numValue >>>= 4; + } + buf.append('\\').append(b); + break; + case '\n': + case '\f': + break; + case '\r': + if (index + 1 < len) { + if (s.charAt(index + 1) == '\n') { + index ++; + } + } + break; + case '-' : case '_' : case 'g' : case 'G' : + case 'h' : case 'H' : case 'i' : case 'I' : + case 'j' : case 'J' : case 'k' : case 'K' : + case 'l' : case 'L' : case 'm' : case 'M' : + case 'n' : case 'N' : case 'o' : case 'O' : + case 'p' : case 'P' : case 'q' : case 'Q' : + case 'r' : case 'R' : case 's' : case 'S' : + case 't' : case 'T' : case 'u' : case 'U' : + case 'v' : case 'V' : case 'w' : case 'W' : + case 'x' : case 'X' : case 'y' : case 'Y' : + case 'z' : case 'Z' : + buf.append(c); + break; + default: + buf.append('\\').append(c); + } + } else { + throw new ParseException("invalid string"); + } + } else { + buf.append(c); + } + escapeFirst = false; + index++; + } + return buf.toString(); + } + + String convertIdent(String s) throws ParseException { + return convertStringIndex(s, 0, s.length(), false); + } + + String convertClassIdent(String s) throws ParseException { + return convertStringIndex(s, 0, s.length(), true); + } + + String convertString(String s) throws ParseException { + return convertStringIndex(s, 0, s.length(), false); + } + + String hexEscapeFirst(String s) throws ParseException { + StringBuilder sb = new StringBuilder(); + sb.append('\\').append(Integer.toString(s.charAt(0), 16)); + char c = s.charAt(1); + if (((c >= '0') && (c <= '9')) || + ((c >= 'A') && (c <= 'F')) || + ((c >= 'a') && (c <= 'f'))) { + sb.append(' '); + } + sb.append(s.substring(1)); + return sb.toString(); + } + + final private boolean jj_2_1(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_1(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(0, xla); } + } + + final private boolean jj_3_1() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_84()) jj_scanpos = xsp; + if (jj_scan_token(98)) return true; + return false; + } + + final private boolean jj_3R_84() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(34)) { + jj_scanpos = xsp; + if (jj_scan_token(47)) return true; + } + return false; + } + + public CssParserTokenManager token_source; + SimpleCharStream jj_input_stream; + public Token token, jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + public boolean lookingAhead = false; + private boolean jj_semLA; + private int jj_gen; + final private int[] jj_la1 = new int[128]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static private int[] jj_la1_2; + static private int[] jj_la1_3; + static { + jj_la1_0(); + jj_la1_1(); + jj_la1_2(); + jj_la1_3(); + } + private static void jj_la1_0() { + jj_la1_0 = new int[] {0x0,0x0,0x0,0xe00000,0xe00000,0x0,0x0,0x200000,0x200000,0x0,0xc00000,0xc00000,0x200000,0x200000,0x200000,0x0,0x0,0x200000,0x200000,0x200000,0x0,0x200000,0x20000000,0x200000,0x0,0x200000,0x200000,0x200000,0x0,0x20000000,0x200000,0x80000000,0x200000,0x200000,0x200000,0x200000,0x0,0x200000,0x200000,0x200000,0x200000,0x0,0x0,0x200000,0x200000,0x0,0x0,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x200000,0x20000000,0x200000,0x20000000,0x58000000,0x200000,0x200000,0x58200000,0x8000000,0x200000,0x20000000,0x200000,0x200000,0x200000,0x0,0x0,0x200000,0x0,0x58200000,0x200000,0x200000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x200000,0x200000,0x3000000,0x200000,0x0,0x200000,0x3000000,0x200000,0x0,0x200000,0x200000,0x0,0x200000,0x200000,0x0,0x0,0x0,0x0,0x200000,0x0,0x0,0x200000,0x0,0x200000,0x8000000,0x200000,0x8000000,0x28000000,0x8000000,0x0,0x200000,0x0,0x200000,0x8000000,0x200000,0x0,}; + } + private static void jj_la1_1() { + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5fc8a01c,0x0,0x0,0x0,0x0,0x0,0x4,0x200001,0x0,0x0,0x0,0x200001,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x100000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5fc8a01c,0x0,0x0,0x0,0x0,0x4,0x80000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x1000,0x0,0x0,0x0,0x0,0x400,0x0,0x0,0x0,0x0,0x0,0x4,0x800,0x0,0x4,0x0,0x0,0x0,0x5fc82018,0x5fc82018,0x5fc82018,0x5fc82018,0x5fc8a01c,0x5fc00000,0x5fc00000,0x8004,0x8004,0x8004,0x0,0x0,0x3c0,0x0,0x5,0x0,0x3c0,0x0,0x5fc8a01c,0x0,0x0,0x5,0x0,0x0,0x0,0x4,0x80000,0x18,0x0,0x0,0x80000,0x0,0x0,0x0,0x40000405,0x0,0x40000405,0xffe0141d,0x400,0xffc00000,0x0,0x20001d,0x0,0xffe0041d,0x0,0x18,}; + } + private static void jj_la1_2() { + jj_la1_2 = new int[] {0x0,0x0,0x8,0x0,0x0,0x10,0x20,0x0,0x0,0x500107c4,0x20000,0x20000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x50000004,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7800,0x7800,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x50000004,0x50000004,0x50000004,0x50000004,0x50000004,0x10000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10000004,0x0,0x0,0x1,0x0,0x0,0xa0000000,0xa0000000,0x4,0x0,0x0,0x2,0x0,0x0,0x2,0x0,0x1,0x0,0x1,0x88000001,0x0,0x80000001,0x0,0x8000000,0x0,0x88000001,0x0,0x0,}; + } + private static void jj_la1_3() { + jj_la1_3 = new int[] {0x3,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + } + final private JJCalls[] jj_2_rtns = new JJCalls[1]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + public CssParser(java.io.InputStream stream) { + this(stream, null); + } + public CssParser(java.io.InputStream stream, String encoding) { + try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source = new CssParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + public void ReInit(java.io.InputStream stream) { + ReInit(stream, null); + } + public void ReInit(java.io.InputStream stream, String encoding) { + try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + public CssParser(java.io.Reader stream) { + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new CssParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + public void ReInit(java.io.Reader stream) { + jj_input_stream.ReInit(stream, 1, 1); + token_source.ReInit(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + public CssParser(CssParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + public void ReInit(CssParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 128; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + final private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) c.first = null; + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { } + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + final private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; Token tok = token; + while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } + if (tok != null) jj_add_error_token(kind, i); + } + if (jj_scanpos.kind != kind) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; + return false; + } + + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + + final public Token getToken(int index) { + Token t = lookingAhead ? jj_scanpos : token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + final private int jj_ntk() { + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.Vector jj_expentries = new java.util.Vector(); + private int[] jj_expentry; + private int jj_kind = -1; + private int[] jj_lasttokens = new int[100]; + private int jj_endpos; + + private void jj_add_error_token(int kind, int pos) { + if (pos >= 100) return; + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + boolean exists = false; + for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { + int[] oldentry = (int[])(e.nextElement()); + if (oldentry.length == jj_expentry.length) { + exists = true; + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + exists = false; + break; + } + } + if (exists) break; + } + } + if (!exists) jj_expentries.addElement(jj_expentry); + if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + + public ParseException generateParseException() { + jj_expentries.removeAllElements(); + boolean[] la1tokens = new boolean[99]; + for (int i = 0; i < 99; i++) { + la1tokens[i] = false; + } + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 128; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { + jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: jj_3_1(); break; + } + } + p = p.next; + } while (p != null); + } catch(LookaheadSuccess ls) { } + } + jj_rescan = false; + } + + final private void jj_save(int index, int xla) { + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { p = p.next = new JJCalls(); break; } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; + } + + static final class JJCalls { + int gen; + Token first; + int arg; + JJCalls next; + } + +} diff -r 03c1ce55e5ef -r 1a02e8a8be9c org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CssParser.jj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/cssvalidation-src/org/w3c/css/parser/analyzer/CssParser.jj Thu Jan 07 14:06:06 2010 -0800 @@ -0,0 +1,2425 @@ +/* -*-java-extended-*- + * + * (c) COPYRIGHT MIT and INRIA, 1997. + * Please first read the full copyright statement in file COPYRIGHT.html + * + * $Id: CssParser.jj,v 1.69 2009-10-11 09:19:37 ylafon Exp $ + * + */ + +options { + IGNORE_CASE = true; + STATIC = false; + UNICODE_INPUT = true; + /* + DEBUG_TOKEN_MANAGER = true; + DEBUG_PARSER = true; + */ +} + +PARSER_BEGIN(CssParser) + +package org.w3c.css.parser.analyzer; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.Vector; +import java.util.Enumeration; +import java.net.URL; + +import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssString; +import org.w3c.css.values.CssURL; +import org.w3c.css.values.CssLength; +import org.w3c.css.values.CssNumber; +import org.w3c.css.values.CssColor; +import org.w3c.css.values.CssIdent; +import org.w3c.css.values.CssPercentage; +import org.w3c.css.values.CssFrequency; +import org.w3c.css.values.CssTime; +import org.w3c.css.values.CssDate; +import org.w3c.css.values.CssAngle; +import org.w3c.css.values.CssFunction; +import org.w3c.css.values.CssUnicodeRange; +import org.w3c.css.values.CssResolution; +import org.w3c.css.properties.css1.CssProperty; +import org.w3c.css.parser.Frame; +import org.w3c.css.util.ApplContext; +import org.w3c.css.parser.CssError; +import org.w3c.css.parser.CssSelectors; +import org.w3c.css.parser.CssParseException; +import org.w3c.css.parser.AtRule; +import org.w3c.css.parser.AtRuleMedia; +import org.w3c.css.parser.AtRuleFontFace; +import org.w3c.css.parser.AtRulePage; +import org.w3c.css.parser.AtRulePreference; +import org.w3c.css.parser.AtRulePhoneticAlphabet; +import org.w3c.css.properties.svg.AtRuleColorProfile; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.util.Util; +import org.w3c.css.util.Messages; +import org.w3c.css.css.StyleSheetCom; + +import org.w3c.css.selectors.AdjacentSiblingSelector; +import org.w3c.css.selectors.AttributeSelector; +import org.w3c.css.selectors.ChildSelector; +import org.w3c.css.selectors.ClassSelector; +import org.w3c.css.selectors.DescendantSelector; +import org.w3c.css.selectors.GeneralSiblingSelector; +import org.w3c.css.selectors.IdSelector; +import org.w3c.css.selectors.TypeSelector; +import org.w3c.css.selectors.UniversalSelector; +import org.w3c.css.selectors.attributes.AttributeAny; +import org.w3c.css.selectors.attributes.AttributeBegin; +import org.w3c.css.selectors.attributes.AttributeExact; +import org.w3c.css.selectors.attributes.AttributeOneOf; +import org.w3c.css.selectors.attributes.AttributeStart; +import org.w3c.css.selectors.attributes.AttributeSubstr; +import org.w3c.css.selectors.attributes.AttributeSuffix; + +/** + * A CSS3 parser + * + * @author Philippe Le Hegaret and Sijtsche Smeman + * @version $Revision: 1.69 $ + */ +public abstract class CssParser { + + private static char hexdigits[] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f' }; + // the current atRule + protected AtRule atRule; + protected String mediaDeclaration = "off"; + + /** + * The URL of the document + */ + protected URL url; + + protected ApplContext ac; + + protected boolean incompatible_error; + + /** + * The current context recognized by the parser (for errors). + */ + protected Vector currentContext; + + /** + * The current property recognized by the parser (for errors). + */ + protected String currentProperty; + + /** + * true if the parser should recognized Aural properties, + * false otherwise. + */ + protected boolean mode; + + /** + * true if the parser had recognize a rule, + * false otherwise. + */ + protected boolean markRule; + + private boolean reinited = false; + private boolean charsetdeclared = false; + + static StringBuilder SPACE = new StringBuilder(" "); + + // to be able to remove a ruleset if the selector is not valid + protected boolean validSelector = true; + + /** + * The ac for handling errors and warnings. + * + * @param ac the new ac for the parser. + */ + public final void setApplContext(ApplContext ac) { + this.ac = ac; + } + + /** + * Set the attribute atRule + * + * @param atRule the new value for the attribute + */ + public void setAtRule(AtRule atRule) { + this.atRule = atRule; + } + + /** + * Set the attribute mediaDeclaration + * + * @param mediaDeclaration indicator if in a media expression list or not + */ + public void setMediaDeclaration(String mediadeclaration) { + this.mediaDeclaration = mediadeclaration; + } + + /** + * Returns the attribute mediaDeclaration + * + * @return the value of the attribute + */ + public String getMediaDeclaration() { + return mediaDeclaration; + } + + /** + * Returns the attribute atRule + * + * @return the value of the attribute + */ + public AtRule getAtRule() { + return atRule; + } + + /** + * Reinitialized the parser. + * + * @param stream the stream data to parse. + * @param ac the new ac to use for parsing. + */ + public void ReInitWithAc(InputStream stream, ApplContext ac, + String charset) + { + InputStream is = /*new CommentSkipperInputStream(stream);*/stream; + if (charset == null) { + charset = "iso-8859-1"; + } + InputStreamReader isr = null; + try { + isr = new InputStreamReader(is, charset); + } catch (UnsupportedEncodingException uex) { + isr = new InputStreamReader(is); + } + // reinit, it can not happen... + // ...in theory ;) + ReInit(isr); + markRule = false; + reinited = true; + setApplContext(ac); + } + + /* utilities for a parser */ + + /** + * Call by the import statement. + * + * @param url The style sheet where this import statement appears. + * @param file the file name in the import + */ + public abstract void handleImport(URL url, String file, + boolean is_url, AtRuleMedia media); + + /** + * Call by the namespace declaration statement. + * + * @param url The style sheet where this namespace statement appears. + * @param file the file/url name in the namespace declaration + */ + public abstract void handleNamespaceDeclaration(URL url, String prefix, + String file, + boolean is_url); + + /** + * Call by the at-rule statement. + * + * @param ident The ident for this at-rule (for example: 'font-face') + * @param string The string associate to this at-rule + * @see org.w3c.css.parser.Analyzer.Couple + */ + public abstract void handleAtRule(String ident, String string); + + /* added by Sijtsche Smeman */ + public abstract void addCharSet(String charset); + public abstract void newAtRule(AtRule atRule); + public abstract void endOfAtRule(); + public abstract void setImportant(boolean important); + public abstract void setSelectorList(Vector selectors); + public abstract void addProperty(Vector properties); + public abstract void endOfRule(); + public abstract void removeThisRule(); + public abstract void removeThisAtRule(); + + /** + * Assign an expression to a property. This function create a new property + * with property and assign to it the expression with the + * importance. Don't forget to set informations too. + *

      + * A subclass must provide an implementation of this method. + * + * @param property the name of the property + * @param values the expression representation of values + * @param important true if values are important + * + * @return nullor a property + * + * @see org.w3c.css.css.CssProperty + */ + public abstract CssProperty handleDeclaration(String property, + CssExpression values, + boolean important) + throws InvalidParamException; + + /** + * Adds a vector of properties to a selector. + *

      + * A subclass must provide an implementation of this method. + * + * @param selector the selector + * @param declarations Properties to associate with contexts + */ + public abstract void handleRule(CssSelectors selector, + Vector declarations); + + /*Added by Sijtsche Smeman */ + + /** + * Returns the source file of the style sheet + */ + public final String getSourceFile() { + return getURL().toString(); + } + + /** + * Returns the current line in the style sheet + */ + public final int getLine() { + //return token.beginLine; + return 0; + } + + /** + * Set the URL of the style sheet. + * + * @param URL The URL for the style sheet + */ + public final void setURL(URL url) { + this.url = url; + } + + public final URL getURL() { + return url; + } + + /** + * Return the next selector from the inputstream + */ + public CssSelectors parseSelector() throws ParseException { + return externalSelector(); + } + + /* + * Add a value to an expression + */ + private void setValue(CssValue v, CssExpression expr, + char operator, Token n, int token) + throws ParseException { + if (n != null) { + if (ac.getCssVersion().equals("css1") && + (n.image).equals("inherit")) { + incompatible_error = true; + } + String val = (operator == ' ') ? n.image : operator+n.image; + + if (n.kind == CssParserConstants.IDENT) { + v.set(convertIdent(val), ac); + } else if (n.kind == CssParserConstants.STRING) { + v.set(val, ac); + } else { + v.set(val, ac); + } + } + expr.addValue(v); + } + + /* + * Error control + */ + private void addError(Exception e, String skippedText) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + CssParseException ex = new CssParseException(e); + ex.setSkippedString(skippedText); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + } + + /* + * Error control 2 + */ + private void addError(Exception e, CssExpression exp) { + if (Util.onDebug) { + System.err.println(e.getMessage()); + e.printStackTrace(); + } + + // if ((exp != null) && (exp.getCount() != 0)) { + CssParseException ex = new CssParseException(e); + ex.setExp(exp); + ex.setProperty(currentProperty); + ex.setContexts(currentContext); + CssError error = new CssError(getSourceFile(), getLine(), ex); + ac.getFrame().addError(error); + // } + } +} + +PARSER_END(CssParser) + +/* + * The tokenizer + */ + + +SPECIAL_TOKEN : +{ + < COMMENT : "/*" ( ~["*"] )* ( "*" )+ ( ~["/", "*"] ( ~["*"] )* ( "*" )+ )* "/" > +} + + + TOKEN [IGNORE_CASE] : /* basic tokens */ +{ + < #H : ["0"-"9", "a"-"f"] > + | < #NONASCII : ["\200"-"\377"] > + | < #UNICODE : "\\" ( )? ( )? ( )? ( )? ( )? + ( "\r\n" | [ " ", "\t" , "\n" , "\r", "\f" ] )? > + | < #ESCAPE : | ( "\\" ~[ "\r", "\n", "\f", "0"-"9", "a"-"f" ] ) > + | < #NMSTART : [ "a"-"z", "_" ] | | > + | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > + | < #STRING1 : "\"" ( ~[ "\n", "\r", "\f", "\\", "\"" ] | "\\" | )* "\"" > + | < #STRING2 : "\'" ( ~[ "\n", "\r", "\f", "\\", "\'" ] | "\\" | )* "\'" > + | < #INVALID1 : "\"" ( ~[ "\n", "\r", "\f", "\\", "\"" ] | "\\" | )* > + | < #INVALID2 : "\'" ( ~[ "\n", "\r", "\f", "\\", "\'" ] | "\\" | )* > + | < #_IDENT : ( )? ( )* > + | < #NAME : ( )+ > + | < #NUM : ( ["0"-"9"] )+ | ( ["0"-"9"] )* "." ( ["0"-"9"] )+ > + | < #_STRING : | > + | < #_INVALID : | > + | < #_URL : ( [ "!", "#", "$", "%", "&", "*"-"[", "]"-"~" ] | | )* > + | < #_S : ( [ " ", "\t" , "\n" , "\r", "\f" ] ) ( | [ " ", "\t" , "\n" , "\r", "\f" ] )* > + | < #_W : ( <_S> )? > + | < #NL : ( "\n" | "\r\n" | "\r" | "\f" ) > +} +/* + * The _S definition is not ( [ " ", "\t" , "\n" , "\r", "\f" ] ) + as we need to add support + * for the unput(' ') (see http://www.w3.org/TR/CSS21/grammar.html#scanner ) + */ + + +TOKEN : +{ + < S : ( <_S> ) > +} + + + TOKEN : +{ + < CDO : "" > + | < INCLUDES : "=" > + | < DASHMATCH : "|=" > +} + + +TOKEN : +{ + < LBRACE : <_W> "{" > + | < PLUS : <_W> "+" > + | < GREATER : <_W> ">" > + | < COMMA : <_W> "," > + | < TILDE : <_W> "~" > +} + + +TOKEN [IGNORE_CASE] : +{ + < AND : "and" > +} + + +TOKEN : +{ + > + | > + | > + | > + | > +} + + +TOKEN : +{ + < RBRACE : "}"> + | < PREFIXMATCH : "^=" > + | < SUFFIXMATCH : "$=" > + | < SUBSTRINGMATCH : "*=" > + | < EQ : "=" > + | < MINUS : "-" > + | < SEMICOLON : ";" > + | < DIV : "/" > + | < LBRACKET : "[" > + | < RBRACKET : "]" > + | < ANY : "*" > + | < DOT : "." > + | < LPARAN : ")" > + | < RPARAN : "("> +} + + + TOKEN : +{ + < COLON : ":" > +} + + +TOKEN [IGNORE_CASE] : +{ + < MEDIARESTRICTOR : "only" | "not" > +} + + +TOKEN [IGNORE_CASE] : +{ + < URL : "url(" ( )* ( | <_URL> ) ( )* ")" > +} + + +TOKEN [IGNORE_CASE] : +{ + < LENGTH : "pt" + | "mm" + | "cm" + | "pc" + | "in" + | "gd" + | "px" > + | < EMS : "em" > + | < EXS : "ex" > + | < ANGLE : ( "deg" | "grad" | "rad" ) > + | < TIME : ( "ms" | "s" ) > + | < FREQ : "Hz" | "kHz" > + | < RESOLUTION : "dpi" | "dpcm" > + | < DATE : "/" "/" > + | < DIMEN : ( )* > + | < PERCENTAGE : "%" > + | < NUMBER : > +} + + +TOKEN [IGNORE_CASE] : +{ + < IMPORTANT_SYM : "!" ( <_W> )* "important" > +} + + +TOKEN : +{ + +} + +/* RESERVED ATRULE WORDS */ + +TOKEN : +{ + < CHARSET_SYM : "@charset" > +} + + +TOKEN [IGNORE_CASE] : +{ + < IMPORT_SYM : "@import"> + | < NAMESPACE_SYM : "@namespace"> + | < MEDIA_SYM : "@media" > + | < PAGE_SYM : "@page" > + | < FONT_FACE_SYM : "@font-face" > + | < PREF_SYM : "@preference" > + | < COLOR_PROFILE : "@color-profile" > + | < ATTOP : "@top" > + | < ATRIGHT : "@right" > + | < ATBOTTOM : "@bottom" > + | < ATLEFT : "@left" > + | < ATCOUNTER : "@counter" > + | < PHONETIC_ALPHABET_SYM : "@phonetic-alphabet" > + | < ATKEYWORD : "@" > +} + + +TOKEN [IGNORE_CASE] : +{ + < #RANGE0 : > + | < #RANGE1 : ( "?" )? > + | < #RANGE2 : ( "?" )? ( "?" )? > + | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE : | | + | | | | > + | < #UNI : ( )? ( )? ( )? ( )? ( )? > + | < UNICODERANGE : "U+" | "U+" "-" > +} + + + TOKEN: +{ + < CLASS : "." > +} + +/* FIXED, added a spacial case for lang pseudoclass */ + +TOKEN [IGNORE_CASE] : +{ + < FUNCTIONLANG : "lang(" > +} + + +TOKEN [IGNORE_CASE] : +{ + < FUNCTIONNOT : ":not(" > +} + + + + TOKEN : +{ + < FUNCTION : "(" > +} + +/* Quick and dirty way to catch HTML tags starting CSS documents + (common mistake) */ + + TOKEN: +{ + )* ( )* + ( "=" ( | ) ( )* )* + ">" > + | )* ( )* ">" > +} + +// +//TOKEN : +//{ /* avoid token manager error */ +// < UNKNOWN : ~[] > +//} + +/* + * The grammar of CSS2 + */ + +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ +void parserUnit() : +{ + Token n = null; +} +{ + try { + // used as an error recovery for HTML tags in CSS pages + ( ( n= | n= ) { + addError ( +new ParseException(ac.getMsg().getString("generator.dontmixhtml")), n.image); + } + )* + ( charset() )* // * instead of ? to capture the reinit part + ( | | )* + ( importDeclaration() ( ignoreStatement() ) )* + ( namespaceDeclaration() ( ignoreStatement() ) )* + afterImportDeclaration() + + } catch (TokenMgrError err) { + addError (new ParseException(ac.getMsg().getString("generator.unrecognize")), + err.getMessage()); + } +} + +void charset() : +{ + Token n = null; + Token charsetToken = null; + Token space1Token = null; + Token space2Token = null; + Token semicolonToken = null; + int nb_S = 0; +} +{ + try { + charsetToken= ( space1Token= { nb_S++;} )* + n= ( space2Token= )* semicolonToken= + { + if (charsetdeclared && !reinited) { + throw new ParseException( + ac.getMsg().getString("parser.charset")); + } + // the @charset must be at the beginning of the document + if(charsetToken.beginLine != 1 || + charsetToken.beginColumn != 1) { + throw new ParseException( + ac.getMsg().getString("parser.charset")); + } + if ("css1".equals(ac.getCssVersion())) { + throw new ParseException(ac.getMsg().getString( + "parser.charsetcss1")); + } + // stricter rule for CSS21 and soon for CSS3 + if ("css21".equals(ac.getCssVersion())) { + // single space before + // case sensitive + // no space before ; + // no comments + // string must start with " + if ( (nb_S != 1) || + (!"@charset".equals(charsetToken.image)) || + (!" ".equals(space1Token.image)) || + (space2Token != null && + !"".equals(space2Token.image)) || + (space1Token.specialToken != null) || + (n.specialToken != null) || + (semicolonToken.specialToken != null) || + (n.image.charAt(0) != '\"') + ) { + throw new ParseException(ac.getMsg().getString( + "parser.charsetspecial")); + } + } + if (!charsetdeclared) { + addCharSet(n.image.substring(1, n.image.length()-1)); + charsetdeclared = true; + } else { + reinited = false; + } + } + } catch (Exception e) { + String skip = charsetToken + + ((space1Token == null) ? "" : space1Token.image) + + n + + ((space2Token == null) ? "" : space2Token.image) + + ";"; + addError(e, skip); + } +} + +void afterImportDeclaration() : +{String ret; } +{ + ( ( ruleSet() | media() | page() | fontFace() | preference() | + colorprofile() | phoneticAlphabet() | ret=skipStatement() + { if ((ret == null) || (ret.length() == 0)) { + return; + } + // quite ugly but necessary to avoid probably a lot of changes in the + // grammar, still having a beautiful error message + else if (ret.startsWith("@charset")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.charset")); + addError(e, ret); + } else if (ret.startsWith("@import")) { + ParseException e = + new ParseException(ac.getMsg().getString("parser.import_not_allowed")); + addError(e, ret); + } else { + ParseException e = + new ParseException(ac.getMsg().getString("generator.unrecognize")); + addError(e, ret); + } + } + ) ignoreStatement() )* +} + +void ignoreStatement() : +{} +{ + ( ( | | atRuleDeclaration() ) ( )* )* +} + +void namespaceDeclaration() : +{ + Token n=null; + Token v=null; + boolean is_url; /* for formatting */ + String nsname; + String prefix = null; + CssValue val; +} +{ + // FIXME add namespaces in context to match when a definition happens + ( + ( )* + ( n= { + prefix = convertIdent(n.image); + } + ( )* )? + ( v= { + is_url = false; + nsname = v.image.substring(1, v.image.length()-1); + } + | v= { + is_url = true; + val = new CssURL(); + ((CssURL) val).set(v.image, ac, url); + nsname = (String) val.get(); + if ((nsname.charAt(0) == '"') + || (nsname.charAt(0) == '\'')) { + nsname = nsname.substring(1, nsname.length()-1); + } + } + ) + ( )* + + ( )* + ) { + if (!ac.getCssVersion().equals("css3")) { + addError(new InvalidParamException("at-rule", "@namespace", ac), + (n==null)?"default":n.toString()); + } else { + if (v != null) { + handleNamespaceDeclaration(getURL(), prefix, nsname, is_url); + } + } + } +} +/** + * The import statement + * + * @exception ParseException exception during the parse + */ +void importDeclaration() : +{Token n; + AtRuleMedia media = new AtRuleMedia(); + CssValue val; + String importFile; + boolean is_url = false; +} +{ + try { + ( )* + ( n= { + importFile = n.image.substring(1, n.image.length() -1); + is_url = false; + } + | n= { + val = new CssURL(); + ((CssURL) val).set(n.image, ac, url); + importFile = (String) val.get(); + if ((importFile.charAt(0) == '"') + || (importFile.charAt(0) == '\'')) { + importFile = importFile.substring(1, importFile.length()-1); + } + is_url = true; + } + ) + ( )* + ( medium(media) + ( ( )* medium(media) + )* )? + ( )* + { + handleImport(getURL(), importFile, is_url, media); + } + } catch (ParseException e) { + addError(e, skipStatement()); + } +} + +/** + * @exception ParseException exception during the parse + */ +void media() : +{ + AtRule old = getAtRule(); + AtRuleMedia newRule = new AtRuleMedia(); + setAtRule(newRule); + Token n; + CssProperty p = null; +} +{ + try { + ( )* + // + (n= { newRule.addMediaRestrictor(convertIdent(n.image), ac); } ( )+)? + medium(newRule) + // + ( ( )* medium(newRule) )* + // + ( ( )* ( )* p=mediadeclaration() { newRule.addMediaFeature(p); } ( )* )* + // + + { + String media = getAtRule().toString(); + if (ac.getMedium() != null && + !(media.equals(ac.getMedium())) && + !(ac.getMedium().equals("all"))) { + + ac.getFrame().addWarning("noothermedium", + getAtRule().toString()); + } + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + } + ( )* ( ruleSet() )* ( )* + { + if (!ac.getCssVersion().equals("css1")) { + endOfAtRule(); + } + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +/** + * @exception ParseException exception during the parse + */ +void medium(AtRuleMedia media) : /* tv, projection, screen, ... */ +{Token n;} +{ + n= ( )* + { + try { + media.addMedia(convertIdent(n.image), ac); + } catch (InvalidParamException e) { + CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void page() : +{ + Vector v ; + Token n = null ; + Vector collectv = new Vector() ; + CssSelectors s = new CssSelectors(ac); + AtRule old = getAtRule() ; + AtRulePage newRule = new AtRulePage() ; + setAtRule(newRule); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + // FIXME ? + ( n= { newRule.setIdent(convertIdent(n.image)); } + ( )* )? + // + ( pseudo_page(newRule) )? ( )* ( v=pageContent() + { + collectv = v; + } + ) ( )* + { + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + if (!ac.getCssVersion().equals("css1")) { + addProperty(collectv); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, collectv); + } + } + } catch (InvalidParamException ie) { + if (!ac.getCssVersion().equals("css1")) { + skipStatement(); + removeThisAtRule(); + ac.getFrame().addError(new CssError(ie)); + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + removeThisAtRule(); + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +Vector pageContent() : +{ CssProperty prop; + Vector v = new Vector(); +} +{ + // ?? FIXME + v=prefAtRule() { return v;} + // + | + v=declarations() { return v;} /* FIXME moved here as it can match empty string */ +} + +Vector prefAtRule() : +{ Token n; + Vector v; +} +{ + try { + (n= | n= | n= | n= ) ( )* + ( )* v=declarations() ( )* + { + return v; + } + } catch (ParseException e) { + addError(e, skipStatement()); + } +} + +void pseudo_page(AtRulePage page) : +{ Token n; } +{ + ":" n= ( )* + { + try { + page.setName(":" + convertIdent(n.image), ac); + } catch (InvalidParamException e) { + throw new InvalidParamException("pseudo", n.image, ac ); + /*CssError error = new CssError(getSourceFile(), getLine(), e); + ac.getFrame().addError(error); */ + } + } +} + +void fontFace() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleFontFace()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + if (v == null) { + ac.getFrame().addWarning("no-declaration"); + } else { + handleRule(s, v); + } + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +void colorprofile() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRuleColorProfile()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (!ac.getCssVersion().equals("svg")) { + skipStatement(); + addError(new InvalidParamException("onlysvg", "", ac), + getAtRule().toString()); + } + if (ac.getCssVersion().equals("svg")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (ac.getCssVersion().equals("svg")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + //ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } + } + catch (ParseException e) { + if (ac.getCssVersion().equals("svg")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + + +void preference() : +{ + Vector v; + AtRule old = getAtRule(); + setAtRule(new AtRulePreference()); + CssSelectors s = new CssSelectors(ac); + s.setAtRule(getAtRule()); +} +{ + try { + ( )* + { + if (ac.getCssVersion().equals("css1")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + if (!ac.getCssVersion().equals("css1")) { + newAtRule(getAtRule()); + } + + } + ( )* v=declarations() ( )* + { + if (!ac.getCssVersion().equals("css1")) { + addProperty(v); + endOfRule(); + endOfAtRule(); + } + + if (v == null) { + ac.getFrame().addWarning("medialist"); + } else { + handleRule(s, v); + } + } + } + catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +void phoneticAlphabet() : +{ + Vector v; + AtRule old = getAtRule(); + AtRulePhoneticAlphabet alphabetrule = new AtRulePhoneticAlphabet(); + setAtRule(alphabetrule); + Token n; +} +{ + try { + ( )* n= ( )* ";" + { + if (!ac.getCssVersion().equals("css3")) { + skipStatement(); + addError(new InvalidParamException("noatruleyet", "", ac), + getAtRule().toString()); + } + + alphabetrule.addAlphabet(convertIdent(n.image), ac); + + if (!ac.getCssVersion().equals("css1") && !ac.getCssVersion().equals("css2")) { + newAtRule(getAtRule()); + } + + } + } catch (ParseException e) { + if (!ac.getCssVersion().equals("css1")) { + addError(e, skipStatement()); + } + } finally { + setAtRule(old); + } +} + +/** + * @exception ParseException exception during the parse + */ +void atRuleDeclaration() : +{Token n;} +{ + n= + { + //ac.getFrame().addWarning("at-rule", token.toString()); + ac.getFrame().addError( + new CssError(new InvalidParamException("at-rule", + token, ac))); + skipStatement(); + } +} + +/** + * @exception ParseException exception during the parse + */ +void operator(CssExpression expr) : +{} +{ + ( (

      { if (expr.getCount() > 0) expr.setOperator('/'); } + | { if (expr.getCount() > 0) expr.setOperator(','); } + ) ( )* )? +} + +/** + * @exception ParseException exception during the parse + */ +char combinator() : +{ + char connector = ' '; +} +{ + ( ( { connector = '+' ; } + | { connector = '>' ; } + | { connector = '~' ; } + ) ( )* + | ( )+ { connector = ' ' ; } + ) + { + return connector; + } +} + +/** + * @exception ParseException exception during the parse + */ +char unaryOperator() : +{} +{ + // FIXME | ? warning as is <_W>? "+" + "-" { return '-'; } + | { return '+'; } +} + +/** + * @exception ParseException exception during the parse + */ +String property() : +{Token n; } +{ + n= ( )* { currentProperty = convertIdent(n.image); + return currentProperty; } +} + +/** + * @exception ParseException exception during the parse + */ +void ruleSet() : +{ CssSelectors contextual; + Vector context_set = new Vector(); + Vector value_set = null; + currentContext = context_set; +} +{ + try { + contextual=selector() + { + if (contextual != null) { + context_set.addElement(contextual); + } + } + + ( ( )* + contextual=selector() + { + if (contextual != null) { + context_set.addElement(contextual); + } + } + )* + { + validSelector = (context_set.size() > 0); + } + ( )* + value_set=declarations() + ( )* + { + markRule = true; + + /* if (value_set == null) { + ac.getFrame().addWarning("no-declaration"); + } else {*/ + if (value_set != null) { + boolean first = true; + CssSelectors sel = null; + Enumeration e = context_set.elements(); + while (e.hasMoreElements()) { + sel = e.nextElement(); + if (first) { + handleRule(sel, value_set); + first = false; + } else { + // we need to duplicate properties in that case + // as property holds reference to the selectors and it interact + // badly with conflict detection + int vsize = value_set.size(); + Vector v = new Vector(vsize); + for (int i=0; i declarations() : +{ + if(!validSelector) { + validSelector = true; + skip_to_matching_brace(); + return null; + } + + CssProperty values; + Vector value_set = new Vector(); + boolean wrong_value = true; +} +{ + ( values=declaration() + { if (values != null) { + value_set.addElement(values); + wrong_value = false; + } /* else { + wrong_value = true; + } */ + currentProperty = null; + } + )? + ( ";" ( )* + ( values=declaration() + { if (values != null) { + value_set.addElement(values); + wrong_value = false; + }/* else { + wrong_value = true; + }*/ + currentProperty = null; + } + )? )* + { + if (!wrong_value) { + addProperty(value_set); + return value_set; + } else { + return null; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +CssSelectors selector() : +{ char comb; + CssSelectors current; } +{ + try { + current=simple_selector(null) + ( + comb=combinator() { + if (ac.getProfile() != null) { + if (ac.getProfile().equals("mobile") || + getAtRule().toString().equals("@media atsc-tv") || + ac.getCssVersion().equals("css1")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + if (comb == '>') + throw new InvalidParamException("nocomb", ">", ac); + } else if (ac.getProfile().equals("tv")) { + if (comb == '+') + throw new InvalidParamException("nocomb", "+", ac); + + } + } + if (!ac.getCssVersion().equals("css3")) { + if (comb == '~') { + throw new InvalidParamException("nocomb", "~", ac); + } + } + switch(comb) { + case '+': + current.addAdjacentSibling(new AdjacentSiblingSelector()); + break; + case '>': + current.addChild(new ChildSelector()); + break; + case '~': + current.addGeneralSibling(new GeneralSiblingSelector()); + break; + default: + current.addDescendant(new DescendantSelector()); + } + //current.setConnector(comb); + } + current=simple_selector(current) + )* + { return current; } + } + catch (InvalidParamException ie) { + // skipStatement(); + // removeThisRule(); + ac.getFrame().addError(new CssError(ie)); + Token t = getToken(1); + StringBuilder s = new StringBuilder(); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + return null; + } + catch (ParseException e) { + // validSelector = false; + Token t = getToken(1); + StringBuilder s = new StringBuilder("["); + s.append(getToken(0).image); + // eat until , { or EOF + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + s.append(']'); + // if (validSelector) { + addError(e, s.toString()); + // } else { + // addError(e,""); + // } + validSelector = true; + return null; + } +} + +/** + * I made this rule to parse a selector from a document. Combinator are avoid. + * @exception ParseException exception during the parse + */ +CssSelectors externalSelector() : +{ + CssSelectors current; } +{ + current=simple_selector(null) + ( ( )+ + current=simple_selector(current) + )* + { return current; } +} + +/** + * @exception ParseException exception during the parse + */ +CssSelectors simple_selector(CssSelectors next) : +{ CssSelectors selector = new CssSelectors(ac, next); + selector.setAtRule(getAtRule()); + //selector.setUserMedium(getUserMedium()); +} +{ + + element_name(selector) ( hash(selector) | _class(selector) + | attrib(selector) | pseudo(selector) + | negation(selector) )* + { + return selector; + } + | ( hash(selector) | _class(selector) | attrib(selector) + | pseudo(selector) | negation(selector) )+ + { + return selector; + } +} + +/** + * @exception ParseException exception during the parse + */ +void _class(CssSelectors s) : +{Token n; } +{ + /* "." n= { */ + n= { + try { + s.addClass(new ClassSelector(convertClassIdent(n.image.substring(1)))); + // s.addAttribute("class", convertIdent(n.image.substring(1)), + // CssSelectors.ATTRIBUTE_CLASS_SEL); + } catch (InvalidParamException e) { + // removeThisRule(); + ac.getFrame().addError(new CssError(e)); + throw new ParseException(e.getMessage()); + } + } + /* FIXME n=deprecated_class() ... ?? (DONE-> to be tested) */ + | ( n=deprecated_class() ) { + if (n.image.charAt(0) == '.') { + n.image = n.image.substring(1); + + // the class with the first digit escaped + String cl = "."+hexEscapeFirst(n.image); + + String profile = ac.getProfile(); + if(profile == null || profile.equals("") || profile.equals("none")) { + profile = ac.getCssVersion(); + } + + if(!profile.equals("css1")) { + StringBuilder sb = new StringBuilder(); + Vector param_err = new Vector(2); + param_err.add(n.image); + param_err.add(cl); + sb.append(ac.getMsg().getString("parser.old_class", param_err)); + throw new ParseException(sb.toString()); + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + CssLength length = new CssLength(); + boolean isLength = false; + try { + length.set(n.image, ac); + isLength = true; + } + catch(Exception e) { + isLength = false; + } + if(isLength) { + StringBuilder sb = new StringBuilder(); + sb.append(ac.getMsg().getString("parser.class_dim")); + sb.append(n.image); + throw new ParseException(sb.toString()); + // s.addClass(new ClassSelector(n.image)); + // removeThisRule(); + } + else { + try { + // for css > 1, we add the rule to have a context, + // and we then remove it + s.addClass(new ClassSelector(n.image)); + ac.getFrame().addWarning("old_class"); + } catch (InvalidParamException e) { + throw new ParseException(e.getMessage()); + //ac.getFrame().addError(new CssError(e)); + //removeThisRule(); + } + } + } + } else { + throw new ParseException("Unrecognized "); + } + } +} + +Token deprecated_class() : +{ + Token n; +} +{ + ( n= + | n= + | n= + | n= + | n=