void RenderTreeUpdater::updateElementRenderer(Element& element, const Style::ElementUpdate& update) { #if PLATFORM(IOS) CheckForVisibilityChange checkForVisibilityChange(element); #endif bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentElement()); if (shouldTearDownRenderers) tearDownRenderers(element, TeardownType::KeepHoverAndActive); bool hasDisplayContents = update.style->display() == CONTENTS; if (hasDisplayContents != element.hasDisplayContents()) { element.setHasDisplayContents(hasDisplayContents); // Render tree position needs to be recomputed as rendering siblings may be found from the display:contents subtree. renderTreePosition().invalidateNextSibling(); } bool shouldCreateNewRenderer = !element.renderer() && !hasDisplayContents; if (shouldCreateNewRenderer) { if (element.hasCustomStyleResolveCallbacks()) element.willAttachRenderers(); createRenderer(element, RenderStyle::clone(*update.style)); invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(element); return; } if (!element.renderer()) return; auto& renderer = *element.renderer(); if (update.recompositeLayer) { renderer.setStyle(RenderStyle::clone(*update.style), StyleDifferenceRecompositeLayer); return; } if (update.change == Style::NoChange) { if (pseudoStyleCacheIsInvalid(&renderer, update.style.get())) { renderer.setStyle(RenderStyle::clone(*update.style), StyleDifferenceEqual); return; } return; } renderer.setStyle(RenderStyle::clone(*update.style), StyleDifferenceEqual); }
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; }
void RenderTreeUpdater::updateElementRenderer(Element& element, Style::ElementUpdate& update) { bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentNode()); if (shouldTearDownRenderers) tearDownRenderers(element, TeardownType::KeepHoverAndActive); bool hasDisplayContest = update.style && update.style->display() == CONTENTS; if (hasDisplayContest != element.hasDisplayContents()) { element.setHasDisplayContents(hasDisplayContest); // Render tree position needs to be recomputed as rendering siblings may be found from the display:contents subtree. renderTreePosition().invalidateNextSibling(); } bool shouldCreateNewRenderer = !element.renderer() && update.style && !hasDisplayContest; if (shouldCreateNewRenderer) { if (element.hasCustomStyleResolveCallbacks()) element.willAttachRenderers(); createRenderer(element, WTFMove(*update.style)); invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(element); return; } if (!element.renderer()) return; auto& renderer = *element.renderer(); if (update.isSynthetic) { renderer.setStyle(WTFMove(*update.style), StyleDifferenceRecompositeLayer); return; } if (update.change == Style::NoChange) { if (pseudoStyleCacheIsInvalid(&renderer, update.style.get()) || (parent().styleChange == Style::Force && renderer.requiresForcedStyleRecalcPropagation())) { renderer.setStyle(WTFMove(*update.style), StyleDifferenceEqual); return; } return; } renderer.setStyle(WTFMove(*update.style), StyleDifferenceEqual); }