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

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

Issue 18360007: MediaQueryEvaluator should use default style for evaluating "rem". Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added layout test for seamless iframe Created 7 years, 5 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
« no previous file with comments | « LayoutTests/fast/frames/seamless/media-query-basing-rem-unit-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Copyright (C) 2013 Intel Corporation. All rights reserved. 6 * Copyright (C) 2013 Intel Corporation. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFea turePrefix op) 327 static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFea turePrefix op)
328 { 328 {
329 // if output device is bitmap, grid: 0 == true 329 // if output device is bitmap, grid: 0 == true
330 // assume we have bitmap device 330 // assume we have bitmap device
331 float number; 331 float number;
332 if (value && numberValue(value, number)) 332 if (value && numberValue(value, number))
333 return compareValue(static_cast<int>(number), 0, op); 333 return compareValue(static_cast<int>(number), 0, op);
334 return false; 334 return false;
335 } 335 }
336 336
337 static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, Rend erStyle* rootStyle, int& result) 337 static bool computeLength(Document* document, CSSValue* value, RenderStyle* styl e, RenderStyle* rootStyle, int& result)
338 { 338 {
339 if (!value->isPrimitiveValue()) 339 if (!value->isPrimitiveValue())
340 return false; 340 return false;
341 341
342 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 342 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
343 343
344 if (primitiveValue->isNumber()) { 344 if (primitiveValue->isNumber()) {
345 result = primitiveValue->getIntValue(); 345 result = primitiveValue->getIntValue();
346 bool strict = !document->inQuirksMode();
346 return !strict || !result; 347 return !strict || !result;
347 } 348 }
348 349
350 if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_REMS) {
351 // Use the initial font size instead of <html> font size.
352 RefPtr<RenderStyle> defaultStyle = StyleResolver::styleForDocument(docum ent);
353 result = primitiveValue->computeLength<int>(style, defaultStyle.get(), 1 .0 /* multiplier */, true /* computingFontSize */);
354 return true;
355 }
356
349 if (primitiveValue->isLength()) { 357 if (primitiveValue->isLength()) {
350 result = primitiveValue->computeLength<int>(style, rootStyle, 1.0 /* mul tiplier */, true /* computingFontSize */); 358 result = primitiveValue->computeLength<int>(style, rootStyle, 1.0 /* mul tiplier */, true /* computingFontSize */);
351 return true; 359 return true;
352 } 360 }
353 361
354 return false; 362 return false;
355 } 363 }
356 364
357 static bool deviceHeightMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr ame* frame, MediaFeaturePrefix op) 365 static bool deviceHeightMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr ame* frame, MediaFeaturePrefix op)
358 { 366 {
359 if (value) { 367 if (value) {
360 FloatRect sg = screenRect(frame->page()->mainFrame()->view()); 368 FloatRect sg = screenRect(frame->page()->mainFrame()->view());
361 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 369 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
362 int length; 370 int length;
363 long height = sg.height(); 371 long height = sg.height();
364 InspectorInstrumentation::applyScreenHeightOverride(frame, &height); 372 InspectorInstrumentation::applyScreenHeightOverride(frame, &height);
365 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(static_cast<int>(height), length, op); 373 return computeLength(frame->document(), value, style, rootStyle, length) && compareValue(static_cast<int>(height), length, op);
366 } 374 }
367 // ({,min-,max-}device-height) 375 // ({,min-,max-}device-height)
368 // assume if we have a device, assume non-zero 376 // assume if we have a device, assume non-zero
369 return true; 377 return true;
370 } 378 }
371 379
372 static bool deviceWidthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fra me* frame, MediaFeaturePrefix op) 380 static bool deviceWidthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fra me* frame, MediaFeaturePrefix op)
373 { 381 {
374 if (value) { 382 if (value) {
375 FloatRect sg = screenRect(frame->page()->mainFrame()->view()); 383 FloatRect sg = screenRect(frame->page()->mainFrame()->view());
376 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 384 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
377 int length; 385 int length;
378 long width = sg.width(); 386 long width = sg.width();
379 InspectorInstrumentation::applyScreenWidthOverride(frame, &width); 387 InspectorInstrumentation::applyScreenWidthOverride(frame, &width);
380 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(static_cast<int>(width), length, op); 388 return computeLength(frame->document(), value, style, rootStyle, length) && compareValue(static_cast<int>(width), length, op);
381 } 389 }
382 // ({,min-,max-}device-width) 390 // ({,min-,max-}device-width)
383 // assume if we have a device, assume non-zero 391 // assume if we have a device, assume non-zero
384 return true; 392 return true;
385 } 393 }
386 394
387 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op) 395 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f rame, MediaFeaturePrefix op)
388 { 396 {
389 FrameView* view = frame->view(); 397 FrameView* view = frame->view();
390 398
391 int height = viewportSize(view).height(); 399 int height = viewportSize(view).height();
392 if (value) { 400 if (value) {
393 if (RenderView* renderView = frame->document()->renderView()) 401 if (RenderView* renderView = frame->document()->renderView())
394 height = adjustForAbsoluteZoom(height, renderView); 402 height = adjustForAbsoluteZoom(height, renderView);
395 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 403 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
396 int length; 404 int length;
397 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(height, length, op); 405 return computeLength(frame->document(), value, style, rootStyle, length) && compareValue(height, length, op);
398 } 406 }
399 407
400 return height; 408 return height;
401 } 409 }
402 410
403 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op) 411 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr ame, MediaFeaturePrefix op)
404 { 412 {
405 FrameView* view = frame->view(); 413 FrameView* view = frame->view();
406 414
407 int width = viewportSize(view).width(); 415 int width = viewportSize(view).width();
408 if (value) { 416 if (value) {
409 if (RenderView* renderView = frame->document()->renderView()) 417 if (RenderView* renderView = frame->document()->renderView())
410 width = adjustForAbsoluteZoom(width, renderView); 418 width = adjustForAbsoluteZoom(width, renderView);
411 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le(); 419 RenderStyle* rootStyle = frame->document()->documentElement()->renderSty le();
412 int length; 420 int length;
413 return computeLength(value, !frame->document()->inQuirksMode(), style, r ootStyle, length) && compareValue(width, length, op); 421 return computeLength(frame->document(), value, style, rootStyle, length) && compareValue(width, length, op);
414 } 422 }
415 423
416 return width; 424 return width;
417 } 425 }
418 426
419 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used 427 // rest of the functions are trampolines which set the prefix according to the m edia feature expression used
420 428
421 static bool minColorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix) 429 static bool minColorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
422 { 430 {
423 return colorMediaFeatureEval(value, style, frame, MinPrefix); 431 return colorMediaFeatureEval(value, style, frame, MinPrefix);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // and let trampoline functions override the prefix if prefix is 693 // and let trampoline functions override the prefix if prefix is
686 // used 694 // used
687 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); 695 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
688 if (func) 696 if (func)
689 return func(expr->value(), m_style.get(), m_frame, NoPrefix); 697 return func(expr->value(), m_style.get(), m_frame, NoPrefix);
690 698
691 return false; 699 return false;
692 } 700 }
693 701
694 } // namespace 702 } // namespace
OLDNEW
« no previous file with comments | « LayoutTests/fast/frames/seamless/media-query-basing-rem-unit-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698