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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 1266713003: Clean up some StyleBuilder property application code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 return ligatures; 310 return ligatures;
311 } 311 }
312 312
313 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); 313 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue());
314 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal); 314 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal);
315 return FontDescription::VariantLigatures(); 315 return FontDescription::VariantLigatures();
316 } 316 }
317 317
318 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt ate&, CSSValue* value) 318 EGlyphOrientation StyleBuilderConverter::convertGlyphOrientation(StyleResolverSt ate&, CSSValue* value)
319 { 319 {
320 if (!value->isPrimitiveValue())
321 return GO_0DEG;
322
323 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 320 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
324 if (primitiveValue->typeWithCalcResolved() != CSSPrimitiveValue::UnitType::D egrees) 321 if (primitiveValue->typeWithCalcResolved() != CSSPrimitiveValue::UnitType::D egrees)
325 return GO_0DEG; 322 return GO_0DEG;
326 323
327 float angle = fabsf(fmodf(primitiveValue->getFloatValue(), 360.0f)); 324 float angle = fabsf(fmodf(primitiveValue->getFloatValue(), 360.0f));
328 325
329 if (angle <= 45.0f || angle > 315.0f) 326 if (angle <= 45.0f || angle > 315.0f)
330 return GO_0DEG; 327 return GO_0DEG;
331 if (angle > 45.0f && angle <= 135.0f) 328 if (angle > 45.0f && angle <= 135.0f)
332 return GO_90DEG; 329 return GO_90DEG;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if (value->isPrimitiveValue()) 451 if (value->isPrimitiveValue())
455 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue( value))); 452 return GridTrackSize(convertGridTrackBreadth(state, toCSSPrimitiveValue( value)));
456 453
457 CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value); 454 CSSFunctionValue* minmaxFunction = toCSSFunctionValue(value);
458 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction->length() == 2); 455 ASSERT_WITH_SECURITY_IMPLICATION(minmaxFunction->length() == 2);
459 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(0)))); 456 GridLength minTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(0))));
460 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(1)))); 457 GridLength maxTrackBreadth(convertGridTrackBreadth(state, toCSSPrimitiveValu e(minmaxFunction->item(1))));
461 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 458 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
462 } 459 }
463 460
464 bool StyleBuilderConverter::convertGridTrackList(CSSValue* value, Vector<GridTra ckSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& o rderedNamedGridLines, StyleResolverState& state) 461 void StyleBuilderConverter::convertGridTrackList(CSSValue* value, Vector<GridTra ckSize>& trackSizes, NamedGridLinesMap& namedGridLines, OrderedNamedGridLines& o rderedNamedGridLines, StyleResolverState& state)
465 { 462 {
466 // Handle 'none'.
467 if (value->isPrimitiveValue()) { 463 if (value->isPrimitiveValue()) {
468 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 464 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
469 return primitiveValue->getValueID() == CSSValueNone; 465 return;
470 } 466 }
471 467
472 if (!value->isValueList())
473 return false;
474
475 size_t currentNamedGridLine = 0; 468 size_t currentNamedGridLine = 0;
476 for (auto& currValue : *toCSSValueList(value)) { 469 for (auto& currValue : *toCSSValueList(value)) {
477 if (currValue->isGridLineNamesValue()) { 470 if (currValue->isGridLineNamesValue()) {
478 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) { 471 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) {
479 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue(); 472 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue();
480 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>()); 473 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>());
481 result.storedValue->value.append(currentNamedGridLine); 474 result.storedValue->value.append(currentNamedGridLine);
482 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>()); 475 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>());
483 orderedInsertionResult.storedValue->value.append(namedGridLine); 476 orderedInsertionResult.storedValue->value.append(namedGridLine);
484 } 477 }
485 continue; 478 continue;
486 } 479 }
487 480
488 ++currentNamedGridLine; 481 ++currentNamedGridLine;
489 trackSizes.append(convertGridTrackSize(state, currValue.get())); 482 trackSizes.append(convertGridTrackSize(state, currValue.get()));
490 } 483 }
491 484
492 // The parser should have rejected any <track-list> without any <track-size> as 485 // The parser should have rejected any <track-list> without any <track-size> as
493 // this is not conformant to the syntax. 486 // this is not conformant to the syntax.
494 ASSERT(!trackSizes.isEmpty()); 487 ASSERT(!trackSizes.isEmpty());
495 return true;
496 } 488 }
497 489
498 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(c onst OrderedNamedGridLines& orderedNamedGridLines, NamedGridLinesMap& namedGridL ines) 490 void StyleBuilderConverter::convertOrderedNamedGridLinesMapToNamedGridLinesMap(c onst OrderedNamedGridLines& orderedNamedGridLines, NamedGridLinesMap& namedGridL ines)
499 { 491 {
500 ASSERT(namedGridLines.size() == 0); 492 ASSERT(namedGridLines.size() == 0);
501 493
502 if (orderedNamedGridLines.size() == 0) 494 if (orderedNamedGridLines.size() == 0)
503 return; 495 return;
504 496
505 for (auto& orderedNamedGridLine : orderedNamedGridLines) { 497 for (auto& orderedNamedGridLine : orderedNamedGridLines) {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso lverState& state, CSSValue* value) 837 PassRefPtr<SVGDashArray> StyleBuilderConverter::convertStrokeDasharray(StyleReso lverState& state, CSSValue* value)
846 { 838 {
847 if (!value->isValueList()) 839 if (!value->isValueList())
848 return SVGComputedStyle::initialStrokeDashArray(); 840 return SVGComputedStyle::initialStrokeDashArray();
849 841
850 CSSValueList* dashes = toCSSValueList(value); 842 CSSValueList* dashes = toCSSValueList(value);
851 843
852 RefPtr<SVGDashArray> array = SVGDashArray::create(); 844 RefPtr<SVGDashArray> array = SVGDashArray::create();
853 size_t length = dashes->length(); 845 size_t length = dashes->length();
854 for (size_t i = 0; i < length; ++i) { 846 for (size_t i = 0; i < length; ++i) {
855 CSSValue* currValue = dashes->item(i);
856 if (!currValue->isPrimitiveValue())
857 continue;
858
859 CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->item(i)); 847 CSSPrimitiveValue* dash = toCSSPrimitiveValue(dashes->item(i));
860 array->append(convertLength(state, dash)); 848 array->append(convertLength(state, dash));
861 } 849 }
862 850
863 return array.release(); 851 return array.release();
864 } 852 }
865 853
866 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C SSValue* value, bool forVisitedLink) 854 StyleColor StyleBuilderConverter::convertStyleColor(StyleResolverState& state, C SSValue* value, bool forVisitedLink)
867 { 855 {
868 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 856 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 965
978 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); 966 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D);
979 } 967 }
980 968
981 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) 969 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value)
982 { 970 {
983 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 971 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
984 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; 972 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation;
985 } 973 }
986 974
987
988 } // namespace blink 975 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698