Title: [141083] trunk/Source/WebCore
- Revision
- 141083
- Author
- espr...@chromium.org
- Date
- 2013-01-29 01:35:35 -0800 (Tue, 29 Jan 2013)
Log Message
Clean up interface to ElementShadow
https://bugs.webkit.org/show_bug.cgi?id=108158
Reviewed by Hajime Morita.
Lots of general clean up to ElementShadow removing unused headers,
adding a create() method that returns a PassOwnPtr, adding missing const,
and moving short inline methods into the class definition so it's easier
to understand what methods do what.
No new tests, just refactoring.
* dom/Element.cpp:
(WebCore::Element::ensureShadow):
* dom/ElementShadow.cpp:
(WebCore::ElementShadow::childNeedsStyleRecalc):
(WebCore::ElementShadow::needsStyleRecalc):
* dom/ElementShadow.h:
(WebCore::ElementShadow::create):
(ElementShadow):
(WebCore::ElementShadow::~ElementShadow):
(WebCore::ElementShadow::youngestShadowRoot):
(WebCore::ElementShadow::oldestShadowRoot):
(WebCore::ElementShadow::distributor):
(WebCore::ElementShadow::ElementShadow):
(WebCore::ElementShadow::containingShadow):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (141082 => 141083)
--- trunk/Source/WebCore/ChangeLog 2013-01-29 09:30:08 UTC (rev 141082)
+++ trunk/Source/WebCore/ChangeLog 2013-01-29 09:35:35 UTC (rev 141083)
@@ -1,5 +1,34 @@
2013-01-29 Elliott Sprehn <espr...@chromium.org>
+ Clean up interface to ElementShadow
+ https://bugs.webkit.org/show_bug.cgi?id=108158
+
+ Reviewed by Hajime Morita.
+
+ Lots of general clean up to ElementShadow removing unused headers,
+ adding a create() method that returns a PassOwnPtr, adding missing const,
+ and moving short inline methods into the class definition so it's easier
+ to understand what methods do what.
+
+ No new tests, just refactoring.
+
+ * dom/Element.cpp:
+ (WebCore::Element::ensureShadow):
+ * dom/ElementShadow.cpp:
+ (WebCore::ElementShadow::childNeedsStyleRecalc):
+ (WebCore::ElementShadow::needsStyleRecalc):
+ * dom/ElementShadow.h:
+ (WebCore::ElementShadow::create):
+ (ElementShadow):
+ (WebCore::ElementShadow::~ElementShadow):
+ (WebCore::ElementShadow::youngestShadowRoot):
+ (WebCore::ElementShadow::oldestShadowRoot):
+ (WebCore::ElementShadow::distributor):
+ (WebCore::ElementShadow::ElementShadow):
+ (WebCore::ElementShadow::containingShadow):
+
+2013-01-29 Elliott Sprehn <espr...@chromium.org>
+
Store ShadowRootType inside the bitfield
https://bugs.webkit.org/show_bug.cgi?id=108147
Modified: trunk/Source/WebCore/dom/Element.cpp (141082 => 141083)
--- trunk/Source/WebCore/dom/Element.cpp 2013-01-29 09:30:08 UTC (rev 141082)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-01-29 09:35:35 UTC (rev 141083)
@@ -1449,7 +1449,7 @@
return shadow;
ElementRareData* data = ""
- data->setShadow(adoptPtr(new ElementShadow()));
+ data->setShadow(ElementShadow::create());
return data->shadow();
}
Modified: trunk/Source/WebCore/dom/ElementShadow.cpp (141082 => 141083)
--- trunk/Source/WebCore/dom/ElementShadow.cpp 2013-01-29 09:30:08 UTC (rev 141082)
+++ trunk/Source/WebCore/dom/ElementShadow.cpp 2013-01-29 09:35:35 UTC (rev 141083)
@@ -27,29 +27,11 @@
#include "config.h"
#include "ElementShadow.h"
-#include "CSSParser.h"
-#include "CSSSelectorList.h"
#include "ContainerNodeAlgorithms.h"
-#include "Document.h"
-#include "Element.h"
-#include "HTMLContentElement.h"
-#include "HTMLShadowElement.h"
#include "InspectorInstrumentation.h"
-#include "NodeTraversal.h"
-#include "ShadowRoot.h"
-#include "StyleResolver.h"
namespace WebCore {
-ElementShadow::ElementShadow()
-{
-}
-
-ElementShadow::~ElementShadow()
-{
- ASSERT(m_shadowRoots.isEmpty());
-}
-
static bool validateShadowRoot(Document* document, ShadowRoot* shadowRoot, ExceptionCode& ec)
{
if (!shadowRoot)
@@ -138,7 +120,7 @@
}
}
-bool ElementShadow::childNeedsStyleRecalc()
+bool ElementShadow::childNeedsStyleRecalc() const
{
ASSERT(youngestShadowRoot());
for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
@@ -148,7 +130,7 @@
return false;
}
-bool ElementShadow::needsStyleRecalc()
+bool ElementShadow::needsStyleRecalc() const
{
ASSERT(youngestShadowRoot());
for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
Modified: trunk/Source/WebCore/dom/ElementShadow.h (141082 => 141083)
--- trunk/Source/WebCore/dom/ElementShadow.h 2013-01-29 09:30:08 UTC (rev 141082)
+++ trunk/Source/WebCore/dom/ElementShadow.h 2013-01-29 09:35:35 UTC (rev 141083)
@@ -32,25 +32,28 @@
#include "ShadowRoot.h"
#include <wtf/DoublyLinkedList.h>
#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
-class Node;
-class Element;
-class TreeScope;
-
class ElementShadow {
WTF_MAKE_NONCOPYABLE(ElementShadow); WTF_MAKE_FAST_ALLOCATED;
public:
- ElementShadow();
- ~ElementShadow();
+ static PassOwnPtr<ElementShadow> create()
+ {
+ return adoptPtr(new ElementShadow());
+ }
+ ~ElementShadow()
+ {
+ ASSERT(m_shadowRoots.isEmpty());
+ }
+
Element* host() const;
- ShadowRoot* youngestShadowRoot() const;
- ShadowRoot* oldestShadowRoot() const;
+ ShadowRoot* youngestShadowRoot() const { return m_shadowRoots.head(); }
+ ShadowRoot* oldestShadowRoot() const { return m_shadowRoots.tail(); }
ElementShadow* containingShadow() const;
void removeAllShadowRoots();
@@ -59,44 +62,26 @@
void attach();
void detach();
- bool childNeedsStyleRecalc();
- bool needsStyleRecalc();
+ bool childNeedsStyleRecalc() const;
+ bool needsStyleRecalc() const;
void recalcStyle(Node::StyleChange);
void invalidateDistribution() { m_distributor.invalidateDistribution(host()); }
void didAffectSelector(AffectedSelectorMask mask) { m_distributor.didAffectSelector(host(), mask); }
void willAffectSelector() { m_distributor.willAffectSelector(host()); }
- ContentDistributor& distributor();
- const ContentDistributor& distributor() const;
+ ContentDistributor& distributor() { return m_distributor; }
+ const ContentDistributor& distributor() const { return m_distributor; }
void reportMemoryUsage(MemoryObjectInfo*) const;
+
private:
+ ElementShadow() { }
DoublyLinkedList<ShadowRoot> m_shadowRoots;
ContentDistributor m_distributor;
};
-inline ShadowRoot* ElementShadow::youngestShadowRoot() const
-{
- return m_shadowRoots.head();
-}
-
-inline ShadowRoot* ElementShadow::oldestShadowRoot() const
-{
- return m_shadowRoots.tail();
-}
-
-inline ContentDistributor& ElementShadow::distributor()
-{
- return m_distributor;
-}
-
-inline const ContentDistributor& ElementShadow::distributor() const
-{
- return m_distributor;
-}
-
inline Element* ElementShadow::host() const
{
ASSERT(!m_shadowRoots.isEmpty());
@@ -114,10 +99,9 @@
inline ElementShadow* ElementShadow::containingShadow() const
{
- ShadowRoot* parentRoot = host()->containingShadowRoot();
- if (!parentRoot)
- return 0;
- return parentRoot->owner();
+ if (ShadowRoot* parentRoot = host()->containingShadowRoot())
+ return parentRoot->owner();
+ return 0;
}
class ShadowRootVector : public Vector<RefPtr<ShadowRoot> > {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes