Changeset 13673 in webkit
- Timestamp:
- Apr 3, 2006 10:21:08 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r13666 r13673 1 2006-04-03 Alexey Proskuryakov <ap@nypop.com> 2 3 Reviewed by Darin. 4 5 - tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=7118 6 Property values with extra items do not get treated as invalid (they should) 7 8 * fast/block/margin-collapse/103-expected.checksum: Corrected the results. 9 * fast/block/margin-collapse/103-expected.png: 10 * fast/block/margin-collapse/103-expected.txt: 11 * fast/css/invalidation-errors-2-expected.checksum: Added. 12 * fast/css/invalidation-errors-2-expected.png: Added. 13 * fast/css/invalidation-errors-2-expected.txt: Added. 14 * fast/css/invalidation-errors-2.html: Added. 15 * fast/css/invalidation-errors-3-expected.checksum: Added. 16 * fast/css/invalidation-errors-3-expected.png: Added. 17 * fast/css/invalidation-errors-3-expected.txt: Added. 18 * fast/css/invalidation-errors-3.html: Added. 19 * fast/css/invalidation-errors-expected.checksum: Added. 20 * fast/css/invalidation-errors-expected.png: Added. 21 * fast/css/invalidation-errors-expected.txt: Added. 22 * fast/css/invalidation-errors.html: Added. 23 1 24 2006-04-03 Darin Adler <darin@apple.com> 2 25 -
trunk/LayoutTests/fast/block/margin-collapse/103-expected.checksum
r12842 r13673 1 b0a4b15bd1c0de763dc4ca23f39b934e 1 193b74a67961c892e96709f3ce75b5b2 -
trunk/LayoutTests/fast/block/margin-collapse/103-expected.txt
r13567 r13673 11 11 text run at (0,2) width 520: "We are trying to understand how UVic students perform Shakespeare related research for" 12 12 text run at (0,22) width 265: "classes as well as for their own interest. The " 13 RenderInline {A} at (0,0) size 173x1 6 [border: (1px dashed #333333) none]13 RenderInline {A} at (0,0) size 173x15 14 14 RenderText {TEXT} at (265,22) size 173x20 15 15 text run at (265,22) width 173: "Internet Shakespeare Editions" -
trunk/WebCore/ChangeLog
r13671 r13673 1 2006-04-03 Alexey Proskuryakov <ap@nypop.com> 2 3 Reviewed by Darin. 4 5 - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7118 6 Property values with extra items do not get treated as invalid (they should) 7 8 Tests: fast/css/invalidation-errors.html 9 fast/css/invalidation-errors-2.html 10 fast/css/invalidation-errors-3.html 11 12 * css/CSSGrammar.y: Rollback the properties added by parseValue() when it returns false. 13 * css/cssparser.h: Moved shorthand counting to ShorthandScope, a new class in cssparser.cpp. 14 * css/cssparser.cpp: 15 (WebCore::CSSParser::rollbackLastProperties): Added. 16 (WebCore::CSSParser::parseValue): Return false if there are too many properties in the list. 17 (WebCore::CSSParser::parseBackgroundShorthand): Use ShorthandScope. 18 (WebCore::CSSParser::parseShorthand): Ditto. 19 (WebCore::CSSParser::parse4Values): Ditto. 20 1 21 2006-04-03 Darin Adler <darin@apple.com> 2 22 -
trunk/WebCore/css/CSSGrammar.y
r13560 r13673 285 285 if ($4) { 286 286 p->valueList = p->sinkFloatingValueList($4); 287 p->parseValue(p->id, p->important); 287 int oldParsedProperties = p->numParsedProperties; 288 if (!p->parseValue(p->id, p->important)) 289 p->rollbackLastProperties(p->numParsedProperties - oldParsedProperties); 288 290 delete p->valueList; 289 291 p->valueList = 0; … … 805 807 if ($1 && $4) { 806 808 p->valueList = p->sinkFloatingValueList($4); 809 int oldParsedProperties = p->numParsedProperties; 807 810 $$ = p->parseValue($1, $5); 811 if (!$$) 812 p->rollbackLastProperties(p->numParsedProperties - oldParsedProperties); 808 813 delete p->valueList; 809 814 p->valueList = 0; -
trunk/WebCore/css/cssparser.cpp
r13639 r13673 56 56 } 57 57 58 namespace { 59 class ShorthandScope { 60 public: 61 ShorthandScope(CSSParser* parser, int propId) : m_parser(parser) 62 { 63 if (!(m_parser->m_inParseShorthand++)) 64 m_parser->m_currentShorthand = propId; 65 } 66 ~ShorthandScope() 67 { 68 if (!(--m_parser->m_inParseShorthand)) 69 m_parser->m_currentShorthand = 0; 70 } 71 72 private: 73 CSSParser* m_parser; 74 }; 75 } 76 58 77 CSSParser* CSSParser::currentParser = 0; 59 78 … … 261 280 } 262 281 parsedProperties[numParsedProperties++] = prop; 282 } 283 284 void CSSParser::rollbackLastProperties(int num) 285 { 286 ASSERT(num >= 0); 287 ASSERT(numParsedProperties >= num); 288 289 for (int i = 0; i < num; ++i) 290 delete parsedProperties[--numParsedProperties]; 263 291 } 264 292 … … 340 368 int id = value->id; 341 369 370 int num = inShorthand() ? 1 : valueList->size(); 371 342 372 if (id == CSS_VAL_INHERIT) { 373 if (num != 1) 374 return false; 343 375 addProperty(propId, new CSSInheritedValue(), important); 344 376 return true; 345 377 } 346 378 else if (id == CSS_VAL_INITIAL) { 379 if (num != 1) 380 return false; 347 381 addProperty(propId, new CSSInitialValue(), important); 348 382 return true; … … 543 577 const int properties[2] = { CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING, 544 578 CSS_PROP__KHTML_BORDER_VERTICAL_SPACING }; 545 int num = valueList->size();546 579 if (num == 1) { 547 if (!parseValue(properties[0], important)) return false; 580 ShorthandScope scope(this, CSS_PROP_BORDER_SPACING); 581 if (!parseValue(properties[0], important)) 582 return false; 548 583 CSSValue* value = parsedProperties[numParsedProperties-1]->value(); 549 584 addProperty(properties[1], value, important); … … 551 586 } 552 587 else if (num == 2) { 553 if (!parseValue(properties[0], important)) return false; 554 if (!parseValue(properties[1], important)) return false; 588 ShorthandScope scope(this, CSS_PROP_BORDER_SPACING); 589 if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) 590 return false; 555 591 return true; 556 592 } … … 679 715 680 716 case CSS_PROP__KHTML_FONT_SIZE_DELTA: // <length> 681 717 valid_primitive = validUnit(value, FLength, strict); 682 718 break; 683 719 … … 882 918 case CSS_PROP_BORDER_BOTTOM_RIGHT_RADIUS: 883 919 case CSS_PROP_BORDER_RADIUS: { 884 int num = valueList->size();885 920 if (num != 1 && num != 2) 886 921 return false; … … 1012 1047 const int properties[2] = { CSS_PROP__KHTML_MARGIN_TOP_COLLAPSE, 1013 1048 CSS_PROP__KHTML_MARGIN_BOTTOM_COLLAPSE }; 1014 int num = valueList->size();1015 1049 if (num == 1) { 1016 if (!parseValue(properties[0], important)) return false; 1050 ShorthandScope scope(this, CSS_PROP__KHTML_MARGIN_COLLAPSE); 1051 if (!parseValue(properties[0], important)) 1052 return false; 1017 1053 CSSValue* value = parsedProperties[numParsedProperties-1]->value(); 1018 1054 addProperty(properties[1], value, important); … … 1020 1056 } 1021 1057 else if (num == 2) { 1022 if (!parseValue(properties[0], important)) return false; 1023 if (!parseValue(properties[1], important)) return false; 1058 ShorthandScope scope(this, CSS_PROP__KHTML_MARGIN_COLLAPSE); 1059 if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) 1060 return false; 1024 1061 return true; 1025 1062 } … … 1187 1224 } 1188 1225 if (parsedValue) { 1189 addProperty(propId, parsedValue, important); 1190 return true; 1226 if (!valueList->current() || inShorthand()) { 1227 addProperty(propId, parsedValue, important); 1228 return true; 1229 } 1230 delete parsedValue; 1191 1231 } 1192 1232 return false; … … 1219 1259 CSS_PROP_BACKGROUND_ORIGIN, CSS_PROP_BACKGROUND_COLOR }; 1220 1260 1221 enterShorthand(CSS_PROP_BACKGROUND);1261 ShorthandScope scope(this, CSS_PROP_BACKGROUND); 1222 1262 1223 1263 bool parsedProperty[numProperties] = { false }; // compiler will repeat false as necessary … … 1287 1327 } 1288 1328 1289 exitShorthand();1290 1329 return true; 1291 1330 1292 1331 fail: 1293 exitShorthand();1294 1332 for (int k = 0; k < numProperties; k++) 1295 1333 delete values[k]; … … 1303 1341 // We set up an array of booleans to mark which property has been found, 1304 1342 // and we try to search for properties until it makes no longer any sense. 1305 enterShorthand(propId);1343 ShorthandScope scope(this, propId); 1306 1344 1307 1345 bool found = false; … … 1321 1359 // if we didn't find at least one match, this is an 1322 1360 // invalid shorthand and we have to ignore it 1323 if (!found) { 1324 exitShorthand(); 1361 if (!found) 1325 1362 return false; 1326 }1327 1363 } 1328 1364 … … 1335 1371 m_implicitShorthand = false; 1336 1372 1337 exitShorthand();1338 1373 return true; 1339 1374 } … … 1351 1386 int num = inShorthand() ? 1 : valueList->size(); 1352 1387 1353 enterShorthand(propId);1388 ShorthandScope scope(this, propId); 1354 1389 1355 1390 // the order is top, right, bottom, left 1356 1391 switch (num) { 1357 1392 case 1: { 1358 if (!parseValue(properties[0], important)) { 1359 exitShorthand(); 1393 if (!parseValue(properties[0], important)) 1360 1394 return false; 1361 }1362 1395 CSSValue *value = parsedProperties[numParsedProperties-1]->value(); 1363 1396 m_implicitShorthand = true; … … 1369 1402 } 1370 1403 case 2: { 1371 if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) { 1372 exitShorthand(); 1404 if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) 1373 1405 return false; 1374 }1375 1406 CSSValue *value = parsedProperties[numParsedProperties-2]->value(); 1376 1407 m_implicitShorthand = true; … … 1382 1413 } 1383 1414 case 3: { 1384 if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || 1385 !parseValue(properties[2], important)) { 1386 exitShorthand(); 1415 if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important)) 1387 1416 return false; 1388 }1389 1417 CSSValue *value = parsedProperties[numParsedProperties-2]->value(); 1390 1418 m_implicitShorthand = true; … … 1395 1423 case 4: { 1396 1424 if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || 1397 !parseValue(properties[2], important) || !parseValue(properties[3], important)) { 1398 exitShorthand(); 1425 !parseValue(properties[2], important) || !parseValue(properties[3], important)) 1399 1426 return false; 1400 }1401 1427 break; 1402 1428 } 1403 1429 default: { 1404 exitShorthand();1405 1430 return false; 1406 1431 } 1407 1432 } 1408 1433 1409 exitShorthand();1410 1434 return true; 1411 1435 } -
trunk/WebCore/css/cssparser.h
r13444 r13673 124 124 125 125 void addProperty(int propId, CSSValue*, bool important); 126 void rollbackLastProperties(int num); 126 127 bool hasProperties() const { return numParsedProperties > 0; } 127 128 … … 213 214 214 215 void setupParser(const char* prefix, const String&, const char* suffix); 215 void enterShorthand(int propId) 216 { 217 if (!(m_inParseShorthand++)) 218 m_currentShorthand = propId; 219 } 220 void exitShorthand() 221 { 222 if (!(--m_inParseShorthand)) 223 m_currentShorthand = 0; 224 } 216 225 217 bool inShorthand() const { return m_inParseShorthand; } 226 218
Note: See TracChangeset
for help on using the changeset viewer.