Changeset 69642 in webkit


Ignore:
Timestamp:
Oct 13, 2010 12:25:57 AM (13 years ago)
Author:
rolandsteiner@chromium.org
Message:

2010-10-07 Roland Steiner <rolandsteiner@chromium.org>

Reviewed by Davit Hyatt.

Bug 41040 - :before/:after content should not become part of a ruby base
https://bugs.webkit.org/show_bug.cgi?id=41040

Also related to:
https://bugs.webkit.org/show_bug.cgi?id=40895.
https://bugs.webkit.org/show_bug.cgi?id=43722.

Layout tests: verify that generated content is outside of the ruby base.
Also, tests shouldn't crash.

  • fast/ruby/after-doesnt-crash-expected.txt:
  • fast/ruby/after-doesnt-crash.html: Added.
  • fast/ruby/before-doesnt-crash.html:
  • fast/ruby/ruby-beforeafter.html: Added.
  • platform/gtk/Skipped:
  • platform/mac/fast/ruby/ruby-beforeafter-expected.checksum: Added.
  • platform/mac/fast/ruby/ruby-beforeafter-expected.png: Added.
  • platform/mac/fast/ruby/ruby-beforeafter-expected.txt: Added.
  • platform/qt/Skipped:

Explicitly handle :before and :after content in the default way.

Test: fast/ruby/ruby-beforeafter.html

fast/ruby/after-doesnt-crash.html

  • rendering/RenderObject.h: (WebCore::RenderObject::isBeforeContent):
  • rendering/RenderRuby.cpp: (WebCore::lastRubyRun): (WebCore::RenderRubyAsInline::addChild): (WebCore::RenderRubyAsInline::removeChild): (WebCore::RenderRubyAsBlock::addChild): (WebCore::RenderRubyAsBlock::removeChild):
Location:
trunk
Files:
5 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69640 r69642  
     12010-10-12  Roland Steiner  <rolandsteiner@chromium.org>
     2
     3        Reviewed by Davit Hyatt.
     4
     5        Bug 41040 - :before/:after content should not become part of a ruby base
     6        https://bugs.webkit.org/show_bug.cgi?id=41040
     7
     8        Also related to:
     9        https://bugs.webkit.org/show_bug.cgi?id=40895.
     10        https://bugs.webkit.org/show_bug.cgi?id=43722.
     11
     12        Layout tests: verify that generated content is outside of the ruby base.
     13        Also, tests shouldn't crash.
     14
     15        * fast/ruby/after-doesnt-crash-expected.txt:
     16        * fast/ruby/after-doesnt-crash.html: Added.
     17        * fast/ruby/before-doesnt-crash.html:
     18        * fast/ruby/ruby-beforeafter.html: Added.
     19        * platform/gtk/Skipped:
     20        * platform/mac/fast/ruby/ruby-beforeafter-expected.checksum: Added.
     21        * platform/mac/fast/ruby/ruby-beforeafter-expected.png: Added.
     22        * platform/mac/fast/ruby/ruby-beforeafter-expected.txt: Added.
     23        * platform/qt/Skipped:
     24
    1252010-10-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    226
  • trunk/LayoutTests/fast/ruby/after-doesnt-crash.html

    r69641 r69642  
    22  <head>
    33    <style>
    4       :before{
    5         content:""
    6       };
     4      :after {
     5        content: ""
     6      }
    77    </style>
    88  </head>
    99  <body onload="document.linkColor=0;">
    1010    <ruby>
     11      <rt></rt>
     12    </ruby>
     13    <ruby style="float: left">
    1114      <rt></rt>
    1215    </ruby>
  • trunk/LayoutTests/fast/ruby/before-doesnt-crash-expected.txt

    r66371 r69642  
    11 
    2  This test passes if it doesn't crash.
     2 
     3This test passes if it doesn't crash.
  • trunk/LayoutTests/fast/ruby/before-doesnt-crash.html

    r66371 r69642  
    22  <head>
    33    <style>
    4       :before{
    5         content:""
    6       };
     4      :before {
     5        content: ""
     6      }
    77    </style>
    88  </head>
    99  <body onload="document.linkColor=0;">
    1010    <ruby>
     11      <rt></rt>
     12    </ruby>
     13    <ruby style="float: left">
    1114      <rt></rt>
    1215    </ruby>
  • trunk/LayoutTests/platform/gtk/Skipped

    r69620 r69642  
    50885088
    50895089# Ruby tests
     5090fast/ruby/ruby-beforeafter.html
    50905091fast/ruby/ruby-empty-rt.html
    50915092fast/ruby/ruby-inline-table.html
  • trunk/LayoutTests/platform/qt/Skipped

    r69597 r69642  
    781781
    782782# ------- missing ruby annotation support for japanese fonts
     783fast/ruby/ruby-beforeafter.html
    783784fast/ruby/ruby-empty-rt.html
    784785fast/ruby/ruby-length.html
  • trunk/WebCore/ChangeLog

    r69640 r69642  
     12010-10-12  Roland Steiner  <rolandsteiner@chromium.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Bug 41040 - :before/:after content should not become part of a ruby base
     6        https://bugs.webkit.org/show_bug.cgi?id=41040
     7
     8        Also related to:
     9        https://bugs.webkit.org/show_bug.cgi?id=40895.
     10        https://bugs.webkit.org/show_bug.cgi?id=43722.
     11
     12        Explicitly handle :before and :after content in the default way.
     13
     14        Test: fast/ruby/ruby-beforeafter.html
     15              fast/ruby/after-doesnt-crash.html
     16
     17        * rendering/RenderObject.h:
     18        (WebCore::RenderObject::isBeforeContent):
     19        * rendering/RenderRuby.cpp:
     20        (WebCore::lastRubyRun):
     21        (WebCore::RenderRubyAsInline::addChild):
     22        (WebCore::RenderRubyAsInline::removeChild):
     23        (WebCore::RenderRubyAsBlock::addChild):
     24        (WebCore::RenderRubyAsBlock::removeChild):
     25
    1262010-10-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    227
  • trunk/WebCore/rendering/RenderObject.h

    r69279 r69642  
    292292    bool isHTMLMarquee() const;
    293293
     294    inline bool isBeforeContent() const;
    294295    inline bool isAfterContent() const;
     296    static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
    295297    static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
    296298
     
    862864}
    863865
     866inline bool RenderObject::isBeforeContent() const
     867{
     868    if (style()->styleType() != BEFORE)
     869        return false;
     870    // Text nodes don't have their own styles, so ignore the style on a text node.
     871    if (isText() && !isBR())
     872        return false;
     873    return true;
     874}
     875
    864876inline bool RenderObject::isAfterContent() const
    865877{
  • trunk/WebCore/rendering/RenderRuby.cpp

    r66371 r69642  
    4545    if (child && ruby->isAfterContent(child))
    4646        child = child->previousSibling();
    47     ASSERT(!child || child->isRubyRun());
    48     return static_cast<RenderRubyRun*>(child);
     47    ASSERT(!child || child->isRubyRun() || child->isBeforeContent());
     48    return child && child->isRubyRun() ? static_cast<RenderRubyRun*>(child) : 0;
    4949}
    5050
     
    7676void RenderRubyAsInline::addChild(RenderObject* child, RenderObject* beforeChild)
    7777{
    78     // Note: ':after' content is handled implicitly below
    79 
     78    // Insert :before and :after content outside of ruby runs.
     79    if (child->isBeforeContent() || child->isAfterContent()) {
     80        RenderInline::addChild(child, beforeChild);
     81        return;
     82    }
     83
     84    // If the child is a ruby run, just add it normally.
    8085    if (child->isRubyRun()) {
    8186        RenderInline::addChild(child, beforeChild);
    82         return;
    83     }
    84 
    85     if (beforeChild && !isAfterContent(beforeChild) && !beforeChild->isRubyRun()) {
    86         if (RenderRubyRun* run = findRubyRunParent(beforeChild)) {
    87             run->addChild(child, beforeChild);
    88             return;
    89         }
    90         ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
    91         // Emergency fallback: fall through and just append.
    92     }
    93 
    94     // If the new child would be appended, try to add the child to the previous run
    95     // if possible, or create a new run otherwise.
    96     // (The RenderRubyRun object will handle the details)
    97     RenderRubyRun* lastRun = lastRubyRun(this);
    98     if (!lastRun || lastRun->hasRubyText()) {
    99         lastRun = RenderRubyRun::staticCreateRubyRun(this);
    100         RenderInline::addChild(lastRun);
    101     }
    102     lastRun->addChild(child);
    103 }
    104 
    105 void RenderRubyAsInline::removeChild(RenderObject* child)
    106 {
    107     // If the child's parent is *this, i.e. a ruby run or ':after' content,
    108     // just use the normal remove method.
    109     if (child->parent() == this) {
    110         ASSERT(child->isRubyRun() || child->isAfterContent());
    111         RenderInline::removeChild(child);
    112         return;
    113     }
    114 
    115     // Find the containing run
    116     RenderRubyRun* run = findRubyRunParent(child);
    117     ASSERT(run);
    118     run->removeChild(child);
    119 }
    120 
    121 
    122 //=== ruby as block object ===
    123 
    124 RenderRubyAsBlock::RenderRubyAsBlock(Node* node)
    125     : RenderBlock(node)
    126 {
    127 }
    128 
    129 RenderRubyAsBlock::~RenderRubyAsBlock()
    130 {
    131 }
    132 
    133 bool RenderRubyAsBlock::isChildAllowed(RenderObject* child, RenderStyle*) const
    134 {
    135     return child->isRubyText()
    136         || child->isRubyRun()
    137         || child->isInline();
    138 }
    139 
    140 void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild)
    141 {
    142     // Note: ':after' content is handled implicitely below
    143 
    144     // if child is a ruby run, just add it normally
    145     if (child->isRubyRun()) {
    146         RenderBlock::addChild(child, beforeChild);
    14787        return;
    14888    }
     
    15898            return;
    15999        }
    160         ASSERT(false); // beforeChild should always have a run as parent!
     100        ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
     101        // Emergency fallback: fall through and just append.
     102    }
     103
     104    // If the new child would be appended, try to add the child to the previous run
     105    // if possible, or create a new run otherwise.
     106    // (The RenderRubyRun object will handle the details)
     107    RenderRubyRun* lastRun = lastRubyRun(this);
     108    if (!lastRun || lastRun->hasRubyText()) {
     109        lastRun = RenderRubyRun::staticCreateRubyRun(this);
     110        RenderInline::addChild(lastRun);
     111    }
     112    lastRun->addChild(child);
     113}
     114
     115void RenderRubyAsInline::removeChild(RenderObject* child)
     116{
     117    // If the child's parent is *this (a ruby run or :before or :after content),
     118    // just use the normal remove method.
     119    if (child->isRubyRun() || child->isBeforeContent() || child->isAfterContent()) {
     120        RenderInline::removeChild(child);
     121        return;
     122    }
     123
     124    // Otherwise find the containing run and remove it from there.
     125    ASSERT(child->parent() != this);
     126    RenderRubyRun* run = findRubyRunParent(child);
     127    ASSERT(run);
     128    run->removeChild(child);
     129}
     130
     131
     132//=== ruby as block object ===
     133
     134RenderRubyAsBlock::RenderRubyAsBlock(Node* node)
     135    : RenderBlock(node)
     136{
     137}
     138
     139RenderRubyAsBlock::~RenderRubyAsBlock()
     140{
     141}
     142
     143bool RenderRubyAsBlock::isChildAllowed(RenderObject* child, RenderStyle*) const
     144{
     145    return child->isRubyText()
     146        || child->isRubyRun()
     147        || child->isInline();
     148}
     149
     150void RenderRubyAsBlock::addChild(RenderObject* child, RenderObject* beforeChild)
     151{
     152    // Insert :before and :after content outside of ruby runs.
     153    if (child->isBeforeContent() || child->isAfterContent()) {
     154        RenderBlock::addChild(child, beforeChild);
     155        return;
     156    }
     157
     158    // If the child is a ruby run, just add it normally.
     159    if (child->isRubyRun()) {
     160        RenderBlock::addChild(child, beforeChild);
     161        return;
     162    }
     163
     164    if (beforeChild && !isAfterContent(beforeChild)) {
     165        // insert child into run
     166        ASSERT(!beforeChild->isRubyRun());
     167        RenderObject* run = beforeChild;
     168        while (run && !run->isRubyRun())
     169            run = run->parent();
     170        if (run) {
     171            run->addChild(child, beforeChild);
     172            return;
     173        }
     174        ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
    161175        // Emergency fallback: fall through and just append.
    162176    }
     
    175189void RenderRubyAsBlock::removeChild(RenderObject* child)
    176190{
    177     // If the child's parent is *this, just use the normal remove method.
    178     if (child->parent() == this) {
    179         // This should happen only during destruction of the whole ruby element, though.
     191    // If the child's parent is *this (a ruby run or :before or :after content),
     192    // just use the normal remove method.
     193    if (child->isRubyRun() || child->isBeforeContent() || child->isAfterContent()) {
    180194        RenderBlock::removeChild(child);
    181195        return;
    182196    }
    183197
    184     // Find the containing run
     198    // Otherwise find the containing run and remove it from there.
     199    ASSERT(child->parent() != this);
    185200    RenderRubyRun* run = findRubyRunParent(child);
    186201    ASSERT(run);
Note: See TracChangeset for help on using the changeset viewer.