-
Notifications
You must be signed in to change notification settings - Fork 3
feat(layout): impl grid layout #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 13 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
47c3dc6
feat: support parsing the grid-template-rows/columns CSS property
TtTRz 7de41f4
feat: support parsing the grid-auto-flow CSS property
TtTRz 5fb3d9b
feat: impl grid layout
TtTRz bd64d0a
feat: impl grid layout
TtTRz 476c79b
feat: impl grid layout
TtTRz 4f752e0
feat: impl grid layout
f87e120
feat: update grid layout
TtTRz c0f13d4
fix: update grid impl
TtTRz d134e21
fix: min-content for grid
TtTRz 3808770
feat: impl min-content
TtTRz 4cca438
Merge remote-tracking branch 'origin/master' into feat-grid
d1a6049
feat: update grid impl & add docs
TtTRz 18665f3
docs: udpate grid doc
TtTRz 7c7d8d9
clippy: fix
TtTRz 61345c3
feat: impl dynamic grid
TtTRz dc23a59
feat: impl dynamic grid
TtTRz bc6b5ef
docs: udpate grid doc
TtTRz c8c7813
docs: udpate grid doc
TtTRz b79186d
feat: update grid impl
TtTRz 5db0863
feat: update grid impl
TtTRz 50bc301
feat: update grid impl
TtTRz 8ad6109
feat: update grid track impl
TtTRz 821bfaa
feat: update grid impl
TtTRz 72eef8a
feat: update grid impl
TtTRz 4c45a07
feat: update grid impl
TtTRz 5d67394
feat: impl direction for grid
TtTRz fcda52d
docs: update grid doc
TtTRz b6d1913
feat: impl grid-auto-columns/row
TtTRz 9bf7f08
feat: impl grid-auto-columns/row
TtTRz d0f6fd7
clippy: fix
TtTRz b6c65e3
fix: impl no_std
TtTRz b6bd6ac
Merge remote-tracking branch 'origin/master' into feat-grid
TtTRz fc8e0d1
feat: init grid matrix with capacity
TtTRz 1aa88fc
Merge remote-tracking branch 'origin/master' into feat-grid
TtTRz 7e78a10
feat: update expand flexible tracks impl
TtTRz eaeaba6
fix: update track height impl
TtTRz 9103d1d
fix: update dense impl
TtTRz 66c31b4
fix: shortcut of min-content
TtTRz 1a944ec
docs: update grid doc
TtTRz a1ee1e5
docs: update grid doc
TtTRz 198e683
docs: update grid doc
TtTRz 480e14a
feat: impl bitMap for grid matrix
TtTRz deb3ea0
docs: update doc
TtTRz 771bd19
fix: initial value of grid auto rows/columns
TtTRz 2f44827
fix: rtl for grid
TtTRz adcd7ef
tests: add grid margin test cases
TtTRz e21fda7
chore: update comment
TtTRz 3c1a764
fix: min-content impl
TtTRz 40f8b54
feat(doc): Update CSS Grid spec refs and clarify sizing logic
TtTRz 43b77f5
fix: remove unsafe impl
TtTRz 3ad1c32
fix: update grid impl
TtTRz e153388
fix: update grid impl
TtTRz ab29189
fix: remove dead code
TtTRz ede8228
feat: update OccupiedBitmap impl
TtTRz 2fb5bc8
feat: update OccupiedBitmap impl
TtTRz 424b12d
feat: update OccupiedBitmap impl
TtTRz 1f54aea
test: add test cases for OccupiedBitmap
TtTRz 65e3768
fix: remove min_content_size from ComputeResult
TtTRz 6d32147
fix: update min-content impl
TtTRz a781487
feat: update grid impl
TtTRz 99b7754
feat: update grid impl
TtTRz ee61e16
docs: update grid doc
TtTRz 3891b29
refactor: refactor grid track classification logic to reduce code dup…
TtTRz 08c2b46
fix: track sizing function
TtTRz 06a4875
docs: update docs
TtTRz 6b1465d
fix: initial value of align-content
TtTRz 3b21b02
docs: update doc
TtTRz 6a63bc3
fix: resolve fr track sizes
TtTRz 87961bc
Merge remote-tracking branch 'origin/master' into feat-grid
TtTRz d8ea23f
fix: guarantees stride at least 1
TtTRz 17d715a
fix: bug
TtTRz a927b52
fix: remove TrackSizingResult
TtTRz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| use cssparser::{ParseError, Parser, Token}; | ||
|
|
||
| use crate::{ | ||
| parser::{property_value::custom_ident_repr, CustomError, ParseState}, | ||
| sheet::PropertyMeta, | ||
| typing::GridAutoFlow, | ||
| }; | ||
|
|
||
| #[inline(never)] | ||
| pub(crate) fn line_names<'a, 't: 'a, 'i: 't>( | ||
| parser: &'a mut Parser<'i, 't>, | ||
| properties: &mut [PropertyMeta], | ||
| st: &mut ParseState, | ||
| ) -> Result<Vec<String>, ParseError<'i, CustomError>> { | ||
| let next = parser.next()?; | ||
| if let Token::SquareBracketBlock = next { | ||
| let line_names = parser.parse_nested_block(|parser| { | ||
| let mut line_names = Vec::with_capacity(1); | ||
| while !parser.is_exhausted() { | ||
| let line_name = custom_ident_repr(parser, properties, st)?; | ||
| line_names.push(line_name); | ||
| } | ||
| Ok(line_names) | ||
| })?; | ||
| return Ok(line_names); | ||
| } | ||
| let next = next.clone(); | ||
| Err(parser.new_unexpected_token_error(next)) | ||
| } | ||
|
|
||
| #[inline(never)] | ||
| pub(crate) fn fr_repr<'a, 't: 'a, 'i: 't>( | ||
| parser: &'a mut Parser<'i, 't>, | ||
| _properties: &mut [PropertyMeta], | ||
| _st: &mut ParseState, | ||
| ) -> Result<f32, ParseError<'i, CustomError>> { | ||
| let next = parser.next()?; | ||
| match next { | ||
| Token::Dimension { value, unit, .. } => match unit as &str { | ||
| "fr" => return Ok(*value), | ||
| _ => {} | ||
| }, | ||
| _ => {} | ||
| } | ||
| let next = next.clone(); | ||
| Err(parser.new_unexpected_token_error(next)) | ||
| } | ||
|
|
||
| #[inline(never)] | ||
| pub(crate) fn grid_auto_flow_repr<'a, 't: 'a, 'i: 't>( | ||
| parser: &'a mut Parser<'i, 't>, | ||
| _properties: &mut [PropertyMeta], | ||
| _st: &mut ParseState, | ||
| ) -> Result<GridAutoFlow, ParseError<'i, CustomError>> { | ||
| #[derive(PartialEq, Clone, Copy)] | ||
| enum FlowDirection { | ||
| Row, | ||
| Column, | ||
| } | ||
| let mut flow_direction = None; | ||
| let mut dense = false; | ||
| let check_flow_direction = move |target: FlowDirection| { | ||
| if flow_direction.is_none() { | ||
| return true; | ||
| } | ||
| flow_direction.unwrap() != target | ||
| }; | ||
| while !parser.is_exhausted() { | ||
| let next = parser.next()?; | ||
| match next { | ||
| Token::Ident(ident) => { | ||
| let ident: &str = ident; | ||
| match ident { | ||
| "row" if check_flow_direction(FlowDirection::Row) => { | ||
| flow_direction.replace(FlowDirection::Row); | ||
| } | ||
| "column" if check_flow_direction(FlowDirection::Column) => { | ||
| flow_direction.replace(FlowDirection::Column); | ||
| } | ||
| "dense" if !dense => { | ||
| dense = true; | ||
| } | ||
| _ => { | ||
| let next = next.clone(); | ||
| return Err(parser.new_unexpected_token_error(next)); | ||
| } | ||
| } | ||
| } | ||
| _ => { | ||
| let next = next.clone(); | ||
| return Err(parser.new_unexpected_token_error(next)); | ||
| } | ||
| } | ||
| } | ||
| match (flow_direction, dense) { | ||
| (Some(FlowDirection::Row), true) => Ok(GridAutoFlow::RowDense), | ||
| (Some(FlowDirection::Column), true) => Ok(GridAutoFlow::ColumnDense), | ||
| (Some(FlowDirection::Row), false) => Ok(GridAutoFlow::Row), | ||
| (Some(FlowDirection::Column), false) => Ok(GridAutoFlow::Column), | ||
| (None, true) => Ok(GridAutoFlow::RowDense), | ||
| (None, _) => Err(parser.new_custom_error(CustomError::Unmatched)), | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.