summaryrefslogtreecommitdiff
path: root/crates/typst-library/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src')
-rw-r--r--crates/typst-library/src/foundations/content.rs3
-rw-r--r--crates/typst-library/src/layout/frame.rs52
-rw-r--r--crates/typst-library/src/model/link.rs5
3 files changed, 6 insertions, 54 deletions
diff --git a/crates/typst-library/src/foundations/content.rs b/crates/typst-library/src/foundations/content.rs
index ab2f68ac..76cd6a22 100644
--- a/crates/typst-library/src/foundations/content.rs
+++ b/crates/typst-library/src/foundations/content.rs
@@ -9,7 +9,6 @@ use std::sync::Arc;
use comemo::Tracked;
use ecow::{eco_format, EcoString};
use serde::{Serialize, Serializer};
-use smallvec::smallvec;
use typst_syntax::Span;
use typst_utils::{fat, singleton, LazyHash, SmallBitSet};
@@ -500,7 +499,7 @@ impl Content {
/// Link the content somewhere.
pub fn linked(self, dest: Destination) -> Self {
- self.styled(LinkElem::set_dests(smallvec![dest]))
+ self.styled(LinkElem::set_current(Some(dest)))
}
/// Set alignments for this content.
diff --git a/crates/typst-library/src/layout/frame.rs b/crates/typst-library/src/layout/frame.rs
index e57eb27e..a26a7d0e 100644
--- a/crates/typst-library/src/layout/frame.rs
+++ b/crates/typst-library/src/layout/frame.rs
@@ -4,16 +4,13 @@ use std::fmt::{self, Debug, Formatter};
use std::num::NonZeroUsize;
use std::sync::Arc;
-use smallvec::SmallVec;
use typst_syntax::Span;
use typst_utils::{LazyHash, Numeric};
-use crate::foundations::{cast, dict, Dict, Label, StyleChain, Value};
+use crate::foundations::{cast, dict, Dict, Label, Value};
use crate::introspection::{Location, Tag};
-use crate::layout::{
- Abs, Axes, FixedAlignment, HideElem, Length, Point, Size, Transform,
-};
-use crate::model::{Destination, LinkElem};
+use crate::layout::{Abs, Axes, FixedAlignment, Length, Point, Size, Transform};
+use crate::model::Destination;
use crate::text::TextItem;
use crate::visualize::{Color, Curve, FixedStroke, Geometry, Image, Paint, Shape};
@@ -304,49 +301,6 @@ impl Frame {
}
}
- /// Apply late-stage properties from the style chain to this frame. This
- /// includes:
- /// - `HideElem::hidden`
- /// - `LinkElem::dests`
- ///
- /// This must be called on all frames produced by elements
- /// that manually handle styles (because their children can have varying
- /// styles). This currently includes flow, par, and equation.
- ///
- /// Other elements don't manually need to handle it because their parents
- /// that result from realization will take care of it and the styles can
- /// only apply to them as a whole, not part of it (because they don't manage
- /// styles).
- pub fn post_processed(mut self, styles: StyleChain) -> Self {
- self.post_process(styles);
- self
- }
-
- /// Post process in place.
- pub fn post_process(&mut self, styles: StyleChain) {
- if !self.is_empty() {
- self.post_process_raw(
- LinkElem::dests_in(styles),
- HideElem::hidden_in(styles),
- );
- }
- }
-
- /// Apply raw late-stage properties from the raw data.
- pub fn post_process_raw(&mut self, dests: SmallVec<[Destination; 1]>, hide: bool) {
- if !self.is_empty() {
- let size = self.size;
- self.push_multiple(
- dests
- .into_iter()
- .map(|dest| (Point::zero(), FrameItem::Link(dest, size))),
- );
- if hide {
- self.hide();
- }
- }
- }
-
/// Hide all content in the frame, but keep metadata.
pub fn hide(&mut self) {
Arc::make_mut(&mut self.items).retain_mut(|(_, item)| match item {
diff --git a/crates/typst-library/src/model/link.rs b/crates/typst-library/src/model/link.rs
index 5df6bead..24b746b7 100644
--- a/crates/typst-library/src/model/link.rs
+++ b/crates/typst-library/src/model/link.rs
@@ -1,7 +1,6 @@
use std::ops::Deref;
use ecow::{eco_format, EcoString};
-use smallvec::SmallVec;
use crate::diag::{bail, warning, At, SourceResult, StrResult};
use crate::engine::Engine;
@@ -90,10 +89,10 @@ pub struct LinkElem {
})]
pub body: Content,
- /// This style is set on the content contained in the `link` element.
+ /// A destination style that should be applied to elements.
#[internal]
#[ghost]
- pub dests: SmallVec<[Destination; 1]>,
+ pub current: Option<Destination>,
}
impl LinkElem {