Changeset 130616 in webkit


Ignore:
Timestamp:
Oct 7, 2012 9:42:26 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

:first-line pseudo selector ignoring words created from :before
https://bugs.webkit.org/show_bug.cgi?id=80794

Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2012-10-07
Reviewed by Daniel Bates.

Source/WebCore:

The :first-line pseudo-element style is not applied for content
which is generated from the :before/:after pseudo-elements.

Test: fast/css/first-line-style-for-before-after-content.html

  • rendering/RenderObject.cpp:

(WebCore::firstLineStyleForCachedUncachedType):
Added a new static helper function incorporating the common
functionality of both uncachedFirstLineStyle() and firstLineStyleSlowCase()
functions. It also modifies the functionality to handle the
scenario when :first-line style needs to be applied on content
generated from :before/:after.

While getting the :first-line style we should also consider the case
when the content is generated from a :before/:after pseudo-element in
which case the RenderInline's parent should be considered for
obtaining the first-line style.

(WebCore):
(WebCore::RenderObject::uncachedFirstLineStyle):
(WebCore::RenderObject::firstLineStyleSlowCase):
Moved the duplicate code between the two functions to the common
helper function firstLineStyleForCachedUncachedType().

LayoutTests:

  • fast/css/first-line-style-for-before-after-content-expected.html: Added.
  • fast/css/first-line-style-for-before-after-content.html: Added.

Added ref test for verification of the scenario when :first-line style
is applied to content generated from :before/:after pseudo-elements.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130610 r130616  
     12012-10-07  Arpita Bahuguna  <arpitabahuguna@gmail.com>
     2
     3        :first-line pseudo selector ignoring words created from :before
     4        https://bugs.webkit.org/show_bug.cgi?id=80794
     5
     6        Reviewed by Daniel Bates.
     7
     8        * fast/css/first-line-style-for-before-after-content-expected.html: Added.
     9        * fast/css/first-line-style-for-before-after-content.html: Added.
     10        Added ref test for verification of the scenario when :first-line style
     11        is applied to content generated from :before/:after pseudo-elements.
     12
    1132012-10-07  Nick Carter  <nick@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r130615 r130616  
     12012-10-07  Arpita Bahuguna  <arpitabahuguna@gmail.com>
     2
     3        :first-line pseudo selector ignoring words created from :before
     4        https://bugs.webkit.org/show_bug.cgi?id=80794
     5
     6        Reviewed by Daniel Bates.
     7
     8        The :first-line pseudo-element style is not applied for content
     9        which is generated from the :before/:after pseudo-elements.
     10
     11        Test: fast/css/first-line-style-for-before-after-content.html
     12
     13        * rendering/RenderObject.cpp:
     14        (WebCore::firstLineStyleForCachedUncachedType):
     15        Added a new static helper function incorporating the common
     16        functionality of both uncachedFirstLineStyle() and firstLineStyleSlowCase()
     17        functions. It also modifies the functionality to handle the
     18        scenario when :first-line style needs to be applied on content
     19        generated from :before/:after.
     20
     21        While getting the :first-line style we should also consider the case
     22        when the content is generated from a :before/:after pseudo-element in
     23        which case the RenderInline's parent should be considered for
     24        obtaining the first-line style.
     25
     26        (WebCore):
     27        (WebCore::RenderObject::uncachedFirstLineStyle):
     28        (WebCore::RenderObject::firstLineStyleSlowCase):
     29        Moved the duplicate code between the two functions to the common
     30        helper function firstLineStyleForCachedUncachedType().
     31
    1322012-10-07  Peter Wang  <peter.wang@torchmobile.com.cn>
    233
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r130573 r130616  
    26032603}
    26042604
     2605enum StyleCacheState {
     2606    Cached,
     2607    Uncached
     2608};
     2609
     2610static PassRefPtr<RenderStyle> firstLineStyleForCachedUncachedType(StyleCacheState type, const RenderObject* renderer, RenderStyle* style)
     2611{
     2612    const RenderObject* rendererForFirstLineStyle = renderer;
     2613    if (renderer->isBeforeOrAfterContent())
     2614        rendererForFirstLineStyle = renderer->parent();
     2615
     2616    if (rendererForFirstLineStyle->isBlockFlow()) {
     2617        if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBlock()) {
     2618            if (type == Cached)
     2619                return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
     2620            return firstLineBlock->getUncachedPseudoStyle(FIRST_LINE, style, firstLineBlock == renderer ? style : 0);
     2621        }
     2622    } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLineStyle->isRenderInline()) {
     2623        RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLineStyle();
     2624        if (parentStyle != rendererForFirstLineStyle->parent()->style()) {
     2625            if (type == Cached) {
     2626                // A first-line style is in effect. Cache a first-line style for ourselves.
     2627                rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE_INHERITED);
     2628                return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle);
     2629            }
     2630            return rendererForFirstLineStyle->getUncachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle, style);
     2631        }
     2632    }
     2633    return 0;
     2634}
     2635
    26052636PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style) const
    26062637{
     
    26102641    ASSERT(!isText());
    26112642
    2612     RefPtr<RenderStyle> result;
    2613 
    2614     if (isBlockFlow()) {
    2615         if (RenderBlock* firstLineBlock = this->firstLineBlock())
    2616             result = firstLineBlock->getUncachedPseudoStyle(FIRST_LINE, style, firstLineBlock == this ? style : 0);
    2617     } else if (!isAnonymous() && isRenderInline()) {
    2618         RenderStyle* parentStyle = parent()->firstLineStyle();
    2619         if (parentStyle != parent()->style())
    2620             result = getUncachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle, style);
    2621     }
    2622 
    2623     return result.release();
     2643    return firstLineStyleForCachedUncachedType(Uncached, this, style);
    26242644}
    26252645
     
    26282648    ASSERT(document()->styleSheetCollection()->usesFirstLineRules());
    26292649
    2630     RenderStyle* style = m_style.get();
    2631     const RenderObject* renderer = isText() ? parent() : this;
    2632     if (renderer->isBlockFlow()) {
    2633         if (RenderBlock* firstLineBlock = renderer->firstLineBlock())
    2634             style = firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
    2635     } else if (!renderer->isAnonymous() && renderer->isRenderInline()) {
    2636         RenderStyle* parentStyle = renderer->parent()->firstLineStyle();
    2637         if (parentStyle != renderer->parent()->style()) {
    2638             // A first-line style is in effect. Cache a first-line style for ourselves.
    2639             renderer->style()->setHasPseudoStyle(FIRST_LINE_INHERITED);
    2640             style = renderer->getCachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle);
    2641         }
    2642     }
    2643 
    2644     return style;
     2650    if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get()))
     2651        return style.get();
     2652
     2653    return m_style.get();
    26452654}
    26462655
Note: See TracChangeset for help on using the changeset viewer.