//
private void page(Stylesheet stylesheet) throws IOException {
//System.out.println("page()");
Token t = next();
try {
PageRule pageRule = new PageRule(stylesheet.getOrigin());
if (t == Token.TK_PAGE_SYM) {
skip_whitespace();
t = la();
if (t == Token.TK_IDENT) {
String pageName = getTokenValue(t);
if (pageName.equals("auto")) {
throw new CSSParseException("page name may not be auto", getCurrentLine());
}
next();
pageRule.setName(pageName);
t = la();
}
if (t == Token.TK_COLON) {
pageRule.setPseudoPage(pseudo_page());
}
Ruleset ruleset = new Ruleset(stylesheet.getOrigin());
skip_whitespace();
t = next();
if (t == Token.TK_LBRACE) {
LOOP:
while (true) {
skip_whitespace();
t = la();
if (t == Token.TK_RBRACE) {
next();
skip_whitespace();
break LOOP;
} else if (t == Token.TK_AT_RULE) {
margin(stylesheet, pageRule);
} else {
declaration_list(ruleset, false, true, false);
}
}
} else {
push(t);
throw new CSSParseException(t, Token.TK_LBRACE, getCurrentLine());
}
pageRule.addContent(ruleset);
stylesheet.addContent(pageRule);
} else {
push(t);
throw new CSSParseException(t, Token.TK_PAGE_SYM, getCurrentLine());
}