Please review: parsing HTML 5 media elements
Harri Porten
porten at kde.org
Fri May 16 00:35:00 BST 2008
Hi!
Germain had added support for the <audio> and <video> elements to the KDE
4.1. feature plan. Not sure whether he already did some work in his git
repo. As the freeze is coming near I went ahead and wanted to lay the
groundwork for them. Details can be implemented later.
I'd like to ask either Allen or Germain to take a look at the necessary
parser extension. For better readability he attached patch does not
contain the generated dtd.h and dtd.c code. The element creation code is
just a dummy printing out a message.
Harri.
P.S. Note to bystanders: we already have audio support in KHTML for some
time now. But that was based on the "Audio" JS element. Equally
non-standard as <audio> so far...
-------------- next part --------------
Index: misc/htmltags.in
===================================================================
--- misc/htmltags.in (revision 808184)
+++ misc/htmltags.in (working copy)
@@ -4,6 +4,7 @@
address
applet
area
+audio
b
base
basefont
@@ -80,6 +81,7 @@
script
select
small
+source
span
strike
strong
@@ -99,5 +101,6 @@
u
ul
var
+video
wbr
xmp
Index: html/dtd.cpp
===================================================================
--- html/dtd.cpp (revision 808184)
+++ html/dtd.cpp (working copy)
@@ -52,6 +52,7 @@
5, // ID_ADDRESS
1, // ID_APPLET
0, // ID_AREA
+ 1, // ID_AUDIO
1, // ID_B
0, // ID_BASE
0, // ID_BASEFONT
@@ -128,6 +129,7 @@
1, // ID_SCRIPT
6, // ID_SELECT
1, // ID_SMALL
+ 1, // ID_SOURCE
1, // ID_SPAN
1, // ID_STRIKE
1, // ID_STRONG
@@ -147,6 +149,7 @@
1, // ID_U
5, // ID_UL
1, // ID_VAR
+ 1, // ID_VIDEO
0, // ID_WBR
5, // ID_XMP
0, // ID_TEXT
@@ -160,6 +163,7 @@
REQUIRED, // ID_ADDRESS
REQUIRED, // ID_APPLET
FORBIDDEN, // ID_AREA
+ REQUIRED, // ID_AUDIO
REQUIRED, // ID_B
FORBIDDEN, // ID_BASE
FORBIDDEN, // ID_BASEFONT
@@ -236,6 +240,7 @@
REQUIRED, // ID_SCRIPT
REQUIRED, // ID_SELECT
REQUIRED, // ID_SMALL
+ FORBIDDEN, // ID_SOURCE
REQUIRED, // ID_SPAN
REQUIRED, // ID_STRIKE
REQUIRED, // ID_STRONG
@@ -255,7 +260,8 @@
REQUIRED, // ID_U
REQUIRED, // ID_UL
REQUIRED, // ID_VAR
- FORBIDDEN, // ID_WBR
+ REQUIRED, // ID_VIDEO
+ FORBIDDEN, // ID_WBR
REQUIRED, // ID_XMP
REQUIRED // ID_TEXT
};
@@ -316,6 +322,8 @@
ID_NOBR, // ?
ID_WBR, // ?
ID_CANVAS,
+ ID_AUDIO,
+ ID_VIDEO,
0
};
@@ -543,6 +551,9 @@
case ID_APPLET:
// OBJECT: %flow | PARAM *
return check_flow(childID, true) || childID == ID_PARAM;
+ case ID_AUDIO:
+ case ID_VIDEO:
+ return check_flow(childID, true) || childID == ID_SOURCE;
case ID_PRE:
case ID_XMP:
case ID_PLAINTEXT:
Index: html/htmlparser.cpp
===================================================================
--- html/htmlparser.cpp (revision 808184)
+++ html/htmlparser.cpp (working copy)
@@ -1061,7 +1061,18 @@
n = scriptElement;
break;
}
-
+ case ID_AUDIO:
+ qDebug("CREATING AUDIO ELEMENT");
+ n = new HTMLGenericElementImpl(document, t->tid);
+ break;
+ case ID_VIDEO:
+ qDebug("CREATING VIDEO ELEMENT");
+ n = new HTMLGenericElementImpl(document, t->tid);
+ break;
+ case ID_SOURCE:
+ qDebug("CREATING SOURCE ELEMENT");
+ n = new HTMLGenericElementImpl(document, t->tid);
+ break;
// tables
case ID_TABLE:
n = new HTMLTableElementImpl(document);
More information about the kfm-devel
mailing list