Diff
Modified: trunk/Source/WebCore/ChangeLog (109312 => 109313)
--- trunk/Source/WebCore/ChangeLog 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/ChangeLog 2012-03-01 06:39:22 UTC (rev 109313)
@@ -1,3 +1,40 @@
+2012-02-29 Shinya Kawanaka <shin...@chromium.org>
+
+ Refactoring: HTMLContentSelector should be InsertionPoint-aware.
+ https://bugs.webkit.org/show_bug.cgi?id=79901
+
+ Reviewed by Hajime Morita.
+
+ ContentSelectorQuery took HTMLContentElement as argument, but patch changes it to take InsertionPoint instead.
+ If InsertionPoint is not HTMLContentElement, ContentSelectorQuery will selects the rest of light children.
+
+ Now InsertionPoint has pure virtual method 'select'. <shadow> will implement this as a method returning empty string.
+
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::hasInsertionPoint):
+ * dom/ShadowRoot.h:
+ (ShadowRoot):
+ * dom/ShadowTree.cpp:
+ (WebCore::ShadowTree::needsReattachHostChildrenAndShadow):
+ (WebCore::ShadowTree::hostChildrenChanged):
+ * html/shadow/ContentSelectorQuery.cpp:
+ (WebCore::ContentSelectorQuery::ContentSelectorQuery):
+ (WebCore::ContentSelectorQuery::matches):
+ * html/shadow/ContentSelectorQuery.h:
+ (WebCore):
+ (ContentSelectorQuery):
+ * html/shadow/HTMLContentElement.cpp:
+ (WebCore::HTMLContentElement::detach):
+ * html/shadow/HTMLContentElement.h:
+ (WebCore::toHTMLContentElement):
+ (WebCore):
+ * html/shadow/HTMLContentSelector.cpp:
+ (WebCore::HTMLContentSelector::select):
+ * html/shadow/HTMLContentSelector.h:
+ (HTMLContentSelector):
+ * html/shadow/InsertionPoint.h:
+ (InsertionPoint):
+
2012-02-29 Luke Macpherson <macpher...@chromium.org>
Handle CSSPropertySpeak in CSSStyleApplyProperty.
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (109312 => 109313)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2012-03-01 06:39:22 UTC (rev 109313)
@@ -178,10 +178,10 @@
return 0;
}
-bool ShadowRoot::hasContentElement() const
+bool ShadowRoot::hasInsertionPoint() const
{
for (Node* n = firstChild(); n; n = n->traverseNextNode(this)) {
- if (n->isContentElement())
+ if (isInsertionPoint(n))
return true;
}
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (109312 => 109313)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2012-03-01 06:39:22 UTC (rev 109313)
@@ -79,7 +79,7 @@
bool isYoungest() const { return !youngerShadowRoot(); }
bool isOldest() const { return !olderShadowRoot(); }
- bool hasContentElement() const;
+ bool hasInsertionPoint() const;
private:
ShadowRoot(Document*);
Modified: trunk/Source/WebCore/dom/ShadowTree.cpp (109312 => 109313)
--- trunk/Source/WebCore/dom/ShadowTree.cpp 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/dom/ShadowTree.cpp 2012-03-01 06:39:22 UTC (rev 109313)
@@ -262,14 +262,14 @@
bool ShadowTree::needsReattachHostChildrenAndShadow()
{
- return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasContentElement());
+ return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint());
}
void ShadowTree::hostChildrenChanged()
{
ASSERT(youngestShadowRoot());
- if (!youngestShadowRoot()->hasContentElement())
+ if (!youngestShadowRoot()->hasInsertionPoint())
return;
// This results in forced detaching/attaching of the shadow render tree. See ShadowRoot::recalcStyle().
Modified: trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-03-01 06:39:22 UTC (rev 109313)
@@ -29,23 +29,23 @@
#include "CSSParser.h"
#include "CSSSelectorList.h"
-#include "HTMLContentElement.h"
+#include "InsertionPoint.h"
namespace WebCore {
-ContentSelectorQuery::ContentSelectorQuery(const HTMLContentElement* element)
- : m_contentElement(element)
- , m_selectorChecker(element->document(), !element->document()->inQuirksMode())
+ContentSelectorQuery::ContentSelectorQuery(const InsertionPoint* insertionPoint)
+ : m_insertionPoint(insertionPoint)
+ , m_selectorChecker(insertionPoint->document(), !insertionPoint->document()->inQuirksMode())
{
m_selectorChecker.setCollectingRulesOnly(true);
- if (element->select().isNull() || element->select().isEmpty()) {
+ if (insertionPoint->select().isNull() || insertionPoint->select().isEmpty()) {
m_isValidSelector = true;
return;
}
CSSParser parser(true);
- parser.parseSelector(element->select(), element->document(), m_selectorList);
+ parser.parseSelector(insertionPoint->select(), insertionPoint->document(), m_selectorList);
m_isValidSelector = ContentSelectorQuery::validateSelectorList();
if (m_isValidSelector)
@@ -63,9 +63,9 @@
if (!node)
return false;
- ASSERT(node->parentNode() == m_contentElement->shadowTreeRootNode()->shadowHost());
+ ASSERT(node->parentNode() == m_insertionPoint->shadowTreeRootNode()->shadowHost());
- if (m_contentElement->select().isNull() || m_contentElement->select().isEmpty())
+ if (m_insertionPoint->select().isNull() || m_insertionPoint->select().isEmpty())
return true;
if (!m_isValidSelector)
Modified: trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/ContentSelectorQuery.h 2012-03-01 06:39:22 UTC (rev 109313)
@@ -41,19 +41,19 @@
class Document;
class Node;
-class HTMLContentElement;
+class InsertionPoint;
class ContentSelectorQuery {
WTF_MAKE_NONCOPYABLE(ContentSelectorQuery);
public:
- explicit ContentSelectorQuery(const HTMLContentElement*);
+ explicit ContentSelectorQuery(const InsertionPoint*);
bool isValidSelector() const;
bool matches(Node*) const;
private:
bool validateSelectorList();
- const HTMLContentElement* m_contentElement;
+ const InsertionPoint* m_insertionPoint;
SelectorDataList m_selectors;
CSSSelectorList m_selectorList;
SelectorChecker m_selectorChecker;
Modified: trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp 2012-03-01 06:39:22 UTC (rev 109313)
@@ -94,7 +94,7 @@
selector->unselect(&m_selections);
// When content element is detached, shadow tree should be recreated to re-calculate selector for
- // other content elements.
+ // other insertion points.
root->tree()->setNeedsReattachHostChildrenAndShadow();
}
Modified: trunk/Source/WebCore/html/shadow/HTMLContentElement.h (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/HTMLContentElement.h 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/HTMLContentElement.h 2012-03-01 06:39:22 UTC (rev 109313)
@@ -66,6 +66,12 @@
virtual void parseAttribute(Attribute*) OVERRIDE;
};
+inline const HTMLContentElement* toHTMLContentElement(const Node* node)
+{
+ ASSERT(!node || node->isContentElement());
+ return static_cast<const HTMLContentElement*>(node);
+}
+
inline HTMLContentElement* toHTMLContentElement(Node* node)
{
ASSERT(!node || node->isContentElement());
Modified: trunk/Source/WebCore/html/shadow/HTMLContentSelector.cpp (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/HTMLContentSelector.cpp 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/HTMLContentSelector.cpp 2012-03-01 06:39:22 UTC (rev 109313)
@@ -108,11 +108,12 @@
ASSERT(m_candidates.isEmpty());
}
-void HTMLContentSelector::select(HTMLContentElement* contentElement, HTMLContentSelectionList* selections)
+void HTMLContentSelector::select(InsertionPoint* insertionPoint, HTMLContentSelectionList* selections)
{
ASSERT(selections->isEmpty());
- ContentSelectorQuery query(contentElement);
+ ContentSelectorQuery query(insertionPoint);
+
for (size_t i = 0; i < m_candidates.size(); ++i) {
Node* child = m_candidates[i].get();
if (!child)
@@ -120,7 +121,7 @@
if (!query.matches(child))
continue;
- RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(contentElement, child);
+ RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(insertionPoint, child);
selections->append(selection);
m_selectionSet.add(selection.get());
Modified: trunk/Source/WebCore/html/shadow/HTMLContentSelector.h (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/HTMLContentSelector.h 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/HTMLContentSelector.h 2012-03-01 06:39:22 UTC (rev 109313)
@@ -130,7 +130,7 @@
HTMLContentSelector();
~HTMLContentSelector();
- void select(HTMLContentElement*, HTMLContentSelectionList*);
+ void select(InsertionPoint*, HTMLContentSelectionList*);
void unselect(HTMLContentSelectionList*);
HTMLContentSelection* findFor(Node* key) const;
Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (109312 => 109313)
--- trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-03-01 06:36:06 UTC (rev 109312)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h 2012-03-01 06:39:22 UTC (rev 109313)
@@ -33,6 +33,7 @@
#include "HTMLContentSelector.h"
#include "HTMLElement.h"
+#include <wtf/Forward.h>
namespace WebCore {
@@ -44,6 +45,8 @@
bool hasSelection() const { return m_selections.first(); }
bool isShadowBoundary() const;
+ virtual const AtomicString& select() const = 0;
+
protected:
InsertionPoint(const QualifiedName&, Document*);
virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;