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

<https://webkit.org/b/120071> Replace NodeRenderingContext with Node* as...

<https://webkit.org/b/120071> Replace NodeRenderingContext with Node* as childShouldCreateRenderer() argument

Reviewed by Darin Adler.

This simplifies the code. NodeRenderingContext was basically only used for getting the Node.

* dom/ContainerNode.h:
(WebCore::ContainerNode::childShouldCreateRenderer):
* dom/Element.cpp:
(WebCore::Element::childShouldCreateRenderer):
* dom/Element.h:
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::shouldCreateRenderer):
* dom/NodeRenderingContext.h:
        
    Move isOnEncapsulationBoundary() to InsertionPoint.h and call it hasShadowRootOrActiveInsertionPointParent().
    Move isOnUpperEncapsulationBoundary() to ShadowRoot.h and call it hasShadowRootParent().

* dom/ShadowRoot.h:
(WebCore::hasShadowRootParent):
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::childShouldCreateRenderer):
* html/HTMLDetailsElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::validationMessageShadowTreeContains):
* html/HTMLFormControlElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::childShouldCreateRenderer):
* html/HTMLMediaElement.h:
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::childShouldCreateRenderer):
* html/HTMLMeterElement.h:
* html/HTMLOptGroupElement.h:
(WebCore::isHTMLOptGroupElement):
* html/HTMLOptionElement.h:
(WebCore::isHTMLOptionElement):
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::childShouldCreateRenderer):
* html/HTMLProgressElement.h:
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::childShouldCreateRenderer):
* html/HTMLSelectElement.h:
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::childShouldCreateRenderer):
* html/HTMLSummaryElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::childShouldCreateRenderer):
(WebCore::enclosingTextFormControl):
* html/HTMLTextFormControlElement.h:
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::shadowTreeContains):
* html/ValidationMessage.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::rendererIsNeeded):
* html/shadow/InsertionPoint.h:
(WebCore::isActiveInsertionPoint):
        
    Remove isShadowBoundary() as it was equivalent to isActive(). 
    Remove isLowerEncapsulationBoundary() as it was equivalent to isActiveInsertionPoint().

(WebCore::hasShadowRootOrActiveInsertionPointParent):
        
    Moved and renamed from NodeRenderingContext::isOnEncapsulationBoundary().

* svg/SVGAElement.cpp:
(WebCore::SVGAElement::childShouldCreateRenderer):
* svg/SVGAElement.h:
* svg/SVGAltGlyphElement.cpp:
(WebCore::SVGAltGlyphElement::childShouldCreateRenderer):
* svg/SVGAltGlyphElement.h:
* svg/SVGDocument.cpp:
(WebCore::SVGDocument::childShouldCreateRenderer):
* svg/SVGDocument.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::childShouldCreateRenderer):
* svg/SVGElement.h:
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::childShouldCreateRenderer):
* svg/SVGFilterElement.h:
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::childShouldCreateRenderer):
* svg/SVGForeignObjectElement.h:
* svg/SVGSVGElement.h:
(WebCore::toSVGSVGElement):
* svg/SVGSwitchElement.cpp:
(WebCore::SVGSwitchElement::childShouldCreateRenderer):
* svg/SVGSwitchElement.h:
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::childShouldCreateRenderer):
* svg/SVGTRefElement.h:
* svg/SVGTSpanElement.cpp:
(WebCore::SVGTSpanElement::childShouldCreateRenderer):
* svg/SVGTSpanElement.h:
* svg/SVGTextElement.cpp:
(WebCore::SVGTextElement::childShouldCreateRenderer):
* svg/SVGTextElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::childShouldCreateRenderer):
* svg/SVGTextPathElement.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c754a75
2013-08-20 Antti Koivisto <antti@apple.com>
<https://webkit.org/b/120071> Replace NodeRenderingContext with Node* as childShouldCreateRenderer() argument
Reviewed by Darin Adler.
This simplifies the code. NodeRenderingContext was basically only used for getting the Node.
* dom/ContainerNode.h:
(WebCore::ContainerNode::childShouldCreateRenderer):
* dom/Element.cpp:
(WebCore::Element::childShouldCreateRenderer):
* dom/Element.h:
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::shouldCreateRenderer):
* dom/NodeRenderingContext.h:
Move isOnEncapsulationBoundary() to InsertionPoint.h and call it hasShadowRootOrActiveInsertionPointParent().
Move isOnUpperEncapsulationBoundary() to ShadowRoot.h and call it hasShadowRootParent().
* dom/ShadowRoot.h:
(WebCore::hasShadowRootParent):
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::childShouldCreateRenderer):
* html/HTMLDetailsElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::validationMessageShadowTreeContains):
* html/HTMLFormControlElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::childShouldCreateRenderer):
* html/HTMLMediaElement.h:
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::childShouldCreateRenderer):
* html/HTMLMeterElement.h:
* html/HTMLOptGroupElement.h:
(WebCore::isHTMLOptGroupElement):
* html/HTMLOptionElement.h:
(WebCore::isHTMLOptionElement):
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::childShouldCreateRenderer):
* html/HTMLProgressElement.h:
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::childShouldCreateRenderer):
* html/HTMLSelectElement.h:
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::childShouldCreateRenderer):
* html/HTMLSummaryElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::childShouldCreateRenderer):
(WebCore::enclosingTextFormControl):
* html/HTMLTextFormControlElement.h:
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::shadowTreeContains):
* html/ValidationMessage.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::rendererIsNeeded):
* html/shadow/InsertionPoint.h:
(WebCore::isActiveInsertionPoint):
Remove isShadowBoundary() as it was equivalent to isActive().
Remove isLowerEncapsulationBoundary() as it was equivalent to isActiveInsertionPoint().
(WebCore::hasShadowRootOrActiveInsertionPointParent):
Moved and renamed from NodeRenderingContext::isOnEncapsulationBoundary().
* svg/SVGAElement.cpp:
(WebCore::SVGAElement::childShouldCreateRenderer):
* svg/SVGAElement.h:
* svg/SVGAltGlyphElement.cpp:
(WebCore::SVGAltGlyphElement::childShouldCreateRenderer):
* svg/SVGAltGlyphElement.h:
* svg/SVGDocument.cpp:
(WebCore::SVGDocument::childShouldCreateRenderer):
* svg/SVGDocument.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::childShouldCreateRenderer):
* svg/SVGElement.h:
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::childShouldCreateRenderer):
* svg/SVGFilterElement.h:
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::childShouldCreateRenderer):
* svg/SVGForeignObjectElement.h:
* svg/SVGSVGElement.h:
(WebCore::toSVGSVGElement):
* svg/SVGSwitchElement.cpp:
(WebCore::SVGSwitchElement::childShouldCreateRenderer):
* svg/SVGSwitchElement.h:
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::childShouldCreateRenderer):
* svg/SVGTRefElement.h:
* svg/SVGTSpanElement.cpp:
(WebCore::SVGTSpanElement::childShouldCreateRenderer):
* svg/SVGTSpanElement.h:
* svg/SVGTextElement.cpp:
(WebCore::SVGTextElement::childShouldCreateRenderer):
* svg/SVGTextElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::childShouldCreateRenderer):
* svg/SVGTextPathElement.h:
2013-08-20 Benjamin Poulain <benjamin@webkit.org>
 
<https://webkit.org/b/120050> Don't bother using a Vector for the ouput of querySelector, just return the first element found
......@@ -30,7 +30,6 @@
#include "MutationEvent.h"
#include "MutationObserverInterestGroup.h"
#include "MutationRecord.h"
#include "NodeRenderingContext.h"
#include "RenderText.h"
#include "StyleInheritedData.h"
#include "Text.h"
......
......@@ -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);
......
......@@ -70,7 +70,6 @@
#include "NamedNodeMap.h"
#include "NodeList.h"
#include "NodeRenderStyle.h"
#include "NodeRenderingContext.h"
#include "Page.h"
#include "PointerLockController.h"
#include "PseudoElement.h"
......@@ -2500,13 +2499,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();
......
......@@ -70,7 +70,6 @@ class NameNodeList;
class NodeList;
class NodeListsNodeData;
class NodeRareData;
class NodeRenderingContext;
class PlatformKeyboardEvent;
class PlatformMouseEvent;
class PlatformWheelEvent;
......
......@@ -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();
......
......@@ -29,7 +29,6 @@
#include "ContentData.h"
#include "InspectorInstrumentation.h"
#include "NodeRenderingContext.h"
#include "RenderObject.h"
#include "RenderQuote.h"
......
......@@ -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
......@@ -28,6 +28,7 @@
namespace WebCore {
class NodeRenderingContext;
class RenderText;
class Text : public CharacterData {
......
......@@ -27,7 +27,6 @@
#include "HTMLSummaryElement.h"
#include "LocalizedStrings.h"
#include "MouseEvent.h"
#include "NodeRenderingContext.h"
#include "RenderBlock.h"
#include "ShadowRoot.h"
#include "Text.h"
......@@ -144,21 +143,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(); }
......
......@@ -41,7 +41,6 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLTableElement.h"
#include "NodeRenderingContext.h"
#include "Page.h"
#include "RenderTextControl.h"
#include "ScriptController.h"
......
......@@ -35,7 +35,6 @@
#include "HTMLNames.h"
#include "Length.h"
#include "MouseEvent.h"
#include "NodeRenderingContext.h"
#include "RenderFrameSet.h"
#include "ScriptEventListener.h"
#include "Text.h"
......
......@@ -30,7 +30,6 @@
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLNames.h"
#include "NodeRenderingContext.h"
#include "RenderIFrame.h"
#include "ScriptableDocumentParser.h"
......
......@@ -67,7 +67,6 @@
#include "MediaQueryEvaluator.h"
#include "MouseEvent.h"
#include "MIMETypeRegistry.h"
#include "NodeRenderingContext.h"
#include "Page.h"
#include "PageActivityAssertionToken.h"
#include "PageGroup.h"
......@@ -576,7 +575,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 +583,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);
......
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