Skip to content

Commit 7312f56

Browse files
committed
reuse the page at-rule for subrules by allowing modification of the displayed name
1 parent f038208 commit 7312f56

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

org/w3c/css/atrules/css/AtRulePage.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ public abstract class AtRulePage extends AtRule {
3333
/**
3434
* Returns the at rule keyword
3535
*/
36-
public String keyword() {
36+
public final String keyword() {
3737
return "page";
3838
}
3939

40+
public String effectiveKeyword() {
41+
return keyword();
42+
}
43+
4044
/**
4145
* Sets the name of the page
4246
* name will be a pseudo name :first, :left, :right
@@ -131,7 +135,7 @@ public boolean canMatch(AtRule atRule) {
131135
*/
132136
public String toString() {
133137
StringBuilder ret = new StringBuilder();
134-
ret.append('@').append(keyword());
138+
ret.append('@').append(effectiveKeyword());
135139
if (names != null) {
136140
int l = names.size();
137141
for (int i = 0; i < l; i++) {

org/w3c/css/atrules/css3/AtRulePage.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class AtRulePage extends org.w3c.css.atrules.css.AtRulePage {
2121
":left", ":right", ":first", ":blank"
2222
};
2323

24+
private String keyword = "page";
25+
2426
/*
2527
* Sets the name of the page
2628
* name will be a pseudo name :first, :left, :right
@@ -54,4 +56,15 @@ public AtRulePage addSelector(String name, ArrayList<String> pseudo, ApplContext
5456
pseudos.add(pseudo);
5557
return this;
5658
}
59+
60+
public void setKeyword(String k) {
61+
keyword = k;
62+
}
63+
64+
/**
65+
* Returns the at rule keyword
66+
*/
67+
public String effectiveKeyword() {
68+
return keyword;
69+
}
5770
}

0 commit comments

Comments
 (0)