Changeset 86521 in webkit
- Timestamp:
- May 15, 2011 7:55:17 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 15 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r86519 r86521 1 2011-05-12 MORITA Hajime <morrita@google.com> 2 3 Reviewed by Dimitri Glazkov. 4 5 ShadowContentElement should affect the order of renderer children 6 https://bugs.webkit.org/show_bug.cgi?id=59157 7 8 * fast/html/details-add-details-child-1.html: Added. 9 * fast/html/details-add-details-child-2.html: Added. 10 * fast/html/details-nested-1.html: Added. 11 * fast/html/details-nested-2.html: Added. 12 * platform/chromium/test_expectations.txt: 13 * platform/gtk/fast/html/details-open2-expected.txt: 14 * platform/mac/fast/html/details-add-child-2-expected.txt: 15 * platform/mac/fast/html/details-add-details-child-1-expected.png: Added. 16 * platform/mac/fast/html/details-add-details-child-1-expected.txt: Copied from LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt. 17 * platform/mac/fast/html/details-add-details-child-2-expected.png: Added. 18 * platform/mac/fast/html/details-add-details-child-2-expected.txt: Copied from LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt. 19 * platform/mac/fast/html/details-add-summary-10-and-click-expected.png: Added. 20 * platform/mac/fast/html/details-add-summary-10-expected.png: Added. 21 * platform/mac/fast/html/details-nested-1-expected.png: Added. 22 * platform/mac/fast/html/details-nested-1-expected.txt: Added. 23 * platform/mac/fast/html/details-nested-2-expected.png: Added. 24 * platform/mac/fast/html/details-nested-2-expected.txt: Added. 25 * platform/mac/fast/html/details-open2-expected.txt: 26 * platform/qt/fast/html/details-add-child-2-expected.txt: 27 * platform/qt/fast/html/details-open2-expected.txt: 28 1 29 2011-05-15 Yuzo Fujishima <yuzo@google.com> 2 30 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r86518 r86521 3975 3975 BUGWK59782 WIN MAC LINUX RELEASE : svg/filters/feDropShadow.svg = IMAGE 3976 3976 3977 // Needs missing expectations. 3978 BUGWK59157 : fast/html/details-nested-2.html = FAIL 3979 BUGWK59157 : fast/html/details-nested-1.html = FAIL 3980 BUGWK59157 : fast/html/details-add-details-child-1.html = FAIL 3981 BUGWK59157 : fast/html/details-add-details-child-2.html = FAIL 3982 3977 3983 // New test added in r85303. 3978 3984 BUG_HCLAM : compositing/masks/layer-mask-placement.html = IMAGE -
trunk/LayoutTests/platform/gtk/fast/html/details-open2-expected.txt
r84677 r86521 11 11 RenderBlock (anonymous) at (0,19) size 784x29 12 12 RenderTextControl {INPUT} at (2,2) size 194x25 [bgcolor=#FFFFFF] [border: (2px inset #000000)] 13 RenderText {#text} at (0,0) size 0x014 13 layer at (13,32) size 188x19 15 14 RenderBlock {DIV} at (3,3) size 188x19 -
trunk/LayoutTests/platform/mac/fast/html/details-add-child-2-expected.txt
r84632 r86521 13 13 RenderText {#text} at (0,0) size 142x18 14 14 text run at (0,0) width 142: "should have bold test" 15 RenderText {#text} at (0,0) size 0x0 -
trunk/LayoutTests/platform/mac/fast/html/details-add-details-child-1-expected.txt
r86520 r86521 13 13 RenderText {#text} at (0,0) size 142x18 14 14 text run at (0,0) width 142: "should have bold test" 15 RenderText {#text} at (0,0) size 0x0 -
trunk/LayoutTests/platform/mac/fast/html/details-add-details-child-2-expected.txt
r86520 r86521 10 10 text run at (16,0) width 58: "summary" 11 11 RenderBlock (anonymous) at (0,18) size 784x18 12 RenderInline {B} at (0,0) size 142x18 13 RenderText {#text} at (0,0) size 142x18 14 text run at (0,0) width 142: "should have bold test" 12 RenderInline {SPAN} at (0,0) size 142x18 13 RenderInline {B} at (0,0) size 142x18 14 RenderText {#text} at (0,0) size 142x18 15 text run at (0,0) width 142: "should have bold test" 15 16 RenderText {#text} at (0,0) size 0x0 -
trunk/LayoutTests/platform/mac/fast/html/details-open2-expected.txt
r84632 r86521 11 11 RenderBlock (anonymous) at (0,18) size 784x23 12 12 RenderTextControl {INPUT} at (2,2) size 125x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)] 13 RenderText {#text} at (0,0) size 0x014 13 layer at (13,31) size 119x13 15 14 RenderBlock {DIV} at (3,3) size 119x13 -
trunk/LayoutTests/platform/qt/fast/html/details-add-child-2-expected.txt
r84963 r86521 13 13 RenderText {#text} at (0,0) size 142x22 14 14 text run at (0,0) width 142: "should have bold test" 15 RenderText {#text} at (0,0) size 0x0 -
trunk/LayoutTests/platform/qt/fast/html/details-open2-expected.txt
r84673 r86521 11 11 RenderBlock (anonymous) at (0,22) size 784x30 12 12 RenderTextControl {INPUT} at (2,2) size 166x26 13 RenderText {#text} at (0,0) size 0x014 13 layer at (12,34) size 162x22 15 14 RenderBlock {DIV} at (2,2) size 162x22 -
trunk/Source/WebCore/ChangeLog
r86520 r86521 1 2011-05-12 MORITA Hajime <morrita@google.com> 2 3 ShadowContentElement should affect the order of renderer children 4 https://bugs.webkit.org/show_bug.cgi?id=59157 5 6 Introduced ShadowContentSelector to collect and forward content 7 children for each ShadowContentElement. ShadowRoot collects child 8 nodes of its host (we call these children "content children"), and 9 the descendant ShadowContentElement pulls that these content 10 children and put it under its child during 11 ShadowContentElement::attach(). 12 13 Content children no longer create its renderer during its normal 14 attach() phase (called "light" phase). And they create it during 15 attach() as a content children instead (called "forwarded phase"). 16 These phases are detected by NodeRendererFactory and represented 17 as NodeRendererFactory::AttachPhase value AttachContentLight and 18 AttachContentForwarded. 19 20 Tests: fast/html/details-add-details-child-1.html 21 fast/html/details-add-details-child-2.html 22 fast/html/details-nested-1.html 23 fast/html/details-nested-2.html 24 25 * dom/Element.cpp: 26 (WebCore::Element::attach): 27 (WebCore::Element::childrenChanged): 28 * dom/Node.cpp: 29 (WebCore::NodeRendererFactory::NodeRendererFactory): 30 (WebCore::NodeRendererFactory::shouldCreateRenderer): 31 (WebCore::NodeRendererFactory::nextRenderer): 32 (WebCore::NodeRendererFactory::createRendererIfNeeded): 33 * dom/ShadowRoot.cpp: 34 (WebCore::forceReattach): 35 (WebCore::ShadowContentSelector::shadowRoot): 36 (WebCore::ShadowContentSelector::activeElement): 37 (WebCore::ShadowContentSelector::currentInstance): 38 (WebCore::ShadowContentSelector::ShadowContentSelector): 39 (WebCore::ShadowContentSelector::~ShadowContentSelector): 40 (WebCore::ShadowContentSelector::attachChildrenFor): 41 (WebCore::ShadowContentElement::attach): 42 (WebCore::ShadowRoot::recalcStyle): 43 (WebCore::ShadowRoot::activeContentContainer): 44 (WebCore::ShadowRoot::hostChildrenChanged): 45 (WebCore::ShadowRoot::attach): 46 * dom/ShadowRoot.h: 47 * html/shadow/ShadowContentElement.h: 48 (WebCore::ShadowContentElement::rendererIsNeeded): 49 * rendering/RenderDetails.cpp: 50 * rendering/RenderDetails.h: 51 1 52 2011-05-13 MORITA Hajime <morrita@google.com> 2 53 -
trunk/Source/WebCore/dom/Element.cpp
r86364 r86521 994 994 StyleSelectorParentPusher parentPusher(this); 995 995 996 if (ShadowRoot* shadow = shadowRoot()) {997 parentPusher.push();998 shadow->attach();999 }1000 1001 996 if (firstChild()) 1002 997 parentPusher.push(); 1003 998 ContainerNode::attach(); 999 1000 if (Node* shadow = shadowRoot()) { 1001 parentPusher.push(); 1002 shadow->attach(); 1003 } 1004 1004 1005 1005 if (hasRareData()) { … … 1322 1322 else 1323 1323 checkForSiblingStyleChanges(this, renderStyle(), false, beforeChange, afterChange, childCountDelta); 1324 if (ShadowRoot* shadow = shadowRoot())1325 shadow->hostChildrenChanged();1326 1324 } 1327 1325 -
trunk/Source/WebCore/dom/Node.cpp
r86248 r86521 1461 1461 class NodeRendererFactory { 1462 1462 public: 1463 enum Type { 1464 NotFound, 1465 AsLightChild, 1466 AsShadowChild, 1467 AsContentChild 1463 enum TreeLocation { 1464 LocationNotInTree, 1465 LocationLightChild, 1466 LocationShadowChild, 1468 1467 }; 1469 1468 1470 NodeRendererFactory(Node* node) 1471 : m_type(NotFound) 1472 , m_node(node) 1473 , m_visualParentShadowRoot(0) 1474 { 1475 m_parentNodeForRenderingAndStyle = findVisualParent(); 1476 } 1477 1469 enum AttachPhase { 1470 AttachStraight, 1471 AttachContentLight, 1472 AttachContentForwarded, 1473 }; 1474 1475 explicit NodeRendererFactory(Node*); 1478 1476 ContainerNode* parentNodeForRenderingAndStyle() const { return m_parentNodeForRenderingAndStyle; } 1479 1477 void createRendererIfNeeded(); … … 1481 1479 private: 1482 1480 Document* document() { return m_node->document(); } 1483 ContainerNode* findVisualParent();1484 RenderObject* nextRenderer() const { return m_node->nextRenderer(); }1481 void initialize(); 1482 RenderObject* nextRenderer() const; 1485 1483 RenderObject* createRendererAndStyle(); 1486 1484 bool shouldCreateRenderer() const; 1487 1485 1488 Type m_type; 1486 TreeLocation m_location; 1487 AttachPhase m_phase; 1489 1488 Node* m_node; 1490 1489 ContainerNode* m_parentNodeForRenderingAndStyle; … … 1492 1491 }; 1493 1492 1494 ContainerNode* NodeRendererFactory::findVisualParent() 1493 NodeRendererFactory::NodeRendererFactory(Node* node) 1494 : m_location(LocationNotInTree) 1495 , m_phase(AttachStraight) 1496 , m_node(node) 1497 , m_parentNodeForRenderingAndStyle(0) 1498 , m_visualParentShadowRoot(0) 1495 1499 { 1496 1500 ContainerNode* parent = m_node->parentOrHostNode(); 1497 1501 if (!parent) 1498 return 0;1502 return; 1499 1503 1500 1504 if (parent->isShadowBoundary()) { 1501 m_type = AsShadowChild; 1502 return parent->shadowHost(); 1503 } 1505 m_location = LocationShadowChild; 1506 m_parentNodeForRenderingAndStyle = parent->shadowHost(); 1507 return; 1508 } 1509 1510 m_location = LocationLightChild; 1504 1511 1505 1512 if (parent->isElementNode()) { 1506 1513 m_visualParentShadowRoot = toElement(parent)->shadowRoot(); 1514 1507 1515 if (m_visualParentShadowRoot) { 1508 if (ContainerNode* contentContainer = m_visualParentShadowRoot->contentContainerFor(m_node)) { 1509 m_type = AsContentChild; 1510 return NodeRendererFactory(contentContainer).parentNodeForRenderingAndStyle(); 1511 } 1512 1513 // FIXME: should be not found once light/shadow is mutual exclusive. 1516 if (ContainerNode* contentContainer = m_visualParentShadowRoot->activeContentContainer()) { 1517 m_phase = AttachContentForwarded; 1518 m_parentNodeForRenderingAndStyle = NodeRendererFactory(contentContainer).parentNodeForRenderingAndStyle(); 1519 return; 1520 } 1521 1522 m_phase = AttachContentLight; 1523 m_parentNodeForRenderingAndStyle = parent; 1524 return; 1514 1525 } 1515 1526 } 1516 1527 1517 m_type = AsLightChild; 1518 return parent; 1528 m_parentNodeForRenderingAndStyle = parent; 1519 1529 } 1520 1530 … … 1522 1532 { 1523 1533 ASSERT(m_parentNodeForRenderingAndStyle); 1534 1535 if (m_location == LocationNotInTree || m_phase == AttachContentLight) 1536 return false; 1524 1537 1525 1538 RenderObject* parentRenderer = m_parentNodeForRenderingAndStyle->renderer(); … … 1527 1540 return false; 1528 1541 1529 if (m_ type == AsLightChild) {1542 if (m_location == LocationLightChild && m_phase == AttachStraight) { 1530 1543 // FIXME: Ignoring canHaveChildren() in a case of shadow children might be wrong. 1531 1544 // See https://bugs.webkit.org/show_bug.cgi?id=52423 … … 1567 1580 newRenderer->setAnimatableStyle(style.release()); // setAnimatableStyle() can depend on renderer() already being set. 1568 1581 return newRenderer; 1582 } 1583 1584 RenderObject* NodeRendererFactory::nextRenderer() const 1585 { 1586 if (m_phase != AttachContentForwarded) 1587 return m_node->nextRenderer(); 1588 // Returns 0 here to insert renderer at the end of child list. 1589 // We assume content children are always attached in tree order and 1590 // there is no partial render tree creation. 1591 return 0; 1569 1592 } 1570 1593 … … 1596 1619 newRenderer = wrapWithRenderFullScreen(newRenderer, document()); 1597 1620 #endif 1621 1622 // FIXME: This side effect should be visible from attach() code. 1623 if (m_phase == AttachContentLight) 1624 m_visualParentShadowRoot->hostChildrenChanged(); 1598 1625 1599 1626 if (!newRenderer) -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r84632 r86521 36 36 namespace WebCore { 37 37 38 static inline void forceReattach(Node* node) 39 { 40 if (!node->attached()) 41 return; 42 node->detach(); 43 node->attach(); 44 } 45 46 class ShadowContentSelector { 47 WTF_MAKE_NONCOPYABLE(ShadowContentSelector); 48 public: 49 explicit ShadowContentSelector(ShadowRoot*); 50 ~ShadowContentSelector(); 51 52 void attachChildrenFor(ShadowContentElement*); 53 ShadowRoot* shadowRoot() const { return m_shadowRoot; } 54 Element* activeElement() const { return m_activeElement; } 55 56 static ShadowContentSelector* currentInstance() { return s_currentInstance; } 57 58 private: 59 ShadowContentSelector* m_parent; 60 ShadowRoot* m_shadowRoot; 61 Element* m_activeElement; 62 Vector<RefPtr<Node> > m_children; 63 64 static ShadowContentSelector* s_currentInstance; 65 }; 66 67 ShadowContentSelector* ShadowContentSelector::s_currentInstance = 0; 68 69 ShadowContentSelector::ShadowContentSelector(ShadowRoot* shadowRoot) 70 : m_parent(s_currentInstance) 71 , m_shadowRoot(shadowRoot) 72 , m_activeElement(0) 73 { 74 s_currentInstance = this; 75 for (Node* node = shadowRoot->shadowHost()->firstChild(); node; node = node->nextSibling()) 76 m_children.append(node); 77 } 78 79 ShadowContentSelector::~ShadowContentSelector() 80 { 81 ASSERT(s_currentInstance == this); 82 s_currentInstance = m_parent; 83 } 84 85 void ShadowContentSelector::attachChildrenFor(ShadowContentElement* contentElement) 86 { 87 m_activeElement = contentElement; 88 89 for (size_t i = 0; i < m_children.size(); ++i) { 90 Node* child = m_children[i].get(); 91 if (!child) 92 continue; 93 if (!contentElement->shouldInclude(child)) 94 continue; 95 96 forceReattach(child); 97 m_children[i] = 0; 98 } 99 100 m_activeElement = 0; 101 } 102 103 // FIXME: Should have its own file. https://bugs.webkit.org/show_bug.cgi?id=59117 will fix this. 104 void ShadowContentElement::attach() 105 { 106 ASSERT(!firstChild()); // Currently doesn't support any light child. 107 HTMLDivElement::attach(); 108 if (ShadowContentSelector* selector = ShadowContentSelector::currentInstance()) 109 selector->attachChildrenFor(this); 110 } 111 38 112 ShadowRoot::ShadowRoot(Document* document) 39 113 : TreeScope(document) … … 85 159 void ShadowRoot::recalcStyle(StyleChange change) 86 160 { 87 for (Node* n = firstChild(); n; n = n->nextSibling()) 88 n->recalcStyle(change); 161 if (hasContentElement()) 162 forceReattach(this); 163 else { 164 for (Node* n = firstChild(); n; n = n->nextSibling()) 165 n->recalcStyle(change); 166 } 89 167 90 168 clearNeedsStyleRecalc(); … … 92 170 } 93 171 94 ContainerNode* ShadowRoot::contentContainerFor(Node* node) 95 { 96 // Current limitation: 97 // - There is at most one content element for each shadow tree 98 // - The shadow tree accepts any light node. 99 for (Node* n = firstChild(); n; n = n->traverseNextNode(this)) { 100 // FIXME: This should be replaced with tag-name checking once <content> is ready. 101 // See also http://webkit.org/b/56973 102 if (n->isShadowBoundary() && static_cast<ShadowContentElement*>(n)->shouldInclude(node)) 103 return toContainerNode(n); 104 } 105 106 return 0; 172 ContainerNode* ShadowRoot::activeContentContainer() 173 { 174 ShadowContentSelector* selector = ShadowContentSelector::currentInstance(); 175 if (!selector || selector->shadowRoot() != this) 176 return 0; 177 return selector->activeElement(); 107 178 } 108 179 … … 111 182 if (!hasContentElement()) 112 183 return; 113 Element* host = shadowHost(); 114 if (!host || !host->attached()) 115 return; 116 host->detach(); 117 host->lazyAttach(); 184 // This results in forced detaching/attaching of the shadow render tree. See ShadowRoot::recalcStyle(). 185 setNeedsStyleRecalc(); 118 186 } 119 187 … … 135 203 } 136 204 137 } 205 void ShadowRoot::attach() 206 { 207 ShadowContentSelector selector(this); 208 TreeScope::attach(); 209 } 210 211 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r85644 r86521 33 33 34 34 class Document; 35 class ShadowContentElement; 35 36 36 37 class ShadowRoot : public TreeScope { … … 41 42 virtual void recalcStyle(StyleChange = NoChange); 42 43 43 ContainerNode* contentContainerFor(Node*);44 ContainerNode* activeContentContainer(); 44 45 void hostChildrenChanged(); 45 46 … … 53 54 virtual bool childTypeAllowed(NodeType) const; 54 55 virtual bool applyAuthorSheets() const; 56 virtual void attach(); 55 57 56 58 bool hasContentElement() const; -
trunk/Source/WebCore/html/shadow/ShadowContentElement.h
r84632 r86521 48 48 49 49 virtual bool shouldInclude(Node*) = 0; 50 virtual void attach(); 50 51 51 52 private: … … 53 54 // See also http://webkit.org/b/56973 54 55 virtual bool isShadowBoundary() const { return true; } 56 virtual bool rendererIsNeeded(RenderStyle*) { return false; } 55 57 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) { return 0; } 56 58 }; -
trunk/Source/WebCore/rendering/RenderDetails.cpp
r84632 r86521 37 37 } 38 38 39 void RenderDetails::addChild(RenderObject* newChild, RenderObject* beforeChild)40 {41 if (static_cast<HTMLDetailsElement*>(node())->mainSummary() == newChild->node())42 RenderBlock::addChild(newChild, firstChild());43 else44 RenderBlock::addChild(newChild, beforeChild);45 }46 47 39 void RenderDetails::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 48 40 { -
trunk/Source/WebCore/rendering/RenderDetails.h
r84632 r86521 40 40 virtual bool isDetails() const { return true; } 41 41 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); 42 virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0);43 42 }; 44 43
Note: See TracChangeset
for help on using the changeset viewer.