265 auto isOverflowVisible = m_style.overflowX() == Overflow::Visible || m_style.overflowY() == Overflow::Visible;
266 // UAs must apply the 'overflow' property set on the root element to the viewport. When the root element is an HTML "HTML" element
267 // or an XHTML "html" element, and that element has an HTML "BODY" element or an XHTML "body" element as a child,
268 // user agents must instead apply the 'overflow' property from the first such child element to the viewport,
269 // if the value on the root element is 'visible'. The 'visible' value when used for the viewport must be interpreted as 'auto'.
270 // The element from which the value is propagated must have a used value for 'overflow' of 'visible'.
271 if (isBodyBox()) {
272 auto* documentBox = parent();
273 ASSERT(documentBox);
274 if (!documentBox->isDocumentBox())
275 return isOverflowVisible;
276 if (!documentBox->isOverflowVisible())
277 return isOverflowVisible;
278 return true;
279 }
280 if (isInitialContainingBlock()) {
281 auto* documentBox = downcast<Container>(*this).firstChild();
282 if (!documentBox || !documentBox->isDocumentBox() || !is<Container>(documentBox))
283 return isOverflowVisible;
284 auto* bodyBox = downcast<Container>(documentBox)->firstChild();
285 if (!bodyBox || !bodyBox->isBodyBox())
286 return isOverflowVisible;
287 auto& bodyBoxStyle = bodyBox->style();
288 return bodyBoxStyle.overflowX() == Overflow::Visible || bodyBoxStyle.overflowY() == Overflow::Visible;
289 }
290 return isOverflowVisible;