Changeset 136142 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 10:43:56 AM (12 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/12771885> Support ruby-position: {before, after}
https://bugs.webkit.org/show_bug.cgi?id=103569

Reviewed by Anders Carlsson.

Source/WebCore:

Specified in <http://www.w3.org/TR/2011/WD-css3-ruby-20110630/#rubypos>, the ruby-position
property takes four values: before, after, inter-character, and inline. This change adds
support for the values before and after.

Test: fast/ruby/position-after.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Handle ruby-position.

  • css/CSSParser.cpp:

(WebCore::isValidKeywordPropertyAndValue): Accept before and after as valid values for
ruby-position.
(WebCore::isKeywordPropertyID): Added ruby-position to the list of properties with keyword
values.
(WebCore::CSSParser::parseValue): Added ruby-position to the switch statement.

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from RubyPosition.
(WebCore::CSSPrimitiveValue::operator RubyPosition): Added mapping from CSSPrimitiveValue.

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty): Added ruby-position as an inherited property.

  • css/CSSPropertyNames.in: Added -webkit-ruby-position.
  • css/CSSValueKeywords.in: Added after and before.
  • css/StyleBuilder.cpp:

(WebCore::StyleBuilder::StyleBuilder): Added a handler for ruby-position.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyProperty): Added ruby-position.

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::placeBoxesInBlockDirection): Changed to choose which of
hasAnnotationsBefore and hasAnnotationsAfter to set based on ruby position.
(WebCore::InlineFlowBox::computeOverAnnotationAdjustment): Changed to adjust only for
ruby positioned before the base.
(WebCore::InlineFlowBox::computeUnderAnnotationAdjustment): Added adjustment for ruby
positioned after the base.

  • rendering/RenderRubyRun.cpp:

(WebCore::RenderRubyRun::layout): Account for ruby-position when positioning the ruby text
relative to the base.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::diff): Made a ruby-position difference a layout difference.

  • rendering/style/RenderStyle.h: Added rubyPosition(), setRubyPosition(), and

initialRubyPosition().

  • rendering/style/RenderStyleConstants.h: Added the RubyPosition enum.
  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData): Added initialized for
m_rubyPosition. Added copying the value of this member to the copy constructor.
(WebCore::StyleRareInheritedData::operator==): Added comparison of m_rubyPosition.

  • rendering/style/StyleRareInheritedData.h:

(StyleRareInheritedData): Added m_rubyPosition member variable.

LayoutTests:

  • fast/ruby/position-after.html: Added.
  • platform/mac/fast/ruby/position-after-expected.png: Added.
  • platform/mac/fast/ruby/position-after-expected.txt: Added.
Location:
trunk
Files:
3 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136132 r136142  
     12012-11-29  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/12771885> Support ruby-position: {before, after}
     4        https://bugs.webkit.org/show_bug.cgi?id=103569
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * fast/ruby/position-after.html: Added.
     9        * platform/mac/fast/ruby/position-after-expected.png: Added.
     10        * platform/mac/fast/ruby/position-after-expected.txt: Added.
     11
    1122012-11-29  Mike West  <mkwst@chromium.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r136136 r136142  
     12012-11-29  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/12771885> Support ruby-position: {before, after}
     4        https://bugs.webkit.org/show_bug.cgi?id=103569
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Specified in <http://www.w3.org/TR/2011/WD-css3-ruby-20110630/#rubypos>, the ruby-position
     9        property takes four values: before, after, inter-character, and inline. This change adds
     10        support for the values before and after.
     11
     12        Test: fast/ruby/position-after.html
     13
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Handle ruby-position.
     16        * css/CSSParser.cpp:
     17        (WebCore::isValidKeywordPropertyAndValue): Accept before and after as valid values for
     18        ruby-position.
     19        (WebCore::isKeywordPropertyID): Added ruby-position to the list of properties with keyword
     20        values.
     21        (WebCore::CSSParser::parseValue): Added ruby-position to the switch statement.
     22        * css/CSSPrimitiveValueMappings.h:
     23        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from RubyPosition.
     24        (WebCore::CSSPrimitiveValue::operator RubyPosition): Added mapping from CSSPrimitiveValue.
     25        * css/CSSProperty.cpp:
     26        (WebCore::CSSProperty::isInheritedProperty): Added ruby-position as an inherited property.
     27        * css/CSSPropertyNames.in: Added -webkit-ruby-position.
     28        * css/CSSValueKeywords.in: Added after and before.
     29        * css/StyleBuilder.cpp:
     30        (WebCore::StyleBuilder::StyleBuilder): Added a handler for ruby-position.
     31        * css/StyleResolver.cpp:
     32        (WebCore::StyleResolver::applyProperty): Added ruby-position.
     33        * rendering/InlineFlowBox.cpp:
     34        (WebCore::InlineFlowBox::placeBoxesInBlockDirection): Changed to choose which of
     35        hasAnnotationsBefore and hasAnnotationsAfter to set based on ruby position.
     36        (WebCore::InlineFlowBox::computeOverAnnotationAdjustment): Changed to adjust only for
     37        ruby positioned before the base.
     38        (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment): Added adjustment for ruby
     39        positioned after the base.
     40        * rendering/RenderRubyRun.cpp:
     41        (WebCore::RenderRubyRun::layout): Account for ruby-position when positioning the ruby text
     42        relative to the base.
     43        * rendering/style/RenderStyle.cpp:
     44        (WebCore::RenderStyle::diff): Made a ruby-position difference a layout difference.
     45        * rendering/style/RenderStyle.h: Added rubyPosition(), setRubyPosition(), and
     46        initialRubyPosition().
     47        * rendering/style/RenderStyleConstants.h: Added the RubyPosition enum.
     48        * rendering/style/StyleRareInheritedData.cpp:
     49        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Added initialized for
     50        m_rubyPosition. Added copying the value of this member to the copy constructor.
     51        (WebCore::StyleRareInheritedData::operator==): Added comparison of m_rubyPosition.
     52        * rendering/style/StyleRareInheritedData.h:
     53        (StyleRareInheritedData): Added m_rubyPosition member variable.
     54
    1552012-11-29  Tiancheng Jiang  <tijiang@rim.com>
    256
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r136080 r136142  
    20262026        case CSSPropertyRight:
    20272027            return getPositionOffsetValue(style.get(), CSSPropertyRight, m_node->document()->renderView());
     2028        case CSSPropertyWebkitRubyPosition:
     2029            return cssValuePool().createValue(style->rubyPosition());
    20282030        case CSSPropertyTableLayout:
    20292031            return cssValuePool().createValue(style->tableLayout());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r136080 r136142  
    891891            return true;
    892892        break;
     893
     894    case CSSPropertyWebkitRubyPosition:
     895        if (valueID == CSSValueBefore || valueID == CSSValueAfter)
     896            return true;
     897        break;
     898
    893899#if ENABLE(CSS3_TEXT)
    894900    case CSSPropertyWebkitTextAlignLast:
     
    10581064#endif
    10591065    case CSSPropertyWebkitRtlOrdering:
     1066    case CSSPropertyWebkitRubyPosition:
    10601067#if ENABLE(CSS3_TEXT)
    10611068    case CSSPropertyWebkitTextAlignLast:
     
    28742881#endif
    28752882    case CSSPropertyWebkitRtlOrdering:
     2883    case CSSPropertyWebkitRubyPosition:
    28762884#if ENABLE(CSS3_TEXT)
    28772885    case CSSPropertyWebkitTextAlignLast:
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r136053 r136142  
    28102810    ASSERT_NOT_REACHED();
    28112811    return TextCombineNone;
     2812}
     2813
     2814template<> inline CSSPrimitiveValue::CSSPrimitiveValue(RubyPosition position)
     2815    : CSSValue(PrimitiveClass)
     2816{
     2817    m_primitiveUnitType = CSS_IDENT;
     2818    switch (position) {
     2819    case RubyPositionBefore:
     2820        m_value.ident = CSSValueBefore;
     2821        break;
     2822    case RubyPositionAfter:
     2823        m_value.ident = CSSValueAfter;
     2824        break;
     2825    }
     2826}
     2827
     2828template<> inline CSSPrimitiveValue::operator RubyPosition() const
     2829{
     2830    switch (m_value.ident) {
     2831    case CSSValueBefore:
     2832        return RubyPositionBefore;
     2833    case CSSValueAfter:
     2834        return RubyPositionAfter;
     2835    }
     2836
     2837    ASSERT_NOT_REACHED();
     2838    return RubyPositionBefore;
    28122839}
    28132840
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r136080 r136142  
    325325    case CSSPropertyWebkitPrintColorAdjust:
    326326    case CSSPropertyWebkitRtlOrdering:
     327    case CSSPropertyWebkitRubyPosition:
    327328    case CSSPropertyWebkitTextCombine:
    328329#if ENABLE(CSS3_TEXT)
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r136080 r136142  
    352352-webkit-print-color-adjust
    353353-webkit-rtl-ordering
     354-webkit-ruby-position
    354355-webkit-text-combine
    355356-epub-text-combine = -webkit-text-combine
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r135314 r136142  
    872872horizontal-bt
    873873
     874// -webkit-ruby-position
     875after
     876before
     877
    874878// -webkit-text-emphasis-position
    875879over
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r136080 r136142  
    20512051#endif
    20522052    setPropertyHandler(CSSPropertyWebkitRtlOrdering, ApplyPropertyDefault<Order, &RenderStyle::rtlOrdering, Order, &RenderStyle::setRTLOrdering, Order, &RenderStyle::initialRTLOrdering>::createHandler());
     2053    setPropertyHandler(CSSPropertyWebkitRubyPosition, ApplyPropertyDefault<RubyPosition, &RenderStyle::rubyPosition, RubyPosition, &RenderStyle::setRubyPosition, RubyPosition, &RenderStyle::initialRubyPosition>::createHandler());
    20532054    setPropertyHandler(CSSPropertyWebkitTextCombine, ApplyPropertyDefault<TextCombine, &RenderStyle::textCombine, TextCombine, &RenderStyle::setTextCombine, TextCombine, &RenderStyle::initialTextCombine>::createHandler());
    20542055    setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r136105 r136142  
    38063806#endif
    38073807    case CSSPropertyWebkitRtlOrdering:
     3808    case CSSPropertyWebkitRubyPosition:
    38083809    case CSSPropertyWebkitTextCombine:
    38093810#if ENABLE(CSS3_TEXT)
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r135841 r136142  
    671671                // Really this is a workaround hack for the fact that ruby should have been done as line layout and not done using
    672672                // inline-block.
    673                 if (!renderer()->style()->isFlippedLinesWritingMode())
     673                if (renderer()->style()->isFlippedLinesWritingMode() == (curr->renderer()->style()->rubyPosition() == RubyPositionAfter))
    674674                    hasAnnotationsBefore = true;
    675675                else
     
    14621462            result = max(result, toInlineFlowBox(curr)->computeOverAnnotationAdjustment(allowedPosition));
    14631463       
    1464         if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun()) {
     1464        if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && curr->renderer()->style()->rubyPosition() == RubyPositionBefore) {
    14651465            RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
    14661466            RenderRubyText* rubyText = rubyRun->rubyText();
     
    15101510            result = max(result, toInlineFlowBox(curr)->computeUnderAnnotationAdjustment(allowedPosition));
    15111511
     1512        if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun() && curr->renderer()->style()->rubyPosition() == RubyPositionAfter) {
     1513            RenderRubyRun* rubyRun = toRenderRubyRun(curr->renderer());
     1514            RenderRubyText* rubyText = rubyRun->rubyText();
     1515            if (!rubyText)
     1516                continue;
     1517
     1518            if (rubyRun->style()->isFlippedLinesWritingMode()) {
     1519                LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
     1520                if (topOfFirstRubyTextLine >= 0)
     1521                    continue;
     1522                topOfFirstRubyTextLine += curr->logicalTop();
     1523                result = max(result, allowedPosition - topOfFirstRubyTextLine);
     1524            } else {
     1525                LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + (rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logicalHeight());
     1526                if (bottomOfLastRubyTextLine <= curr->logicalHeight())
     1527                    continue;
     1528                bottomOfLastRubyTextLine += curr->logicalTop();
     1529                result = max(result, bottomOfLastRubyTextLine - allowedPosition);
     1530            }
     1531        }
     1532
    15121533        if (curr->isInlineTextBox()) {
    15131534            RenderStyle* style = curr->renderer()->style(isFirstLineStyle());
  • trunk/Source/WebCore/rendering/RenderRubyRun.cpp

    r131938 r136142  
    247247    }
    248248
    249     if (!style()->isFlippedLinesWritingMode()) {
     249    if (style()->isFlippedLinesWritingMode() == (style()->rubyPosition() == RubyPositionAfter)) {
    250250        LayoutUnit firstLineTop = 0;
    251251        if (RenderRubyBase* rb = rubyBase()) {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r136001 r136142  
    479479            || rareInheritedData->hyphenationString != other->rareInheritedData->hyphenationString
    480480            || rareInheritedData->locale != other->rareInheritedData->locale
     481            || rareInheritedData->m_rubyPosition != other->rareInheritedData->m_rubyPosition
    481482            || rareInheritedData->textEmphasisMark != other->rareInheritedData->textEmphasisMark
    482483            || rareInheritedData->textEmphasisPosition != other->rareInheritedData->textEmphasisPosition
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r136080 r136142  
    836836    TextEmphasisPosition textEmphasisPosition() const { return static_cast<TextEmphasisPosition>(rareInheritedData->textEmphasisPosition); }
    837837    const AtomicString& textEmphasisMarkString() const;
    838    
     838
     839    RubyPosition rubyPosition() const { return static_cast<RubyPosition>(rareInheritedData->m_rubyPosition); }
     840
    839841    // Return true if any transform related property (currently transform, transformStyle3D or perspective)
    840842    // indicates that we are transforming
     
    13001302    void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(rareInheritedData, textEmphasisCustomMark, mark); }
    13011303    void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(rareInheritedData, textEmphasisPosition, position); }
     1304
     1305    void setRubyPosition(RubyPosition position) { SET_VAR(rareInheritedData, m_rubyPosition, position); }
    13021306
    13031307#if ENABLE(CSS_FILTERS)
     
    16171621    static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom; }
    16181622    static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; }
     1623    static RubyPosition initialRubyPosition() { return RubyPositionBefore; }
    16191624    static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
    16201625    static ImageOrientationEnum initialImageOrientation() { return OriginTopLeft; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r136053 r136142  
    476476enum WrapThrough { WrapThroughWrap, WrapThroughNone };
    477477
     478enum RubyPosition { RubyPositionBefore, RubyPositionAfter };
     479
    478480#if ENABLE(DRAGGABLE_REGION)
    479481enum DraggableRegionMode { DraggableRegionNone, DraggableRegionDrag, DraggableRegionNoDrag };
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r135788 r136142  
    103103    , m_textAlignLast(RenderStyle::initialTextAlignLast())
    104104#endif // CSS3_TEXT
     105    , m_rubyPosition(RenderStyle::initialRubyPosition())
    105106    , hyphenationLimitBefore(-1)
    106107    , hyphenationLimitAfter(-1)
     
    169170    , m_textAlignLast(o.m_textAlignLast)
    170171#endif // CSS3_TEXT
     172    , m_rubyPosition(o.m_rubyPosition)
    171173    , hyphenationString(o.hyphenationString)
    172174    , hyphenationLimitBefore(o.hyphenationLimitBefore)
     
    261263        && m_textAlignLast == o.m_textAlignLast
    262264#endif // CSS3_TEXT
     265        && m_rubyPosition == o.m_rubyPosition
    263266        && m_lineSnap == o.m_lineSnap
    264267#if ENABLE(CSS_VARIABLES)
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r135788 r136142  
    117117    unsigned m_textAlignLast : 3; // ETextAlignLast
    118118#endif // CSS3_TEXT
     119    unsigned m_rubyPosition : 1; // RubyPosition
    119120
    120121    AtomicString hyphenationString;
Note: See TracChangeset for help on using the changeset viewer.