Changeset 95058 in webkit
- Timestamp:
- Sep 13, 2011 5:17:09 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95056 r95058 1 2011-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 1 13 2011-09-12 Jon Honeycutt <jhoneycutt@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r95057 r95058 1 2011-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 1 34 2011-09-13 Jeff Miller <jeffm@apple.com> 2 35 -
trunk/Source/WebCore/css/CSSParser.cpp
r94989 r95058 5159 5159 BorderImageParseContext(CSSPrimitiveValueCache* primitiveValueCache) 5160 5160 : 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) 5162 5166 , m_allowSlash(false) 5163 , m_allowWidth(false) 5164 , m_allowOutset(false) 5165 , m_allowRepeat(false) 5167 , m_requireWidth(false) 5168 , m_requireOutset(false) 5166 5169 {} 5167 5170 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; } 5169 5178 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 } 5175 5195 void commitImageSlice(PassRefPtr<CSSBorderImageSliceValue> slice) 5176 5196 { 5177 5197 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; 5179 5206 } 5180 5207 void commitSlash() 5181 5208 { 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 } 5187 5222 } 5188 5223 void commitBorderWidth(PassRefPtr<CSSPrimitiveValue> slice) 5189 5224 { 5190 5225 m_borderSlice = slice; 5191 m_ allowBreak = m_allowRepeat= true;5192 m_allow Width = false;5226 m_canAdvance = true; 5227 m_allowCommit = true; 5193 5228 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; 5194 5234 } 5195 5235 void commitBorderOutset(PassRefPtr<CSSPrimitiveValue> outset) 5196 5236 { 5197 5237 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; 5200 5246 } 5201 5247 void commitRepeat(PassRefPtr<CSSValue> repeat) 5202 5248 { 5203 5249 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; 5206 5258 } 5207 5259 … … 5214 5266 CSSPrimitiveValueCache* m_primitiveValueCache; 5215 5267 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; 5217 5274 bool m_allowSlash; 5218 bool m_allowWidth;5219 bool m_ allowOutset;5220 bool m_ allowRepeat;5275 5276 bool m_requireWidth; 5277 bool m_requireOutset; 5221 5278 5222 5279 RefPtr<CSSValue> m_image; … … 5230 5287 bool CSSParser::parseBorderImage(int propId, RefPtr<CSSValue>& result) 5231 5288 { 5232 // Look for an image initially. If the first value is not a URI or the keyword "none", then we're done.5233 5289 ShorthandScope scope(this, propId); 5234 5290 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 == '/') 5260 5293 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()) { 5274 5317 RefPtr<CSSValue> repeat; 5275 5318 if (parseBorderImageRepeat(repeat)) 5276 5319 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()) { 5285 5341 // Need to fully commit as a single value. 5286 5342 result = context.commitBorderImage(); … … 5310 5366 if (isBorderImageRepeatKeyword(val->id)) 5311 5367 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 } 5314 5376 } else 5315 5377 secondValue = firstValue; … … 5409 5471 } else if (context.allowFill() && val->id == CSSValueFill) 5410 5472 context.commitFill(); 5411 else if ( propId == CSSPropertyBorderImageSlice || propId == CSSPropertyWebkitMaskBoxImageSlice) {5473 else if (!inShorthand()) { 5412 5474 // If we're not parsing a shorthand then we are invalid. 5413 5475 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 } 5415 5481 break; 5482 } 5416 5483 m_valueList->next(); 5417 5484 } … … 5524 5591 // If we're not parsing a shorthand then we are invalid. 5525 5592 return false; 5526 } else 5593 } else { 5594 if (context.allowFinalCommit()) 5595 m_valueList->previous(); // The shorthand loop will advance back to this point. 5527 5596 break; 5597 } 5528 5598 m_valueList->next(); 5529 5599 } -
trunk/Source/WebCore/css/CSSParserValues.h
r85077 r95058 79 79 CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; } 80 80 CSSParserValue* next() { ++m_current; return current(); } 81 CSSParserValue* previous() 82 { 83 if (!m_current) 84 return 0; 85 --m_current; 86 return current(); 87 } 81 88 82 89 CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
Note: See TracChangeset
for help on using the changeset viewer.