This project provides implementations of APIs similar to W3C/WHATWG's:
Unless otherwise noted, this software is provided under a BSD-style license
(see also LICENSES.txt for included files that have a different licensing).
The functionality of this library can be divided in the following areas:
A CSSOM API very similar to the standard W3C CSS Object Model API,
that allows accessing the CSS information (style sheets, inline styles, etc.)
in a DOM Document, as well as getting computed styles for its elements.
A CSS-enabled native DOM implementation.
A DOM wrapper that can be used with an external DOM implementation.
A device profile API to encapsulate target device-specific information.
In separate modules you can find:
A DOM4J backend (module css4j-dom4j)
which uses documents and elements that extend those of dom4j (for those who
are comfortable with the dom4j API).
User agent helper classes, that ease the usage of the library with correct
cookie settings etc. (css4j-agent module).
A few AWT helper classes (AWT module).
CSS3 is partially supported. The following table summarizes the basic support
for setting/retrieving the main CSS level 3/4 features (other specifications are
also supported):
CSS Spec Name | Support |
---|---|
Background / Border | Yes |
Color | Partial (1) |
Media Queries | Partial (2) |
Selectors | Yes |
Transitions | Yes |
Values | Yes |
Properties and Values API | Partial |
Grid / Template / Alignment | Partial (3) |
Notes:
1) Level 3 is supported, level 4 partially.
2) Event handling with addListener
/removeListener
is not supported, given that
the library's user is supposed to be in control of the CSSCanvas
instances where
the information about such events should be available.
3) Legacy gap properties (grid-row-gap
, grid-column-gap
, and grid-gap
) are not
supported, although the longhands can be used if declared explicitly).
All the classes in the binary package have been compiled with a Java compiler
set to 1.7 compiler compliance level, except the module-info.java
file.
Building the library requires JDK 11 or higher.
To build css4j from the code that is currently at the Git repository, JDK 11 or later is needed.
You can run a variety of Gradle tasks with the Gradle wrapper (on Windows shells you can omit the ./
):
./gradlew build
(normal build)./gradlew build publishToMavenLocal
(to install in local Maven repository)./gradlew copyJars
(to copy jar files into a top-level jar directory)./gradlew jacocoTestReport
(produces a test coverage report in the build/reports/jacoco/test/html
directory)./gradlew publish
(deploys to a Maven repository, as described in the publishing.repositories.maven
block ofIf your Gradle project depends on css4j, you can use this project's own Maven repository in a repositories
section of
your build file:
repositories {
maven {
url "https://css4j.github.io/maven/"
mavenContent {
releasesOnly()
}
content {
includeGroup 'io.sf.carte'
includeGroup 'io.sf.jclf'
}
}
}
please use this repository only for the artifact groups listed in the includeGroup
statements.
Then, in your build.gradle
file:
dependencies {
api "io.sf.carte:css4j:${css4jVersion}"
}
where css4jVersion
would be defined in a gradle.properties
file.
In case that you do not use a Gradle or Maven build (which would manage the
dependencies according to the relevant .module
or .pom
files), the required
and optional library packages are the following:
The jclf-text
(5.0.0 or higher) and jclf-linear3
(1.0.0 or higher) modules. See: https://sourceforge.net/projects/jclf
The commons-codec library;
a recent version is recommended.
The SAC api version 1.3.
SLF4J, which is a logging package.
It is optional at runtime.
A recent version of JUnit 4.
The SteadyState cssparser library.
The batik-css
, batik-util
and batik-i18n
artifacts from
Apache Batik.
For more information please see https://css4j.github.io/