Changeset 27581 in webkit


Ignore:
Timestamp:
Nov 7, 2007 1:54:57 PM (16 years ago)
Author:
ddkilzer
Message:

WebCore:

WebKit confuses width/height for Media Queries device-aspect-ratio evaluation
<http://bugs.webkit.org/show_bug.cgi?id=14893>
<rdar://problem/5380295>

Reviewed by Darin.

Tests: fast/css/device-aspect-ratio.html

fast/css/max-device-aspect-ratio.html
fast/css/min-device-aspect-ratio.html

  • css/MediaQueryEvaluator.cpp: (WebCore::parseAspectRatio): Renamed method parameters from a/b to h/v. (WebCore::device_aspect_ratioMediaFeatureEval): Renamed local variables from a/b to h/v. Switched first two arguments of the call to cmpvalue() to fix the bug.

LayoutTests:

WebKit confuses width/height for Media Queries device-aspect-ratio evaluation
<http://bugs.webkit.org/show_bug.cgi?id=14893>
<rdar://problem/5380295>

Reviewed by Darin.

Each of the following tests creates a <link> element and dynamically sets its
media query based on the aspect ratio (width/height) of the current screen.
When the <link> element is attached to the <head> node, the test expects the
stylesheet to be loaded for the test to pass.

  • fast/css/device-aspect-ratio-expected.txt: Added.
  • fast/css/device-aspect-ratio.html: Added.

This test sets the device-aspect-ratio to the current size of the screen.
NOTE: This test passed before the fix.

  • fast/css/max-device-aspect-ratio-expected.txt: Added.
  • fast/css/max-device-aspect-ratio.html: Added.

This test sets the max-device-aspect ratio to 100/1 for landscape monitors or
1/1 for portrait (or square) monitors.
NOTE: This test failed before the fix.

  • fast/css/min-device-aspect-ratio-expected.txt: Added.
  • fast/css/min-device-aspect-ratio.html: Added.

This test sets the min-device-aspect ratio to 1/1 for landscape monitors or
1/100 for portrait (or square) monitors.
NOTE: This test failed before the fix.

  • fast/css/resources/device-aspect-ratio.css: Added.
Location:
trunk
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r27579 r27581  
     12007-11-07  David Kilzer  <ddkilzer@apple.com>
     2
     3        WebKit confuses width/height for Media Queries device-aspect-ratio evaluation
     4        <http://bugs.webkit.org/show_bug.cgi?id=14893>
     5        <rdar://problem/5380295>
     6
     7        Reviewed by Darin.
     8
     9        Each of the following tests creates a <link> element and dynamically sets its
     10        media query based on the aspect ratio (width/height) of the current screen.
     11        When the <link> element is attached to the <head> node, the test expects the
     12        stylesheet to be loaded for the test to pass.
     13
     14        * fast/css/device-aspect-ratio-expected.txt: Added.
     15        * fast/css/device-aspect-ratio.html: Added.
     16
     17        This test sets the device-aspect-ratio to the current size of the screen.
     18        NOTE: This test passed before the fix.
     19
     20        * fast/css/max-device-aspect-ratio-expected.txt: Added.
     21        * fast/css/max-device-aspect-ratio.html: Added.
     22
     23        This test sets the max-device-aspect ratio to 100/1 for landscape monitors or
     24        1/1 for portrait (or square) monitors.
     25        NOTE: This test failed before the fix.
     26
     27        * fast/css/min-device-aspect-ratio-expected.txt: Added.
     28        * fast/css/min-device-aspect-ratio.html: Added.
     29
     30        This test sets the min-device-aspect ratio to 1/1 for landscape monitors or
     31        1/100 for portrait (or square) monitors.
     32        NOTE: This test failed before the fix.
     33
     34        * fast/css/resources/device-aspect-ratio.css: Added.
     35
    1362007-11-07  Dan Bernstein  <mitz@apple.com>
    237
  • trunk/WebCore/ChangeLog

    r27580 r27581  
     12007-11-07  David Kilzer  <ddkilzer@apple.com>
     2
     3        WebKit confuses width/height for Media Queries device-aspect-ratio evaluation
     4        <http://bugs.webkit.org/show_bug.cgi?id=14893>
     5        <rdar://problem/5380295>
     6
     7        Reviewed by Darin.
     8
     9        Tests: fast/css/device-aspect-ratio.html
     10               fast/css/max-device-aspect-ratio.html
     11               fast/css/min-device-aspect-ratio.html
     12
     13        * css/MediaQueryEvaluator.cpp:
     14        (WebCore::parseAspectRatio): Renamed method parameters from a/b to h/v.
     15        (WebCore::device_aspect_ratioMediaFeatureEval): Renamed local variables from
     16        a/b to h/v.  Switched first two arguments of the call to cmpvalue() to fix
     17        the bug.
     18
    1192007-11-07  Dan Bernstein  <mitz@apple.com>
    220
  • trunk/WebCore/css/MediaQueryEvaluator.cpp

    r23916 r27581  
    155155}
    156156
    157 static bool parseAspectRatio(CSSValue* value, int& a, int& b)
     157static bool parseAspectRatio(CSSValue* value, int& h, int& v)
    158158{
    159159    if (value->isValueList()){
     
    168168                String str = static_cast<CSSPrimitiveValue*>(i1)->getStringValue();
    169169                if (!str.isNull() && str.length() == 1 && str[0] == DeprecatedChar('/')) {
    170                     a = static_cast<CSSPrimitiveValue*>(i0)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
    171                     b = static_cast<CSSPrimitiveValue*>(i2)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
     170                    h = static_cast<CSSPrimitiveValue*>(i0)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
     171                    v = static_cast<CSSPrimitiveValue*>(i2)->getIntValue(CSSPrimitiveValue::CSS_NUMBER);
    172172                    return true;
    173173                }
     
    236236    if (value) {
    237237        FloatRect sg = screenRect(page->mainFrame()->view());
    238         int a = 0;
    239         int b = 0;
    240         if (parseAspectRatio(value, a, b))
    241             return b != 0  && cmpvalue(a * (int)sg.height(), b * (int)sg.width(), op);
     238        int h = 0;
     239        int v = 0;
     240        if (parseAspectRatio(value, h, v))
     241            return v != 0  && cmpvalue((int)sg.width() * v, (int)sg.height() * h, op);
    242242        return false;
    243243    }
Note: See TracChangeset for help on using the changeset viewer.