https://bugs.webkit.org/show_bug.cgi?id=82010
Patch by Takashi Sakamoto <tasak@google.com> on 2012-04-16
Reviewed by Hajime Morita.
This patch adds isActive public member function to InsertionPoint and
makes InsertionPoint elements consider whether active or not.
If an InsertionPoint is inactive, the element is not shadow boundary
and is needed to be rendered.
c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point
Test: update existing tests, i.e.
LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
LayoutTests/fast/dom/shadow/shadow-contents-fallback.html
* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::isActive):
A new public method for checking whether an insertion point is active or inactive.
If active, returns true. Otherwise, false.
(WebCore::InsertionPoint::isShadowBoundary):
Make the method consider whether an insertin point is active or inactive.
(WebCore::InsertionPoint::rendererIsNeeded):
Changed to return true If an insertion point is inactive.
(WebCore::InsertionPoint::attach):
Changed to call only HTMLElement::attach If an insertion point is inactive.
(WebCore::InsertionPoint::detach):
Changed to call only HTMLElement::detach If an insertion point is inactive.
* html/shadow/InsertionPoint.h:
(InsertionPoint):
Added isActive public method.
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::NodeRenderingContext):
Changed to take into account an insertion point's activeness when parent is an insertion point.
(WebCore::NodeRenderingContext::firstRendererOf):
(WebCore::NodeRenderingContext::lastRendererOf):
Changed to take into account an insertion point's activeness.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114334
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
function testContentInContent(callIfDone) {
document.getElementById('expect-container').innerHTML =
- "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
+ "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
var target = document.createElement('div');
target.appendChild(createSpanWithText('S1'));
function testContentInContentFallback(callIfDone) {
document.getElementById('expect-container').innerHTML =
- "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+ "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
var target = document.createElement('div');
target.appendChild(createSpanWithText('S1'));
function testContentInContentFallbackDirect(callIfDone) {
document.getElementById('expect-container').innerHTML =
- "<div><span>CONTENT 2 FALLBACK</span></div>";
+ "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
var target = document.createElement('div');
target.appendChild(createSpanWithText('S1'));
document.getElementById('actual-container').appendChild(target);
document.getElementById('expect-container').innerHTML =
- "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
+ "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
}
function testContentInContentFallback() {
document.getElementById('actual-container').appendChild(target);
document.getElementById('expect-container').innerHTML =
- "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+ "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
}
function testContentInContentFallbackWithDisplayNone() {
document.getElementById('actual-container').appendChild(target);
document.getElementById('expect-container').innerHTML =
- "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+ "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
}
function testContentInContentFallbackDirect() {
document.getElementById('actual-container').appendChild(target);
document.getElementById('expect-container').innerHTML =
- "<div><span>CONTENT 2 FALLBACK</span></div>";
+ "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
}
var testFuncs = [
+2012-04-16 Takashi Sakamoto <tasak@google.com>
+
+ [Shadow DOM] InsertionPoint should have isActive() member function.
+ https://bugs.webkit.org/show_bug.cgi?id=82010
+
+ Reviewed by Hajime Morita.
+
+ This patch adds isActive public member function to InsertionPoint and
+ makes InsertionPoint elements consider whether active or not.
+ If an InsertionPoint is inactive, the element is not shadow boundary
+ and is needed to be rendered.
+ c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point
+
+ Test: update existing tests, i.e.
+ LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
+ LayoutTests/fast/dom/shadow/shadow-contents-fallback.html
+
+ * html/shadow/InsertionPoint.cpp:
+ (WebCore::InsertionPoint::isActive):
+ A new public method for checking whether an insertion point is active or inactive.
+ If active, returns true. Otherwise, false.
+ (WebCore::InsertionPoint::isShadowBoundary):
+ Make the method consider whether an insertin point is active or inactive.
+ (WebCore::InsertionPoint::rendererIsNeeded):
+ Changed to return true If an insertion point is inactive.
+ (WebCore::InsertionPoint::attach):
+ Changed to call only HTMLElement::attach If an insertion point is inactive.
+ (WebCore::InsertionPoint::detach):
+ Changed to call only HTMLElement::detach If an insertion point is inactive.
+ * html/shadow/InsertionPoint.h:
+ (InsertionPoint):
+ Added isActive public method.
+ * dom/NodeRenderingContext.cpp:
+ (WebCore::NodeRenderingContext::NodeRenderingContext):
+ Changed to take into account an insertion point's activeness when parent is an insertion point.
+ (WebCore::NodeRenderingContext::firstRendererOf):
+ (WebCore::NodeRenderingContext::lastRendererOf):
+ Changed to take into account an insertion point's activeness.
+
2012-04-16 MORITA Hajime <morrita@google.com>
Type tags in NodeFlags could be compressed
m_phase = AttachingNotFallbacked;
else
m_phase = AttachingFallbacked;
- m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
+
+ if (toInsertionPoint(parent)->isActive())
+ m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
+ else
+ m_parentNodeForRenderingAndStyle = parent;
return;
}
}
return node->renderer();
}
- if (isInsertionPoint(node)) {
+ if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
if (RenderObject* first = firstRendererOfInsertionPoint(toInsertionPoint(node)))
return first;
}
continue;
return node->renderer();
}
- if (isInsertionPoint(node)) {
+ if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
if (RenderObject* last = lastRendererOfInsertionPoint(toInsertionPoint(node)))
return last;
}
void InsertionPoint::attach()
{
- TreeScope* scope = treeScope();
- if (scope->rootNode()->isShadowRoot()) {
- ShadowRoot* root = toShadowRoot(scope->rootNode());
+ if (isShadowBoundary()) {
+ ShadowRoot* root = toShadowRoot(treeScope()->rootNode());
if (doesSelectFromHostChildren()) {
distributeHostChildren(root->tree());
attachDistributedNode();
void InsertionPoint::detach()
{
- if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
+ ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
+ if (root && isActive()) {
ShadowTree* tree = root->tree();
if (doesSelectFromHostChildren())
bool InsertionPoint::isShadowBoundary() const
{
- return treeScope()->rootNode()->isShadowRoot();
+ return treeScope()->rootNode()->isShadowRoot() && isActive();
+}
+
+bool InsertionPoint::isActive() const
+{
+ const Node* node = parentNode();
+ while (node) {
+ if (WebCore::isInsertionPoint(node))
+ return false;
+
+ node = node->parentNode();
+ }
+ return true;
}
bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
const HTMLContentSelectionList* selections() const { return &m_selections; }
bool hasSelection() const { return m_selections.first(); }
bool isShadowBoundary() const;
+ bool isActive() const;
virtual const AtomicString& select() const = 0;
virtual bool isSelectValid() const = 0;