| Methods |
public
|
__construct(Dompdf $dompdf)
The class constructor.
The class constructor.
The base protocol, host & path are initialized to those of
the current script.
|
#
|
public
|
set_protocol(string $protocol)
Set the base protocol
|
#
|
public
|
set_host(string $host)
Set the base host
|
#
|
public
|
set_base_path(string $path)
Set the base path
|
#
|
public
|
get_dompdf(): Dompdf
Return the Dompdf object
|
#
|
public
|
get_protocol(): string
Return the base protocol for this stylesheet
Return the base protocol for this stylesheet
|
#
|
public
|
get_host(): string
Return the base host for this stylesheet
Return the base host for this stylesheet
|
#
|
public
|
get_base_path(): string
Return the base path for this stylesheet
Return the base path for this stylesheet
|
#
|
public
|
get_page_styles(): Style[]
Return the array of page styles
Return the array of page styles
|
#
|
public
|
create_style(): Style
Create a new Style object associated with this stylesheet
Create a new Style object associated with this stylesheet
|
#
|
public
|
add_style(string $key, Style $style): void
Add a new Style object to the stylesheet
Add a new Style object to the stylesheet
The style's origin is changed to the current origin of the stylesheet.
Parameters
| $key |
the Style's selector
|
| $style |
the Style to be added
|
|
#
|
public
|
load_css(string &$css, int $origin = self::ORIG_AUTHOR)
load and parse a CSS string
load and parse a CSS string
|
#
|
public
|
load_css_file(string $file, int $origin = self::ORIG_AUTHOR)
load and parse a CSS file
load and parse a CSS file
|
#
|
protected
|
specificity(string $selector, int $origin = self::ORIG_AUTHOR): int
|
#
|
protected
|
selectorToXpath(string $selector, bool $firstPass = false): array|null
Converts a CSS selector to an XPath query.
Converts a CSS selector to an XPath query.
|
#
|
protected
|
selectorAnPlusB(string $expr, string $position): string
Parse an `nth-child` expression of the form `an+b`, `odd`, or `even`.
Parse an nth-child expression of the form an+b, odd, or even.
|
#
|
public
|
apply_styles(FrameTree $tree)
applies all current styles to a particular document tree
applies all current styles to a particular document tree
apply_styles() applies all currently loaded styles to the provided
{@link FrameTree}. Aside from parsing CSS, this is the main purpose
of this class.
|
#
|
private
|
_parse_css(string $str)
parse a CSS string using a regex parser
Called by {@link Stylesheet::parse_css()}
parse a CSS string using a regex parser
Called by {@link Stylesheet::parse_css()}
Throws
|
#
|
public
|
resolve_url(string|null $val): string
Resolve the given `url()` declaration to an absolute URL.
Resolve the given url() declaration to an absolute URL.
Parameters
| $val |
The declaration to resolve in the context of the stylesheet.
|
Returns
The resolved URL, or none, if the value is none,
invalid, or points to a non-existent local file.
|
#
|
private
|
_parse_import(string $url)
parse @import{} sections
Parameters
| $url |
the url of the imported CSS file
|
|
#
|
private
|
_parse_font_face(string $str)
parse @font-face{} sections
http://www.w3.org/TR/css3-fonts/#the-font-face-rule
Parameters
| $str |
CSS @font-face rules
|
|
#
|
private
|
_parse_properties(string $str): Style
parse regular CSS blocks
parse regular CSS blocks
_parse_properties() creates a new Style object based on the provided
CSS rules.
Parameters
|
#
|
private
|
_parse_sections(string $str, array $media_queries = [])
parse selector + rulesets
parse selector + rulesets
Parameters
| $str |
CSS selectors and rulesets
|
|
#
|
public
|
getDefaultStylesheet(): string
|
#
|
public
|
setFontMetrics(FontMetrics $fontMetrics): $this
|
#
|
public
|
getFontMetrics(): FontMetrics
|
#
|
public
|
__toString(): string
dumps the entire stylesheet as a string
dumps the entire stylesheet as a string
Generates a string of each selector and associated style in the
Stylesheet. Useful for debugging.
|
#
|
| Properties |
private
static
|
|
$_stylesheet_origins = [self::ORIG_UA => 0x00000000, self::ORIG_USER => 0x10000000, self::ORIG_AUTHOR => 0x30000000]
|
#
|
private
|
Dompdf
|
$_dompdf
|
#
|
private
|
Style[][]
|
$_styles
|
#
|
private
|
string
|
$_protocol = ""
|
#
|
private
|
string
|
$_base_host = ""
|
#
|
private
|
string
|
$_base_path = ""
|
#
|
private
|
array<Style>
|
$_page_styles
|
#
|
private
|
array
|
$_loaded_files
|
#
|
private
|
int
|
$_current_origin = self::ORIG_UA
|
#
|
public
static
|
|
$ACCEPTED_DEFAULT_MEDIA_TYPE = "print"
Accepted CSS media types
List of types and parsing rules for future extensions:
http://www.w3.org/TR/REC-html40/types…
Accepted CSS media types
List of types and parsing rules for future extensions:
http://www.w3.org/TR/REC-html40/types.html
screen, tty, tv, projection, handheld, print, braille, aural, all
The following are non standard extensions for undocumented specific environments.
static, visual, bitmap, paged, dompdf
Note, even though the generated pdf file is intended for print output,
the desired content might be different (e.g. screen or projection view of html file).
Therefore allow specification of content by dompdf setting Options::defaultMediaType.
If given, replace media "print" by Options::defaultMediaType.
(Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE)
|
#
|
public
static
|
|
$ACCEPTED_GENERIC_MEDIA_TYPES = ["all", "static", "visual", "bitmap", "paged", "dompdf"]
|
#
|
public
static
|
|
$VALID_MEDIA_TYPES = [
"all",
"aural",
"bitmap",
"braille",
"dompdf",
"embossed",
"handheld",
"paged",
"print",
"projection",
"screen",
"speech",
"static",
"tty",
"tv",
"visual",
]
|
#
|
private
|
FontMetrics
|
$fontMetrics
|
#
|