Changeset 132490 in webkit
- Timestamp:
- Oct 25, 2012 8:58:21 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r132488 r132490 1 2012-10-25 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 'resolution' MQ: Printing should use use high resolution images when available 4 https://bugs.webkit.org/show_bug.cgi?id=100382 5 6 Reviewed by Antti Koivisto. 7 8 Special case print to not use the dpi of the screen, but one of 300. 9 10 Updated the resolution media query test to cover this. 11 12 * fast/media/mq-resolution-expected.txt: 13 * fast/media/mq-resolution.html: 14 1 15 2012-10-25 Kevin Ellis <kevers@chromium.org> 2 16 -
trunk/LayoutTests/fast/media/mq-resolution-expected.txt
r132227 r132490 35 35 PASS matchMedia('(max-resolution: 85dpcm)').matches is false 36 36 PASS matchMedia('(max-resolution: 100dpcm)').matches is true 37 PASS matchMedia('(min-resolution: 300dpi)').matches is true 38 PASS matchMedia('(min-resolution: 118dpcm)').matches is true 39 PASS resolutionFromStyle() is 3 40 PASS resolutionFromStyle() is 3.125 37 41 PASS successfullyParsed is true 38 42 -
trunk/LayoutTests/fast/media/mq-resolution.html
r132227 r132490 7 7 8 8 <style> 9 #detector { width: 10 px; }9 #detector { width: 100px; } 10 10 @media (resolution: 1.00dppx) { #detector { width: 10px; } } 11 11 @media (resolution: 1.50dppx) { #detector { width: 15px; } } 12 12 @media (resolution: 2.00dppx) { #detector { width: 20px; } } 13 13 @media (resolution: 2.25dppx) { #detector { width: 23px; } } 14 @media print and (min-resolution: 3dppx) { #detector { width: 30px; } } 14 15 </style> 15 16 … … 31 32 case "23px": 32 33 return 2.25; 34 case "30px": 35 return 3; 36 case "31px": 37 return 3.125; 33 38 default: 34 39 return undefined; 35 40 } 41 } 42 43 function appendMediaRule(rule) { 44 var lastStyleSheet = document.styleSheets[document.styleSheets.length - 1]; 45 lastStyleSheet.insertRule(rule, lastStyleSheet.cssRules.length); 36 46 } 37 47 … … 83 93 shouldBe("matchMedia('(max-resolution: 85dpcm)').matches", "false"); 84 94 shouldBe("matchMedia('(max-resolution: 100dpcm)').matches", "true"); 95 96 // Test printing. 97 98 window.internals.settings.setMediaTypeOverride("print"); 99 shouldBe("matchMedia('(min-resolution: 300dpi)').matches", "true"); 100 shouldBe("matchMedia('(min-resolution: 118dpcm)').matches", "true"); 101 102 // Should match the one requiring 'print' media type. 103 shouldBe("resolutionFromStyle()", "3"); 104 105 // As well as those matching 'all'. 106 appendMediaRule("@media (resolution: 3.125dppx) { #detector { width: 31px; } }"); 107 shouldBe("resolutionFromStyle()", "3.125"); 85 108 } 86 109 </script> -
trunk/Source/WebCore/ChangeLog
r132489 r132490 1 2012-10-25 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 'resolution' MQ: Printing should use use high resolution images when available 4 https://bugs.webkit.org/show_bug.cgi?id=100382 5 6 Reviewed by Antti Koivisto. 7 8 Special case print to not use the dpi of the screen, but one of 300. 9 10 Updated the resolution media query test to cover this. 11 12 * css/MediaQueryEvaluator.cpp: 13 (WebCore::resolutionMediaFeatureEval): Update compared decimal points 14 to three, due to 300 / 96 being equal to 3.125. 15 1 16 2012-10-25 Kinuko Yasuda <kinuko@chromium.org> 2 17 -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r132227 r132490 316 316 // round((220 * 1.0 / 96) * 4) / 4 = 2.0 317 317 318 float horiDPI = frame->document()->domWindow()->screen()->horizontalDPI(); 319 float vertDPI = frame->document()->domWindow()->screen()->verticalDPI(); 318 float horiDPI; 319 float vertDPI; 320 321 // This checks the actual media type applied to the document, and we know 322 // this method only got called if this media type matches the one defined 323 // in the query. Thus, if if the document's media type is "print", the 324 // media type of the query will either be "print" or "all". 325 String mediaType = frame->view()->mediaType(); 326 if (equalIgnoringCase(mediaType, "screen")) { 327 Screen* screen = frame->document()->domWindow()->screen(); 328 horiDPI = screen->horizontalDPI(); 329 vertDPI = screen->verticalDPI(); 330 } else if (equalIgnoringCase(mediaType, "print")) { 331 // The resolution of images while printing should not depend on the dpi 332 // of the screen. Until we support proper ways of querying this info 333 // we use 300px which is considered minimum for current printers. 334 horiDPI = vertDPI = 300; 335 } else { 336 // FIXME: Possible handle other media types than 'screen' and 'print'. 337 // For now, do not match. 338 return false; 339 } 320 340 321 341 float leastDenseDPI = std::min(horiDPI, vertDPI); … … 345 365 // http://dev.w3.org/csswg/css3-values/#absolute-lengths recommends 346 366 // "that the pixel unit refer to the whole number of device pixels that 347 // best approximates the reference pixel". We compare with 2decimal367 // best approximates the reference pixel". We compare with 3 decimal 348 368 // points, which aligns with current device-pixel-ratio's in use. 349 float leastDenseDensity = floorf(leastDenseDPI * 100 / 96) / 100;350 float mostDenseDensity = floorf(leastDenseDPI * 100 / 96) / 100;369 float leastDenseDensity = floorf(leastDenseDPI * 1000 / 96) / 1000; 370 float mostDenseDensity = floorf(leastDenseDPI * 1000 / 96) / 1000; 351 371 float testedDensity = rawValue->getFloatValue(CSSPrimitiveValue::CSS_DPPX); 352 372 return compareResolution(leastDenseDensity, mostDenseDensity, testedDensity, op);
Note: See TracChangeset
for help on using the changeset viewer.