about summary refs log tree commit diff stats
path: root/src/css/layout.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/css/layout.nim')
-rw-r--r--src/css/layout.nim29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index e535b2b7..76c36b93 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -230,8 +230,6 @@ type
   LineBoxState = object
     atomStates: seq[InlineAtomState]
     baseline: LayoutUnit
-    paddingTop: LayoutUnit
-    paddingBottom: LayoutUnit
     hasExclusion: bool
     charwidth: int
     # Set at the end of layoutText. It helps determine the beginning of the
@@ -330,14 +328,6 @@ func computeShift(ictx: InlineContext; state: InlineState): LayoutUnit =
       return 0
   return ictx.cellWidth * ictx.whitespacenum
 
-proc applyLineHeight(ictx: InlineContext; state: var LineBoxState;
-    computed: CSSComputedValues) =
-  let lctx = ictx.lctx
-  let paddingTop = computed{"padding-top"}.px(lctx, ictx.space.w)
-  let paddingBottom = computed{"padding-bottom"}.px(lctx, ictx.space.w)
-  state.paddingTop = max(paddingTop, state.paddingTop)
-  state.paddingBottom = max(paddingBottom, state.paddingBottom)
-
 proc newWord(ictx: var InlineContext) =
   ictx.word = InlineAtom(
     t: iatWord,
@@ -443,7 +433,7 @@ func getLineXShift(ictx: InlineContext; width: LayoutUnit): LayoutUnit =
 
 proc shiftAtoms(ictx: var InlineContext; marginTop: LayoutUnit) =
   let offsety = ictx.lbstate.offsety
-  let shiftTop = marginTop + ictx.lbstate.paddingTop
+  let shiftTop = marginTop
   let cellHeight = ictx.cellHeight
   let width = ictx.getLineWidth()
   let xshift = ictx.getLineXShift(width)
@@ -517,7 +507,6 @@ proc alignLine(ictx: var InlineContext) =
   ictx.lbstate.size.h = ictx.lbstate.resizeLine(ictx.lctx)
   # Now we can calculate the actual position of atoms inside the line.
   let marginTop = ictx.lbstate.positionAtoms(ictx.lctx)
-  ictx.lbstate.baseline += ictx.lbstate.paddingTop
   # Finally, offset all atoms' y position by the largest top margin and the
   # line box's top padding.
   ictx.shiftAtoms(marginTop)
@@ -649,11 +638,6 @@ func shouldWrap2(ictx: InlineContext; w: LayoutUnit): bool =
     return false
   return ictx.lbstate.size.w + w > ictx.lbstate.availableWidth
 
-# Start a new line, even if the previous one is empty
-proc flushLine(ictx: var InlineContext; state: var InlineState) =
-  ictx.applyLineHeight(ictx.lbstate, state.fragment.computed)
-  ictx.finishLine(state, wrap = false, force = true)
-
 func getBaseline(ictx: InlineContext; iastate: InlineAtomState;
     atom: InlineAtom): LayoutUnit =
   return case iastate.vertalign.keyword
@@ -677,14 +661,13 @@ proc addAtom(ictx: var InlineContext; state: var InlineState;
   ictx.whitespacenum = 0
   # Line wrapping
   if ictx.shouldWrap(atom.size.w + shift, state.fragment.computed):
-    ictx.finishLine(state, wrap = true, force = false)
+    ictx.finishLine(state, wrap = true)
     result = true
     # Recompute on newline
     shift = ictx.computeShift(state)
     # For floats: flush lines until we can place the atom.
     #TODO this is inefficient
     while ictx.shouldWrap2(atom.size.w + shift):
-      ictx.applyLineHeight(ictx.lbstate, state.fragment.computed)
       ictx.finishLine(state, wrap = false, force = true)
       # Recompute on newline
       shift = ictx.computeShift(state)
@@ -692,7 +675,6 @@ proc addAtom(ictx: var InlineContext; state: var InlineState;
     if shift > 0:
       ictx.addSpacing(shift, state)
     ictx.state.xminwidth = max(ictx.state.xminwidth, atom.xminwidth)
-    ictx.applyLineHeight(ictx.lbstate, state.fragment.computed)
     if atom.t == iatWord:
       if ictx.lbstate.atoms.len > 0 and state.fragment.state.atoms.len > 0:
         let oatom = ictx.lbstate.atoms[^1]
@@ -783,7 +765,7 @@ proc processWhitespace(ictx: var InlineContext; state: var InlineState;
       ictx.whitespaceIsLF = false
   of WhitespacePreLine:
     if c == '\n':
-      ictx.flushLine(state)
+      ictx.finishLine(state, wrap = false, force = true)
     elif ictx.whitespacenum < 1:
       ictx.whitespaceIsLF = false
       ictx.whitespacenum = 1
@@ -791,7 +773,7 @@ proc processWhitespace(ictx: var InlineContext; state: var InlineState;
   of WhitespacePre, WhitespacePreWrap:
     ictx.whitespaceIsLF = false
     if c == '\n':
-      ictx.flushLine(state)
+      ictx.finishLine(state, wrap = false, force = true)
     elif c == '\t':
       let realWidth = ictx.lbstate.charwidth + ictx.whitespacenum
       # We must flush first, because addWord would otherwise try to wrap the
@@ -1665,9 +1647,8 @@ proc layoutInline(ictx: var InlineContext; fragment: InlineFragment) =
   if stSplitStart in fragment.splitType and
       computed{"position"} notin PositionStaticLike:
     lctx.pushPositioned()
-  ictx.applyLineHeight(ictx.lbstate, computed)
   case fragment.t
-  of iftNewline: ictx.flushLine(state)
+  of iftNewline: ictx.finishLine(state, wrap = false, force = true)
   of iftBox: ictx.addBox(state, fragment.box)
   of iftBitmap: ictx.addInlineImage(state, fragment.bmp, padding.sum())
   of iftText: ictx.layoutText(state, fragment.text.textData)
ity.nim?h=devel&id=4b0b536419a500dc2e5a987ed9c2a374e0848008'>4b0b53641 ^
4780b08b9 ^
4b0b53641 ^
4780b08b9 ^

e081f565c ^

02be027e9 ^
4780b08b9 ^








4b0b53641 ^
4780b08b9 ^




3f1de49e2 ^

4780b08b9 ^




3f1de49e2 ^
4b0b53641 ^
4780b08b9 ^

3f1de49e2 ^
4b0b53641 ^
4780b08b9 ^













30cf33f04 ^
4780b08b9 ^
30cf33f04 ^

4780b08b9 ^



02be027e9 ^
4780b08b9 ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155