Closed Bug 1108429 Opened 10 years ago Closed 10 years ago

Implement default ruby alignment (ruby-align: space-around)

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: xidorn, Assigned: xidorn)

References

()

Details

Attachments

(8 files, 2 obsolete files)

6.45 KB, patch
roc
: review+
Details | Diff | Splinter Review
2.50 KB, patch
roc
: review+
Details | Diff | Splinter Review
3.49 KB, patch
roc
: review+
Details | Diff | Splinter Review
5.57 KB, patch
roc
: review+
Details | Diff | Splinter Review
6.32 KB, patch
roc
: review+
Details | Diff | Splinter Review
7.67 KB, patch
roc
: review+
Details | Diff | Splinter Review
4.86 KB, patch
roc
: review+
Details | Diff | Splinter Review
6.61 KB, patch
roc
: review+
Details | Diff | Splinter Review
I plan to implement the space-around first, and ruby-align later.
Blocks: 1081770
Assignee: nobody → quanxunzhen
No longer blocks: 1081770
Depends on: 1081770
Attachment #8538372 - Flags: review?(roc)
Comment on attachment 8538363 [details] [diff] [review]
patch 1 - Add ruby utils for reserving isize of ruby boxes

Review of attachment 8538363 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/RubyUtils.h
@@ +24,5 @@
> +  }
> +
> +  static void SetReservedISize(nsIFrame* aFrame, nscoord aISize);
> +  static void ClearReservedISize(nsIFrame* aFrame);
> +  static nscoord GetReservedISize(nsIFrame* aFrame);

You need comments explaining what the "Reserved ISize" is.
Attachment #8538363 - Flags: review?(roc) → review-
Comment on attachment 8538371 [details] [diff] [review]
patch 7 - Modify jusitication computation to take ruby into account

Review of attachment 8538371 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsLineLayout.cpp
@@ +2490,2 @@
>    PerFrameData* mLastParticipant;
> +  bool mAcrossRubyBaseBound;

Please document what this means.

@@ +2569,5 @@
>          }
>        }
>  
>        aState.mLastParticipant = pfd;
> +      aState.mAcrossRubyBaseBound = isRubyBase;

Why are we setting this in two places?
Attachment #8538371 - Flags: review?(roc) → review-
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #9)
> Comment on attachment 8538363 [details] [diff] [review]
> patch 1 - Add ruby utils for reserving isize of ruby boxes
> 
> Review of attachment 8538363 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: layout/generic/RubyUtils.h
> @@ +24,5 @@
> > +  }
> > +
> > +  static void SetReservedISize(nsIFrame* aFrame, nscoord aISize);
> > +  static void ClearReservedISize(nsIFrame* aFrame);
> > +  static nscoord GetReservedISize(nsIFrame* aFrame);
> 
> You need comments explaining what the "Reserved ISize" is.

OK, so "Reserved ISize" is the difference between the isize a frame should be and what it is currently. The difference is reserved so that we can expand the frames to the expected isize later. The isize has been reserved in line layout via AdvanceICoord.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #10)
> Comment on attachment 8538371 [details] [diff] [review]
> patch 7 - Modify jusitication computation to take ruby into account
> 
> Review of attachment 8538371 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: layout/generic/nsLineLayout.cpp
> @@ +2490,2 @@
> >    PerFrameData* mLastParticipant;
> > +  bool mAcrossRubyBaseBound;
> 
> Please document what this means.

It means, we are going across a boundary of a ruby base, that is, we are entering one, leaving one, or both.

> @@ +2569,5 @@
> >          }
> >        }
> >  
> >        aState.mLastParticipant = pfd;
> > +      aState.mAcrossRubyBaseBound = isRubyBase;
> 
> Why are we setting this in two places?

It is set here because we are leaving the ruby base.
Do you think my comments above have been clear enough for understanding the patches? If so, I'll update the patches to include them.
Flags: needinfo?(roc)
(In reply to Xidorn Quan [:xidorn] (UTC+11) from comment #11)
> OK, so "Reserved ISize" is the difference between the isize a frame should
> be and what it is currently. The difference is reserved so that we can
> expand the frames to the expected isize later. The isize has been reserved
> in line layout via AdvanceICoord.

This isn't detailed enough. You need to say what causes the difference and what exactly you mean by "now" and "later".
Flags: needinfo?(roc)
Comment on attachment 8538371 [details] [diff] [review]
patch 7 - Modify jusitication computation to take ruby into account

Review of attachment 8538371 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsLineLayout.cpp
@@ +2490,2 @@
>    PerFrameData* mLastParticipant;
> +  bool mAcrossRubyBaseBound;

OK, call it "mCrossingRubyBaseBoundary".
Attachment #8538371 - Flags: review- → review+
Ruby boxes usually need to synchronize their isize among different levels, which means they might have a larger isize than what themselves require. When these ruby boxes are reflowed, they are sized like a normal inline container, but the difference between this size and the isize it should be, is reserved in line layout, and saved as "Reserved ISize" in the property of the frame.
Is comment 16 clear enough?
Flags: needinfo?(roc)
Can you give an example?

When you say "the isize it should be", how exactly is the "isize it should be" determined?
Flags: needinfo?(roc)
With some exceptions, each ruby internal box has two isizes, which are intrinsic isize and intended isize. The intrinsic isize is what a box itself needs. It is determined when the box gets reflowed.

The intended isize is what it should be as the final result. For an rb/rt box, the intended isize is the size of its ruby column. For an rbc/rtc box, the intended isize is the size of its ruby segment. The intended isize is never smaller than the intrinsic isize for any ruby box. It is initially determined when a ruby column/segment gets fully reflowed, and may be advanced when a box is expanded, e.g. when applying justification.

The difference between the intended isize and the intrinsic isize is reserved in the line layout after reflowing the box, hence it is called reserved isize here. The reserved isize is used to expand the ruby boxes from their intrinsic isize to the intended isize during aligning the line.

There are three exceptions for the intrinsic isize:
1. An rbc box does not have intended isize unless there is any span or collapsed annotation in its segment;
2. An rtc box have intended isize only if it is for a span or collapsed annotations;
3. If an rtc box have intended isize, its children must not have.

Is it clear enough now? I feel that the word "intrinsic isize" here might refer to another concept in our code, but I have no idea what term should be used instead.
Flags: needinfo?(roc)
That's a lot clearer, thanks. That explanation should definitely be in a comment somewhere.

We already have intrinsic preferred and max isizes, which seem different since they don't take line breaks into account. How is your "intrinsic isize" affected by line breaking? I can't tell from your explanation.

"intended" is also too vague. Maybe we should call it "final ruby isize".
Flags: needinfo?(roc)
Thanks, I'll add them. I'm going to add them to RubyUtils.h.

rb/rt boxes currently never have line break inside (bug 1105051), so the "intrinsic isize" I mentioned here should effectively be equal to the intrinsic preferred isize for them. (I assume the other one should be intrinsic min isize, not max). However, right, the "intrinsic isize" for rbc/rtc boxes is affected by line breaking. The "intrinsic isize" for them only takes the left parts into account, i.e. any pushed frames are not included.
(In reply to Xidorn Quan [:xidorn] (UTC+11) from comment #21)
> intrinsic min isize, not max). However, right, the "intrinsic isize" for
> rbc/rtc boxes is affected by line breaking. The "intrinsic isize" for them
> only takes the left parts into account, i.e. any pushed frames are not
> included.

I'd prefer not to use the term "intrinsic" for things that are affected by line breaking.  Line breaking is a function of the environment (available width) outside of the element, so it's not intrinsic to the element.
Add the comment.
Attachment #8538363 - Attachment is obsolete: true
Attachment #8539991 - Flags: review?(roc)
Attachment #8538372 - Attachment is obsolete: true
Attachment #8538372 - Flags: review?(roc)
Attachment #8539993 - Flags: review?(roc)
Comment on attachment 8539991 [details] [diff] [review]
patch 1 - Add ruby utils for reserving isize of ruby boxes

Review of attachment 8539991 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/RubyUtils.h
@@ +11,5 @@
> +
> +namespace mozilla {
> +
> +/**
> + * Reserved ISize

fix this line

@@ +28,5 @@
> + *
> + * The difference between the reflowed isize and the final isize is
> + * reserved in the line layout after reflowing a box, hence it is called
> + * "Reserved ISize" here. It is used to expand the ruby boxes from their
> + * reflowed isize to the final isize during aligning the line.

"during alignment of the line"
Attachment #8539991 - Flags: review?(roc) → review+
Depends on: 1116631
Depends on: 1116635
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: