Commit a478fdac authored by antti@apple.com's avatar antti@apple.com
Browse files

<https://webkit.org/b/120078> Replace NodeRenderingContext with RenderStyle&...

<https://webkit.org/b/120078> Replace NodeRenderingContext with RenderStyle& as shouldCreateRenderer() argument

Reviewed by Darin Adler.

This simplifies the code. NodeRenderingContext was only used for getting the RenderStyle.

* dom/Element.cpp:
(WebCore::Element::rendererIsNeeded):
* dom/Element.h:
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::elementInsideRegionNeedsRenderer):
(WebCore::NodeRenderingContext::createRendererForElementIfNeeded):
* dom/PseudoElement.cpp:
(WebCore::PseudoElement::rendererIsNeeded):
* dom/PseudoElement.h:
* html/HTMLAppletElement.cpp:
(WebCore::HTMLAppletElement::rendererIsNeeded):
* html/HTMLAppletElement.h:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::rendererIsNeeded):
* html/HTMLElement.h:
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::rendererIsNeeded):
* html/HTMLEmbedElement.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::rendererIsNeeded):
* html/HTMLFormElement.h:
* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::rendererIsNeeded):
* html/HTMLFrameElement.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::rendererIsNeeded):
* html/HTMLFrameSetElement.h:
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::rendererIsNeeded):
* html/HTMLIFrameElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::rendererIsNeeded):
* html/HTMLInputElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::rendererIsNeeded):
* html/HTMLMediaElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::rendererIsNeeded):
* html/HTMLObjectElement.h:
* html/HTMLOptGroupElement.h:
* html/HTMLOptionElement.h:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::rendererIsNeeded):
* html/HTMLVideoElement.h:
* html/shadow/DetailsMarkerControl.cpp:
(WebCore::DetailsMarkerControl::rendererIsNeeded):
* html/shadow/DetailsMarkerControl.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::rendererIsNeeded):
* html/shadow/InsertionPoint.h:
* html/shadow/MeterShadowElement.cpp:
(WebCore::MeterShadowElement::rendererIsNeeded):
(WebCore::MeterInnerElement::rendererIsNeeded):
* html/shadow/MeterShadowElement.h:
* html/shadow/ProgressShadowElement.cpp:
(WebCore::ProgressShadowElement::rendererIsNeeded):
(WebCore::ProgressInnerElement::rendererIsNeeded):
* html/shadow/ProgressShadowElement.h:
* svg/SVGDescElement.h:
* svg/SVGElement.h:
(WebCore::SVGElement::rendererIsNeeded):
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::rendererIsNeeded):
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/SVGFontElement.h:
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::rendererIsNeeded):
* svg/SVGForeignObjectElement.h:
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::rendererIsNeeded):
* svg/SVGGElement.h:
* svg/SVGGlyphElement.h:
* svg/SVGGlyphRefElement.h:
* svg/SVGHKernElement.h:
* svg/SVGMarkerElement.h:
* svg/SVGMissingGlyphElement.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::rendererIsNeeded):
* svg/SVGSVGElement.h:
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::rendererIsNeeded):
* svg/SVGStopElement.h:
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::rendererIsNeeded):
* svg/SVGStyledElement.h:
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::rendererIsNeeded):
* svg/SVGTRefElement.h:
* svg/SVGTSpanElement.cpp:
(WebCore::SVGTSpanElement::rendererIsNeeded):
* svg/SVGTSpanElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::rendererIsNeeded):
* svg/SVGTextPathElement.h:
* svg/SVGTitleElement.h:
* svg/SVGVKernElement.h:
* svg/SVGViewElement.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a9be5099
2013-08-20 Antti Koivisto <antti@apple.com>
<https://webkit.org/b/120078> Replace NodeRenderingContext with RenderStyle& as shouldCreateRenderer() argument
Reviewed by Darin Adler.
This simplifies the code. NodeRenderingContext was only used for getting the RenderStyle.
* dom/Element.cpp:
(WebCore::Element::rendererIsNeeded):
* dom/Element.h:
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::elementInsideRegionNeedsRenderer):
(WebCore::NodeRenderingContext::createRendererForElementIfNeeded):
* dom/PseudoElement.cpp:
(WebCore::PseudoElement::rendererIsNeeded):
* dom/PseudoElement.h:
* html/HTMLAppletElement.cpp:
(WebCore::HTMLAppletElement::rendererIsNeeded):
* html/HTMLAppletElement.h:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::rendererIsNeeded):
* html/HTMLElement.h:
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::rendererIsNeeded):
* html/HTMLEmbedElement.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::rendererIsNeeded):
* html/HTMLFormElement.h:
* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::rendererIsNeeded):
* html/HTMLFrameElement.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::rendererIsNeeded):
* html/HTMLFrameSetElement.h:
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::rendererIsNeeded):
* html/HTMLIFrameElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::rendererIsNeeded):
* html/HTMLInputElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::rendererIsNeeded):
* html/HTMLMediaElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::rendererIsNeeded):
* html/HTMLObjectElement.h:
* html/HTMLOptGroupElement.h:
* html/HTMLOptionElement.h:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::rendererIsNeeded):
* html/HTMLVideoElement.h:
* html/shadow/DetailsMarkerControl.cpp:
(WebCore::DetailsMarkerControl::rendererIsNeeded):
* html/shadow/DetailsMarkerControl.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::rendererIsNeeded):
* html/shadow/InsertionPoint.h:
* html/shadow/MeterShadowElement.cpp:
(WebCore::MeterShadowElement::rendererIsNeeded):
(WebCore::MeterInnerElement::rendererIsNeeded):
* html/shadow/MeterShadowElement.h:
* html/shadow/ProgressShadowElement.cpp:
(WebCore::ProgressShadowElement::rendererIsNeeded):
(WebCore::ProgressInnerElement::rendererIsNeeded):
* html/shadow/ProgressShadowElement.h:
* svg/SVGDescElement.h:
* svg/SVGElement.h:
(WebCore::SVGElement::rendererIsNeeded):
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::rendererIsNeeded):
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/SVGFontElement.h:
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::rendererIsNeeded):
* svg/SVGForeignObjectElement.h:
* svg/SVGGElement.cpp:
(WebCore::SVGGElement::rendererIsNeeded):
* svg/SVGGElement.h:
* svg/SVGGlyphElement.h:
* svg/SVGGlyphRefElement.h:
* svg/SVGHKernElement.h:
* svg/SVGMarkerElement.h:
* svg/SVGMissingGlyphElement.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::rendererIsNeeded):
* svg/SVGSVGElement.h:
* svg/SVGStopElement.cpp:
(WebCore::SVGStopElement::rendererIsNeeded):
* svg/SVGStopElement.h:
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::rendererIsNeeded):
* svg/SVGStyledElement.h:
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::rendererIsNeeded):
* svg/SVGTRefElement.h:
* svg/SVGTSpanElement.cpp:
(WebCore::SVGTSpanElement::rendererIsNeeded):
* svg/SVGTSpanElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::rendererIsNeeded):
* svg/SVGTextPathElement.h:
* svg/SVGTitleElement.h:
* svg/SVGVKernElement.h:
* svg/SVGViewElement.h:
2013-08-20 Daniel Bates <dabates@apple.com>
 
<https://webkit.org/b/120088> Define Clipboard::hasData() only when building with drag support
......@@ -118,7 +118,7 @@ public:
void disconnectDescendantFrames();
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const { return true; }
virtual bool childShouldCreateRenderer(const Node*) const { return true; }
protected:
ContainerNode(Document*, ConstructionType = CreateContainer);
......
......@@ -2500,13 +2500,13 @@ const AtomicString& Element::UIActions() const
#if ENABLE(SVG)
bool Element::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool Element::childShouldCreateRenderer(const Node* child) const
{
// Only create renderers for SVG elements whose parents are SVG elements, or for proper <svg xmlns="svgNS"> subdocuments.
if (childContext.node()->isSVGElement())
return childContext.node()->hasTagName(SVGNames::svgTag) || isSVGElement();
if (child->isSVGElement())
return child->hasTagName(SVGNames::svgTag) || isSVGElement();
return ContainerNode::childShouldCreateRenderer(childContext);
return ContainerNode::childShouldCreateRenderer(child);
}
#endif
......
......@@ -481,7 +481,7 @@ public:
#endif
#if ENABLE(SVG)
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
virtual bool childShouldCreateRenderer(const Node*) const;
bool hasPendingResources() const;
void setHasPendingResources();
void clearHasPendingResources();
......
......@@ -190,7 +190,7 @@ bool NodeRenderingContext::shouldCreateRenderer() const
return false;
if (!parentRenderer->canHaveChildren() && !(m_node->isPseudoElement() && parentRenderer->canHaveGeneratedChildren()))
return false;
if (!m_renderingParent->childShouldCreateRenderer(*this))
if (!m_renderingParent->childShouldCreateRenderer(m_node))
return false;
return true;
}
......@@ -235,18 +235,6 @@ void NodeRenderingContext::moveToFlowThreadIfNeeded()
#endif
}
bool NodeRenderingContext::isOnEncapsulationBoundary() const
{
return isOnUpperEncapsulationBoundary()
|| isLowerEncapsulationBoundary(findInsertionPointOf(m_node))
|| isLowerEncapsulationBoundary(m_node->parentNode());
}
bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
{
return m_node->parentNode() && m_node->parentNode()->isShadowRoot();
}
void NodeRenderingContext::createRendererForElementIfNeeded()
{
ASSERT(!m_node->renderer());
......
......@@ -62,9 +62,6 @@ public:
const RenderStyle* style() const;
bool isOnUpperEncapsulationBoundary() const;
bool isOnEncapsulationBoundary() const;
private:
bool shouldCreateRenderer() const;
void moveToFlowThreadIfNeeded();
......
......@@ -135,6 +135,11 @@ inline ContainerNode* Node::parentOrShadowHostNode() const
return parentNode();
}
inline bool hasShadowRootParent(const Node* node)
{
return node->parentNode() && node->parentNode()->isShadowRoot();
}
} // namespace
#endif
......@@ -144,21 +144,21 @@ void HTMLDetailsElement::parseAttribute(const QualifiedName& name, const AtomicS
HTMLElement::parseAttribute(name, value);
}
bool HTMLDetailsElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool HTMLDetailsElement::childShouldCreateRenderer(const Node* child) const
{
if (childContext.node()->isPseudoElement())
return HTMLElement::childShouldCreateRenderer(childContext);
if (child->isPseudoElement())
return HTMLElement::childShouldCreateRenderer(child);
if (!childContext.isOnEncapsulationBoundary())
if (!hasShadowRootOrActiveInsertionPointParent(child))
return false;
if (m_isOpen)
return HTMLElement::childShouldCreateRenderer(childContext);
return HTMLElement::childShouldCreateRenderer(child);
if (!childContext.node()->hasTagName(summaryTag))
if (!child->hasTagName(summaryTag))
return false;
return childContext.node() == findMainSummary() && HTMLElement::childShouldCreateRenderer(childContext);
return child == findMainSummary() && HTMLElement::childShouldCreateRenderer(child);
}
void HTMLDetailsElement::toggleOpen()
......
......@@ -36,7 +36,7 @@ private:
HTMLDetailsElement(const QualifiedName&, Document*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
virtual bool childShouldCreateRenderer(const Node*) const OVERRIDE;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
virtual void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE;
......
......@@ -452,7 +452,7 @@ void HTMLFormControlElement::setCustomValidity(const String& error)
setNeedsValidityCheck();
}
bool HTMLFormControlElement::validationMessageShadowTreeContains(Node* node) const
bool HTMLFormControlElement::validationMessageShadowTreeContains(const Node* node) const
{
return m_validationMessage && m_validationMessage->shadowTreeContains(node);
}
......
......@@ -128,7 +128,7 @@ protected:
void setNeedsWillValidateCheck();
virtual bool recalcWillValidate() const;
bool validationMessageShadowTreeContains(Node*) const;
bool validationMessageShadowTreeContains(const Node*) const;
private:
virtual void refFormAssociatedElement() { ref(); }
......
......@@ -576,7 +576,7 @@ RenderObject* HTMLMediaElement::createRenderer(RenderArena* arena, RenderStyle*)
#endif
}
bool HTMLMediaElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool HTMLMediaElement::childShouldCreateRenderer(const Node* child) const
{
if (!hasMediaControls())
return false;
......@@ -584,8 +584,9 @@ bool HTMLMediaElement::childShouldCreateRenderer(const NodeRenderingContext& chi
// be rendered. So this should return false for most of the children.
// One exception is a shadow tree built for rendering controls which should be visible.
// So we let them go here by comparing its subtree root with one of the controls.
return (mediaControls()->treeScope() == childContext.node()->treeScope()
&& childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext));
return mediaControls()->treeScope() == child->treeScope()
&& hasShadowRootParent(child)
&& HTMLElement::childShouldCreateRenderer(child);
}
Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint)
......
......@@ -434,7 +434,7 @@ private:
virtual bool isMouseFocusable() const OVERRIDE;
virtual bool rendererIsNeeded(const RenderStyle&);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
virtual bool childShouldCreateRenderer(const Node*) const OVERRIDE;
virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
virtual void removedFrom(ContainerNode*) OVERRIDE;
virtual void didRecalcStyle(Style::Change);
......
......@@ -65,9 +65,9 @@ RenderObject* HTMLMeterElement::createRenderer(RenderArena* arena, RenderStyle*
return new (arena) RenderMeter(this);
}
bool HTMLMeterElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool HTMLMeterElement::childShouldCreateRenderer(const Node* child) const
{
return childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext);
return hasShadowRootParent(child) && HTMLElement::childShouldCreateRenderer(child);
}
void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
......
......@@ -73,7 +73,7 @@ private:
virtual bool recalcWillValidate() const { return false; }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
virtual bool childShouldCreateRenderer(const Node*) const OVERRIDE;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
void didElementStateChange();
......
......@@ -63,12 +63,12 @@ private:
RefPtr<RenderStyle> m_style;
};
inline bool isHTMLOptGroupElement(Node* node)
inline bool isHTMLOptGroupElement(const Node* node)
{
return node->hasTagName(HTMLNames::optgroupTag);
}
inline bool isHTMLOptGroupElement(Element* element)
inline bool isHTMLOptGroupElement(const Element* element)
{
return element->hasTagName(HTMLNames::optgroupTag);
}
......
......@@ -95,12 +95,12 @@ private:
RefPtr<RenderStyle> m_style;
};
inline bool isHTMLOptionElement(Node* node)
inline bool isHTMLOptionElement(const Node* node)
{
return node->hasTagName(HTMLNames::optionTag);
}
inline bool isHTMLOptionElement(Element* element)
inline bool isHTMLOptionElement(const Element* element)
{
return element->hasTagName(HTMLNames::optionTag);
}
......
......@@ -67,9 +67,9 @@ RenderObject* HTMLProgressElement::createRenderer(RenderArena* arena, RenderStyl
return new (arena) RenderProgress(this);
}
bool HTMLProgressElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool HTMLProgressElement::childShouldCreateRenderer(const Node* child) const
{
return childContext.isOnUpperEncapsulationBoundary() && HTMLElement::childShouldCreateRenderer(childContext);
return hasShadowRootParent(child) && HTMLElement::childShouldCreateRenderer(child);
}
RenderProgress* HTMLProgressElement::renderProgress() const
......
......@@ -55,7 +55,7 @@ private:
virtual bool supportLabels() const OVERRIDE { return true; }
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
virtual bool childShouldCreateRenderer(const Node*) const OVERRIDE;
RenderProgress* renderProgress() const;
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
......
......@@ -345,13 +345,13 @@ RenderObject* HTMLSelectElement::createRenderer(RenderArena* arena, RenderStyle*
return new (arena) RenderListBox(this);
}
bool HTMLSelectElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
bool HTMLSelectElement::childShouldCreateRenderer(const Node* child) const
{
if (!HTMLFormControlElementWithState::childShouldCreateRenderer(childContext))
if (!HTMLFormControlElementWithState::childShouldCreateRenderer(child))
return false;
if (!usesMenuList())
return isHTMLOptionElement(childContext.node()) || isHTMLOptGroupElement(childContext.node()) || validationMessageShadowTreeContains(childContext.node());
return validationMessageShadowTreeContains(childContext.node());
return isHTMLOptionElement(child) || isHTMLOptGroupElement(child) || validationMessageShadowTreeContains(child);
return validationMessageShadowTreeContains(child);
}
PassRefPtr<HTMLCollection> HTMLSelectElement::selectedOptions()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment