void ShadowRoot::attach() { StyleResolver* styleResolver = document()->styleResolver(); styleResolver->pushParentShadowRoot(this); DocumentFragment::attach(); styleResolver->popParentShadowRoot(this); }
void DocumentStyleSheetCollection::resetCSSFeatureFlags() { StyleResolver* styleResolver = m_document->styleResolver(); m_usesSiblingRules = styleResolver->usesSiblingRules(); m_usesFirstLineRules = styleResolver->usesFirstLineRules(); m_usesBeforeAfterRules = styleResolver->usesBeforeAfterRules(); }
void RenderSVGInlineText::computeNewScaledFontForStyle(RenderObject* renderer, const RenderStyle* style, float& scalingFactor, Font& scaledFont) { ASSERT(style); ASSERT(renderer); Document* document = renderer->document(); ASSERT(document); StyleResolver* styleResolver = document->styleResolver(); ASSERT(styleResolver); // Alter font-size to the right on-screen value to avoid scaling the glyphs themselves, except when GeometricPrecision is specified scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFactor(renderer); if (scalingFactor == 1 || !scalingFactor || style->fontDescription().textRenderingMode() == GeometricPrecision) { scalingFactor = 1; scaledFont = style->font(); return; } FontDescription fontDescription(style->fontDescription()); // FIXME: We need to better handle the case when we compute very small fonts below (below 1pt). fontDescription.setComputedSize(StyleResolver::getComputedSizeFromSpecifiedSize(document, scalingFactor, fontDescription.isAbsoluteSize(), fontDescription.computedSize(), DoNotUseSmartMinimumForFontSize)); scaledFont = Font(fontDescription, 0, 0); scaledFont.update(styleResolver->fontSelector()); }
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); }
void ShadowTree::recalcShadowTreeStyle(Node::StyleChange change) { ShadowRoot* youngest = youngestShadowRoot(); if (!youngest) return; if (needsReattachHostChildrenAndShadow()) reattachHostChildrenAndShadow(); else { StyleResolver* styleResolver = youngest->document()->styleResolver(); styleResolver->pushParentShadowRoot(youngest); for (Node* n = youngest->firstChild(); n; n = n->nextSibling()) { if (n->isElementNode()) static_cast<Element*>(n)->recalcStyle(change); else if (n->isTextNode()) toText(n)->recalcTextStyle(change); } styleResolver->popParentShadowRoot(youngest); } clearNeedsReattachHostChildrenAndShadow(); for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { root->clearNeedsStyleRecalc(); root->clearChildNeedsStyleRecalc(); } }
void DocumentStyleSheetCollection::combineCSSFeatureFlags() { // Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/after). StyleResolver* styleResolver = m_document->styleResolver(); m_usesSiblingRules = m_usesSiblingRules || styleResolver->usesSiblingRules(); m_usesFirstLineRules = m_usesFirstLineRules || styleResolver->usesFirstLineRules(); m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver->usesBeforeAfterRules(); }
void ShadowRoot::attach() { StyleResolver* styleResolver = document()->styleResolver(); styleResolver->pushParentShadowRoot(this); attachChildrenIfNeeded(); attachAsNode(); styleResolver->popParentShadowRoot(this); }
bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag) { if (m_document->inStyleRecalc()) { // SVG <use> element may manage to invalidate style selector in the middle of a style recalc. // https://bugs.webkit.org/show_bug.cgi?id=54344 // FIXME: This should be fixed in SVG and the call site replaced by ASSERT(!m_inStyleRecalc). m_needsUpdateActiveStylesheetsOnStyleRecalc = true; m_document->scheduleForcedStyleRecalc(); return false; } if (!m_document->renderer() || !m_document->attached()) return false; Vector<RefPtr<StyleSheet> > activeStyleSheets; collectActiveStyleSheets(activeStyleSheets); Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets; activeCSSStyleSheets.append(injectedAuthorStyleSheets()); activeCSSStyleSheets.append(documentAuthorStyleSheets()); collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document); filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); StyleResolverUpdateType styleResolverUpdateType; bool requiresFullStyleRecalc; analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc); if (styleResolverUpdateType == Reconstruct) m_document->clearStyleResolver(); else { StyleResolver* styleResolver = m_document->styleResolver(); if (styleResolverUpdateType == Reset) { styleResolver->ruleSets().resetAuthorStyle(); styleResolver->appendAuthorStyleSheets(0, activeCSSStyleSheets); } else { ASSERT(styleResolverUpdateType == Additive); styleResolver->appendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), activeCSSStyleSheets); } resetCSSFeatureFlags(); } m_activeAuthorStyleSheets.swap(activeCSSStyleSheets); m_styleSheetsForStyleSheetList.swap(activeStyleSheets); m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); m_needsUpdateActiveStylesheetsOnStyleRecalc = false; m_document->notifySeamlessChildDocumentsOfStylesheetUpdate(); return requiresFullStyleRecalc; }
PassOwnPtr<MediaQueryEvaluator> MediaQueryMatcher::prepareEvaluator() const { if (!m_document || !m_document->frame()) return nullptr; Element* documentElement = m_document->documentElement(); if (!documentElement) return nullptr; StyleResolver* styleResolver = m_document->ensureStyleResolver(); RefPtr<RenderStyle> rootStyle = styleResolver->styleForElement(documentElement, 0 /*defaultParent*/, DisallowStyleSharing, MatchOnlyUserAgentRules); return adoptPtr(new MediaQueryEvaluator(mediaType(), m_document->frame(), rootStyle.get())); }
void ShadowRoot::recalcStyle(StyleChange change) { // ShadowRoot doesn't support custom callbacks. ASSERT(!hasCustomCallbacks()); StyleResolver* styleResolver = document()->styleResolver(); styleResolver->pushParentShadowRoot(this); for (Node* child = firstChild(); child; child = child->nextSibling()) { if (child->isElementNode()) static_cast<Element*>(child)->recalcStyle(change); else if (child->isTextNode()) toText(child)->recalcTextStyle(change); } styleResolver->popParentShadowRoot(this); clearNeedsStyleRecalc(); clearChildNeedsStyleRecalc(); }
void RenderThemeSafari::setFontFromControlSize(StyleResolver& styleResolver, RenderStyle& style, NSControlSize controlSize) const { FontDescription fontDescription; fontDescription.setIsAbsoluteSize(true); float fontSize = systemFontSizeForControlSize(controlSize); fontDescription.setOneFamily("Lucida Grande"); fontDescription.setComputedSize(fontSize); fontDescription.setSpecifiedSize(fontSize); // Reset line height style.setLineHeight(RenderStyle::initialLineHeight()); if (style.setFontDescription(fontDescription)) style.fontCascade().update(&styleResolver.document().fontSelector()); }
static void applyPropertyToCurrentStyle(StyleResolver& styleResolver, CSSPropertyID id, const RefPtr<StyleProperties>& parsedStyle) { styleResolver.applyPropertyToCurrentStyle(id, parsedStyle->getPropertyCSSValue(id).get()); }