void Text::recalcTextStyle(StyleRecalcChange change) { if (RenderText* renderer = this->renderer()) { if (change != NoChange || needsStyleRecalc()) renderer->setStyle(document().styleResolver().styleForText(this)); if (needsStyleRecalc()) renderer->setText(dataImpl()); clearNeedsStyleRecalc(); } else if (needsStyleRecalc() || needsWhitespaceRenderer()) { reattach(); } }
bool Text::recalcTextStyle(StyleChange change) { if (RenderText* renderer = toRenderText(this->renderer())) { if (change != NoChange || needsStyleRecalc()) renderer->setStyle(document()->styleResolver()->styleForText(this)); if (needsStyleRecalc()) renderer->setText(dataImpl()); clearNeedsStyleRecalc(); } else if (needsStyleRecalc() || needsWhitespaceRenderer()) { reattach(); return true; } return false; }
void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { if (change != NoChange || needsStyleRecalc()) layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); if (needsStyleRecalc()) layoutItem.setText(dataImpl()); clearNeedsStyleRecalc(); } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { reattach(); if (this->layoutObject()) reattachWhitespaceSiblingsIfNeeded(nextTextSibling); } }
void SVGUseElement::recalcStyle(StyleChange change) { // Eventually mark shadow root element needing style recalc if (needsStyleRecalc() && m_targetElementInstance) { if (SVGElement* shadowRoot = m_targetElementInstance->shadowTreeElement()) shadowRoot->setNeedsStyleRecalc(); } SVGStyledTransformableElement::recalcStyle(change); bool needsStyleUpdate = !m_needsShadowTreeRecreation; if (m_needsShadowTreeRecreation) { static_cast<RenderSVGShadowTreeRootContainer*>(renderer())->markShadowTreeForRecreation(); m_needsShadowTreeRecreation = false; } RenderSVGShadowTreeRootContainer* shadowRoot = static_cast<RenderSVGShadowTreeRootContainer*>(renderer()); if (!shadowRoot) return; shadowRoot->updateFromElement(); if (!needsStyleUpdate) return; shadowRoot->updateStyle(change); }
void SVGUseElement::recalcStyle(StyleChange change) { // Eventually mark shadow root element needing style recalc if ((change >= Inherit || needsStyleRecalc() || childNeedsStyleRecalc()) && m_targetElementInstance && !m_updatesBlocked) { if (SVGElement* shadowRoot = m_targetElementInstance->shadowTreeElement()) shadowRoot->setNeedsStyleRecalc(); } SVGStyledTransformableElement::recalcStyle(change); // Assure that the shadow tree has not been marked for recreation, while we're building it. if (m_updatesBlocked) ASSERT(!m_needsShadowTreeRecreation); RenderSVGShadowTreeRootContainer* shadowRoot = static_cast<RenderSVGShadowTreeRootContainer*>(renderer()); if (!shadowRoot) return; bool needsStyleUpdate = !m_needsShadowTreeRecreation; if (m_needsShadowTreeRecreation) { shadowRoot->markShadowTreeForRecreation(); m_needsShadowTreeRecreation = false; } shadowRoot->updateFromElement(); if (!needsStyleUpdate) return; shadowRoot->updateStyle(change); }
void Element::recalcChildStyle(StyleRecalcChange change) { ASSERT(document().inStyleRecalc()); ASSERT(change >= Inherit || childNeedsStyleRecalc()); ASSERT(!needsStyleRecalc()); if (change > Inherit || childNeedsStyleRecalc()) { // This loop is deliberately backwards because we use insertBefore in the rendering tree, and want to avoid // a potentially n^2 loop to find the insertion point while resolving style. Having us start from the last // child and work our way back means in the common case, we'll find the insertion point in O(1) time. // See crbug.com/288225 StyleResolver& styleResolver = document().styleResolver(); for (Node* child = lastChild(); child; child = child->previousSibling()) { if (child->isTextNode()) { toText(child)->recalcTextStyle(change); } else if (child->isElementNode()) { Element* element = toElement(child); if (element->shouldCallRecalcStyle(change)) element->recalcStyle(change); else if (element->supportsStyleSharing()) styleResolver.addToStyleSharingList(*element); } } } }
StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) { ASSERT(document().inStyleRecalc()); ASSERT(!parentNode()->needsStyleRecalc()); ASSERT(change >= Inherit || needsStyleRecalc()); ASSERT(parentRenderStyle()); RefPtr<RenderStyle> oldStyle = renderStyle(); RefPtr<RenderStyle> newStyle = styleForRenderer(); StyleRecalcChange localChange = RenderStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); ASSERT(newStyle); if (localChange == Reattach) { AttachContext reattachContext; reattachContext.resolvedStyle = newStyle.get(); reattach(reattachContext); return Reattach; } ASSERT(oldStyle); if (RenderObject* renderer = this->renderer()) { if (localChange != NoChange) renderer->setStyle(newStyle.get()); } if (styleChangeType() >= SubtreeStyleChange) return Force; if (change > Inherit || localChange > Inherit) return max(localChange, change); return localChange; }
void SVGElement::willRecalcStyle(StyleRecalcChange change) { if (!hasSVGRareData()) return; // If the style changes because of a regular property change (not induced by SMIL animations themselves) // reset the "computed style without SMIL style properties", so the base value change gets reflected. if (change > NoChange || needsStyleRecalc()) svgRareData()->setNeedsOverrideComputedStyleUpdate(); }
void SVGElement::willRecalcStyle(StyleRecalcChange change) { // FIXME: This assumes that when shouldNotifyRendererWithIdenticalStyles() is true // the change came from a SMIL animation, but what if there were non-SMIL changes // since then? I think we should remove the shouldNotifyRendererWithIdenticalStyles // check. if (!hasSVGRareData() || shouldNotifyRendererWithIdenticalStyles()) return; // If the style changes because of a regular property change (not induced by SMIL animations themselves) // reset the "computed style without SMIL style properties", so the base value change gets reflected. if (change > NoChange || needsStyleRecalc()) svgRareData()->setNeedsOverrideComputedStyleUpdate(); }
void Text::recalcStyle(StyleChange change) { if (change != NoChange && parentNode()) { if (renderer()) renderer()->setStyle(parentNode()->renderer()->style()); } if (needsStyleRecalc()) { if (renderer()) { if (renderer()->isText()) toRenderText(renderer())->setText(dataImpl()); } else reattach(); } clearNeedsStyleRecalc(); }
void Text::recalcTextStyle(StyleChange change) { RenderText* renderer = toRenderText(this->renderer()); if (change != NoChange && renderer) renderer->setStyle(document()->ensureStyleResolver()->styleForText(this)); if (needsStyleRecalc()) { if (renderer) renderer->setText(dataImpl()); else reattach(); } clearNeedsStyleRecalc(); }
void Text::recalcStyle(StyleChange change) { if (change != NoChange && parentNode()) { if (renderer()) renderer()->setStyle(parentNode()->renderer()->style()); } if (needsStyleRecalc()) { if (renderer()) { if (renderer()->isText()) toRenderText(renderer())->setText(m_data); } else { if (attached()) detach(); attach(); } } setNeedsStyleRecalc(NoStyleChange); }
void Text::recalcTextStyle(StyleChange change) { if (hasCustomCallbacks()) willRecalcTextStyle(change); if (change != NoChange && parentNode() && parentNode()->renderer()) { if (renderer()) renderer()->setStyle(parentNode()->renderer()->style()); } if (needsStyleRecalc()) { if (renderer()) { if (renderer()->isText()) toRenderText(renderer())->setText(dataImpl()); } else reattach(); } clearNeedsStyleRecalc(); }
void Text::recalcTextStyle(StyleChange change) { if (hasCustomCallbacks()) willRecalcTextStyle(change); RenderObject* renderer = this->renderer(); // The only time we have a renderer and our parent doesn't is if our parent // is a shadow root. if (change != NoChange && renderer && !parentNode()->isShadowRoot()) renderer->setStyle(parentNode()->renderer()->style()); if (needsStyleRecalc()) { if (renderer) { if (renderer->isText()) toRenderText(renderer)->setText(dataImpl()); } else reattach(); } clearNeedsStyleRecalc(); }
void Element::recalcStyle(StyleRecalcChange change) { ASSERT(document().inStyleRecalc()); ASSERT(!parentNode()->needsStyleRecalc()); if (change >= Inherit || needsStyleRecalc()) { if (hasRareData()) { ElementRareData* data = elementRareData(); data->clearComputedStyle(); } if (parentRenderStyle()) change = recalcOwnStyle(change); clearNeedsStyleRecalc(); } // If we reattached we don't need to recalc the style of our descendants anymore. if ((change >= Inherit && change < Reattach) || childNeedsStyleRecalc()) { recalcChildStyle(change); clearChildNeedsStyleRecalc(); } }