some css fixes

This commit is contained in:
Adam D. Ruppe 2024-09-24 09:18:33 -04:00
parent 49dee2642b
commit 161d733196
1 changed files with 24 additions and 2 deletions

26
dom.d
View File

@ -7443,7 +7443,8 @@ int intFromHex(string hex) {
break;
default:
assert(0, token);
import arsd.core;
throw ArsdException!"CSS Selector Problem"(token, tokens, cast(int) state);
}
}
break;
@ -7493,6 +7494,9 @@ int intFromHex(string hex) {
case "root":
current.rootElement = true;
break;
case "lang":
state = State.SkippingFunctionalSelector;
continue;
case "nth-child":
current.nthChild ~= ParsedNth(readFunctionalSelector());
state = State.SkippingFunctionalSelector;
@ -7505,6 +7509,11 @@ int intFromHex(string hex) {
current.nthLastOfType ~= ParsedNth(readFunctionalSelector());
state = State.SkippingFunctionalSelector;
continue;
case "nth-last-child":
// FIXME
//current.nthLastOfType ~= ParsedNth(readFunctionalSelector());
state = State.SkippingFunctionalSelector;
continue;
case "is":
state = State.SkippingFunctionalSelector;
current.isSelectors ~= readFunctionalSelector();
@ -7706,6 +7715,7 @@ class CssStyle {
p.specificity = originatingSpecificity;
properties ~= p;
}
foreach(property; properties)
@ -7716,8 +7726,19 @@ class CssStyle {
Specificity getSpecificityOfRule(string rule) {
Specificity s;
if(rule.length == 0) { // inline
// s.important = 2;
s.important = 2;
} else {
// SO. WRONG.
foreach(ch; rule) {
if(ch == '.')
s.classes++;
if(ch == '#')
s.ids++;
if(ch == ' ')
s.tags++;
if(ch == ',')
break;
}
// FIXME
}
@ -7782,6 +7803,7 @@ class CssStyle {
if(newSpecificity.score >= property.specificity.score) {
property.givenExplicitly = explicit;
expandShortForm(property, newSpecificity);
property.specificity = newSpecificity;
return (property.value = value);
} else {
if(name == "display")