mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Improve line index documentation
This commit is contained in:
parent
c6a60276d1
commit
4e27045687
1 changed files with 41 additions and 33 deletions
|
@ -59,6 +59,33 @@ use sync::Arc;
|
||||||
/// left corner of the green zone is the same as that of the line, but
|
/// left corner of the green zone is the same as that of the line, but
|
||||||
/// the green zone can be taller and wider than the line itself.
|
/// the green zone can be taller and wider than the line itself.
|
||||||
pub struct Line {
|
pub struct Line {
|
||||||
|
/// A range of line indices that describe line breaks.
|
||||||
|
///
|
||||||
|
/// For example, consider the following HTML and rendered element with
|
||||||
|
/// linebreaks:
|
||||||
|
///
|
||||||
|
/// ~~~html
|
||||||
|
/// <span>I <span>like truffles, <img></span> yes I do.</span>
|
||||||
|
/// ~~~
|
||||||
|
///
|
||||||
|
/// ~~~
|
||||||
|
/// +------------+
|
||||||
|
/// | I like |
|
||||||
|
/// | truffles, |
|
||||||
|
/// | +----+ |
|
||||||
|
/// | | | |
|
||||||
|
/// | +----+ yes |
|
||||||
|
/// | I do. |
|
||||||
|
/// +------------+
|
||||||
|
/// ~~~
|
||||||
|
///
|
||||||
|
/// The ranges that describe these lines would be:
|
||||||
|
///
|
||||||
|
/// ~~~
|
||||||
|
/// | [0.0, 1.4) | [1.5, 2.0) | [2.0, 3.4) | [3.4, 4.0) |
|
||||||
|
/// |------------|-------------|-------------|-------------|
|
||||||
|
/// | 'I like' | 'truffles,' | '<img> yes' | 'yes I do.' |
|
||||||
|
/// ~~~
|
||||||
pub range: Range<LineIndices>,
|
pub range: Range<LineIndices>,
|
||||||
pub bounds: Rect<Au>,
|
pub bounds: Rect<Au>,
|
||||||
pub green_zone: Size2D<Au>
|
pub green_zone: Size2D<Au>
|
||||||
|
@ -72,29 +99,6 @@ int_range_index! {
|
||||||
/// A line index consists of two indices: a fragment index that refers to the
|
/// A line index consists of two indices: a fragment index that refers to the
|
||||||
/// index of a DOM fragment within a flattened inline element; and a glyph index
|
/// index of a DOM fragment within a flattened inline element; and a glyph index
|
||||||
/// where the 0th glyph refers to the first glyph of that fragment.
|
/// where the 0th glyph refers to the first glyph of that fragment.
|
||||||
///
|
|
||||||
/// For example, consider the following HTML and rendered element with
|
|
||||||
/// linebreaks:
|
|
||||||
///
|
|
||||||
/// ~~~html
|
|
||||||
/// <span>I <span>like truffles,</span> yes I do.</span>
|
|
||||||
/// ~~~
|
|
||||||
///
|
|
||||||
/// ~~~
|
|
||||||
/// +-----------+
|
|
||||||
/// | I like |
|
|
||||||
/// | truffles, |
|
|
||||||
/// | yes I do. |
|
|
||||||
/// +-----------+
|
|
||||||
/// ~~~
|
|
||||||
///
|
|
||||||
/// The ranges that describe these lines would be:
|
|
||||||
///
|
|
||||||
/// ~~~
|
|
||||||
/// | [0.0, 1.4) | [1.5, 2.0) | [2.1, 3.0) |
|
|
||||||
/// |------------|-------------|-------------|
|
|
||||||
/// | 'I like' | 'truffles,' | 'yes I do.' |
|
|
||||||
/// ~~~
|
|
||||||
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Zero)]
|
#[deriving(Clone, Eq, Ord, TotalEq, TotalOrd, Zero)]
|
||||||
pub struct LineIndices {
|
pub struct LineIndices {
|
||||||
/// The index of a fragment into the flattened vector of DOM elements.
|
/// The index of a fragment into the flattened vector of DOM elements.
|
||||||
|
@ -102,34 +106,38 @@ pub struct LineIndices {
|
||||||
/// For example, given the HTML below:
|
/// For example, given the HTML below:
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// <span>I <span>like truffles,</span> yes I do.</span>
|
/// <span>I <span>like truffles, <img></span> yes I do.</span>
|
||||||
/// ~~~
|
/// ~~~
|
||||||
///
|
///
|
||||||
/// The fragments would be indexed as follows:
|
/// The fragments would be indexed as follows:
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// | 0 | 1 | 2 |
|
/// | 0 | 1 | 2 | 3 |
|
||||||
/// |------|------------------|--------------|
|
/// |------|------------------|-------|--------------|
|
||||||
/// | 'I ' | 'like truffles,' | ' yes I do.' |
|
/// | 'I ' | 'like truffles,' | <img> | ' yes I do.' |
|
||||||
/// ~~~
|
/// ~~~
|
||||||
pub fragment_index: FragmentIndex,
|
pub fragment_index: FragmentIndex,
|
||||||
|
|
||||||
/// The index of a character in a DOM fragment. Ligatures and continuous
|
/// The index of a character in a DOM fragment. Continuous runs of whitespace
|
||||||
/// runs of whitespace are treated as single characters. Non-breakable DOM
|
/// are treated as single characters. Non-breakable DOM
|
||||||
/// fragments such as images are treated as having a range length of `1`.
|
/// fragments such as images are treated as having a range length of `1`.
|
||||||
///
|
///
|
||||||
/// For example, given the HTML below:
|
/// For example, given the HTML below:
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// <span>like truffles,</span>
|
/// <span>I <span>like truffles, <img></span> yes I do.</span>
|
||||||
/// ~~~
|
/// ~~~
|
||||||
///
|
///
|
||||||
/// The characters would be indexed as follows:
|
/// The characters would be indexed as follows:
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|
/// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|
||||||
/// |---|---|---|---|---|---|---|---|---|---|----|----|----|----|
|
/// |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|----|
|
||||||
/// | l | i | k | e | | t | r | u | f | f | l | e | s | , |
|
/// | I | | l | i | k | e | e | l | i | k | e | | t | r | u | f | f | l |
|
||||||
|
///
|
||||||
|
/// | 11 | 12 | 13 | 14 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|
||||||
|
/// |----|----|----|----|-------|---|---|---|---|---|---|---|---|---|---|
|
||||||
|
/// | e | s | , | | <img> | | y | e | s | | I | | d | o | . |
|
||||||
/// ~~~
|
/// ~~~
|
||||||
pub char_index: CharIndex,
|
pub char_index: CharIndex,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue