зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1697529 - Implement visibility: collapse support for ruby text. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D107990
This commit is contained in:
Родитель
cee32e6733
Коммит
3c6c9eeffc
|
@ -639,7 +639,7 @@ FRAME_STATE_BIT(Inline, 23, NS_INLINE_FRAME_BIDI_VISUAL_IS_LAST)
|
|||
FRAME_STATE_GROUP(RubyText, nsRubyTextFrame)
|
||||
|
||||
// inherits from nsInlineFrame
|
||||
FRAME_STATE_BIT(RubyText, 24, NS_RUBY_TEXT_FRAME_AUTOHIDE)
|
||||
FRAME_STATE_BIT(RubyText, 24, NS_RUBY_TEXT_FRAME_COLLAPSED)
|
||||
|
||||
// == Frame state bits that apply to ruby text container frames ===============
|
||||
|
||||
|
|
|
@ -2814,7 +2814,7 @@ void nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD,
|
|||
// For ruby text frames, only increase frames
|
||||
// which are not auto-hidden.
|
||||
if (frameType != LayoutFrameType::RubyText ||
|
||||
!static_cast<nsRubyTextFrame*>(frame)->IsAutoHidden()) {
|
||||
!static_cast<nsRubyTextFrame*>(frame)->IsCollapsed()) {
|
||||
nscoord reservedISize = RubyUtils::GetReservedISize(frame);
|
||||
RubyUtils::SetReservedISize(frame, reservedISize + aDeltaISize);
|
||||
}
|
||||
|
|
|
@ -598,18 +598,23 @@ nscoord nsRubyBaseContainerFrame::ReflowOneColumn(
|
|||
for (uint32_t i = 0; i < rtcCount; i++) {
|
||||
nsRubyTextFrame* textFrame = aColumn.mTextFrames[i];
|
||||
if (textFrame) {
|
||||
nsAutoString annotationText;
|
||||
nsLayoutUtils::GetFrameTextContent(textFrame, annotationText);
|
||||
|
||||
// Per CSS Ruby spec, the content comparison for auto-hiding
|
||||
// takes place prior to white spaces collapsing (white-space)
|
||||
// and text transformation (text-transform), and ignores elements
|
||||
// (considers only the textContent of the boxes). Which means
|
||||
// using the content tree text comparison is correct.
|
||||
if (annotationText.Equals(baseText)) {
|
||||
textFrame->AddStateBits(NS_RUBY_TEXT_FRAME_AUTOHIDE);
|
||||
bool isCollapsed = false;
|
||||
if (textFrame->StyleVisibility()->mVisible == StyleVisibility::Collapse) {
|
||||
isCollapsed = true;
|
||||
} else {
|
||||
textFrame->RemoveStateBits(NS_RUBY_TEXT_FRAME_AUTOHIDE);
|
||||
// Per CSS Ruby spec, the content comparison for auto-hiding
|
||||
// takes place prior to white spaces collapsing (white-space)
|
||||
// and text transformation (text-transform), and ignores elements
|
||||
// (considers only the textContent of the boxes). Which means
|
||||
// using the content tree text comparison is correct.
|
||||
nsAutoString annotationText;
|
||||
nsLayoutUtils::GetFrameTextContent(textFrame, annotationText);
|
||||
isCollapsed = annotationText.Equals(baseText);
|
||||
}
|
||||
if (isCollapsed) {
|
||||
textFrame->AddStateBits(NS_RUBY_TEXT_FRAME_COLLAPSED);
|
||||
} else {
|
||||
textFrame->RemoveStateBits(NS_RUBY_TEXT_FRAME_COLLAPSED);
|
||||
}
|
||||
RubyUtils::ClearReservedISize(textFrame);
|
||||
|
||||
|
@ -682,7 +687,7 @@ nscoord nsRubyBaseContainerFrame::ReflowOneColumn(
|
|||
nscoord deltaISize = icoord - lineLayout->GetCurrentICoord();
|
||||
if (deltaISize > 0) {
|
||||
lineLayout->AdvanceICoord(deltaISize);
|
||||
if (textFrame && !textFrame->IsAutoHidden()) {
|
||||
if (textFrame && !textFrame->IsCollapsed()) {
|
||||
RubyUtils::SetReservedISize(textFrame, deltaISize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ nsresult nsRubyTextFrame::GetFrameName(nsAString& aResult) const {
|
|||
/* virtual */
|
||||
void nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists) {
|
||||
if (IsAutoHidden()) {
|
||||
if (IsCollapsed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ void nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
|
|||
// created. There might be other problems if we don't do that.
|
||||
nsRubyContentFrame::Reflow(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
||||
|
||||
if (IsAutoHidden()) {
|
||||
if (IsCollapsed()) {
|
||||
// Reset the ISize. The BSize is not changed so that it won't
|
||||
// affect vertical positioning in unexpected way.
|
||||
WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
|
||||
|
|
|
@ -41,8 +41,8 @@ class nsRubyTextFrame final : public nsRubyContentFrame {
|
|||
const ReflowInput& aReflowInput,
|
||||
nsReflowStatus& aStatus) override;
|
||||
|
||||
bool IsAutoHidden() const {
|
||||
return HasAnyStateBits(NS_RUBY_TEXT_FRAME_AUTOHIDE);
|
||||
bool IsCollapsed() const {
|
||||
return HasAnyStateBits(NS_RUBY_TEXT_FRAME_COLLAPSED);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<meta charset="UTF-8">
|
||||
<title>CSS Reference: visibility: collapse hides ruby annotations</title>
|
||||
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
|
||||
<style>
|
||||
body { line-height: 5; }
|
||||
rt { font-size: 80%; }
|
||||
</style>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt>ちゅう</rt><rt>き</rt>
|
||||
</ruby><br>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt style="opacity: 0">ちゅう</rt><rt>き</rt>
|
||||
</ruby><br>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt></rt><rt>き</rt>
|
||||
</ruby>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<meta charset="UTF-8">
|
||||
<title>CSS Test: visibility: collapse hides ruby annotations</title>
|
||||
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-ruby-1/#hiding">
|
||||
<link rel="match" href="ruby-text-collapse-ref.html">
|
||||
<style>
|
||||
body { line-height: 5; }
|
||||
rt { font-size: 80%; }
|
||||
</style>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt>ちゅう</rt><rt>き</rt>
|
||||
</ruby><br>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt style="visibility: hidden">ちゅう</rt><rt>き</rt>
|
||||
</ruby><br>
|
||||
<ruby>
|
||||
<rb>昆</rb><rb>虫</rb><rb>記</rb>
|
||||
<rt>こん</rt><rt style="visibility: collapse">ちゅう</rt><rt>き</rt>
|
||||
</ruby>
|
Загрузка…
Ссылка в новой задаче