Skip to content

Commit

Permalink
feat: report CSS absolute/fixed positioning as USAGE
Browse files Browse the repository at this point in the history
- `CSS-006` and `CSS-017` that report position fixed/absolute are now
  `USAGE` messages (instead of `WARNING`)
- Removes `CSS-027` as it would be a duplicate of `CSS-017`
- Command line severity tests now use a missing title as the `WARNING`
  trigger (instead of the now usage-only absolute positionning)

Fix #889
  • Loading branch information
mattgarrish authored and rdeltour committed Feb 19, 2019
1 parent 356fac0 commit 672ac6d
Show file tree
Hide file tree
Showing 26 changed files with 108 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,14 @@ void checkTermsAndValues(CssGrammar.CssDeclaration declaration)
{
if (!isGlobalFixedFormat || hasIndividualFixedFormatDocuments)
{
MessageId id = hasIndividualFixedFormatDocuments ? MessageId.CSS_027 : MessageId.CSS_017;
if ("position".compareToIgnoreCase(declaration.getName().get()) == 0)
{
for (CssGrammar.CssConstruct construct : declaration.getComponents())
{
if (construct.getType() == CssGrammar.CssConstruct.Type.KEYWORD &&
"absolute".compareToIgnoreCase(construct.toCssString()) == 0)
{
getReport().message(id, getCorrectedEPUBLocation(path, declaration.getLocation().getLine(), declaration.getLocation().getColumn(), declaration.toCssString()), declaration.getName().get());
getReport().message(MessageId.CSS_017, getCorrectedEPUBLocation(path, declaration.getLocation().getLine(), declaration.getLocation().getColumn(), declaration.toCssString()), declaration.getName().get());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void initialize()
severities.put(MessageId.CSS_003, Severity.ERROR);
severities.put(MessageId.CSS_004, Severity.ERROR);
severities.put(MessageId.CSS_005, Severity.ERROR);
severities.put(MessageId.CSS_006, Severity.WARNING);
severities.put(MessageId.CSS_006, Severity.USAGE);
severities.put(MessageId.CSS_007, Severity.INFO);
severities.put(MessageId.CSS_008, Severity.ERROR);
severities.put(MessageId.CSS_009, Severity.USAGE);
Expand All @@ -80,15 +80,14 @@ private void initialize()
severities.put(MessageId.CSS_013, Severity.USAGE);
severities.put(MessageId.CSS_015, Severity.ERROR);
severities.put(MessageId.CSS_016, Severity.SUPPRESSED);
severities.put(MessageId.CSS_017, Severity.WARNING);
severities.put(MessageId.CSS_017, Severity.USAGE);
severities.put(MessageId.CSS_019, Severity.WARNING);
severities.put(MessageId.CSS_020, Severity.ERROR);
severities.put(MessageId.CSS_021, Severity.USAGE);
severities.put(MessageId.CSS_022, Severity.USAGE);
severities.put(MessageId.CSS_023, Severity.USAGE);
severities.put(MessageId.CSS_024, Severity.USAGE);
severities.put(MessageId.CSS_025, Severity.USAGE);
severities.put(MessageId.CSS_027, Severity.USAGE);
severities.put(MessageId.CSS_028, Severity.USAGE);

// HTML
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/adobe/epubcheck/messages/MessageId.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public enum MessageId implements Comparable<MessageId>
CSS_023("CSS-023"),
CSS_024("CSS-024"),
CSS_025("CSS-025"),
CSS_027("CSS-027"),
CSS_028("CSS-028"),

// Messages relating to xhtml markup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CSS_002=Empty or NULL reference found.
CSS_003=Only UTF-8 and UTF-16 encodings are allowed, detected %1$s.
CSS_004=Only UTF-8 and UTF-16 encodings are allowed, detected %1$s BOM.
CSS_005=Conflicting alternate style attributes found: %1$s.
CSS_006=CSS position:fixed property should not be used in EPUBs.
CSS_006=CSS selector specifies fixed position.
CSS_007=Font-face reference %1$s refers to non-standard font type %2$s.
CSS_008=An error occurred while parsing the CSS: %1$s.
CSS_009=Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.
Expand All @@ -63,7 +63,6 @@ CSS_024=CSS class Selector is not used.
CSS_024_SUG=Remove unused CSS selectors.
CSS_025=CSS class Selector could not be found.
CSS_025_SUG=Check for typos or define a class selector to document the use of the class.
CSS_027=CSS selector specifies absolute position.
CSS_028=Use of Font-face declaration.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=CSS-Klasse wird nicht verwendet.
CSS_024_SUG=Entferne unbenutzte CSS-Selektoren/-Klassen.
CSS_025=CSS-Klasse wurde nicht gefunden.
CSS_025_SUG=Überprüfe die Angabe der CSS-Klasse auf Schreibfehler oder definiere einen neuen Klassen-Selektor im CSS.
CSS_027=CSS-Selektor enthält Anweisungen zu absoluter Positionierung.
CSS_028=Eine 'font-face'-Deklaration wird genutzt.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=El selector de clase CSS no se utiliza.
CSS_024_SUG=Elimine los selectores CSS no usados.
CSS_025=No se encuentra el selector de clase CSS.
CSS_025_SUG=Compruebe la sintaxis o defina un selector de clase para documentar el uso de la clase.
CSS_027=El selector CSS especifica una posición absoluta.
CSS_028=Uso de declaración 'font-face'.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=Le sélecteur CSS de classe n'est pas utilisé.
CSS_024_SUG=Supprimez les sélecteurs CSS inutilisés.
CSS_025=Le sélecteur CSS de classe est introuvable.
CSS_025_SUG=Vérifiez les fautes de frappe ou définissez un sélecteur de classe pour attester de l'utilisation de la classe.
CSS_027=Le sélecteur CSS spécifie une position absolue.
CSS_028=Utilisation d'une déclaration font-face.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=La regola CSS 'class' non è usata.
CSS_024_SUG=È consigliabile rimuovere le regole CSS non usate.
CSS_025=La regola CSS 'class' non è stata trovata.
CSS_025_SUG=È consigliabile controllare di non aver compiuto un errore nel nome della classe o definire una 'class' effettivamente usata.
CSS_027=La regola CSS specifica una posizione assoluta.
CSS_028=La regola CSS specifica una 'font-face'.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=CSSクラスセレクタが使われていません.
CSS_024_SUG=使用していないCSSセレクタを削除してください.
CSS_025=CSSクラスセレクタが見つけられませんでした.
CSS_025_SUG=タイプミスをチェックするか、クラスを利用するセレクタを定義してください.
CSS_027=CSSセレクタでabsolute positionを指定しています.
CSS_028=Font-face宣言が使われています.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=클래스 셀렉터가 사용되지 않습니다.
CSS_024_SUG=사용하지 않은 선택자를 제거하십시요.
CSS_025=클래스 선택자를 찾을 수 없습니다.
CSS_025_SUG=오타가 없는지 확인하거나 사용하려는 클래스 선택자를 추가하십시요.
CSS_027=선택자가 absolute position 속성을 사용하였습니다.
CSS_028='font-face' 선언을 사용합니다.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=CSS class - bijvoorbeeld .voorbeeld - wordt niet gebruikt.
CSS_024_SUG=Verwijder ongebruikte CSS selectors.
CSS_025=De CSS class selector werd niet aangetroffen.
CSS_025_SUG=Controleer op typefouten of definieer een class selector om het gebruik van de class te documenteren.
CSS_027=De CSS selector specificeert een absolute positie.
CSS_028=Gebruik van font-face verklaring.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CSS_024=O seletor de classe CSS não é utilizado.
CSS_024_SUG=Remova seletores CSS não utilizados.
CSS_025=O seletor de classe CSS não foi localizado.
CSS_025_SUG=Verifique erros de digitação ou defina um seletor de classe para documentar o uso da classe.
CSS_027=O seletor CSS especifica posição absoluta.
CSS_028=Uso de declaração Font-face.

#HTM - XHTML related messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ public void testValidateEPUB30_CSSURLS_2()
@Test
public void testValidateEPUB30_CSSURLS_3()
{
Collections.addAll(expectedWarnings, MessageId.CSS_017);
Collections.addAll(expectedErrors, MessageId.CSS_020, MessageId.CSS_020);
// 'imgs/table_header_bg_uni.jpg': referenced resource missing in the
// package
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Transform - Style Tag</title>
<!-- <title>Transform - Style Tag</title> -->
<style type="text/css">
.rotateY {
background-color:yellow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"suggestion" : "Inline styles are not compatible with accessibility settings and display personalization. Use CSS Styles instead."
}, {
"ID" : "CSS-006",
"severity" : "WARNING",
"message" : "CSS position:fixed property should not be used in EPUBs.",
"severity" : "USAGE",
"message" : "CSS selector specifies fixed position.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "OPS/style.css",
Expand Down Expand Up @@ -94,7 +94,32 @@
"context" : ""
} ],
"suggestion" : null
} ],
}, {
"ID" : "HTM-033",
"severity" : "USAGE",
"message" : "HTML 'head' element does not have a 'title' child element.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "OPS/style_tag_css.xhtml",
"line" : 16,
"column" : 8,
"context" : null
} ],
"suggestion" : null
}, {
"ID" : "RSC-017",
"severity" : "WARNING",
"message" : "Warning while parsing file: The 'head' element should have a 'title' child element.",
"additionalLocations" : 0,
"locations" : [ {
"path" : "OPS/style_tag_css.xhtml",
"line" : 3,
"column" : 7,
"context" : null
} ],
"suggestion" : null
}
],
"customMessageFileName" : null,
"checker" : {
"path" : "./com/adobe/epubcheck/test/command_line/failonwarnings.epub",
Expand All @@ -105,7 +130,7 @@
"nFatal" : 0,
"nError" : 0,
"nWarning" : 1,
"nUsage" : 4
"nUsage" : 6
},
"publication" : {
"publisher" : null,
Expand All @@ -128,7 +153,7 @@
"isBackwardCompatible" : true,
"hasAudio" : false,
"hasVideo" : false,
"charsCount" : 648,
"charsCount" : 627,
"embeddedFonts" : [ ],
"refFonts" : [ ],
"hasEncryption" : false,
Expand Down Expand Up @@ -249,10 +274,10 @@
"id" : "page02",
"fileName" : "OPS/style_tag_css.xhtml",
"media_type" : "application/xhtml+xml",
"compressedSize" : 263,
"uncompressedSize" : 563,
"compressedSize" : 269,
"uncompressedSize" : 572,
"compressionMethod" : "Deflated",
"checkSum" : "a4d45bfbd24ab97ff2bdaa17276c1bc88aa8a5aadbf06f3b28b2f5db91612f6",
"checkSum" : "9ade68841fe28761295789b39e412d95cd26316e688f27cbac6ba2fc6f8840",
"isSpineItem" : true,
"spineIndex" : 1,
"isLinear" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CSS-002 ERROR Empty or NULL reference found.
CSS-003 ERROR Only UTF-8 and UTF-16 encodings are allowed, detected %1$s.
CSS-004 ERROR Only UTF-8 and UTF-16 encodings are allowed, detected %1$s BOM.
CSS-005 ERROR Conflicting alternate style attributes found: %1$s.
CSS-006 WARNING CSS position:fixed property should not be used in EPUBs.
CSS-006 WARNING CSS selector specifies fixed position.
CSS-007 WARNING Font-face reference %1$s refers to non-standard font type %2$s.
CSS-008 ERROR An error occurred while parsing the CSS: %1$s.
CSS-009 USAGE Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.
Expand All @@ -46,7 +46,7 @@ CSS-022 USAGE CSS selector specifies global margin setting.
CSS-023 USAGE CSS selector specifies media query.
CSS-024 USAGE CSS class Selector is not used. Remove unused CSS selectors.
CSS-025 USAGE CSS class Selector could not be found. Check for typos or define a class selector to document the use of the class.
CSS-027 USAGE CSS selector specifies absolute position.
CSS-017 USAGE CSS selector specifies absolute position.
CSS-028 USAGE Use of Font-face declaration.
HTM-001 ERROR Any publication resource that is an XML-based media type must be a valid XML 1.0 document. XML version found: %1$s.
HTM-002 WARNING The installed xml parser doesn't support xml version verification. Xml files must be a valid XML 1.0 document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Unused - Style Tag CSS</title>
<!-- <title>Unused - Style Tag CSS</title> -->
<style>
.used {
font-style: italic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ Start command_line test('severity_overrideBadId')
ERROR(CHK-002): ./com/adobe/epubcheck/test/command_line/severity(1,0): Unrecognized custom message id BogusID encountered in message overrides file './com/adobe/epubcheck/test/command_line/severity_overrideBadId.txt'.
Validating using EPUB version 3.0.1 rules.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(27,13): The 'unicode-bidi' property must not be included in an EPUB Style Sheet.
WARNING(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(38,13): CSS position:fixed property should not be used in EPUBs.
USAGE(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(38,13): CSS selector specifies fixed position.
WARNING(RSC-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(4,7): Warning while parsing file: The 'head' element should have a 'title' child element.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(14,1): The 'unicode-bidi' property must not be included in an EPUB Style Sheet.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(14,22): The 'direction' property must not be included in an EPUB Style Sheet.
WARNING(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(15,1): CSS position:fixed property should not be used in EPUBs.
USAGE(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/inline_css.xhtml(15,1): CSS selector specifies fixed position.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(55,5): The 'unicode-bidi' property must not be included in an EPUB Style Sheet.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(56,5): The 'direction' property must not be included in an EPUB Style Sheet.
WARNING(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(66,5): CSS position:fixed property should not be used in EPUBs.
USAGE(CSS-006): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(66,5): CSS selector specifies fixed position.
USAGE(ACC-008): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.xhtml(-1,-1): Navigation Document has no 'landmarks nav' element.
USAGE(HTM-010): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/toc.ncx(2,68): Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.
USAGE(CSS-012): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/external_css.xhtml(6,62): Document links to multiple CSS files.
USAGE(CSS-012): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/external_css.xhtml(7,66): Document links to multiple CSS files.
USAGE(HTM-033): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(4,7): HTML 'head' element does not have a 'title' child element.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(2,5): Value of CSS property 'font-size' does not use a relative size: '14px'
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(7,5): Value of CSS property 'font-size' does not use a relative size: '12px'
USAGE(ACC-015): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(7,5): Value of CSS property 'line-height' does not use a relative size.
Expand All @@ -23,7 +25,7 @@ USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.
USAGE(ACC-015): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(27,5): Value of CSS property 'line-height' does not use a relative size.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(35,5): Value of CSS property 'font-size' does not use a relative size: 'x-large'
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(39,5): Value of CSS property 'font-size' does not use a relative size: 'large'
WARNING(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(70,5): CSS selector specifies absolute position.
USAGE(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(70,5): CSS selector specifies absolute position.
USAGE(CSS-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(79,5): CSS property is declared !Important.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(90,5): Value of CSS property 'font-size' does not use a relative size: 'large'
USAGE(CSS-023): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(97,1): CSS selector specifies media query.
Expand All @@ -35,15 +37,15 @@ USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(38,5): Value of CSS property 'font-size' does not use a relative size: '12px'
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(51,5): Value of CSS property 'font-size' does not use a relative size: '11px'
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(58,5): Value of CSS property 'font-size' does not use a relative size: '10px'
WARNING(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(2,5): CSS selector specifies absolute position.
USAGE(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(2,5): CSS selector specifies absolute position.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(10,5): Value of CSS property 'font-size' does not use a relative size: '12px'
USAGE(ACC-015): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(10,5): Value of CSS property 'line-height' does not use a relative size.
USAGE(CSS-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(15,5): CSS property is declared !Important.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(27,5): Value of CSS property 'font-size' does not use a relative size: 'large'
USAGE(CSS-023): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(33,1): CSS selector specifies media query.
USAGE(ACC-014): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssStyles.css(35,9): Value of CSS property 'font-size' does not use a relative size: 'large'
USAGE(CSS-013): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(9,13): CSS property is declared !Important.
WARNING(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(17,13): CSS selector specifies absolute position.
USAGE(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(17,13): CSS selector specifies absolute position.
USAGE(CSS-023): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(20,9): CSS selector specifies media query.
USAGE(CSS-025): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(54,24): CSS class Selector could not be found.
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(14,9): CSS class Selector is not used.
Expand Down Expand Up @@ -72,7 +74,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 6 errors / 6 warnings / 0 info / 58 usage
Messages: 0 fatal / 6 errors / 1 warnings / 0 info / 65 usage

EPUBCheck completed
Completed command_line test('severity_overrideBadId')
Loading

0 comments on commit 672ac6d

Please sign in to comment.