Changeset 19164 in webkit
- Timestamp:
- Jan 26, 2007, 2:45:42 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r19163 r19164 1 2007-01-26 David Hyatt <hyatt@apple.com> 2 3 Fix for style regression caused by strictness checking of the number of properties. This caused code like: 4 "width: 20 px" to fail, because we interpreted it as two values and rejected it. Our old code allowed 20 to be 5 used like a pixel value and then ignored the orphaned unit. 6 7 This patch actually scans the list of values looking for orphaned units and reattaches them to the numeric 8 values that they should correspond to. This means rules like "width: 5 em" will now work in quirks mdoe and 9 the "em" unit type will be honored. 10 11 Reviewed by beth 12 13 * WebCore.xcodeproj/project.pbxproj: 14 * css/cssparser.cpp: 15 (WebCore::unitFromString): 16 (WebCore::CSSParser::checkForOrphanedUnits): 17 (WebCore::CSSParser::parseValue): 18 * css/cssparser.h: 19 (WebCore::ValueList::valueAt): 20 (WebCore::ValueList::deleteValueAt): 21 1 22 2007-01-26 George Staikos <staikos@kde.org> 2 23 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r19160 r19164 11096 11096 isa = PBXProject; 11097 11097 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 11098 compatibilityVersion = "Xcode 2.4";11099 11098 hasScannedForEncodings = 1; 11100 11099 knownRegions = ( … … 11111 11110 projectDirPath = ""; 11112 11111 projectRoot = ""; 11113 shouldCheckCompatibility = 1;11114 11112 targets = ( 11115 11113 93F198A508245E59001E9ABC /* WebCore */, -
trunk/WebCore/css/cssparser.cpp
r18838 r19164 422 422 } 423 423 424 static int unitFromString(Value* value) 425 { 426 if (value->unit != CSSPrimitiveValue::CSS_IDENT || value->id) 427 return 0; 428 429 String str = domString(value->string); 430 if (str == "em") 431 return CSSPrimitiveValue::CSS_EMS; 432 if (str == "ex") 433 return CSSPrimitiveValue::CSS_EXS; 434 if (str == "px") 435 return CSSPrimitiveValue::CSS_PX; 436 if (str == "cm") 437 return CSSPrimitiveValue::CSS_CM; 438 if (str == "mm") 439 return CSSPrimitiveValue::CSS_MM; 440 if (str == "in") 441 return CSSPrimitiveValue::CSS_IN; 442 if (str == "pt") 443 return CSSPrimitiveValue::CSS_PT; 444 if (str == "pc") 445 return CSSPrimitiveValue::CSS_PC; 446 if (str == "deg") 447 return CSSPrimitiveValue::CSS_DEG; 448 if (str == "rad") 449 return CSSPrimitiveValue::CSS_RAD; 450 if (str == "grad") 451 return CSSPrimitiveValue::CSS_GRAD; 452 if (str == "ms") 453 return CSSPrimitiveValue::CSS_MS; 454 if (str == "s") 455 return CSSPrimitiveValue::CSS_S; 456 if (str == "Hz") 457 return CSSPrimitiveValue::CSS_HZ; 458 if (str == "kHz") 459 return CSSPrimitiveValue::CSS_KHZ; 460 461 return 0; 462 } 463 464 void CSSParser::checkForOrphanedUnits() 465 { 466 if (strict || inShorthand()) 467 return; 468 469 // The purpose of this code is to implement the WinIE quirk that allows unit types to be separated from their numeric values 470 // by whitespace, so e.g., width: 20 px instead of width:20px. This is invalid CSS, so we don't do this in strict mode. 471 Value* numericVal = 0; 472 unsigned size = valueList->size(); 473 for (unsigned i = 0; i < size; i++) { 474 Value* value = valueList->valueAt(i); 475 if (numericVal) { 476 // Change the unit type of the numeric val to match. 477 int unit = unitFromString(value); 478 if (unit) { 479 numericVal->unit = unit; 480 numericVal = 0; 481 482 // Now delete the bogus unit value. 483 valueList->deleteValueAt(i); 484 i--; // We're safe even though |i| is unsigned, since we only hit this code if we had a previous numeric value (so |i| is always > 0 here). 485 size--; 486 continue; 487 } 488 } 489 490 numericVal = (value->unit == CSSPrimitiveValue::CSS_NUMBER) ? value : 0; 491 } 492 } 493 424 494 bool CSSParser::parseValue(int propId, bool important) 425 495 { … … 451 521 bool valid_primitive = false; 452 522 CSSValue *parsedValue = 0; 523 524 // In quirks mode, we will look for units that have been incorrectly separated from the number they belong to 525 // by a space. We go ahead and associate the unit with the number even though it is invalid CSS. 526 checkForOrphanedUnits(); 453 527 454 528 switch(propId) { -
trunk/WebCore/css/cssparser.h
r18850 r19164 95 95 Value* next() { ++m_current; return current(); } 96 96 97 Value* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; } 98 void deleteValueAt(unsigned i) { m_values.remove(i); } 99 97 100 private: 98 101 Vector<Value, 16> m_values; … … 235 238 bool inShorthand() const { return m_inParseShorthand; } 236 239 240 void checkForOrphanedUnits(); 241 237 242 UChar* data; 238 243 UChar* yytext;
Note:
See TracChangeset
for help on using the changeset viewer.