source: webkit/trunk/Source/WebCore/css/CSSFontStyleValue.h

Last change on this file was 252392, checked in by Simon Fraser, 6 years ago

Convert CSSPrimitiveValue::UnitType to an enum class, and cleanup
https://bugs.webkit.org/show_bug.cgi?id=204101

Reviewed by Antti Koivisto.
Source/WebCore:

Move CSSPrimitiveValue::UnitType to a standalone enum class CSSUnitType, and
CSSPrimitiveVallue::UnitCategory to CSSUnitCategory; these are going to more extensive
use in calc() and in the CSS OM.

Remove some comments about quirky units behavior which is now the standard behavior.

The compiler warned about some units not handled in CSSPrimitiveValue::formatNumberForCustomCSSText()
and CSSPrimitiveValue::equals() which may reveal bugs; assert for now.

  • css/CSSCalculationValue.cpp:

(WebCore::calcUnitCategory):
(WebCore::hasDoubleValue):
(WebCore::CSSCalcOperation::createSimplified):
(WebCore::CSSCalcOperation::primitiveType const):
(WebCore::CSSCalcExpressionNodeParser::parseValue):
(WebCore::createBlendHalf):
(WebCore::createCSS):
(WebCore::unitCategory): Deleted.

  • css/CSSCalculationValue.h:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForImageSliceSide):
(WebCore::valueForNinePieceImageQuad):
(WebCore::zoomAdjustedPixelValue):
(WebCore::zoomAdjustedNumberValue):
(WebCore::valueForReflection):
(WebCore::percentageOrZoomAdjustedValue):
(WebCore::matrixTransformValue):
(WebCore::adjustLengthForZoom):
(WebCore::ComputedStyleExtractor::valueForFilter):
(WebCore::specifiedValueForGridTrackBreadth):
(WebCore::specifiedValueForGridTrackSize):
(WebCore::OrderedNamedLinesCollector::appendLines const):
(WebCore::valueForGridPosition):
(WebCore::createTransitionPropertyValue):
(WebCore::delayValue):
(WebCore::durationValue):
(WebCore::textUnderlineOffsetToCSSValue):
(WebCore::textDecorationThicknessToCSSValue):
(WebCore::altTextToCSSValue):
(WebCore::contentToCSSValue):
(WebCore::counterToCSSValue):
(WebCore::ComputedStyleExtractor::fontNonKeywordWeightFromStyleValue):
(WebCore::ComputedStyleExtractor::fontNonKeywordStretchFromStyleValue):
(WebCore::ComputedStyleExtractor::fontNonKeywordStyleFromStyleValue):
(WebCore::fontShorthandValueForSelectionProperties):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

  • css/CSSCrossfadeValue.cpp:

(WebCore::CSSCrossfadeValue::blend const):

  • css/CSSCustomPropertyValue.cpp:

(WebCore::CSSCustomPropertyValue::customCSSText const):

  • css/CSSFontFace.cpp:

(WebCore::calculateItalicRange):

  • css/CSSFontStyleValue.h:
  • css/CSSGradientValue.cpp:

(WebCore::compareStops):
(WebCore::CSSGradientValue::computeStops):
(WebCore::appendGradientStops):
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSConicGradientValue::createGradient):

  • css/CSSImageValue.cpp:

(WebCore::CSSImageValue::createDeprecatedCSSOMWrapper const):

  • css/CSSPrimitiveValue.cpp:

(WebCore::isValidCSSUnitTypeForDoubleConversion):
(WebCore::isStringType):
(WebCore::unitCategory):
(WebCore::CSSPrimitiveValue::primitiveType const):
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::init):
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::computeDegrees const):
(WebCore::CSSPrimitiveValue::computeLengthDouble const):
(WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
(WebCore::CSSPrimitiveValue::setFloatValue):
(WebCore::CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor):
(WebCore::CSSPrimitiveValue::getFloatValue const):
(WebCore::CSSPrimitiveValue::doubleValue const):
(WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory):
(WebCore::CSSPrimitiveValue::doubleValueInternal const):
(WebCore::CSSPrimitiveValue::setStringValue):
(WebCore::CSSPrimitiveValue::getStringValue const):
(WebCore::CSSPrimitiveValue::stringValue const):
(WebCore:: const):
(WebCore::CSSPrimitiveValue::getRGBColorValue const):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
(WebCore::CSSPrimitiveValue::equals const):
(WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const):
(WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const):
(WebCore::CSSPrimitiveValue::unitCategory): Deleted.

  • css/CSSPrimitiveValue.h:

(WebCore::CSSPrimitiveValue::isAngle const):
(WebCore::CSSPrimitiveValue::isFontRelativeLength):
(WebCore::CSSPrimitiveValue::isLength):
(WebCore::CSSPrimitiveValue::isResolution):
(WebCore::CSSPrimitiveValue::createAllowingMarginQuirk):
(WebCore::CSSPrimitiveValue::computeTime const):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator short const):
(WebCore::CSSPrimitiveValue::operator unsigned short const):
(WebCore::CSSPrimitiveValue::operator int const):
(WebCore::CSSPrimitiveValue::operator unsigned const):
(WebCore::CSSPrimitiveValue::operator float const):
(WebCore::CSSPrimitiveValue::operator LineClampValue const):
(WebCore::CSSPrimitiveValue::operator ColumnFill const):
(WebCore::CSSPrimitiveValue::operator ColumnSpan const):
(WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const):
(WebCore::CSSPrimitiveValue::operator ImageOrientation const):

  • css/CSSStyleDeclaration.cpp:

(WebCore::CSSStyleDeclaration::namedItem):

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::mapNinePieceImageSlice):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):

  • css/CSSValue.h:
  • css/CSSValuePool.cpp:

(WebCore::CSSValuePool::CSSValuePool):
(WebCore::CSSValuePool::createValue):

  • css/CSSValuePool.h:

(WebCore::CSSValuePool::createValue):

  • css/DeprecatedCSSOMPrimitiveValue.cpp:

(WebCore::DeprecatedCSSOMPrimitiveValue::primitiveType const):
(WebCore::DeprecatedCSSOMPrimitiveValue::setFloatValue):
(WebCore::DeprecatedCSSOMPrimitiveValue::getFloatValue const):
(WebCore::DeprecatedCSSOMPrimitiveValue::setStringValue):

  • css/DeprecatedCSSOMPrimitiveValue.h:
  • css/DeprecatedCSSOMRGBColor.h:
  • css/MediaQueryEvaluator.cpp:

(WebCore::doubleValue):
(WebCore::evaluateResolution):

  • css/MediaQueryExpression.cpp:

(WebCore::featureWithValidIdent):

  • css/SVGCSSComputedStyleDeclaration.cpp:

(WebCore::glyphOrientationToCSSPrimitiveValue):
(WebCore::ComputedStyleExtractor::adjustSVGPaintForCurrentColor const):
(WebCore::ComputedStyleExtractor::svgPropertyValue):

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::asText const):

  • css/parser/CSSParserFastPaths.cpp:

(WebCore::parseSimpleLength):
(WebCore::parseSimpleAngle):
(WebCore::parseSimpleLengthValue):
(WebCore::parseColorIntOrPercentage):
(WebCore::fastParseColorInternal):
(WebCore::parseTransformTranslateArguments):
(WebCore::parseTransformAngleArgument):
(WebCore::parseTransformNumberArguments):

  • css/parser/CSSParserToken.cpp:

(WebCore::cssPrimitiveValueUnitFromTrie):
(WebCore::stringToUnitType):
(WebCore::CSSParserToken::CSSParserToken):
(WebCore::CSSParserToken::convertToPercentage):

  • css/parser/CSSParserToken.h:

(WebCore::CSSParserToken::unitType const):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::CSSPropertyParser::consumeTransformOrigin):
(WebCore::consumeFontStyle):
(WebCore::consumeFontStyleRange):
(WebCore::consumeCounter):
(WebCore::consumeAnimationName):
(WebCore::consumePerspective):
(WebCore::consumePositionLonghand):
(WebCore::consumeAttr):
(WebCore::consumeCounterContent):
(WebCore::consumeReflect):
(WebCore::consumeGridBreadth):
(WebCore::CSSPropertyParser::consumeSystemFont):
(WebCore::CSSPropertyParser::consumeFlex):

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::CalcParser::consumeInteger):
(WebCore::CSSPropertyParserHelpers::CalcParser::consumeNumber):
(WebCore::CSSPropertyParserHelpers::consumeInteger):
(WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
(WebCore::CSSPropertyParserHelpers::consumeLength):
(WebCore::CSSPropertyParserHelpers::consumePercent):
(WebCore::CSSPropertyParserHelpers::consumeAngle):
(WebCore::CSSPropertyParserHelpers::consumeAngleOrPercent):
(WebCore::CSSPropertyParserHelpers::consumeTime):
(WebCore::CSSPropertyParserHelpers::consumeResolution):
(WebCore::CSSPropertyParserHelpers::consumeCustomIdent):
(WebCore::CSSPropertyParserHelpers::consumeString):
(WebCore::CSSPropertyParserHelpers::consumeUrl):
(WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientPoint):
(WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientColorStop):
(WebCore::CSSPropertyParserHelpers::consumeCrossFade):
(WebCore::CSSPropertyParserHelpers::consumeImageSet):
(WebCore::CSSPropertyParserHelpers::consumeFilterFunction):

  • css/parser/MediaQueryParser.cpp:

(WebCore::MediaQueryParser::readFeatureValue):

  • css/parser/SizesAttributeParser.cpp:

(WebCore::SizesAttributeParser::computeLength):
(WebCore::SizesAttributeParser::effectiveSizeDefaultValue):

  • css/parser/SizesAttributeParser.h:
  • css/typedom/StylePropertyMapReadOnly.cpp:

(WebCore::StylePropertyMapReadOnly::reifyValue):

  • dom/StyledElement.cpp:

(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::addPropertyToPresentationAttributeStyle):

  • dom/StyledElement.h:
  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::computedFontSize):

  • editing/EditingStyle.cpp:

(WebCore::legacyFontSizeFromCSSValue):

  • editing/FontAttributeChanges.cpp:

(WebCore::FontChanges::createStyleProperties const):
(WebCore::cssValueListForShadow):

  • editing/cocoa/HTMLConverter.mm:

(stringFromCSSValue):
(floatValueFromPrimitiveValue):

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::applyBorderAttributeToStyle):

  • html/HTMLEmbedElement.cpp:

(WebCore::HTMLEmbedElement::collectStyleForPresentationAttribute):

  • html/HTMLHRElement.cpp:

(WebCore::HTMLHRElement::collectStyleForPresentationAttribute):

  • html/HTMLIFrameElement.cpp:

(WebCore::HTMLIFrameElement::collectStyleForPresentationAttribute):

  • html/HTMLInputElement.cpp:

(WebCore::autoFillStrongPasswordMaskImage):

  • html/HTMLMeterElement.cpp:

(WebCore::HTMLMeterElement::didElementStateChange):

  • html/HTMLTableElement.cpp:

(WebCore::HTMLTableElement::collectStyleForPresentationAttribute):
(WebCore::HTMLTableElement::createSharedCellStyle):

  • html/ValidationMessage.cpp:

(WebCore::adjustBubblePosition):

  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlPanelElement::setPosition):
(WebCore::MediaControlPanelElement::makeOpaque):
(WebCore::MediaControlPanelElement::makeTransparent):
(WebCore::MediaControlTextTrackContainerElement::updateTextStrokeStyle):
(WebCore::MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation):

  • html/shadow/ProgressShadowElement.cpp:

(WebCore::ProgressValueElement::setWidthPercentage):

  • html/shadow/TextControlInnerElements.cpp:

(WebCore::TextControlInnerElement::resolveCustomStyle):

  • html/shadow/mac/ImageControlsButtonElementMac.cpp:

(WebCore::ImageControlsButtonElementMac::tryCreate):

  • html/track/TextTrackCueGeneric.cpp:

(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
(WebCore::TextTrackCueGeneric::setFontSize):

  • html/track/VTTCue.cpp:

(WebCore::VTTCueBox::applyCSSProperties):
(WebCore::VTTCue::getDisplayTree):

  • html/track/VTTRegion.cpp:

(WebCore::VTTRegion::displayLastTextTrackCueBox):
(WebCore::VTTRegion::willRemoveTextTrackCueBox):
(WebCore::VTTRegion::prepareRegionDisplayTree):

  • page/DragController.cpp:

(WebCore::DragController::insertDroppedImagePlaceholdersAtCaret):

  • page/PrintContext.cpp:

(WebCore::PrintContext::computedPageMargin):

  • page/animation/CSSPropertyAnimation.cpp:

(WebCore::crossfadeBlend):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::resize):

  • rendering/RenderThemeIOS.mm:

(WebCore::applyCommonButtonPaddingToStyle):
(WebCore::RenderThemeIOS::adjustButtonStyle const):

  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::convertNumber):
(WebCore::Style::BuilderConverter::convertWebkitHyphenateLimitLines):
(WebCore::Style::BuilderConverter::convertClipPath):
(WebCore::Style::BuilderConverter::convertTextStrokeWidth):
(WebCore::Style::BuilderConverter::convertFontStyleFromValue):

  • style/StyleBuilderCustom.h:

(WebCore::Style::BuilderCustom::mmLength):
(WebCore::Style::BuilderCustom::inchLength):
(WebCore::Style::BuilderCustom::applyValueImageResolution):

  • svg/SVGLengthValue.cpp:

(WebCore::primitiveTypeToLengthType):
(WebCore::lengthTypeToPrimitiveType):

Source/WebKit:

Move CSSPrimitiveValue::UnitType to a standalone enum class CSSUnitType, and
CSSPrimitiveVallue::UnitCategory to CSSUnitCategory; these are going to more extensive
use in calc() and in the CSS OM.

  • WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:

(WebKit::PDFPluginAnnotation::updateGeometry):

  • WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:

(WebKit::PDFPluginChoiceAnnotation::updateGeometry):

  • WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:

(WebKit::PDFPluginTextAnnotation::updateGeometry):

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Rev URL
File size: 2.7 KB
Line 
1/*
2 * Copyright (C) 2017 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "CSSPrimitiveValue.h"
29#include "CSSValue.h"
30#include "FontSelectionAlgorithm.h"
31
32namespace WebCore {
33
34class CSSFontStyleValue final : public CSSValue {
35public:
36 static Ref<CSSFontStyleValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue)
37 {
38 return adoptRef(*new CSSFontStyleValue(WTFMove(fontStyleValue), nullptr));
39 }
40 static Ref<CSSFontStyleValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSPrimitiveValue>&& obliqueValue)
41 {
42 return adoptRef(*new CSSFontStyleValue(WTFMove(fontStyleValue), WTFMove(obliqueValue)));
43 }
44
45 String customCSSText() const;
46
47 bool equals(const CSSFontStyleValue&) const;
48
49 bool isItalicOrOblique() const
50 {
51 if (!obliqueValue) {
52 auto valueID = fontStyleValue->valueID();
53 return valueID == CSSValueItalic || valueID == CSSValueOblique;
54 }
55 return obliqueValue->value<float>(CSSUnitType::CSS_DEG) >= static_cast<float>(italicValue());
56 }
57
58 Ref<CSSPrimitiveValue> fontStyleValue;
59 RefPtr<CSSPrimitiveValue> obliqueValue;
60
61private:
62 CSSFontStyleValue(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSPrimitiveValue>&& obliqueValue)
63 : CSSValue(FontStyleClass)
64 , fontStyleValue(WTFMove(fontStyleValue))
65 , obliqueValue(WTFMove(obliqueValue))
66 {
67 }
68};
69
70}
71
72SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontStyleValue, isFontStyleValue())
Note: See TracBrowser for help on using the repository browser.