void resolveTree(Document& document, Change change) { bool resolveRootStyle = change == Force || (document.shouldDisplaySeamlesslyWithParent() && change >= Inherit); if (resolveRootStyle) { RefPtr<RenderStyle> documentStyle = resolveForDocument(document); #if PLATFORM(IOS) // Inserting the pictograph font at the end of the font fallback list is done by the // font selector, so set a font selector if needed. if (Settings* settings = document.settings()) { StyleResolver* styleResolver = document.styleResolverIfExists(); if (settings->fontFallbackPrefersPictographs() && styleResolver) documentStyle->font().update(styleResolver->fontSelector()); } #endif Style::Change documentChange = determineChange(documentStyle.get(), document.renderer()->style(), document.settings()); if (documentChange != NoChange) document.renderer()->setStyle(documentStyle.release()); } Element* documentElement = document.documentElement(); if (!documentElement) return; if (change < Inherit && !documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) return; resolveTree(*documentElement, change); }
ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, RenderElement* rendererToUpdate, Document& document) { ElementUpdate update; std::unique_ptr<RenderStyle> animatedStyle; if (rendererToUpdate && document.frame()->animation().updateAnimations(*rendererToUpdate, *newStyle, animatedStyle)) update.isSynthetic = true; if (animatedStyle) { update.change = determineChange(rendererToUpdate->style(), *animatedStyle); // If animation forces render tree reconstruction pass the original style. The animation will be applied on renderer construction. // FIXME: We should always use the animated style here. update.style = update.change == Detach ? WTFMove(newStyle) : WTFMove(animatedStyle); } else { update.change = rendererToUpdate ? determineChange(rendererToUpdate->style(), *newStyle) : Detach; update.style = WTFMove(newStyle); } return update; }
void resolveTree(Document* document, Change change) { bool resolveRootStyle = change == Force || (document->shouldDisplaySeamlesslyWithParent() && change >= Inherit); if (resolveRootStyle) { RefPtr<RenderStyle> documentStyle = resolveForDocument(document); Style::Change documentChange = determineChange(documentStyle.get(), document->renderer()->style(), document->settings()); if (documentChange != NoChange) document->renderer()->setStyle(documentStyle.release()); } for (Element* child = ElementTraversal::firstWithin(document); child; child = ElementTraversal::nextSibling(child)) { if (change < Inherit && !child->childNeedsStyleRecalc() && !child->needsStyleRecalc()) continue; resolveTree(child, change); } }
static Change resolveLocal(Element* current, Change inheritedChange) { Change localChange = Detach; RefPtr<RenderStyle> newStyle; RefPtr<RenderStyle> currentStyle = current->renderStyle(); Document* document = current->document(); if (currentStyle) { newStyle = current->styleForRenderer(); localChange = determineChange(currentStyle.get(), newStyle.get(), document->settings()); } if (localChange == Detach) { AttachContext reattachContext; reattachContext.resolvedStyle = newStyle.get(); reattachRenderTree(current, reattachContext); return Detach; } if (RenderObject* renderer = current->renderer()) { if (localChange != NoChange || pseudoStyleCacheIsInvalid(renderer, newStyle.get()) || (inheritedChange == Force && renderer->requiresForcedStyleRecalcPropagation()) || current->styleChangeType() == SyntheticStyleChange) renderer->setAnimatableStyle(newStyle.get()); else if (current->needsStyleRecalc()) { // Although no change occurred, we use the new style so that the cousin style sharing code won't get // fooled into believing this style is the same. renderer->setStyleInternal(newStyle.get()); } } // If "rem" units are used anywhere in the document, and if the document element's font size changes, then go ahead and force font updating // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway). if (document->styleSheetCollection()->usesRemUnits() && document->documentElement() == current && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) { // Cached RenderStyles may depend on the re units. if (StyleResolver* styleResolver = document->styleResolverIfExists()) styleResolver->invalidateMatchedPropertiesCache(); return Force; } if (inheritedChange == Force) return Force; if (current->styleChangeType() >= FullStyleChange) return Force; return localChange; }