repos
/
Oh, Ducks!
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
element-parent now works in lhtml
Annotate for file unify.lisp
2009-11-18 pix
1
(in-package #:oh-ducks)
2009-11-13 pix
2
2009-11-13 pix
3
(defmethod unify ((a css-selector-template) (b css-selector-template)
2009-11-13 pix
4
&optional (env (make-empty-environment))
2010-01-02 pix
5
&key)
2009-11-18 pix
6
(declare (ignore env))
2009-11-13 pix
7
(error 'unification-failure
2009-11-13 pix
8
:format-control "Do not know how to unify the two css-selector-templates ~S and ~S."
2009-11-13 pix
9
:format-arguments (list a b)))
01:43:02 '
10
2009-11-13 pix
11
(defmethod unify ((template css-selector-template) document
2009-11-13 pix
12
&optional (env (make-empty-environment))
2010-01-02 pix
13
&key)
2009-11-21 pix
14
(declare (optimize debug))
2009-11-13 pix
15
(loop :for (css-specifier . template) :in (specifiers template)
2009-11-23 pix
16
:do (typecase template
10:24:02 '
17
;; CSS selectors work backwards, not forwards
'
18
(css-selector-template
'
19
(unify template document env))
'
20
(t
2009-12-05 pix
21
(let* ((*implicit-element* document)
07:18:05 '
22
;; FIXME: this is UGLY!
'
23
(val (cond
'
24
((terminating-implicit-sibling-combinator-p css-specifier)
'
25
;; search remaining siblings
2010-01-04 pix
26
(subjects-in-list
2009-12-05 pix
27
css-specifier
07:18:05 '
28
(rest
'
29
(member document
'
30
(when-let* ((parent (element-parent document)))
'
31
(element-children parent))
'
32
:test #'eq))))
'
33
;; search subelements
'
34
;;; FIXME: this assumes if someone passes us a node they want to find
'
35
;;; subelements of that node. In the case of nested matches, that's probably
'
36
;;; true, but it hardly seems fair to assume it. Really we want some sort of
'
37
;;; descendant combinator to be sure, but the general one (#\Space) doesn't
'
38
;;; exactly show up all that well. Somebody might assume " b" was the same as
'
39
;;; "b" and get confused.
2010-01-04 pix
40
((element-parent document)
2010-01-04 pix
41
(subjects-in-list css-specifier (element-children document)))
2009-12-05 pix
42
;; root element includes itself
2010-01-04 pix
43
(t (subjects-of css-specifier document)))))
2009-11-23 pix
44
(cond
2009-11-23 pix
45
((null val)
13:19:59 '
46
(error 'unification-failure
'
47
:format-control "Unable to unify ~s and ~s"
'
48
:format-arguments (list css-specifier template)))
2009-11-23 pix
49
((unify::template-p template)
10:24:02 '
50
(unify template val env))
'
51
((unify::variablep template)
'
52
(unify::var-unify template val env))
2009-12-03 pix
53
(t (error "Don't know what to do with selector ~s and template ~s." css-specifier template)))))))
2009-11-13 pix
54
env)
01:43:02 '
55
2009-11-18 pix
56
(defmethod unify (document (template css-selector-template)
2009-11-13 pix
57
&optional (env (make-empty-environment))
2010-01-02 pix
58
&key)
2009-11-18 pix
59
(unify template document env))
2009-11-16 pix
60
2009-11-18 pix
61
(defmethod unify ((template css-selector-template) (document string)
2009-11-16 pix
62
&optional (env (make-empty-environment))
2010-01-02 pix
63
&key)
2009-11-21 pix
64
(unify template (funcall (slot-value template 'parser) document) env))
2009-11-18 pix
65
08:57:44 '
66
(defmethod unify ((template css-selector-template) (document pathname)
'
67
&optional (env (make-empty-environment))
2010-01-02 pix
68
&key)
2009-11-21 pix
69
(unify template (funcall (slot-value template 'parser) document) env))