static WebScreenOrientationLockType stringToOrientationLock(const AtomicString& orientationLockString) { unsigned length = 0; ScreenOrientationInfo* orientationMap = orientationsMap(length); for (unsigned i = 0; i < length; ++i) { if (orientationMap[i].name == orientationLockString) return static_cast<WebScreenOrientationLockType>(orientationMap[i].orientation); } ASSERT_NOT_REACHED(); return WebScreenOrientationLockDefault; }
const AtomicString& ScreenOrientation::orientationTypeToString(WebScreenOrientationType orientation) { unsigned length = 0; ScreenOrientationInfo* orientationMap = orientationsMap(length); for (unsigned i = 0; i < length; ++i) { if (static_cast<unsigned>(orientation) == orientationMap[i].orientation) return orientationMap[i].name; } ASSERT_NOT_REACHED(); return nullAtom; }
static const AtomicString& orientationToString(blink::WebScreenOrientation orientation) { unsigned length = 0; ScreenOrientationInfo* orientationMap = orientationsMap(length); for (unsigned i = 0; i < length; ++i) { if (orientationMap[i].orientation == orientation) return orientationMap[i].name; } // We do no handle OrientationInvalid and OrientationAny but this is fine because screen.orientation // should never return these and WebScreenOrientation does not define those values. ASSERT_NOT_REACHED(); return nullAtom; }
static blink::WebScreenOrientations stringToOrientations(const AtomicString& orientationString) { DEFINE_STATIC_LOCAL(const AtomicString, portrait, ("portrait", AtomicString::ConstructFromLiteral)); DEFINE_STATIC_LOCAL(const AtomicString, landscape, ("landscape", AtomicString::ConstructFromLiteral)); if (orientationString == portrait) return blink::WebScreenOrientationPortraitPrimary | blink::WebScreenOrientationPortraitSecondary; if (orientationString == landscape) return blink::WebScreenOrientationLandscapePrimary | blink::WebScreenOrientationLandscapeSecondary; unsigned length = 0; ScreenOrientationInfo* orientationMap = orientationsMap(length); for (unsigned i = 0; i < length; ++i) { if (orientationMap[i].name == orientationString) return orientationMap[i].orientation; } return 0; }