Changeset 95058 in webkit


Ignore:
Timestamp:
Sep 13, 2011 5:17:09 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=68040

Make sure border image sub-properties can be specified in any order.

Reviewed by Beth Dakin.

Source/WebCore:

New tests in fast/borders.

  • css/CSSParser.cpp:

(WebCore::BorderImageParseContext::BorderImageParseContext):
(WebCore::BorderImageParseContext::canAdvance):
(WebCore::BorderImageParseContext::setCanAdvance):
(WebCore::BorderImageParseContext::allowCommit):
(WebCore::BorderImageParseContext::allowImage):
(WebCore::BorderImageParseContext::allowImageSlice):
(WebCore::BorderImageParseContext::allowSlash):
(WebCore::BorderImageParseContext::requireWidth):
(WebCore::BorderImageParseContext::requireOutset):
(WebCore::BorderImageParseContext::commitImage):
(WebCore::BorderImageParseContext::commitImageSlice):
(WebCore::BorderImageParseContext::commitSlash):
(WebCore::BorderImageParseContext::commitBorderWidth):
(WebCore::BorderImageParseContext::commitBorderOutset):
(WebCore::BorderImageParseContext::commitRepeat):
(WebCore::CSSParser::parseBorderImage):
(WebCore::CSSParser::parseBorderImageRepeat):
(WebCore::CSSParser::parseBorderImageSlice):
(WebCore::CSSParser::parseBorderImageQuad):

  • css/CSSParserValues.h:

(WebCore::CSSParserValueList::previous):

LayoutTests:

  • fast/borders/border-image-scrambled.html: Added.
  • platform/mac/fast/borders/border-image-scrambled-expected.png: Added.
  • platform/mac/fast/borders/border-image-scrambled-expected.txt: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95056 r95058  
     12011-09-13  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68040
     4       
     5        Make sure border image sub-properties can be specified in any order.
     6
     7        Reviewed by Beth Dakin.
     8
     9        * fast/borders/border-image-scrambled.html: Added.
     10        * platform/mac/fast/borders/border-image-scrambled-expected.png: Added.
     11        * platform/mac/fast/borders/border-image-scrambled-expected.txt: Added.
     12
    1132011-09-12  Jon Honeycutt  <jhoneycutt@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r95057 r95058  
     12011-09-13  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68040
     4       
     5        Make sure border image sub-properties can be specified in any order.
     6
     7        Reviewed by Beth Dakin.
     8
     9        New tests in fast/borders.
     10
     11        * css/CSSParser.cpp:
     12        (WebCore::BorderImageParseContext::BorderImageParseContext):
     13        (WebCore::BorderImageParseContext::canAdvance):
     14        (WebCore::BorderImageParseContext::setCanAdvance):
     15        (WebCore::BorderImageParseContext::allowCommit):
     16        (WebCore::BorderImageParseContext::allowImage):
     17        (WebCore::BorderImageParseContext::allowImageSlice):
     18        (WebCore::BorderImageParseContext::allowSlash):
     19        (WebCore::BorderImageParseContext::requireWidth):
     20        (WebCore::BorderImageParseContext::requireOutset):
     21        (WebCore::BorderImageParseContext::commitImage):
     22        (WebCore::BorderImageParseContext::commitImageSlice):
     23        (WebCore::BorderImageParseContext::commitSlash):
     24        (WebCore::BorderImageParseContext::commitBorderWidth):
     25        (WebCore::BorderImageParseContext::commitBorderOutset):
     26        (WebCore::BorderImageParseContext::commitRepeat):
     27        (WebCore::CSSParser::parseBorderImage):
     28        (WebCore::CSSParser::parseBorderImageRepeat):
     29        (WebCore::CSSParser::parseBorderImageSlice):
     30        (WebCore::CSSParser::parseBorderImageQuad):
     31        * css/CSSParserValues.h:
     32        (WebCore::CSSParserValueList::previous):
     33
    1342011-09-13  Jeff Miller  <jeffm@apple.com>
    235
  • trunk/Source/WebCore/css/CSSParser.cpp

    r94989 r95058  
    51595159    BorderImageParseContext(CSSPrimitiveValueCache* primitiveValueCache)
    51605160    : m_primitiveValueCache(primitiveValueCache)
    5161     , m_allowBreak(false)
     5161    , m_canAdvance(false)
     5162    , m_allowCommit(true)
     5163    , m_allowImage(true)
     5164    , m_allowImageSlice(true)
     5165    , m_allowRepeat(true)
    51625166    , m_allowSlash(false)
    5163     , m_allowWidth(false)
    5164     , m_allowOutset(false)
    5165     , m_allowRepeat(false)
     5167    , m_requireWidth(false)
     5168    , m_requireOutset(false)   
    51665169    {}
    51675170
    5168     bool allowBreak() const { return m_allowBreak; }
     5171    bool canAdvance() const { return m_canAdvance; }
     5172    void setCanAdvance(bool canAdvance) { m_canAdvance = canAdvance; }
     5173
     5174    bool allowCommit() const { return m_allowCommit; }
     5175    bool allowImage() const { return m_allowImage; }
     5176    bool allowImageSlice() const { return m_allowImageSlice; }
     5177    bool allowRepeat() const { return m_allowRepeat; }
    51695178    bool allowSlash() const { return m_allowSlash; }
    5170     bool allowWidth() const { return m_allowWidth; }
    5171     bool allowOutset() const { return m_allowOutset; }
    5172     bool allowRepeat() const { return m_allowRepeat; }
    5173 
    5174     void commitImage(PassRefPtr<CSSValue> image) { m_image = image; }
     5179
     5180    bool requireWidth() const { return m_requireWidth; }
     5181    bool requireOutset() const { return m_requireOutset; }
     5182   
     5183    void commitImage(PassRefPtr<CSSValue> image)
     5184    {
     5185        m_image = image;
     5186        m_canAdvance = true;
     5187        m_allowCommit = true;
     5188        m_allowImage = false;
     5189        m_allowSlash = false;
     5190        m_requireWidth = false;
     5191        m_requireOutset = false;
     5192        m_allowImageSlice = !m_imageSlice;
     5193        m_allowRepeat = !m_repeat;
     5194    }
    51755195    void commitImageSlice(PassRefPtr<CSSBorderImageSliceValue> slice)
    51765196    {
    51775197        m_imageSlice = slice;
    5178         m_allowBreak = m_allowSlash = m_allowRepeat = true;
     5198        m_canAdvance = true;
     5199        m_allowCommit = true;
     5200        m_allowSlash = true;
     5201        m_allowImageSlice = false;
     5202        m_requireWidth = false;
     5203        m_requireOutset = false;
     5204        m_allowImage = !m_image;
     5205        m_allowRepeat = !m_repeat;
    51795206    }
    51805207    void commitSlash()
    51815208    {
    5182         m_allowBreak = m_allowSlash = m_allowRepeat = false;
    5183         if (!m_borderSlice)
    5184             m_allowWidth = true;
    5185         else
    5186             m_allowOutset = true;
     5209        m_canAdvance = true;
     5210        m_allowCommit = false;
     5211        m_allowImage = false;
     5212        m_allowImageSlice = false;
     5213        m_allowRepeat = false;
     5214        m_allowSlash = false;
     5215        if (!m_borderSlice) {
     5216            m_requireWidth = true;
     5217            m_requireOutset = false;
     5218        } else {
     5219            m_requireOutset = true;
     5220            m_requireWidth = false;
     5221        }
    51875222    }
    51885223    void commitBorderWidth(PassRefPtr<CSSPrimitiveValue> slice)
    51895224    {
    51905225        m_borderSlice = slice;
    5191         m_allowBreak = m_allowRepeat = true;
    5192         m_allowWidth = false;
     5226        m_canAdvance = true;
     5227        m_allowCommit = true;
    51935228        m_allowSlash = true;
     5229        m_allowImageSlice = false;
     5230        m_requireWidth = false;
     5231        m_requireOutset = false;
     5232        m_allowImage = !m_image;
     5233        m_allowRepeat = !m_repeat;
    51945234    }
    51955235    void commitBorderOutset(PassRefPtr<CSSPrimitiveValue> outset)
    51965236    {
    51975237        m_outset = outset;
    5198         m_allowBreak = m_allowRepeat = true;
    5199         m_allowWidth = m_allowOutset = m_allowSlash = false;
     5238        m_canAdvance = true;
     5239        m_allowCommit = true;
     5240        m_allowImageSlice = false;
     5241        m_allowSlash = false;
     5242        m_requireWidth = false;
     5243        m_requireOutset = false;
     5244        m_allowImage = !m_image;
     5245        m_allowRepeat = !m_repeat;
    52005246    }
    52015247    void commitRepeat(PassRefPtr<CSSValue> repeat)
    52025248    {
    52035249        m_repeat = repeat;
    5204         m_allowRepeat = m_allowSlash = m_allowWidth = m_allowOutset = false;
    5205         m_allowBreak = true;
     5250        m_canAdvance = true;
     5251        m_allowCommit = true;
     5252        m_allowRepeat = false;
     5253        m_allowSlash = false;
     5254        m_requireWidth = false;
     5255        m_requireOutset = false;
     5256        m_allowImageSlice = !m_imageSlice;
     5257        m_allowImage = !m_image;
    52065258    }
    52075259
     
    52145266    CSSPrimitiveValueCache* m_primitiveValueCache;
    52155267
    5216     bool m_allowBreak;
     5268    bool m_canAdvance;
     5269
     5270    bool m_allowCommit;
     5271    bool m_allowImage;
     5272    bool m_allowImageSlice;
     5273    bool m_allowRepeat;
    52175274    bool m_allowSlash;
    5218     bool m_allowWidth;
    5219     bool m_allowOutset;
    5220     bool m_allowRepeat;
     5275   
     5276    bool m_requireWidth;
     5277    bool m_requireOutset;
    52215278
    52225279    RefPtr<CSSValue> m_image;
     
    52305287bool CSSParser::parseBorderImage(int propId, RefPtr<CSSValue>& result)
    52315288{
    5232     // Look for an image initially. If the first value is not a URI or the keyword "none", then we're done.
    52335289    ShorthandScope scope(this, propId);
    52345290    BorderImageParseContext context(primitiveValueCache());
    5235     CSSParserValue* val = m_valueList->current();
    5236     if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) {
    5237         // FIXME: The completeURL call should be done when using the CSSImageValue,
    5238         // not when creating it.
    5239         context.commitImage(CSSImageValue::create(m_styleSheet->completeURL(val->string)));
    5240     } else if (isGeneratedImageValue(val)) {
    5241         RefPtr<CSSValue> value;
    5242         if (parseGeneratedImage(value))
    5243             context.commitImage(value);
    5244         else
    5245             return false;
    5246     } else if (val->id == CSSValueNone)
    5247         context.commitImage(CSSImageValue::create());
    5248     else
    5249         return false;
    5250 
    5251     // Parse the slice next.
    5252     m_valueList->next();
    5253     RefPtr<CSSBorderImageSliceValue> imageSlice;
    5254     if (!parseBorderImageSlice(propId, imageSlice))
    5255         return false;
    5256     context.commitImageSlice(imageSlice.release());
    5257 
    5258     while ((val = m_valueList->current())) {
    5259         if (context.allowSlash() && val->unit == CSSParserValue::Operator && val->iValue == '/') {
     5291    while (CSSParserValue* val = m_valueList->current()) {
     5292        if (!context.canAdvance() && context.allowSlash() && val->unit == CSSParserValue::Operator && val->iValue == '/')
    52605293            context.commitSlash();
    5261         } else if (context.allowWidth()) {
    5262             RefPtr<CSSPrimitiveValue> borderSlice;
    5263             if (!parseBorderImageWidth(borderSlice))
    5264                 return false;
    5265             context.commitBorderWidth(borderSlice.release());
    5266             continue;
    5267         } else if (context.allowOutset()) {
    5268             RefPtr<CSSPrimitiveValue> borderOutset;
    5269             if (!parseBorderImageOutset(borderOutset))
    5270                 return false;
    5271             context.commitBorderOutset(borderOutset.release());
    5272             continue;
    5273         } else if (context.allowRepeat()) {
     5294       
     5295        if (!context.canAdvance() && context.allowImage()) {
     5296            if (val->unit == CSSPrimitiveValue::CSS_URI && m_styleSheet) {
     5297                // FIXME: The completeURL call should be done when using the CSSImageValue,
     5298                // not when creating it.
     5299                context.commitImage(CSSImageValue::create(m_styleSheet->completeURL(val->string)));
     5300            } else if (isGeneratedImageValue(val)) {
     5301                RefPtr<CSSValue> value;
     5302                if (parseGeneratedImage(value))
     5303                    context.commitImage(value);
     5304                else
     5305                    return false;
     5306            } else if (val->id == CSSValueNone)
     5307                context.commitImage(CSSImageValue::create());
     5308        }
     5309       
     5310        if (!context.canAdvance() && context.allowImageSlice()) {
     5311            RefPtr<CSSBorderImageSliceValue> imageSlice;
     5312            if (parseBorderImageSlice(propId, imageSlice))
     5313                context.commitImageSlice(imageSlice.release());
     5314        }
     5315       
     5316        if (!context.canAdvance() && context.allowRepeat()) {
    52745317            RefPtr<CSSValue> repeat;
    52755318            if (parseBorderImageRepeat(repeat))
    52765319                context.commitRepeat(repeat);
    5277         } else {
    5278             // Something invalid was encountered.
    5279             return false;
    5280         }
    5281         m_valueList->next();
    5282     }
    5283 
    5284     if (context.allowBreak()) {
     5320        }
     5321       
     5322        if (!context.canAdvance() && context.requireWidth()) {
     5323            RefPtr<CSSPrimitiveValue> borderSlice;
     5324            if (parseBorderImageWidth(borderSlice))
     5325                context.commitBorderWidth(borderSlice.release());
     5326        }
     5327       
     5328        if (!context.canAdvance() && context.requireOutset()) {
     5329            RefPtr<CSSPrimitiveValue> borderOutset;
     5330            if (parseBorderImageOutset(borderOutset))
     5331                context.commitBorderOutset(borderOutset.release());
     5332        }
     5333       
     5334        if (context.canAdvance()) {
     5335            m_valueList->next();
     5336            context.setCanAdvance(false);
     5337        }
     5338    }
     5339
     5340    if (context.allowCommit()) {
    52855341        // Need to fully commit as a single value.
    52865342        result = context.commitBorderImage();
     
    53105366        if (isBorderImageRepeatKeyword(val->id))
    53115367            secondValue = primitiveValueCache()->createIdentifierValue(val->id);
    5312         else
    5313             return false;
     5368        else if (!inShorthand()) {
     5369            // If we're not parsing a shorthand then we are invalid.
     5370            return false;
     5371        } else {
     5372            // We need to rewind the value list, so that when its advanced we'll
     5373            // end up back at this value.
     5374            m_valueList->previous();
     5375        }
    53145376    } else
    53155377        secondValue = firstValue;
     
    54095471        } else if (context.allowFill() && val->id == CSSValueFill)
    54105472            context.commitFill();
    5411         else if (propId == CSSPropertyBorderImageSlice || propId == CSSPropertyWebkitMaskBoxImageSlice) {
     5473        else if (!inShorthand()) {
    54125474            // If we're not parsing a shorthand then we are invalid.
    54135475            return false;
    5414         } else
     5476        } else {
     5477            if (context.allowFinalCommit()) {
     5478                // We're going to successfully parse, but we don't want to consume this token.
     5479                m_valueList->previous();
     5480            }
    54155481            break;
     5482        }
    54165483        m_valueList->next();
    54175484    }
     
    55245591            // If we're not parsing a shorthand then we are invalid.
    55255592            return false;
    5526         } else
     5593        } else {
     5594            if (context.allowFinalCommit())
     5595                m_valueList->previous(); // The shorthand loop will advance back to this point.
    55275596            break;
     5597        }
    55285598        m_valueList->next();
    55295599    }
  • trunk/Source/WebCore/css/CSSParserValues.h

    r85077 r95058  
    7979    CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; }
    8080    CSSParserValue* next() { ++m_current; return current(); }
     81    CSSParserValue* previous()
     82    {
     83        if (!m_current)
     84            return 0;
     85        --m_current;
     86        return current();
     87    }
    8188
    8289    CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
Note: See TracChangeset for help on using the changeset viewer.