Skip to content

Commit 1a64e00

Browse files
committed
css: make the non-CSS presentational hints Set final and unmodifiable
1 parent 97d7c36 commit 1a64e00

File tree

1 file changed

+27
-5
lines changed
  • echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine

1 file changed

+27
-5
lines changed

echosvg-css/src/main/java/io/sf/carte/echosvg/css/engine/CSSEngine.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ public static CSSStylableElement getParentCSSStylableElement(Element elt) {
286286
/**
287287
* The non CSS presentational hints.
288288
*/
289-
protected Set<String> nonCSSPresentationalHints;
289+
protected final Set<String> nonCSSPresentationalHints;
290290

291291
/**
292292
* The non CSS presentational hints namespace URI.
293293
*/
294-
protected String nonCSSPresentationalHintsNamespaceURI;
294+
protected final String nonCSSPresentationalHintsNamespaceURI;
295295

296296
/**
297297
* The style declaration document handler.
@@ -453,18 +453,22 @@ protected CSSEngine(Document doc, ParsedURL uri, Parser p, ValueManager[] vm, Sh
453453
}
454454

455455
if (hints) {
456-
nonCSSPresentationalHints = new HashSet<>(vm.length + sm.length);
456+
HashSet<String> ncph = new HashSet<>(vm.length + sm.length);
457457
nonCSSPresentationalHintsNamespaceURI = hintsNS;
458458
len = vm.length;
459459
for (int i = 0; i < len; i++) {
460460
String pn = vm[i].getPropertyName();
461-
nonCSSPresentationalHints.add(pn);
461+
ncph.add(pn);
462462
}
463463
len = sm.length;
464464
for (int i = 0; i < len; i++) {
465465
String pn = sm[i].getPropertyName();
466-
nonCSSPresentationalHints.add(pn);
466+
ncph.add(pn);
467467
}
468+
nonCSSPresentationalHints = Collections.unmodifiableSet(ncph);
469+
} else {
470+
nonCSSPresentationalHints = null;
471+
nonCSSPresentationalHintsNamespaceURI = null;
468472
}
469473

470474
if (cssContext.isDynamic() && document instanceof EventTarget) {
@@ -825,6 +829,24 @@ public List<FontFaceRule> getFontFaces() {
825829
return fontFaces;
826830
}
827831

832+
/**
833+
* Get the set of non-CSS presentational hints.
834+
*
835+
* @return the non-CSS presentational hints.
836+
*/
837+
protected Set<String> getNonCSSPresentationalHints() {
838+
return nonCSSPresentationalHints;
839+
}
840+
841+
/**
842+
* Get the namespace URI of non-CSS presentational hints.
843+
*
844+
* @return the namespace URI of non-CSS presentational hints.
845+
*/
846+
protected String getNonCSSPresentationalHintsNamespaceURI() {
847+
return nonCSSPresentationalHintsNamespaceURI;
848+
}
849+
828850
/**
829851
* Sets the media to use to compute the styles.
830852
*/

0 commit comments

Comments
 (0)