Diff
Modified: trunk/Source/WebCore/ChangeLog (136327 => 136328)
--- trunk/Source/WebCore/ChangeLog 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/ChangeLog 2012-12-02 11:16:33 UTC (rev 136328)
@@ -1,3 +1,46 @@
+2012-12-02 Elliott Sprehn <[email protected]>
+
+ Simplify treeScope and setTreeScope
+ https://bugs.webkit.org/show_bug.cgi?id=103708
+
+ Reviewed by Hajime Morita.
+
+ By making the default treeScope in NodeRareData the document and then
+ moving the m_treeScope field to NodeRareDataBase we can make treeScope
+ inline and make setTreeScope much simpler.
+
+ There's also no reason to save calls to rareData() now that the map has
+ been eliminated by r133372 so we can eliminate the return value from
+ setTreeScope.
+
+ No new tests, just refactoring.
+
+ * WebCore.exp.in:
+ * dom/Document.h:
+ (WebCore::Node::treeScope):
+ (WebCore):
+ * dom/Element.cpp:
+ (WebCore::Element::createRareData):
+ * dom/ElementRareData.h:
+ (ElementRareData):
+ (WebCore::ElementRareData::ElementRareData):
+ * dom/Node.cpp:
+ (WebCore::Node::setTreeScope):
+ (WebCore::Node::createRareData):
+ * dom/Node.h:
+ (NodeRareDataBase):
+ (WebCore::NodeRareDataBase::treeScope):
+ (WebCore::NodeRareDataBase::setTreeScope):
+ (WebCore::NodeRareDataBase::NodeRareDataBase):
+ (Node):
+ * dom/NodeRareData.cpp:
+ (WebCore::NodeRareData::reportMemoryUsage):
+ * dom/NodeRareData.h:
+ (WebCore::NodeRareData::NodeRareData):
+ (NodeRareData):
+ * dom/TreeScopeAdopter.cpp:
+ (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+
2012-12-02 Justin Novosad <[email protected]>
Fix occlusion culling logic to handle css background layer clipping
Modified: trunk/Source/WebCore/WebCore.exp.in (136327 => 136328)
--- trunk/Source/WebCore/WebCore.exp.in 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-12-02 11:16:33 UTC (rev 136328)
@@ -1363,7 +1363,6 @@
__ZNK7WebCore4Node27traverseNextAncestorSiblingEv
__ZNK7WebCore4Node31numberOfScopedHTMLStyleChildrenEv
__ZNK7WebCore4Node9nodeIndexEv
-__ZNK7WebCore4Node9treeScopeEv
__ZNK7WebCore4Page10pluginDataEv
__ZNK7WebCore4Page14renderTreeSizeEv
__ZNK7WebCore4Page15backForwardListEv
Modified: trunk/Source/WebCore/dom/Document.h (136327 => 136328)
--- trunk/Source/WebCore/dom/Document.h 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/Document.h 2012-12-02 11:16:33 UTC (rev 136328)
@@ -1538,6 +1538,11 @@
return this == m_document;
}
+inline TreeScope* Node::treeScope() const
+{
+ return hasRareData() ? m_data.m_rareData->treeScope() : documentInternal();
+}
+
inline Node::Node(Document* document, ConstructionType type)
: m_nodeFlags(type)
, m_document(document)
Modified: trunk/Source/WebCore/dom/Element.cpp (136327 => 136328)
--- trunk/Source/WebCore/dom/Element.cpp 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-12-02 11:16:33 UTC (rev 136328)
@@ -209,7 +209,7 @@
OwnPtr<NodeRareData> Element::createRareData()
{
- return adoptPtr(new ElementRareData);
+ return adoptPtr(new ElementRareData(documentInternal()));
}
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur);
Modified: trunk/Source/WebCore/dom/ElementRareData.h (136327 => 136328)
--- trunk/Source/WebCore/dom/ElementRareData.h 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2012-12-02 11:16:33 UTC (rev 136328)
@@ -34,7 +34,7 @@
class ElementRareData : public NodeRareData {
public:
- ElementRareData();
+ ElementRareData(Document*);
virtual ~ElementRareData();
void resetComputedStyle();
@@ -91,8 +91,9 @@
return IntSize(LayoutUnit::max(), LayoutUnit::max());
}
-inline ElementRareData::ElementRareData()
- : m_minimumSizeForResizing(defaultMinimumSizeForResizing())
+inline ElementRareData::ElementRareData(Document* document)
+ : NodeRareData(document)
+ , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
{
}
Modified: trunk/Source/WebCore/dom/Node.cpp (136327 => 136328)
--- trunk/Source/WebCore/dom/Node.cpp 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-12-02 11:16:33 UTC (rev 136328)
@@ -439,32 +439,14 @@
m_document = document;
}
-NodeRareData* Node::setTreeScope(TreeScope* scope)
+void Node::setTreeScope(TreeScope* scope)
{
- if (!scope) {
- if (hasRareData()) {
- NodeRareData* data = ""
- data->setTreeScope(0);
- return data;
- }
+ if (!hasRareData() && scope->rootNode()->isDocumentNode())
+ return;
- return 0;
- }
-
- NodeRareData* data = ""
- data->setTreeScope(scope);
- return data;
+ ensureRareData()->setTreeScope(scope);
}
-TreeScope* Node::treeScope() const
-{
- // FIXME: Using m_document directly is not good -> see comment with document() in the header file.
- if (!hasRareData())
- return m_document;
- TreeScope* scope = rareData()->treeScope();
- return scope ? scope : m_document;
-}
-
NodeRareData* Node::rareData() const
{
ASSERT(hasRareData());
@@ -486,7 +468,7 @@
OwnPtr<NodeRareData> Node::createRareData()
{
- return adoptPtr(new NodeRareData);
+ return adoptPtr(new NodeRareData(documentInternal()));
}
void Node::clearRareData()
Modified: trunk/Source/WebCore/dom/Node.h (136327 => 136328)
--- trunk/Source/WebCore/dom/Node.h 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/Node.h 2012-12-02 11:16:33 UTC (rev 136328)
@@ -114,11 +114,19 @@
public:
RenderObject* renderer() const { return m_renderer; }
void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
+
+ TreeScope* treeScope() const { return m_treeScope; }
+ void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
+
virtual ~NodeRareDataBase() { }
protected:
- NodeRareDataBase() { }
+ NodeRareDataBase(TreeScope* scope)
+ : m_treeScope(scope)
+ {
+ }
private:
RenderObject* m_renderer;
+ TreeScope* m_treeScope;
};
class Node : public EventTarget, public ScriptWrappable, public TreeShared<Node, ContainerNode> {
@@ -770,8 +778,7 @@
void removedLastRef();
// These API should be only used for a tree scope migration.
- // setTreeScope() returns NodeRareData to save extra nodeRareData() invocations on the caller site.
- NodeRareData* setTreeScope(TreeScope*);
+ void setTreeScope(TreeScope*);
void setDocument(Document*);
enum EditableLevel { Editable, RichlyEditable };
Modified: trunk/Source/WebCore/dom/NodeRareData.cpp (136327 => 136328)
--- trunk/Source/WebCore/dom/NodeRareData.cpp 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/NodeRareData.cpp 2012-12-02 11:16:33 UTC (rev 136328)
@@ -49,7 +49,7 @@
void NodeRareData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_treeScope);
+ info.addMember(treeScope());
info.addMember(m_nodeLists);
info.addMember(m_childNodeList);
Modified: trunk/Source/WebCore/dom/NodeRareData.h (136327 => 136328)
--- trunk/Source/WebCore/dom/NodeRareData.h 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/NodeRareData.h 2012-12-02 11:16:33 UTC (rev 136328)
@@ -199,8 +199,8 @@
class NodeRareData : public NodeRareDataBase {
WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED;
public:
- NodeRareData()
- : m_treeScope(0)
+ NodeRareData(Document* document)
+ : NodeRareDataBase(document)
, m_childNodeList(0)
, m_tabIndex(0)
, m_childIndex(0)
@@ -230,9 +230,6 @@
{
}
- TreeScope* treeScope() const { return m_treeScope; }
- void setTreeScope(TreeScope* treeScope) { m_treeScope = treeScope; }
-
void clearNodeLists() { m_nodeLists.clear(); }
void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; }
NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); }
@@ -366,7 +363,6 @@
void setChildIndex(unsigned index) { m_childIndex = index; }
private:
- TreeScope* m_treeScope;
OwnPtr<NodeListsNodeData> m_nodeLists;
ChildNodeList* m_childNodeList;
short m_tabIndex;
Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (136327 => 136328)
--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp 2012-12-02 11:00:13 UTC (rev 136327)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp 2012-12-02 11:16:33 UTC (rev 136328)
@@ -49,7 +49,9 @@
oldDocument->incDOMTreeVersion();
for (Node* node = root; node; node = node->traverseNextNode(root)) {
- if (NodeRareData* rareData = node->setTreeScope(newDocument == m_newScope ? 0 : m_newScope)) {
+ node->setTreeScope(m_newScope);
+ if (node->hasRareData()) {
+ NodeRareData* rareData = node->rareData();
if (rareData->nodeLists())
rareData->nodeLists()->adoptTreeScope(oldDocument, newDocument);
}