[webkit-changes] [WebKit/WebKit] 44bf0d: Basic support for CSS based Ruby in IFC

Antti Koivisto noreply at github.com
Wed Sep 13 01:25:22 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 44bf0d71007ce85571ea893edef23a9b3935f7a8
      https://github.com/WebKit/WebKit/commit/44bf0d71007ce85571ea893edef23a9b3935f7a8
  Author: Antti Koivisto <antti at apple.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-input.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSPrimitiveValueMappings.h
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/CSSValueKeywords.in
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.h
    A Source/WebCore/css/ruby.css
    M Source/WebCore/html/RubyElement.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h
    M Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp
    M Source/WebCore/layout/layouttree/LayoutBox.cpp
    M Source/WebCore/layout/layouttree/LayoutBox.h
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/style/RenderStyleConstants.cpp
    M Source/WebCore/rendering/style/RenderStyleConstants.h
    M Source/WebCore/rendering/style/RenderStyleInlines.h
    M Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
    M Source/WebCore/rendering/updating/RenderTreeBuilderInline.cpp
    M Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp
    M Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h
    M Source/WebCore/style/StyleAdjuster.cpp
    M Source/WebCore/style/UserAgentStyle.cpp
    M Source/WebCore/style/UserAgentStyle.h

  Log Message:
  -----------
  Basic support for CSS based Ruby in IFC
https://bugs.webkit.org/show_bug.cgi?id=261468
rdar://115370429

Reviewed by Alan Baradlay.

The current Ruby implementation uses special elements and renderers.

This patch implements basic support for CSS based ruby in IFC:
- Adds display property values 'ruby', 'block-ruby', 'ruby-base' and 'ruby-text' but does not expose them outside the user
agent stylesheet.
- Adds render tree building support for these values.
- Sketches an IFC implementation that is able to generate annotation boxes in the simple case. Layout is not affected.

The feature is behind a flag and is disabled by default.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:

Add a setting.

* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSPrimitiveValueMappings.h:
(WebCore::toCSSValueID):
(WebCore::fromCSSValueID):

Use switch for robustness and readability.

* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeDisplay):

Pass the parsing mode so we can limit the new properties to the UA sheet.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.h:
* Source/WebCore/css/ruby.css: Added.

Add a UA stylesheet that sets the display property values for HTML ruby elements.

* Source/WebCore/html/RubyElement.cpp:
(WebCore::RubyElement::createElementRenderer):

Skip the special case renderer generation if enabled.

* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::InlineItemsBuilder::collectInlineItems):

Skip over ruby annotation boxes when collecting inline items.
Ruby bases simply map to inline boxes.

* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::appendInlineBoxDisplayBox):
(WebCore::Layout::InlineDisplayContentBuilder::appendAssociatedRubyAnnotationBoxIfNeeded):

If an inline box has an associated ruby box it is actually a ruby base.
Generate an annotation box and place it above the base.

* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h:
* Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::updateRenderTreePositions):

Place the annotation box renderer after layout.

* Source/WebCore/layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::isInlineLevelBox const):
(WebCore::Layout::Box::isInlineBox const):
(WebCore::Layout::Box::isBlockContainer const):
(WebCore::Layout::Box::isRubyAnnotationBox const):
(WebCore::Layout::Box::isInternalRubyBox const):
(WebCore::Layout::Box::associatedRubyAnnotationBox const):

Find the annotation if any.

* Source/WebCore/layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::isImage const):
(WebCore::Layout::Box::isInternalRubyBox const): Deleted.
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::createFor):

Use generic renderers for ruby display values.

* Source/WebCore/rendering/style/RenderStyleConstants.cpp:
(WebCore::operator<<):
* Source/WebCore/rendering/style/RenderStyleConstants.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::isDisplayBlockType):
(WebCore::RenderStyle::isDisplayInlineType):
* Source/WebCore/rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::attachInternal):
* Source/WebCore/rendering/updating/RenderTreeBuilderInline.cpp:
(WebCore::RenderTreeBuilder::Inline::splitInlines):

With ruby we may find anonymous inlines when splitting inlines for continuations. Just ignore them, they provide no styling.

* Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::findOrCreateParentForStyleBasedRubyChild):

Generate anonymous boxes for ruby so we get structure like

<ruby><ruby-base>base content</ruby-base><ruby-annotation>annotation content</ruby-annotation></ruby>

* Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h:
* Source/WebCore/style/StyleAdjuster.cpp:
(WebCore::Style::equivalentBlockDisplay):
(WebCore::Style::equivalentInlineDisplay):

Add inlinification function.

(WebCore::Style::shouldInlinifyForRuby):
(WebCore::Style::Adjuster::adjust const):

Inlinify children of ruby boxes.

* Source/WebCore/style/UserAgentStyle.cpp:
(WebCore::Style::UserAgentStyle::ensureDefaultStyleSheetsForElement):

Include ruby.css if enabled.

* Source/WebCore/style/UserAgentStyle.h:

Canonical link: https://commits.webkit.org/267937@main




More information about the webkit-changes mailing list