Changeset 133458 in webkit


Ignore:
Timestamp:
Nov 5, 2012 4:47:46 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Validate CSS Device Adaptation properties and resolve shorthands
https://bugs.webkit.org/show_bug.cgi?id=95962

Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-11-05
Reviewed by Alexis Menard.

Source/WebCore:

Add the missing keywords and properties for the viewport at-rule.
Note that we have to mark that we are inside a viewport scope because
some properties are not validated as they would be inside a style
rule. As an example, the semantics of CSSPropertyWidth are completely
different: on a viewport rule, it stands for a shorthand for the
minimum and maximum width.

Test: css3/device-adapt/viewport-properties-validation.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore):
(WebCore::CSSParser::parseViewportProperty):
(WebCore::CSSParser::parseViewportShorthand):

  • css/CSSParser.h:
  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):

  • css/CSSPropertyNames.in:
  • css/CSSValueKeywords.in:

LayoutTests:

Added a test for CSS Device Adaptation property parsing validation.

  • css3/device-adapt/viewport-properties-validation-expected.txt: Added.
  • css3/device-adapt/viewport-properties-validation.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133456 r133458  
     12012-11-05  Thiago Marcos P. Santos  <thiago.santos@intel.com>
     2
     3        Validate CSS Device Adaptation properties and resolve shorthands
     4        https://bugs.webkit.org/show_bug.cgi?id=95962
     5
     6        Reviewed by Alexis Menard.
     7
     8        Added a test for CSS Device Adaptation property parsing validation.
     9
     10        * css3/device-adapt/viewport-properties-validation-expected.txt: Added.
     11        * css3/device-adapt/viewport-properties-validation.html: Added.
     12
    1132012-11-05  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r133451 r133458  
     12012-11-05  Thiago Marcos P. Santos  <thiago.santos@intel.com>
     2
     3        Validate CSS Device Adaptation properties and resolve shorthands
     4        https://bugs.webkit.org/show_bug.cgi?id=95962
     5
     6        Reviewed by Alexis Menard.
     7
     8        Add the missing keywords and properties for the viewport at-rule.
     9        Note that we have to mark that we are inside a viewport scope because
     10        some properties are not validated as they would be inside a style
     11        rule. As an example, the semantics of CSSPropertyWidth are completely
     12        different: on a viewport rule, it stands for a shorthand for the
     13        minimum and maximum width.
     14
     15        Test: css3/device-adapt/viewport-properties-validation.html
     16
     17        * css/CSSComputedStyleDeclaration.cpp:
     18        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     19        * css/CSSParser.cpp:
     20        (WebCore::CSSParser::parseValue):
     21        (WebCore):
     22        (WebCore::CSSParser::parseViewportProperty):
     23        (WebCore::CSSParser::parseViewportShorthand):
     24        * css/CSSParser.h:
     25        * css/CSSProperty.cpp:
     26        (WebCore::CSSProperty::isInheritedProperty):
     27        * css/CSSPropertyNames.in:
     28        * css/CSSValueKeywords.in:
     29
    1302012-11-05  Sheriff Bot  <webkit.review.bot@gmail.com>
    231
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r132960 r133458  
    26502650            break;
    26512651
     2652#if ENABLE(CSS_DEVICE_ADAPTATION)
     2653        case CSSPropertyMaxZoom:
     2654        case CSSPropertyMinZoom:
     2655        case CSSPropertyOrientation:
     2656        case CSSPropertyUserZoom:
     2657            break;
     2658#endif
     2659
    26522660#if ENABLE(SVG)
    26532661        case CSSPropertyClipPath:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r133387 r133458  
    77 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    88 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
     9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
    910 *
    1011 * This library is free software; you can redistribute it and/or
     
    17301731    }
    17311732
     1733#if ENABLE(CSS_DEVICE_ADAPTATION)
     1734    if (inViewport())
     1735        return parseViewportProperty(propId, important);
     1736#endif
     1737
    17321738    bool validPrimitive = false;
    17331739    RefPtr<CSSValue> parsedValue;
     
    28572863        ASSERT_NOT_REACHED();
    28582864        return false;
     2865#if ENABLE(CSS_DEVICE_ADAPTATION)
     2866    // Properties bellow are validated inside parseViewportProperty, because we
     2867    // check for parser state inViewportScope. We need to invalidate if someone
     2868    // adds them outside a @viewport rule.
     2869    case CSSPropertyMaxZoom:
     2870    case CSSPropertyMinZoom:
     2871    case CSSPropertyOrientation:
     2872    case CSSPropertyUserZoom:
     2873        validPrimitive = false;
     2874        break;
     2875#endif
    28592876#if ENABLE(SVG)
    28602877    default:
     
    1041810435    return result;
    1041910436}
     10437
     10438bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important)
     10439{
     10440    CSSParserValue* value = m_valueList->current();
     10441    if (!value)
     10442        return false;
     10443
     10444    int id = value->id;
     10445    bool validPrimitive = false;
     10446
     10447    switch (propId) {
     10448    case CSSPropertyMinWidth: // auto | device-width | device-height | <length> | <percentage>
     10449    case CSSPropertyMaxWidth:
     10450    case CSSPropertyMinHeight:
     10451    case CSSPropertyMaxHeight:
     10452        if (id == CSSValueAuto || id == CSSValueDeviceWidth || id == CSSValueDeviceHeight)
     10453            validPrimitive = true;
     10454        else
     10455            validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg));
     10456        break;
     10457    case CSSPropertyWidth: // shorthand
     10458        return parseViewportShorthand(propId, CSSPropertyMinWidth, CSSPropertyMaxWidth, important);
     10459    case CSSPropertyHeight:
     10460        return parseViewportShorthand(propId, CSSPropertyMinHeight, CSSPropertyMaxHeight, important);
     10461    case CSSPropertyMinZoom: // auto | <number> | <percentage>
     10462    case CSSPropertyMaxZoom:
     10463    case CSSPropertyZoom:
     10464        if (id == CSSValueAuto)
     10465            validPrimitive = true;
     10466        else
     10467            validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg));
     10468        break;
     10469    case CSSPropertyUserZoom: // zoom | fixed
     10470        if (id == CSSValueZoom || id == CSSValueFixed)
     10471            validPrimitive = true;
     10472        break;
     10473    case CSSPropertyOrientation: // auto | portrait | landscape
     10474        if (id == CSSValueAuto || id == CSSValuePortrait || id == CSSValueLandscape)
     10475            validPrimitive = true;
     10476    default:
     10477        break;
     10478    }
     10479
     10480    RefPtr<CSSValue> parsedValue;
     10481    if (validPrimitive) {
     10482        parsedValue = parseValidPrimitive(id, value);
     10483        m_valueList->next();
     10484    }
     10485
     10486    if (parsedValue) {
     10487        if (!m_valueList->current() || inShorthand()) {
     10488            addProperty(propId, parsedValue.release(), important);
     10489            return true;
     10490        }
     10491    }
     10492
     10493    return false;
     10494}
     10495
     10496bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first, CSSPropertyID second, bool important)
     10497{
     10498    unsigned numValues = m_valueList->size();
     10499
     10500    if (numValues > 2)
     10501        return false;
     10502
     10503    ShorthandScope scope(this, propId);
     10504
     10505    if (!parseViewportProperty(first, important))
     10506        return false;
     10507
     10508    // If just one value is supplied, the second value
     10509    // is implicitly initialized with the first value.
     10510    if (numValues == 1)
     10511        m_valueList->previous();
     10512
     10513    return parseViewportProperty(second, important);
     10514}
    1042010515#endif
    1042110516
  • trunk/Source/WebCore/css/CSSParser.h

    r133387 r133458  
    525525
    526526#if ENABLE(CSS_DEVICE_ADAPTATION)
     527    bool parseViewportProperty(CSSPropertyID propId, bool important);
     528    bool parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first, CSSPropertyID second, bool important);
     529
    527530    bool inViewport() const { return m_inViewport; }
    528531    bool m_inViewport;
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r133138 r133458  
    682682    case CSSPropertyWebkitAppRegion:
    683683#endif
     684#if ENABLE(CSS_DEVICE_ADAPTATION)
     685    case CSSPropertyMaxZoom:
     686    case CSSPropertyMinZoom:
     687    case CSSPropertyOrientation:
     688    case CSSPropertyUserZoom:
     689#endif
    684690        return false;
    685691    case CSSPropertyInvalid:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r131925 r133458  
    403403-webkit-wrap
    404404#endif
     405#if defined(ENABLE_CSS_DEVICE_ADAPTATION) && ENABLE_CSS_DEVICE_ADAPTATION
     406max-zoom
     407min-zoom
     408orientation
     409user-zoom
     410#endif
    405411#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
    406412-webkit-tap-highlight-color
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r132942 r133458  
    776776reset
    777777
     778#if defined(ENABLE_CSS_DEVICE_ADAPTATION) && ENABLE_CSS_DEVICE_ADAPTATION
     779//
     780// CSS_PROP_USER_ZOOM
     781//
     782// fixed
     783zoom
     784
     785//
     786// CSS_PROP_MIN_WIDTH
     787// CSS_PROP_MAX_WIDTH
     788// CSS_PROP_MIN_HEIGHT
     789// CSS_PROP_MAX_HEIGHT
     790//
     791// auto
     792device-width
     793device-height
     794#endif
     795
    778796//
    779797// CSS_PROP_POINTER_EVENTS
Note: See TracChangeset for help on using the changeset viewer.