#include "core/rendering/style/KeyframeList.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGElement.h"
-#include "core/svg/SVGFontFaceElement.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/StdLibExtras.h"
}
initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSelectors());
-
-#if ENABLE(SVG_FONTS)
- if (document.svgExtensions()) {
- const WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >& svgFontFaceElements = document.svgExtensions()->svgFontFaceElements();
- WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_iterator end = svgFontFaceElements.end();
- for (WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_iterator it = svgFontFaceElements.begin(); it != end; ++it)
- addFontFaceRule(&document, document.styleEngine()->fontSelector(), (*it)->fontFaceRule());
- }
-#endif
}
void StyleResolver::initWatchedSelectorRules(const WillBeHeapVector<RefPtrWillBeMember<StyleRule> >& watchedSelectors)
ScopedStyleResolver& resolver = treeScope->ensureScopedStyleResolver();
document().styleEngine()->addScopedStyleResolver(&resolver);
- resolver.addRulesFromSheet(cssSheet, *m_medium, this);
+ unsigned index = resolver.appendCSSStyleSheet(cssSheet);
+
+ addRulesFromSheet(cssSheet, treeScope, index);
+}
+
+void StyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, TreeScope* treeScope, unsigned index)
+{
+ StyleSheetContents* sheet = cssSheet->contents();
+ AddRuleFlags addRuleFlags = document().securityOrigin()->canRequest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
+ const RuleSet& ruleSet = sheet->ensureRuleSet(*m_medium, addRuleFlags);
+
+ addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults());
+ processScopedRules(ruleSet, cssSheet, index, treeScope->rootNode());
}
void StyleResolver::appendPendingAuthorStyleSheets()
{
- for (WillBeHeapListHashSet<RawPtrWillBeMember<CSSStyleSheet>, 16>::iterator it = m_pendingStyleSheets.begin(); it != m_pendingStyleSheets.end(); ++it)
- appendCSSStyleSheet(*it);
+ for (const auto& styleSheet : m_pendingStyleSheets)
+ appendCSSStyleSheet(styleSheet);
m_pendingStyleSheets.clear();
finishAppendAuthorStyleSheets();
CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance();
RuleSet* userAgentStyleSheet = m_printMediaType ? defaultStyleSheets.defaultPrintStyle() : defaultStyleSheets.defaultStyle();
- matchUARules(collector, userAgentStyleSheet);
+ matchRuleSet(collector, userAgentStyleSheet);
// In quirks mode, we match rules from the quirks user agent sheet.
if (document().inQuirksMode())
- matchUARules(collector, defaultStyleSheets.defaultQuirksStyle());
+ matchRuleSet(collector, defaultStyleSheets.defaultQuirksStyle());
// If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet.
if (document().isViewSource())
- matchUARules(collector, defaultStyleSheets.defaultViewSourceStyle());
+ matchRuleSet(collector, defaultStyleSheets.defaultViewSourceStyle());
if (document().isTransitionDocument())
- matchUARules(collector, defaultStyleSheets.defaultTransitionStyle());
+ matchRuleSet(collector, defaultStyleSheets.defaultTransitionStyle());
collector.setMatchingUARules(false);
}
-void StyleResolver::matchUARules(ElementRuleCollector& collector, RuleSet* rules)
+void StyleResolver::matchRuleSet(ElementRuleCollector& collector, RuleSet* rules)
{
collector.clearMatchedRules();
collector.matchedResult().ranges.lastUARule = collector.matchedResult().matchedProperties.size() - 1;
return sharedStyle.release();
}
- if (state.parentStyle()) {
- state.setStyle(RenderStyle::create());
- state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
+ ActiveAnimations* activeAnimations = element->activeAnimations();
+ const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->baseRenderStyle() : nullptr;
+
+ if (baseRenderStyle) {
+ state.setStyle(RenderStyle::clone(baseRenderStyle));
+ if (!state.parentStyle())
+ state.setParentStyle(defaultStyleForElement());
} else {
- state.setStyle(defaultStyleForElement());
- state.setParentStyle(RenderStyle::clone(state.style()));
+ if (state.parentStyle()) {
+ state.setStyle(RenderStyle::create());
+ state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
+ } else {
+ state.setStyle(defaultStyleForElement());
+ state.setParentStyle(RenderStyle::clone(state.style()));
+ }
}
+
// contenteditable attribute (implemented by -webkit-user-modify) should
// be propagated from shadow host to distributed node.
if (state.distributedToInsertionPoint()) {
}
}
- state.fontBuilder().initForStyleResolve(state.document(), state.style());
-
if (element->isLink()) {
state.style()->setIsLink(true);
EInsideLink linkState = state.elementLinkState();
state.style()->setInsideLink(linkState);
}
- bool needsCollection = false;
- CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element, needsCollection);
- if (needsCollection)
- collectFeatures();
+ if (!baseRenderStyle) {
+
+ bool needsCollection = false;
+ CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element, needsCollection);
+ if (needsCollection)
+ collectFeatures();
- {
ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludingSMIL);
applyCallbackSelectors(state);
addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
- }
- // Cache our original display.
- state.style()->setOriginalDisplay(state.style()->display());
+ // Cache our original display.
+ state.style()->setOriginalDisplay(state.style()->display());
- adjustRenderStyle(state, element);
+ adjustRenderStyle(state, element);
+
+ if (activeAnimations)
+ activeAnimations->updateBaseRenderStyle(state.style());
+ }
// FIXME: The CSSWG wants to specify that the effects of animations are applied before
// important rules, but this currently happens here as we require adjustment to have happened
// Create the style
state.setStyle(RenderStyle::clone(&elementStyle));
- state.setLineHeightValue(0);
-
- state.fontBuilder().initForStyleResolve(state.document(), state.style());
// We don't need to bother with !important. Since there is only ever one
// decl, there's nothing to override. So just add the first properties.
// If our font got dirtied, go ahead and update it now.
updateFont(state);
- // Line-height is set when we are sure we decided on the font-size
- if (state.lineHeightValue())
- StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeightValue());
-
// Now do rest of the properties.
applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
style = RenderStyle::create();
StyleResolverState state(element.document(), &element);
state.setStyle(style);
- state.fontBuilder().initForStyleResolve(state.document(), state.style());
return createAnimatableValueSnapshot(state, property, value);
}
ASSERT(document().frame());
ASSERT(document().settings());
ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED);
+ ASSERT(state.parentStyle());
StyleResolverParentScope::ensureParentStackIsPushed();
- if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
+ Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId);
+
+ ActiveAnimations* activeAnimations = pseudoElement ? pseudoElement->activeAnimations() : nullptr;
+ const RenderStyle* baseRenderStyle = activeAnimations ? activeAnimations->baseRenderStyle() : nullptr;
+
+ if (baseRenderStyle) {
+ state.setStyle(RenderStyle::clone(baseRenderStyle));
+ } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
state.setStyle(RenderStyle::create());
state.style()->inheritFrom(state.parentStyle());
} else {
}
state.style()->setStyleType(pseudoStyleRequest.pseudoId);
- state.fontBuilder().initForStyleResolve(state.document(), state.style());
// Since we don't use pseudo-elements in any of our quirk/print
// user agent rules, don't waste time walking those rules.
- {
+ if (!baseRenderStyle) {
// Check UA, user and author rules.
ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
collector.setPseudoStyleRequest(pseudoStyleRequest);
applyCallbackSelectors(state);
addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
- }
- // Cache our original display.
- state.style()->setOriginalDisplay(state.style()->display());
+ // Cache our original display.
+ state.style()->setOriginalDisplay(state.style()->display());
- // FIXME: Passing 0 as the Element* introduces a lot of complexity
- // in the adjustRenderStyle code.
- adjustRenderStyle(state, 0);
+ // FIXME: Passing 0 as the Element* introduces a lot of complexity
+ // in the adjustRenderStyle code.
+ adjustRenderStyle(state, 0);
+
+ if (activeAnimations)
+ activeAnimations->updateBaseRenderStyle(state.style());
+ }
// FIXME: The CSSWG wants to specify that the effects of animations are applied before
// important rules, but this currently happens here as we require adjustment to have happened
// before deciding which properties to transition.
- if (applyAnimatedProperties(state, element.pseudoElement(pseudoStyleRequest.pseudoId)))
+ if (applyAnimatedProperties(state, pseudoElement))
adjustRenderStyle(state, 0);
didAccess();
ASSERT(rootElementStyle);
state.style()->inheritFrom(rootElementStyle);
- state.fontBuilder().initForStyleResolve(state.document(), state.style());
-
PageRuleCollector collector(rootElementStyle, pageIndex);
collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle());
if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver())
scopedResolver->matchPageRules(collector);
- state.setLineHeightValue(0);
bool inheritedOnly = false;
MatchResult& result = collector.matchedResult();
// If our font got dirtied, go ahead and update it now.
updateFont(state);
- // Line-height is set when we are sure we decided on the font-size.
- if (state.lineHeightValue())
- StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeightValue());
-
applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
addContentAttrValuesToFeatures(state.contentAttrValues(), m_features);
{
StyleResolverState state(document(), 0);
state.setStyle(RenderStyle::create());
- state.fontBuilder().initForStyleResolve(document(), state.style());
- state.style()->setLineHeight(RenderStyle::initialLineHeight());
- state.setLineHeightValue(0);
state.fontBuilder().setInitial(state.style()->effectiveZoom());
state.style()->font().update(document().styleEngine()->fontSelector());
return state.takeStyle();
template <StyleResolver::StyleApplicationPass pass>
void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolations)
{
- for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::const_iterator iter = activeInterpolations.begin(); iter != activeInterpolations.end(); ++iter) {
- CSSPropertyID property = iter->key;
+ for (const auto& interpolationEntry : activeInterpolations) {
+ CSSPropertyID property = interpolationEntry.key;
if (!isPropertyForPass<pass>(property))
continue;
- const StyleInterpolation* interpolation = toStyleInterpolation(iter->value.get());
+ const StyleInterpolation* interpolation = toStyleInterpolation(interpolationEntry.value.get());
interpolation->apply(state);
}
}
case CSSPropertyWebkitBorderEndColor:
case CSSPropertyWebkitBorderEndStyle:
case CSSPropertyWebkitBorderEndWidth:
- case CSSPropertyWebkitBorderFit:
case CSSPropertyWebkitBorderHorizontalSpacing:
case CSSPropertyWebkitBorderImage:
case CSSPropertyWebkitBorderRadius:
// This method returns the last CSSPropertyId of high priority properties.
template<> CSSPropertyID StyleResolver::lastCSSPropertyId<StyleResolver::HighPriorityProperties>()
{
- COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyColor + 18, CSS_line_height_is_end_of_high_prioity_property_range);
- COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyLineHeight - 1, CSS_zoom_is_before_line_height);
- return CSSPropertyLineHeight;
+ COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_high_priority_property_range);
+ COMPILE_ASSERT(CSSPropertyTextRendering == CSSPropertyZoom - 1, CSS_text_rendering_is_before_zoom);
+ return CSSPropertyZoom;
}
// This method returns the first CSSPropertyId of remaining properties,
// lastCSSPropertyId<LowPriorityProperties>.
template<> CSSPropertyID StyleResolver::firstCSSPropertyId<StyleResolver::LowPriorityProperties>()
{
- COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyLineHeight + 1, CSS_background_is_first_low_priority_property);
+ COMPILE_ASSERT(CSSPropertyAlignContent == CSSPropertyZoom + 1, CSS_align_content_is_first_low_priority_property);
return CSSPropertyAlignContent;
}
CSSPropertyID propertyId = static_cast<CSSPropertyID>(i);
// StyleBuilder does not allow any expanded shorthands.
- if (isExpandedShorthandForAll(propertyId))
+ if (isShorthandProperty(propertyId))
continue;
// all shorthand spec says:
continue;
}
+ if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStyleProperty(property))
+ continue;
+ if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFirstLetterStyleProperty(property))
+ continue;
+
if (inheritedOnly && !current.isInherited()) {
// If the property value is explicitly inherited, we need to apply further non-inherited properties
// as they might override the value inherited here. For this reason we don't allow declarations with
continue;
}
- if (propertyWhitelistType == PropertyWhitelistCue && !isValidCueStyleProperty(property))
- continue;
- if (propertyWhitelistType == PropertyWhitelistFirstLetter && !isValidFirstLetterStyleProperty(property))
- continue;
if (!isPropertyForPass<pass>(property))
continue;
- if (pass == HighPriorityProperties && property == CSSPropertyLineHeight)
- state.setLineHeightValue(current.value());
- else
- StyleBuilder::applyProperty(current.id(), state, current.value());
+
+ StyleBuilder::applyProperty(current.id(), state, current.value());
}
}
// high-priority properties first, i.e., those properties that other properties depend on.
// The order is (1) high-priority not important, (2) high-priority important, (3) normal not important
// and (4) normal important.
- state.setLineHeightValue(0);
applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
// If our font got dirtied, go ahead and update it now.
updateFont(state);
- // Line-height is set when we are sure we decided on the font-size.
- if (state.lineHeightValue())
- StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeightValue());
-
// Many properties depend on the font. If it changes we just apply all properties.
if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDescription() != state.style()->fontDescription())
applyInheritedOnly = false;
StyleResolverState state(document(), document().documentElement(), style);
state.setStyle(style);
- state.fontBuilder().initForStyleResolve(document(), style);
-
for (size_t i = 0; i < count; ++i) {
if (properties[i].value) {
// As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,