Changeset 276208 in webkit
- Timestamp:
- Apr 17, 2021, 3:21:20 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/fast/media/media-query-lengths-evaluate-with-double-precision-expected.html (added)
-
LayoutTests/fast/media/media-query-lengths-evaluate-with-double-precision.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/MediaQueryEvaluator.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r276197 r276208 1 2021-04-17 Tyler Wilcock <twilco.o@protonmail.com> 2 3 Media queries with max-width greater than 999999999px evaluate to false 4 https://bugs.webkit.org/show_bug.cgi?id=224097 5 6 Reviewed by Darin Adler. 7 8 We now evaluate <length> values in media queries with double 9 precision instead of int precision to match other browsers and pass another WPT. 10 11 * TestExpectations: 12 Remove ImageOnlyFailure for imported/w3c/web-platform-tests/css/mediaqueries/min-width-001.xht 13 because it passes now. 14 15 * fast/media/media-query-lengths-evaluate-with-double-precision-expected.html: 16 Added. 17 18 * fast/media/media-query-lengths-evaluate-with-double-precision.html: 19 Added to test properties that WPT min-width-001.xht doesn't 20 (min-height, device-min-height, device-min-width). 21 1 22 2021-04-17 Philippe Normand <pnormand@igalia.com> 2 23 -
trunk/LayoutTests/TestExpectations
r276182 r276208 1253 1253 imported/w3c/web-platform-tests/css/mediaqueries/device-aspect-ratio-005.html [ Skip ] 1254 1254 1255 imported/w3c/web-platform-tests/css/mediaqueries/min-width-001.xht [ ImageOnlyFailure ]1256 1255 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/relative-units-001.html [ ImageOnlyFailure ] 1257 1256 webkit.org/b/156684 imported/w3c/web-platform-tests/css/mediaqueries/mq-calc-005.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r276207 r276208 1 2021-04-17 Tyler Wilcock <twilco.o@protonmail.com> 2 3 Media queries with max-width greater than 999999999px evaluate to false 4 https://bugs.webkit.org/show_bug.cgi?id=224097 5 6 Reviewed by Darin Adler. 7 8 We now evaluate <length> values in media queries with double 9 precision instead of int precision to match other browsers and pass a WPT. 10 11 See similar method in Chromium: 12 https://github.com/chromium/chromium/blob/09a0b960b27f6e08fbe67ad97e6c4fb55ada383f/third_party/blink/renderer/core/css/media_query_evaluator.cc#L436 13 14 Test: fast/media/media-query-lengths-evaluate-with-double-precision.html 15 and WPT imported/w3c/web-platform-tests/css/mediaqueries/min-width-001.xht 16 17 * css/MediaQueryEvaluator.cpp: 18 (WebCore::computeLength): 19 Return Optional<double> rather than int& out-value. 20 21 (WebCore::deviceHeightEvaluate): 22 (WebCore::deviceWidthEvaluate): 23 (WebCore::heightEvaluate): 24 (WebCore::widthEvaluate): 25 Evaluate `length` values as doubles instead of ints. 26 1 27 2021-04-17 Zalan Bujtas <zalan@apple.com> 2 28 -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r270823 r276208 483 483 } 484 484 485 static bool computeLength(CSSValue* value, bool strict, const CSSToLengthConversionData& conversionData, int& result)485 static Optional<double> computeLength(CSSValue* value, bool strict, const CSSToLengthConversionData& conversionData) 486 486 { 487 487 if (!is<CSSPrimitiveValue>(value)) 488 return false;488 return WTF::nullopt; 489 489 490 490 auto& primitiveValue = downcast<CSSPrimitiveValue>(*value); 491 492 491 if (primitiveValue.isNumber()) { 493 result = primitiveValue.intValue(); 494 return !strict || !result; 495 } 496 497 if (primitiveValue.isLength()) { 498 result = primitiveValue.computeLength<int>(conversionData); 499 return true; 500 } 501 502 return false; 492 double value = primitiveValue.doubleValue(); 493 // The only unitless number value allowed in strict mode is zero. 494 if (strict && value) 495 return WTF::nullopt; 496 return value; 497 } 498 499 if (primitiveValue.isLength()) 500 return primitiveValue.computeLength<double>(conversionData); 501 502 return WTF::nullopt; 503 503 } 504 504 … … 509 509 if (!value) 510 510 return true; 511 int length; 511 auto length = computeLength(value, !frame.document()->inQuirksMode(), conversionData); 512 if (!length) 513 return false; 514 512 515 auto height = frame.mainFrame().screenSize().height(); 513 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 514 return false; 515 516 LOG_WITH_STREAM(MediaQueries, stream << " deviceHeightEvaluate: query " << op << " height " << length << ", actual height " << height << " result: " << compareValue(height, length, op)); 517 518 return compareValue(height, length, op); 516 LOG_WITH_STREAM(MediaQueries, stream << " deviceHeightEvaluate: query " << op << " height " << *length << ", actual height " << height << " result: " << compareValue(height, *length, op)); 517 return compareValue(height, *length, op); 519 518 } 520 519 … … 525 524 if (!value) 526 525 return true; 527 int length; 526 auto length = computeLength(value, !frame.document()->inQuirksMode(), conversionData); 527 if (!length) 528 return false; 529 528 530 auto width = frame.mainFrame().screenSize().width(); 529 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 530 return false; 531 532 LOG_WITH_STREAM(MediaQueries, stream << " deviceWidthEvaluate: query " << op << " width " << length << ", actual width " << width << " result: " << compareValue(width, length, op)); 533 534 return compareValue(width, length, op); 531 LOG_WITH_STREAM(MediaQueries, stream << " deviceWidthEvaluate: query " << op << " width " << *length << ", actual width " << width << " result: " << compareValue(width, *length, op)); 532 return compareValue(width, *length, op); 535 533 } 536 534 … … 543 541 if (!value) 544 542 return height; 543 544 auto length = computeLength(value, !frame.document()->inQuirksMode(), conversionData); 545 if (!length) 546 return false; 547 545 548 if (auto* renderView = frame.document()->renderView()) 546 549 height = adjustForAbsoluteZoom(height, *renderView); 547 550 548 int length; 549 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 550 return false; 551 552 LOG_WITH_STREAM(MediaQueries, stream << " heightEvaluate: query " << op << " height " << length << ", actual height " << height << " result: " << compareValue(height, length, op)); 553 554 return compareValue(height, length, op); 551 LOG_WITH_STREAM(MediaQueries, stream << " heightEvaluate: query " << op << " height " << *length << ", actual height " << height << " result: " << compareValue(height, *length, op)); 552 return compareValue(height, *length, op); 555 553 } 556 554 … … 563 561 if (!value) 564 562 return width; 563 564 auto length = computeLength(value, !frame.document()->inQuirksMode(), conversionData); 565 if (!length) 566 return false; 567 565 568 if (auto* renderView = frame.document()->renderView()) 566 569 width = adjustForAbsoluteZoom(width, *renderView); 567 570 568 int length; 569 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 570 return false; 571 572 LOG_WITH_STREAM(MediaQueries, stream << " widthEvaluate: query " << op << " width " << length << ", actual width " << width << " result: " << compareValue(width, length, op)); 573 574 return compareValue(width, length, op); 571 LOG_WITH_STREAM(MediaQueries, stream << " widthEvaluate: query " << op << " width " << *length << ", actual width " << width << " result: " << compareValue(width, *length, op)); 572 return compareValue(width, *length, op); 575 573 } 576 574
Note:
See TracChangeset
for help on using the changeset viewer.