这是indexloc提供的服务,不要输入任何密码
Skip to content

Percentages in top/left/bottom/right properties are relative to the containing block #23

@SimonSapin

Description

@SimonSapin

In this code:

let relative_adjustement = relative_adjustement(style, inline_size, block_size);

The size of a block box is given as a basis to resolve percentages in offset properties if that same box is position: relative. Instead, the size of the containing block should be used. However at this point in the code, the block-direction size of the containing block might not be known yet. Therefore the computation of position: relative offsets must be delayed until later, when it is known. Options include:

  • When the "main layout phase" is finished for a containing block, do a another sub-tree traversal to find and adjust position: relative descendants that have this containing block. (They are not necessarily direct children in the box tree, for example for inline boxes.)

  • Keep track during the main phase of a list of position: relative descendants, like we already do for postition: absolute. This has an allocation and memory cost.

  • Only account for position: relative offsets during the "painting" phase. (Or eventually in Servo, during display list construction.)

The last one seems preferable to me, but requires keeping track of containing blocks in the fragment tree. (The containing block is not necessarily the direct parent fragment, again because of nested inline boxes.)

CC @nox

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions