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

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

Issue 1307673003: Made CSSPrimitiveValue::getString() only work for String types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_pair
Patch Set: Rebase and review feedback Created 5 years, 3 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 { 462 {
463 if (value->isPrimitiveValue()) { 463 if (value->isPrimitiveValue()) {
464 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); 464 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
465 return; 465 return;
466 } 466 }
467 467
468 size_t currentNamedGridLine = 0; 468 size_t currentNamedGridLine = 0;
469 for (auto& currValue : *toCSSValueList(value)) { 469 for (auto& currValue : *toCSSValueList(value)) {
470 if (currValue->isGridLineNamesValue()) { 470 if (currValue->isGridLineNamesValue()) {
471 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) { 471 for (auto& namedGridLineValue : toCSSGridLineNamesValue(*currValue)) {
472 ASSERT(toCSSPrimitiveValue(namedGridLineValue.get())->isCustomId ent());
472 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue(); 473 String namedGridLine = toCSSPrimitiveValue(namedGridLineValue.ge t())->getStringValue();
473 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>()); 474 NamedGridLinesMap::AddResult result = namedGridLines.add(namedGr idLine, Vector<size_t>());
474 result.storedValue->value.append(currentNamedGridLine); 475 result.storedValue->value.append(currentNamedGridLine);
475 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>()); 476 OrderedNamedGridLines::AddResult orderedInsertionResult = ordere dNamedGridLines.add(currentNamedGridLine, Vector<String>());
476 orderedInsertionResult.storedValue->value.append(namedGridLine); 477 orderedInsertionResult.storedValue->value.append(namedGridLine);
477 } 478 }
478 continue; 479 continue;
479 } 480 }
480 481
481 ++currentNamedGridLine; 482 ++currentNamedGridLine;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 734 }
734 735
735 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue* value) 736 PassRefPtr<QuotesData> StyleBuilderConverter::convertQuotes(StyleResolverState&, CSSValue* value)
736 { 737 {
737 if (value->isValueList()) { 738 if (value->isValueList()) {
738 CSSValueList* list = toCSSValueList(value); 739 CSSValueList* list = toCSSValueList(value);
739 RefPtr<QuotesData> quotes = QuotesData::create(); 740 RefPtr<QuotesData> quotes = QuotesData::create();
740 for (size_t i = 0; i < list->length(); i += 2) { 741 for (size_t i = 0; i < list->length(); i += 2) {
741 CSSValue* first = list->item(i); 742 CSSValue* first = list->item(i);
742 CSSValue* second = list->item(i + 1); 743 CSSValue* second = list->item(i + 1);
744 ASSERT(toCSSPrimitiveValue(first)->isString());
745 ASSERT(toCSSPrimitiveValue(second)->isString());
743 String startQuote = toCSSPrimitiveValue(first)->getStringValue(); 746 String startQuote = toCSSPrimitiveValue(first)->getStringValue();
744 String endQuote = toCSSPrimitiveValue(second)->getStringValue(); 747 String endQuote = toCSSPrimitiveValue(second)->getStringValue();
745 quotes->addPair(std::make_pair(startQuote, endQuote)); 748 quotes->addPair(std::make_pair(startQuote, endQuote));
746 } 749 }
747 return quotes.release(); 750 return quotes.release();
748 } 751 }
749 // FIXME: We should assert we're a primitive value with valueID = CSSValueNo ne 752 ASSERT(value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
750 return QuotesData::create(); 753 return QuotesData::create();
751 } 754 }
752 755
753 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value) 756 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, CSSVa lue* value)
754 { 757 {
755 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 758 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
756 Pair* pair = primitiveValue->getPairValue(); 759 Pair* pair = primitiveValue->getPairValue();
757 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers ionData()); 760 Length radiusWidth = pair->first()->convertToLength(state.cssToLengthConvers ionData());
758 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve rsionData()); 761 Length radiusHeight = pair->second()->convertToLength(state.cssToLengthConve rsionData());
759 float width = radiusWidth.value(); 762 float width = radiusWidth.value();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D); 960 return ScaleTransformOperation::create(sx, sy, sz, TransformOperation::Scale 3D);
958 } 961 }
959 962
960 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value) 963 RespectImageOrientationEnum StyleBuilderConverter::convertImageOrientation(Style ResolverState& state, CSSValue* value)
961 { 964 {
962 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 965 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
963 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation; 966 return primitiveValue->getValueID() == CSSValueFromImage ? RespectImageOrien tation : DoNotRespectImageOrientation;
964 } 967 }
965 968
966 } // namespace blink 969 } // 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