Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index 120bcd11433c8edaac1a498d8a17746ea66cf6b6..0846ea20abf784820d42703abc3a300cb538a6bd 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -70,7 +70,7 @@
#include "core/css/resolver/ViewportStyleResolver.h"
#include "core/dom/CSSSelectorWatch.h"
#include "core/dom/FirstLetterPseudoElement.h"
-#include "core/dom/NodeLayoutStyle.h"
+#include "core/dom/NodeComputedStyle.h"
#include "core/dom/StyleEngine.h"
#include "core/dom/Text.h"
#include "core/dom/shadow/ElementShadow.h"
@@ -105,7 +105,7 @@ namespace blink {
using namespace HTMLNames;
-LayoutStyle* StyleResolver::s_styleNotYetAvailable;
+ComputedStyle* StyleResolver::s_styleNotYetAvailable;
static StylePropertySet* leftToRightDeclaration()
{
@@ -475,18 +475,18 @@ void StyleResolver::matchAllRules(StyleResolverState& state, ElementRuleCollecto
}
}
-PassRefPtr<LayoutStyle> StyleResolver::styleForDocument(Document& document)
+PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document)
{
const LocalFrame* frame = document.frame();
- RefPtr<LayoutStyle> documentStyle = LayoutStyle::create();
+ RefPtr<ComputedStyle> documentStyle = ComputedStyle::create();
documentStyle->setRTLOrdering(document.visuallyOrdered() ? VisualOrder : LogicalOrder);
documentStyle->setZoom(frame && !document.printing() ? frame->pageZoomFactor() : 1);
documentStyle->setLocale(document.contentLanguage());
documentStyle->setZIndex(0);
documentStyle->setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONLY);
// These are designed to match the user-agent stylesheet values for the document element
- // so that the common case doesn't need to create a new LayoutStyle in
+ // so that the common case doesn't need to create a new ComputedStyle in
// Document::inheritHtmlAndBodyElementStyles.
documentStyle->setDisplay(BLOCK);
documentStyle->setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent);
@@ -518,10 +518,10 @@ AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state)
return AuthorStyleInfo(backgroundChanged, borderChanged);
}
-void StyleResolver::adjustLayoutStyle(StyleResolverState& state, Element* element)
+void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* element)
{
StyleAdjuster adjuster(document().inQuirksMode());
- adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), element, authorStyleInfo(state));
+ adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(), element, authorStyleInfo(state));
}
// Start loading resources referenced by this style.
@@ -531,7 +531,7 @@ void StyleResolver::loadPendingResources(StyleResolverState& state)
document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts();
}
-PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const LayoutStyle* defaultParent, StyleSharingBehavior sharingBehavior,
+PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior,
RuleMatchingBehavior matchingBehavior)
{
ASSERT(document().frame());
@@ -543,7 +543,7 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
// will vanish if a style recalc happens during loading.
if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() && !element->layoutObject()) {
if (!s_styleNotYetAvailable) {
- s_styleNotYetAvailable = LayoutStyle::create().leakRef();
+ s_styleNotYetAvailable = ComputedStyle::create().leakRef();
s_styleNotYetAvailable->setDisplay(NONE);
s_styleNotYetAvailable->font().update(document().styleEngine().fontSelector());
}
@@ -560,27 +560,27 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
if (sharingBehavior == AllowStyleSharing && (defaultParent || elementContext.parentStyle())) {
SharedStyleFinder styleFinder(elementContext, m_features, m_siblingRuleSet.get(), m_uncommonAttributeRuleSet.get(), *this);
- if (RefPtr<LayoutStyle> sharedStyle = styleFinder.findSharedStyle())
+ if (RefPtr<ComputedStyle> sharedStyle = styleFinder.findSharedStyle())
return sharedStyle.release();
}
StyleResolverState state(document(), elementContext, defaultParent);
ElementAnimations* elementAnimations = element->elementAnimations();
- const LayoutStyle* baseLayoutStyle = elementAnimations ? elementAnimations->baseLayoutStyle() : nullptr;
+ const ComputedStyle* baseComputedStyle = elementAnimations ? elementAnimations->baseComputedStyle() : nullptr;
- if (baseLayoutStyle) {
- state.setStyle(LayoutStyle::clone(*baseLayoutStyle));
+ if (baseComputedStyle) {
+ state.setStyle(ComputedStyle::clone(*baseComputedStyle));
if (!state.parentStyle())
state.setParentStyle(initialStyleForElement());
} else {
if (state.parentStyle()) {
- RefPtr<LayoutStyle> style = LayoutStyle::create();
- style->inheritFrom(*state.parentStyle(), isAtShadowBoundary(element) ? LayoutStyle::AtShadowBoundary : LayoutStyle::NotAtShadowBoundary);
+ RefPtr<ComputedStyle> style = ComputedStyle::create();
+ style->inheritFrom(*state.parentStyle(), isAtShadowBoundary(element) ? ComputedStyle::AtShadowBoundary : ComputedStyle::NotAtShadowBoundary);
state.setStyle(style.release());
} else {
state.setStyle(initialStyleForElement());
- state.setParentStyle(LayoutStyle::clone(*state.style()));
+ state.setParentStyle(ComputedStyle::clone(*state.style()));
}
}
@@ -588,7 +588,7 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
// be propagated from shadow host to distributed node.
if (state.distributedToInsertionPoint()) {
if (Element* parent = element->parentElement()) {
- if (LayoutStyle* styleOfShadowHost = parent->mutableLayoutStyle())
+ if (ComputedStyle* styleOfShadowHost = parent->mutableComputedStyle())
state.style()->setUserModify(styleOfShadowHost->userModify());
}
}
@@ -604,7 +604,7 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
state.style()->setInsideLink(linkState);
}
- if (!baseLayoutStyle) {
+ if (!baseComputedStyle) {
bool needsCollection = false;
CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(element, needsCollection);
@@ -615,10 +615,10 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludingSMIL);
- if (element->layoutStyle() && element->layoutStyle()->textAutosizingMultiplier() != state.style()->textAutosizingMultiplier()) {
+ if (element->computedStyle() && element->computedStyle()->textAutosizingMultiplier() != state.style()->textAutosizingMultiplier()) {
// Preserve the text autosizing multiplier on style recalc. Autosizer will update it during layout if needed.
// NOTE: this must occur before applyMatchedProperties for correct computation of font-relative lengths.
- state.style()->setTextAutosizingMultiplier(element->layoutStyle()->textAutosizingMultiplier());
+ state.style()->setTextAutosizingMultiplier(element->computedStyle()->textAutosizingMultiplier());
state.style()->setUnique();
}
@@ -631,17 +631,17 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
// Cache our original display.
state.style()->setOriginalDisplay(state.style()->display());
- adjustLayoutStyle(state, element);
+ adjustComputedStyle(state, element);
if (elementAnimations)
- elementAnimations->updateBaseLayoutStyle(state.style());
+ elementAnimations->updateBaseComputedStyle(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))
- adjustLayoutStyle(state, element);
+ adjustComputedStyle(state, element);
if (isHTMLBodyElement(*element))
document().textLinkColors().setTextColor(state.style()->color());
@@ -655,7 +655,7 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
return state.takeStyle();
}
-PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const LayoutStyle& elementStyle, const LayoutStyle* parentStyle, const StyleRuleKeyframe* keyframe, const AtomicString& animationName)
+PassRefPtr<ComputedStyle> StyleResolver::styleForKeyframe(Element& element, const ComputedStyle& elementStyle, const ComputedStyle* parentStyle, const StyleRuleKeyframe* keyframe, const AtomicString& animationName)
{
ASSERT(document().frame());
ASSERT(document().settings());
@@ -669,7 +669,7 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
ASSERT(!state.style());
// Create the style
- state.setStyle(LayoutStyle::clone(elementStyle));
+ state.setStyle(ComputedStyle::clone(elementStyle));
// 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.
@@ -694,10 +694,10 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
// This function is used by the WebAnimations JavaScript API method animate().
// FIXME: Remove this when animate() switches away from resolution-dependent parsing.
-PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(Element& element, const LayoutStyle* baseStyle, CSSPropertyID property, CSSValue* value)
+PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(Element& element, const ComputedStyle* baseStyle, CSSPropertyID property, CSSValue* value)
{
StyleResolverState state(element.document(), &element);
- state.setStyle(baseStyle ? LayoutStyle::clone(*baseStyle) : LayoutStyle::create());
+ state.setStyle(baseStyle ? ComputedStyle::clone(*baseStyle) : ComputedStyle::create());
return createAnimatableValueSnapshot(state, property, value);
}
@@ -737,8 +737,8 @@ PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
if (!parentRenderer->canHaveGeneratedChildren())
return nullptr;
- LayoutStyle* parentStyle = parentRenderer->style();
- if (LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) {
+ ComputedStyle* parentStyle = parentRenderer->style();
+ if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)) {
if (!pseudoElementRendererIsNeeded(cachedStyle))
return nullptr;
return createPseudoElement(&parent, pseudoId);
@@ -747,7 +747,7 @@ PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
StyleResolverState state(document(), &parent, parentStyle);
if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state))
return nullptr;
- RefPtr<LayoutStyle> style = state.takeStyle();
+ RefPtr<ComputedStyle> style = state.takeStyle();
ASSERT(style);
parentStyle->addCachedPseudoStyle(style);
@@ -762,7 +762,7 @@ PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
return pseudo.release();
}
-bool StyleResolver::pseudoStyleForElementInternal(Element& element, const PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle, StyleResolverState& state)
+bool StyleResolver::pseudoStyleForElementInternal(Element& element, const PseudoStyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolverState& state)
{
ASSERT(document().frame());
ASSERT(document().settings());
@@ -774,17 +774,17 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId);
ElementAnimations* elementAnimations = pseudoElement ? pseudoElement->elementAnimations() : nullptr;
- const LayoutStyle* baseLayoutStyle = elementAnimations ? elementAnimations->baseLayoutStyle() : nullptr;
+ const ComputedStyle* baseComputedStyle = elementAnimations ? elementAnimations->baseComputedStyle() : nullptr;
- if (baseLayoutStyle) {
- state.setStyle(LayoutStyle::clone(*baseLayoutStyle));
+ if (baseComputedStyle) {
+ state.setStyle(ComputedStyle::clone(*baseComputedStyle));
} else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) {
- RefPtr<LayoutStyle> style = LayoutStyle::create();
+ RefPtr<ComputedStyle> style = ComputedStyle::create();
style->inheritFrom(*state.parentStyle());
state.setStyle(style.release());
} else {
state.setStyle(initialStyleForElement());
- state.setParentStyle(LayoutStyle::clone(*state.style()));
+ state.setParentStyle(ComputedStyle::clone(*state.style()));
}
state.style()->setStyleType(pseudoStyleRequest.pseudoId);
@@ -792,7 +792,7 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
// Since we don't use pseudo-elements in any of our quirk/print
// user agent rules, don't waste time walking those rules.
- if (!baseLayoutStyle) {
+ if (!baseComputedStyle) {
// Check UA, user and author rules.
ElementRuleCollector collector(state.elementContext(), m_selectorFilter, state.style());
collector.setPseudoStyleRequest(pseudoStyleRequest);
@@ -810,18 +810,18 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
state.style()->setOriginalDisplay(state.style()->display());
// FIXME: Passing 0 as the Element* introduces a lot of complexity
- // in the adjustLayoutStyle code.
- adjustLayoutStyle(state, 0);
+ // in the adjustComputedStyle code.
+ adjustComputedStyle(state, 0);
if (elementAnimations)
- elementAnimations->updateBaseLayoutStyle(state.style());
+ elementAnimations->updateBaseComputedStyle(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, pseudoElement))
- adjustLayoutStyle(state, 0);
+ adjustComputedStyle(state, 0);
didAccess();
@@ -831,7 +831,7 @@ bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
return true;
}
-PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle)
+PassRefPtr<ComputedStyle> StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle)
{
ASSERT(parentStyle);
if (!element)
@@ -851,13 +851,13 @@ PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
return state.takeStyle();
}
-PassRefPtr<LayoutStyle> StyleResolver::styleForPage(int pageIndex)
+PassRefPtr<ComputedStyle> StyleResolver::styleForPage(int pageIndex)
{
ASSERT(!hasPendingAuthorStyleSheets());
StyleResolverState state(document(), document().documentElement()); // m_rootElementStyle will be set to the document style.
- RefPtr<LayoutStyle> style = LayoutStyle::create();
- const LayoutStyle* rootElementStyle = state.rootElementStyle() ? state.rootElementStyle() : document().layoutStyle();
+ RefPtr<ComputedStyle> style = ComputedStyle::create();
+ const ComputedStyle* rootElementStyle = state.rootElementStyle() ? state.rootElementStyle() : document().computedStyle();
ASSERT(rootElementStyle);
style->inheritFrom(*rootElementStyle);
state.setStyle(style.release());
@@ -887,23 +887,23 @@ PassRefPtr<LayoutStyle> StyleResolver::styleForPage(int pageIndex)
return state.takeStyle();
}
-PassRefPtr<LayoutStyle> StyleResolver::initialStyleForElement()
+PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement()
{
- RefPtr<LayoutStyle> style = LayoutStyle::create();
+ RefPtr<ComputedStyle> style = ComputedStyle::create();
FontBuilder fontBuilder(document());
fontBuilder.setInitial(style->effectiveZoom());
fontBuilder.createFont(document().styleEngine().fontSelector(), *style);
return style.release();
}
-PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode)
+PassRefPtr<ComputedStyle> StyleResolver::styleForText(Text* textNode)
{
ASSERT(textNode);
Node* parentNode = NodeRenderingTraversal::parent(*textNode);
- if (!parentNode || !parentNode->layoutStyle())
+ if (!parentNode || !parentNode->computedStyle())
return initialStyleForElement();
- return parentNode->mutableLayoutStyle();
+ return parentNode->mutableComputedStyle();
}
void StyleResolver::updateFont(StyleResolverState& state)
@@ -1343,15 +1343,15 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
// We can build up the style by copying non-inherited properties from an earlier style object built using the same exact
// style declarations. We then only need to apply the inherited properties, if any, as their values can depend on the
// element context. This is fast and saves memory by reusing the style data structures.
- state.style()->copyNonInheritedFromCached(*cachedMatchedProperties->layoutStyle);
- if (state.parentStyle()->inheritedDataShared(*cachedMatchedProperties->parentLayoutStyle) && !isAtShadowBoundary(element)
+ state.style()->copyNonInheritedFromCached(*cachedMatchedProperties->computedStyle);
+ if (state.parentStyle()->inheritedDataShared(*cachedMatchedProperties->parentComputedStyle) && !isAtShadowBoundary(element)
&& (!state.distributedToInsertionPoint() || state.style()->userModify() == READ_ONLY)) {
INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHit);
EInsideLink linkStatus = state.style()->insideLink();
// If the cache item parent style has identical inherited properties to the current parent style then the
// resulting style will be identical too. We copy the inherited properties over from the cache and are done.
- state.style()->inheritFrom(*cachedMatchedProperties->layoutStyle);
+ state.style()->inheritFrom(*cachedMatchedProperties->computedStyle);
// Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
state.style()->setInsideLink(linkStatus);
@@ -1379,10 +1379,10 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
// properties used as input to the FontBuilder, so resetting it here may cause the FontBuilder to recompute the
// font used as inheritable font for foreignObject content. If we want to support zoom on foreignObject we'll
// need to find another way of handling the SVG zoom model.
- state.setEffectiveZoom(LayoutStyle::initialZoom());
+ state.setEffectiveZoom(ComputedStyle::initialZoom());
}
- if (cachedMatchedProperties && cachedMatchedProperties->layoutStyle->effectiveZoom() != state.style()->effectiveZoom()) {
+ if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->effectiveZoom() != state.style()->effectiveZoom()) {
state.fontBuilder().didChangeEffectiveZoom();
applyInheritedOnly = false;
}
@@ -1391,13 +1391,13 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc
updateFont(state);
// Many properties depend on the font. If it changes we just apply all properties.
- if (cachedMatchedProperties && cachedMatchedProperties->layoutStyle->fontDescription() != state.style()->fontDescription())
+ if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontDescription() != state.style()->fontDescription())
applyInheritedOnly = false;
// Now do the normal priority UA properties.
applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
- // Cache the UA properties to pass them to LayoutTheme in adjustLayoutStyle.
+ // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyle.
state.cacheUserAgentBorderAndBackground();
// Now do the author and user normal priority properties and all the !important properties.
@@ -1468,7 +1468,7 @@ void StyleResolver::printStats()
fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data());
}
-void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, LayoutStyle* style)
+void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, ComputedStyle* style)
{
StyleResolverState state(document(), document().documentElement(), style);
state.setStyle(style);
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698