#include "core/StylePropertyShorthand.h"
#include "core/animation/DocumentAnimations.h"
#include "core/css/BasicShapeFunctions.h"
-#include "core/css/CSSAspectRatioValue.h"
#include "core/css/CSSBorderImage.h"
#include "core/css/CSSFilterValue.h"
#include "core/css/CSSFontFeatureValue.h"
#include "core/css/CSSGridLineNamesValue.h"
#include "core/css/CSSGridTemplateAreasValue.h"
#include "core/css/CSSLineBoxContainValue.h"
-#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSReflectValue.h"
#include "core/css/CSSSelector.h"
#include "core/css/CSSShadowValue.h"
#include "core/css/CSSValuePool.h"
#include "core/css/Pair.h"
#include "core/css/Rect.h"
-#include "core/css/RuntimeCSSEnabled.h"
#include "core/css/StylePropertySet.h"
+#include "core/css/parser/CSSParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
CSSPropertyWebkitBackgroundComposite,
CSSPropertyWebkitBackgroundOrigin,
CSSPropertyWebkitBackgroundSize,
- CSSPropertyWebkitBorderFit,
CSSPropertyWebkitBorderHorizontalSpacing,
CSSPropertyWebkitBorderImage,
CSSPropertyWebkitBorderVerticalSpacing,
{
DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
if (properties.isEmpty())
- RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticComputableProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties);
+ CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticComputableProperties, WTF_ARRAY_LENGTH(staticComputableProperties), properties);
return properties;
}
static PassRefPtrWillBeRawPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle& style)
{
- if (!renderer || !renderer->hasTransform() || !style.hasTransform())
+ if (!renderer || !renderer->hasTransformRelatedProperty() || !style.hasTransform())
return cssValuePool().createIdentifierValue(CSSValueNone);
IntRect box;
RefPtrWillBeRawPtr<CSSFilterValue> filterValue = nullptr;
- Vector<RefPtr<FilterOperation> >::const_iterator end = style.filter().operations().end();
- for (Vector<RefPtr<FilterOperation> >::const_iterator it = style.filter().operations().begin(); it != end; ++it) {
- FilterOperation* filterOperation = it->get();
+ for (const auto& operation : style.filter().operations()) {
+ FilterOperation* filterOperation = operation.get();
switch (filterOperation->type()) {
case FilterOperation::REFERENCE:
filterValue = CSSFilterValue::create(CSSFilterValue::ReferenceFilterOperation);
{
const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style.gridTemplateColumns() : style.gridTemplateRows();
const OrderedNamedGridLines& orderedNamedGridLines = direction == ForColumns ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines();
+ bool isRenderGrid = renderer && renderer->isRenderGrid();
+
+ // Handle the 'none' case.
+ bool trackListIsEmpty = trackSizes.isEmpty();
+ if (isRenderGrid && trackListIsEmpty) {
+ // For grids we should consider every listed track, whether implicitly or explicitly created. If we don't have
+ // any explicit track and there are no children then there are no implicit tracks. We cannot simply check the
+ // number of rows/columns in our internal grid representation because it's always at least 1x1 (see r143331).
+ trackListIsEmpty = !toRenderBlock(renderer)->firstChild();
+ }
- // Handle the 'none' case here.
- if (!trackSizes.size()) {
+ if (trackListIsEmpty) {
ASSERT(orderedNamedGridLines.isEmpty());
return cssValuePool().createIdentifierValue(CSSValueNone);
}
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- if (renderer && renderer->isRenderGrid()) {
+ if (isRenderGrid) {
const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toRenderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions();
// There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
// so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
ASSERT(trackPositions.size() - 1 >= trackSizes.size());
- for (size_t i = 0; i < trackSizes.size(); ++i) {
+ for (size_t i = 0; i < trackPositions.size() - 1; ++i) {
addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
list->append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i], style));
}
case TimingFunction::StepsFunction:
{
const StepsTimingFunction* stepsTimingFunction = toStepsTimingFunction(timingFunction);
- if (stepsTimingFunction->subType() == StepsTimingFunction::Custom)
- return CSSStepsTimingFunctionValue::create(stepsTimingFunction->numberOfSteps(), stepsTimingFunction->stepAtPosition());
+ StepsTimingFunction::StepAtPosition position = stepsTimingFunction->stepAtPosition();
+ int steps = stepsTimingFunction->numberOfSteps();
+ ASSERT(position == StepsTimingFunction::Start || position == StepsTimingFunction::End);
- CSSValueID valueId;
- switch (stepsTimingFunction->subType()) {
- case StepsTimingFunction::Start:
- valueId = CSSValueStepStart;
- break;
- case StepsTimingFunction::End:
- valueId = CSSValueStepEnd;
- break;
- default:
- ASSERT_NOT_REACHED();
- return nullptr;
- }
+ if (steps > 1)
+ return CSSStepsTimingFunctionValue::create(steps, position);
+ CSSValueID valueId = position == StepsTimingFunction::Start ? CSSValueStepStart : CSSValueStepEnd;
return cssValuePool().createIdentifierValue(valueId);
}
{
unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0;
m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType(
- AtomicString(pseudoElementName.substring(nameWithoutColonsStart))));
+ AtomicString(pseudoElementName.substring(nameWithoutColonsStart)), false));
}
CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration()
if (i)
result.append(' ');
result.append(getPropertyName(properties[i]));
- result.append(": ", 2);
+ result.appendLiteral(": ");
result.append(getPropertyValue(properties[i]));
result.append(';');
}
return nullptr;
RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- for (CounterDirectiveMap::const_iterator it = map->begin(); it != map->end(); ++it) {
- list->append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
- short number = propertyID == CSSPropertyCounterIncrement ? it->value.incrementValue() : it->value.resetValue();
+ for (const auto& item : *map) {
+ list->append(cssValuePool().createValue(item.key, CSSPrimitiveValue::CSS_STRING));
+ short number = propertyID == CSSPropertyCounterIncrement ? item.value.incrementValue() : item.value.resetValue();
list->append(cssValuePool().createValue((double)number, CSSPrimitiveValue::CSS_NUMBER));
}
return list.release();
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontSize(RenderStyle& style)
{
- return zoomAdjustedPixelValue(style.fontDescription().computedPixelSize(), style);
+ return zoomAdjustedPixelValue(RuntimeEnabledFeatures::subpixelFontScalingEnabled() ? style.fontDescription().computedSize() : style.fontDescription().computedPixelSize(), style);
}
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForFontStretch(RenderStyle& style)
}
}
-PassRefPtr<RenderStyle> CSSComputedStyleDeclaration::computeRenderStyle(CSSPropertyID propertyID) const
+PassRefPtr<RenderStyle> CSSComputedStyleDeclaration::computeRenderStyle() const
{
Node* styledNode = this->styledNode();
ASSERT(styledNode);
return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart;
}
+static ContentPosition resolveContentAlignmentAuto(ContentPosition position, ContentDistributionType distribution, Node* element)
+{
+ if (position != ContentPositionAuto || distribution != ContentDistributionDefault)
+ return position;
+
+ bool isFlex = element && element->computedStyle()
+ && element->computedStyle()->isDisplayFlexibleBox();
+
+ return isFlex ? ContentPositionFlexStart : ContentPositionStart;
+}
+
static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType)
{
RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
return result.release();
}
+static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributionWithOverflowAlignment(ContentPosition position, OverflowAlignment overflowAlignment, ContentDistributionType distribution)
+{
+ RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
+ if (distribution != ContentDistributionDefault)
+ result->append(CSSPrimitiveValue::create(distribution));
+ if (distribution == ContentDistributionDefault || position != ContentPositionAuto)
+ result->append(CSSPrimitiveValue::create(position));
+ if ((position >= ContentPositionCenter || distribution != ContentDistributionDefault) && overflowAlignment != OverflowAlignmentDefault)
+ result->append(CSSPrimitiveValue::create(overflowAlignment));
+ ASSERT(result->length() > 0);
+ ASSERT(result->length() <= 3);
+ return result.release();
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
{
Node* styledNode = this->styledNode();
styledNode = this->styledNode();
renderer = styledNode->renderer();
- style = computeRenderStyle(propertyID);
+ style = computeRenderStyle();
bool forceFullLayout = isLayoutDependent(propertyID, style, renderer)
|| styledNode->isInShadowTree()
if (forceFullLayout) {
document.updateLayoutIgnorePendingStylesheets();
styledNode = this->styledNode();
- style = computeRenderStyle(propertyID);
+ style = computeRenderStyle();
renderer = styledNode->renderer();
}
} else {
- style = computeRenderStyle(propertyID);
+ style = computeRenderStyle();
}
if (!style)
return cssValuePool().createIdentifierValue(CSSValueAuto);
return cssValuePool().createValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyColumnFill:
- if (RuntimeEnabledFeatures::regionBasedColumnsEnabled())
- return cssValuePool().createValue(style->columnFill());
- return nullptr;
+ ASSERT(RuntimeEnabledFeatures::regionBasedColumnsEnabled());
+ return cssValuePool().createValue(style->columnFill());
case CSSPropertyWebkitColumnGap:
if (style->hasNormalColumnGap())
return cssValuePool().createIdentifierValue(CSSValueNormal);
case CSSPropertyFlexWrap:
return cssValuePool().createValue(style->flexWrap());
case CSSPropertyJustifyContent:
- return cssValuePool().createValue(style->justifyContent());
+ return valueForContentPositionAndDistributionWithOverflowAlignment(resolveContentAlignmentAuto(style->justifyContent(), style->justifyContentDistribution(), styledNode), style->justifyContentOverflowAlignment(), style->justifyContentDistribution());
case CSSPropertyOrder:
return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyFloat:
if (style->hyphenationString().isNull())
return cssValuePool().createIdentifierValue(CSSValueAuto);
return cssValuePool().createValue(style->hyphenationString(), CSSPrimitiveValue::CSS_STRING);
- case CSSPropertyWebkitBorderFit:
- if (style->borderFit() == BorderFitBorder)
- return cssValuePool().createIdentifierValue(CSSValueBorder);
- return cssValuePool().createIdentifierValue(CSSValueLines);
case CSSPropertyImageRendering:
return CSSPrimitiveValue::create(style->imageRendering());
case CSSPropertyIsolation:
return cssValuePool().createValue(style->userModify());
case CSSPropertyMaxHeight: {
const Length& maxHeight = style->maxHeight();
- if (maxHeight.isUndefined())
+ if (maxHeight.isMaxSizeNone())
return cssValuePool().createIdentifierValue(CSSValueNone);
return zoomAdjustedPixelValueForLength(maxHeight, *style);
}
case CSSPropertyMaxWidth: {
const Length& maxWidth = style->maxWidth();
- if (maxWidth.isUndefined())
+ if (maxWidth.isMaxSizeNone())
return cssValuePool().createIdentifierValue(CSSValueNone);
return zoomAdjustedPixelValueForLength(maxWidth, *style);
}
}
case CSSPropertyWebkitAppearance:
return cssValuePool().createValue(style->appearance());
- case CSSPropertyWebkitAspectRatio:
- if (!style->hasAspectRatio())
- return cssValuePool().createIdentifierValue(CSSValueNone);
- return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
case CSSPropertyBackfaceVisibility:
case CSSPropertyWebkitBackfaceVisibility:
return cssValuePool().createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
case CSSPropertyBorderTopRightRadius:
return valueForBorderRadiusCorner(style->borderTopRightRadius(), *style);
case CSSPropertyClip: {
- if (!style->hasClip())
+ if (style->hasAutoClip())
return cssValuePool().createIdentifierValue(CSSValueAuto);
RefPtrWillBeRawPtr<Rect> rect = Rect::create();
rect->setTop(zoomAdjustedPixelValue(style->clip().top().value(), *style));
case CSSPropertyBackgroundRepeatX:
case CSSPropertyBackgroundRepeatY:
break;
- case CSSPropertyInternalCallback:
- // This property is hidden from the web.
- return nullptr;
/* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
case CSSPropertyWebkitTextEmphasis:
case CSSPropertyUserZoom:
break;
- // Internal properties that shouldn't be exposed throught getComputedStyle.
- case CSSPropertyInternalMarqueeDirection:
- case CSSPropertyInternalMarqueeIncrement:
- case CSSPropertyInternalMarqueeRepetition:
- case CSSPropertyInternalMarqueeSpeed:
- case CSSPropertyInternalMarqueeStyle:
- ASSERT_NOT_REACHED();
- return nullptr;
-
case CSSPropertyBufferedRendering:
case CSSPropertyClipPath:
case CSSPropertyClipRule:
unsigned CSSComputedStyleDeclaration::length() const
{
- Node* node = m_node.get();
- if (!node)
+ if (!m_node || !m_node->inActiveDocument())
return 0;
-
- RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier);
- if (!style)
- return 0;
-
return computableProperties().size();
}
String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
{
CSSPropertyID propertyID = cssPropertyID(propertyName);
- if (!propertyID || !RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID))
+ if (!propertyID)
return String();
+ ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
return getPropertyValue(propertyID);
}