haikuwebkit/Source/WebCore/css/CSSToLengthConversionData.h

103 lines
4.4 KiB
C
Raw Permalink Normal View History

Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
#include "CSSPropertyNames.h"
Remove <wtf/Optional.h> https://bugs.webkit.org/show_bug.cgi?id=226437 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Remove include of <wtf/Optional.h>. * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: (CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): Don't generate an include of wtf/Optional.h; including WTFString.h takes care of this anyway. * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: (CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator.generate_output): Generate an include of <optional> instead of <wtf/Optional.h>. * inspector/scripts/tests/expected/*: Regenerate. Source/WebCore: * <many files>: Removed include of <wtf/Optional.h>. * platform/graphics/Font.h: Tweaked style a bit. * Modules/geolocation/GeolocationClient.h: Added include of <optional>. * Modules/mediastream/DoubleRange.h: Ditto. * Modules/mediastream/LongRange.h: Ditto. * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Ditto. * css/CSSToLengthConversionData.h: Ditto. * css/DOMMatrix2DInit.h: Ditto. * dom/AddEventListenerOptions.h: Ditto. * dom/DeviceMotionData.h: Ditto. * dom/DeviceOrientationData.h: Ditto. * dom/SuccessOr.h: Ditto. * html/DateTimeFieldsState.h: Ditto. * html/ImageBitmapOptions.h: Ditto. * html/canvas/PredefinedColorSpace.h: Ditto. * layout/LayoutPhase.h: Ditto. * layout/MarginTypes.h: Ditto. * loader/ResourceLoadNotifier.h: Ditto. * page/RuntimeEnabledFeatures.h: Ditto. * page/ScrollOptions.h: Ditto. * platform/MediaCapabilitiesInfo.h: Ditto. * platform/cocoa/SystemBattery.h: Ditto. * platform/graphics/DecodingOptions.h: Ditto. * platform/graphics/DestinationColorSpace.h: Ditto. * platform/graphics/DisplayRefreshMonitorClient.h: Ditto. * platform/graphics/FloatLine.h: Ditto. * platform/graphics/gpu/GPURequestAdapterOptions.h: Ditto. * platform/graphics/x11/PlatformDisplayX11.h: Ditto. * platform/ios/SelectionGeometry.h: Ditto. * platform/mac/NSScrollerImpDetails.h: Ditto. * platform/network/DNS.h: Ditto. * platform/text/EncodingTables.h: Ditto. * platform/text/TextCodecCJK.h: Ditto. * platform/text/TextCodecUTF16.h: Ditto. * platform/text/TextFlags.h: Ditto. Source/WebCore/PAL: * pal/SessionID.h: Include <optional>. * pal/crypto/gcrypt/Utilities.h: Ditto. * pal/crypto/tasn1/Utilities.cpp: Removed include of <wtf/Optional.h>. Source/WebDriver: * SessionHost.h: Removed include of <wtf/Optional.h>. Source/WebKit: * <many files>: Removed include of <wtf/Optional.h>. Source/WebKitLegacy/mac: * DOM/DOMRangeInternal.h: Added import of <optional>. * WebView/WebGeolocationPosition.mm: Removed import of <wtf/Optional.h>. * WebView/WebGeolocationPositionInternal.h: Added import of <optional>. Source/WTF: * <many files>: Removed include of <wtf/Optional.h>. * WTF.xcodeproj/project.pbxproj: Removed Optional.h. * wtf/Markable.h: Added include of <optional>. * wtf/OptionSet.h: Ditto. * wtf/Optional.h: Emptied this file. On the Windows build system, we can't seem to build successfully without an empty file here. The copied forwarding header seems to linger even if we remove the original. Until we fix the Windows build system, if we want to support incremental builds, we need to keep this empty file around. * wtf/PrintStream.h: Added include of <optional>. * wtf/Seconds.h: Ditto. * wtf/StackTrace.h: Ditto. * wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h. Re-sorted the "using" at the bottom of the file. * wtf/URLHelpers.h: Added include of <optional>. * wtf/Vector.h: Ditto. Tools: * <many files>: Removed include of <wtf/Optional.h>. Canonical link: https://commits.webkit.org/238372@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 06:45:51 +00:00
#include <optional>
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
#include <wtf/Assertions.h>
namespace WebCore {
class RenderStyle;
vw/vh units used as font/line-height values don't scale with the viewport https://bugs.webkit.org/show_bug.cgi?id=87846 Reviewed by Darin Adler. Source/WebCore: This patch moves the resolution of viewport units to style recalc time. Currently viewport units are left unresolved during style recalcs, which leads to many problems with viewport units. Moving the resolution will fix these problems, as well as reduce the plumbing that goes on. This patch touches a lot of files since the valueForLength functions no longer need a RenderView. The interesting changes are in: - CSSToLengthConversionData -> CSSPrimitiveValue: for moving resolution to style recalc time. - Length / LengthFunctions: no longer needs to know about viewport units. - FrameView -> Document -> StyleResolver: for scheduling style recalcs upon resize Note that getComputedStyle will now return pixel values when viewport units are used. This behavior matches Firefox and the css3-cascade spec. This is based on a Blink patch by timloh@chromium.org. Tests: css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html * WebCore.exp.in: Remove RenderView argument to floatValueForLength. * accessibility/atk/WebKitAccessibleInterfaceText.cpp: (getAttributeSetForAccessibilityObject): Remove RenderView argument. * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): Ditto. (WebCore::floatValueForCenterCoordinate): Ditto. * css/BasicShapeFunctions.h: Ditto. * css/CSSCalculationValue.cpp: (WebCore::unitCategory): Remove special handling for viewport units, as they get resolved to pixels. (WebCore::createCSS): Ditto. * css/CSSComputedStyleDeclaration.cpp: (WebCore::positionOffsetValue): Remove RendewView argument. (WebCore::getBorderRadiusCornerValues): Remove handling of viewport units, as they are already resolve to pixels here. (WebCore::getBorderRadiusCornerValue): Remove RenderView argument. (WebCore::getBorderRadiusShorthandValue): Ditto. (WebCore::specifiedValueForGridTrackBreadth): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::specifiedValueForGridTrackSize): Remove RenderView argument. (WebCore::valueForGridTrackList): Ditto. (WebCore::lineHeightFromStyle): Ditto. (WebCore::ComputedStyleExtractor::propertyValue): Ditto. * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): Pass RenderView to CSSToLengthConversionData constructor. (WebCore::CSSRadialGradientValue::createGradient): Ditto. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitCategory): Remove handling of viewport units, as they get resolved to pixels. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::init): Ditto. (WebCore::CSSPrimitiveValue::computeLengthDouble): Resolve viewport units to pixels. (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Remove handling of viewport units, since they get resolved to pixels. (WebCore::CSSPrimitiveValue::viewportPercentageLength): Deleted. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLength): Remove special handling of viewport units, since they get resolved to pixels. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): Ditto. * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor): Caclulate conversion factor for viewport units to pixels. Note this does not set hasViewportUnits on the RenderStyle if computing the font size, because in the font size case, the RenderStyle is the parent's style, not the current renderer's style. (WebCore::CSSToLengthConversionData::viewportHeightFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor): Ditto. * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add RenderView parameter, and make RenderStyle non-const so that hasViewportUnits can be set on the Style.. (WebCore::CSSToLengthConversionData::style): style is now non-const. (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): Handle RenderView argument. * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapFillXPosition): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::CSSToStyleMap::mapFillYPosition): Ditto. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyLength::applyValue): Ditto. (WebCore::ApplyPropertyBorderRadius::applyValue): Ditto. (WebCore::ApplyPropertyComputeLength::applyValue): Ditto. (WebCore::ApplyPropertyFontSize::applyValue): Ditto. (WebCore::ApplyPropertyLineHeight::applyValue): Ditto. (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Ditto. (WebCore::ApplyPropertyWordSpacing::applyValue): Ditto. (WebCore::ApplyPropertyVerticalAlign::applyValue): Ditto. (WebCore::ApplyPropertyTextIndent::applyValue): Ditto. * css/LengthFunctions.cpp: (WebCore::minimumIntValueForLength): Remove RenderView argument. (WebCore::intValueForLength): Remove RenderView argument and roundPecentages. (WebCore::minimumValueForLength): Remove RenderView argument, and special handling of viewport units. (WebCore::valueForLength): Ditto. (WebCore::floatValueForLength): Ditto. (WebCore::floatSizeForLengthSize): Remove RenderView argument. * css/LengthFunctions.h: Ditto. * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::eval): Add RenderView argument for CSSToLengthConversionData constuctor. * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): Change to 0 arg constructor for CSSToLengthConversionData. (WebCore::StyleResolver::State::updateConversionData): In order to get the RenderView, we need to have a valid Element set on the state. Since this means that we need to set the conversion data in more places, move the contruction of conversion data into this helper method. (WebCore::StyleResolver::State::initElement): Make sure conversion data is up to date. (WebCore::StyleResolver::State::initForStyleResolve): Ditto. (WebCore::StyleResolver::State::setStyle): When the style is set, we need to make sure to update the conversion data. (WebCore::StyleResolver::styleForElement): If the style has viewport units, flage the document so that we can make sure to recalc the viewport unit values when the viewport is resized. (WebCore::StyleResolver::pseudoStyleForElement): Ditto. (WebCore::StyleResolver::updateFont): Make sure the font having viewport units updates the style. (WebCore::StyleResolver::convertToIntLength): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::convertToFloatLength): Ditto. (WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits): Invalidate the matched properties cache for styles with viewport units when the viewport is resized. (WebCore::createGridTrackBreadth): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::applyProperty): Ditto. (WebCore::StyleResolver::hasMediaQueriesAffectedByViewportChange): Rename to be less confusing, since it has nothing to do with viewport units. (WebCore::StyleResolver::createFilterOperations): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::affectedByViewportChange): Deleted. (WebCore::StyleResolver::viewportPercentageValue): Deleted. * css/StyleResolver.h: (WebCore::StyleResolver::State::State): C++11 cleanup: 0 -> nullptr. (WebCore::StyleResolver::State::setFontSizeHasViewportUnits): Set if the font size is specified in viewport units. (WebCore::StyleResolver::State::fontSizeHasViewportUnits): Ditto. (WebCore::StyleResolver::State::setStyle): Deleted. * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): Remove handling of viewport units, since they are resolved to pixels. * dom/Document.cpp: (WebCore::Document::Document): Add flag to determine if some style in the document has viewport units. (WebCore::Document::pageSizeAndMarginsInPixels): Remove RenderView argument. (WebCore::Document::updateViewportUnitsOnResize): Mark elements with viewport units for style recalc when the viewport size has changed. * dom/Document.h: (WebCore::Document::setHasStyleWithViewportUnits): Flag to determine if some style in the document has viewport units. (WebCore::Document::hasStyleWithViewportUnits): Ditto. * html/HTMLAreaElement.cpp: (WebCore::HTMLAreaElement::getRegion): Remove RenderView argument. * page/FrameView.cpp: (WebCore::FrameView::layout): When the viewport is resized, call updateViewportUnitsOnResize on the document. * platform/Length.h: (WebCore::Length::isSpecified): Remove handling of viewport units, since they are now resolved to pixels. (WebCore::Length::viewportPercentageLength): Deleted. (WebCore::Length::isViewportPercentage): Deleted. * rendering/ClipPathOperation.h: (WebCore::ShapeClipPathOperation::pathForReferenceRect): Remove RenderView argument. (WebCore::BoxClipPathOperation::pathForReferenceRect): Ditto. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout): Remove handling of viewport units, since they get updated by updateViewportUnitsOnResize when the viewport is resized. (WebCore::RenderBlock::nodeAtPoint): Remove RenderView argument. (WebCore::RenderBlock::lineHeight): Ditto. * rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations): Remove RenderView argument. (WebCore::RenderBox::computeContentAndScrollbarLogicalHeightUsing): Remove handling of viewport units, as they are resolved to pixels. (WebCore::RenderBox::computePercentageLogicalHeight): Ditto. (WebCore::RenderBox::computeReplacedLogicalWidthUsing): Ditto. (WebCore::RenderBox::computeReplacedLogicalHeightUsing): Ditto. (WebCore::RenderBox::hasViewportPercentageLogicalHeight): Deleted. * rendering/RenderBox.h: * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::getBackgroundRoundedRect): Remove RenderView argument. (WebCore::RenderBoxModelObject::calculateFillTileSize): Remove handling of viewport units, as they are resolved to pixels. (WebCore::computeBorderImageSide): Remove RenderView argument. (WebCore::RenderBoxModelObject::paintNinePieceImage): Ditto. (WebCore::RenderBoxModelObject::paintBorder): Ditto. (WebCore::RenderBoxModelObject::paintBoxShadow): Ditto. * rendering/RenderElement.cpp: (WebCore::RenderElement::repaintAfterLayoutIfNeeded): Ditto. * rendering/RenderElement.h: (WebCore::RenderElement::valueForLength): Remove unused roundPercentages argument. (WebCore::RenderElement::minimumValueForLength): Remove unused RoundPercentages and RenderView arguments. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::layoutGridItems): Remove handling of viewport units as they are resolved to pixels. * rendering/RenderInline.cpp: (WebCore::computeMargin): Ditto. (WebCore::RenderInline::lineHeight): Remove RenderView argument. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::setupClipPath): Ditto. * rendering/RenderLineBreak.cpp: (WebCore::RenderLineBreak::lineHeight): Ditto. * rendering/RenderScrollbarPart.cpp: (WebCore::calcScrollbarThicknessUsing): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarWidth): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarHeight): Ditto. * rendering/RenderTable.cpp: (WebCore::RenderTable::convertStyleLogicalHeightToComputedHeight): Remove handling of viewport units, since they are resolved to pixels. (WebCore::RenderTable::computePreferredLogicalWidths): Now that viewport unit values are resolved to pixels at style recalc time, no special checking is needed to handle them, so update the comment to reflect that. * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): Add RenderView argument to CSSToLengthConversionData constructor. (WebCore::RenderThemeIOS::adjustButtonStyle): Ditto. * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::paintMenuListButtonGradients): Remove RenderView argument. * rendering/RenderView.cpp: (WebCore::RenderView::layout): Remove handling of viewport units, since they are resolved to pixels. * rendering/RootInlineBox.cpp: (WebCore::RootInlineBox::ascentAndDescentForBox): Remove RenderView argument. * rendering/shapes/Shape.cpp: (WebCore::Shape::createShape): Remove RenderView argument. * rendering/shapes/Shape.h: * rendering/shapes/ShapeOutsideInfo.cpp: (WebCore::ShapeOutsideInfo::computedShape): Ditto. * rendering/style/BasicShapes.cpp: (WebCore::BasicShapeCircle::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeCircle::path): Ditto. (WebCore::BasicShapeEllipse::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeEllipse::path): Ditto. (WebCore::BasicShapePolygon::path): Ditto. (WebCore::floatSizeForLengthSize): Ditto. (WebCore::BasicShapeInset::path): Ditto. * rendering/style/BasicShapes.h: * rendering/style/RenderStyle.cpp: (WebCore::calcRadiiFor): Ditto. (WebCore::RenderStyle::getRoundedBorderFor): Ditto. (WebCore::RenderStyle::computedLineHeight): Remove handling of viewport units since they are resolved to pixels. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setHasViewportUnits): Set if this style has a property set with viewport units. (WebCore::RenderStyle::hasViewportUnits): Ditto. * rendering/svg/RenderSVGRoot.cpp: (WebCore::resolveLengthAttributeForSVG): Remove RenderView argument. (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Ditto. (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto. * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::prepareToRenderSVGContent): Ditto. LayoutTests: Update existing tests to work with the proper behavior of viewport units. Add tests for some of the things fixed by this patch: handling of viewport units in font sizes, with calc, and when the viewport is resized without a reload. The anonymous block and percent size child tests make sure that the viewport unit updates still work properly when there is another relative unit the depends on the size specified in viewport units. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: * css3/viewport-percentage-lengths/resources/resize-test.js: Added. (resizeTest): (standardResizeTest): * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added. * fast/canvas/draw-focus-if-needed-expected.txt: Removed. * fast/canvas/draw-focus-if-needed.html: Removed. * fast/masking/parsing-clip-path-shape-expected.txt: * fast/masking/parsing-clip-path-shape.html: * fast/shapes/parsing/parsing-shape-lengths-expected.txt: * fast/shapes/parsing/parsing-shape-lengths.html: Canonical link: https://commits.webkit.org/151360@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-28 01:33:26 +00:00
class RenderView;
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
class CSSToLengthConversionData {
public:
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, float zoom, std::optional<CSSPropertyID> propertyToCompute = std::nullopt, RenderStyle* viewportDependencyDetectionStyle = nullptr)
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
: m_style(style)
, m_rootStyle(rootStyle)
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
, m_parentStyle(parentStyle)
font-size with viewport units in calc() doesn't change when viewport resizes https://bugs.webkit.org/show_bug.cgi?id=224614 Reviewed by Zalan Bujtas. Source/WebCore: * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::zoom const): Updated since m_zoom is now optional. We use effectiveZoom when m_zoom is not specified, which is the same semantic that was implemented before with a separate boolean. (WebCore::CSSToLengthConversionData::viewportWidthFactor const): When calling the setHasViewportUnits function as a side effect, use m_viewportDependencyDetectionStyle, rather than always using m_style. This lets us handle the font-size case correctly. Also removed the explicit computingFontSize check for the same reason. (WebCore::CSSToLengthConversionData::viewportHeightFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor const): Ditto. * css/CSSToLengthConversionData.h: Added a new member, m_viewportDependencyDetectionStyle, which defaults to the same value as m_style. Also changed m_zoom to use Optional instead of a separate boolean and an ignored "must be 1.0" value. Initialized data members in the modern way, allowing us to use the default constructor. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): Pass in the builder's style as the viewportDependencyDetectionStyle. This does the same thing that the existing code to call setHasViewportUnits did directly, but does it even for more complex cases involving calc(). Also made the isLength and isCalculatedPercentageWithLength cases more similar to each other and left a FIXME behind about taking that a bit further, but doing that probably requires creating some more test cases. LayoutTests: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added tests that involve calc, and broke rules up into multiple elements so that side effects from one style won't give us false negatives. This now has a subtest that was failing without the fix in this patch. Canonical link: https://commits.webkit.org/236669@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-17 01:08:45 +00:00
, m_viewportDependencyDetectionStyle(viewportDependencyDetectionStyle ? viewportDependencyDetectionStyle : const_cast<RenderStyle*>(style))
vw/vh units used as font/line-height values don't scale with the viewport https://bugs.webkit.org/show_bug.cgi?id=87846 Reviewed by Darin Adler. Source/WebCore: This patch moves the resolution of viewport units to style recalc time. Currently viewport units are left unresolved during style recalcs, which leads to many problems with viewport units. Moving the resolution will fix these problems, as well as reduce the plumbing that goes on. This patch touches a lot of files since the valueForLength functions no longer need a RenderView. The interesting changes are in: - CSSToLengthConversionData -> CSSPrimitiveValue: for moving resolution to style recalc time. - Length / LengthFunctions: no longer needs to know about viewport units. - FrameView -> Document -> StyleResolver: for scheduling style recalcs upon resize Note that getComputedStyle will now return pixel values when viewport units are used. This behavior matches Firefox and the css3-cascade spec. This is based on a Blink patch by timloh@chromium.org. Tests: css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html * WebCore.exp.in: Remove RenderView argument to floatValueForLength. * accessibility/atk/WebKitAccessibleInterfaceText.cpp: (getAttributeSetForAccessibilityObject): Remove RenderView argument. * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): Ditto. (WebCore::floatValueForCenterCoordinate): Ditto. * css/BasicShapeFunctions.h: Ditto. * css/CSSCalculationValue.cpp: (WebCore::unitCategory): Remove special handling for viewport units, as they get resolved to pixels. (WebCore::createCSS): Ditto. * css/CSSComputedStyleDeclaration.cpp: (WebCore::positionOffsetValue): Remove RendewView argument. (WebCore::getBorderRadiusCornerValues): Remove handling of viewport units, as they are already resolve to pixels here. (WebCore::getBorderRadiusCornerValue): Remove RenderView argument. (WebCore::getBorderRadiusShorthandValue): Ditto. (WebCore::specifiedValueForGridTrackBreadth): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::specifiedValueForGridTrackSize): Remove RenderView argument. (WebCore::valueForGridTrackList): Ditto. (WebCore::lineHeightFromStyle): Ditto. (WebCore::ComputedStyleExtractor::propertyValue): Ditto. * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): Pass RenderView to CSSToLengthConversionData constructor. (WebCore::CSSRadialGradientValue::createGradient): Ditto. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitCategory): Remove handling of viewport units, as they get resolved to pixels. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::init): Ditto. (WebCore::CSSPrimitiveValue::computeLengthDouble): Resolve viewport units to pixels. (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Remove handling of viewport units, since they get resolved to pixels. (WebCore::CSSPrimitiveValue::viewportPercentageLength): Deleted. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLength): Remove special handling of viewport units, since they get resolved to pixels. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): Ditto. * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor): Caclulate conversion factor for viewport units to pixels. Note this does not set hasViewportUnits on the RenderStyle if computing the font size, because in the font size case, the RenderStyle is the parent's style, not the current renderer's style. (WebCore::CSSToLengthConversionData::viewportHeightFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor): Ditto. * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add RenderView parameter, and make RenderStyle non-const so that hasViewportUnits can be set on the Style.. (WebCore::CSSToLengthConversionData::style): style is now non-const. (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): Handle RenderView argument. * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapFillXPosition): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::CSSToStyleMap::mapFillYPosition): Ditto. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyLength::applyValue): Ditto. (WebCore::ApplyPropertyBorderRadius::applyValue): Ditto. (WebCore::ApplyPropertyComputeLength::applyValue): Ditto. (WebCore::ApplyPropertyFontSize::applyValue): Ditto. (WebCore::ApplyPropertyLineHeight::applyValue): Ditto. (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Ditto. (WebCore::ApplyPropertyWordSpacing::applyValue): Ditto. (WebCore::ApplyPropertyVerticalAlign::applyValue): Ditto. (WebCore::ApplyPropertyTextIndent::applyValue): Ditto. * css/LengthFunctions.cpp: (WebCore::minimumIntValueForLength): Remove RenderView argument. (WebCore::intValueForLength): Remove RenderView argument and roundPecentages. (WebCore::minimumValueForLength): Remove RenderView argument, and special handling of viewport units. (WebCore::valueForLength): Ditto. (WebCore::floatValueForLength): Ditto. (WebCore::floatSizeForLengthSize): Remove RenderView argument. * css/LengthFunctions.h: Ditto. * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::eval): Add RenderView argument for CSSToLengthConversionData constuctor. * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): Change to 0 arg constructor for CSSToLengthConversionData. (WebCore::StyleResolver::State::updateConversionData): In order to get the RenderView, we need to have a valid Element set on the state. Since this means that we need to set the conversion data in more places, move the contruction of conversion data into this helper method. (WebCore::StyleResolver::State::initElement): Make sure conversion data is up to date. (WebCore::StyleResolver::State::initForStyleResolve): Ditto. (WebCore::StyleResolver::State::setStyle): When the style is set, we need to make sure to update the conversion data. (WebCore::StyleResolver::styleForElement): If the style has viewport units, flage the document so that we can make sure to recalc the viewport unit values when the viewport is resized. (WebCore::StyleResolver::pseudoStyleForElement): Ditto. (WebCore::StyleResolver::updateFont): Make sure the font having viewport units updates the style. (WebCore::StyleResolver::convertToIntLength): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::convertToFloatLength): Ditto. (WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits): Invalidate the matched properties cache for styles with viewport units when the viewport is resized. (WebCore::createGridTrackBreadth): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::applyProperty): Ditto. (WebCore::StyleResolver::hasMediaQueriesAffectedByViewportChange): Rename to be less confusing, since it has nothing to do with viewport units. (WebCore::StyleResolver::createFilterOperations): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::affectedByViewportChange): Deleted. (WebCore::StyleResolver::viewportPercentageValue): Deleted. * css/StyleResolver.h: (WebCore::StyleResolver::State::State): C++11 cleanup: 0 -> nullptr. (WebCore::StyleResolver::State::setFontSizeHasViewportUnits): Set if the font size is specified in viewport units. (WebCore::StyleResolver::State::fontSizeHasViewportUnits): Ditto. (WebCore::StyleResolver::State::setStyle): Deleted. * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): Remove handling of viewport units, since they are resolved to pixels. * dom/Document.cpp: (WebCore::Document::Document): Add flag to determine if some style in the document has viewport units. (WebCore::Document::pageSizeAndMarginsInPixels): Remove RenderView argument. (WebCore::Document::updateViewportUnitsOnResize): Mark elements with viewport units for style recalc when the viewport size has changed. * dom/Document.h: (WebCore::Document::setHasStyleWithViewportUnits): Flag to determine if some style in the document has viewport units. (WebCore::Document::hasStyleWithViewportUnits): Ditto. * html/HTMLAreaElement.cpp: (WebCore::HTMLAreaElement::getRegion): Remove RenderView argument. * page/FrameView.cpp: (WebCore::FrameView::layout): When the viewport is resized, call updateViewportUnitsOnResize on the document. * platform/Length.h: (WebCore::Length::isSpecified): Remove handling of viewport units, since they are now resolved to pixels. (WebCore::Length::viewportPercentageLength): Deleted. (WebCore::Length::isViewportPercentage): Deleted. * rendering/ClipPathOperation.h: (WebCore::ShapeClipPathOperation::pathForReferenceRect): Remove RenderView argument. (WebCore::BoxClipPathOperation::pathForReferenceRect): Ditto. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout): Remove handling of viewport units, since they get updated by updateViewportUnitsOnResize when the viewport is resized. (WebCore::RenderBlock::nodeAtPoint): Remove RenderView argument. (WebCore::RenderBlock::lineHeight): Ditto. * rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations): Remove RenderView argument. (WebCore::RenderBox::computeContentAndScrollbarLogicalHeightUsing): Remove handling of viewport units, as they are resolved to pixels. (WebCore::RenderBox::computePercentageLogicalHeight): Ditto. (WebCore::RenderBox::computeReplacedLogicalWidthUsing): Ditto. (WebCore::RenderBox::computeReplacedLogicalHeightUsing): Ditto. (WebCore::RenderBox::hasViewportPercentageLogicalHeight): Deleted. * rendering/RenderBox.h: * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::getBackgroundRoundedRect): Remove RenderView argument. (WebCore::RenderBoxModelObject::calculateFillTileSize): Remove handling of viewport units, as they are resolved to pixels. (WebCore::computeBorderImageSide): Remove RenderView argument. (WebCore::RenderBoxModelObject::paintNinePieceImage): Ditto. (WebCore::RenderBoxModelObject::paintBorder): Ditto. (WebCore::RenderBoxModelObject::paintBoxShadow): Ditto. * rendering/RenderElement.cpp: (WebCore::RenderElement::repaintAfterLayoutIfNeeded): Ditto. * rendering/RenderElement.h: (WebCore::RenderElement::valueForLength): Remove unused roundPercentages argument. (WebCore::RenderElement::minimumValueForLength): Remove unused RoundPercentages and RenderView arguments. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::layoutGridItems): Remove handling of viewport units as they are resolved to pixels. * rendering/RenderInline.cpp: (WebCore::computeMargin): Ditto. (WebCore::RenderInline::lineHeight): Remove RenderView argument. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::setupClipPath): Ditto. * rendering/RenderLineBreak.cpp: (WebCore::RenderLineBreak::lineHeight): Ditto. * rendering/RenderScrollbarPart.cpp: (WebCore::calcScrollbarThicknessUsing): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarWidth): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarHeight): Ditto. * rendering/RenderTable.cpp: (WebCore::RenderTable::convertStyleLogicalHeightToComputedHeight): Remove handling of viewport units, since they are resolved to pixels. (WebCore::RenderTable::computePreferredLogicalWidths): Now that viewport unit values are resolved to pixels at style recalc time, no special checking is needed to handle them, so update the comment to reflect that. * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): Add RenderView argument to CSSToLengthConversionData constructor. (WebCore::RenderThemeIOS::adjustButtonStyle): Ditto. * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::paintMenuListButtonGradients): Remove RenderView argument. * rendering/RenderView.cpp: (WebCore::RenderView::layout): Remove handling of viewport units, since they are resolved to pixels. * rendering/RootInlineBox.cpp: (WebCore::RootInlineBox::ascentAndDescentForBox): Remove RenderView argument. * rendering/shapes/Shape.cpp: (WebCore::Shape::createShape): Remove RenderView argument. * rendering/shapes/Shape.h: * rendering/shapes/ShapeOutsideInfo.cpp: (WebCore::ShapeOutsideInfo::computedShape): Ditto. * rendering/style/BasicShapes.cpp: (WebCore::BasicShapeCircle::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeCircle::path): Ditto. (WebCore::BasicShapeEllipse::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeEllipse::path): Ditto. (WebCore::BasicShapePolygon::path): Ditto. (WebCore::floatSizeForLengthSize): Ditto. (WebCore::BasicShapeInset::path): Ditto. * rendering/style/BasicShapes.h: * rendering/style/RenderStyle.cpp: (WebCore::calcRadiiFor): Ditto. (WebCore::RenderStyle::getRoundedBorderFor): Ditto. (WebCore::RenderStyle::computedLineHeight): Remove handling of viewport units since they are resolved to pixels. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setHasViewportUnits): Set if this style has a property set with viewport units. (WebCore::RenderStyle::hasViewportUnits): Ditto. * rendering/svg/RenderSVGRoot.cpp: (WebCore::resolveLengthAttributeForSVG): Remove RenderView argument. (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Ditto. (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto. * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::prepareToRenderSVGContent): Ditto. LayoutTests: Update existing tests to work with the proper behavior of viewport units. Add tests for some of the things fixed by this patch: handling of viewport units in font sizes, with calc, and when the viewport is resized without a reload. The anonymous block and percent size child tests make sure that the viewport unit updates still work properly when there is another relative unit the depends on the size specified in viewport units. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: * css3/viewport-percentage-lengths/resources/resize-test.js: Added. (resizeTest): (standardResizeTest): * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added. * fast/canvas/draw-focus-if-needed-expected.txt: Removed. * fast/canvas/draw-focus-if-needed.html: Removed. * fast/masking/parsing-clip-path-shape-expected.txt: * fast/masking/parsing-clip-path-shape.html: * fast/shapes/parsing/parsing-shape-lengths-expected.txt: * fast/shapes/parsing/parsing-shape-lengths.html: Canonical link: https://commits.webkit.org/151360@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-28 01:33:26 +00:00
, m_renderView(renderView)
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
, m_zoom(zoom)
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
, m_propertyToCompute(propertyToCompute)
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
{
ASSERT(zoom > 0);
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
CSSToLengthConversionData(const RenderStyle* style, const RenderStyle* rootStyle, const RenderStyle* parentStyle, const RenderView* renderView, std::optional<CSSPropertyID> propertyToCompute = std::nullopt)
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
: m_style(style)
, m_rootStyle(rootStyle)
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
, m_parentStyle(parentStyle)
font-size with viewport units in calc() doesn't change when viewport resizes https://bugs.webkit.org/show_bug.cgi?id=224614 Reviewed by Zalan Bujtas. Source/WebCore: * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::zoom const): Updated since m_zoom is now optional. We use effectiveZoom when m_zoom is not specified, which is the same semantic that was implemented before with a separate boolean. (WebCore::CSSToLengthConversionData::viewportWidthFactor const): When calling the setHasViewportUnits function as a side effect, use m_viewportDependencyDetectionStyle, rather than always using m_style. This lets us handle the font-size case correctly. Also removed the explicit computingFontSize check for the same reason. (WebCore::CSSToLengthConversionData::viewportHeightFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor const): Ditto. * css/CSSToLengthConversionData.h: Added a new member, m_viewportDependencyDetectionStyle, which defaults to the same value as m_style. Also changed m_zoom to use Optional instead of a separate boolean and an ignored "must be 1.0" value. Initialized data members in the modern way, allowing us to use the default constructor. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): Pass in the builder's style as the viewportDependencyDetectionStyle. This does the same thing that the existing code to call setHasViewportUnits did directly, but does it even for more complex cases involving calc(). Also made the isLength and isCalculatedPercentageWithLength cases more similar to each other and left a FIXME behind about taking that a bit further, but doing that probably requires creating some more test cases. LayoutTests: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added tests that involve calc, and broke rules up into multiple elements so that side effects from one style won't give us false negatives. This now has a subtest that was failing without the fix in this patch. Canonical link: https://commits.webkit.org/236669@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-17 01:08:45 +00:00
, m_viewportDependencyDetectionStyle(const_cast<RenderStyle*>(style))
vw/vh units used as font/line-height values don't scale with the viewport https://bugs.webkit.org/show_bug.cgi?id=87846 Reviewed by Darin Adler. Source/WebCore: This patch moves the resolution of viewport units to style recalc time. Currently viewport units are left unresolved during style recalcs, which leads to many problems with viewport units. Moving the resolution will fix these problems, as well as reduce the plumbing that goes on. This patch touches a lot of files since the valueForLength functions no longer need a RenderView. The interesting changes are in: - CSSToLengthConversionData -> CSSPrimitiveValue: for moving resolution to style recalc time. - Length / LengthFunctions: no longer needs to know about viewport units. - FrameView -> Document -> StyleResolver: for scheduling style recalcs upon resize Note that getComputedStyle will now return pixel values when viewport units are used. This behavior matches Firefox and the css3-cascade spec. This is based on a Blink patch by timloh@chromium.org. Tests: css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html * WebCore.exp.in: Remove RenderView argument to floatValueForLength. * accessibility/atk/WebKitAccessibleInterfaceText.cpp: (getAttributeSetForAccessibilityObject): Remove RenderView argument. * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): Ditto. (WebCore::floatValueForCenterCoordinate): Ditto. * css/BasicShapeFunctions.h: Ditto. * css/CSSCalculationValue.cpp: (WebCore::unitCategory): Remove special handling for viewport units, as they get resolved to pixels. (WebCore::createCSS): Ditto. * css/CSSComputedStyleDeclaration.cpp: (WebCore::positionOffsetValue): Remove RendewView argument. (WebCore::getBorderRadiusCornerValues): Remove handling of viewport units, as they are already resolve to pixels here. (WebCore::getBorderRadiusCornerValue): Remove RenderView argument. (WebCore::getBorderRadiusShorthandValue): Ditto. (WebCore::specifiedValueForGridTrackBreadth): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::specifiedValueForGridTrackSize): Remove RenderView argument. (WebCore::valueForGridTrackList): Ditto. (WebCore::lineHeightFromStyle): Ditto. (WebCore::ComputedStyleExtractor::propertyValue): Ditto. * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): Pass RenderView to CSSToLengthConversionData constructor. (WebCore::CSSRadialGradientValue::createGradient): Ditto. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitCategory): Remove handling of viewport units, as they get resolved to pixels. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::init): Ditto. (WebCore::CSSPrimitiveValue::computeLengthDouble): Resolve viewport units to pixels. (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Remove handling of viewport units, since they get resolved to pixels. (WebCore::CSSPrimitiveValue::viewportPercentageLength): Deleted. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLength): Remove special handling of viewport units, since they get resolved to pixels. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): Ditto. * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor): Caclulate conversion factor for viewport units to pixels. Note this does not set hasViewportUnits on the RenderStyle if computing the font size, because in the font size case, the RenderStyle is the parent's style, not the current renderer's style. (WebCore::CSSToLengthConversionData::viewportHeightFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor): Ditto. * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add RenderView parameter, and make RenderStyle non-const so that hasViewportUnits can be set on the Style.. (WebCore::CSSToLengthConversionData::style): style is now non-const. (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): Handle RenderView argument. * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapFillXPosition): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::CSSToStyleMap::mapFillYPosition): Ditto. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyLength::applyValue): Ditto. (WebCore::ApplyPropertyBorderRadius::applyValue): Ditto. (WebCore::ApplyPropertyComputeLength::applyValue): Ditto. (WebCore::ApplyPropertyFontSize::applyValue): Ditto. (WebCore::ApplyPropertyLineHeight::applyValue): Ditto. (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Ditto. (WebCore::ApplyPropertyWordSpacing::applyValue): Ditto. (WebCore::ApplyPropertyVerticalAlign::applyValue): Ditto. (WebCore::ApplyPropertyTextIndent::applyValue): Ditto. * css/LengthFunctions.cpp: (WebCore::minimumIntValueForLength): Remove RenderView argument. (WebCore::intValueForLength): Remove RenderView argument and roundPecentages. (WebCore::minimumValueForLength): Remove RenderView argument, and special handling of viewport units. (WebCore::valueForLength): Ditto. (WebCore::floatValueForLength): Ditto. (WebCore::floatSizeForLengthSize): Remove RenderView argument. * css/LengthFunctions.h: Ditto. * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::eval): Add RenderView argument for CSSToLengthConversionData constuctor. * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): Change to 0 arg constructor for CSSToLengthConversionData. (WebCore::StyleResolver::State::updateConversionData): In order to get the RenderView, we need to have a valid Element set on the state. Since this means that we need to set the conversion data in more places, move the contruction of conversion data into this helper method. (WebCore::StyleResolver::State::initElement): Make sure conversion data is up to date. (WebCore::StyleResolver::State::initForStyleResolve): Ditto. (WebCore::StyleResolver::State::setStyle): When the style is set, we need to make sure to update the conversion data. (WebCore::StyleResolver::styleForElement): If the style has viewport units, flage the document so that we can make sure to recalc the viewport unit values when the viewport is resized. (WebCore::StyleResolver::pseudoStyleForElement): Ditto. (WebCore::StyleResolver::updateFont): Make sure the font having viewport units updates the style. (WebCore::StyleResolver::convertToIntLength): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::convertToFloatLength): Ditto. (WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits): Invalidate the matched properties cache for styles with viewport units when the viewport is resized. (WebCore::createGridTrackBreadth): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::applyProperty): Ditto. (WebCore::StyleResolver::hasMediaQueriesAffectedByViewportChange): Rename to be less confusing, since it has nothing to do with viewport units. (WebCore::StyleResolver::createFilterOperations): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::affectedByViewportChange): Deleted. (WebCore::StyleResolver::viewportPercentageValue): Deleted. * css/StyleResolver.h: (WebCore::StyleResolver::State::State): C++11 cleanup: 0 -> nullptr. (WebCore::StyleResolver::State::setFontSizeHasViewportUnits): Set if the font size is specified in viewport units. (WebCore::StyleResolver::State::fontSizeHasViewportUnits): Ditto. (WebCore::StyleResolver::State::setStyle): Deleted. * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): Remove handling of viewport units, since they are resolved to pixels. * dom/Document.cpp: (WebCore::Document::Document): Add flag to determine if some style in the document has viewport units. (WebCore::Document::pageSizeAndMarginsInPixels): Remove RenderView argument. (WebCore::Document::updateViewportUnitsOnResize): Mark elements with viewport units for style recalc when the viewport size has changed. * dom/Document.h: (WebCore::Document::setHasStyleWithViewportUnits): Flag to determine if some style in the document has viewport units. (WebCore::Document::hasStyleWithViewportUnits): Ditto. * html/HTMLAreaElement.cpp: (WebCore::HTMLAreaElement::getRegion): Remove RenderView argument. * page/FrameView.cpp: (WebCore::FrameView::layout): When the viewport is resized, call updateViewportUnitsOnResize on the document. * platform/Length.h: (WebCore::Length::isSpecified): Remove handling of viewport units, since they are now resolved to pixels. (WebCore::Length::viewportPercentageLength): Deleted. (WebCore::Length::isViewportPercentage): Deleted. * rendering/ClipPathOperation.h: (WebCore::ShapeClipPathOperation::pathForReferenceRect): Remove RenderView argument. (WebCore::BoxClipPathOperation::pathForReferenceRect): Ditto. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout): Remove handling of viewport units, since they get updated by updateViewportUnitsOnResize when the viewport is resized. (WebCore::RenderBlock::nodeAtPoint): Remove RenderView argument. (WebCore::RenderBlock::lineHeight): Ditto. * rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations): Remove RenderView argument. (WebCore::RenderBox::computeContentAndScrollbarLogicalHeightUsing): Remove handling of viewport units, as they are resolved to pixels. (WebCore::RenderBox::computePercentageLogicalHeight): Ditto. (WebCore::RenderBox::computeReplacedLogicalWidthUsing): Ditto. (WebCore::RenderBox::computeReplacedLogicalHeightUsing): Ditto. (WebCore::RenderBox::hasViewportPercentageLogicalHeight): Deleted. * rendering/RenderBox.h: * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::getBackgroundRoundedRect): Remove RenderView argument. (WebCore::RenderBoxModelObject::calculateFillTileSize): Remove handling of viewport units, as they are resolved to pixels. (WebCore::computeBorderImageSide): Remove RenderView argument. (WebCore::RenderBoxModelObject::paintNinePieceImage): Ditto. (WebCore::RenderBoxModelObject::paintBorder): Ditto. (WebCore::RenderBoxModelObject::paintBoxShadow): Ditto. * rendering/RenderElement.cpp: (WebCore::RenderElement::repaintAfterLayoutIfNeeded): Ditto. * rendering/RenderElement.h: (WebCore::RenderElement::valueForLength): Remove unused roundPercentages argument. (WebCore::RenderElement::minimumValueForLength): Remove unused RoundPercentages and RenderView arguments. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::layoutGridItems): Remove handling of viewport units as they are resolved to pixels. * rendering/RenderInline.cpp: (WebCore::computeMargin): Ditto. (WebCore::RenderInline::lineHeight): Remove RenderView argument. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::setupClipPath): Ditto. * rendering/RenderLineBreak.cpp: (WebCore::RenderLineBreak::lineHeight): Ditto. * rendering/RenderScrollbarPart.cpp: (WebCore::calcScrollbarThicknessUsing): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarWidth): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarHeight): Ditto. * rendering/RenderTable.cpp: (WebCore::RenderTable::convertStyleLogicalHeightToComputedHeight): Remove handling of viewport units, since they are resolved to pixels. (WebCore::RenderTable::computePreferredLogicalWidths): Now that viewport unit values are resolved to pixels at style recalc time, no special checking is needed to handle them, so update the comment to reflect that. * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): Add RenderView argument to CSSToLengthConversionData constructor. (WebCore::RenderThemeIOS::adjustButtonStyle): Ditto. * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::paintMenuListButtonGradients): Remove RenderView argument. * rendering/RenderView.cpp: (WebCore::RenderView::layout): Remove handling of viewport units, since they are resolved to pixels. * rendering/RootInlineBox.cpp: (WebCore::RootInlineBox::ascentAndDescentForBox): Remove RenderView argument. * rendering/shapes/Shape.cpp: (WebCore::Shape::createShape): Remove RenderView argument. * rendering/shapes/Shape.h: * rendering/shapes/ShapeOutsideInfo.cpp: (WebCore::ShapeOutsideInfo::computedShape): Ditto. * rendering/style/BasicShapes.cpp: (WebCore::BasicShapeCircle::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeCircle::path): Ditto. (WebCore::BasicShapeEllipse::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeEllipse::path): Ditto. (WebCore::BasicShapePolygon::path): Ditto. (WebCore::floatSizeForLengthSize): Ditto. (WebCore::BasicShapeInset::path): Ditto. * rendering/style/BasicShapes.h: * rendering/style/RenderStyle.cpp: (WebCore::calcRadiiFor): Ditto. (WebCore::RenderStyle::getRoundedBorderFor): Ditto. (WebCore::RenderStyle::computedLineHeight): Remove handling of viewport units since they are resolved to pixels. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setHasViewportUnits): Set if this style has a property set with viewport units. (WebCore::RenderStyle::hasViewportUnits): Ditto. * rendering/svg/RenderSVGRoot.cpp: (WebCore::resolveLengthAttributeForSVG): Remove RenderView argument. (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Ditto. (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto. * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::prepareToRenderSVGContent): Ditto. LayoutTests: Update existing tests to work with the proper behavior of viewport units. Add tests for some of the things fixed by this patch: handling of viewport units in font sizes, with calc, and when the viewport is resized without a reload. The anonymous block and percent size child tests make sure that the viewport unit updates still work properly when there is another relative unit the depends on the size specified in viewport units. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: * css3/viewport-percentage-lengths/resources/resize-test.js: Added. (resizeTest): (standardResizeTest): * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added. * fast/canvas/draw-focus-if-needed-expected.txt: Removed. * fast/canvas/draw-focus-if-needed.html: Removed. * fast/masking/parsing-clip-path-shape-expected.txt: * fast/masking/parsing-clip-path-shape.html: * fast/shapes/parsing/parsing-shape-lengths-expected.txt: * fast/shapes/parsing/parsing-shape-lengths.html: Canonical link: https://commits.webkit.org/151360@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-28 01:33:26 +00:00
, m_renderView(renderView)
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
, m_propertyToCompute(propertyToCompute)
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
{
}
font-size with viewport units in calc() doesn't change when viewport resizes https://bugs.webkit.org/show_bug.cgi?id=224614 Reviewed by Zalan Bujtas. Source/WebCore: * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::zoom const): Updated since m_zoom is now optional. We use effectiveZoom when m_zoom is not specified, which is the same semantic that was implemented before with a separate boolean. (WebCore::CSSToLengthConversionData::viewportWidthFactor const): When calling the setHasViewportUnits function as a side effect, use m_viewportDependencyDetectionStyle, rather than always using m_style. This lets us handle the font-size case correctly. Also removed the explicit computingFontSize check for the same reason. (WebCore::CSSToLengthConversionData::viewportHeightFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor const): Ditto. * css/CSSToLengthConversionData.h: Added a new member, m_viewportDependencyDetectionStyle, which defaults to the same value as m_style. Also changed m_zoom to use Optional instead of a separate boolean and an ignored "must be 1.0" value. Initialized data members in the modern way, allowing us to use the default constructor. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): Pass in the builder's style as the viewportDependencyDetectionStyle. This does the same thing that the existing code to call setHasViewportUnits did directly, but does it even for more complex cases involving calc(). Also made the isLength and isCalculatedPercentageWithLength cases more similar to each other and left a FIXME behind about taking that a bit further, but doing that probably requires creating some more test cases. LayoutTests: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added tests that involve calc, and broke rules up into multiple elements so that side effects from one style won't give us false negatives. This now has a subtest that was failing without the fix in this patch. Canonical link: https://commits.webkit.org/236669@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-17 01:08:45 +00:00
CSSToLengthConversionData() = default;
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
RenderElement::style() should return const RenderStyle https://bugs.webkit.org/show_bug.cgi?id=157016 Reviewed by Geoff Garen. Style should be changed via setStyle, not by mutating it directly. Pulling this string turns RenderStyle const in many places. * accessibility/AccessibilityObject.cpp: (WebCore::startOfStyleRange): * accessibility/atk/WebKitAccessibleInterfaceText.cpp: (getAttributeSetForAccessibilityObject): * bindings/objc/DOM.mm: (-[DOMNode innerFrameQuad]): (-[DOMNode computedFontSize]): * css/CSSComputedStyleDeclaration.cpp: (WebCore::createPositionListForLayer): (WebCore::positionOffsetValue): (WebCore::ComputedStyleExtractor::currentColorOrValidColor): (WebCore::getTransitionPropertyValue): (WebCore::scrollSnapDestination): (WebCore::scrollSnapPoints): (WebCore::scrollSnapCoordinates): (WebCore::logUnimplementedPropertyID): (WebCore::fontFamilyFromStyle): (WebCore::lineHeightFromStyle): (WebCore::fontSizeFromStyle): (WebCore::fontStyleFromStyle): (WebCore::fontVariantFromStyle): (WebCore::fontWeightFromStyle): (WebCore::fontSynthesisFromStyle): (WebCore::zoomAdjustedPaddingOrMarginPixelValue): (WebCore::paddingOrMarginIsRendererDependent): (WebCore::convertToRegionBreak): (WebCore::isLayoutDependent): (WebCore::updateStyleIfNeededForNode): (WebCore::computeRenderStyleForProperty): (WebCore::ComputedStyleExtractor::propertyValue): (WebCore::CSSComputedStyleDeclaration::length): (WebCore::CSSComputedStyleDeclaration::item): (WebCore::ComputedStyleExtractor::propertyMatches): * css/CSSComputedStyleDeclaration.h: * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor): (WebCore::CSSToLengthConversionData::viewportHeightFactor): (WebCore::CSSToLengthConversionData::viewportMinFactor): (WebCore::CSSToLengthConversionData::viewportMaxFactor): * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::style): (WebCore::CSSToStyleMap::rootElementStyle): * css/CSSToStyleMap.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::MediaQueryEvaluator): * css/MediaQueryEvaluator.h: * css/SVGCSSComputedStyleDeclaration.cpp: (WebCore::strokeDashArrayToCSSValueList): (WebCore::ComputedStyleExtractor::adjustSVGPaintForCurrentColor): (WebCore::ComputedStyleExtractor::svgPropertyValue): * css/SourceSizeList.cpp: (WebCore::match): (WebCore::defaultLength): (WebCore::computeLength): (WebCore::parseSizesAttribute): * css/StyleBuilderCustom.h: (WebCore::ApplyPropertyBorderImageModifier::applyValue): (WebCore::ApplyPropertyBorderImageModifier::getValue): (WebCore::StyleBuilderCustom::applyInheritClip): (WebCore::StyleBuilderCustom::applyInheritCounter): (WebCore::StyleBuilderCustom::applyValueContent): (WebCore::StyleBuilderCustom::applyValueAlt): * css/StyleResolver.cpp: (WebCore::StyleResolver::sweepMatchedPropertiesCache): (WebCore::StyleResolver::State::State): (WebCore::isAtShadowBoundary): (WebCore::StyleResolver::styleForElement): (WebCore::StyleResolver::keyframeStylesForAnimation): (WebCore::StyleResolver::pseudoStyleForElement): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::checkForTextSizeAdjust): (WebCore::StyleResolver::checkForZoomChange): (WebCore::StyleResolver::checkForGenericFamilyChange): * css/StyleResolver.h: (WebCore::StyleResolver::style): (WebCore::StyleResolver::parentStyle): (WebCore::StyleResolver::rootElementStyle): (WebCore::StyleResolver::element): (WebCore::StyleResolver::document): (WebCore::StyleResolver::documentSettings): (WebCore::StyleResolver::State::State): (WebCore::StyleResolver::State::takeStyle): (WebCore::StyleResolver::State::parentStyle): (WebCore::StyleResolver::State::rootElementStyle): (WebCore::StyleResolver::State::regionForStyling): (WebCore::StyleResolver::State::elementLinkState): * dom/Document.cpp: (WebCore::Document::updateLayoutIgnorePendingStylesheets): (WebCore::Document::styleForElementIgnoringPendingStylesheets): (WebCore::Document::setVisuallyOrdered): (WebCore::Document::createParser): * dom/Document.h: * dom/Element.cpp: (WebCore::Element::styleResolver): (WebCore::Element::resolveStyle): (WebCore::checkForEmptyStyleChange): (WebCore::checkForSiblingStyleChanges): (WebCore::beforeOrAfterPseudoElement): (WebCore::Element::existingComputedStyle): (WebCore::Element::resolveComputedStyle): (WebCore::Element::computedStyle): (WebCore::Element::didDetachRenderers): (WebCore::Element::resolveCustomStyle): * dom/Element.h: * dom/Node.cpp: (WebCore::computeEditabilityFromComputedStyle): (WebCore::Node::pseudoAwareLastChild): (WebCore::Node::computedStyle): * dom/Node.h: * dom/NodeRenderStyle.h: (WebCore::Node::renderStyle): * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): (WebCore::PseudoElement::resolveCustomStyle): * dom/PseudoElement.h: * editing/ApplyBlockElementCommand.cpp: (WebCore::isNewLineAtPosition): (WebCore::ApplyBlockElementCommand::renderStyleOfEnclosingTextNode): (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded): (WebCore::ApplyBlockElementCommand::endOfNextParagraphSplittingTextNodesIfNeeded): * editing/ApplyBlockElementCommand.h: * editing/EditingStyle.cpp: (WebCore::EditingStyle::init): (WebCore::EditingStyle::removeTextFillAndStrokeColorsIfNeeded): * editing/EditingStyle.h: * editing/Editor.h: * editing/SimplifyMarkupCommand.cpp: (WebCore::SimplifyMarkupCommand::doApply): * editing/cocoa/EditorCocoa.mm: (WebCore::Editor::styleForSelectionStart): (WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle): * editing/ios/EditorIOS.mm: (WebCore::Editor::fontForSelection): (WebCore::Editor::fontAttributesForSelectionStart): * editing/mac/EditorMac.mm: (WebCore::Editor::fontForSelection): (WebCore::Editor::fontAttributesForSelectionStart): * html/HTMLTitleElement.cpp: (WebCore::HTMLTitleElement::computedTextWithDirection): * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::FontProxy::fontsNeedUpdate): (WebCore::CanvasRenderingContext2D::FontProxy::initialize): (WebCore::CanvasRenderingContext2D::setFont): (WebCore::CanvasRenderingContext2D::setTextBaseline): (WebCore::CanvasRenderingContext2D::toTextDirection): (WebCore::CanvasRenderingContext2D::drawTextInternal): * html/canvas/CanvasRenderingContext2D.h: * html/parser/HTMLResourcePreloader.cpp: (WebCore::HTMLResourcePreloader::preload): (WebCore::mediaAttributeMatches): * html/shadow/SliderThumbElement.cpp: (WebCore::RenderSliderThumb::RenderSliderThumb): (WebCore::RenderSliderThumb::updateAppearance): (WebCore::RenderSliderContainer::layout): (WebCore::SliderThumbElement::hostInput): (WebCore::SliderThumbElement::resolveCustomStyle): (WebCore::SliderContainerElement::createElementRenderer): (WebCore::SliderContainerElement::resolveCustomStyle): * html/shadow/SliderThumbElement.h: * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::create): (WebCore::TextControlInnerElement::resolveCustomStyle): (WebCore::TextControlInnerTextElement::renderer): (WebCore::TextControlInnerTextElement::resolveCustomStyle): (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): (WebCore::TextControlPlaceholderElement::resolveCustomStyle): * html/shadow/TextControlInnerElements.h: * page/EventHandler.cpp: (WebCore::EventHandler::selectCursor): * page/animation/AnimationBase.cpp: (WebCore::solveStepsFunction): (WebCore::AnimationBase::AnimationBase): * page/animation/AnimationBase.h: (WebCore::AnimationBase::~AnimationBase): (WebCore::AnimationBase::renderer): (WebCore::AnimationBase::animation): (WebCore::AnimationBase::setAnimation): * page/animation/AnimationController.cpp: (WebCore::AnimationController::cancelAnimations): (WebCore::AnimationController::updateAnimations): * page/animation/AnimationController.h: * page/animation/CompositeAnimation.cpp: (WebCore::CompositeAnimation::clearRenderer): (WebCore::CompositeAnimation::updateTransitions): (WebCore::CompositeAnimation::updateKeyframeAnimations): (WebCore::CompositeAnimation::animate): * page/animation/CompositeAnimation.h: * page/animation/ImplicitAnimation.cpp: (WebCore::ImplicitAnimation::ImplicitAnimation): (WebCore::ImplicitAnimation::shouldSendEventForListener): (WebCore::ImplicitAnimation::animate): (WebCore::ImplicitAnimation::sendTransitionEvent): (WebCore::ImplicitAnimation::reset): * page/animation/ImplicitAnimation.h: (WebCore::ImplicitAnimation::create): * page/animation/KeyframeAnimation.cpp: (WebCore::KeyframeAnimation::KeyframeAnimation): (WebCore::KeyframeAnimation::fetchIntervalEndpointsForProperty): (WebCore::KeyframeAnimation::animate): * page/animation/KeyframeAnimation.h: * page/ios/FrameIOS.mm: (WebCore::ancestorRespondingToScrollWheelEvents): * rendering/FlowThreadController.cpp: (WebCore::FlowThreadController::styleDidChange): * rendering/InlineFlowBox.cpp: (WebCore::clipRectForNinePieceImageStrip): * rendering/RenderBlock.cpp: (WebCore::RenderBlock::styleDidChange): (WebCore::RenderBlock::lineHeight): (WebCore::RenderBlock::firstLineBlock): (WebCore::styleForFirstLetter): (WebCore::RenderBlock::updateFirstLetterStyle): (WebCore::RenderBlock::createFirstLetterRenderer): * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::adjustBlockChildForPagination): (WebCore::calculateMinimumPageHeight): (WebCore::RenderBlockFlow::adjustComputedFontSizes): * rendering/RenderBox.cpp: (WebCore::RenderBox::styleDidChange): (WebCore::RenderBox::borderRadii): (WebCore::RenderBox::enclosingFloatPaintingLayer): (WebCore::RenderBox::logicalVisualOverflowRectForPropagation): (WebCore::RenderBox::visualOverflowRectForPropagation): (WebCore::RenderBox::logicalLayoutOverflowRectForPropagation): (WebCore::RenderBox::layoutOverflowRectForPropagation): * rendering/RenderBox.h: (WebCore::RenderBox::applyTopLeftLocationOffset): (WebCore::RenderBox::hasRenderOverflow): (WebCore::RenderBox::hasVisualOverflow): * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance): (WebCore::applyBoxShadowForBackground): * rendering/RenderButton.cpp: (WebCore::RenderButton::addChild): (WebCore::RenderButton::styleWillChange): (WebCore::RenderButton::styleDidChange): (WebCore::RenderButton::setupInnerStyle): (WebCore::RenderButton::layout): * rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::RenderDeprecatedFlexibleBox::styleWillChange): * rendering/RenderElement.cpp: (WebCore::RenderElement::createFor): (WebCore::RenderElement::uncachedFirstLineStyle): (WebCore::RenderElement::cachedFirstLineStyle): (WebCore::RenderElement::firstLineStyle): (WebCore::RenderElement::styleWillChange): (WebCore::RenderElement::addControlStatesForRenderer): (WebCore::RenderElement::getCachedPseudoStyle): (WebCore::RenderElement::getMutableCachedPseudoStyle): (WebCore::RenderElement::getUncachedPseudoStyle): (WebCore::RenderElement::paintOutline): * rendering/RenderElement.h: (WebCore::RenderElement::hasInitializedStyle): (WebCore::RenderElement::style): (WebCore::RenderElement::mutableStyle): (WebCore::RenderElement::element): (WebCore::RenderObject::isRenderInline): (WebCore::RenderObject::style): (WebCore::RenderObject::firstLineStyle): * rendering/RenderEmbeddedObject.cpp: (WebCore::RenderEmbeddedObject::layout): * rendering/RenderFlowThread.cpp: (WebCore::RenderFlowThread::RenderFlowThread): (WebCore::RenderFlowThread::createFlowThreadStyle): * rendering/RenderFlowThread.h: * rendering/RenderImage.cpp: (WebCore::RenderImage::layoutShadowControls): * rendering/RenderInline.cpp: (WebCore::RenderInline::styleDidChange): (WebCore::RenderInline::updateAlwaysCreateLineBoxes): (WebCore::RenderInline::paintOutline): * rendering/RenderLayer.cpp: (WebCore::RenderLayer::setupClipPath): * rendering/RenderListBox.cpp: (WebCore::RenderListBox::paintScrollbar): (WebCore::itemOffsetForAlignment): (WebCore::RenderListBox::paintItemForeground): (WebCore::RenderListBox::paintItemBackground): * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::updateMargins): (WebCore::RenderListMarker::lineHeight): * rendering/RenderMarquee.cpp: (WebCore::RenderMarquee::computePosition): (WebCore::RenderMarquee::updateMarqueeStyle): * rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::adjustInnerStyle): (RenderMenuList::updateOptionsWidth): (RenderMenuList::itemStyle): * rendering/RenderMultiColumnFlowThread.cpp: (WebCore::isValidColumnSpanner): * rendering/RenderMultiColumnSpannerPlaceholder.cpp: (WebCore::RenderMultiColumnSpannerPlaceholder::createAnonymous): * rendering/RenderMultiColumnSpannerPlaceholder.h: * rendering/RenderNamedFlowFragment.cpp: (WebCore::RenderNamedFlowFragment::checkRegionStyle): (WebCore::RenderNamedFlowFragment::computeStyleInRegion): * rendering/RenderNamedFlowFragment.h: * rendering/RenderObject.cpp: (WebCore::RenderObject::innerLineHeight): (WebCore::decorationColor): (WebCore::RenderObject::getTextDecorationColorsAndStyles): * rendering/RenderObject.h: (WebCore::RenderObject::minPreferredLogicalWidth): (WebCore::RenderObject::maxPreferredLogicalWidth): * rendering/RenderTable.cpp: (WebCore::RenderTable::computePreferredLogicalWidths): * rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::paintRowGroupBorderIfRequired): (WebCore::physicalBorderForDirection): * rendering/RenderText.h: (WebCore::RenderText::characterAt): (WebCore::RenderText::style): (WebCore::RenderText::firstLineStyle): (WebCore::RenderText::getCachedPseudoStyle): * rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::styleDidChange): * rendering/RenderTextControlMultiLine.cpp: (WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild): * rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::layout): (WebCore::RenderTextControlSingleLine::styleDidChange): * rendering/RenderTextFragment.cpp: (WebCore::RenderTextFragment::styleDidChange): * rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::paintMediaToggleClosedCaptionsButton): (WebCore::borderRadiiFromStyle): (WebCore::RenderThemeGtk::paintMediaSliderTrack): (WebCore::RenderThemeGtk::paintMediaSliderThumb): (WebCore::RenderThemeGtk::paintMediaVolumeSliderTrack): * rendering/SimpleLineLayoutFunctions.cpp: (WebCore::SimpleLineLayout::paintFlow): (WebCore::SimpleLineLayout::hitTestFlow): * rendering/TextAutoSizing.cpp: (WebCore::TextAutoSizingKey::TextAutoSizingKey): * rendering/TextAutoSizing.h: (WebCore::TextAutoSizingKey::style): (WebCore::TextAutoSizingKey::isDeleted): * rendering/TextPaintStyle.cpp: (WebCore::computeTextSelectionPaintStyle): * rendering/line/BreakingContext.h: * rendering/mathml/RenderMathMLRoot.cpp: (WebCore::RenderMathMLRoot::layout): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setColumnRuleWidth): (WebCore::RenderStyle::resetColumnRule): (WebCore::RenderStyle::setColumnSpan): (WebCore::RenderStyle::inheritColumnPropertiesFrom): (WebCore::RenderStyle::setTransform): (WebCore::RenderStyle::setTransformOriginX): (WebCore::RenderStyle::setTransformOriginY): * rendering/svg/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::positionForOffset): (WebCore::SVGInlineTextBox::selectionRectForTextFragment): (WebCore::SVGInlineTextBox::localSelectionRect): (WebCore::SVGInlineTextBox::paintSelectionBackground): (WebCore::SVGInlineTextBox::paint): (WebCore::SVGInlineTextBox::acquirePaintingResource): (WebCore::SVGInlineTextBox::releasePaintingResource): (WebCore::SVGInlineTextBox::prepareGraphicsContextForTextPainting): (WebCore::SVGInlineTextBox::restoreGraphicsContextAfterTextPainting): (WebCore::SVGInlineTextBox::constructTextRun): (WebCore::SVGInlineTextBox::paintDecorationWithStyle): (WebCore::SVGInlineTextBox::paintTextWithShadows): (WebCore::SVGInlineTextBox::paintText): * rendering/svg/SVGInlineTextBox.h: * rendering/svg/SVGPathData.cpp: (WebCore::updatePathFromCircleElement): (WebCore::updatePathFromEllipseElement): (WebCore::updatePathFromRectElement): * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::prepareToRenderSVGContent): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::Parent::Parent): (WebCore::Style::TreeResolver::popScope): (WebCore::Style::TreeResolver::styleForElement): (WebCore::Style::TreeResolver::pushParent): (WebCore::Style::TreeResolver::resolveComposedTree): * style/StyleTreeResolver.h: (WebCore::Style::TreeResolver::scope): * style/StyleUpdate.cpp: (WebCore::Style::Update::textUpdate): (WebCore::Style::Update::elementStyle): (WebCore::Style::Update::addElement): * style/StyleUpdate.h: (WebCore::Style::Update::document): * svg/SVGElement.cpp: (WebCore::SVGElement::synchronizeSystemLanguage): (WebCore::SVGElement::resolveCustomStyle): (WebCore::SVGElement::setUseOverrideComputedStyle): (WebCore::SVGElement::computedStyle): * svg/SVGElement.h: * svg/SVGElementRareData.h: (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties): (WebCore::SVGElementRareData::overrideComputedStyle): * svg/SVGGraphicsElement.cpp: (WebCore::SVGGraphicsElement::animatedLocalTransform): * svg/SVGLengthContext.cpp: (WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits): (WebCore::renderStyleForLengthResolving): (WebCore::SVGLengthContext::convertValueFromUserUnitsToEMS): (WebCore::SVGLengthContext::convertValueFromEMSToUserUnits): (WebCore::SVGLengthContext::convertValueFromUserUnitsToEXS): (WebCore::SVGLengthContext::convertValueFromEXSToUserUnits): * svg/SVGStopElement.cpp: (WebCore::SVGStopElement::stopColorIncludingOpacity): * svg/SVGTextElement.cpp: (WebCore::SVGTextElement::animatedLocalTransform): Canonical link: https://commits.webkit.org/175153@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200098 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-04-26 18:20:09 +00:00
const RenderStyle* style() const { return m_style; }
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
const RenderStyle* rootStyle() const { return m_rootStyle; }
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
const RenderStyle* parentStyle() const { return m_parentStyle; }
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
float zoom() const;
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
bool computingFontSize() const { return m_propertyToCompute == CSSPropertyFontSize; }
bool computingLineHeight() const { return m_propertyToCompute == CSSPropertyLineHeight; }
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
CSSPropertyID propertyToCompute() const { return m_propertyToCompute.value_or(CSSPropertyInvalid); }
Allow CSS font-styling for canvas without RenderStyle https://bugs.webkit.org/show_bug.cgi?id=222665 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/html/canvas/element/drawing-text-to-the-canvas/2d.text.draw.fontface.notinpage-expected.txt: Now passes Source/WebCore: Refactor CSSPrimitiveValue::computeNonCalcLengthDouble to allow for its use without requiring CSSToLengthConversionData and RenderStyle. No new tests, already covered by existing tests. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::propertyToCompute const): (WebCore::CSSToLengthConversionData::renderView const): * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::setFont): * html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::FontProxy::initialize): * html/canvas/CanvasRenderingContext2DBase.h: * html/canvas/OffscreenCanvasRenderingContext2D.cpp: (WebCore::OffscreenCanvasRenderingContext2D::setFont): * style/StyleFontSizeFunctions.cpp: (WebCore::Style::computedFontSizeFromSpecifiedSize): (WebCore::Style::computedFontSizeFromSpecifiedSizeForSVGInlineText): (WebCore::Style::fontSizeForKeyword): * style/StyleFontSizeFunctions.h: * style/StyleResolveForFontRaw.cpp: (WebCore::Style::resolveForFontRaw): * style/StyleResolveForFontRaw.h: Canonical link: https://commits.webkit.org/234912@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-05 15:05:07 +00:00
const RenderView* renderView() const { return m_renderView; }
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
vw/vh units used as font/line-height values don't scale with the viewport https://bugs.webkit.org/show_bug.cgi?id=87846 Reviewed by Darin Adler. Source/WebCore: This patch moves the resolution of viewport units to style recalc time. Currently viewport units are left unresolved during style recalcs, which leads to many problems with viewport units. Moving the resolution will fix these problems, as well as reduce the plumbing that goes on. This patch touches a lot of files since the valueForLength functions no longer need a RenderView. The interesting changes are in: - CSSToLengthConversionData -> CSSPrimitiveValue: for moving resolution to style recalc time. - Length / LengthFunctions: no longer needs to know about viewport units. - FrameView -> Document -> StyleResolver: for scheduling style recalcs upon resize Note that getComputedStyle will now return pixel values when viewport units are used. This behavior matches Firefox and the css3-cascade spec. This is based on a Blink patch by timloh@chromium.org. Tests: css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html * WebCore.exp.in: Remove RenderView argument to floatValueForLength. * accessibility/atk/WebKitAccessibleInterfaceText.cpp: (getAttributeSetForAccessibilityObject): Remove RenderView argument. * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): Ditto. (WebCore::floatValueForCenterCoordinate): Ditto. * css/BasicShapeFunctions.h: Ditto. * css/CSSCalculationValue.cpp: (WebCore::unitCategory): Remove special handling for viewport units, as they get resolved to pixels. (WebCore::createCSS): Ditto. * css/CSSComputedStyleDeclaration.cpp: (WebCore::positionOffsetValue): Remove RendewView argument. (WebCore::getBorderRadiusCornerValues): Remove handling of viewport units, as they are already resolve to pixels here. (WebCore::getBorderRadiusCornerValue): Remove RenderView argument. (WebCore::getBorderRadiusShorthandValue): Ditto. (WebCore::specifiedValueForGridTrackBreadth): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::specifiedValueForGridTrackSize): Remove RenderView argument. (WebCore::valueForGridTrackList): Ditto. (WebCore::lineHeightFromStyle): Ditto. (WebCore::ComputedStyleExtractor::propertyValue): Ditto. * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): Pass RenderView to CSSToLengthConversionData constructor. (WebCore::CSSRadialGradientValue::createGradient): Ditto. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitCategory): Remove handling of viewport units, as they get resolved to pixels. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Ditto. (WebCore::CSSPrimitiveValue::init): Ditto. (WebCore::CSSPrimitiveValue::computeLengthDouble): Resolve viewport units to pixels. (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Remove handling of viewport units, since they get resolved to pixels. (WebCore::CSSPrimitiveValue::viewportPercentageLength): Deleted. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isLength): Remove special handling of viewport units, since they get resolved to pixels. * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): Ditto. * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor): Caclulate conversion factor for viewport units to pixels. Note this does not set hasViewportUnits on the RenderStyle if computing the font size, because in the font size case, the RenderStyle is the parent's style, not the current renderer's style. (WebCore::CSSToLengthConversionData::viewportHeightFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor): Ditto. * css/CSSToLengthConversionData.h: (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add RenderView parameter, and make RenderStyle non-const so that hasViewportUnits can be set on the Style.. (WebCore::CSSToLengthConversionData::style): style is now non-const. (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): Handle RenderView argument. * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::mapFillXPosition): Remove handling of viewport units, as they are already resolved to pixels here. (WebCore::CSSToStyleMap::mapFillYPosition): Ditto. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyLength::applyValue): Ditto. (WebCore::ApplyPropertyBorderRadius::applyValue): Ditto. (WebCore::ApplyPropertyComputeLength::applyValue): Ditto. (WebCore::ApplyPropertyFontSize::applyValue): Ditto. (WebCore::ApplyPropertyLineHeight::applyValue): Ditto. (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Ditto. (WebCore::ApplyPropertyWordSpacing::applyValue): Ditto. (WebCore::ApplyPropertyVerticalAlign::applyValue): Ditto. (WebCore::ApplyPropertyTextIndent::applyValue): Ditto. * css/LengthFunctions.cpp: (WebCore::minimumIntValueForLength): Remove RenderView argument. (WebCore::intValueForLength): Remove RenderView argument and roundPecentages. (WebCore::minimumValueForLength): Remove RenderView argument, and special handling of viewport units. (WebCore::valueForLength): Ditto. (WebCore::floatValueForLength): Ditto. (WebCore::floatSizeForLengthSize): Remove RenderView argument. * css/LengthFunctions.h: Ditto. * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::eval): Add RenderView argument for CSSToLengthConversionData constuctor. * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): Change to 0 arg constructor for CSSToLengthConversionData. (WebCore::StyleResolver::State::updateConversionData): In order to get the RenderView, we need to have a valid Element set on the state. Since this means that we need to set the conversion data in more places, move the contruction of conversion data into this helper method. (WebCore::StyleResolver::State::initElement): Make sure conversion data is up to date. (WebCore::StyleResolver::State::initForStyleResolve): Ditto. (WebCore::StyleResolver::State::setStyle): When the style is set, we need to make sure to update the conversion data. (WebCore::StyleResolver::styleForElement): If the style has viewport units, flage the document so that we can make sure to recalc the viewport unit values when the viewport is resized. (WebCore::StyleResolver::pseudoStyleForElement): Ditto. (WebCore::StyleResolver::updateFont): Make sure the font having viewport units updates the style. (WebCore::StyleResolver::convertToIntLength): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::convertToFloatLength): Ditto. (WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits): Invalidate the matched properties cache for styles with viewport units when the viewport is resized. (WebCore::createGridTrackBreadth): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::applyProperty): Ditto. (WebCore::StyleResolver::hasMediaQueriesAffectedByViewportChange): Rename to be less confusing, since it has nothing to do with viewport units. (WebCore::StyleResolver::createFilterOperations): Remove handling of viewport units, as they are resolved to pixels. (WebCore::StyleResolver::affectedByViewportChange): Deleted. (WebCore::StyleResolver::viewportPercentageValue): Deleted. * css/StyleResolver.h: (WebCore::StyleResolver::State::State): C++11 cleanup: 0 -> nullptr. (WebCore::StyleResolver::State::setFontSizeHasViewportUnits): Set if the font size is specified in viewport units. (WebCore::StyleResolver::State::fontSizeHasViewportUnits): Ditto. (WebCore::StyleResolver::State::setStyle): Deleted. * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): Remove handling of viewport units, since they are resolved to pixels. * dom/Document.cpp: (WebCore::Document::Document): Add flag to determine if some style in the document has viewport units. (WebCore::Document::pageSizeAndMarginsInPixels): Remove RenderView argument. (WebCore::Document::updateViewportUnitsOnResize): Mark elements with viewport units for style recalc when the viewport size has changed. * dom/Document.h: (WebCore::Document::setHasStyleWithViewportUnits): Flag to determine if some style in the document has viewport units. (WebCore::Document::hasStyleWithViewportUnits): Ditto. * html/HTMLAreaElement.cpp: (WebCore::HTMLAreaElement::getRegion): Remove RenderView argument. * page/FrameView.cpp: (WebCore::FrameView::layout): When the viewport is resized, call updateViewportUnitsOnResize on the document. * platform/Length.h: (WebCore::Length::isSpecified): Remove handling of viewport units, since they are now resolved to pixels. (WebCore::Length::viewportPercentageLength): Deleted. (WebCore::Length::isViewportPercentage): Deleted. * rendering/ClipPathOperation.h: (WebCore::ShapeClipPathOperation::pathForReferenceRect): Remove RenderView argument. (WebCore::BoxClipPathOperation::pathForReferenceRect): Ditto. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateBlockChildDirtyBitsBeforeLayout): Remove handling of viewport units, since they get updated by updateViewportUnitsOnResize when the viewport is resized. (WebCore::RenderBlock::nodeAtPoint): Remove RenderView argument. (WebCore::RenderBlock::lineHeight): Ditto. * rendering/RenderBox.cpp: (WebCore::RenderBox::paintBoxDecorations): Remove RenderView argument. (WebCore::RenderBox::computeContentAndScrollbarLogicalHeightUsing): Remove handling of viewport units, as they are resolved to pixels. (WebCore::RenderBox::computePercentageLogicalHeight): Ditto. (WebCore::RenderBox::computeReplacedLogicalWidthUsing): Ditto. (WebCore::RenderBox::computeReplacedLogicalHeightUsing): Ditto. (WebCore::RenderBox::hasViewportPercentageLogicalHeight): Deleted. * rendering/RenderBox.h: * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::getBackgroundRoundedRect): Remove RenderView argument. (WebCore::RenderBoxModelObject::calculateFillTileSize): Remove handling of viewport units, as they are resolved to pixels. (WebCore::computeBorderImageSide): Remove RenderView argument. (WebCore::RenderBoxModelObject::paintNinePieceImage): Ditto. (WebCore::RenderBoxModelObject::paintBorder): Ditto. (WebCore::RenderBoxModelObject::paintBoxShadow): Ditto. * rendering/RenderElement.cpp: (WebCore::RenderElement::repaintAfterLayoutIfNeeded): Ditto. * rendering/RenderElement.h: (WebCore::RenderElement::valueForLength): Remove unused roundPercentages argument. (WebCore::RenderElement::minimumValueForLength): Remove unused RoundPercentages and RenderView arguments. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::layoutGridItems): Remove handling of viewport units as they are resolved to pixels. * rendering/RenderInline.cpp: (WebCore::computeMargin): Ditto. (WebCore::RenderInline::lineHeight): Remove RenderView argument. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::setupClipPath): Ditto. * rendering/RenderLineBreak.cpp: (WebCore::RenderLineBreak::lineHeight): Ditto. * rendering/RenderScrollbarPart.cpp: (WebCore::calcScrollbarThicknessUsing): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarWidth): Ditto. (WebCore::RenderScrollbarPart::computeScrollbarHeight): Ditto. * rendering/RenderTable.cpp: (WebCore::RenderTable::convertStyleLogicalHeightToComputedHeight): Remove handling of viewport units, since they are resolved to pixels. (WebCore::RenderTable::computePreferredLogicalWidths): Now that viewport unit values are resolved to pixels at style recalc time, no special checking is needed to handle them, so update the comment to reflect that. * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): Add RenderView argument to CSSToLengthConversionData constructor. (WebCore::RenderThemeIOS::adjustButtonStyle): Ditto. * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::paintMenuListButtonGradients): Remove RenderView argument. * rendering/RenderView.cpp: (WebCore::RenderView::layout): Remove handling of viewport units, since they are resolved to pixels. * rendering/RootInlineBox.cpp: (WebCore::RootInlineBox::ascentAndDescentForBox): Remove RenderView argument. * rendering/shapes/Shape.cpp: (WebCore::Shape::createShape): Remove RenderView argument. * rendering/shapes/Shape.h: * rendering/shapes/ShapeOutsideInfo.cpp: (WebCore::ShapeOutsideInfo::computedShape): Ditto. * rendering/style/BasicShapes.cpp: (WebCore::BasicShapeCircle::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeCircle::path): Ditto. (WebCore::BasicShapeEllipse::floatValueForRadiusInBox): Ditto. (WebCore::BasicShapeEllipse::path): Ditto. (WebCore::BasicShapePolygon::path): Ditto. (WebCore::floatSizeForLengthSize): Ditto. (WebCore::BasicShapeInset::path): Ditto. * rendering/style/BasicShapes.h: * rendering/style/RenderStyle.cpp: (WebCore::calcRadiiFor): Ditto. (WebCore::RenderStyle::getRoundedBorderFor): Ditto. (WebCore::RenderStyle::computedLineHeight): Remove handling of viewport units since they are resolved to pixels. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setHasViewportUnits): Set if this style has a property set with viewport units. (WebCore::RenderStyle::hasViewportUnits): Ditto. * rendering/svg/RenderSVGRoot.cpp: (WebCore::resolveLengthAttributeForSVG): Remove RenderView argument. (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): Ditto. (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto. * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::prepareToRenderSVGContent): Ditto. LayoutTests: Update existing tests to work with the proper behavior of viewport units. Add tests for some of the things fixed by this patch: handling of viewport units in font sizes, with calc, and when the viewport is resized without a reload. The anonymous block and percent size child tests make sure that the viewport unit updates still work properly when there is another relative unit the depends on the size specified in viewport units. * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle-expected.txt: * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-getStyle.html: * css3/viewport-percentage-lengths/resources/resize-test.js: Added. (resizeTest): (standardResizeTest): * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-anonymous-block.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-calc.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-percent-size-child.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-relative-font-size.html: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: Added. * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added. * fast/canvas/draw-focus-if-needed-expected.txt: Removed. * fast/canvas/draw-focus-if-needed.html: Removed. * fast/masking/parsing-clip-path-shape-expected.txt: * fast/masking/parsing-clip-path-shape.html: * fast/shapes/parsing/parsing-shape-lengths-expected.txt: * fast/shapes/parsing/parsing-shape-lengths.html: Canonical link: https://commits.webkit.org/151360@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169407 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-28 01:33:26 +00:00
double viewportWidthFactor() const;
double viewportHeightFactor() const;
double viewportMinFactor() const;
double viewportMaxFactor() const;
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
CSSToLengthConversionData copyWithAdjustedZoom(float newZoom) const
{
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, newZoom, m_propertyToCompute);
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
CSSToLengthConversionData copyWithAdjustedZoomAndPropertyToCompute(float zoom, std::optional<CSSPropertyID> propertyToCompute) const
[css-values-4] Support font-relative lh and rlh unit https://bugs.webkit.org/show_bug.cgi?id=195180 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-04-07 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Pass all 'lh' and 'rlh' tests, minus the '2rlh in font-size on root' test which may be a bug in the test itself: https://github.com/web-platform-tests/wpt/issues/22055 * web-platform-tests/css/css-values/lh-rlh-on-root-001-expected.txt: Source/WebCore: Implement support for 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths * css/CSSCalculationValue.cpp: (WebCore::calcUnitCategory): (WebCore::calculationCategoryForCombination): (WebCore::hasDoubleValue): * css/CSSGradientValue.cpp: (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::createGradient): (WebCore::CSSConicGradientValue::createGradient): * css/CSSPrimitiveValue.cpp: (WebCore::isValidCSSUnitTypeForDoubleConversion): (WebCore::isStringType): (WebCore::CSSPrimitiveValue::cleanup): (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): (WebCore::CSSPrimitiveValue::unitTypeString): (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): (WebCore::CSSPrimitiveValue::equals const): (WebCore::CSSPrimitiveValue::collectDirectComputationalDependencies const): (WebCore::CSSPrimitiveValue::collectDirectRootComputationalDependencies const): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontRelativeLength): (WebCore::CSSPrimitiveValue::isLength): * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertingToLengthRequiresNonNullStyle const): * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::viewportWidthFactor const): (WebCore::CSSToLengthConversionData::viewportHeightFactor const): (WebCore::CSSToLengthConversionData::viewportMinFactor const): (WebCore::CSSToLengthConversionData::viewportMaxFactor const): * css/CSSToLengthConversionData.h: Replace bool 'm_computingFontSize' with Optional<CSSPropertyID> that indicates the property being computed, where none means the property being computed is unknown or unimportant to know. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): Add 'parentStyle' parameter, necessary for calculating lh/rlh unit values. (WebCore::CSSToLengthConversionData::parentStyle const): (WebCore::CSSToLengthConversionData::computingFontSize const): (WebCore::CSSToLengthConversionData::computingLineHeight const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoomAndPropertyToCompute const): * css/CSSUnits.cpp: (WebCore::operator<<): * css/CSSUnits.h: * css/MediaQueryEvaluator.cpp: (WebCore::MediaQueryEvaluator::evaluate const): * css/parser/CSSParserToken.cpp: (WebCore::cssPrimitiveValueUnitFromTrie): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeLength): * css/parser/SizesAttributeParser.cpp: (WebCore::SizesAttributeParser::computeLength): (WebCore::SizesAttributeParser::effectiveSizeDefaultValue): * html/shadow/TextControlInnerElements.cpp: (WebCore::TextControlInnerElement::resolveCustomStyle): * rendering/RenderElement.h: (WebCore::RenderElement::parentStyle const): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle const): * rendering/style/RenderStyle.cpp: Extract 'computedLineHeight' behavior into separate 'computeLineHeight' function so logic can be reused elsewhere. (WebCore::RenderStyle::computedLineHeight const): (WebCore::RenderStyle::computeLineHeight const): * rendering/style/RenderStyle.h: * style/StyleBuilderConverter.h: Extract zoom calculation logic out of 'csstoLengthConversionDataWithTextZoomFactor' into separate 'zoomWithTextZoomFactor' function so logic can be reused elsewhere. (WebCore::Style::zoomWithTextZoomFactor): (WebCore::Style::BuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::Style::BuilderConverter::convertLineHeight): * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::BuilderState): LayoutTests: Implement support for the font-relative 'lh' and 'rlh' units. https://www.w3.org/TR/css-values-4/#font-relative-lengths Canonical link: https://commits.webkit.org/223066@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-08 04:45:45 +00:00
{
return CSSToLengthConversionData(m_style, m_rootStyle, m_parentStyle, m_renderView, zoom, propertyToCompute);
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
}
private:
font-size with viewport units in calc() doesn't change when viewport resizes https://bugs.webkit.org/show_bug.cgi?id=224614 Reviewed by Zalan Bujtas. Source/WebCore: * css/CSSToLengthConversionData.cpp: (WebCore::CSSToLengthConversionData::zoom const): Updated since m_zoom is now optional. We use effectiveZoom when m_zoom is not specified, which is the same semantic that was implemented before with a separate boolean. (WebCore::CSSToLengthConversionData::viewportWidthFactor const): When calling the setHasViewportUnits function as a side effect, use m_viewportDependencyDetectionStyle, rather than always using m_style. This lets us handle the font-size case correctly. Also removed the explicit computingFontSize check for the same reason. (WebCore::CSSToLengthConversionData::viewportHeightFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMinFactor const): Ditto. (WebCore::CSSToLengthConversionData::viewportMaxFactor const): Ditto. * css/CSSToLengthConversionData.h: Added a new member, m_viewportDependencyDetectionStyle, which defaults to the same value as m_style. Also changed m_zoom to use Optional instead of a separate boolean and an ignored "must be 1.0" value. Initialized data members in the modern way, allowing us to use the default constructor. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontSize): Pass in the builder's style as the viewportDependencyDetectionStyle. This does the same thing that the existing code to call setHasViewportUnits did directly, but does it even for more complex cases involving calc(). Also made the isLength and isCalculatedPercentageWithLength cases more similar to each other and left a FIXME behind about taking that a bit further, but doing that probably requires creating some more test cases. LayoutTests: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize-expected.txt: * css3/viewport-percentage-lengths/viewport-percentage-lengths-resize.html: Added tests that involve calc, and broke rules up into multiple elements so that side effects from one style won't give us false negatives. This now has a subtest that was failing without the fix in this patch. Canonical link: https://commits.webkit.org/236669@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-17 01:08:45 +00:00
const RenderStyle* m_style { nullptr };
const RenderStyle* m_rootStyle { nullptr };
const RenderStyle* m_parentStyle { nullptr };
RenderStyle* m_viewportDependencyDetectionStyle { nullptr };
const RenderView* m_renderView { nullptr };
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<float> m_zoom;
std::optional<CSSPropertyID> m_propertyToCompute;
Wrap CSS length conversion arguments in an object https://bugs.webkit.org/show_bug.cgi?id=131552 Reviewed by Andreas Kling. This patch introduces a class CSSToLengthConversionData to wrap the data required to convert CSS lengths to Lengths. This simplifies the plumbing that goes on whenever we need to resolve CSS lengths and makes it easier to update the arguments needed for resolving these (in particular adding a RenderView for resolving viewport units at style recalc time; removing the computingFontSize bool also appears possible). Note that the zoom argument, which was previously a float in some places and a double in others is now a float. This is a port of a Blink patch by timloh@chromium.org. No new tests, no behavior change. * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * css/BasicShapeFunctions.cpp: (WebCore::convertToLength): (WebCore::convertToLengthSize): (WebCore::convertToCenterCoordinate): (WebCore::cssValueToBasicShapeRadius): (WebCore::basicShapeForValue): * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcValue::computeLengthPx): (WebCore::determineCategory): * css/CSSCalculationValue.h: (WebCore::CSSCalcValue::createCalculationValue): * css/CSSGradientValue.cpp: (WebCore::CSSGradientValue::addStops): (WebCore::positionFromValue): (WebCore::CSSGradientValue::computeEndPoint): (WebCore::CSSLinearGradientValue::createGradient): (WebCore::CSSRadialGradientValue::resolveRadius): (WebCore::CSSRadialGradientValue::createGradient): * css/CSSGradientValue.h: * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLength): (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: * css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::convertToLength): * css/CSSToLengthConversionData.cpp: Added. (WebCore::CSSToLengthConversionData::zoom): * css/CSSToLengthConversionData.h: Added. (WebCore::CSSToLengthConversionData::CSSToLengthConversionData): (WebCore::CSSToLengthConversionData::style): (WebCore::CSSToLengthConversionData::rootStyle): (WebCore::CSSToLengthConversionData::computingFontSize): (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom): * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): * css/CSSToStyleMap.h: (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted. * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyAuto::applyValue): (WebCore::ApplyPropertyClip::convertToLength): (WebCore::ApplyPropertyLength::applyValue): (WebCore::ApplyPropertyBorderRadius::applyValue): (WebCore::ApplyPropertyComputeLength::applyValue): (WebCore::ApplyPropertyFontSize::applyValue): (WebCore::csstoLengthConversionDataWithTextZoomFactor): (WebCore::ApplyPropertyMarqueeIncrement::applyValue): (WebCore::ApplyPropertyLineHeight::applyValue): (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): (WebCore::ApplyPropertyWordSpacing::applyValue): (WebCore::ApplyPropertyPageSize::mmLength): (WebCore::ApplyPropertyPageSize::inchLength): (WebCore::ApplyPropertyPageSize::applyValue): (WebCore::ApplyPropertyVerticalAlign::applyValue): (WebCore::ApplyPropertyClipPath::applyValue): (WebCore::ApplyPropertyShape::applyValue): (WebCore::ApplyPropertyTextIndent::applyValue): * css/MediaQueryEvaluator.cpp: (WebCore::colorMediaFeatureEval): (WebCore::color_indexMediaFeatureEval): (WebCore::monochromeMediaFeatureEval): (WebCore::orientationMediaFeatureEval): (WebCore::aspect_ratioMediaFeatureEval): (WebCore::device_aspect_ratioMediaFeatureEval): (WebCore::device_pixel_ratioMediaFeatureEval): (WebCore::resolutionMediaFeatureEval): (WebCore::gridMediaFeatureEval): (WebCore::computeLength): (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval): (WebCore::min_colorMediaFeatureEval): (WebCore::max_colorMediaFeatureEval): (WebCore::min_color_indexMediaFeatureEval): (WebCore::max_color_indexMediaFeatureEval): (WebCore::min_monochromeMediaFeatureEval): (WebCore::max_monochromeMediaFeatureEval): (WebCore::min_aspect_ratioMediaFeatureEval): (WebCore::max_aspect_ratioMediaFeatureEval): (WebCore::min_device_aspect_ratioMediaFeatureEval): (WebCore::max_device_aspect_ratioMediaFeatureEval): (WebCore::min_device_pixel_ratioMediaFeatureEval): (WebCore::max_device_pixel_ratioMediaFeatureEval): (WebCore::min_heightMediaFeatureEval): (WebCore::max_heightMediaFeatureEval): (WebCore::min_widthMediaFeatureEval): (WebCore::max_widthMediaFeatureEval): (WebCore::min_device_heightMediaFeatureEval): (WebCore::max_device_heightMediaFeatureEval): (WebCore::min_device_widthMediaFeatureEval): (WebCore::max_device_widthMediaFeatureEval): (WebCore::min_resolutionMediaFeatureEval): (WebCore::max_resolutionMediaFeatureEval): (WebCore::animationMediaFeatureEval): (WebCore::transitionMediaFeatureEval): (WebCore::transform_2dMediaFeatureEval): (WebCore::transform_3dMediaFeatureEval): (WebCore::view_modeMediaFeatureEval): (WebCore::video_playable_inlineMediaFeatureEval): (WebCore::hoverMediaFeatureEval): (WebCore::pointerMediaFeatureEval): (WebCore::MediaQueryEvaluator::eval): * css/SVGCSSStyleSelector.cpp: (WebCore::StyleResolver::applySVGProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::State::clear): (WebCore::StyleResolver::State::initForStyleResolve): (WebCore::StyleResolver::convertToIntLength): (WebCore::StyleResolver::convertToFloatLength): (WebCore::createGridTrackBreadth): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::createFilterOperations): * css/StyleResolver.h: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::State::cssToLengthConversionData): * css/TransformFunctions.cpp: (WebCore::convertToFloatLength): (WebCore::transformsForValue): * css/TransformFunctions.h: * css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue): * rendering/RenderThemeIOS.mm: (WebCore::applyCommonButtonPaddingToStyle): (WebCore::RenderThemeIOS::adjustButtonStyle): Canonical link: https://commits.webkit.org/150345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-29 16:36:43 +00:00
};
} // namespace WebCore