boxes

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package boxes defines the basic elements of the formatting structure, as a tree of boxes.

This tree is build from an HTML document by this package, but the boxes are not correctly positionned yet (see the layout package).

Index

Constants

This section is empty.

Variables

View Source
var (
	TableFirstLetter = []*unicode.RangeTable{unicode.Ps, unicode.Pe, unicode.Pi, unicode.Pf, unicode.Po}
)

Functions

func HitArea

func HitArea(box Box) pr.Rectangle

HitArea returns the rectangle where the box is clickable.

func IsInput added in v0.0.3

func IsInput(box Box) bool

Return whether this box is a form input.

func ProcessTextTransform

func ProcessTextTransform(box Box)

func ProcessWhitespace

func ProcessWhitespace(box Box, followingCollapsibleSpace bool) bool

ProcessWhitespace executes the first part of "The 'white-space' processing model". See https://www.w3.org/TR/CSS21/text.html#white-space-model and https://drafts.csswg.org/css-text-3/#white-space-rules The default value of followingCollapsibleSpace shoud be `false`.

func SerializedBoxEquals

func SerializedBoxEquals(l1, l2 []SerBox) bool

func UpdateCounters

func UpdateCounters(state *tree.PageState, style pr.ElementStyle)

Handle the “counter-*“ properties.

Types

type Area

type Area struct {
	String string
	Rect   pr.Rectangle
}

type AtomicInlineLevelBoxITF

type AtomicInlineLevelBoxITF interface {
	InlineLevelBoxITF
	// contains filtered or unexported methods
}

An atomic box in an inline formatting context. This inline-level box cannot be split for line breaks.

type BC

type BC struct {
	Text string
	C    []SerBox
}

type Background

type Background struct {
	ImageRendering pr.String
	Layers         []BackgroundLayer
	Color          parser.RGBA
}

type BackgroundLayer

type BackgroundLayer struct {
	Image           images.Image
	Position        Position
	Repeat          Repeat
	ClippedBoxes    []RoundedBox
	PaintingArea    pr.Rectangle
	PositioningArea pr.Rectangle
	Size            [2]pr.Float // width, height
	Unbounded       bool
}

type BlockBox

type BlockBox struct {
	BlockLevelBox
	BoxFields
}

func BlockBoxAnonymousFrom

func BlockBoxAnonymousFrom(parent Box, children []Box) *BlockBox

func NewBlockBox

func NewBlockBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *BlockBox

func (*BlockBox) Box

func (b *BlockBox) Box() *BoxFields

func (BlockBox) Copy

func (b BlockBox) Copy() Box

func (BlockBox) IsClassicalBox

func (BlockBox) IsClassicalBox() bool

func (BlockBox) Type

func (BlockBox) Type() BoxType

type BlockBoxITF

type BlockBoxITF interface {
	BlockContainerBoxITF
	BlockLevelBoxITF
	// contains filtered or unexported methods
}

A block-level box that is also a block container. A non-replaced element with a “display“ value of “block“, “list-item“ generates a block box.

type BlockContainerBoxITF

type BlockContainerBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

A box that contains only block-level boxes or only line boxes. A box that either contains only block-level boxes or establishes an inline formatting context and thus contains only line boxes. A non-replaced element with a “display“ value of “block“, “list-item“, “inline-block“ or 'table-cell' generates a block container box.

type BlockLevelBox

type BlockLevelBox struct {
	Clearance pr.MaybeFloat
}

func (*BlockLevelBox) BlockLevel

func (b *BlockLevelBox) BlockLevel() *BlockLevelBox

type BlockLevelBoxITF

type BlockLevelBoxITF interface {
	BoxITF
	// contains filtered or unexported methods
}

A box that participates in an block formatting context. An element with a “display“ value of “block“, “list-item“ or “table“ generates a block-level box.

func BuildFormattingStructure

func BuildFormattingStructure(elementTree *utils.HTMLNode, styleFor *tree.StyleFor, resolver URLResolver,
	baseUrl string, targetCollector *tree.TargetCollector, cs counters.CounterStyle, footnotes *[]Box,
) BlockLevelBoxITF

Build a formatting structure (box tree) from an element tree.

type BlockReplacedBox

type BlockReplacedBox struct {
	BlockLevelBox
	ReplacedBox
}

func NewBlockReplacedBox

func NewBlockReplacedBox(style pr.ElementStyle, element *html.Node, pseudoType string, replacement images.Image) BlockReplacedBox

func (*BlockReplacedBox) Box

func (b *BlockReplacedBox) Box() *BoxFields

func (BlockReplacedBox) Copy

func (b BlockReplacedBox) Copy() Box

func (BlockReplacedBox) IsClassicalBox

func (BlockReplacedBox) IsClassicalBox() bool

func (BlockReplacedBox) Type

func (BlockReplacedBox) Type() BoxType

type BlockReplacedBoxITF

type BlockReplacedBoxITF interface {
	BlockLevelBoxITF
	ReplacedBoxITF
	// contains filtered or unexported methods
}

A box that is both replaced and block-level. A replaced element with a “display“ value of “block“, “liste-item“ or “table“ generates a block-level replaced box.

type Border

type Border struct {
	Style pr.String
	Score Score
	Width utils.Fl
	Color pr.Color
}

type BorderGrids

type BorderGrids struct {
	Vertical, Horizontal [][]Border
}

type Box

type Box interface {
	// IsClassicalBox returns true for all standard boxes defined in this package, but false
	// for the special ones, defined in other packages, like AbsolutePlaceholder or StackingContext.
	IsClassicalBox() bool

	tree.Box

	Type() BoxType

	Box() *BoxFields
	Copy() Box
	AllChildren() []Box
	Translate(box Box, dx, dy pr.Float, ignoreFloats bool)
	RemoveDecoration(box *BoxFields, isStart, isEnd bool)
	PageValues() (pr.Page, pr.Page)
}

Box is the common interface grouping all possible boxes

func AnonymousTableBoxes

func AnonymousTableBoxes(box Box) Box

Remove and add boxes according to the table model.

Take and return a “Box“ object.

See https://www.w3.org/TR/CSS21/tables.html#anonymous-boxes

func BlockInInline

func BlockInInline(box Box) Box

Build the structure of blocks inside lines.

Inline boxes containing block-level boxes will be broken in two boxes on each side on consecutive block-level boxes, each side wrapped in an anonymous block-level box.

This is the second case in https://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level

Eg. if this is given::

    BlockBox[
        LineBox[
            InlineBox[
                TextBox["Hello."],
            ],
            InlineBox[
                TextBox["Some "],
                InlineBox[
                    TextBox["text"]
                    BlockBox[LineBox[TextBox["More text"]]],
                    BlockBox[LineBox[TextBox["More text again"]]],
                ],
                BlockBox[LineBox[TextBox["And again."]]],
            ]
        ]
    ]

this is returned::

    BlockBox[
        AnonymousBlockBox[
            LineBox[
                InlineBox[
                    TextBox["Hello."],
                ],
                InlineBox[
                    TextBox["Some "],
                    InlineBox[TextBox["text"]],
                ]
            ]
        ],
        BlockBox[LineBox[TextBox["More text"]]],
        BlockBox[LineBox[TextBox["More text again"]]],
        AnonymousBlockBox[
            LineBox[
                InlineBox[
                ]
            ]
        ],
        BlockBox[LineBox[TextBox["And again."]]],
        AnonymousBlockBox[
            LineBox[
                InlineBox[
                ]
            ]
        ],
    ]

func ContentToBoxes

func ContentToBoxes(style pr.ElementStyle, parentBox Box, quoteDepth []int, counterValues tree.CounterValues,
	resolver URLResolver, targetCollector *tree.TargetCollector, cs counters.CounterStyle, context Context, page Box,
) []Box

Takes the value of a “content“ property and yield boxes.

func CopyWithChildren

func CopyWithChildren(box Box, newChildren []Box) Box

Create a new equivalent box with given “newChildren“."""

func CreateAnonymousBox added in v0.0.2

func CreateAnonymousBox(box Box) Box

CreateAnonymousBox create anonymous boxes in box descendants according to layout rules.

func Deepcopy added in v0.0.2

func Deepcopy(b Box) Box

Returns a deep copy of `b`, copying b and its descendants.

func Descendants

func Descendants(b Box) []Box

Descendants returns `b` and its children, and their children, etc...

func FlexBoxes

func FlexBoxes(box Box) Box

Remove and add boxes according to the flex model. See https://www.w3.org/TR/css-flexbox-1/#flex-items

func InlineInBlock

func InlineInBlock(box Box) Box

Build the structure of lines inside blocks and return a new box tree.

Consecutive inline-level boxes in a block container box are wrapped into a line box, itself wrapped into an anonymous block box.

This line box will be broken into multiple lines later.

This is the first case in https://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level

Example:

BlockBox[
    TextBox["Some "],
    InlineBox[TextBox["text"]],
    BlockBox[
        TextBox["More text"],
    ]
]

is turned into::

BlockBox[
    AnonymousBlockBox[
        LineBox[
            TextBox["Some "],
            InlineBox[TextBox["text"]],
        ]
    ]
    BlockBox[
        LineBox[
            TextBox["More text"],
        ]
    ]
]

func LineBoxAnonymousFrom

func LineBoxAnonymousFrom(parent Box, children []Box) Box

type BoxFields

type BoxFields struct {
	// Original html node, needed for post-processing.
	// May be nil, like for PageBox and MarginBox
	Element    *html.Node
	PseudoType string

	// Keep track of removed collapsing spaces for wrap opportunities.
	LeadingCollapsibleSpace  bool
	TrailingCollapsibleSpace bool

	// Default, may be overriden on instances.
	IsTableWrapper   bool
	IsFlexItem       bool
	IsForRootElement bool
	IsColumn         bool
	IsLeader         bool

	BookmarkLabel string

	StringSet pr.ContentProperties

	Style pr.ElementStyle

	FirstLetterStyle pr.ElementStyle

	PositionX, PositionY                                    pr.Float
	Width, Height, MinWidth, MaxWidth, MinHeight, MaxHeight pr.MaybeFloat
	Top, Bottom, Left, Right                                pr.MaybeFloat
	MarginTop, MarginBottom, MarginLeft, MarginRight        pr.MaybeFloat
	PaddingTop, PaddingBottom, PaddingLeft, PaddingRight    pr.MaybeFloat

	BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth pr.Float

	BorderTopLeftRadius, BorderTopRightRadius, BorderBottomRightRadius, BorderBottomLeftRadius Point

	ViewportOverflow string

	Children []Box

	Footnote Box

	IsHeader, IsFooter bool

	Baseline       pr.MaybeFloat
	ComputedHeight pr.MaybeFloat
	ContentHeight  pr.Float
	VerticalAlign  string

	// For table cells, [true] when no children is either floated or in normal flow
	Empty bool

	Colspan int
	Rowspan int

	GridX int
	Index int

	FlexBasis                                                      pr.Value
	FlexBaseSize, TargetMainSize, Adjustment, HypotheticalMainSize pr.Float
	FlexFactor, ScaledFlexShrinkFactor                             pr.Float
	Frozen                                                         bool

	GetCells func() []Box // closure which may have default implementation or be set

	Background *Background

	RemoveDecorationSides [4]bool
	// contains filtered or unexported fields
}

BoxFields is an abstract base class for all boxes.

func (*BoxFields) AllChildren

func (box *BoxFields) AllChildren() []Box

func (*BoxFields) BorderBoxX

func (b *BoxFields) BorderBoxX() pr.Float

Absolute horizontal position of the border box.

func (*BoxFields) BorderBoxY

func (b *BoxFields) BorderBoxY() pr.Float

Absolute vertical position of the border box.

func (*BoxFields) BorderHeight

func (b *BoxFields) BorderHeight() pr.Float

Height of the border box.

func (*BoxFields) BorderWidth

func (b *BoxFields) BorderWidth() pr.Float

Width of the border box.

func (*BoxFields) CachedCounterValues

func (box *BoxFields) CachedCounterValues() tree.CounterValues

func (*BoxFields) ContainingBlock

func (box *BoxFields) ContainingBlock() (width, height pr.MaybeFloat)

ContainingBlock implements an interface required for layout.

func (*BoxFields) ContentBoxX

func (b *BoxFields) ContentBoxX() pr.Float

Absolute horizontal position of the content box.

func (*BoxFields) ContentBoxY

func (b *BoxFields) ContentBoxY() pr.Float

Absolute vertical position of the content box.

func (*BoxFields) ElementTag

func (box *BoxFields) ElementTag() string

ElementTag returns the html tag name of the element and an optionnal pseudo type (in the form tag::pseudoType)

func (*BoxFields) GetBookmarkLabel

func (box *BoxFields) GetBookmarkLabel() string

func (*BoxFields) GetWrappedTable

func (box *BoxFields) GetWrappedTable() TableBoxITF

func (*BoxFields) IsAbsolutelyPositioned

func (b *BoxFields) IsAbsolutelyPositioned() bool

Return whether this box is in the absolute positioning scheme.

func (*BoxFields) IsAttachment

func (box *BoxFields) IsAttachment() bool

Return whether this link should be stored as a PDF attachment

func (*BoxFields) IsFloated

func (b *BoxFields) IsFloated() bool

Return whether this box is floated.

func (*BoxFields) IsFootnote added in v0.0.2

func (b *BoxFields) IsFootnote() bool

Return whether this box is a footnote.

func (*BoxFields) IsInNormalFlow

func (b *BoxFields) IsInNormalFlow() bool

Return whether this box is in normal flow.

func (*BoxFields) IsRunning

func (b *BoxFields) IsRunning() bool

Return whether this box is a running element.

func (*BoxFields) MarginHeight

func (b *BoxFields) MarginHeight() pr.Float

Height of the margin box (aka. outer box).

func (*BoxFields) MarginWidth

func (b *BoxFields) MarginWidth() pr.Float

Width of the margin box (aka. outer box).

func (box *BoxFields) MissingLink() tree.Box

func (*BoxFields) PaddingBoxX

func (b *BoxFields) PaddingBoxX() pr.Float

Absolute horizontal position of the padding box.

func (*BoxFields) PaddingBoxY

func (b *BoxFields) PaddingBoxY() pr.Float

Absolute vertical position of the padding box.

func (*BoxFields) PaddingHeight

func (b *BoxFields) PaddingHeight() pr.Float

Height of the padding box.

func (*BoxFields) PaddingWidth

func (b *BoxFields) PaddingWidth() pr.Float

Width of the padding box.

func (*BoxFields) PageValues

func (b *BoxFields) PageValues() (pr.Page, pr.Page)

Return start and end page values.

func (*BoxFields) RemoveDecoration

func (*BoxFields) RemoveDecoration(box *BoxFields, start, end bool)

func (*BoxFields) ResetSpacing

func (b *BoxFields) ResetSpacing(side Side)

Set to 0 the margin, padding and border of “side“.

func (*BoxFields) RoundedBorderBox

func (b *BoxFields) RoundedBorderBox() RoundedBox

Return the position, size and radii of the rounded border box.

func (*BoxFields) RoundedBoxRatio

func (b *BoxFields) RoundedBoxRatio(ratio pr.Float) RoundedBox

func (*BoxFields) RoundedContentBox

func (b *BoxFields) RoundedContentBox() RoundedBox

Return the position, size and radii of the rounded content box.

func (*BoxFields) RoundedPaddingBox

func (b *BoxFields) RoundedPaddingBox() RoundedBox

Return the position, size and radii of the rounded padding box.

func (*BoxFields) SetCachedCounterValues

func (box *BoxFields) SetCachedCounterValues(cv tree.CounterValues)
func (box *BoxFields) SetMissingLink(b tree.Box)

func (BoxFields) Translate

func (BoxFields) Translate(box Box, dx, dy pr.Float, ignoreFloats bool)

Translate changes the box’s position. Also update the children’s positions accordingly.

type BoxITF

type BoxITF = Box

type BoxType

type BoxType uint8

BoxType represents a box type.

const (
	AtomicInlineLevelT BoxType
	BlockT
	BlockContainerT
	BlockLevelT
	BlockReplacedT
	T
	FlexT
	FlexContainerT
	FootnoteAreaT
	InlineBlockT
	InlineT
	InlineFlexT
	InlineLevelT
	InlineReplacedT
	InlineTableT
	LineT
	MarginT
	PageT
	ParentT
	ReplacedT
	TableT
	TableCaptionT
	TableCellT
	TableColumnT
	TableColumnGroupT
	TableRowT
	TableRowGroupT
	TextT
)

func (BoxType) AnonymousFrom

func (t BoxType) AnonymousFrom(parent Box, children []Box) Box

func (BoxType) IsInProperParents

func (t BoxType) IsInProperParents(type_ BoxType) bool

IsInProperParents returns true if `t` is one of the the proper parents of `type_`

func (BoxType) IsInstance

func (t BoxType) IsInstance(box BoxITF) bool

Returns true is the box is an instance of t.

func (BoxType) String

func (t BoxType) String() string

type Context

type Context interface {
	// RunningElements() map[string]map[int]Box
	CurrentPage() int
	GetStringSetFor(page Box, name, keyword string) string
	GetRunningElementFor(page Box, name, keyword string) Box
}

type FlexBox

type FlexBox struct {
	BlockLevelBox
	BoxFields
}

func FlexBoxAnonymousFrom

func FlexBoxAnonymousFrom(parent Box, children []Box) *FlexBox

func NewFlexBox

func NewFlexBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *FlexBox

func (*FlexBox) Box

func (b *FlexBox) Box() *BoxFields

func (FlexBox) Copy

func (b FlexBox) Copy() Box

func (FlexBox) IsClassicalBox

func (FlexBox) IsClassicalBox() bool

func (FlexBox) Type

func (FlexBox) Type() BoxType

type FlexBoxITF

type FlexBoxITF interface {
	BlockLevelBoxITF
	FlexContainerBoxITF
	// contains filtered or unexported methods
}

A box that is both block-level and a flex container. It behaves as block on the outside and as a flex container on the inside.

type FlexContainerBoxITF

type FlexContainerBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

A box that contains only flex-items.

type FootnoteAreaBox added in v0.0.2

type FootnoteAreaBox struct {
	BlockBox
	Page *PageBox
}

Box displaying footnotes, as defined in GCPM.

func NewFootnoteAreaBox added in v0.0.2

func NewFootnoteAreaBox(page *PageBox, style pr.ElementStyle) *FootnoteAreaBox

func (*FootnoteAreaBox) Box added in v0.0.2

func (b *FootnoteAreaBox) Box() *BoxFields

func (FootnoteAreaBox) Copy added in v0.0.2

func (b FootnoteAreaBox) Copy() Box

func (FootnoteAreaBox) IsClassicalBox added in v0.0.2

func (FootnoteAreaBox) IsClassicalBox() bool

func (FootnoteAreaBox) Type added in v0.0.2

func (FootnoteAreaBox) Type() BoxType

type FootnoteAreaBoxITF added in v0.0.2

type FootnoteAreaBoxITF interface {
	BlockBoxITF
	// contains filtered or unexported methods
}

Box displaying footnotes, as defined in GCPM.

type Gifu

type Gifu = func(url, forcedMimeType string, orientation pr.SBoolFloat) images.Image

type InlineBlockBox

type InlineBlockBox struct {
	BoxFields
}

func InlineBlockBoxAnonymousFrom

func InlineBlockBoxAnonymousFrom(parent Box, children []Box) *InlineBlockBox

func NewInlineBlockBox

func NewInlineBlockBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *InlineBlockBox

func (*InlineBlockBox) Box

func (b *InlineBlockBox) Box() *BoxFields

func (InlineBlockBox) Copy

func (b InlineBlockBox) Copy() Box

func (InlineBlockBox) IsClassicalBox

func (InlineBlockBox) IsClassicalBox() bool

func (InlineBlockBox) Type

func (InlineBlockBox) Type() BoxType

type InlineBlockBoxITF

type InlineBlockBoxITF interface {
	AtomicInlineLevelBoxITF
	BlockContainerBoxITF
	// contains filtered or unexported methods
}

A box that is both inline-level and a block container. It behaves as inline on the outside and as a block on the inside. A non-replaced element with a 'display' value of 'inline-block' generates an inline-block box.

type InlineBox

type InlineBox struct {
	InlineLevelBox
	BoxFields
}

func InlineBoxAnonymousFrom

func InlineBoxAnonymousFrom(parent Box, children []Box) *InlineBox

func NewInlineBox

func NewInlineBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *InlineBox

func (*InlineBox) Box

func (b *InlineBox) Box() *BoxFields

func (InlineBox) Copy

func (b InlineBox) Copy() Box

func (InlineBox) IsClassicalBox

func (InlineBox) IsClassicalBox() bool

func (InlineBox) RemoveDecoration

func (u InlineBox) RemoveDecoration(b *BoxFields, start, end bool)

func (InlineBox) Type

func (InlineBox) Type() BoxType

type InlineBoxITF

type InlineBoxITF interface {
	InlineLevelBoxITF
	ParentBoxITF
	// contains filtered or unexported methods
}

An inline box with inline children. A box that participates in an inline formatting context and whose content also participates in that inline formatting context. A non-replaced element with a “display“ value of “inline“ generates an inline box.

type InlineFlexBox

type InlineFlexBox struct {
	InlineLevelBox
	BoxFields
}

func InlineFlexBoxAnonymousFrom

func InlineFlexBoxAnonymousFrom(parent Box, children []Box) *InlineFlexBox

func NewInlineFlexBox

func NewInlineFlexBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *InlineFlexBox

func (*InlineFlexBox) Box

func (b *InlineFlexBox) Box() *BoxFields

func (InlineFlexBox) Copy

func (b InlineFlexBox) Copy() Box

func (InlineFlexBox) IsClassicalBox

func (InlineFlexBox) IsClassicalBox() bool

func (InlineFlexBox) RemoveDecoration

func (u InlineFlexBox) RemoveDecoration(b *BoxFields, start, end bool)

func (InlineFlexBox) Type

func (InlineFlexBox) Type() BoxType

type InlineFlexBoxITF

type InlineFlexBoxITF interface {
	FlexContainerBoxITF
	InlineLevelBoxITF
	// contains filtered or unexported methods
}

A box that is both inline-level and a flex container. It behaves as inline on the outside and as a flex container on the inside.

type InlineLevelBox

type InlineLevelBox struct{}

func (*InlineLevelBox) RemoveDecoration

func (*InlineLevelBox) RemoveDecoration(box *BoxFields, start, end bool)

type InlineLevelBoxITF

type InlineLevelBoxITF interface {
	BoxITF
	// contains filtered or unexported methods
}

A box that participates in an inline formatting context. An inline-level box that is not an inline box is said to be "atomic". Such boxes are inline blocks, replaced elements and inline tables. An element with a “display“ value of “inline“, “inline-table“, or “inline-block“ generates an inline-level box.

type InlineReplacedBox

type InlineReplacedBox struct {
	ReplacedBox
}

func InlineReplacedBoxAnonymousFrom

func InlineReplacedBoxAnonymousFrom(parent Box, replacement images.Image) *InlineReplacedBox

func NewInlineReplacedBox

func NewInlineReplacedBox(style pr.ElementStyle, element *html.Node, pseudoType string, replacement images.Image) InlineReplacedBox

func (*InlineReplacedBox) Box

func (b *InlineReplacedBox) Box() *BoxFields

func (InlineReplacedBox) Copy

func (b InlineReplacedBox) Copy() Box

func (InlineReplacedBox) IsClassicalBox

func (InlineReplacedBox) IsClassicalBox() bool

func (InlineReplacedBox) RemoveDecoration

func (u InlineReplacedBox) RemoveDecoration(b *BoxFields, start, end bool)

func (InlineReplacedBox) Type

func (InlineReplacedBox) Type() BoxType

type InlineReplacedBoxITF

type InlineReplacedBoxITF interface {
	AtomicInlineLevelBoxITF
	ReplacedBoxITF
	// contains filtered or unexported methods
}

A box that is both replaced and inline-level. A replaced element with a “display“ value of “inline“, “inline-table“, or “inline-block“ generates an inline-level replaced box.

type InlineTableBox

type InlineTableBox struct {
	TableBox
}

func InlineTableBoxAnonymousFrom

func InlineTableBoxAnonymousFrom(parent Box, children []Box) *InlineTableBox

func NewInlineTableBox

func NewInlineTableBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *InlineTableBox

func (*InlineTableBox) Box

func (b *InlineTableBox) Box() *BoxFields

func (InlineTableBox) Copy

func (b InlineTableBox) Copy() Box

func (InlineTableBox) IsClassicalBox

func (InlineTableBox) IsClassicalBox() bool

func (InlineTableBox) Type

func (InlineTableBox) Type() BoxType

type InlineTableBoxITF

type InlineTableBoxITF interface {
	TableBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: inline-table“

type LineBox

type LineBox struct {
	BoxFields

	ResumeAt      tree.ResumeStack
	TextIndent    pr.MaybeFloat
	TextOverflow  string
	BlockEllipsis pr.TaggedString
}

func NewLineBox

func NewLineBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) LineBox

func (*LineBox) Box

func (b *LineBox) Box() *BoxFields

func (LineBox) Copy

func (b LineBox) Copy() Box

func (LineBox) IsClassicalBox

func (LineBox) IsClassicalBox() bool

func (LineBox) Type

func (LineBox) Type() BoxType

type LineBoxITF

type LineBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

A box that represents a line in an inline formatting context. Can only contain inline-level boxes. In early stages of building the box tree a single line box contains many consecutive inline boxes. Later, during layout phase, each line boxes will be split into multiple line boxes, one for each actual line.

type MarginBox

type MarginBox struct {
	BoxFields
	AtKeyword   string
	IsGenerated bool
}

func NewMarginBox

func NewMarginBox(atKeyword string, style pr.ElementStyle) *MarginBox

func (*MarginBox) Box

func (b *MarginBox) Box() *BoxFields

func (MarginBox) Copy

func (b MarginBox) Copy() Box

func (MarginBox) IsClassicalBox

func (MarginBox) IsClassicalBox() bool

func (*MarginBox) String

func (b *MarginBox) String() string

func (MarginBox) Type

func (MarginBox) Type() BoxType

type MarginBoxITF

type MarginBoxITF interface {
	BlockContainerBoxITF
	// contains filtered or unexported methods
}

Box in page margins, as defined in CSS3 Paged Media

type MaybePoint

type MaybePoint [2]pr.MaybeFloat

func (MaybePoint) V

func (mp MaybePoint) V() Point

type PageBox

type PageBox struct {
	BoxFields
	CanvasBackground *Background
	FixedBoxes       []Box
	PageType         utils.PageElement
}

func NewPageBox

func NewPageBox(pageType utils.PageElement, style pr.ElementStyle) *PageBox

func (*PageBox) Box

func (b *PageBox) Box() *BoxFields

func (PageBox) Copy

func (b PageBox) Copy() Box

func (PageBox) IsClassicalBox

func (PageBox) IsClassicalBox() bool

func (*PageBox) String

func (b *PageBox) String() string

func (PageBox) Type

func (PageBox) Type() BoxType

type PageBoxITF

type PageBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for a page. Initially the whole document will be in the box for the root element. During layout a new page box is created after every page break.

type ParentBoxITF

type ParentBoxITF interface {
	BoxITF
	// contains filtered or unexported methods
}

A box that has children.

type Point

type Point [2]pr.Float

type Position

type Position struct {
	Point  MaybePoint
	String string
}

type Repeat

type Repeat struct {
	String string
	Reps   [2]string
}

type ReplacedBox

type ReplacedBox struct {
	Replacement images.Image
	BoxFields
}

func NewReplacedBox

func NewReplacedBox(style pr.ElementStyle, element *html.Node, pseudoType string, replacement images.Image) ReplacedBox

func (*ReplacedBox) Box

func (b *ReplacedBox) Box() *BoxFields

func (ReplacedBox) Copy

func (b ReplacedBox) Copy() Box

func (ReplacedBox) IsClassicalBox

func (ReplacedBox) IsClassicalBox() bool

func (*ReplacedBox) Replaced

func (b *ReplacedBox) Replaced() *ReplacedBox

func (ReplacedBox) Type

func (ReplacedBox) Type() BoxType

type ReplacedBoxITF

type ReplacedBoxITF interface {
	BoxITF
	// contains filtered or unexported methods
}

A box whose content is replaced. For example, “<img>“ are replaced: their content is rendered externally and is opaque from CSS’s point of view.

type RoundedBox

type RoundedBox struct {
	X, Y, Width, Height                        pr.Float
	TopLeft, TopRight, BottomRight, BottomLeft Point
}

type Score

type Score [3]float64

func (Score) Lower

func (s Score) Lower(other Score) bool

type SerBox

type SerBox struct {
	Tag     string
	Type    BoxType
	Content BC
}

func Serialize

func Serialize(boxList []Box) []SerBox

Transform a box list into a structure easier to compare for testing.

type Side

type Side uint8
const (
	SLeft Side = iota
	SRight
	STop
	SBottom
)

func (Side) String

func (s Side) String() string

type TableBox

type TableBox struct {
	BoxFields
	BlockLevelBox

	ColumnWidths, ColumnPositions           []pr.Float
	ColumnGroups                            []*TableColumnGroupBox
	CollapsedBorderGrid                     BorderGrids
	SkippedRows                             int
	SkipCellBorderTop, SkipCellBorderBottom bool
}

func NewTableBox

func NewTableBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableBox

func TableBoxAnonymousFrom

func TableBoxAnonymousFrom(parent Box, children []Box) *TableBox

func (*TableBox) AllChildren

func (b *TableBox) AllChildren() []Box

func (*TableBox) Box

func (b *TableBox) Box() *BoxFields

func (TableBox) Copy

func (b TableBox) Copy() Box

func (TableBox) IsClassicalBox

func (TableBox) IsClassicalBox() bool

func (*TableBox) PageValues

func (b *TableBox) PageValues() (pr.Page, pr.Page)

func (*TableBox) Table

func (b *TableBox) Table() *TableBox

Table implements InstanceTableBox

func (*TableBox) Translate

func (b *TableBox) Translate(box Box, dx, dy pr.Float, ignoreFloats bool)

func (TableBox) Type

func (TableBox) Type() BoxType

type TableBoxITF

type TableBoxITF interface {
	BlockLevelBoxITF
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table“

type TableCaptionBox

type TableCaptionBox struct {
	BlockBox
}

func NewTableCaptionBox

func NewTableCaptionBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableCaptionBox

func TableCaptionBoxAnonymousFrom

func TableCaptionBoxAnonymousFrom(parent Box, children []Box) *TableCaptionBox

func (*TableCaptionBox) Box

func (b *TableCaptionBox) Box() *BoxFields

func (TableCaptionBox) Copy

func (b TableCaptionBox) Copy() Box

func (TableCaptionBox) IsClassicalBox

func (TableCaptionBox) IsClassicalBox() bool

func (TableCaptionBox) Type

func (TableCaptionBox) Type() BoxType

type TableCaptionBoxITF

type TableCaptionBoxITF interface {
	BlockBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-caption“

type TableCellBox

type TableCellBox struct {
	BoxFields
}

func NewTableCellBox

func NewTableCellBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableCellBox

func TableCellBoxAnonymousFrom

func TableCellBoxAnonymousFrom(parent Box, children []Box) *TableCellBox

func (*TableCellBox) Box

func (b *TableCellBox) Box() *BoxFields

func (TableCellBox) Copy

func (b TableCellBox) Copy() Box

func (TableCellBox) IsClassicalBox

func (TableCellBox) IsClassicalBox() bool

func (TableCellBox) Type

func (TableCellBox) Type() BoxType

type TableCellBoxITF

type TableCellBoxITF interface {
	BlockContainerBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-cell“

type TableColumnBox

type TableColumnBox struct {
	BoxFields
}

func NewTableColumnBox

func NewTableColumnBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableColumnBox

func TableColumnBoxAnonymousFrom

func TableColumnBoxAnonymousFrom(parent Box, children []Box) *TableColumnBox

func (*TableColumnBox) Box

func (b *TableColumnBox) Box() *BoxFields

func (TableColumnBox) Copy

func (b TableColumnBox) Copy() Box

func (TableColumnBox) IsClassicalBox

func (TableColumnBox) IsClassicalBox() bool

func (TableColumnBox) Type

func (TableColumnBox) Type() BoxType

type TableColumnBoxITF

type TableColumnBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-column“

type TableColumnGroupBox

type TableColumnGroupBox struct {
	BoxFields
}

func NewTableColumnGroupBox

func NewTableColumnGroupBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableColumnGroupBox

func TableColumnGroupBoxAnonymousFrom

func TableColumnGroupBoxAnonymousFrom(parent Box, children []Box) *TableColumnGroupBox

func (*TableColumnGroupBox) Box

func (b *TableColumnGroupBox) Box() *BoxFields

func (TableColumnGroupBox) Copy

func (b TableColumnGroupBox) Copy() Box

func (TableColumnGroupBox) IsClassicalBox

func (TableColumnGroupBox) IsClassicalBox() bool

func (TableColumnGroupBox) Type

type TableColumnGroupBoxITF

type TableColumnGroupBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-column-group“

type TableRowBox

type TableRowBox struct {
	BoxFields
}

func NewTableRowBox

func NewTableRowBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableRowBox

func TableRowBoxAnonymousFrom

func TableRowBoxAnonymousFrom(parent Box, children []Box) *TableRowBox

func (*TableRowBox) Box

func (b *TableRowBox) Box() *BoxFields

func (TableRowBox) Copy

func (b TableRowBox) Copy() Box

func (TableRowBox) IsClassicalBox

func (TableRowBox) IsClassicalBox() bool

func (TableRowBox) Type

func (TableRowBox) Type() BoxType

type TableRowBoxITF

type TableRowBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-row“

type TableRowGroupBox

type TableRowGroupBox struct {
	BoxFields
}

func NewTableRowGroupBox

func NewTableRowGroupBox(style pr.ElementStyle, element *html.Node, pseudoType string, children []Box) *TableRowGroupBox

func TableRowGroupBoxAnonymousFrom

func TableRowGroupBoxAnonymousFrom(parent Box, children []Box) *TableRowGroupBox

func (*TableRowGroupBox) Box

func (b *TableRowGroupBox) Box() *BoxFields

func (TableRowGroupBox) Copy

func (b TableRowGroupBox) Copy() Box

func (TableRowGroupBox) IsClassicalBox

func (TableRowGroupBox) IsClassicalBox() bool

func (TableRowGroupBox) Type

func (TableRowGroupBox) Type() BoxType

type TableRowGroupBoxITF

type TableRowGroupBoxITF interface {
	ParentBoxITF
	// contains filtered or unexported methods
}

Box for elements with “display: table-row-group“

type TextBox

type TextBox struct {
	InlineLevelBox
	BoxFields

	TextLayout text.EngineLayout
	Text       string
}

func NewTextBox

func NewTextBox(style pr.ElementStyle, element *html.Node, pseudoType string, text string) TextBox

func TextBoxAnonymousFrom

func TextBoxAnonymousFrom(parent Box, text string) *TextBox

func (*TextBox) Box

func (b *TextBox) Box() *BoxFields

func (TextBox) Copy

func (b TextBox) Copy() Box

func (TextBox) CopyWithText

func (b TextBox) CopyWithText(text string) *TextBox

Return a new TextBox identical to this one except for the text.

func (TextBox) IsClassicalBox

func (TextBox) IsClassicalBox() bool

func (TextBox) RemoveDecoration

func (u TextBox) RemoveDecoration(b *BoxFields, start, end bool)

func (TextBox) Type

func (TextBox) Type() BoxType

type TextBoxITF

type TextBoxITF interface {
	InlineLevelBoxITF
	// contains filtered or unexported methods
}

A box that contains only text and has no box children. Any text in the document ends up in a text box. What CSS calls "anonymous inline boxes" are also text boxes.

type URLResolver added in v0.0.2

type URLResolver struct {
	Fetch      utils.UrlFetcher
	FetchImage Gifu
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL