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/StylePropertySerializer.cpp

Issue 333163004: Remove explicit bounds check from CSSValueList::item (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 | « Source/core/css/FontFace.cpp ('k') | Source/core/css/parser/CSSPropertyParser.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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. 5 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // can safely be omitted. 495 // can safely be omitted.
496 for (size_t i = 0; i < numLayers; i++) { 496 for (size_t i = 0; i < numLayers; i++) {
497 StringBuilder layerResult; 497 StringBuilder layerResult;
498 bool useRepeatXShorthand = false; 498 bool useRepeatXShorthand = false;
499 bool useRepeatYShorthand = false; 499 bool useRepeatYShorthand = false;
500 bool useSingleWordShorthand = false; 500 bool useSingleWordShorthand = false;
501 bool foundPositionYCSSProperty = false; 501 bool foundPositionYCSSProperty = false;
502 for (unsigned j = 0; j < size; j++) { 502 for (unsigned j = 0; j < size; j++) {
503 RefPtrWillBeRawPtr<CSSValue> value = nullptr; 503 RefPtrWillBeRawPtr<CSSValue> value = nullptr;
504 if (values[j]) { 504 if (values[j]) {
505 if (values[j]->isBaseValueList()) 505 if (values[j]->isBaseValueList()) {
506 value = toCSSValueList(values[j].get())->item(i); 506 CSSValueList* list = toCSSValueList(values[j].get());
507 else { 507 value = i < list->length() ? list->item(i) : nullptr;
alancutter (OOO until 2018) 2014/06/26 00:36:35 itemWithBoundsCheck()
508 } else {
508 value = values[j]; 509 value = values[j];
509 510
510 // Color only belongs in the last layer. 511 // Color only belongs in the last layer.
511 if (shorthand.properties()[j] == CSSPropertyBackgroundColor) { 512 if (shorthand.properties()[j] == CSSPropertyBackgroundColor) {
512 if (i != numLayers - 1) 513 if (i != numLayers - 1)
513 value = nullptr; 514 value = nullptr;
514 } else if (i) { 515 } else if (i) {
515 // Other singletons only belong in the first layer. 516 // Other singletons only belong in the first layer.
516 value = nullptr; 517 value = nullptr;
517 } 518 }
518 } 519 }
519 } 520 }
520 521
521 // We need to report background-repeat as it was written in the CSS. If the property is implicit, 522 // We need to report background-repeat as it was written in the CSS. If the property is implicit,
522 // then it was written with only one value. Here we figure out which value that was so we can 523 // then it was written with only one value. Here we figure out which value that was so we can
523 // report back correctly. 524 // report back correctly.
524 if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && m_ propertySet.isPropertyImplicit(shorthand.properties()[j])) 525 if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && m_ propertySet.isPropertyImplicit(shorthand.properties()[j]))
525 || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX && m_propertySet.isPropertyImplicit(shorthand.properties()[j]))) { 526 || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX && m_propertySet.isPropertyImplicit(shorthand.properties()[j]))) {
526 527
527 // BUG 49055: make sure the value was not reset in the layer che ck just above. 528 // BUG 49055: make sure the value was not reset in the layer che ck just above.
528 if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropert yBackgroundRepeatY && value) 529 if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropert yBackgroundRepeatY && value)
529 || (j < size - 1 && shorthand.properties()[j + 1] == CSSProp ertyWebkitMaskRepeatY && value)) { 530 || (j < size - 1 && shorthand.properties()[j + 1] == CSSProp ertyWebkitMaskRepeatY && value)) {
530 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; 531 RefPtrWillBeRawPtr<CSSValue> yValue = nullptr;
531 RefPtrWillBeRawPtr<CSSValue> nextValue = values[j + 1]; 532 RefPtrWillBeRawPtr<CSSValue> nextValue = values[j + 1];
532 if (nextValue->isValueList()) 533 if (nextValue->isValueList())
533 yValue = toCSSValueList(nextValue.get())->itemWithoutBou ndsCheck(i); 534 yValue = toCSSValueList(nextValue.get())->item(i);
534 else 535 else
535 yValue = nextValue; 536 yValue = nextValue;
536 537
537 // background-repeat-x(y) or mask-repeat-x(y) may be like th is : "initial, repeat". We can omit the implicit initial values 538 // background-repeat-x(y) or mask-repeat-x(y) may be like th is : "initial, repeat". We can omit the implicit initial values
538 // before starting to compare their values. 539 // before starting to compare their values.
539 if (value->isImplicitInitialValue() || yValue->isImplicitIni tialValue()) 540 if (value->isImplicitInitialValue() || yValue->isImplicitIni tialValue())
540 continue; 541 continue;
541 542
542 // FIXME: At some point we need to fix this code to avoid re turning an invalid shorthand, 543 // FIXME: At some point we need to fix this code to avoid re turning an invalid shorthand,
543 // since some longhand combinations are not serializable int o a single shorthand. 544 // since some longhand combinations are not serializable int o a single shorthand.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 isInitialValue = false; 864 isInitialValue = false;
864 if (!value->isInheritedValue()) 865 if (!value->isInheritedValue())
865 isInheritedValue = false; 866 isInheritedValue = false;
866 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 867 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
867 return false; 868 return false;
868 } 869 }
869 return isInitialValue || isInheritedValue; 870 return isInitialValue || isInheritedValue;
870 } 871 }
871 872
872 } 873 }
OLDNEW
« no previous file with comments | « Source/core/css/FontFace.cpp ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698