- Revision
- 121131
- Author
- [email protected]
- Date
- 2012-06-24 19:25:43 -0700 (Sun, 24 Jun 2012)
Log Message
NodeRenderingContext::AttachingPhase is redundant.
https://bugs.webkit.org/show_bug.cgi?id=79220
Reviewed by Dimitri Glazkov.
This change removes NodeRenderingContext::AttachingPhase and
NodeRenderingContext::m_phase respectively. The state originally
represented as m_phase is naturally encoded into other member variables.
NodeRenderingContext::m_visualParentShadow is also replaced, with
a local variable parentScope.
Basically, what NodeRenderingContext wants to know is the parent of
the composed shadow tree and an optional insertion point where the
node is distributed. Once these becomes clear, m_phase is no longer required.
It was rather a historical artifact.
No new tests. No behavioral change.
* dom/NodeRenderingContext.cpp: Replaced m_phase with implicit states.
(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::NodeRenderingContext::nextRenderer):
(WebCore::NodeRenderingContext::previousRenderer):
(WebCore::NodeRenderingContext::parentRenderer):
(WebCore::NodeRenderingContext::shouldCreateRenderer):
(WebCore::NodeRenderingContext::isOnEncapsulationBoundary):
(WebCore::NodeRenderingContext::isOnUpperEncapsulationBoundary):
* dom/NodeRenderingContext.h:
(NodeRenderingContext):
(WebCore::NodeRenderingContext::parentNodeForRenderingAndStyle): Removed an assert which checks m_phase.
(WebCore::NodeRenderingContext::resetStyleInheritance): Removed an assert which checks m_phase.
* html/shadow/InsertionPoint.h:
(WebCore::isInsertionPoint): Fix null case check.
(WebCore::isLowerEncapsulationBoundary): Renamed from isShadowBoundary()
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (121130 => 121131)
--- trunk/Source/WebCore/ChangeLog 2012-06-25 02:14:26 UTC (rev 121130)
+++ trunk/Source/WebCore/ChangeLog 2012-06-25 02:25:43 UTC (rev 121131)
@@ -1,3 +1,40 @@
+2012-06-24 MORITA Hajime <[email protected]>
+
+ NodeRenderingContext::AttachingPhase is redundant.
+ https://bugs.webkit.org/show_bug.cgi?id=79220
+
+ Reviewed by Dimitri Glazkov.
+
+ This change removes NodeRenderingContext::AttachingPhase and
+ NodeRenderingContext::m_phase respectively. The state originally
+ represented as m_phase is naturally encoded into other member variables.
+
+ NodeRenderingContext::m_visualParentShadow is also replaced, with
+ a local variable parentScope.
+
+ Basically, what NodeRenderingContext wants to know is the parent of
+ the composed shadow tree and an optional insertion point where the
+ node is distributed. Once these becomes clear, m_phase is no longer required.
+ It was rather a historical artifact.
+
+ No new tests. No behavioral change.
+
+ * dom/NodeRenderingContext.cpp: Replaced m_phase with implicit states.
+ (WebCore::NodeRenderingContext::NodeRenderingContext):
+ (WebCore::NodeRenderingContext::nextRenderer):
+ (WebCore::NodeRenderingContext::previousRenderer):
+ (WebCore::NodeRenderingContext::parentRenderer):
+ (WebCore::NodeRenderingContext::shouldCreateRenderer):
+ (WebCore::NodeRenderingContext::isOnEncapsulationBoundary):
+ (WebCore::NodeRenderingContext::isOnUpperEncapsulationBoundary):
+ * dom/NodeRenderingContext.h:
+ (NodeRenderingContext):
+ (WebCore::NodeRenderingContext::parentNodeForRenderingAndStyle): Removed an assert which checks m_phase.
+ (WebCore::NodeRenderingContext::resetStyleInheritance): Removed an assert which checks m_phase.
+ * html/shadow/InsertionPoint.h:
+ (WebCore::isInsertionPoint): Fix null case check.
+ (WebCore::isLowerEncapsulationBoundary): Renamed from isShadowBoundary()
+
2012-06-24 Antti Koivisto <[email protected]>
REGRESSION(r121124): LayoutTests/fast/block/inline-children-root-linebox-crash.html asserts
Modified: trunk/Source/WebCore/dom/NodeRenderingContext.cpp (121130 => 121131)
--- trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2012-06-25 02:14:26 UTC (rev 121130)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2012-06-25 02:25:43 UTC (rev 121131)
@@ -52,11 +52,9 @@
static RenderObject* lastRendererOf(Node*);
NodeRenderingContext::NodeRenderingContext(Node* node)
- : m_phase(AttachingNotInTree)
- , m_node(node)
+ : m_node(node)
, m_parentNodeForRenderingAndStyle(0)
, m_resetStyleInheritance(false)
- , m_visualParentShadow(0)
, m_insertionPoint(0)
, m_style(0)
, m_parentFlowRenderer(0)
@@ -66,71 +64,68 @@
return;
if (parent->isShadowRoot() && toShadowRoot(parent)->isYoungest()) {
- m_phase = AttachingShadowChild;
m_parentNodeForRenderingAndStyle = toShadowRoot(parent)->host();
m_resetStyleInheritance = toShadowRoot(parent)->resetStyleInheritance();
return;
}
if (parent->isElementNode() || parent->isShadowRoot()) {
+ ElementShadow* parentShadow = 0;
+
if (parent->isElementNode())
- m_visualParentShadow = toElement(parent)->shadow();
+ parentShadow = toElement(parent)->shadow();
else if (parent->isShadowRoot())
- m_visualParentShadow = toShadowRoot(parent)->owner();
+ parentShadow = toShadowRoot(parent)->owner();
- if (m_visualParentShadow) {
- m_visualParentShadow->ensureDistribution();
+ if (parentShadow) {
+ parentShadow->ensureDistribution();
- if ((m_insertionPoint = m_visualParentShadow->insertionPointFor(m_node))) {
- if (m_insertionPoint->shadowRoot()->isUsedForRendering()) {
- m_phase = AttachingDistributed;
- NodeRenderingContext insertionPointContext(m_insertionPoint);
+ if (InsertionPoint* insertionPoint = parentShadow->insertionPointFor(m_node)) {
+ if (insertionPoint->shadowRoot()->isUsedForRendering()) {
+ NodeRenderingContext insertionPointContext(insertionPoint);
m_parentNodeForRenderingAndStyle = insertionPointContext.parentNodeForRenderingAndStyle();
m_resetStyleInheritance = insertionPointContext.resetStyleInheritance();
+ m_insertionPoint = insertionPoint;
return;
}
}
- m_phase = AttachingNotDistributed;
- m_parentNodeForRenderingAndStyle = parent;
return;
}
- if (isShadowBoundary(parent)) {
- ShadowRoot* parentShadowRoot = parent->shadowRoot();
- parentShadowRoot->owner()->ensureDistribution();
+ if (isLowerEncapsulationBoundary(parent)) {
+ ShadowRoot* parentScope = parent->shadowRoot();
+ parentScope->owner()->ensureDistribution();
- if (!parentShadowRoot->isUsedForRendering()) {
- m_phase = AttachingNotDistributed;
- m_parentNodeForRenderingAndStyle = parent;
+ // The shadow tree isn't part of composed tree.
+ if (!parentScope->isUsedForRendering())
return;
- }
+ // the parent insertion point doesn't need any fallback content.
if (toInsertionPoint(parent)->hasDistribution())
- m_phase = AttachingNotFallbacked;
- else
- m_phase = AttachingFallbacked;
+ return;
if (toInsertionPoint(parent)->isActive()) {
+ // Uses m_node as a fallback node of the insertion point.
NodeRenderingContext parentContext(parent);
m_parentNodeForRenderingAndStyle = parentContext.parentNodeForRenderingAndStyle();
m_resetStyleInheritance = parentContext.resetStyleInheritance();
- } else
- m_parentNodeForRenderingAndStyle = parent;
+ return;
+ }
+
+ // The insertion point isn't active thus behaves as a plain old element.
+ m_parentNodeForRenderingAndStyle = parent;
return;
}
}
- m_phase = AttachingStraight;
m_parentNodeForRenderingAndStyle = parent;
}
NodeRenderingContext::NodeRenderingContext(Node* node, RenderStyle* style)
- : m_phase(Calculating)
- , m_node(node)
+ : m_node(node)
, m_parentNodeForRenderingAndStyle(0)
, m_resetStyleInheritance(false)
- , m_visualParentShadow(0)
, m_insertionPoint(0)
, m_style(style)
, m_parentFlowRenderer(0)
@@ -241,14 +236,13 @@
RenderObject* NodeRenderingContext::nextRenderer() const
{
- ASSERT(m_node->renderer() || m_phase != Calculating);
if (RenderObject* renderer = m_node->renderer())
return renderer->nextSibling();
if (m_parentFlowRenderer)
return m_parentFlowRenderer->nextRendererForNode(m_node);
- if (m_phase == AttachingDistributed) {
+ if (m_insertionPoint) {
if (RenderObject* found = nextRendererOfInsertionPoint(m_insertionPoint, m_node))
return found;
return NodeRenderingContext(m_insertionPoint).nextRenderer();
@@ -264,15 +258,13 @@
RenderObject* NodeRenderingContext::previousRenderer() const
{
- ASSERT(m_node->renderer() || m_phase != Calculating);
-
if (RenderObject* renderer = m_node->renderer())
return renderer->previousSibling();
if (m_parentFlowRenderer)
return m_parentFlowRenderer->previousRendererForNode(m_node);
- if (m_phase == AttachingDistributed) {
+ if (m_insertionPoint) {
if (RenderObject* found = previousRendererOfInsertionPoint(m_insertionPoint, m_node))
return found;
return NodeRenderingContext(m_insertionPoint).previousRenderer();
@@ -285,24 +277,17 @@
RenderObject* NodeRenderingContext::parentRenderer() const
{
- if (RenderObject* renderer = m_node->renderer()) {
- ASSERT(m_phase == Calculating);
+ if (RenderObject* renderer = m_node->renderer())
return renderer->parent();
- }
-
if (m_parentFlowRenderer)
return m_parentFlowRenderer;
- ASSERT(m_phase != Calculating);
return m_parentNodeForRenderingAndStyle ? m_parentNodeForRenderingAndStyle->renderer() : 0;
}
bool NodeRenderingContext::shouldCreateRenderer() const
{
- ASSERT(m_phase != Calculating);
- ASSERT(parentNodeForRenderingAndStyle());
-
- if (m_phase == AttachingNotInTree || m_phase == AttachingNotDistributed || m_phase == AttachingNotFallbacked)
+ if (!m_parentNodeForRenderingAndStyle)
return false;
RenderObject* parentRenderer = this->parentRenderer();
if (!parentRenderer)
@@ -340,6 +325,16 @@
flowThreadController->registerNamedFlowContentNode(m_node, m_parentFlowRenderer);
}
+bool NodeRenderingContext::isOnEncapsulationBoundary() const
+{
+ return isOnUpperEncapsulationBoundary() || isLowerEncapsulationBoundary(m_insertionPoint) || isLowerEncapsulationBoundary(m_node->parentNode());
+}
+
+bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
+{
+ return m_node->parentNode() && m_node->parentNode()->isShadowRoot();
+}
+
NodeRendererFactory::NodeRendererFactory(Node* node)
: m_context(node)
{
Modified: trunk/Source/WebCore/dom/NodeRenderingContext.h (121130 => 121131)
--- trunk/Source/WebCore/dom/NodeRenderingContext.h 2012-06-25 02:14:26 UTC (rev 121130)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.h 2012-06-25 02:25:43 UTC (rev 121131)
@@ -68,22 +68,9 @@
void moveToFlowThreadIfNeeded();
private:
- enum AttachingPhase {
- Calculating,
- AttachingStraight,
- AttachingNotInTree,
- AttachingDistributed,
- AttachingNotDistributed,
- AttachingFallbacked,
- AttachingNotFallbacked,
- AttachingShadowChild,
- };
-
- AttachingPhase m_phase;
Node* m_node;
ContainerNode* m_parentNodeForRenderingAndStyle;
bool m_resetStyleInheritance;
- ElementShadow* m_visualParentShadow;
InsertionPoint* m_insertionPoint;
RefPtr<RenderStyle> m_style;
RenderNamedFlowThread* m_parentFlowRenderer;
@@ -97,13 +84,11 @@
inline ContainerNode* NodeRenderingContext::parentNodeForRenderingAndStyle() const
{
- ASSERT(m_phase != Calculating);
return m_parentNodeForRenderingAndStyle;
}
inline bool NodeRenderingContext::resetStyleInheritance() const
{
- ASSERT(m_phase != Calculating);
return m_resetStyleInheritance;
}
@@ -117,18 +102,6 @@
return m_insertionPoint;
}
-inline bool NodeRenderingContext::isOnEncapsulationBoundary() const
-{
- return (m_phase == AttachingDistributed
- || m_phase == AttachingShadowChild
- || m_phase == AttachingFallbacked);
-}
-
-inline bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
-{
- return m_phase == AttachingShadowChild;
-}
-
class NodeRendererFactory {
WTF_MAKE_NONCOPYABLE(NodeRendererFactory);
WTF_MAKE_FAST_ALLOCATED;
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (121130 => 121131)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-06-25 02:14:26 UTC (rev 121130)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-06-25 02:25:43 UTC (rev 121131)
@@ -80,7 +80,7 @@
inline bool isInsertionPoint(const Node* node)
{
if (!node)
- return true;
+ return false;
if (node->isHTMLElement() && toHTMLElement(node)->isInsertionPoint())
return true;
@@ -105,7 +105,7 @@
return isInsertionPoint(node) && toInsertionPoint(node)->isActive();
}
-inline bool isShadowBoundary(Node* node)
+inline bool isLowerEncapsulationBoundary(Node* node)
{
if (!isInsertionPoint(node))
return false;