Need a way to ignore text-zoom in a Web page.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 18:43:46 +0000 (18:43 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 18:43:46 +0000 (18:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=27092
rdar://problem/7037987

Reviewed by Simon Fraser.

Source/WebCore:

This patch adds a new property, -webkit-text-zoom, with values of normal and reset. The reset
keyword, just as with the zoom property, can be used to ignore any inherited zoom from the
document.

Added new test in fast/text.

* Modules/mediacontrols/mediaControlsApple.css:
(audio::-webkit-media-controls-panel):
(video::-webkit-media-controls-panel):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::operator ContentDistributionType):
(WebCore::CSSPrimitiveValue::operator TextZoom):
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSPropertyNames.in:
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust):
(WebCore::StyleBuilderCustom::applyValueWebkitTextZoom):
(WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::checkForZoomChange):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayout):
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
* rendering/style/StyleRareInheritedData.h:
* style/StyleFontSizeFunctions.cpp:
(WebCore::Style::computedFontSizeFromSpecifiedSize):
* testing/Internals.cpp:
(WebCore::Internals::setPageZoomFactor):
(WebCore::Internals::setTextZoomFactor):
(WebCore::Internals::setUseFixedLayout):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/text/text-zoom-reset-expected.html: Added.
* fast/text/text-zoom-reset.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187110 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/text-zoom-reset-expected.html [new file with mode: 0644]
LayoutTests/fast/text/text-zoom-reset.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/mediaControlsApple.css
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h
Source/WebCore/style/StyleFontSizeFunctions.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index aecee3b..6e03707 100644 (file)
@@ -1,3 +1,14 @@
+2015-07-21  David Hyatt  <hyatt@apple.com>
+
+        Need a way to ignore text-zoom in a Web page.
+        https://bugs.webkit.org/show_bug.cgi?id=27092
+        rdar://problem/7037987
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/text-zoom-reset-expected.html: Added.
+        * fast/text/text-zoom-reset.html: Added.
+
 2015-07-20  Nan Wang  <n_wang@apple.com>
 
         AX: Selection change as a result of focusing an element may cause Safari to crash
diff --git a/LayoutTests/fast/text/text-zoom-reset-expected.html b/LayoutTests/fast/text/text-zoom-reset-expected.html
new file mode 100644 (file)
index 0000000..c0847e9
--- /dev/null
@@ -0,0 +1,8 @@
+<!doctype html>
+<html style="font-size:18px">
+<body>
+<p style="-webkit-text-zoom:reset">This text should not zoom</p>
+<p style="-webkit-text-zoom:reset; font-size:24px">This text should not zoom</p>
+<p style="-webkit-text-zoom:reset; font-size:inherit">This text should not zoom</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/text-zoom-reset.html b/LayoutTests/fast/text/text-zoom-reset.html
new file mode 100644 (file)
index 0000000..ff999af
--- /dev/null
@@ -0,0 +1,14 @@
+<!doctype html>
+<html style="font-size:18px">
+<head>
+<script>
+if (window.internals)
+    window.internals.setTextZoomFactor(2)
+</script>
+</head>
+<body>
+<p style="-webkit-text-zoom:reset">This text should not zoom</p>
+<p style="-webkit-text-zoom:reset; font-size:24px">This text should not zoom</p>
+<p style="-webkit-text-zoom:reset; font-size:inherit">This text should not zoom</p>
+</body>
+</html>
index a37161d..2ca3344 100644 (file)
@@ -1,3 +1,54 @@
+2015-07-21  David Hyatt  <hyatt@apple.com>
+
+        Need a way to ignore text-zoom in a Web page.
+        https://bugs.webkit.org/show_bug.cgi?id=27092
+        rdar://problem/7037987
+
+        Reviewed by Simon Fraser.
+
+        This patch adds a new property, -webkit-text-zoom, with values of normal and reset. The reset
+        keyword, just as with the zoom property, can be used to ignore any inherited zoom from the
+        document.
+
+        Added new test in fast/text.
+
+        * Modules/mediacontrols/mediaControlsApple.css:
+        (audio::-webkit-media-controls-panel):
+        (video::-webkit-media-controls-panel):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::operator ContentDistributionType):
+        (WebCore::CSSPrimitiveValue::operator TextZoom):
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSPropertyNames.in:
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor):
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust):
+        (WebCore::StyleBuilderCustom::applyValueWebkitTextZoom):
+        (WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::checkForZoomChange):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeRequiresLayout):
+        * rendering/style/RenderStyle.h:
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+        (WebCore::StyleRareInheritedData::operator==):
+        * rendering/style/StyleRareInheritedData.h:
+        * style/StyleFontSizeFunctions.cpp:
+        (WebCore::Style::computedFontSizeFromSpecifiedSize):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setPageZoomFactor):
+        (WebCore::Internals::setTextZoomFactor):
+        (WebCore::Internals::setUseFixedLayout):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2015-07-21  Per Arne Vollan  <peavo@outlook.com>
 
         WinLauncher does not start on WinXP.
index 71164a4..a8c13c7 100644 (file)
@@ -87,6 +87,8 @@ audio::-webkit-media-controls-panel {
     direction: ltr;
 
     transition: opacity 0.25s linear;
+    
+    -webkit-text-zoom: reset
 }
 
 video::-webkit-media-controls-panel {
index 53332be..bbf94a0 100644 (file)
@@ -395,6 +395,7 @@ static const CSSPropertyID computedProperties[] = {
 #endif
     CSSPropertyWebkitTextStrokeColor,
     CSSPropertyWebkitTextStrokeWidth,
+    CSSPropertyWebkitTextZoom,
     CSSPropertyWebkitTransformStyle,
     CSSPropertyWebkitTransitionDelay,
     CSSPropertyWebkitTransitionDuration,
@@ -3178,6 +3179,8 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propert
             return zoomAdjustedPixelValueForLength(style->svgStyle().x(), *style);
         case CSSPropertyY:
             return zoomAdjustedPixelValueForLength(style->svgStyle().y(), *style);
+        case CSSPropertyWebkitTextZoom:
+            return cssValuePool().createValue(style->textZoom());
 
         /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
         case CSSPropertyAnimation:
index cc4c38c..fb1dfb5 100644 (file)
@@ -2358,12 +2358,19 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
         // auto | alphabetic | under
         return parseTextUnderlinePosition(important);
 
-    case CSSPropertyZoom:          // normal | reset | document | <number> | <percentage> | inherit
+    case CSSPropertyZoom:
+        // normal | reset | document | <number> | <percentage> | inherit
         if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)
             validPrimitive = true;
         else
             validPrimitive = (!id && validateUnit(valueWithCalculation, FNumber | FPercent | FNonNeg, CSSStrictMode));
         break;
+    
+    case CSSPropertyWebkitTextZoom:
+        // normal | reset
+        if (id == CSSValueNormal || id == CSSValueReset)
+            validPrimitive = true;
+        break;
 
     case CSSPropertySrc: // Only used within @font-face and @-webkit-filter, so cannot use inherit | initial or be !important. This is a list of urls or local references.
         return parseFontFaceSrc();
index 9a99758..61b9b2b 100644 (file)
@@ -5254,6 +5254,40 @@ template<> inline CSSPrimitiveValue::operator ContentDistributionType() const
     return ContentDistributionStretch;
 }
 
+template<> inline CSSPrimitiveValue::operator TextZoom() const
+{
+    ASSERT(isValueID());
+
+    switch (m_value.valueID) {
+    case CSSValueNormal:
+        return TextZoomNormal;
+    case CSSValueReset:
+        return TextZoomReset;
+    default:
+        break;
+    }
+
+    ASSERT_NOT_REACHED();
+    return TextZoomNormal;
+}
+
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextZoom textZoom)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_VALUE_ID;
+    switch (textZoom) {
+    case TextZoomNormal:
+        m_value.valueID = CSSValueNormal;
+        return;
+    case TextZoomReset:
+        m_value.valueID = CSSValueReset;
+        return;
+    }
+
+    ASSERT_NOT_REACHED();
+    m_value.valueID = CSSValueNormal;
+}
+
 #if ENABLE(CSS_SCROLL_SNAP)
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ScrollSnapType e)
     : CSSValue(PrimitiveClass)
index 33797b5..5122c4f 100644 (file)
@@ -117,6 +117,7 @@ text-rendering [Inherited, FontProperty, NameForMethods=TextRenderingMode]
 #endif
 -webkit-writing-mode [Inherited, Custom=Value]
 -epub-writing-mode = -webkit-writing-mode
+-webkit-text-zoom [Inherited, Custom=Value]
 zoom [Custom=All]
 font-synthesis [Inherited, FontProperty, Converter=FontSynthesis]
 
index 4fe30b7..ce807b1 100644 (file)
@@ -930,9 +930,10 @@ inline GridAutoFlow StyleBuilderConverter::convertGridAutoFlow(StyleResolver&, C
 
 inline CSSToLengthConversionData StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
 {
-    if (auto* frame = styleResolver.document().frame())
-        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
-
+    if (auto* frame = styleResolver.document().frame()) {
+        float textZoomFactor = styleResolver.style()->textZoom() != TextZoomReset ? frame->textZoomFactor() : 1.0f;
+        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * textZoomFactor);
+    }
     return styleResolver.state().cssToLengthConversionData();
 }
 
index d440bd2..17ed265 100644 (file)
@@ -125,6 +125,7 @@ public:
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     static void applyValueWebkitTextSizeAdjust(StyleResolver&, CSSValue&);
 #endif
+    static void applyValueWebkitTextZoom(StyleResolver&, CSSValue&);
     static void applyValueWebkitWritingMode(StyleResolver&, CSSValue&);
     static void applyValueAlt(StyleResolver&, CSSValue&);
 #if ENABLE(CSS_SCROLL_SNAP)
@@ -731,6 +732,16 @@ inline void StyleBuilderCustom::applyValueWebkitTextSizeAdjust(StyleResolver& st
 }
 #endif
 
+inline void StyleBuilderCustom::applyValueWebkitTextZoom(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.getValueID() == CSSValueNormal)
+        styleResolver.style()->setTextZoom(TextZoomNormal);
+    else if (primitiveValue.getValueID() == CSSValueReset)
+        styleResolver.style()->setTextZoom(TextZoomReset);
+    styleResolver.state().setFontDirty(true);
+}
+
 template <CSSPropertyID id>
 inline void StyleBuilderCustom::applyTextOrBoxShadowValue(StyleResolver& styleResolver, CSSValue& value)
 {
index d97b9b0..f40fd27 100644 (file)
@@ -1991,7 +1991,7 @@ void StyleResolver::checkForZoomChange(RenderStyle* style, RenderStyle* parentSt
     if (!parentStyle)
         return;
     
-    if (style->effectiveZoom() == parentStyle->effectiveZoom())
+    if (style->effectiveZoom() == parentStyle->effectiveZoom() && style->textZoom() == parentStyle->textZoom())
         return;
 
     const FontDescription& childFont = style->fontDescription();
index cc06a49..3d23484 100644 (file)
@@ -563,6 +563,7 @@ bool RenderStyle::changeRequiresLayout(const RenderStyle& other, unsigned& chang
             || rareInheritedData->m_textIndentLine != other.rareInheritedData->m_textIndentLine
 #endif
             || rareInheritedData->m_effectiveZoom != other.rareInheritedData->m_effectiveZoom
+            || rareInheritedData->m_textZoom != other.rareInheritedData->m_textZoom
 #if ENABLE(IOS_TEXT_AUTOSIZING)
             || rareInheritedData->textSizeAdjust != other.rareInheritedData->textSizeAdjust
 #endif
index ccc5322..140f492 100644 (file)
@@ -731,6 +731,8 @@ public:
 
     float zoom() const { return visual->m_zoom; }
     float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; }
+    
+    TextZoom textZoom() const { return static_cast<TextZoom>(rareInheritedData->m_textZoom); }
 
     TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
     bool isLeftToRightDirection() const { return direction() == LTR; }
@@ -1370,7 +1372,8 @@ public:
     bool setZoom(float);
     void setZoomWithoutReturnValue(float f) { setZoom(f); }
     bool setEffectiveZoom(float);
-
+    void setTextZoom(TextZoom v) { SET_VAR(rareInheritedData, m_textZoom, v); }
+    
 #if ENABLE(CSS_IMAGE_ORIENTATION)
     void setImageOrientation(ImageOrientationEnum v) { SET_VAR(rareInheritedData, m_imageOrientation, static_cast<int>(v)); }
 #endif
@@ -1920,6 +1923,7 @@ public:
     static TextDecorationSkip initialTextDecorationSkip() { return TextDecorationSkipAuto; }
     static TextUnderlinePosition initialTextUnderlinePosition() { return TextUnderlinePositionAuto; }
     static float initialZoom() { return 1.0f; }
+    static TextZoom initialTextZoom() { return TextZoomNormal; }
     static int initialOutlineOffset() { return 0; }
     static float initialOpacity() { return 1.0f; }
     static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
index f131805..ec960cf 100644 (file)
@@ -465,6 +465,10 @@ enum TextUnderlinePosition {
     TextUnderlinePositionAuto = 0x1, TextUnderlinePositionAlphabetic = 0x2, TextUnderlinePositionUnder = 0x4
 };
 
+enum TextZoom {
+    TextZoomNormal, TextZoomReset
+};
+
 enum EPageBreak {
     PBAUTO, PBALWAYS, PBAVOID
 };
index ad6b3a5..dffa90e 100644 (file)
@@ -113,6 +113,7 @@ StyleRareInheritedData::StyleRareInheritedData()
     , m_textDecorationSkip(RenderStyle::initialTextDecorationSkip())
     , m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
     , m_rubyPosition(RenderStyle::initialRubyPosition())
+    , m_textZoom(RenderStyle::initialTextZoom())
 #if PLATFORM(IOS)
     , touchCalloutEnabled(RenderStyle::initialTouchCalloutEnabled())
 #endif
@@ -194,6 +195,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
     , m_textDecorationSkip(o.m_textDecorationSkip)
     , m_textUnderlinePosition(o.m_textUnderlinePosition)
     , m_rubyPosition(o.m_rubyPosition)
+    , m_textZoom(o.m_textZoom)
 #if PLATFORM(IOS)
     , touchCalloutEnabled(o.touchCalloutEnabled)
 #endif
@@ -321,6 +323,7 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && m_textDecorationSkip == o.m_textDecorationSkip
         && m_textUnderlinePosition == o.m_textUnderlinePosition
         && m_rubyPosition == o.m_rubyPosition
+        && m_textZoom == o.m_textZoom
         && m_lineSnap == o.m_lineSnap
         && m_lineAlign == o.m_lineAlign
 #if ENABLE(CSS_TRAILING_WORD)
index a892d69..2cd9954 100644 (file)
@@ -124,6 +124,7 @@ public:
     unsigned m_textDecorationSkip : 5; // TextDecorationSkip
     unsigned m_textUnderlinePosition : 3; // TextUnderlinePosition
     unsigned m_rubyPosition : 2; // RubyPosition
+    unsigned m_textZoom: 1; // TextZoom
 
 #if PLATFORM(IOS)
     unsigned touchCalloutEnabled : 1;
index c0a67c2..660abbc 100644 (file)
@@ -95,7 +95,8 @@ float computedFontSizeFromSpecifiedSize(float specifiedSize, bool isAbsoluteSize
     float zoomFactor = 1.0f;
     if (!useSVGZoomRules) {
         zoomFactor = style->effectiveZoom();
-        if (Frame* frame = document.frame())
+        Frame* frame = document.frame();
+        if (frame && style->textZoom() != TextZoomReset)
             zoomFactor *= frame->textZoomFactor();
     }
     return computedFontSizeFromSpecifiedSize(specifiedSize, isAbsoluteSize, zoomFactor, useSVGZoomRules ? DoNotApplyMinimumFontSize : UseSmartMinimumForFontFize, document.settings());
index bb734f5..3d076f9 100644 (file)
@@ -2012,6 +2012,17 @@ void Internals::setPageZoomFactor(float zoomFactor, ExceptionCode& ec)
     frame->setPageZoomFactor(zoomFactor);
 }
 
+void Internals::setTextZoomFactor(float zoomFactor, ExceptionCode& ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document->frame()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+    Frame* frame = document->frame();
+    frame->setTextZoomFactor(zoomFactor);
+}
+
 void Internals::setUseFixedLayout(bool useFixedLayout, ExceptionCode& ec)
 {
     Document* document = contextDocument();
index 146f989..c0811a7 100644 (file)
@@ -279,6 +279,7 @@ public:
 
     void setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode&);
     void setPageZoomFactor(float zoomFactor, ExceptionCode&);
+    void setTextZoomFactor(float zoomFactor, ExceptionCode&);
 
     void setUseFixedLayout(bool useFixedLayout, ExceptionCode&);
     void setFixedLayoutSize(int width, int height, ExceptionCode&);
index 5e27e45..8e0ef32 100644 (file)
@@ -253,6 +253,7 @@ enum MediaSessionInterruptingCategory {
 
     [RaisesException] void setPageScaleFactor(unrestricted float scaleFactor, long x, long y);
     [RaisesException] void setPageZoomFactor(unrestricted float zoomFactor);
+    [RaisesException] void setTextZoomFactor(unrestricted float zoomFactor);
 
     [RaisesException] void setUseFixedLayout(boolean useFixedLayout);
     [RaisesException] void setFixedLayoutSize(long width, long height);