Changeset 156527 in webkit


Ignore:
Timestamp:
Sep 26, 2013, 7:02:27 PM (12 years ago)
Author:
Antti Koivisto
Message:

Move m_style to RenderElement
https://bugs.webkit.org/show_bug.cgi?id=121936

Source/WebCore:

Reviewed by Andreas Kling.

Text renderers always have the same style as their parent. They can get their style via the parent pointer
rather than having a member of their own.

This shrinks RenderText by a pointer.

  • dom/PseudoElement.cpp:

(WebCore::PseudoElement::didRecalcStyle):

Text renderers have no independent style. No need to set it.

  • editing/ApplyBlockElementCommand.cpp:
  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::addChildToAnonymousColumnBlocks):

Avoid getting style from text child before it is added to tree.

(WebCore::RenderBlock::updateFirstLetterStyle):
(WebCore::RenderBlock::createFirstLetterRenderer):

  • rendering/RenderButton.cpp:

(WebCore::RenderButton::styleDidChange):
(WebCore::RenderButton::setText):

  • rendering/RenderCombineText.cpp:

(WebCore::RenderCombineText::styleDidChange):

Don't set text style anymore.

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::RenderElement):
(WebCore::RenderElement::setStyle):

Notify child text renderers of style change.

(WebCore::RenderElement::setAnimatableStyle):
(WebCore::RenderElement::setPseudoStyle):

Push down to RenderElement, remove text branches.

(WebCore::RenderElement::addChild):

Notify text renderers of style change when added to tree.

(WebCore::RenderElement::propagateStyleToAnonymousChildren):

  • rendering/RenderElement.h:

(WebCore::RenderElement::style):
(WebCore::RenderElement::setStyleInternal):

Move m_style from RenderObject.

(WebCore::RenderObject::style):

Inline this in RenderElement.h instead of making it virtual.

  • rendering/RenderInline.cpp:

(WebCore::updateStyleOfAnonymousBlockContinuations):
(WebCore::RenderInline::styleDidChange):

Tighten typing to call RenderElement::setStyle.

(WebCore::RenderInline::clippedOverflowRectForRepaint):

Change assert. This can get legitimately called during layout for the first letter renderers.
This was previously avoided by luck.

  • rendering/RenderMenuList.cpp:

(WebCore::RenderMenuList::styleDidChange):
(WebCore::RenderMenuList::setText):

Don't set text style anymore.

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::containingBlock):
(WebCore::RenderObject::drawLineForBoxSide):
(WebCore::RenderObject::hasEntirelyFixedBackground):
(WebCore::RenderObject::container):
(WebCore::RenderObject::cachedFirstLineStyle):

Switch to style(), avoid unnecessary repetition.
Move code out.

  • rendering/RenderObject.h:


Move functions to RenderElement.

(WebCore::RenderObject::isBeforeContent):
(WebCore::RenderObject::isAfterContent):

Avoid accessing style for text renderers as these are called before the renderer
is added to tree.

(WebCore::RenderObject::setNeedsPositionedMovementLayout):

  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::restoreRegionObjectsOriginalStyle):
(WebCore::RenderRegion::setObjectStyleInRegion):

  • rendering/RenderSearchField.cpp:

(WebCore::RenderSearchField::updateCancelButtonVisibility):

  • rendering/RenderText.cpp:
  • rendering/RenderText.h:


Remove setStyle.

(WebCore::RenderText::style):

Get style from parent.

  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::updateFromElement):
(WebCore::RenderMathMLOperator::createGlyph):

  • rendering/style/ContentData.cpp:

(WebCore::TextContentData::createRenderer):
(WebCore::CounterContentData::createRenderer):
(WebCore::QuoteContentData::createRenderer):

Pseudo style for RenderText subclasses comes from parent without any explicit setting.

  • style/StyleResolveTree.cpp:

(WebCore::Style::createTextRendererIfNeeded):
(WebCore::Style::resolveLocal):
(WebCore::Style::updateTextStyle):
(WebCore::Style::resolveShadowTree):
(WebCore::Style::resolveTree):

No need to set or update text renderer style separately.

LayoutTests:

Reviewed by Andreas Kling.

Progressions from text style updating correctly in all cases.

  • compositing/contents-opaque/hidden-with-visible-text-expected.txt:
  • compositing/contents-opaque/visibility-hidden-expected.txt:


Can't figure out why these progress but they do. The new rendering (showing nothing)
is correct and matches Firefox.

  • platform/mac/svg/custom/SVGPoint-matrixTransform-expected.txt:
  • platform/mac/svg/custom/getTransformToElement-expected.txt:
  • platform/mac/svg/custom/text-ctm-expected.txt:
  • platform/mac/svg/custom/text-hit-test-expected.txt:
  • platform/mac/svg/text/append-text-node-to-tspan-expected.txt:
Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156522 r156527  
     12013-09-26  Antti Koivisto  <antti@apple.com>
     2
     3        Move m_style to RenderElement
     4        https://bugs.webkit.org/show_bug.cgi?id=121936
     5
     6        Reviewed by Andreas Kling.
     7       
     8        Progressions from text style updating correctly in all cases.
     9
     10        * compositing/contents-opaque/hidden-with-visible-text-expected.txt:
     11        * compositing/contents-opaque/visibility-hidden-expected.txt:
     12       
     13            Can't figure out why these progress but they do. The new rendering (showing nothing)
     14            is correct and matches Firefox.
     15
     16        * platform/mac/svg/custom/SVGPoint-matrixTransform-expected.txt:
     17        * platform/mac/svg/custom/getTransformToElement-expected.txt:
     18        * platform/mac/svg/custom/text-ctm-expected.txt:
     19        * platform/mac/svg/custom/text-hit-test-expected.txt:
     20        * platform/mac/svg/text/append-text-node-to-tspan-expected.txt:
     21
    1222013-09-26  Eric Carlson  <eric.carlson@apple.com>
    223
  • trunk/LayoutTests/compositing/contents-opaque/hidden-with-visible-text-expected.txt

    r149915 r156527  
    99          (position 8.00 13.00)
    1010          (bounds 200.00 100.00)
    11           (drawsContent 1)
     11          (contentsVisible 0)
    1212        )
    1313      )
  • trunk/LayoutTests/compositing/contents-opaque/visibility-hidden-expected.txt

    r149084 r156527  
    99          (position 8.00 20.00)
    1010          (bounds 200.00 50.00)
    11           (drawsContent 1)
     11          (contentsVisible 0)
    1212        )
    1313      )
  • trunk/LayoutTests/platform/mac/svg/custom/SVGPoint-matrixTransform-expected.txt

    r107057 r156527  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (40,12) size 86x36
    5     RenderSVGText {text} at (20,6) size 43x18 contains 1 chunk(s)
    6       RenderSVGInlineText {#text} at (0,0) size 43x18
     4  RenderSVGRoot {svg} at (40,10) size 86x38
     5    RenderSVGText {text} at (20,5) size 43x19 contains 1 chunk(s)
     6      RenderSVGInlineText {#text} at (0,0) size 43x19
    77        chunk 1 text run 1 at (20.00,20.00) startOffset 0 endOffset 6 width 43.00: "Passed"
  • trunk/LayoutTests/platform/mac/svg/custom/getTransformToElement-expected.txt

    r149210 r156527  
    44  RenderSVGRoot {svg} at (20,56) size 101x157
    55    RenderSVGContainer {g} at (0,0) size 0x0 [transform={m=((0.00,0.00)(0.00,0.00)) t=(0.00,0.00)}]
    6     RenderSVGContainer {g} at (20,56) size 41x18 [transform={m=((1.00,0.00)(0.00,1.00)) t=(15.00,15.00)}]
    7       RenderSVGText {text} at (50,122) size 82x35 contains 1 chunk(s)
    8         RenderSVGInlineText {#text} at (0,0) size 82x35
    9           chunk 1 text run 1 at (50.00,150.00) startOffset 0 endOffset 6 width 82.00: "Passed"
     6    RenderSVGContainer {g} at (20,56) size 42x18 [transform={m=((1.00,0.00)(0.00,1.00)) t=(15.00,15.00)}]
     7      RenderSVGText {text} at (50,123) size 84x34 contains 1 chunk(s)
     8        RenderSVGInlineText {#text} at (0,0) size 84x34
     9          chunk 1 text run 1 at (50.00,150.00) startOffset 0 endOffset 6 width 84.00: "Passed"
    1010    RenderSVGContainer {g} at (49,141) size 72x72 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(0.00,0.00)}]
    1111      RenderSVGRect {rect} at (49,141) size 72x72 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,0.00)}] [x=50.00] [y=50.00] [width=70.00] [height=30.00]
  • trunk/LayoutTests/platform/mac/svg/custom/text-ctm-expected.txt

    r146424 r156527  
    22  RenderView at (0,0) size 800x600
    33layer at (0,0) size 800x600
    4   RenderSVGRoot {svg} at (100,72) size 86x36
    5     RenderSVGContainer {g} at (100,72) size 86x36 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
    6       RenderSVGViewportContainer {svg} at (100,72) size 86x36
    7         RenderSVGText {text} at (70,56) size 43x18 contains 1 chunk(s)
    8           RenderSVGInlineText {#text} at (0,0) size 43x18
     4  RenderSVGRoot {svg} at (100,70) size 86x38
     5    RenderSVGContainer {g} at (100,70) size 86x38 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
     6      RenderSVGViewportContainer {svg} at (100,70) size 86x38
     7        RenderSVGText {text} at (70,55) size 43x19 contains 1 chunk(s)
     8          RenderSVGInlineText {#text} at (0,0) size 43x19
    99            chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 6 width 43.00: "Passed"
  • trunk/LayoutTests/platform/mac/svg/custom/text-hit-test-expected.txt

    r149210 r156527  
    1010        RenderSVGInlineText {#text} at (0,0) size 44x19
    1111          chunk 1 text run 1 at (10.00,130.00) startOffset 0 endOffset 7 width 43.50: "Status:"
    12       RenderSVGText {text} at (90,116) size 43x18 contains 1 chunk(s)
    13         RenderSVGInlineText {#text} at (0,0) size 43x18
     12      RenderSVGText {text} at (90,115) size 43x19 contains 1 chunk(s)
     13        RenderSVGInlineText {#text} at (0,0) size 43x19
    1414          chunk 1 text run 1 at (90.00,130.00) startOffset 0 endOffset 6 width 43.00: "Passed"
    1515caret: position 0 of child 0 {#text} of child 1 {text} of child 3 {g} of child 1 {svg} of document
  • trunk/LayoutTests/platform/mac/svg/text/append-text-node-to-tspan-expected.txt

    r149210 r156527  
    55    RenderBody {BODY} at (8,8) size 784x0
    66layer at (0,0) size 800x600
    7   RenderSVGRoot {svg} at (10,60) size 330x380
    8     RenderSVGText {text} at (0,1) size 33x38 contains 1 chunk(s)
    9       RenderSVGTSpan {tspan} at (0,0) size 30x14
     7  RenderSVGRoot {svg} at (10,60) size 320x380
     8    RenderSVGText {text} at (0,1) size 32x38 contains 1 chunk(s)
     9      RenderSVGTSpan {tspan} at (0,0) size 29x14
    1010        RenderSVGInlineText {#text} at (0,0) size 16x14
    1111          chunk 1 text run 1 at (0.00,12.00) startOffset 0 endOffset 2 width 15.40: "PA"
    1212        RenderSVGInlineText {#text} at (15,0) size 14x14
    13           chunk 1 text run 1 at (15.40,12.00) startOffset 0 endOffset 2 width 14.00: "SS"
    14       RenderSVGInlineText {#text} at (29,0) size 3x14
    15         chunk 1 text run 1 at (29.40,12.00) startOffset 0 endOffset 1 width 3.00: " "
     13          chunk 1 text run 1 at (15.40,12.00) startOffset 0 endOffset 2 width 13.40: "SS"
     14      RenderSVGInlineText {#text} at (28,0) size 3x14
     15        chunk 1 text run 1 at (28.80,12.00) startOffset 0 endOffset 1 width 3.00: " "
    1616      RenderSVGTSpan {tspan} at (0,0) size 29x14
    1717        RenderSVGInlineText {#text} at (0,12) size 29x14
  • trunk/Source/WebCore/ChangeLog

    r156522 r156527  
     12013-09-26  Antti Koivisto  <antti@apple.com>
     2
     3        Move m_style to RenderElement
     4        https://bugs.webkit.org/show_bug.cgi?id=121936
     5
     6        Reviewed by Andreas Kling.
     7
     8        Text renderers always have the same style as their parent. They can get their style via the parent pointer
     9        rather than having a member of their own.
     10       
     11        This shrinks RenderText by a pointer.
     12
     13        * dom/PseudoElement.cpp:
     14        (WebCore::PseudoElement::didRecalcStyle):
     15       
     16            Text renderers have no independent style. No need to set it.
     17
     18        * editing/ApplyBlockElementCommand.cpp:
     19        * rendering/RenderBlock.cpp:
     20        (WebCore::RenderBlock::addChildToAnonymousColumnBlocks):
     21       
     22            Avoid getting style from text child before it is added to tree.
     23
     24        (WebCore::RenderBlock::updateFirstLetterStyle):
     25        (WebCore::RenderBlock::createFirstLetterRenderer):
     26        * rendering/RenderButton.cpp:
     27        (WebCore::RenderButton::styleDidChange):
     28        (WebCore::RenderButton::setText):
     29        * rendering/RenderCombineText.cpp:
     30        (WebCore::RenderCombineText::styleDidChange):
     31               
     32            Don't set text style anymore.
     33
     34        * rendering/RenderElement.cpp:
     35        (WebCore::RenderElement::RenderElement):
     36        (WebCore::RenderElement::setStyle):
     37       
     38            Notify child text renderers of style change.
     39
     40        (WebCore::RenderElement::setAnimatableStyle):
     41        (WebCore::RenderElement::setPseudoStyle):
     42       
     43            Push down to RenderElement, remove text branches.
     44
     45        (WebCore::RenderElement::addChild):
     46       
     47            Notify text renderers of style change when added to tree.
     48
     49        (WebCore::RenderElement::propagateStyleToAnonymousChildren):
     50        * rendering/RenderElement.h:
     51        (WebCore::RenderElement::style):
     52        (WebCore::RenderElement::setStyleInternal):
     53       
     54            Move m_style from RenderObject.
     55
     56        (WebCore::RenderObject::style):
     57       
     58            Inline this in RenderElement.h instead of making it virtual.
     59
     60        * rendering/RenderInline.cpp:
     61        (WebCore::updateStyleOfAnonymousBlockContinuations):
     62        (WebCore::RenderInline::styleDidChange):
     63       
     64            Tighten typing to call RenderElement::setStyle.
     65
     66        (WebCore::RenderInline::clippedOverflowRectForRepaint):
     67       
     68            Change assert. This can get legitimately called during layout for the first letter renderers.
     69            This was previously avoided by luck.
     70
     71        * rendering/RenderMenuList.cpp:
     72        (WebCore::RenderMenuList::styleDidChange):
     73        (WebCore::RenderMenuList::setText):
     74       
     75            Don't set text style anymore.
     76
     77        * rendering/RenderObject.cpp:
     78        (WebCore::RenderObject::RenderObject):
     79        (WebCore::RenderObject::containingBlock):
     80        (WebCore::RenderObject::drawLineForBoxSide):
     81        (WebCore::RenderObject::hasEntirelyFixedBackground):
     82        (WebCore::RenderObject::container):
     83        (WebCore::RenderObject::cachedFirstLineStyle):
     84
     85            Switch to style(), avoid unnecessary repetition.
     86            Move code out.
     87
     88        * rendering/RenderObject.h:
     89       
     90            Move functions to RenderElement.
     91
     92        (WebCore::RenderObject::isBeforeContent):
     93        (WebCore::RenderObject::isAfterContent):
     94       
     95            Avoid accessing style for text renderers as these are called before the renderer
     96            is added to tree.
     97
     98        (WebCore::RenderObject::setNeedsPositionedMovementLayout):
     99        * rendering/RenderRegion.cpp:
     100        (WebCore::RenderRegion::restoreRegionObjectsOriginalStyle):
     101        (WebCore::RenderRegion::setObjectStyleInRegion):
     102        * rendering/RenderSearchField.cpp:
     103        (WebCore::RenderSearchField::updateCancelButtonVisibility):
     104        * rendering/RenderText.cpp:
     105        * rendering/RenderText.h:
     106       
     107            Remove setStyle.
     108
     109        (WebCore::RenderText::style):
     110       
     111            Get style from parent.
     112
     113        * rendering/mathml/RenderMathMLOperator.cpp:
     114        (WebCore::RenderMathMLOperator::updateFromElement):
     115        (WebCore::RenderMathMLOperator::createGlyph):
     116        * rendering/style/ContentData.cpp:
     117        (WebCore::TextContentData::createRenderer):
     118        (WebCore::CounterContentData::createRenderer):
     119        (WebCore::QuoteContentData::createRenderer):
     120       
     121            Pseudo style for RenderText subclasses comes from parent without any explicit setting.
     122
     123        * style/StyleResolveTree.cpp:
     124        (WebCore::Style::createTextRendererIfNeeded):
     125        (WebCore::Style::resolveLocal):
     126        (WebCore::Style::updateTextStyle):
     127        (WebCore::Style::resolveShadowTree):
     128        (WebCore::Style::resolveTree):
     129       
     130            No need to set or update text renderer style separately.
     131
    11322013-09-26  Eric Carlson  <eric.carlson@apple.com>
    2133
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r156226 r156527  
    3535#include "IntSizeHash.h"
    3636#include "NodeRenderStyle.h"
    37 #include "RenderObject.h"
     37#include "RenderElement.h"
    3838#include "StyleResolver.h"
    3939#include <wtf/text/StringBuilder.h>
  • trunk/Source/WebCore/dom/PseudoElement.cpp

    r156144 r156527  
    112112    for (RenderObject* child = renderer->nextInPreOrder(renderer); child; child = child->nextInPreOrder(renderer)) {
    113113        // We only manage the style for the generated content which must be images or text.
    114         if (!child->isText() && !child->isImage())
     114        if (!child->isImage())
    115115            continue;
    116 
    117         // The style for the RenderTextFragment for first letter is managed by an enclosing block, not by us.
    118         if (child->style()->styleType() == FIRST_LETTER)
    119             continue;
    120 
    121         child->setPseudoStyle(renderer->style());
     116        toRenderElement(child)->setPseudoStyle(renderer->style());
    122117    }
    123118}
  • trunk/Source/WebCore/editing/ApplyBlockElementCommand.cpp

    r156289 r156527  
    3030#include "HTMLElement.h"
    3131#include "HTMLNames.h"
    32 #include "RenderObject.h"
     32#include "RenderElement.h"
    3333#include "RenderStyle.h"
    3434#include "Text.h"
  • trunk/Source/WebCore/editing/HTMLInterchange.cpp

    r151947 r156527  
    2727#include "HTMLInterchange.h"
    2828
    29 #include "RenderObject.h"
     29#include "RenderElement.h"
    3030#include "Text.h"
    3131#include "TextIterator.h"
  • trunk/Source/WebCore/editing/InsertLineBreakCommand.cpp

    r156289 r156527  
    3535#include "HTMLTableElement.h"
    3636#include "Range.h"
    37 #include "RenderObject.h"
     37#include "RenderElement.h"
    3838#include "Text.h"
    3939#include "VisiblePosition.h"
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r156422 r156527  
    457457
    458458    // See if the child can be placed in the box.
    459     bool newChildHasColumnSpan = newChild->style()->columnSpan() && !newChild->isInline();
     459    bool newChildHasColumnSpan = !newChild->isInline() && newChild->style()->columnSpan();
    460460    bool beforeChildParentHoldsColumnSpans = beforeChildParent->isAnonymousColumnSpanBlock();
    461461
     
    58745874    } else
    58755875        firstLetter->setStyle(pseudoStyle);
    5876 
    5877     for (RenderObject* genChild = firstLetter->firstChild(); genChild; genChild = genChild->nextSibling()) {
    5878         if (genChild->isText())
    5879             genChild->setStyle(pseudoStyle);
    5880     }
    58815876}
    58825877
     
    59295924            remainingText = RenderTextFragment::createAnonymous(document(), oldText, length, oldText.length() - length);
    59305925
    5931         remainingText->setStyle(currentTextChild->style());
    59325926        if (remainingText->textNode())
    59335927            remainingText->textNode()->setRenderer(remainingText);
     
    59455939            letter = RenderTextFragment::createAnonymous(document(), oldText, 0, length);
    59465940
    5947         letter->setStyle(pseudoStyle);
    59485941        firstLetter->addChild(letter);
    59495942
  • trunk/Source/WebCore/rendering/RenderButton.cpp

    r156155 r156527  
    106106    RenderBlock::styleDidChange(diff, oldStyle);
    107107
    108     if (m_buttonText)
    109         m_buttonText->setStyle(style());
    110108    if (m_inner) // RenderBlock handled updating the anonymous block's style.
    111109        setupInnerStyle(m_inner->style());
     
    157155        else {
    158156            m_buttonText = RenderTextFragment::createAnonymous(document(), str);
    159             m_buttonText->setStyle(style());
    160157            addChild(m_buttonText);
    161158        }
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r156478 r156527  
    2727
    2828#include "AXObjectCache.h"
     29#include "AnimationController.h"
    2930#include "ContentData.h"
    3031#include "CursorList.h"
     
    6768    , m_firstChild(nullptr)
    6869    , m_lastChild(nullptr)
     70    , m_style(0)
    6971{
    7072}
     
    324326    styleDidChange(diff, oldStyle.get());
    325327
     328    // Text renderers use their parent style. Notify them about the change.
     329    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
     330        if (child->isText())
     331            toRenderText(child)->styleDidChange(diff, oldStyle.get());
     332    }
     333
    326334    // FIXME: |this| might be destroyed here. This can currently happen for a RenderTextFragment when
    327335    // its first-letter block gets an update in RenderTextFragment::styleDidChange. For RenderTextFragment(s),
     
    354362}
    355363
     364void RenderElement::setAnimatableStyle(PassRefPtr<RenderStyle> style)
     365{
     366    setStyle(animation().updateAnimations(this, style.get()));
     367}
     368
     369void RenderElement::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle)
     370{
     371    ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFTER);
     372
     373    // Images are special and must inherit the pseudoStyle so the width and height of
     374    // the pseudo element doesn't change the size of the image. In all other cases we
     375    // can just share the style.
     376    if (isImage()) {
     377        RefPtr<RenderStyle> style = RenderStyle::create();
     378        style->inheritFrom(pseudoStyle.get());
     379        setStyle(style.release());
     380        return;
     381    }
     382
     383    setStyle(pseudoStyle);
     384}
     385
    356386void RenderElement::addChild(RenderObject* newChild, RenderObject* beforeChild)
    357387{
     
    384414        insertChildInternal(newChild, beforeChild, NotifyChildren);
    385415
    386     if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE)
    387         toRenderText(newChild)->transformText();
     416    if (newChild->isText())
     417        toRenderText(newChild)->styleDidChange(StyleDifferenceEqual, nullptr);
    388418
    389419    // SVG creates renderers for <g display="none">, as SVG requires children of hidden
     
    660690    // FIXME: We could save this call when the change only affected non-inherited properties.
    661691    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
     692        if (child->isText())
     693            continue;
    662694        if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO)
    663695            continue;
     
    684716            newStyle->setPosition(child->style()->position());
    685717
    686         child->setStyle(newStyle.release());
     718        toRenderElement(child)->setStyle(newStyle.release());
    687719    }
    688720}
  • trunk/Source/WebCore/rendering/RenderElement.h

    r156338 r156527  
    3434    static RenderElement* createFor(Element&, RenderStyle&);
    3535
    36     virtual void setStyle(PassRefPtr<RenderStyle>) OVERRIDE;
     36    RenderStyle* style() const { return m_style.get(); }
     37    RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
     38
     39    virtual void setStyle(PassRefPtr<RenderStyle>);
     40    // Called to update a style that is allowed to trigger animations.
     41    void setAnimatableStyle(PassRefPtr<RenderStyle>);
     42    // Set the style of the object if it's generated content.
     43    void setPseudoStyle(PassRefPtr<RenderStyle>);
    3744
    3845    // This is null for anonymous renderers.
     
    6572    // Return the renderer whose background style is used to paint the root background. Should only be called on the renderer for which isRoot() is true.
    6673    RenderElement* rendererForRootBackground();
     74
     75    // Updates only the local style ptr of the object. Does not update the state of the object,
     76    // and so only should be called when the style is known not to have changed (or from setStyle).
     77    void setStyleInternal(PassRefPtr<RenderStyle> style) { m_style = style; }
    6778
    6879protected:
     
    112123    RenderObject* m_lastChild;
    113124
     125    RefPtr<RenderStyle> m_style;
     126
    114127    // FIXME: Get rid of this hack.
    115128    // Store state between styleWillChange and styleDidChange
     
    156169void toRenderElement(const RenderElement&);
    157170
     171inline RenderStyle* RenderObject::style() const
     172{
     173    if (isText())
     174        return m_parent->style();
     175    return toRenderElement(this)->style();
     176}
     177
    158178inline RenderElement* Element::renderer() const
    159179{
  • trunk/Source/WebCore/rendering/RenderImageResource.cpp

    r154858 r156527  
    3131#include "CachedImage.h"
    3232#include "Image.h"
     33#include "RenderElement.h"
    3334#include "RenderImageResourceStyleImage.h"
    34 #include "RenderObject.h"
    3535
    3636namespace WebCore {
  • trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp

    r144568 r156527  
    3030
    3131#include "CachedImage.h"
    32 #include "RenderObject.h"
     32#include "RenderElement.h"
    3333#include "StyleCachedImage.h"
    3434
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r156422 r156527  
    149149}
    150150
    151 static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const RenderStyle* newStyle, const RenderStyle* oldStyle)
    152 {
    153     for (;block && block->isAnonymousBlock(); block = block->nextSibling()) {
    154         if (!toRenderBlock(block)->isAnonymousBlockContinuation() || block->style()->position() == newStyle->position())
     151static void updateStyleOfAnonymousBlockContinuations(RenderBlock* block, const RenderStyle* newStyle, const RenderStyle* oldStyle)
     152{
     153    for (;block && block->isAnonymousBlock(); block = toRenderBlock(block->nextSibling())) {
     154        if (!block->isAnonymousBlockContinuation() || block->style()->position() == newStyle->position())
    155155            continue;
    156156        // If we are no longer in-flow positioned but our descendant block(s) still have an in-flow positioned ancestor then
    157157        // their containing anonymous block should keep its in-flow positioning.
    158         RenderInline* cont = toRenderBlock(block)->inlineElementContinuation();
     158        RenderInline* cont = block->inlineElementContinuation();
    159159        if (oldStyle->hasInFlowPosition() && inFlowPositionedInlineAncestor(cont))
    160160            continue;
     
    191191        RenderObject* block = containingBlock()->nextSibling();
    192192        ASSERT(block && block->isAnonymousBlock());
    193         updateStyleOfAnonymousBlockContinuations(block, newStyle, oldStyle);
     193        updateStyleOfAnonymousBlockContinuations(toRenderBlock(block), newStyle, oldStyle);
    194194    }
    195195
     
    10301030LayoutRect RenderInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
    10311031{
    1032     // Only run-ins are allowed in here during layout.
    1033     ASSERT(!view().layoutStateEnabled() || isRunIn());
     1032    // Only run-ins and first-letter renderers are allowed in here during layout. They mutate the tree triggering repaints.
     1033    ASSERT(!view().layoutStateEnabled() || isRunIn() || style()->styleType() == FIRST_LETTER);
    10341034
    10351035    if (!firstLineBoxIncludingCulling() && !continuation())
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r156166 r156527  
    158158    RenderBlock::styleDidChange(diff, oldStyle);
    159159
    160     if (m_buttonText)
    161         m_buttonText->setStyle(style());
    162160    if (m_innerBlock) // RenderBlock handled updating the anonymous block's style.
    163161        adjustInnerStyle();
     
    245243    else {
    246244        m_buttonText = RenderText::createAnonymous(document(), textToUse);
    247         m_buttonText->setStyle(style());
    248245        addChild(m_buttonText);
    249246    }
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r156422 r156527  
    9494struct SameSizeAsRenderObject {
    9595    virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer.
    96     void* pointers[5];
     96    void* pointers[4];
    9797#ifndef NDEBUG
    9898    unsigned m_debugBitfields : 2;
     
    122122RenderObject::RenderObject(Node* node)
    123123    : CachedImageClient()
    124     , m_style(0)
    125124    , m_node(node)
    126125    , m_parent(0)
     
    738737        o = toRenderScrollbarPart(this)->rendererOwningScrollbar();
    739738
    740     if (!isText() && m_style->position() == FixedPosition)
     739    RenderStyle* style = this->style();
     740    if (!isText() && style->position() == FixedPosition)
    741741        o = containingBlockForFixedPosition(o);
    742     else if (!isText() && m_style->position() == AbsolutePosition)
     742    else if (!isText() && style->position() == AbsolutePosition)
    743743        o = containingBlockForAbsolutePosition(o);
    744744    else
     
    811811
    812812void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
    813                                       BoxSide side, Color color, EBorderStyle style,
    814                                       int adjacentWidth1, int adjacentWidth2, bool antialias)
     813    BoxSide side, Color color, EBorderStyle borderStyle, int adjacentWidth1, int adjacentWidth2, bool antialias)
    815814{
    816815    int thickness;
     
    829828        return;
    830829
    831     if (style == DOUBLE && thickness < 3)
    832         style = SOLID;
    833 
    834     switch (style) {
     830    if (borderStyle == DOUBLE && thickness < 3)
     831        borderStyle = SOLID;
     832
     833    RenderStyle* style = this->style();
     834    switch (borderStyle) {
    835835        case BNONE:
    836836        case BHIDDEN:
     
    842842                StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle();
    843843                graphicsContext->setShouldAntialias(antialias);
    844                 graphicsContext->setStrokeColor(color, m_style->colorSpace());
     844                graphicsContext->setStrokeColor(color, style->colorSpace());
    845845                graphicsContext->setStrokeThickness(thickness);
    846                 graphicsContext->setStrokeStyle(style == DASHED ? DashedStroke : DottedStroke);
     846                graphicsContext->setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke);
    847847
    848848                switch (side) {
     
    868868                StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle();
    869869                graphicsContext->setStrokeStyle(NoStroke);
    870                 graphicsContext->setFillColor(color, m_style->colorSpace());
     870                graphicsContext->setFillColor(color, style->colorSpace());
    871871               
    872872                bool wasAntialiased = graphicsContext->shouldAntialias();
     
    938938            EBorderStyle s1;
    939939            EBorderStyle s2;
    940             if (style == GROOVE) {
     940            if (borderStyle == GROOVE) {
    941941                s1 = INSET;
    942942                s2 = OUTSET;
     
    984984            // fall through
    985985        case OUTSET:
    986             if (style == OUTSET && (side == BSBottom || side == BSRight))
     986            if (borderStyle == OUTSET && (side == BSBottom || side == BSRight))
    987987                color = color.dark();
    988988            // fall through
     
    990990            StrokeStyle oldStrokeStyle = graphicsContext->strokeStyle();
    991991            graphicsContext->setStrokeStyle(NoStroke);
    992             graphicsContext->setFillColor(color, m_style->colorSpace());
     992            graphicsContext->setFillColor(color, style->colorSpace());
    993993            ASSERT(x2 >= x1);
    994994            ASSERT(y2 >= y1);
     
    16651665}
    16661666
    1667 void RenderObject::setAnimatableStyle(PassRefPtr<RenderStyle> style)
    1668 {
    1669     if (!isText() && style)
    1670         setStyle(animation().updateAnimations(this, style.get()));
    1671     else
    1672         setStyle(style);
    1673 }
    1674 
    1675 void RenderObject::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle)
    1676 {
    1677     ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFTER);
    1678 
    1679     // Images are special and must inherit the pseudoStyle so the width and height of
    1680     // the pseudo element doesn't change the size of the image. In all other cases we
    1681     // can just share the style.
    1682     if (isImage()) {
    1683         RefPtr<RenderStyle> style = RenderStyle::create();
    1684         style->inheritFrom(pseudoStyle.get());
    1685         setStyle(style.release());
    1686         return;
    1687     }
    1688 
    1689     setStyle(pseudoStyle);
    1690 }
    1691 
    16921667LayoutRect RenderObject::viewRect() const
    16931668{
     
    19141889bool RenderObject::hasEntirelyFixedBackground() const
    19151890{
    1916     return m_style->hasEntirelyFixedBackground();
     1891    return style()->hasEntirelyFixedBackground();
    19171892}
    19181893
     
    19361911        return o;
    19371912
    1938     EPosition pos = m_style->position();
     1913    EPosition pos = style()->position();
    19391914    if (pos == FixedPosition) {
    19401915        // container() can be called on an object that is not in the
     
    23032278    ASSERT(document().styleSheetCollection().usesFirstLineRules());
    23042279
    2305     if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get()))
    2306         return style.get();
    2307 
    2308     return m_style.get();
     2280    RenderStyle* style = this->style();
     2281    if (RefPtr<RenderStyle> firstLineStyle = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, style))
     2282        return firstLineStyle.get();
     2283
     2284    return style;
    23092285}
    23102286
  • trunk/Source/WebCore/rendering/RenderObject.h

    r156422 r156527  
    705705    virtual void dirtyLinesFromChangedChild(RenderObject*);
    706706
    707     // Called to update a style that is allowed to trigger animations.
    708     // FIXME: Right now this will typically be called only when updating happens from the DOM on explicit elements.
    709     // We don't yet handle generated content animation such as first-letter or before/after (we'll worry about this later).
    710     void setAnimatableStyle(PassRefPtr<RenderStyle>);
    711 
    712     // Set the style of the object and update the state of the object accordingly.
    713     virtual void setStyle(PassRefPtr<RenderStyle>) = 0;
    714 
    715     // Set the style of the object if it's generated content.
    716     void setPseudoStyle(PassRefPtr<RenderStyle>);
    717 
    718     // Updates only the local style ptr of the object.  Does not update the state of the object,
    719     // and so only should be called when the style is known not to have changed (or from setStyle).
    720     void setStyleInternal(PassRefPtr<RenderStyle> style) { m_style = style; }
    721 
    722707    // returns the containing block level element for this element.
    723708    RenderBlock* containingBlock() const;
     
    774759    virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
    775760
    776     RenderStyle* style() const { return m_style.get(); }
     761    RenderStyle* style() const;
    777762    RenderStyle* firstLineStyle() const { return document().styleSheetCollection().usesFirstLineRules() ? cachedFirstLineStyle() : style(); }
    778763    RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
     
    1002987    void checkBlockPositionedObjectsNeedLayout();
    1003988#endif
    1004 
    1005     RefPtr<RenderStyle> m_style;
    1006989
    1007990    Node* m_node;
     
    11431126inline bool RenderObject::isBeforeContent() const
    11441127{
    1145     if (style()->styleType() != BEFORE)
    1146         return false;
    11471128    // Text nodes don't have their own styles, so ignore the style on a text node.
    11481129    if (isText())
    11491130        return false;
     1131    if (style()->styleType() != BEFORE)
     1132        return false;
    11501133    return true;
    11511134}
     
    11531136inline bool RenderObject::isAfterContent() const
    11541137{
    1155     if (style()->styleType() != AFTER)
    1156         return false;
    11571138    // Text nodes don't have their own styles, so ignore the style on a text node.
    11581139    if (isText())
     1140        return false;
     1141    if (style()->styleType() != AFTER)
    11591142        return false;
    11601143    return true;
     
    12151198        markContainingBlocksForLayout();
    12161199        if (hasLayer()) {
    1217             if (oldStyle && m_style->diffRequiresRepaint(oldStyle))
     1200            if (oldStyle && style()->diffRequiresRepaint(oldStyle))
    12181201                setLayerNeedsFullRepaint();
    12191202            else
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r156478 r156527  
    531531        RefPtr<RenderStyle> objectRegionStyle = object->style();
    532532        RefPtr<RenderStyle> objectOriginalStyle = iter->value.style;
    533         object->setStyleInternal(objectOriginalStyle);
     533        if (object->isRenderElement())
     534            toRenderElement(object)->setStyleInternal(objectOriginalStyle);
    534535
    535536        bool shouldCacheRegionStyle = iter->value.cached;
     
    611612
    612613    RefPtr<RenderStyle> objectOriginalStyle = object->style();
    613     object->setStyleInternal(styleInRegion);
     614    if (object->isRenderElement())
     615        toRenderElement(object)->setStyleInternal(styleInRegion);
    614616
    615617    if (object->isBoxModelObject() && !object->hasBoxDecorations()) {
  • trunk/Source/WebCore/rendering/RenderSearchField.cpp

    r155671 r156527  
    173173void RenderSearchField::updateCancelButtonVisibility() const
    174174{
    175     RenderObject* cancelButtonRenderer = cancelButtonElement()->renderer();
     175    RenderElement* cancelButtonRenderer = cancelButtonElement()->renderer();
    176176    if (!cancelButtonRenderer)
    177177        return;
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r156325 r156527  
    199199{
    200200    return false;
    201 }
    202 
    203 void RenderText::setStyle(PassRefPtr<RenderStyle> style)
    204 {
    205     if (style == this->style())
    206         return;
    207 
    208     StyleDifference diff = StyleDifferenceEqual;
    209     unsigned contextSensitiveProperties = ContextSensitivePropertyNone;
    210     RefPtr<RenderStyle> oldStyle = this->style();
    211     if (oldStyle.get())
    212         diff = oldStyle->diff(style.get(), contextSensitiveProperties);
    213 
    214     setStyleInternal(style);
    215 
    216     styleDidChange(diff, oldStyle.get());
    217201}
    218202
  • trunk/Source/WebCore/rendering/RenderText.h

    r156325 r156527  
    2424#define RenderText_h
    2525
    26 #include "RenderObject.h"
     26#include "RenderElement.h"
    2727#include <wtf/Forward.h>
    2828
     
    4747    virtual bool isTextFragment() const;
    4848
    49     virtual void setStyle(PassRefPtr<RenderStyle>) OVERRIDE FINAL;
     49    RenderStyle* style() const;
     50    RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
    5051
    5152    virtual String originalText() const;
     
    143144    void removeAndDestroyTextBoxes();
    144145
     146    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     147
    145148#if ENABLE(IOS_TEXT_AUTOSIZING)
    146149    float candidateComputedTextSize() const { return m_candidateComputedTextSize; }
     
    151154    virtual void computePreferredLogicalWidths(float leadWidth);
    152155    virtual void willBeDestroyed() OVERRIDE;
    153 
    154     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    155156
    156157    virtual void setTextInternal(const String&);
     
    244245void toRenderText(const RenderText&);
    245246
     247inline RenderStyle* RenderText::style() const
     248{
     249    return parent()->style();
     250}
     251
    246252#ifdef NDEBUG
    247253inline void RenderText::checkConsistency() const
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r156278 r156527  
    235235        // If we can't figure out the text, leave it blank.
    236236        if (text) {
    237             RefPtr<RenderStyle> textStyle = RenderStyle::create();
    238             textStyle->inheritFrom(container->style());
    239             text->setStyle(textStyle.release());
    240237            container->addChild(text);
    241238        }
     
    317314   
    318315    RenderText* text = RenderText::createAnonymous(document(), String(&glyph, 1));
    319     text->setStyle(container->style());
    320316    parent->addChild(text);
    321317    return container;
  • trunk/Source/WebCore/rendering/style/ContentData.cpp

    r156090 r156527  
    7979}
    8080
    81 RenderObject* TextContentData::createRenderer(Document& document, RenderStyle& pseudoStyle) const
     81RenderObject* TextContentData::createRenderer(Document& document, RenderStyle&) const
    8282{
    83     RenderObject* renderer = RenderTextFragment::createAnonymous(document, m_text);
    84     renderer->setPseudoStyle(&pseudoStyle);
    85     return renderer;
     83    return RenderTextFragment::createAnonymous(document, m_text);
    8684}
    8785
    88 RenderObject* CounterContentData::createRenderer(Document& document, RenderStyle& pseudoStyle) const
     86RenderObject* CounterContentData::createRenderer(Document& document, RenderStyle&) const
    8987{
    90     RenderObject* renderer = RenderCounter::createAnonymous(document, *m_counter);
    91     renderer->setPseudoStyle(&pseudoStyle);
    92     return renderer;
     88    return RenderCounter::createAnonymous(document, *m_counter);
    9389}
    9490
    95 RenderObject* QuoteContentData::createRenderer(Document& document, RenderStyle& pseudoStyle) const
     91RenderObject* QuoteContentData::createRenderer(Document& document, RenderStyle&) const
    9692{
    97     RenderObject* renderer = RenderQuote::createAnonymous(document, m_quote);
    98     renderer->setPseudoStyle(&pseudoStyle);
    99     return renderer;
     93    return RenderQuote::createAnonymous(document, m_quote);
    10094}
    10195
  • trunk/Source/WebCore/style/StyleResolveTree.cpp

    r156422 r156527  
    367367
    368368    Document& document = textNode.document();
    369     RefPtr<RenderStyle> style;
    370     bool resetStyleInheritance = textNode.parentNode()->isShadowRoot() && toShadowRoot(textNode.parentNode())->resetStyleInheritance();
    371     if (resetStyleInheritance)
    372         style = document.ensureStyleResolver().defaultStyleForElement();
    373     else
    374         style = parentRenderer->style();
     369    RefPtr<RenderStyle> style = parentRenderer->style();
    375370
    376371    if (!textRendererIsNeeded(textNode, *parentRenderer, *style))
     
    391386    textNode.setRenderer(newRenderer);
    392387    // Parent takes care of the animations, no need to call setAnimatableStyle.
    393     newRenderer->setStyle(style.release());
    394388    parentRenderer->addChild(newRenderer, nextRenderer);
    395389}
     
    606600    }
    607601
    608     if (RenderObject* renderer = current.renderer()) {
     602    if (RenderElement* renderer = current.renderer()) {
    609603        if (localChange != NoChange || pseudoStyleCacheIsInvalid(renderer, newStyle.get()) || (inheritedChange == Force && renderer->requiresForcedStyleRecalcPropagation()) || current.styleChangeType() == SyntheticStyleChange)
    610604            renderer->setAnimatableStyle(newStyle.get());
     
    632626}
    633627
    634 static void updateTextStyle(Text& text, RenderStyle* parentElementStyle, Style::Change change)
     628static void updateTextStyle(Text& text)
    635629{
    636630    RenderText* renderer = toRenderText(text.renderer());
    637 
    638     if (change != Style::NoChange && renderer)
    639         renderer->setStyle(parentElementStyle);
    640631
    641632    if (!text.needsStyleRecalc())
     
    650641}
    651642
    652 static void resolveShadowTree(ShadowRoot* shadowRoot, RenderStyle* parentElementStyle, Style::Change change)
     643static void resolveShadowTree(ShadowRoot* shadowRoot, Style::Change change)
    653644{
    654645    if (!shadowRoot)
     
    660651        if (child->isTextNode()) {
    661652            // Current user agent ShadowRoots don't have immediate text children so this branch is never actually taken.
    662             updateTextStyle(*toText(child), parentElementStyle, change);
     653            updateTextStyle(*toText(child));
    663654            continue;
    664655        }
     
    752743        StyleResolverParentPusher parentPusher(&current);
    753744
    754         RenderStyle* currentStyle = current.renderStyle();
    755 
    756745        if (ShadowRoot* shadowRoot = current.shadowRoot()) {
    757746            if (change >= Inherit || shadowRoot->childNeedsStyleRecalc() || shadowRoot->needsStyleRecalc()) {
    758747                parentPusher.push();
    759                 resolveShadowTree(shadowRoot, currentStyle, change);
     748                resolveShadowTree(shadowRoot, change);
    760749            }
    761750        }
     
    770759        for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
    771760            if (child->isTextNode()) {
    772                 updateTextStyle(*toText(child), currentStyle, change);
     761                updateTextStyle(*toText(child));
    773762                continue;
    774763            }
  • trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm

    r155641 r156527  
    5959#import <WebCore/Range.h>
    6060#import <WebCore/RegularExpression.h>
    61 #import <WebCore/RenderObject.h>
     61#import <WebCore/RenderElement.h>
    6262#import <WebCore/TextResourceDecoder.h>
    6363#import <WebKit/DOMHTMLInputElement.h>
Note: See TracChangeset for help on using the changeset viewer.