CSSVariableData* CSSVariableResolver::valueForCustomProperty(AtomicString name) { if (m_variablesSeen.contains(name)) { m_cycleStartPoints.add(name); return nullptr; } if (!m_styleVariableData) return nullptr; CSSVariableData* variableData = m_styleVariableData->getVariable(name); if (!variableData) return nullptr; if (!variableData->needsVariableResolution()) return variableData; RefPtr<CSSVariableData> newVariableData = resolveCustomProperty(name, *variableData); m_styleVariableData->setVariable(name, newVariableData); return newVariableData.get(); }
PassRefPtr<CSSVariableData> CSSVariableResolver::resolveCustomProperty(AtomicString name, const CSSVariableData& variableData) { ASSERT(variableData.needsVariableResolution()); Vector<CSSParserToken> tokens; m_variablesSeen.add(name); bool success = resolveTokenRange(variableData.tokens(), tokens); m_variablesSeen.remove(name); // The old variable data holds onto the backing string the new resolved CSSVariableData // relies on. Ensure it will live beyond us overwriting the RefPtr in StyleVariableData. ASSERT(variableData.refCount() > 1); if (!success || !m_cycleStartPoints.isEmpty()) { m_cycleStartPoints.remove(name); return nullptr; } return CSSVariableData::createResolved(tokens, variableData); }