The manakai project

Web::CSS::Context

Providing context for CSS processing

DESCRIPTION

The Web::CSS::Context object provides context for parsing and processing of CSS, Selectors, and/or Media Queries.

When a context object is expected, you can use the Web::CSS::Context object or an instance of subclass of Web::CSS::Context.

METHODS

The Web::CSS::Context object has following methods:

Constructors

$ctx = Web::CSS::Context->new_empty

Create a new empty context object, with no namespaces.

$ctx = Web::CSS::Context->new_from_nscallback ($callback)

Create a new context object with a callback function for namespace resolution. The argument must be a code reference or the undef value. If it is a code reference, when invoked with the namespace prefix argument, it must return the corresponding namespace URL. Instead of the namespace prefix, the undef value representing the default namespace might be specified. The code may return the empty string, representing the null namespace, or the undef value, representing the lack of the namespace binding. If the callback throws an exception, it is propagated to the callee of the method which invoked the code.

$ctx = Web::CSS::Context->new_from_nsmaps ($p2u, $u2p)

Create a new context object with two mapping tables, represented as hash references.

The first mapping table is used to lookup namespace URL from the namespace prefix. The default namespace is represented by the empty string. The value can be the empty string, representing the null namespace, or the undef value, representing the lack of the namespace binding.

The second mapping table is used to lookup namespace prefix from the namespace URL. The null namespace is represented by the empty string. The value can be the empty string, representing the default namespace, or the undef value, representing the lack of the namespace binding.

URL methods

$url = $context->url
$context->url ($url)

Return or specify the URL in which the style sheet, selectors, or media queries is contained.

$scalarref = $context->urlref

Return the reference to the URL.

$url = $context->base_url
$context->base_url ($url)

Return or specify the base URL for the style sheet.

$scalarref = $context->base_urlref

Return the reference to the base URL.

Quirksness methods

$string = $context->manakai_compat_mode
$context->manakai_compat_mode ($string)

Return or specify the quirksness of the document for which the style sheet is parsed. It must be one of quirks, limited quirks, or no quirks.

$boolean = $context->quirks

Return whether the manakai_compat_mode is quirks or not.

Namespace methods

$boolean = $ctx->has_namespace

Return whether there is any namespace binding or not.

$prefix = $ctx->get_prefix_by_url ($url)

Return the namespace prefix associated with the specified namespace URL. The namespace URL can be the empty string, representing the null namespace. If the result is the empty string, it represents the default namespace. If the result is the undef value, there is no namespace prefix (or the default namespace) associated with the URL.

$url = $ctx->get_url_by_prefix ($url)

Return the namespace URL associated with the specified namespace prefix. The namespace prefix can be the empty string, representing the default namespace. If the result is the empty string, it represents the null namespace. If the result is the undef value, there is no namespace URL (even the null namespace) associated with the prefix.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2007-2013 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.