346 List<Style> matchingStyles = removeUserAgentStyles(allStyles);
347 List<Style> notApplied = new ArrayList<>();
348 for (Style style : matchingStyles) {
349 if (!appliedStyles.contains(style)) {
350 notApplied.add(style);
351 }
352 }
353 for (Style style : notApplied) {
354 if (style.getDeclaration().getProperty().equals(cssMeta.getProperty())) {
355 // We need to retrieve from allStyles, in case a lookup is shared by appliedStyles and notApplied
356 CssStyle cssStyle = retrieveStyle(matchingStyles, style);
357 ret.add(cssStyle);
358 }
359 }
360 return ret;
361 }
362
363 protected static List<Style> removeUserAgentStyles(List<Style> allStyles) {
364 // With SB 2, we apply explicitly Modena/Caspian theme css on user scene graph.
365 // The rules that appear with an AUTHOR origin has already been considered as USER_AGENT.
366 // So when an internal css method (such as impl_getMatchingStyles()) is called,
367 // we need here to remove all USER_AGENT styles, to avoid doublons.
368 List<Style> matchingStyles = new ArrayList<>();
369 for (Style style : allStyles) {
370 if (!(style.getDeclaration().getRule().getOrigin() == StyleOrigin.USER_AGENT)) {
371 matchingStyles.add(style);
372 }
373 }
374 return matchingStyles;
375 }
376
377 // protected static void printStyles(List<Style> styles) {
378 // for (Style style : styles) {
379 // printStyle(style);
380 // }
381 //
382 // }
383 // private static void printStyle(Style style) {
384 // System.out.println(style.getDeclaration().getRule().getOrigin() + " ==> STYLE " + style.getDeclaration());
385 // System.out.println("--> css url = " + style.getDeclaration().getRule().getStylesheet().getUrl());
386 // }
|
346 List<Style> matchingStyles = removeUserAgentStyles(allStyles);
347 List<Style> notApplied = new ArrayList<>();
348 for (Style style : matchingStyles) {
349 if (!appliedStyles.contains(style)) {
350 notApplied.add(style);
351 }
352 }
353 for (Style style : notApplied) {
354 if (style.getDeclaration().getProperty().equals(cssMeta.getProperty())) {
355 // We need to retrieve from allStyles, in case a lookup is shared by appliedStyles and notApplied
356 CssStyle cssStyle = retrieveStyle(matchingStyles, style);
357 ret.add(cssStyle);
358 }
359 }
360 return ret;
361 }
362
363 protected static List<Style> removeUserAgentStyles(List<Style> allStyles) {
364 // With SB 2, we apply explicitly Modena/Caspian theme css on user scene graph.
365 // The rules that appear with an AUTHOR origin has already been considered as USER_AGENT.
366 // So when an internal css method (such as getMatchingStyles()) is called,
367 // we need here to remove all USER_AGENT styles, to avoid doublons.
368 List<Style> matchingStyles = new ArrayList<>();
369 for (Style style : allStyles) {
370 if (!(style.getDeclaration().getRule().getOrigin() == StyleOrigin.USER_AGENT)) {
371 matchingStyles.add(style);
372 }
373 }
374 return matchingStyles;
375 }
376
377 // protected static void printStyles(List<Style> styles) {
378 // for (Style style : styles) {
379 // printStyle(style);
380 // }
381 //
382 // }
383 // private static void printStyle(Style style) {
384 // System.out.println(style.getDeclaration().getRule().getOrigin() + " ==> STYLE " + style.getDeclaration());
385 // System.out.println("--> css url = " + style.getDeclaration().getRule().getStylesheet().getUrl());
386 // }
|