about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-01-07 01:28:58 +0100
committerbptato <nincsnevem662@gmail.com>2023-01-07 01:28:58 +0100
commit5c7e24f90e418e015d92113726b66d045e030e85 (patch)
tree0728a95919808148cecc5ff3fe26dce9b6c5275d /src/css
parent814814ee4cf11f442a2e08d004140462d398b72a (diff)
downloadchawan-5c7e24f90e418e015d92113726b66d045e030e85.tar.gz
css/cascade: remove scoped sheets
...in favor of handling all style elements like other browsers
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cascade.nim34
-rw-r--r--src/css/stylednode.nim2
2 files changed, 2 insertions, 34 deletions
diff --git a/src/css/cascade.nim b/src/css/cascade.nim
index 68b9ebee..c7d6dfd0 100644
--- a/src/css/cascade.nim
+++ b/src/css/cascade.nim
@@ -234,20 +234,15 @@ proc applyRules(document: Document, ua, user: CSSStylesheet, cachedTree: StyledN
     return
 
   var author: seq[CSSStylesheet]
+  for sheet in document.sheets():
+    author.add(sheet.applyMediaQuery())
 
-  var lenstack = newSeqOfCap[int](256)
   var styledStack: seq[CascadeLevel]
   styledStack.add((nil, document.html, PSEUDO_NONE, cachedTree))
 
   while styledStack.len > 0:
     var (styledParent, child, pseudo, cachedChild) = styledStack.pop()
 
-    # Remove stylesheets on nil
-    if pseudo == PSEUDO_NONE and child == nil:
-      let len = lenstack.pop()
-      author.setLen(author.len - len)
-      continue
-
     var styledChild: StyledNode
     let valid = cachedChild != nil and cachedChild.isValid()
     if valid:
@@ -370,31 +365,6 @@ proc applyRules(document: Document, ua, user: CSSStylesheet, cachedTree: StyledN
           styledStack.add((styledParent, nil, ps, nil))
 
       let elem = Element(styledChild.node)
-      if valid and result != styledChild:
-        styledChild.sheets = cachedChild.sheets
-      else:
-        if result == styledChild:
-          #TODO this is ugly. we should cache head sheets separately.
-          let head = document.head
-          if head != nil:
-            if head.invalid or cachedChild == nil:
-              let sheets = head.sheets()
-              for sheet in sheets:
-                styledChild.sheets.add(sheet.applyMediaQuery())
-            else:
-              styledChild.sheets = cachedChild.sheets
-        else:
-          let sheets = elem.sheets()
-          if sheets.len > 0:
-            for sheet in sheets:
-              styledChild.sheets.add(sheet.applyMediaQuery())
-      if styledChild.sheets.len > 0:
-        for sheet in styledChild.sheets:
-          author.add(sheet)
-        lenstack.add(styledChild.sheets.len)
-        # Add a nil before the last element (in-stack), so we know when to
-        # remove inline author sheets.
-        styledStack.add((nil, nil, PSEUDO_NONE, nil))
 
       stack_append styledChild, PSEUDO_AFTER
 
diff --git a/src/css/stylednode.nim b/src/css/stylednode.nim
index 30358b29..c18c8779 100644
--- a/src/css/stylednode.nim
+++ b/src/css/stylednode.nim
@@ -1,5 +1,4 @@
 import css/selectorparser
-import css/sheet
 import css/values
 import html/dom
 import html/tags
@@ -60,7 +59,6 @@ type
       computed*: CSSComputedValues
       children*: seq[StyledNode]
       depends*: DependencyInfo
-      sheets*: seq[CSSStylesheet]
     of STYLED_REPLACEMENT: # replaced elements: quotes, or (TODO) markers, images
       content*: CSSContent