Ignore:
Timestamp:
Oct 27, 2013, 3:54:07 PM (12 years ago)
Author:
[email protected]
Message:

Renderers should receive their style at construction.
<https://webkit.org/b/123396>

Pass the RenderStyle to all non-text renderer constructors.
After construction, initializeStyle() must be called (as a stopgap
measure) until we are able to do style-derived initialization
without virtual function calls.

With this change, RenderElement::m_style is never null. Subsequent
patches will add enforcement for this and also make style() return
a RenderStyle&.

I'm adding three FIXME's in this patch:

  • createRendererIfNeeded() calls AnimationController to set up the initial style manually instead of asking RenderElement's setAnimatedStyle() to do it. This can probably be done in a nicer way, but it's not clear yet how.
  • ImageContentData::createRenderer() does a bit of unnecessary work. This should be easy to clean up but got too distracting to be part of this patch.
  • Document::createRenderTree() creates the RenderView with an initial dummy RenderStyle. I've done this because resolving the document style assumes we already have a RenderView.

For styleWillChange() implementations to detect that they are
reacting to the initial style, I've added a hasInitializedStyle()
function on RenderElement. This will return false until you've
called initializeStyle() on the renderer. This should go away
along with initializeStyle() eventually.

Reviewed by Antti Koivisto.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r157662 r158097  
    4343const int cDefaultHeight = 150;
    4444
    45 RenderReplaced::RenderReplaced(Element& element)
    46     : RenderBox(element, RenderReplacedFlag)
     45RenderReplaced::RenderReplaced(Element& element, PassRef<RenderStyle> style)
     46    : RenderBox(element, std::move(style), RenderReplacedFlag)
    4747    , m_intrinsicSize(cDefaultWidth, cDefaultHeight)
    4848{
     
    5050}
    5151
    52 RenderReplaced::RenderReplaced(Element& element, const LayoutSize& intrinsicSize)
    53     : RenderBox(element, RenderReplacedFlag)
     52RenderReplaced::RenderReplaced(Element& element, PassRef<RenderStyle> style, const LayoutSize& intrinsicSize)
     53    : RenderBox(element, std::move(style), RenderReplacedFlag)
    5454    , m_intrinsicSize(intrinsicSize)
    5555{
     
    5757}
    5858
    59 RenderReplaced::RenderReplaced(Document& document, const LayoutSize& intrinsicSize)
    60     : RenderBox(document, RenderReplacedFlag)
     59RenderReplaced::RenderReplaced(Document& document, PassRef<RenderStyle> style, const LayoutSize& intrinsicSize)
     60    : RenderBox(document, std::move(style), RenderReplacedFlag)
    6161    , m_intrinsicSize(intrinsicSize)
    6262{
Note: See TracChangeset for help on using the changeset viewer.