Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: better check media overlays styling properties #1402

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/main/java/com/adobe/epubcheck/css/CSSHandler.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,9 @@
import org.idpf.epubcheck.util.css.CssContentHandler;
import org.idpf.epubcheck.util.css.CssErrorHandler;
import org.idpf.epubcheck.util.css.CssExceptions.CssException;
import org.idpf.epubcheck.util.css.CssGrammar;
import org.idpf.epubcheck.util.css.CssGrammar.CssAtRule;
import org.idpf.epubcheck.util.css.CssGrammar.CssComposedConstruct;
import org.idpf.epubcheck.util.css.CssGrammar.CssConstruct;
import org.idpf.epubcheck.util.css.CssGrammar.CssDeclaration;
import org.idpf.epubcheck.util.css.CssGrammar.CssSelector;
@@ -201,6 +203,43 @@ public void endAtRule(String name)
@Override
public void selectors(List<CssSelector> selectors)
{
for (CssSelector selector : selectors)
{
if (!context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_ACTIVE_CLASS)
&& findClassName(selector, ".-epub-media-overlay-active"))
{
report.message(MessageId.CSS_029,
getCorrectedEPUBLocation(selector.getLocation().getLine(),
selector.getLocation().getColumn(), selector.toCssString()),
"-epub-media-overlay-active", "media:active-class");
}
if (!context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_PLAYBACK_ACTIVE_CLASS)
&& findClassName(selector, ".-epub-media-overlay-playing"))
{
report.message(MessageId.CSS_029,
getCorrectedEPUBLocation(selector.getLocation().getLine(),
selector.getLocation().getColumn(), selector.toCssString()),
"-epub-media-overlay-playing", "media:playback-active-class");
}
}
}

private boolean findClassName(CssConstruct construct, String name)
{
if (construct.getType() == CssGrammar.CssConstruct.Type.CLASSNAME
&& name.equals(construct.toCssString()))
{
return true;

}
else if (construct instanceof CssComposedConstruct)
{
for (CssConstruct component : ((CssComposedConstruct) construct).getComponents())
{
if (findClassName(component, name)) return true;
}
}
return false;
}

@Override
Original file line number Diff line number Diff line change
@@ -91,6 +91,8 @@ private void initialize()
severities.put(MessageId.CSS_024, Severity.SUPPRESSED);
severities.put(MessageId.CSS_025, Severity.SUPPRESSED);
severities.put(MessageId.CSS_028, Severity.USAGE);
severities.put(MessageId.CSS_029, Severity.USAGE);
severities.put(MessageId.CSS_030, Severity.ERROR);

// HTML
severities.put(MessageId.HTM_001, Severity.ERROR);
2 changes: 2 additions & 0 deletions src/main/java/com/adobe/epubcheck/messages/MessageId.java
Original file line number Diff line number Diff line change
@@ -85,6 +85,8 @@ public enum MessageId implements Comparable<MessageId>
CSS_024("CSS-024"),
CSS_025("CSS-025"),
CSS_028("CSS-028"),
CSS_029("CSS-029"),
CSS_030("CSS-030"),

// Messages relating to xhtml markup
HTM_001("HTM-001"),
18 changes: 18 additions & 0 deletions src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java
Original file line number Diff line number Diff line change
@@ -566,6 +566,24 @@ private void processMeta()
{
metadataBuilders.peekFirst().meta(e.getAttribute("id"), prop.get(),
(String) e.getPrivateData(), e.getAttribute("refines"));

// Primary metadata checks
if (metadataBuilders.size() == 1)
{
switch (prop.get().getPrefixedName())
{
case "media:active-class":
context.featureReport.report(FeatureEnum.MEDIA_OVERLAYS_ACTIVE_CLASS, location(),
e.getPrivateData().toString());
break;
case "media:playback-active-class":
context.featureReport.report(FeatureEnum.MEDIA_OVERLAYS_PLAYBACK_ACTIVE_CLASS, location(),
e.getPrivateData().toString());
break;
default:
break;
}
}
}

// just parse the scheme for vocab errors
9 changes: 7 additions & 2 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler.java
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ public class OPSHandler extends XMLHandler
protected boolean hasTh = false;
protected boolean hasThead = false;
protected boolean hasCaption = false;
protected boolean hasCSS = false;
protected boolean epubTypeInUse = false;
protected StringBuilder textNode;
protected Stack<EPUBLocation> elementLocationStack = new Stack<EPUBLocation>();
@@ -94,10 +95,13 @@ protected void checkLink()
XMLElement e = currentElement();
URL href = checkURL(e.getAttribute("href"));
String rel = e.getAttribute("rel");
if (xrefChecker.isPresent() && href != null && rel != null
if (href != null && rel != null
&& rel.toLowerCase(Locale.ROOT).contains("stylesheet"))
{
xrefChecker.get().registerReference(href, XRefChecker.Type.STYLESHEET, location());
this.hasCSS = true;
if (xrefChecker.isPresent()) {
xrefChecker.get().registerReference(href, XRefChecker.Type.STYLESHEET, location());
}
}
}

@@ -365,6 +369,7 @@ public void endElement()
String style = textNode.toString();
if (style.length() > 0)
{
this.hasCSS = true;
new CSSChecker(context, style, currentLocation.getLine(), false).check();
}
textNode = null;
12 changes: 12 additions & 0 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Original file line number Diff line number Diff line change
@@ -815,6 +815,7 @@ public void endElement()
String name = e.getName();
if (openElements == 0 && (name.equals("html") || name.equals("svg")))
{
checkOverlaysStyles();
checkProperties();
}
else if (name.equals("object"))
@@ -902,6 +903,17 @@ protected void checkFallback(String elementType)
}
}

protected void checkOverlaysStyles()
{
if (context.opfItem.isPresent() && context.opfItem.get().getMediaOverlay() != null
&& (context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_ACTIVE_CLASS)
|| context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_PLAYBACK_ACTIVE_CLASS))
&& !this.hasCSS)
{
report.message(MessageId.CSS_030, location());
}
}

protected void checkProperties()
{
if (!context.container.isPresent()) // single file validation
2 changes: 2 additions & 0 deletions src/main/java/com/adobe/epubcheck/util/FeatureEnum.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,8 @@ public enum FeatureEnum
LOI("list of illustrations"),
LOT("list of tables"),
LOV("list of videos"),
MEDIA_OVERLAYS_ACTIVE_CLASS("media:active-class"),
MEDIA_OVERLAYS_PLAYBACK_ACTIVE_CLASS("media:playback-active-class"),
MODIFIED_DATE("modification date"),
NAVIGATION_ORDER("navigation order"),
PAGE_BREAK("epub:page-break"),
4 changes: 2 additions & 2 deletions src/main/java/org/idpf/epubcheck/util/css/CssGrammar.java
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ public enum Type
/**
* A CssConstruct that is composed by a single token.
*/
static abstract class CssAtomicConstruct extends CssConstruct
public static abstract class CssAtomicConstruct extends CssConstruct
{
final String value;

@@ -434,7 +434,7 @@ public String toString()
* A CssConstruct that is composed a list of atomic and/or composed CssConstructs,
* and optionally a name.
*/
static abstract class CssComposedConstruct extends CssConstruct
public static abstract class CssComposedConstruct extends CssConstruct
{
final List<CssConstruct> components;
final Optional<String> name;
Original file line number Diff line number Diff line change
@@ -67,6 +67,8 @@ 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_028=Use of Font-face declaration.
CSS_029=Found CSS class name "%1$s" but no "%2$s" property was declared in the package document.
CSS_030=The package document declares media overlays styling class names but no CSS was found in the content document.

#HTM - XHTML related messages
HTM_001=Any publication resource that is an XML-based media type must be a valid XML 1.0 document. XML version found: %1$s.
10 changes: 10 additions & 0 deletions src/main/resources/com/adobe/epubcheck/schema/30/package-30.sch
Original file line number Diff line number Diff line change
@@ -417,14 +417,24 @@
</pattern>

<pattern id="opf.media.overlay.metadata.active-class">
<rule context="opf:package/opf:metadata">
<assert test="count(opf:meta[normalize-space(@property)='media:active-class']) le 1">The 'active-class' property must not occur more than one time in the package
metadata.</assert>
</rule>
<rule context="opf:meta[normalize-space(@property)='media:active-class']">
<report test="@refines"> @refines must not be used with the media:active-class property</report>
<report test="contains(normalize-space(.),' ')">the 'active-class' property must define a single class name</report>
</rule>
</pattern>

<pattern id="opf.media.overlay.metadata.playback-active-class">
<rule context="opf:package/opf:metadata">
<assert test="count(opf:meta[normalize-space(@property)='media:playback-active-class']) le 1">The 'playback-active-class' property must not occur more than one time in the package
metadata.</assert>
</rule>
<rule context="opf:meta[normalize-space(@property)='media:playback-active-class']">
<report test="@refines"> @refines must not be used with the media:playback-active-class property</report>
<report test="contains(normalize-space(.),' ')">the 'playback-active-class' property must define a single class name</report>
</rule>
</pattern>

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="content_001.xhtml#c01"/>
<audio src="content_001.mp3"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
<style>
.-epub-media-overlay-active {
background-color: yellow;
}
.-epub-media-overlay-playing {
color: gray;
}
</style>
</head>
<body>
<h1 id="c01">Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
<meta property="media:duration">2.5s</meta>
<meta property="media:duration" refines="#mo_001">2.5s</meta>
<meta property="media:active-class">-epub-media-overlay-active</meta>
<meta property="media:playback-active-class">-epub-media-overlay-playing</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml" media-overlay="mo_001"/>
<item id="mo_001" href="content_001.smil" media-type="application/smil+xml"/>
<item id="audio_001" href="content_001.mp3" media-type="audio/mpeg"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata>
<dc:title>Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<meta property="media:active-class">class1 class2</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">10min</meta>
<meta refines="#mo001" property="media:duration">10min</meta>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="content_001.xhtml#c01"/>
<audio src="content_001.mp3"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1 id="c01">Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
<meta property="media:duration">2.5s</meta>
<meta property="media:duration" refines="#mo_001">2.5s</meta>
<meta property="media:active-class">-epub-media-overlay-active</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml" media-overlay="mo_001"/>
<item id="mo_001" href="content_001.smil" media-type="application/smil+xml"/>
<item id="audio_001" href="content_001.mp3" media-type="audio/mpeg"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="content_001.xhtml#c01"/>
<audio src="content_001.mp3"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1 id="c01">Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
<meta property="media:duration">2.5s</meta>
<meta property="media:duration" refines="#mo_001">2.5s</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml" media-overlay="mo_001"/>
<item id="styles" href="styles.css" media-type="text/css"/>
<item id="mo_001" href="content_001.smil" media-type="application/smil+xml"/>
<item id="audio_001" href="content_001.mp3" media-type="audio/mpeg"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.-epub-media-overlay-active {
background-color: yellow;
}
.-epub-media-overlay-playing {
color: gray;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="content_001.xhtml#c01"/>
<audio src="content_001.mp3"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<h1 id="c01">Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
<meta property="media:duration">2.5s</meta>
<meta property="media:duration" refines="#mo_001">2.5s</meta>
<meta property="media:active-class">-epub-media-overlay-active</meta>
<meta property="media:playback-active-class">-epub-media-overlay-playing</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml" media-overlay="mo_001"/>
<item id="styles" href="styles.css" media-type="text/css"/>
<item id="mo_001" href="content_001.smil" media-type="application/smil+xml"/>
<item id="audio_001" href="content_001.mp3" media-type="audio/mpeg"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.-epub-media-overlay-active {
background-color: yellow;
}
.-epub-media-overlay-playing {
color: gray;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata>
<dc:title>Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<meta property="media:playback-active-class">class1 class2</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">10min</meta>
<meta refines="#mo001" property="media:duration">10min</meta>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<meta property="media:playback-active-class" refines="#mo001">-epub-media-overlay-playing</meta>
<meta property="media:playback-active-class" refines="#mo001">-epub-media-overlay-playing</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">10min</meta>
<meta refines="#mo001" property="media:duration">10min</meta>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/ns/SMIL" xmlns:epub="http://www.idpf.org/2007/ops" version="3.0">
<body>
<par id="par1">
<text src="content_001.xhtml#c01"/>
<audio src="content_001.mp3"/>
</par>
</body>
</smil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1 id="c01">Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
<meta property="media:duration">2.5s</meta>
<meta property="media:duration" refines="#mo_001">2.5s</meta>
<meta property="media:playback-active-class">-epub-media-overlay-playing</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml" media-overlay="mo_001"/>
<item id="mo_001" href="content_001.smil" media-type="application/smil+xml"/>
<item id="audio_001" href="content_001.mp3" media-type="audio/mpeg"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
45 changes: 45 additions & 0 deletions src/test/resources/epub3/09-media-overlays/media-overlays.feature
Original file line number Diff line number Diff line change
@@ -174,6 +174,36 @@ Feature: EPUB 3 — Media Overlays


### 9.3.4 Associating style information

@spec @xref:sec-docs-assoc-style
Scenario: Verify 'media:active-class' and 'media:playback-active-class' properties referring to classes defined in a stylesheet
Given the reporting level is set to USAGE
When checking EPUB 'mediaoverlays-active-class-stylesheet-valid'
Then usage CSS-029 is reported 0 times
And no errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Verify 'media:active-class' and 'media:playback-active-class' properties referring to classes defined inline
When checking EPUB 'mediaoverlays-active-class-inline-valid'
Then no errors or warnings are reported

Scenario: Report when well-known class names are found in CSS but not declared in the package document
Given the reporting level is set to USAGE
When checking EPUB 'mediaoverlays-active-class-stylesheet-undeclared-valid'
Then usage CSS-029 is reported 2 times
But no errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Report when 'media:active-class' is defined but no CSS was found in the content document
When checking EPUB 'mediaoverlays-active-class-style-not-found-error'
Then error CSS-030 is reported
And no other errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Report when 'media:playback-active-class' is defined but no CSS was found in the content document
When checking EPUB 'mediaoverlays-playback-active-class-style-not-found-error'
Then error CSS-030 is reported
And no other errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Report a 'media:active-class' property with a refines attribute
@@ -189,6 +219,21 @@ Feature: EPUB 3 — Media Overlays
And the message contains "must not be used with the media:playback-active-class property"
And no other errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Report a 'media:active-class' property that defines more than one class
When checking file 'mediaoverlays-active-class-multiple-class-names-error.opf'
Then error RSC-005 is reported
And the message contains "must define a single class name"
And no other errors or warnings are reported

@spec @xref:sec-docs-assoc-style
Scenario: Report a 'media:playback-active-class' property that defines more than one class
When checking file 'mediaoverlays-playback-active-class-multiple-class-names-error.opf'
Then error RSC-005 is reported
And the message contains "must define a single class name"
And no other errors or warnings are reported

#Scenario: Detect when media overlays class are declared in the publication but no CSS is found

### 9.3.5 Media overlays packaging

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata>
<dc:title>Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">0:01:30.200</meta>
<meta refines="#mo001" property="media:duration">0:01:30.200</meta>
<meta property="media:active-class">class1</meta>
<meta property="media:active-class">class2</meta>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata>
<dc:title>Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<meta property="dcterms:modified">2019-01-01T12:00:00Z</meta>
<!-- Media Overlays Duration Properties -->
<meta property="media:duration">0:01:30.200</meta>
<meta refines="#mo001" property="media:duration">0:01:30.200</meta>
<meta property="media:playback-active-class">class1</meta>
<meta property="media:playback-active-class">class2</meta>
</metadata>
<manifest>
<item id="t001" href="contents.xhtml" properties="nav" media-type="application/xhtml+xml"/>
<item id="mo001" href="mediaoverlay_001.smil" media-type="application/smil+xml"/>
</manifest>
<spine>
<itemref idref="t001"/>
</spine>
</package>
19 changes: 19 additions & 0 deletions src/test/resources/epub3/D-vocabularies/media-overlays.feature
Original file line number Diff line number Diff line change
@@ -10,6 +10,15 @@ Feature: EPUB 3 — Vocabularies — Media overlays vocabulary
And EPUBCheck with default settings

## D.8 Media Overlays Metadata Vocabulary

### D.8.1 active-class

@spec @xref:sec-active-class
Scenario: Report a 'media:active-class' property defined more than once
When checking file 'mediaoverlays-active-class-more-than-once-error.opf'
Then error RSC-005 is reported
And the message contains "The 'active-class' property must not occur more than one time"
And no other errors or warnings are reported

### D.8.2 duration

@@ -30,4 +39,14 @@ Feature: EPUB 3 — Vocabularies — Media overlays vocabulary
| RSC-005 | must be a valid SMIL3 clock value |
| RSC-005 | must be a valid SMIL3 clock value |
| RSC-005 | must be a valid SMIL3 clock value |
And no other errors or warnings are reported


### D.8.1 playback-active-class

@spec @xref:sec-playback-active-class
Scenario: Report a 'media:playback-active-class' property defined more than once
When checking file 'mediaoverlays-playback-active-class-more-than-once-error.opf'
Then error RSC-005 is reported
And the message contains "The 'playback-active-class' property must not occur more than one time"
And no other errors or warnings are reported