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

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: layoutSize(VisibleContentRectIncludesScrollbars) 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (value) { 238 if (value) {
239 float number; 239 float number;
240 return numberValue(value, number) && compareValue(0, static_cast<int >(number), op); 240 return numberValue(value, number) && compareValue(0, static_cast<int >(number), op);
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 IntSize viewportSize(FrameView* view)
249 {
250 return view->layoutSize(ScrollableArea::IncludeScrollbars);
251 }
252
248 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr ame, MediaFeaturePrefix) 253 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* fr ame, MediaFeaturePrefix)
249 { 254 {
250 FrameView* view = frame->view(); 255 FrameView* view = frame->view();
251 int width = view->layoutWidth(); 256 int width = viewportSize(view).width();
252 int height = view->layoutHeight(); 257 int height = viewportSize(view).height();
253 if (value && value->isPrimitiveValue()) { 258 if (value && value->isPrimitiveValue()) {
254 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent(); 259 const int id = static_cast<CSSPrimitiveValue*>(value)->getIdent();
255 if (width > height) // Square viewport is portrait. 260 if (width > height) // Square viewport is portrait.
256 return CSSValueLandscape == id; 261 return CSSValueLandscape == id;
257 return CSSValuePortrait == id; 262 return CSSValuePortrait == id;
258 } 263 }
259 264
260 // Expression (orientation) evaluates to true if width and height >= 0. 265 // Expression (orientation) evaluates to true if width and height >= 0.
261 return height >= 0 && width >= 0; 266 return height >= 0 && width >= 0;
262 } 267 }
263 268
264 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f rame, MediaFeaturePrefix op) 269 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f rame, MediaFeaturePrefix op)
265 { 270 {
266 if (value) { 271 if (value) {
267 FrameView* view = frame->view(); 272 FrameView* view = frame->view();
268 return compareAspectRatioValue(value, view->layoutWidth(), view->layoutH eight(), op); 273 return compareAspectRatioValue(value, viewportSize(view).width(), viewpo rtSize(view).height(), op);
269 } 274 }
270 275
271 // ({,min-,max-}aspect-ratio) 276 // ({,min-,max-}aspect-ratio)
272 // assume if we have a device, its aspect ratio is non-zero 277 // assume if we have a device, its aspect ratio is non-zero
273 return true; 278 return true;
274 } 279 }
275 280
276 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, F rame* frame, MediaFeaturePrefix op) 281 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, F rame* frame, MediaFeaturePrefix op)
277 { 282 {
278 if (value) { 283 if (value) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 473 }
469 // ({,min-,max-}device-width) 474 // ({,min-,max-}device-width)
470 // assume if we have a device, assume non-zero 475 // assume if we have a device, assume non-zero
471 return true; 476 return true;
472 } 477 }
473 478
474 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op) 479 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op)
475 { 480 {
476 FrameView* view = frame->view(); 481 FrameView* view = frame->view();
477 482
483 int height = viewportSize(view).height();
478 if (value) { 484 if (value) {
479 int height = view->layoutHeight();
480 if (RenderView* renderView = frame->document()->renderView()) 485 if (RenderView* renderView = frame->document()->renderView())
481 height = adjustForAbsoluteZoom(height, renderView); 486 height = adjustForAbsoluteZoom(height, renderView);
482 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 487 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
483 int length; 488 int length;
484 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(height, length, op); 489 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(height, length, op);
485 } 490 }
486 491
487 return view->layoutHeight() != 0; 492 return height;
488 } 493 }
489 494
490 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op) 495 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op)
491 { 496 {
492 FrameView* view = frame->view(); 497 FrameView* view = frame->view();
493 498
499 int width = viewportSize(view).width();
494 if (value) { 500 if (value) {
495 int width = view->layoutWidth();
496 if (RenderView* renderView = frame->document()->renderView()) 501 if (RenderView* renderView = frame->document()->renderView())
497 width = adjustForAbsoluteZoom(width, renderView); 502 width = adjustForAbsoluteZoom(width, renderView);
498 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 503 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
499 int length; 504 int length;
500 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(width, length, op); 505 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(width, length, op);
501 } 506 }
502 507
503 return view->layoutWidth() != 0; 508 return width;
504 } 509 }
505 510
506 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used 511 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used
507 512
508 static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix) 513 static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix)
509 { 514 {
510 return colorMediaFeatureEval(value, style, frame, MinPrefix); 515 return colorMediaFeatureEval(value, style, frame, MinPrefix);
511 } 516 }
512 517
513 static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame * frame, MediaFeaturePrefix) 518 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 750 // and let trampoline functions override the prefix if prefix is
746 // used 751 // used
747 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); 752 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
748 if (func) 753 if (func)
749 return func(expr->value(), m_style.get(), m_frame, NoPrefix); 754 return func(expr->value(), m_style.get(), m_frame, NoPrefix);
750 755
751 return false; 756 return false;
752 } 757 }
753 758
754 } // namespace 759 } // namespace
OLDNEW
« no previous file with comments | « LayoutTests/fast/media/mq-size-include-scrollbars-expected.html ('k') | Source/core/platform/ScrollView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698