|
Lines 199-204
auto TreeResolver::computeDescendantsToResolve(Change change, Validity validity,
a/Source/WebCore/style/StyleTreeResolver.cpp_sec1
|
| 199 |
case Change::FastPathInherited: |
199 |
case Change::FastPathInherited: |
| 200 |
case Change::Inherited: |
200 |
case Change::Inherited: |
| 201 |
return DescendantsToResolve::Children; |
201 |
return DescendantsToResolve::Children; |
|
|
202 |
case Change::Descendants: |
| 202 |
case Change::Renderer: |
203 |
case Change::Renderer: |
| 203 |
return DescendantsToResolve::All; |
204 |
return DescendantsToResolve::All; |
| 204 |
}; |
205 |
}; |
|
Lines 625-630
ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderSt
a/Source/WebCore/style/StyleTreeResolver.cpp_sec2
|
| 625 |
void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change change, DescendantsToResolve descendantsToResolve) |
626 |
void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change change, DescendantsToResolve descendantsToResolve) |
| 626 |
{ |
627 |
{ |
| 627 |
scope().selectorMatchingState.selectorFilter.pushParent(&element); |
628 |
scope().selectorMatchingState.selectorFilter.pushParent(&element); |
|
|
629 |
if (style.containerType() != ContainerType::None) |
| 630 |
scope().selectorMatchingState.queryContainers.append(element); |
| 628 |
|
631 |
|
| 629 |
Parent parent(element, style, change, descendantsToResolve); |
632 |
Parent parent(element, style, change, descendantsToResolve); |
| 630 |
|
633 |
|
|
Lines 645-651
void TreeResolver::popParent()
a/Source/WebCore/style/StyleTreeResolver.cpp_sec3
|
| 645 |
auto& parentElement = *parent().element; |
648 |
auto& parentElement = *parent().element; |
| 646 |
|
649 |
|
| 647 |
parentElement.setHasValidStyle(); |
650 |
parentElement.setHasValidStyle(); |
| 648 |
parentElement.clearChildNeedsStyleRecalc(); |
651 |
// Don't clear the child flag if the are unresolved containers because we are going to resume the style resolution. |
|
|
652 |
if (m_unresolvedQueryContainers.isEmpty()) |
| 653 |
parentElement.clearChildNeedsStyleRecalc(); |
| 649 |
|
654 |
|
| 650 |
if (parent().didPushScope) |
655 |
if (parent().didPushScope) |
| 651 |
popScope(); |
656 |
popScope(); |
|
Lines 834-843
void TreeResolver::resolveComposedTree()
a/Source/WebCore/style/StyleTreeResolver.cpp_sec4
|
| 834 |
if (!style) |
839 |
if (!style) |
| 835 |
resetStyleForNonRenderedDescendants(element); |
840 |
resetStyleForNonRenderedDescendants(element); |
| 836 |
|
841 |
|
| 837 |
bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None); |
842 |
auto queryContainerAction = determineQueryContainerAction(element, style, previousContainerType); |
|
|
843 |
|
| 844 |
bool shouldIterateChildren = [&] { |
| 845 |
// display::none, no need to resolve descendants. |
| 846 |
if (!style) |
| 847 |
return false; |
| 848 |
// Style resolution will be resumed after the container has been resolved. |
| 849 |
if (queryContainerAction == QueryContainerAction::Resolve) |
| 850 |
return false; |
| 851 |
return element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None; |
| 852 |
}(); |
| 838 |
|
853 |
|
| 839 |
if (style && updateQueryContainer(element, *style, previousContainerType) == QueryContainerAction::Layout) |
854 |
// Ensure we respect DescendantsToResolve::All after resuming the style resolution. |
| 840 |
shouldIterateChildren = false; |
855 |
if (queryContainerAction == QueryContainerAction::Resolve && descendantsToResolve == DescendantsToResolve::All) |
|
|
856 |
element.invalidateStyleForSubtreeInternal(); |
| 841 |
|
857 |
|
| 842 |
if (!m_didSeePendingStylesheet) |
858 |
if (!m_didSeePendingStylesheet) |
| 843 |
m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren); |
859 |
m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren); |
|
Lines 860-898
void TreeResolver::resolveComposedTree()
a/Source/WebCore/style/StyleTreeResolver.cpp_sec5
|
| 860 |
popParentsToDepth(1); |
876 |
popParentsToDepth(1); |
| 861 |
} |
877 |
} |
| 862 |
|
878 |
|
| 863 |
auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style, ContainerType previousContainerType) -> QueryContainerAction |
879 |
auto TreeResolver::determineQueryContainerAction(Element& element, const RenderStyle* style, ContainerType previousContainerType) -> QueryContainerAction |
| 864 |
{ |
880 |
{ |
| 865 |
if (style.containerType() != ContainerType::None) |
881 |
if (!style) |
| 866 |
scope().selectorMatchingState.queryContainers.append(element); |
882 |
return QueryContainerAction::None; |
| 867 |
|
|
|
| 868 |
if (m_unresolvedQueryContainers.remove(&element)) |
| 869 |
return QueryContainerAction::Continue; |
| 870 |
|
883 |
|
| 871 |
// Render tree needs to be updated before proceeding to children also if we have a former query container |
884 |
// FIXME: Render tree needs to be updated before proceeding to children also if we have a former query container |
| 872 |
// because container query resolution for descendants relies on it being up-to-date. |
885 |
// because container unit resolution for descendants relies on it being up-to-date. |
| 873 |
if (style.containerType() == ContainerType::None && previousContainerType == ContainerType::None) |
886 |
if (style->containerType() == ContainerType::None && previousContainerType == ContainerType::None) |
| 874 |
return QueryContainerAction::None; |
887 |
return QueryContainerAction::None; |
| 875 |
|
888 |
|
| 876 |
if (m_update->isEmpty()) |
889 |
if (m_resolvedQueryContainers.contains(&element)) |
| 877 |
return QueryContainerAction::Continue; |
890 |
return QueryContainerAction::None; |
| 878 |
|
891 |
|
| 879 |
// Bail out from TreeResolver to build a render tree and do a layout. Resolution continues after. |
|
|
| 880 |
m_unresolvedQueryContainers.add(&element); |
892 |
m_unresolvedQueryContainers.add(&element); |
| 881 |
return QueryContainerAction::Layout; |
893 |
return QueryContainerAction::Resolve; |
| 882 |
} |
894 |
} |
| 883 |
|
895 |
|
| 884 |
std::unique_ptr<Update> TreeResolver::resolve() |
896 |
std::unique_ptr<Update> TreeResolver::resolve() |
| 885 |
{ |
897 |
{ |
|
|
898 |
m_resolvedQueryContainers.add(m_unresolvedQueryContainers.begin(), m_unresolvedQueryContainers.end()); |
| 899 |
m_unresolvedQueryContainers.clear(); |
| 900 |
|
| 886 |
Element* documentElement = m_document.documentElement(); |
901 |
Element* documentElement = m_document.documentElement(); |
| 887 |
if (!documentElement) { |
902 |
if (!documentElement) { |
| 888 |
m_document.styleScope().resolver(); |
903 |
m_document.styleScope().resolver(); |
| 889 |
return nullptr; |
904 |
return nullptr; |
| 890 |
} |
905 |
} |
| 891 |
|
906 |
|
| 892 |
// FIXME: Just need to restore the ancestor marking. |
|
|
| 893 |
for (auto& queryContainer : m_unresolvedQueryContainers) |
| 894 |
queryContainer->invalidateStyleForSubtreeInternal(); |
| 895 |
|
| 896 |
if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) |
907 |
if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) |
| 897 |
return WTFMove(m_update); |
908 |
return WTFMove(m_update); |
| 898 |
|
909 |
|