LayoutTests/ChangeLog

 12021-06-08 Antti Koivisto <antti@apple.com>
 2
 3 `text-decoration: underline` is not applied to web component
 4 https://bugs.webkit.org/show_bug.cgi?id=226724
 5 <rdar://problem/78987286>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 * fast/shadow-dom/effective-text-decoration-inheritance-expected.html: Added.
 10 * fast/shadow-dom/effective-text-decoration-inheritance.html: Added.
 11
1122021-06-07 Aditya Keerthi <akeerthi@apple.com>
213
314 [iOS] Unexpected scrolling when switching focus from a text input to a select element

LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance-expected.html

 1<div style="text-decoration: underline">This should be underlined</div>

LayoutTests/fast/shadow-dom/effective-text-decoration-inheritance.html

 1<script>
 2class CustomElement extends HTMLElement {
 3 constructor() {
 4 super();
 5
 6 const shadow = this.attachShadow({ mode: 'open' });
 7 const slot = document.createElement('slot');
 8 const style = document.createElement('style');
 9 style.textContent = `
 10 :host {
 11 text-decoration: underline;
 12 }
 13 `;
 14 shadow.append(style, slot);
 15 }
 16}
 17
 18customElements.define('custom-element', CustomElement);
 19</script>
 20
 21<custom-element>This should be underlined</custom-element>

Source/WebCore/ChangeLog

 12021-06-08 Antti Koivisto <antti@apple.com>
 2
 3 `text-decoration: underline` is not applied to web component
 4 https://bugs.webkit.org/show_bug.cgi?id=226724
 5 <rdar://problem/78987286>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 'text-decoration' is not an inherited property in itself but its effective value
 10 behaves as it was. We fail to inherit this effective value into author shadow trees.
 11
 12 Test case by Jeroen Zwartepoorte.
 13
 14 Test: fast/shadow-dom/effective-text-decoration-inheritance.html
 15
 16 * style/StyleAdjuster.cpp:
 17 (WebCore::Style::shouldInheritEffectiveTextDecorations):
 18
 19 Test for user agent shadow tree, not a shadow tree in general.
 20 Also inverse the logic and refactor a bit.
 21
 22 (WebCore::Style::Adjuster::adjust const):
 23 (WebCore::Style::isAtShadowBoundary): Deleted.
 24 (WebCore::Style::doesNotInheritTextDecoration): Deleted.
 25
1262021-06-07 Antti Koivisto <antti@apple.com>
227
328 Factor selection state computation out of LegacyInlineTextBox

Source/WebCore/style/StyleAdjuster.cpp

@@static DisplayType equivalentBlockDisplay(const RenderStyle& style, const Docume
141141 return DisplayType::Block;
142142}
143143
144 static inline bool isAtShadowBoundary(const Element& element)
 144static bool shouldInheritTextDecorationsInEffect(const RenderStyle& style, const Element* element)
145145{
146  auto* parentNode = element.parentNode();
147  return parentNode && parentNode->isShadowRoot();
148 }
 146 if (style.isFloating() || style.hasOutOfFlowPosition())
 147 return false;
149148
150 // CSS requires text-decoration to be reset at each DOM element for tables,
151 // inline blocks, inline tables, shadow DOM crossings, floating elements,
152 // and absolute or relatively positioned elements.
153 static bool doesNotInheritTextDecoration(const RenderStyle& style, const Element* element)
154 {
155  return style.display() == DisplayType::Table || style.display() == DisplayType::InlineTable
156  || style.display() == DisplayType::InlineBlock || style.display() == DisplayType::InlineBox || (element && isAtShadowBoundary(*element))
157  || style.isFloating() || style.hasOutOfFlowPosition();
 149 auto isAtUserAgentShadowBoundary = [&] {
 150 if (!element)
 151 return false;
 152 auto* parentNode = element->parentNode();
 153 return parentNode && parentNode->isUserAgentShadowRoot();
 154 }();
 155
 156 if (isAtUserAgentShadowBoundary)
 157 return false;
 158
 159 switch (style.display()) {
 160 case DisplayType::Table:
 161 case DisplayType::InlineTable:
 162 case DisplayType::InlineBlock:
 163 case DisplayType::InlineBox:
 164 return false;
 165 default:
 166 return true;
 167 };
158168}
159169
160170static bool isScrollableOverflow(Overflow overflow)

@@void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearance
393403 }
394404 }
395405
396  if (doesNotInheritTextDecoration(style, m_element))
397  style.setTextDecorationsInEffect(style.textDecoration());
398  else
 406 if (shouldInheritTextDecorationsInEffect(style, m_element))
399407 style.addToTextDecorationsInEffect(style.textDecoration());
 408 else
 409 style.setTextDecorationsInEffect(style.textDecoration());
400410
401411 // If either overflow value is not visible, change to auto.
402412 if (style.overflowX() == Overflow::Visible && style.overflowY() != Overflow::Visible) {