Bug 25197 - implement orientation and aspect-ratio media queries
Summary: implement orientation and aspect-ratio media queries
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2009-04-14 17:58 PDT by Dean Jackson
Modified: 2009-05-14 16:15 PDT (History)
1 user (show)

See Also:


Attachments
patch (9.63 KB, patch)
2009-04-15 12:40 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
patch now does live updating (10.99 KB, patch)
2009-04-15 19:44 PDT, Dean Jackson
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2009-04-14 17:58:30 PDT
http://www.w3.org/TR/css3-mediaqueries/#orientation

We don't yet implement orientation and aspect-ratio

<rdar://problem/6791666>
Comment 1 Dean Jackson 2009-04-15 12:40:18 PDT
Created attachment 29512 [details]
patch

obviously patch needs PNG pixel results too.
Comment 2 Dean Jackson 2009-04-15 12:45:50 PDT
Hmmm.. Firefox reevaluates media queries as the page resizes.
Comment 3 Dean Jackson 2009-04-15 19:44:02 PDT
Created attachment 29524 [details]
patch now does live updating

patch now links up viewport changes to re-evaluation
Comment 4 Simon Fraser (smfr) 2009-05-12 11:16:12 PDT
Comment on attachment 29524 [details]
patch now does live updating

> +static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)
> +{
> +    if (value) {

An early return if !(value) would make the code simpler.

> +        FrameView* view = frame->view();
> +        int width = view->layoutWidth();
> +        int height = view->layoutHeight();
> +        if (width > height) // Square viewport is portrait
> +            return "landscape" == static_cast<CSSPrimitiveValue*>(value)->getStringValue();
> +        else
> +            return "portrait" == static_cast<CSSPrimitiveValue*>(value)->getStringValue();

Don't use 'else' after 'return'.

> +static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
> +{
> +    if (value) {

Prefer early return.

r=me
Comment 5 Dean Jackson 2009-05-14 16:15:13 PDT
Committed r43739
	M	WebCore/ChangeLog
	M	WebCore/css/MediaQueryExp.h
	M	WebCore/css/MediaFeatureNames.h
	M	WebCore/css/MediaQueryEvaluator.cpp
	A	LayoutTests/platform/mac/fast/media/mq-aspect-ratio-expected.checksum
	A	LayoutTests/platform/mac/fast/media/mq-orientation-expected.png
	A	LayoutTests/platform/mac/fast/media/mq-orientation-expected.txt
	A	LayoutTests/platform/mac/fast/media/mq-aspect-ratio-expected.png
	A	LayoutTests/platform/mac/fast/media/mq-orientation-expected.checksum
	A	LayoutTests/platform/mac/fast/media/mq-aspect-ratio-expected.txt
	M	LayoutTests/ChangeLog
	A	LayoutTests/fast/media/mq-orientation.html
	A	LayoutTests/fast/media/mq-aspect-ratio.html

with early return fix, and no else