Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: Source/core/css/MediaQueryEvaluator.cpp

Issue 14659008: Include scrollbar size in @media width/height (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * CSS Media Query Evaluator 2 * CSS Media Query Evaluator
3 * 3 *
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
5 * Copyright (C) 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 return false; 242 return false;
243 } 243 }
244 244
245 return colorMediaFeatureEval(value, style, frame, op); 245 return colorMediaFeatureEval(value, style, frame, op);
246 } 246 }
247 247
248 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr ame, MediaFeaturePrefix) 248 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr ame, MediaFeaturePrefix)
249 { 249 {
250 FrameView* view = frame->view(); 250 FrameView* view = frame->view();
251 int width = view->layoutWidth(); 251 int width = view->mediaWidth();
252 int height = view->layoutHeight(); 252 int height = view->mediaHeight();
253 if (value && value->isPrimitiveValue()) { 253 if (value && value->isPrimitiveValue()) {
254 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent(); 254 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent();
255 if (width > height) // Square viewport is portrait. 255 if (width > height) // Square viewport is portrait.
256 return CSSValueLandscape == id; 256 return CSSValueLandscape == id;
257 return CSSValuePortrait == id; 257 return CSSValuePortrait == id;
258 } 258 }
259 259
260 // Expression (orientation) evaluates to true if width and height >= 0. 260 // Expression (orientation) evaluates to true if width and height >= 0.
261 return height >= 0 && width >= 0; 261 return height >= 0 && width >= 0;
262 } 262 }
263 263
264 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f rame, MediaFeaturePrefix op) 264 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f rame, MediaFeaturePrefix op)
265 { 265 {
266 if (value) { 266 if (value) {
267 FrameView* view = frame->view(); 267 FrameView* view = frame->view();
268 return compareAspectRatioValue(value, view->layoutWidth(), view->layoutH eight(), op); 268 return compareAspectRatioValue(value, view->mediaWidth(), view->mediaHei ght(), op);
269 } 269 }
270 270
271 // ({,min-,max-}aspect-ratio) 271 // ({,min-,max-}aspect-ratio)
272 // assume if we have a device, its aspect ratio is non-zero 272 // assume if we have a device, its aspect ratio is non-zero
273 return true; 273 return true;
274 } 274 }
275 275
276 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, F rame* frame, MediaFeaturePrefix op) 276 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, F rame* frame, MediaFeaturePrefix op)
277 { 277 {
278 if (value) { 278 if (value) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // ({,min-,max-}device-width) 469 // ({,min-,max-}device-width)
470 // assume if we have a device, assume non-zero 470 // assume if we have a device, assume non-zero
471 return true; 471 return true;
472 } 472 }
473 473
474 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op) 474 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op)
475 { 475 {
476 FrameView* view = frame->view(); 476 FrameView* view = frame->view();
477 477
478 if (value) { 478 if (value) {
479 int height = view->layoutHeight(); 479 int height = view->mediaHeight();
480 if (RenderView* renderView = frame->document()->renderView()) 480 if (RenderView* renderView = frame->document()->renderView())
481 height = adjustForAbsoluteZoom(height, renderView); 481 height = adjustForAbsoluteZoom(height, renderView);
482 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 482 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
483 int length; 483 int length;
484 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(height, length, op); 484 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(height, length, op);
485 } 485 }
486 486
487 return view->layoutHeight() != 0; 487 return view->mediaHeight();
488 } 488 }
489 489
490 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op) 490 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op)
491 { 491 {
492 FrameView* view = frame->view(); 492 FrameView* view = frame->view();
493 493
494 if (value) { 494 if (value) {
495 int width = view->layoutWidth(); 495 int width = view->mediaWidth();
496 if (RenderView* renderView = frame->document()->renderView()) 496 if (RenderView* renderView = frame->document()->renderView())
497 width = adjustForAbsoluteZoom(width, renderView); 497 width = adjustForAbsoluteZoom(width, renderView);
498 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 498 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
499 int length; 499 int length;
500 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(width, length, op); 500 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(width, length, op);
501 } 501 }
502 502
503 return view->layoutWidth() != 0; 503 return view->mediaWidth();
504 } 504 }
505 505
506 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used 506 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used
507 507
508 static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix) 508 static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix)
509 { 509 {
510 return colorMediaFeatureEval(value, style, frame, MinPrefix); 510 return colorMediaFeatureEval(value, style, frame, MinPrefix);
511 } 511 }
512 512
513 static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix) 513 static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 // and let trampoline functions override the prefix if prefix is 745 // and let trampoline functions override the prefix if prefix is
746 // used 746 // used
747 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); 747 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
748 if (func) 748 if (func)
749 return func(expr->value(), m_style.get(), m_frame, NoPrefix); 749 return func(expr->value(), m_style.get(), m_frame, NoPrefix);
750 750
751 return false; 751 return false;
752 } 752 }
753 753
754 } // namespace 754 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698