@@ 2,10 2,11 @@
module Graphics.Layout.CSS(CSSBox(..), BoxSizing(..), Display(..),
finalizeCSS, finalizeCSS') where
-import Data.CSS.Syntax.Tokens (Token(..))
+import Data.CSS.Syntax.Tokens (Token(..), NumericValue(..))
import qualified Data.Text as Txt
import Stylist (PropertyParser(..), TrivialPropertyParser)
import Stylist.Tree (StyleTree(..))
+import Data.Text.ParagraphLayout (PageOptions(..))
import Graphics.Layout.Box as B
import Graphics.Layout
@@ 25,7 26,8 @@ data CSSBox a = CSSBox {
gridStyles :: CSSGrid,
cellStyles :: CSSCell,
inlineStyles :: CSSInline,
- captionBelow :: Bool
+ captionBelow :: Bool,
+ pageOptions :: PageOptions
}
data BoxSizing = BorderBox | ContentBox
noborder = Border (0,"px") (0,"px") (0,"px") (0,"px")
@@ 54,7 56,8 @@ instance PropertyParser a => PropertyParser (CSSBox a) where
gridStyles = temp,
cellStyles = temp,
inlineStyles = temp,
- captionBelow = False
+ captionBelow = False,
+ pageOptions = PageOptions 0 0 2 2
}
inherit parent = CSSBox {
boxSizing = boxSizing parent,
@@ 66,7 69,8 @@ instance PropertyParser a => PropertyParser (CSSBox a) where
gridStyles = inherit $ gridStyles parent,
cellStyles = inherit $ cellStyles parent,
inlineStyles = inherit $ inlineStyles parent,
- captionBelow = captionBelow parent
+ captionBelow = captionBelow parent,
+ pageOptions = pageOptions parent
}
-- Wasn't sure how to implement in FontConfig-Pure
@@ 142,6 146,11 @@ instance PropertyParser a => PropertyParser (CSSBox a) where
longhand _ self "caption-side" [Ident "bottom"] = Just self { captionBelow = True }
longhand _ self "caption-side" [Ident "initial"] = Just self {captionBelow = False}
+ longhand _ self "orphans" [Number _ (NVInteger x)] =
+ Just self { pageOptions = (pageOptions self) { pageOrphans = fromInteger x } }
+ longhand _ self "widows" [Number _ (NVInteger x)] =
+ Just self { pageOptions = (pageOptions self) { pageWidows = fromInteger x } }
+
longhand a b c d | Just x <- longhand (font a) (font b) c d,
Just y <- longhand (font' a) (font' b) c d =
Just b { font = x, font' = y } -- Those properties can overlap!