⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 179722 in webkit


Ignore:
Timestamp:
Feb 5, 2015, 4:32:59 PM (12 years ago)
Author:
Lucas Forschler
Message:

Merged r179366. rdar://problem/19432900

Location:
branches/safari-600.1.4.15-branch
Files:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog

    r179711 r179722  
     12015-02-05  Lucas Forschler  <lforschler@apple.com>
     2
     3        Merge r179366
     4
     5    2015-01-20  David Hyatt  <hyatt@apple.com>
     6
     7            Japanese line breaking rules need to be respected before and after Ruby.
     8            https://bugs.webkit.org/show_bug.cgi?id=91588
     9            <rdar://problem/17306535>
     10
     11            Reviewed by Dean Jackson.
     12
     13            * fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt:
     14            * fast/ruby/ruby-block-style-not-updated-with-before-after-content.html:
     15            * fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt:
     16            * fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html:
     17            * fast/ruby/ruby-punctuation-avoid-breaking-expected.html: Added.
     18            * fast/ruby/ruby-punctuation-avoid-breaking.html: Added.
     19
    1202015-02-05  Lucas Forschler  <lforschler@apple.com>
    221
  • branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt

    r94543 r179722  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderRuby (block) {RUBY} at (0,0) size 784x384 [color=#0000FF]
    7         RenderInline (generated) at (0,0) size 512x128 [color=#FFA500]
    8           RenderText at (0,0) size 512x128
    9             text run at (0,0) width 512: "1234"
     7        RenderInline (generated) at (0,0) size 640x128 [color=#FFA500]
     8          RenderText at (0,0) size 640x128
     9            text run at (0,0) width 640: "1234 "
    1010        RenderRubyRun (anonymous) at (0,128) size 512x128
    1111          RenderRubyBase (anonymous) at (0,0) size 512x128
  • branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content.html

    r94582 r179722  
    55#test::before
    66{
    7     content: "1234";
     7    content: "1234 ";
    88    color: orange;
    99}
    1010#test::after
    1111{
    12     content: "4578";
     12    content: " 4578";
    1313    color: yellow;
    1414}
  • branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt

    r94543 r179722  
    55    RenderBody {BODY} at (8,8) size 784x584
    66      RenderBlock (anonymous) at (0,0) size 784x384
    7         RenderRuby (inline) {RUBY} at (0,0) size 512x384 [color=#0000FF]
    8           RenderInline (generated) at (0,0) size 512x128 [color=#FFA500]
    9             RenderText at (0,0) size 512x128
    10               text run at (0,0) width 512: "1234"
     7        RenderRuby (inline) {RUBY} at (0,0) size 640x384 [color=#0000FF]
     8          RenderInline (generated) at (0,0) size 640x128 [color=#FFA500]
     9            RenderText at (0,0) size 640x128
     10              text run at (0,0) width 640: "1234 "
    1111          RenderRubyRun (anonymous) at (0,128) size 512x128
    1212            RenderRubyBase (anonymous) at (0,0) size 512x128
  • branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html

    r94582 r179722  
    55#test::before
    66{
    7     content: "1234";
     7    content: "1234 ";
    88    color: orange;
    99}
    1010#test::after
    1111{
    12     content: "4578";
     12    content: " 4578";
    1313    color: yellow;
    1414}
  • branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog

    r179711 r179722  
     12015-02-05  Lucas Forschler  <lforschler@apple.com>
     2
     3        Merge r179366
     4
     5    2015-01-20  David Hyatt  <hyatt@apple.com>
     6
     7            Japanese line breaking rules need to be respected before and after Ruby.
     8            https://bugs.webkit.org/show_bug.cgi?id=91588
     9            <rdar://problem/17306535>
     10
     11            Reviewed by Dean Jackson.
     12
     13            Added fast/ruby/ruby-punctuation-avoid-breaking.html.
     14
     15            This patch has to add support for following line breaking rules at both
     16            sides of a Ruby boundary. For breaking before a Ruby, unfortunately we
     17            just hard-code the rules (and apply this hard-coding only to Ruby and not
     18            to other inline replaced elements).
     19
     20            For breaking after a Ruby we do better. The Ruby run caches its prior characters
     21            and line layout is able to obtain them and use them when deciding whether or not
     22            to break. This means for the "after" side of a Ruby, we're able to behave the same
     23            as if no Ruby was used.
     24
     25            * rendering/RenderBlockFlow.h:
     26            (WebCore::RenderBlockFlow::cachePriorCharactersIfNeeded):
     27            * rendering/RenderBlockLineLayout.cpp:
     28            (WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
     29            * rendering/RenderRubyBase.cpp:
     30            (WebCore::RenderRubyBase::cachePriorCharactersIfNeeded):
     31            * rendering/RenderRubyBase.h:
     32            * rendering/RenderRubyRun.cpp:
     33            (WebCore::RenderRubyRun::RenderRubyRun):
     34            (WebCore::RenderRubyRun::updatePriorContextFromCachedBreakIterator):
     35            (WebCore::RenderRubyRun::canBreakBefore):
     36            * rendering/RenderRubyRun.h:
     37            * rendering/RenderRubyText.cpp:
     38            (WebCore::RenderRubyText::canBreakBefore):
     39            * rendering/RenderRubyText.h:
     40            * rendering/line/BreakingContextInlineHeaders.h:
     41            (WebCore::BreakingContext::handleReplaced):
     42            (WebCore::BreakingContext::canBreakAtThisPosition):
     43            (WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):
     44
    1452015-02-05  Lucas Forschler  <lforschler@apple.com>
    246
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/InlineBox.h

    r179133 r179722  
    2323
    2424#include "RenderBoxModelObject.h"
     25#include "TextBreakIterator.h"
    2526#include "TextDirection.h"
     27
    2628
    2729namespace WebCore {
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.h

    r179133 r179722  
    463463    virtual void computeColumnCountAndWidth();
    464464    virtual bool requiresColumns(int) const;
    465 
     465   
     466    virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) {};
     467   
    466468private:
    467469    bool recomputeLogicalWidthAndColumnWidth();
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r179138 r179722  
    11731173        WordMeasurements wordMeasurements;
    11741174        end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
     1175        cachePriorCharactersIfNeeded(renderTextInfo.m_lineBreakIterator);
    11751176        renderTextInfo.m_lineBreakIterator.resetPriorContext();
    11761177        if (resolver.position().atEnd()) {
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.cpp

    r179133 r179722  
    163163}
    164164
     165void RenderRubyBase::cachePriorCharactersIfNeeded(const LazyLineBreakIterator& lineBreakIterator)
     166{
     167    auto* run = rubyRun();
     168    if (run)
     169        run->setCachedPriorCharacters(lineBreakIterator.lastCharacter(), lineBreakIterator.secondToLastCharacter());
     170}
     171
    165172} // namespace WebCore
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h

    r179133 r179722  
    5959        m_isAfterExpansion = true;
    6060    }
     61   
     62    virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
    6163
    6264private:
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyRun.cpp

    r179138 r179722  
    4444RenderRubyRun::RenderRubyRun(Document& document, PassRef<RenderStyle> style)
    4545    : RenderBlockFlow(document, WTF::move(style))
     46    , m_lastCharacter(0)
     47    , m_secondToLastCharacter(0)
    4648{
    4749    setReplaced(true);
     
    331333}
    332334
     335void RenderRubyRun::updatePriorContextFromCachedBreakIterator(LazyLineBreakIterator& iterator) const
     336{
     337    iterator.setPriorContext(m_lastCharacter, m_secondToLastCharacter);
     338}
     339
     340bool RenderRubyRun::canBreakBefore(const LazyLineBreakIterator& iterator) const
     341{
     342    RenderRubyText* rubyText = this->rubyText();
     343    if (!rubyText)
     344        return true;
     345    return rubyText->canBreakBefore(iterator);
     346}
     347
    333348} // namespace WebCore
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyRun.h

    r179138 r179722  
    6868    static RenderRubyRun* staticCreateRubyRun(const RenderObject* parentRuby);
    6969
     70    void updatePriorContextFromCachedBreakIterator(LazyLineBreakIterator&) const;
     71    void setCachedPriorCharacters(UChar last, UChar secondToLast)
     72    {
     73        m_lastCharacter = last;
     74        m_secondToLastCharacter = secondToLast;
     75    }
     76    bool canBreakBefore(const LazyLineBreakIterator&) const;
     77   
    7078protected:
    7179    RenderRubyBase* createRubyBase() const;
     
    7684    virtual bool createsAnonymousWrapper() const { return true; }
    7785    virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
     86
     87private:
     88    UChar m_lastCharacter;
     89    UChar m_secondToLastCharacter;
    7890};
    7991
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp

    r179071 r179722  
    9494}
    9595
     96bool RenderRubyText::canBreakBefore(const LazyLineBreakIterator& iterator) const
     97{
     98    // FIXME: It would be nice to improve this so that it isn't just hard-coded, but lookahead in this
     99    // case is particularly problematic.
     100
     101    if (!iterator.priorContextLength())
     102        return true;
     103    UChar ch = iterator.lastCharacter();
     104    ULineBreak lineBreak = (ULineBreak)u_getIntPropertyValue(ch, UCHAR_LINE_BREAK);
     105    // UNICODE LINE BREAKING ALGORITHM
     106    // http://www.unicode.org/reports/tr14/
     107    // And Requirements for Japanese Text Layout, 3.1.7 Characters Not Starting a Line
     108    // http://www.w3.org/TR/2012/NOTE-jlreq-20120403/#characters_not_starting_a_line
     109    switch (lineBreak) {
     110    case U_LB_NONSTARTER:
     111    case U_LB_CLOSE_PARENTHESIS:
     112    case U_LB_CLOSE_PUNCTUATION:
     113    case U_LB_EXCLAMATION:
     114    case U_LB_BREAK_SYMBOLS:
     115    case U_LB_INFIX_NUMERIC:
     116    case U_LB_ZWSPACE:
     117    case U_LB_WORD_JOINER:
     118        return false;
     119    default:
     120        break;
     121    }
     122    // Special care for Requirements for Japanese Text Layout
     123    switch (ch) {
     124    case 0x2019: // RIGHT SINGLE QUOTATION MARK
     125    case 0x201D: // RIGHT DOUBLE QUOTATION MARK
     126    case 0x00BB: // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
     127    case 0x2010: // HYPHEN
     128    case 0x2013: // EN DASH
     129    case 0x300C: // LEFT CORNER BRACKET
     130        return false;
     131    default:
     132        break;
     133    }
     134    return true;
     135}
     136
    96137} // namespace WebCore
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h

    r179071 r179722  
    4646   
    4747    RenderRubyRun* rubyRun() const;
    48 
     48   
     49    bool canBreakBefore(const LazyLineBreakIterator&) const;
     50   
    4951private:
    5052    virtual const char* renderName() const override { return "RenderRubyText"; }
  • branches/safari-600.1.4.15-branch/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h

    r167628 r179722  
    414414
    415415    // Break on replaced elements if either has normal white-space.
    416     if ((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!m_current.renderer()->isImage() || m_allowImagesToBreak)) {
     416    if ((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!m_current.renderer()->isImage() || m_allowImagesToBreak)
     417        && (!m_current.renderer()->isRubyRun() || toRenderRubyRun(m_current.renderer())->canBreakBefore(m_renderTextInfo.m_lineBreakIterator))) {
    417418        m_width.commit();
    418419        m_lineBreak.moveToStartOf(m_current.renderer());
     
    443444    } else
    444445        m_width.addUncommittedWidth(replacedLogicalWidth);
    445     if (m_current.renderer()->isRubyRun())
     446    if (m_current.renderer()->isRubyRun()) {
    446447        m_width.applyOverhang(toRenderRubyRun(m_current.renderer()), m_lastObject, m_nextObject);
    447     // Update prior line break context characters, using U+FFFD (OBJECT REPLACEMENT CHARACTER) for replaced element.
    448     m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter);
     448        toRenderRubyRun(m_current.renderer())->updatePriorContextFromCachedBreakIterator(m_renderTextInfo.m_lineBreakIterator);
     449    } else {
     450        // Update prior line break context characters, using U+FFFD (OBJECT REPLACEMENT CHARACTER) for replaced element.
     451        m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter);
     452    }
    449453}
    450454
     
    952956    bool currentIsTextOrEmptyInline = m_current.renderer()->isText() || (m_current.renderer()->isRenderInline() && isEmptyInline(toRenderInline(*m_current.renderer())));
    953957    if (!currentIsTextOrEmptyInline)
    954         return m_autoWrap;
     958        return m_autoWrap && !m_current.renderer()->isRubyRun();
    955959
    956960    bool canBreakHere = !m_currentCharacterIsSpace && textBeginsWithBreakablePosition(m_nextObject);
     
    9991003    if (!m_current.renderer()->isFloatingOrOutOfFlowPositioned()) {
    10001004        m_lastObject = m_current.renderer();
    1001         if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage() || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMarker(*m_lastObject).isInside())) {
     1005        if (m_lastObject->isReplaced() && m_autoWrap && !m_lastObject->isRubyRun() && (!m_lastObject->isImage() || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMarker(*m_lastObject).isInside())) {
    10021006            m_width.commit();
    10031007            m_lineBreak.moveToStartOf(m_nextObject);
Note: See TracChangeset for help on using the changeset viewer.