annotate pyink/html5css3.py @ 1365:c832f0b041b9

Added tag s for changeset aa7cbf2cbf34
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 25 Feb 2011 15:27:35 +0800
parents aa7cbf2cbf34
children dc6591b4079d
rev   line source
1341
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 import pybExtension
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
2 from domview import component_manager, layers_parser, scenes_parser
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
3 from trait import composite, trait, require
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
4
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
5
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
6 def _scene_node_range(node):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
7 start = node.getAttribute('start')
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
8 try:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
9 end = node.getAttribute('end')
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
10 except:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
11 end = start
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
12 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
13 try:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
14 scene_type = node.getAttribute('type')
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
15 except:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
16 scene_type = 'normal'
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
17 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
18
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
19 return int(start), int(end), scene_type
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
20
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
21
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
22 @composite
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
23 class dom_parser(object):
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
24 use_traits = (component_manager, layers_parser, scenes_parser)
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
25 provide_traits = {layers_parser.get_scene: '_scenes_get_scene'}
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
26 method_map_traits = {
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
27 scenes_parser._find_maxframe: '_find_maxframe',
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
28 scenes_parser._collect_all_scenes: '_collect_all_scenes',
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
29 scenes_parser._collect_node_ids: '_collect_node_ids',
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
30 component_manager._start_component_manager:
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
31 '_start_component_manager',
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
32 scenes_parser.get_scene: '_scenes_get_scene'
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
33 }
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
34
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
35 def __init__(self):
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
36 self._metadata_node = None
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
37 self._scenes_node = None
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
38
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
39 self._doc = None
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
40 self._root = None
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
41 self._layers = []
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
42 self._layers_parent = None
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
43 self._maxframe = 0
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
44 self.current = 0
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
45 self._id2node = {}
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
46 self._group2scene = {}
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
47 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
48
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
49 def _find_meta(self):
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
50 for child in self._root.childList():
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
51 if child.name() == 'svg:metadata':
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
52 self._metadata_node = child
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
53 break
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
54 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
55 else:
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
56 raise RuntimeError, 'can not find \'svg:metadata\' node'
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
57
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
58 for child in self._metadata_node.childList():
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
59 if child.name() == 'ns0:scenes':
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
60 self._scenes_node = child
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
61 break
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
62 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
63 else:
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
64 raise RuntimeError, \
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
65 'can not find \'ns0:scenes\' node under \'svg:metadata\''
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
66
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
67 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
68
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
69 def start_handle(self, doc):
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
70 self._doc = doc
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
71 self._root = doc.root()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
72 self._layers_parent = self._root
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
73
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
74 self._find_meta()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
75
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
76 self._collect_node_ids()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
77 self._collect_all_scenes()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
78
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
79 self.parse_all_layers()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
80
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
81 self._start_component_manager()
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
82 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
83
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
84 def reset(self):
1354
f92be354ad24 Refactory code to layer_parser.reset_layers()
Thinker K.F. Li <thinker@codemud.net>
parents: 1353
diff changeset
85 self.reset_layers()
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
86 pass
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
87
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
88 def get_maxframe(self):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
89 return self._maxframe
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
90
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
91 def _find_scene_node(self, frame_idx, layer_idx):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
92 layer = self._layers[layer_idx]
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
93 for scene_node in layer.scenes:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
94 start, end, scene_type = _scene_node_range(scene_node)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
95 if start <= frame_idx and frame_idx <= end:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
96 return scene_node
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
97 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
98 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
99
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
100 def get_scene(self, frame_idx, layer_idx):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
101 scene_node = self._find_scene_node(frame_idx, layer_idx)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
102 if scene_node:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
103 start, end, scene_type = _scene_node_range(scene_node)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
104 return start, end, scene_type
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
105 return None
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
106
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
107 def get_scene_group(self, frame_idx, layer_idx):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
108 scene_node = self._find_scene_node(frame_idx, layer_idx)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
109 if scene_node:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
110 gid = scene_node.getAttribute('ref')
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
111 scene_group = self.get_node(gid)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
112 return scene_group
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
113 return None
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
114 pass
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
115
1341
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
116
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
117 def _print_level(txt, lvl, out):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
118 indent = ' ' * lvl
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
119 print >> out, '%s%s' % (indent, txt)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
120 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
121
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
122 def _print_node_open(node, lvl, out):
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
123 node_name = node.name()
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
124 if node_name.startswith('svg:'):
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
125 node_name = node_name[4:]
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
126 pass
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
127
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
128 attrs = []
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
129 for attrname in node.allAttributes():
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
130 attrvalue = node.getAttribute(attrname)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
131 attr = '%s="%s"' % (attrname, attrvalue)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
132 attrs.append(attr)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
133 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
134
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
135 if attrs:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
136 attrs_str = ' '.join(attrs)
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
137 line = '<%s %s>' % (node_name, attrs_str)
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
138 else:
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
139 line = '<%s>' % (node_name)
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
140 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
141 _print_level(line, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
142 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
143
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
144 def _print_node_close(node, lvl, out):
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
145 node_name = node.name()
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
146 if node_name.startswith('svg:'):
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
147 node_name = node_name[4:]
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
148 pass
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
149
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
150 line = '</%s>' % (node_name)
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
151 _print_level(line, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
152 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
153
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
154 def _print_node_single(node, lvl, out):
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
155 node_name = node.name()
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
156 if node_name.startswith('svg:'):
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
157 node_name = node_name[4:]
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
158 pass
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
159
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
160 attrs = []
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
161 for attrname in node.allAttributes():
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
162 attrvalue = node.getAttribute(attrname)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
163 attr = '%s="%s"' % (attrname, attrvalue)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
164 attrs.append(attr)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
165 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
166
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
167 if attrs:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
168 attrs_str = ' '.join(attrs)
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
169 line = '<%s %s/>' % (node_name, attrs_str)
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
170 else:
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
171 line = '<%s/>' % (node_name)
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
172 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
173 _print_level(line, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
174 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
175
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
176 def _print_node_content(node, lvl, out):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
177 line = node.content()
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
178 _print_level(line, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
179 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
180
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
181 def _print_subtree(node, lvl, out):
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
182 children = node.childList()
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
183 if not children:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
184 if node.name() != 'string':
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
185 _print_node_single(node, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
186 else:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
187 _print_node_content(node, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
188 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
189 return
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
190
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
191 _print_node_open(node, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
192 for child in children:
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
193 _print_subtree(child, lvl + 1, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
194 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
195 _print_node_close(node, lvl, out)
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
196 pass
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
197
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
198
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
199 ## \brief CSS3 animation code generator.
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
200 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
201 # This trait parses and generate transition code, in CSS3, for two
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
202 # nodes.
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
203 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
204 @trait
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
205 class css3_ani_gen(object):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
206 _parse_ani_attrs = require
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
207
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
208 _passing = lambda name, value: (name, str(value))
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
209 _trans_transform = lambda name, value: \
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
210 (name, 'matrix(' + ','.join([str(e) for e in value]) + ')')
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
211
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
212 _translators = {'x': _passing, 'y': _passing,
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
213 'width': _passing, 'height': _passing,
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
214 'opacity': _passing, 'transform': _trans_transform
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
215 }
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
216
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
217 del _trans_transform
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
218 del _passing
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
219
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
220 @staticmethod
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
221 def _ani_attr_to_css3(attrname, attrvalue, css):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
222 translator = css3_ani_gen._translators[attrname]
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
223 cssname, cssvalue = translator(attrname, attrvalue)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
224 css[cssname] = cssvalue
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
225 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
226
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
227 def _make_css3_transition(self, node1, node2, duration):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
228 from tween import _normalize_attrs
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
229
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
230 ani_attrs1 = self._parse_ani_attrs(node1)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
231 ani_attrs2 = self._parse_ani_attrs(node2)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
232
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
233 _normalize_attrs(node1, ani_attrs1, node2, ani_attrs2)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
234
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
235 css = {}
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
236
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
237 attrnames = set(ani_attrs1.keys() + ani_attrs2.keys())
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
238 for attrname in attrnames:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
239 attrvalue = ani_attrs2[attrname]
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
240 self._ani_attr_to_css3(attrname, attrvalue, css)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
241 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
242
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
243 properties = css.keys()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
244 css['transition-property'] = ', '.join(properties)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
245 css['transition-duration'] = '%gs' % (duration)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
246
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
247 return css
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
248
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
249 def _write_css(self, selector, css_props, out):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
250 print >> out, '%s {' % (selector)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
251 for prop_name, prop_value in css_props.items():
1363
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
252 print >> out, ' %s: %s;' % (prop_name, prop_value)
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
253 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
254 print >> out, '}'
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
255 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
256 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
257
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
258
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
259 @composite
1341
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
260 class html5css3_ext(pybExtension.PYBindExtImp):
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
261 use_traits = (css3_ani_gen,)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
262 method_map_traits = {css3_ani_gen._make_css3_transition:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
263 '_make_css3_transition',
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
264 css3_ani_gen._write_css: '_write_css'
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
265 }
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
266
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
267 _frame_rate = 12
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
268
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
269 def __init__(self):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
270 self._stylesheet = {}
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
271 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
272
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
273 @staticmethod
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
274 def _parse_ani_attrs(node):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
275 from tween import _parse_attr_ani, _parse_style_ani
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
276 attrs = {}
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
277 _parse_attr_ani(node, attrs)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
278 _parse_style_ani(node, attrs)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
279 return attrs
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
280
1341
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
281 def save(self, module, doc, filename):
1361
cf5ed0b8f45d Write out all content of a DOM-tree
Thinker K.F. Li <thinker@codemud.net>
parents: 1354
diff changeset
282 import sys
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
283 parser = dom_parser()
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
284 self._parser = parser
1353
ce19a11657a7 Try parsing DOM in html5css3.py try with parser from domview.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1341
diff changeset
285 parser.start_handle(doc.rdoc)
1354
f92be354ad24 Refactory code to layer_parser.reset_layers()
Thinker K.F. Li <thinker@codemud.net>
parents: 1353
diff changeset
286
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
287 self._handle_transition_layers()
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
288
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
289 out = file(filename, 'w+')
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
290 print >> out, '''\
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
291 <html
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
292 xmlns:dc="http://purl.org/dc/elements/1.1/"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
293 xmlns:cc="http://creativecommons.org/ns#"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
294 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
295 xmlns:svg="http://www.w3.org/2000/svg"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
296 xmlns:xlink="http://www.w3.org/1999/xlink"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
297 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
298 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
299 xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd"
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
300 >
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
301 <head>
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
302 <title>Scribboo Test Page</title>
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
303 <!-- Style for animation transitions -->
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
304 <style type='text/css'>'''
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
305
1364
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
306 for selector, style in self._stylesheet.items():
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
307 self._write_css(selector, style, out)
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
308 pass
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
309
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
310 print >> out, '''\
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
311 </style>
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
312 </head>
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
313 <body>'''
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
314
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
315 root = doc.rdoc.root()
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
316 _print_subtree(root, 1, out)
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
317
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
318 print >> out, '''\
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
319 </body>
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
320 </html>'''
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
321
aa7cbf2cbf34 Fix bug of SVG been fault for showing
Thinker K.F. Li <thinker@codemud.net>
parents: 1363
diff changeset
322 out.close()
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
323 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
324
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
325 ## \brief Find all animation pairs.
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
326 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
327 # An animation pair is two nodes, one from start scene group and
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
328 # another from stop scene group. The node from start scene group
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
329 # will transite to the state of the node from stop scene group.
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
330 # This method is responsible for finding all pairs.
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
331 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
332 @staticmethod
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
333 def _find_transition_pairs(start_scene_group, stop_scene_group):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
334 # Collect all nodes in stop scene
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
335 stop_nodes = {}
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
336 node = stop_scene_group.firstChild()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
337 while node:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
338 try:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
339 node_label = node.getAttribute("ns0:duplicate-src")
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
340 stop_nodes[node_label] = node
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
341 except:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
342 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
343 node = node.next()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
344 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
345
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
346 # Collect all nodes in start scene
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
347 start_nodes = {}
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
348 node = start_scene_group.firstChild()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
349 while node:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
350 try:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
351 node_label = node.getAttribute("id")
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
352 start_nodes[node_label] = node
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
353 except:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
354 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
355 node = node.next()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
356 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
357
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
358 pairs = []
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
359 for start_node in start_scene_group.childList():
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
360 start_node_id = start_node.getAttribute('id')
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
361 try:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
362 stop_node = stop_nodes[start_node_id]
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
363 except:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
364 stop_node = start_node
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
365 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
366 pairs.append((start_node, stop_node))
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
367 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
368
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
369 return pairs
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
370
1363
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
371 def _make_scene_group_style(self, frame_idx, layer_idx):
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
372 scene_group = self._parser.get_scene_group(frame_idx, layer_idx)
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
373 gid = scene_group.getAttribute('id')
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
374 selector = '.frame%04d #%s' % (frame_idx, gid)
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
375 style = {'display': 'inline'}
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
376 self._stylesheet[selector] = style
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
377 pass
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
378
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
379 def _handle_transition_layer(self, layer_idx):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
380 parser = self._parser
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
381 maxframe = parser.get_maxframe()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
382 stylesheet = self._stylesheet
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
383
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
384 frame_idx = 0
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
385 while frame_idx < maxframe:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
386 scene = parser.get_scene(frame_idx, layer_idx)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
387 if not scene:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
388 frame_idx = frame_idx + 1
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
389 continue
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
390
1363
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
391 self._make_scene_group_style(frame_idx, layer_idx)
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
392
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
393 start, end, tween_type = scene
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
394 if start == end:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
395 frame_idx = frame_idx + 1
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
396 continue
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
397
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
398 next_start = end + 1
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
399 scene = parser.get_scene(next_start, layer_idx)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
400 if not scene:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
401 frame_idx = next_start + 1
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
402 continue
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
403
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
404 scene_group = parser.get_scene_group(start, layer_idx)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
405 next_scene_group = parser.get_scene_group(next_start, layer_idx)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
406
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
407 duration = float(next_start - start) / self._frame_rate
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
408
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
409 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
410 # Generate style for every transition pair
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
411 #
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
412 transition_pairs = \
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
413 self._find_transition_pairs(scene_group, next_scene_group)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
414 for start_node, stop_node in transition_pairs:
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
415 css_props = self._make_css3_transition(start_node,
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
416 stop_node,
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
417 duration)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
418 node_id = start_node.getAttribute('id')
1363
a05ea7fa43ec Generate CSS rule for key frames
Thinker K.F. Li <thinker@codemud.net>
parents: 1362
diff changeset
419 selector = '.frame%04d #%s' % (start, node_id)
1362
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
420 stylesheet[selector] = css_props
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
421 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
422
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
423 frame_idx = next_start
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
424 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
425 pass
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
426
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
427 def _handle_transition_layers(self):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
428 num_layers = self._parser.get_layer_num()
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
429 for layer_idx in range(num_layers):
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
430 self._handle_transition_layer(layer_idx)
bb76f9d57363 Generate CSS3 transition rules
Thinker K.F. Li <thinker@codemud.net>
parents: 1361
diff changeset
431 pass
1341
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
432 pass
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
433 pass
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
434
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
435 extension = (html5css3_ext(),
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
436 'net.scribboo.html5css3',
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
437 'HTML5/CSS3 exporter',
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
438 'output',
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
439 {'extension': '.html',
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
440 'mimetype': 'text/html',
599b606c4669 Start to implement HTML5/CSS3 exporter
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
441 '_filetypename': 'HTML5/CSS3 (*.html)'})