Source/modules/screen_orientation/ScreenOrientationController.cpp
// Compute the screen orientation using the orientation angle and the screen width / height.
Compute the screen orientation using the orientation angle and the screen width / height.
Compute the screen orientation using the orientation angle and the screen width / height .
blink::WebScreenOrientationType ScreenOrientationController::computeOrientation(FrameView* view)
{
    if (isRunningLayoutTest())
        return blink::WebScreenOrientationPortraitPrimary;
    FloatRect rect = screenRect(view);
    uint16_t rotation = screenOrientationAngle(view);
    bool isTallDisplay = rotation % 180 ? rect.height() < rect.width() : rect.height() > rect.width();
    switch (rotation) {
    case 0:
        return isTallDisplay ? blink::WebScreenOrientationPortraitPrimary : blink::WebScreenOrientationLandscapePrimary;
    case 90:
        return isTallDisplay ? blink::WebScreenOrientationLandscapePrimary : blink::WebScreenOrientationPortraitSecondary;
    case 180:
        return isTallDisplay ? blink::WebScreenOrientationPortraitSecondary : blink::WebScreenOrientationLandscapeSecondary;
    case 270:
        return isTallDisplay ? blink::WebScreenOrientationLandscapeSecondary : blink::WebScreenOrientationPortraitPrimary;
    default:
        ASSERT_NOT_REACHED();
        return blink::WebScreenOrientationPortraitPrimary;
    }
}
blink :: WebScreenOrientationType ScreenOrientationController :: computeOrientation ( FrameView * view ) { if ( isRunningLayoutTest ( ) ) return blink :: WebScreenOrientationPortraitPrimary ; FloatRect rect = screenRect ( view ) ; uint16_t rotation = screenOrientationAngle ( view ) ; bool isTallDisplay = rotation % 180 ? rect . height ( ) < rect . width ( ) : rect . height ( ) > rect . width ( ) ; switch ( rotation ) { case 0 : return isTallDisplay ? blink :: WebScreenOrientationPortraitPrimary : blink :: WebScreenOrientationLandscapePrimary ; case 90 : return isTallDisplay ? blink :: WebScreenOrientationLandscapePrimary : blink :: WebScreenOrientationPortraitSecondary ; case 180 : return isTallDisplay ? blink :: WebScreenOrientationPortraitSecondary : blink :: WebScreenOrientationLandscapeSecondary ; case 270 : return isTallDisplay ? blink :: WebScreenOrientationLandscapeSecondary : blink :: WebScreenOrientationPortraitPrimary ; default : ASSERT_NOT_REACHED ( ) ; return blink :: WebScreenOrientationPortraitPrimary ; } }
Compute the screen orientation using the orientation angle and the screen width / height.
Compute the screen orientation using the orientation angle and the screen width / height .
// Bypass orientation detection in layout tests to get consistent results. // FIXME: The screen dimension should be fixed when running the layout tests to avoid such // issues.