public class

StyleInjector

extends Object
java.lang.Object
   ↳ com.google.gwt.dom.client.StyleInjector

Class Overview

Used to add stylesheets to the document. The one-argument versions of inject(String), injectAtEnd(String), and injectAtStart(String) use scheduleFinally(Scheduler.RepeatingCommand) to minimize the number of individual style elements created.

Summary

Nested Classes
class StyleInjector.StyleInjectorImpl The DOM-compatible way of adding stylesheets. 
class StyleInjector.StyleInjectorImplIE IE doesn't allow manipulation of a style element through DOM methods. 
Public Methods
static void inject(String css)
Add a stylesheet to the document.
static void inject(String css, boolean immediate)
Add a stylesheet to the document.
static void injectAtEnd(String css, boolean immediate)
Add stylesheet data to the document as though it were declared after all stylesheets previously created by inject(String).
static void injectAtEnd(String css)
Add stylesheet data to the document as though it were declared after all stylesheets previously created by inject(String).
static void injectAtStart(String css, boolean immediate)
Add stylesheet data to the document as though it were declared before all stylesheets previously created by inject(String).
static void injectAtStart(String css)
Add stylesheet data to the document as though it were declared before all stylesheets previously created by inject(String).
static StyleElement injectStylesheet(String contents)
This method is deprecated. The returned StyleElement cannot be implemented consistently across all browsers
static StyleElement injectStylesheetAtEnd(String contents)
This method is deprecated. The returned StyleElement cannot be implemented consistently across all browsers
static StyleElement injectStylesheetAtStart(String contents)
This method is deprecated. The returned StyleElement cannot be implemented consistently across all browsers
static void setContents(StyleElement style, String contents)
This method is deprecated. The associated StyleElement cannot be implemented consistently across all browsers
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void inject (String css)

Add a stylesheet to the document.

Parameters
css the CSS contents of the stylesheet

public static void inject (String css, boolean immediate)

Add a stylesheet to the document.

Parameters
css the CSS contents of the stylesheet
immediate if true the DOM will be updated immediately instead of just before returning to the event loop. Using this option excessively will decrease performance, especially if used with an inject-css-on-init coding pattern

public static void injectAtEnd (String css, boolean immediate)

Add stylesheet data to the document as though it were declared after all stylesheets previously created by inject(String).

Parameters
css the CSS contents of the stylesheet
immediate if true the DOM will be updated immediately instead of just before returning to the event loop. Using this option excessively will decrease performance, especially if used with an inject-css-on-init coding pattern

public static void injectAtEnd (String css)

Add stylesheet data to the document as though it were declared after all stylesheets previously created by inject(String).

Parameters
css the CSS contents of the stylesheet

public static void injectAtStart (String css, boolean immediate)

Add stylesheet data to the document as though it were declared before all stylesheets previously created by inject(String).

Parameters
css the CSS contents of the stylesheet
immediate if true the DOM will be updated immediately instead of just before returning to the event loop. Using this option excessively will decrease performance, especially if used with an inject-css-on-init coding pattern

public static void injectAtStart (String css)

Add stylesheet data to the document as though it were declared before all stylesheets previously created by inject(String).

Parameters
css the CSS contents of the stylesheet

public static StyleElement injectStylesheet (String contents)

This method is deprecated.
The returned StyleElement cannot be implemented consistently across all browsers

Add a stylesheet to the document. The StyleElement returned by this method is not guaranteed to be unique.

Parameters
contents the CSS contents of the stylesheet
Returns
  • the StyleElement that contains the newly-injected CSS

public static StyleElement injectStylesheetAtEnd (String contents)

This method is deprecated.
The returned StyleElement cannot be implemented consistently across all browsers

Add stylesheet data to the document as though it were declared after all stylesheets previously created by injectStylesheet(String). The StyleElement returned by this method is not guaranteed to be unique.

Parameters
contents the CSS contents of the stylesheet
Returns
  • the StyleElement that contains the newly-injected CSS

public static StyleElement injectStylesheetAtStart (String contents)

This method is deprecated.
The returned StyleElement cannot be implemented consistently across all browsers

Add stylesheet data to the document as though it were declared before any stylesheet previously created by injectStylesheet(String). The StyleElement returned by this method is not guaranteed to be unique.

Parameters
contents the CSS contents of the stylesheet
Returns
  • the StyleElement that contains the newly-injected CSS

public static void setContents (StyleElement style, String contents)

This method is deprecated.
The associated StyleElement cannot be implemented consistently across all browsers

Replace the contents of a previously-injected stylesheet. Updating the stylesheet in-place is typically more efficient than removing a previously-created element and adding a new one. This method should be used with some caution as StyleInjector may recycle StyleElements on certain browsers.

Parameters
style a StyleElement previously-returned from injectStylesheet(String).
contents the new contents of the stylesheet.