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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 2908933002: Make PageSizeType an enum class. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | 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 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 8 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
9 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 9 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
10 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 10 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return FloatSize(0, 0); 365 return FloatSize(0, 0);
366 } 366 }
367 } 367 }
368 368
369 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) {} 369 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) {}
370 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) {} 370 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) {}
371 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state, 371 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state,
372 const CSSValue& value) { 372 const CSSValue& value) {
373 state.Style()->ResetPageSizeType(); 373 state.Style()->ResetPageSizeType();
374 FloatSize size; 374 FloatSize size;
375 PageSizeType page_size_type = PAGE_SIZE_AUTO; 375 PageSizeType page_size_type = PageSizeType::kAuto;
376 const CSSValueList& list = ToCSSValueList(value); 376 const CSSValueList& list = ToCSSValueList(value);
377 if (list.length() == 2) { 377 if (list.length() == 2) {
378 // <length>{2} | <page-size> <orientation> 378 // <length>{2} | <page-size> <orientation>
379 const CSSValue& first = list.Item(0); 379 const CSSValue& first = list.Item(0);
380 const CSSValue& second = list.Item(1); 380 const CSSValue& second = list.Item(1);
381 if (first.IsPrimitiveValue() && ToCSSPrimitiveValue(first).IsLength()) { 381 if (first.IsPrimitiveValue() && ToCSSPrimitiveValue(first).IsLength()) {
382 // <length>{2} 382 // <length>{2}
383 size = FloatSize( 383 size = FloatSize(
384 ToCSSPrimitiveValue(first).ComputeLength<float>( 384 ToCSSPrimitiveValue(first).ComputeLength<float>(
385 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)), 385 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)),
386 ToCSSPrimitiveValue(second).ComputeLength<float>( 386 ToCSSPrimitiveValue(second).ComputeLength<float>(
387 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0))); 387 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)));
388 } else { 388 } else {
389 // <page-size> <orientation> 389 // <page-size> <orientation>
390 size = GetPageSizeFromName(ToCSSIdentifierValue(first)); 390 size = GetPageSizeFromName(ToCSSIdentifierValue(first));
391 391
392 DCHECK(ToCSSIdentifierValue(second).GetValueID() == CSSValueLandscape || 392 DCHECK(ToCSSIdentifierValue(second).GetValueID() == CSSValueLandscape ||
393 ToCSSIdentifierValue(second).GetValueID() == CSSValuePortrait); 393 ToCSSIdentifierValue(second).GetValueID() == CSSValuePortrait);
394 if (ToCSSIdentifierValue(second).GetValueID() == CSSValueLandscape) 394 if (ToCSSIdentifierValue(second).GetValueID() == CSSValueLandscape)
395 size = size.TransposedSize(); 395 size = size.TransposedSize();
396 } 396 }
397 page_size_type = PAGE_SIZE_RESOLVED; 397 page_size_type = PageSizeType::kResolved;
398 } else { 398 } else {
399 DCHECK_EQ(list.length(), 1U); 399 DCHECK_EQ(list.length(), 1U);
400 // <length> | auto | <page-size> | [ portrait | landscape] 400 // <length> | auto | <page-size> | [ portrait | landscape]
401 const CSSValue& first = list.Item(0); 401 const CSSValue& first = list.Item(0);
402 if (first.IsPrimitiveValue() && ToCSSPrimitiveValue(first).IsLength()) { 402 if (first.IsPrimitiveValue() && ToCSSPrimitiveValue(first).IsLength()) {
403 // <length> 403 // <length>
404 page_size_type = PAGE_SIZE_RESOLVED; 404 page_size_type = PageSizeType::kResolved;
405 float width = ToCSSPrimitiveValue(first).ComputeLength<float>( 405 float width = ToCSSPrimitiveValue(first).ComputeLength<float>(
406 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0)); 406 state.CssToLengthConversionData().CopyWithAdjustedZoom(1.0));
407 size = FloatSize(width, width); 407 size = FloatSize(width, width);
408 } else { 408 } else {
409 const CSSIdentifierValue& ident = ToCSSIdentifierValue(first); 409 const CSSIdentifierValue& ident = ToCSSIdentifierValue(first);
410 switch (ident.GetValueID()) { 410 switch (ident.GetValueID()) {
411 case CSSValueAuto: 411 case CSSValueAuto:
412 page_size_type = PAGE_SIZE_AUTO; 412 page_size_type = PageSizeType::kAuto;
413 break; 413 break;
414 case CSSValuePortrait: 414 case CSSValuePortrait:
415 page_size_type = PAGE_SIZE_AUTO_PORTRAIT; 415 page_size_type = PageSizeType::kPortrait;
416 break; 416 break;
417 case CSSValueLandscape: 417 case CSSValueLandscape:
418 page_size_type = PAGE_SIZE_AUTO_LANDSCAPE; 418 page_size_type = PageSizeType::kLandscape;
419 break; 419 break;
420 default: 420 default:
421 // <page-size> 421 // <page-size>
422 page_size_type = PAGE_SIZE_RESOLVED; 422 page_size_type = PageSizeType::kResolved;
423 size = GetPageSizeFromName(ident); 423 size = GetPageSizeFromName(ident);
424 } 424 }
425 } 425 }
426 } 426 }
427 state.Style()->SetPageSizeType(page_size_type); 427 state.Style()->SetPageSizeType(page_size_type);
428 state.Style()->SetPageSize(size); 428 state.Style()->SetPageSize(size);
429 } 429 }
430 430
431 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign( 431 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(
432 StyleResolverState& state, 432 StyleResolverState& state,
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 state.Style()->SetCaretColor( 987 state.Style()->SetCaretColor(
988 StyleBuilderConverter::ConvertStyleAutoColor(state, value)); 988 StyleBuilderConverter::ConvertStyleAutoColor(state, value));
989 } 989 }
990 if (state.ApplyPropertyToVisitedLinkStyle()) { 990 if (state.ApplyPropertyToVisitedLinkStyle()) {
991 state.Style()->SetVisitedLinkCaretColor( 991 state.Style()->SetVisitedLinkCaretColor(
992 StyleBuilderConverter::ConvertStyleAutoColor(state, value, true)); 992 StyleBuilderConverter::ConvertStyleAutoColor(state, value, true));
993 } 993 }
994 } 994 }
995 995
996 } // namespace blink 996 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698