Changeset 137418 in webkit
- Timestamp:
- Dec 11, 2012 10:24:30 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r137414 r137418 1 2012-12-11 Takashi Sakamoto <tasak@google.com> 2 3 Text nodes in shadow roots don't inherit style properly 4 https://bugs.webkit.org/show_bug.cgi?id=101116 5 6 Reviewed by Hajime Morita. 7 8 * fast/dom/shadow/text-node-in-shadow-expected.html: Added. 9 * fast/dom/shadow/text-node-in-shadow.html: Added. 10 1 11 2012-12-11 Dominic Mazzoni <dmazzoni@google.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r137417 r137418 1 2012-12-11 Takashi Sakamoto <tasak@google.com> 2 3 Text nodes in shadow roots don't inherit style properly 4 https://bugs.webkit.org/show_bug.cgi?id=101116 5 6 Reviewed by Hajime Morita. 7 8 Use NodeRenderingContext to resolve styles of text nodes. 9 If text nodes are direct children of shadow roots, the text nodes 10 should be inherited styles from their shadow hosts. 11 But if reset-style-inheritance flag is true, the text nodes should 12 not be inherited. And if text nodes are distributed nodes, 13 we have to check whether their insertion point's 14 reset-style-inheritance. 15 c.f. shadow dom spec is: 16 http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles 17 18 Test: fast/dom/shadow/text-node-in-shadow.html 19 20 * css/StyleResolver.cpp: 21 (WebCore::StyleResolver::styleForElement): 22 Modified to use defaultStyleForElement if the given element has 23 no parent style. 24 (WebCore::StyleResolver::initForStyleResolve): 25 Removed shouldResetStyleInheritance, because now NodeRenderingContext 26 resetStyleInheritance() takes care of reset-style-inheritance of 27 both shadow roots and insertion points. 28 (WebCore::StyleResolver::defaultStyleForElement): 29 Added to create a default style for elements. 30 (WebCore): 31 (WebCore::StyleResolver::styleForText): 32 Use NodeRenderingContext to find the parent node for style from the 33 given text node. If no parent node is found or reset-style-inheritance 34 is true, returns a default style (i.e. empty render style). 35 Otherwise, just returns the found node's style. 36 * css/StyleResolver.h: 37 (StyleResolver): 38 * dom/ComposedShadowTreeWalker.cpp: 39 (WebCore::ComposedShadowTreeWalker::ParentTraversalDetails::didTraverseInsertionPoint): 40 Modify to consider insertion point's resetStyleInheritance. 41 * dom/NodeRenderingContext.cpp: 42 (WebCore::NodeRenderingContext::createRendererForTextIfNeeded): 43 Since NodeRenderingContext has already found a parent node for 44 rendering and style and a parentRenderer is just the found node's 45 renderer, we have to only check reset-style-inheritance. 46 If reset, use default style. Otherwise, the parentRenderer's style. 47 * dom/Text.cpp: 48 (WebCore::Text::recalcTextStyle): 49 Use styleForText instead of parentRenderer's styles if the given text 50 node is a direct child of a shadow root or a direct child of a shadow 51 host. 52 1 53 2012-12-11 Takashi Sakamoto <tasak@google.com> 2 54 -
trunk/Source/WebCore/css/StyleResolver.cpp
r137359 r137418 967 967 } 968 968 969 inline bool shouldResetStyleInheritance(NodeRenderingContext& context)970 {971 if (context.resetStyleInheritance())972 return true;973 974 if (InsertionPoint* insertionPoint = context.insertionPoint())975 return insertionPoint->resetStyleInheritance();976 977 return false;978 }979 980 969 inline void StyleResolver::initForStyleResolve(Element* e, RenderStyle* parentStyle, PseudoId pseudoID) 981 970 { … … 985 974 NodeRenderingContext context(e); 986 975 m_parentNode = context.parentNodeForRenderingAndStyle(); 987 m_parentStyle = shouldResetStyleInheritance(context) ? 0 :976 m_parentStyle = context.resetStyleInheritance() ? 0 : 988 977 parentStyle ? parentStyle : 989 978 m_parentNode ? m_parentNode->renderStyle() : 0; … … 1554 1543 } 1555 1544 1556 m_style = RenderStyle::create();1557 1558 1545 RefPtr<RenderStyle> cloneForParent; 1559 1546 1560 if (m_parentStyle) 1547 if (m_parentStyle) { 1548 m_style = RenderStyle::create(); 1561 1549 m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); 1562 else { 1563 // Make sure our fonts are initialized if we don't inherit them from our parent style. 1564 if (Settings* settings = documentSettings()) { 1565 initializeFontStyle(settings); 1566 m_style->font().update(fontSelector()); 1567 } else 1568 m_style->font().update(0); 1550 } else { 1551 m_style = defaultStyleForElement(); 1569 1552 cloneForParent = RenderStyle::clone(style()); 1570 1553 m_parentStyle = cloneForParent.get(); … … 1807 1790 // Now return the style. 1808 1791 return m_style.release(); 1792 } 1793 1794 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() 1795 { 1796 m_style = RenderStyle::create(); 1797 // Make sure our fonts are initialized if we don't inherit them from our parent style. 1798 if (Settings* settings = documentSettings()) { 1799 initializeFontStyle(settings); 1800 m_style->font().update(fontSelector()); 1801 } else 1802 m_style->font().update(0); 1803 1804 return m_style.release(); 1805 } 1806 1807 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) 1808 { 1809 ASSERT(textNode); 1810 1811 NodeRenderingContext context(textNode); 1812 Node* parentNode = context.parentNodeForRenderingAndStyle(); 1813 return context.resetStyleInheritance() || !parentNode ? 1814 defaultStyleForElement() : parentNode->renderStyle(); 1809 1815 } 1810 1816 -
trunk/Source/WebCore/css/StyleResolver.h
r137417 r137418 155 155 156 156 PassRefPtr<RenderStyle> styleForPage(int pageIndex); 157 PassRefPtr<RenderStyle> defaultStyleForElement(); 158 PassRefPtr<RenderStyle> styleForText(Text*); 157 159 158 160 static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector* = 0); -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
r137336 r137418 73 73 inline void ComposedShadowTreeWalker::ParentTraversalDetails::didTraverseInsertionPoint(InsertionPoint* insertionPoint) 74 74 { 75 if (!m_insertionPoint) 75 if (!m_insertionPoint) { 76 76 m_insertionPoint = insertionPoint; 77 m_resetStyleInheritance = m_resetStyleInheritance || insertionPoint->resetStyleInheritance(); 78 } 77 79 } 78 80 -
trunk/Source/WebCore/dom/NodeRenderingContext.cpp
r137336 r137418 45 45 #include "ShadowRoot.h" 46 46 #include "StyleInheritedData.h" 47 #include "StyleResolver.h" 47 48 #include "Text.h" 48 49 … … 266 267 if (!shouldCreateRenderer()) 267 268 return; 269 268 270 RenderObject* parentRenderer = this->parentRenderer(); 269 271 ASSERT(parentRenderer); 270 m_style = parentRenderer->style(); 272 Document* document = textNode->document(); 273 274 if (resetStyleInheritance()) 275 m_style = document->styleResolver()->defaultStyleForElement(); 276 else 277 m_style = parentRenderer->style(); 271 278 272 279 if (!textNode->textRendererIsNeeded(*this)) 273 280 return; 274 Document* document = textNode->document();275 281 RenderText* newRenderer = textNode->createTextRenderer(document->renderArena(), m_style.get()); 276 282 if (!newRenderer) -
trunk/Source/WebCore/dom/Text.cpp
r135668 r137418 34 34 35 35 #include "StyleInheritedData.h" 36 #include "StyleResolver.h" 36 37 #include <wtf/text/CString.h> 37 38 #include <wtf/text/StringBuilder.h> … … 283 284 { 284 285 RenderText* renderer = toRenderText(this->renderer()); 285 // The only time we have a renderer and our parent doesn't is if our parent 286 // is a shadow root. 287 if (change != NoChange && renderer) { 288 if (!parentNode()->isShadowRoot()) 289 renderer->setStyle(parentNode()->renderer()->style()); 290 #if ENABLE(SVG) 291 else if (isSVGShadowText(this)) 292 renderer->setStyle(toShadowRoot(parentNode())->host()->renderer()->style()); 293 #endif 294 } 286 287 if (change != NoChange && renderer) 288 renderer->setStyle(document()->styleResolver()->styleForText(this)); 295 289 296 290 if (needsStyleRecalc()) {
Note: See TracChangeset
for help on using the changeset viewer.