GWT 2.7.0

com.google.gwt.resources.client
Interface CssResource

All Superinterfaces:
CssResourceBase, ResourcePrototype
All Known Subinterfaces:
ButtonCellBase.DefaultAppearance.Style, CellBrowser.Style, CellList.Style, CellTable.BasicStyle, CellTable.Style, CellTree.BasicStyle, CellTree.Style, CommonResources.InlineBlockStyle, CustomScrollPanel.Style, DataGrid.Style, NativeHorizontalScrollbar.Style, NativeHorizontalScrollbar.StyleTransparant, NativeVerticalScrollbar.Style, NativeVerticalScrollbar.StyleTransparant, NotificationMole.Style, SimplePager.Style

public interface CssResource
extends CssResourceBase

Aggregates and minifies CSS stylesheets. A CssResource represents a regular CSS file with GWT-specific at-rules.

Currently-supported accessor functions:

Currently-supported rules:

Currently-supported CSS functions:

Any class selectors that do not correspond with a String accessor method in the return type will trigger a compilation error. This ensures that the CssResource does not contribute any unobfuscated class selectors into the global CSS namespace. Strict mode can be disabled by annotating the ClientBundle method declaration with CssResource.NotStrict, however this is only recommended for interacting with legacy CSS.

Given these interfaces:

 interface MyCss extends CssResource {
   String someClass();
 }
 
 interface MyBundle extends ClientBundle {
  @Source("my.css")
   MyCss css();
 }
 
the source CSS will fail to compile if it does not contain exactly the one class selector defined in the MyCss type.

The @external at-rule can be used in strict mode to indicate that certain class selectors are exempt from the strict semantics. Class selectors marked as external will not be obfuscated and are not required to have string accessor functions. Consider the following example in conjunction with the above MyCss interface:

 @external .foo, .bar;
 .foo .someClass .bar { .... }
 
The resulting CSS would look like:
 .foo .A1234 .bar { .... }
 
If a String foo() method were defined in MyCss, it would return the string value "foo".

The utility tool com.google.gwt.resources.css.InterfaceGenerator can be used to automatically generate a Java interface from a CssResource-compatible CSS file.

See Also:
CssResource design doc

Nested Class Summary
static interface CssResource.ClassName
          The original CSS class name specified in the resource.
static interface CssResource.Import
          Makes class selectors from other CssResource types available in the raw source of a CssResource.
static interface CssResource.ImportedWithPrefix
          Specifies the string prefix to use when one CssResource is imported into the scope of another CssResource.
static interface CssResource.NotStrict
          The presence of this annotation on a CssResource accessor method indicates that any class selectors that do not correspond with a String accessor method in the return type or an @external declaration should not trigger a compilation error.
static interface CssResource.Shared
          Indicates that the String accessor methods defined in a CssResource will return the same values across all implementations of that type.
static interface CssResource.Strict
          Deprecated. Strict mode is now the default behavior for CssResource
 
Method Summary
 boolean ensureInjected()
          Calls StyleInjector.injectStylesheet(String) to inject the contents of the CssResource into the DOM.
 java.lang.String getText()
          Provides the contents of the CssResource.
 
Methods inherited from interface com.google.gwt.resources.client.ResourcePrototype
getName
 

Method Detail

ensureInjected

boolean ensureInjected()
Calls StyleInjector.injectStylesheet(String) to inject the contents of the CssResource into the DOM. Repeated calls to this method on an instance of a CssResources will have no effect.

Returns:
true if this method mutated the DOM.

getText

java.lang.String getText()
Provides the contents of the CssResource.


GWT 2.7.0