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

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

Issue 2392343005: Reflow comments in core/css (Closed)
Patch Set: Revert clang-format Created 4 years, 2 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 * (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
4 * rights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 5 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. 6 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * 7 *
7 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * 12 *
12 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (value.isVariableReferenceValue()) 412 if (value.isVariableReferenceValue())
412 return emptyString(); 413 return emptyString();
413 } 414 }
414 415
415 return String(); 416 return String();
416 } 417 }
417 418
418 String StylePropertySerializer::getPropertyValue( 419 String StylePropertySerializer::getPropertyValue(
419 CSSPropertyID propertyID) const { 420 CSSPropertyID propertyID) const {
420 const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID); 421 const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID);
421 // TODO(timloh): This is weird, why do we call this with non-shorthands at all ? 422 // TODO(timloh): This is weird, why do we call this with non-shorthands at
423 // all?
422 if (!shorthand.length()) 424 if (!shorthand.length())
423 return String(); 425 return String();
424 426
425 String result = commonShorthandChecks(shorthand); 427 String result = commonShorthandChecks(shorthand);
426 if (!result.isNull()) 428 if (!result.isNull())
427 return result; 429 return result;
428 430
429 switch (propertyID) { 431 switch (propertyID) {
430 case CSSPropertyAnimation: 432 case CSSPropertyAnimation:
431 return getLayeredShorthandValue(animationShorthand()); 433 return getLayeredShorthandValue(animationShorthand());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 prefix = '/'; 557 prefix = '/';
556 break; 558 break;
557 default: 559 default:
558 ASSERT_NOT_REACHED(); 560 ASSERT_NOT_REACHED();
559 } 561 }
560 562
561 if (prefix && !result.isEmpty()) 563 if (prefix && !result.isEmpty())
562 result.append(prefix); 564 result.append(prefix);
563 565
564 String value; 566 String value;
565 // In the font-variant shorthand a "none" ligatures value needs to be expanded . 567 // In the font-variant shorthand a "none" ligatures value needs to be
568 // expanded.
566 if (propertyID == CSSPropertyFontVariantLigatures && 569 if (propertyID == CSSPropertyFontVariantLigatures &&
567 val->isIdentifierValue() && 570 val->isIdentifierValue() &&
568 toCSSIdentifierValue(val)->getValueID() == CSSValueNone) { 571 toCSSIdentifierValue(val)->getValueID() == CSSValueNone) {
569 value = 572 value =
570 "no-common-ligatures no-discretionary-ligatures " 573 "no-common-ligatures no-discretionary-ligatures "
571 "no-historical-ligatures no-contextual"; 574 "no-historical-ligatures no-contextual";
572 } else { 575 } else {
573 value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText(); 576 value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText();
574 } 577 }
575 578
(...skipping 21 matching lines...) Expand all
597 m_propertySet.propertyAt(fontSizePropertyIndex); 600 m_propertySet.propertyAt(fontSizePropertyIndex);
598 PropertyValueForSerializer fontFamilyProperty = 601 PropertyValueForSerializer fontFamilyProperty =
599 m_propertySet.propertyAt(fontFamilyPropertyIndex); 602 m_propertySet.propertyAt(fontFamilyPropertyIndex);
600 PropertyValueForSerializer fontVariantCapsProperty = 603 PropertyValueForSerializer fontVariantCapsProperty =
601 m_propertySet.propertyAt(fontVariantCapsPropertyIndex); 604 m_propertySet.propertyAt(fontVariantCapsPropertyIndex);
602 PropertyValueForSerializer fontVariantLigaturesProperty = 605 PropertyValueForSerializer fontVariantLigaturesProperty =
603 m_propertySet.propertyAt(fontVariantLigaturesPropertyIndex); 606 m_propertySet.propertyAt(fontVariantLigaturesPropertyIndex);
604 PropertyValueForSerializer fontVariantNumericProperty = 607 PropertyValueForSerializer fontVariantNumericProperty =
605 m_propertySet.propertyAt(fontVariantNumericPropertyIndex); 608 m_propertySet.propertyAt(fontVariantNumericPropertyIndex);
606 609
607 // Check that non-initial font-variant subproperties are not conflicting with this serialization. 610 // Check that non-initial font-variant subproperties are not conflicting with
611 // this serialization.
608 const CSSValue* ligaturesValue = fontVariantLigaturesProperty.value(); 612 const CSSValue* ligaturesValue = fontVariantLigaturesProperty.value();
609 const CSSValue* numericValue = fontVariantNumericProperty.value(); 613 const CSSValue* numericValue = fontVariantNumericProperty.value();
610 if ((ligaturesValue->isIdentifierValue() && 614 if ((ligaturesValue->isIdentifierValue() &&
611 toCSSIdentifierValue(ligaturesValue)->getValueID() != CSSValueNormal) || 615 toCSSIdentifierValue(ligaturesValue)->getValueID() != CSSValueNormal) ||
612 ligaturesValue->isValueList() || 616 ligaturesValue->isValueList() ||
613 (numericValue->isIdentifierValue() && 617 (numericValue->isIdentifierValue() &&
614 toCSSIdentifierValue(numericValue)->getValueID() != CSSValueNormal) || 618 toCSSIdentifierValue(numericValue)->getValueID() != CSSValueNormal) ||
615 numericValue->isValueList()) 619 numericValue->isValueList())
616 return emptyString(); 620 return emptyString();
617 621
(...skipping 15 matching lines...) Expand all
633 appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result); 637 appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result);
634 if (!result.isEmpty()) 638 if (!result.isEmpty())
635 result.append(' '); 639 result.append(' ');
636 result.append(fontFamilyProperty.value()->cssText()); 640 result.append(fontFamilyProperty.value()->cssText());
637 return result.toString(); 641 return result.toString();
638 } 642 }
639 643
640 String StylePropertySerializer::fontVariantValue() const { 644 String StylePropertySerializer::fontVariantValue() const {
641 StringBuilder result; 645 StringBuilder result;
642 646
643 // TODO(drott): Decide how we want to return ligature values in shorthands, re duced to "none" or 647 // TODO(drott): Decide how we want to return ligature values in shorthands,
644 // spelled out, filed as W3C bug: 648 // reduced to "none" or spelled out, filed as W3C bug:
645 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=29594 649 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=29594
646 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantLigatures, result); 650 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantLigatures, result);
647 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantCaps, result); 651 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantCaps, result);
648 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantNumeric, result); 652 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariantNumeric, result);
649 653
650 if (result.isEmpty()) { 654 if (result.isEmpty()) {
651 return "normal"; 655 return "normal";
652 } 656 }
653 657
654 return result.toString(); 658 return result.toString();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 for (size_t i = 0; i < size; i++) { 713 for (size_t i = 0; i < size; i++) {
710 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]); 714 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i]);
711 if (values[i]->isBaseValueList()) { 715 if (values[i]->isBaseValueList()) {
712 const CSSValueList* valueList = toCSSValueList(values[i]); 716 const CSSValueList* valueList = toCSSValueList(values[i]);
713 numLayers = std::max(numLayers, valueList->length()); 717 numLayers = std::max(numLayers, valueList->length());
714 } 718 }
715 } 719 }
716 720
717 StringBuilder result; 721 StringBuilder result;
718 722
719 // Now stitch the properties together. Implicit initial values are flagged as such and 723 // Now stitch the properties together. Implicit initial values are flagged as
724 // such and
720 // can safely be omitted. 725 // can safely be omitted.
721 for (size_t layer = 0; layer < numLayers; layer++) { 726 for (size_t layer = 0; layer < numLayers; layer++) {
722 StringBuilder layerResult; 727 StringBuilder layerResult;
723 bool useRepeatXShorthand = false; 728 bool useRepeatXShorthand = false;
724 bool useRepeatYShorthand = false; 729 bool useRepeatYShorthand = false;
725 bool useSingleWordShorthand = false; 730 bool useSingleWordShorthand = false;
726 bool foundPositionXCSSProperty = false; 731 bool foundPositionXCSSProperty = false;
727 bool foundPositionYCSSProperty = false; 732 bool foundPositionYCSSProperty = false;
728 733
729 for (unsigned propertyIndex = 0; propertyIndex < size; propertyIndex++) { 734 for (unsigned propertyIndex = 0; propertyIndex < size; propertyIndex++) {
(...skipping 24 matching lines...) Expand all
754 property == CSSPropertyWebkitMaskRepeatX)) { 759 property == CSSPropertyWebkitMaskRepeatX)) {
755 ASSERT(shorthand.properties()[propertyIndex + 1] == 760 ASSERT(shorthand.properties()[propertyIndex + 1] ==
756 CSSPropertyBackgroundRepeatY || 761 CSSPropertyBackgroundRepeatY ||
757 shorthand.properties()[propertyIndex + 1] == 762 shorthand.properties()[propertyIndex + 1] ==
758 CSSPropertyWebkitMaskRepeatY); 763 CSSPropertyWebkitMaskRepeatY);
759 const CSSValue& yValue = 764 const CSSValue& yValue =
760 values[propertyIndex + 1]->isValueList() 765 values[propertyIndex + 1]->isValueList()
761 ? toCSSValueList(values[propertyIndex + 1])->item(layer) 766 ? toCSSValueList(values[propertyIndex + 1])->item(layer)
762 : *values[propertyIndex + 1]; 767 : *values[propertyIndex + 1];
763 768
764 // FIXME: At some point we need to fix this code to avoid returning an i nvalid shorthand, 769 // FIXME: At some point we need to fix this code to avoid returning an
765 // since some longhand combinations are not serializable into a single s horthand. 770 // invalid shorthand, since some longhand combinations are not
771 // serializable into a single shorthand.
766 if (!value->isIdentifierValue() || !yValue.isIdentifierValue()) 772 if (!value->isIdentifierValue() || !yValue.isIdentifierValue())
767 continue; 773 continue;
768 774
769 CSSValueID xId = toCSSIdentifierValue(value)->getValueID(); 775 CSSValueID xId = toCSSIdentifierValue(value)->getValueID();
770 CSSValueID yId = toCSSIdentifierValue(yValue).getValueID(); 776 CSSValueID yId = toCSSIdentifierValue(yValue).getValueID();
771 // Maybe advance propertyIndex to look at the next CSSValue in the list for the checks below. 777 // Maybe advance propertyIndex to look at the next CSSValue in the list
778 // for the checks below.
772 if (xId == yId) { 779 if (xId == yId) {
773 useSingleWordShorthand = true; 780 useSingleWordShorthand = true;
774 property = shorthand.properties()[++propertyIndex]; 781 property = shorthand.properties()[++propertyIndex];
775 } else if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) { 782 } else if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) {
776 useRepeatXShorthand = true; 783 useRepeatXShorthand = true;
777 property = shorthand.properties()[++propertyIndex]; 784 property = shorthand.properties()[++propertyIndex];
778 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) { 785 } else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) {
779 useRepeatYShorthand = true; 786 useRepeatYShorthand = true;
780 property = shorthand.properties()[++propertyIndex]; 787 property = shorthand.properties()[++propertyIndex];
781 } 788 }
782 } 789 }
783 790
784 if (!(value->isInitialValue() && 791 if (!(value->isInitialValue() &&
785 toCSSInitialValue(value)->isImplicit())) { 792 toCSSInitialValue(value)->isImplicit())) {
786 if (property == CSSPropertyBackgroundSize || 793 if (property == CSSPropertyBackgroundSize ||
787 property == CSSPropertyWebkitMaskSize) { 794 property == CSSPropertyWebkitMaskSize) {
788 if (foundPositionYCSSProperty || foundPositionXCSSProperty) 795 if (foundPositionYCSSProperty || foundPositionXCSSProperty)
789 layerResult.append(" / "); 796 layerResult.append(" / ");
790 else 797 else
791 layerResult.append(" 0% 0% / "); 798 layerResult.append(" 0% 0% / ");
792 } else if (!layerResult.isEmpty()) { 799 } else if (!layerResult.isEmpty()) {
793 // Do this second to avoid ending up with an extra space in the output if we hit the continue above. 800 // Do this second to avoid ending up with an extra space in the output
801 // if we hit the continue above.
794 layerResult.append(' '); 802 layerResult.append(' ');
795 } 803 }
796 804
797 if (useRepeatXShorthand) { 805 if (useRepeatXShorthand) {
798 useRepeatXShorthand = false; 806 useRepeatXShorthand = false;
799 layerResult.append(getValueName(CSSValueRepeatX)); 807 layerResult.append(getValueName(CSSValueRepeatX));
800 } else if (useRepeatYShorthand) { 808 } else if (useRepeatYShorthand) {
801 useRepeatYShorthand = false; 809 useRepeatYShorthand = false;
802 layerResult.append(getValueName(CSSValueRepeatY)); 810 layerResult.append(getValueName(CSSValueRepeatY));
803 } else { 811 } else {
804 if (useSingleWordShorthand) 812 if (useSingleWordShorthand)
805 useSingleWordShorthand = false; 813 useSingleWordShorthand = false;
806 layerResult.append(value->cssText()); 814 layerResult.append(value->cssText());
807 } 815 }
808 if (property == CSSPropertyBackgroundPositionX || 816 if (property == CSSPropertyBackgroundPositionX ||
809 property == CSSPropertyWebkitMaskPositionX) 817 property == CSSPropertyWebkitMaskPositionX)
810 foundPositionXCSSProperty = true; 818 foundPositionXCSSProperty = true;
811 if (property == CSSPropertyBackgroundPositionY || 819 if (property == CSSPropertyBackgroundPositionY ||
812 property == CSSPropertyWebkitMaskPositionY) { 820 property == CSSPropertyWebkitMaskPositionY) {
813 foundPositionYCSSProperty = true; 821 foundPositionYCSSProperty = true;
814 // background-position is a special case. If only the first offset is specified, 822 // background-position is a special case. If only the first offset is
815 // the second one defaults to "center", not the same value. 823 // specified, the second one defaults to "center", not the same value.
816 } 824 }
817 } 825 }
818 } 826 }
819 if (!layerResult.isEmpty()) { 827 if (!layerResult.isEmpty()) {
820 if (!result.isEmpty()) 828 if (!result.isEmpty())
821 result.append(", "); 829 result.append(", ");
822 result.append(layerResult); 830 result.append(layerResult);
823 } 831 }
824 } 832 }
825 833
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 const CSSValue& xValue = 947 const CSSValue& xValue =
940 repeatXList ? repeatXList->item(i % repeatXList->length()) : repeatX; 948 repeatXList ? repeatXList->item(i % repeatXList->length()) : repeatX;
941 const CSSValue& yValue = 949 const CSSValue& yValue =
942 repeatYList ? repeatYList->item(i % repeatYList->length()) : repeatY; 950 repeatYList ? repeatYList->item(i % repeatYList->length()) : repeatY;
943 appendBackgroundRepeatValue(builder, xValue, yValue); 951 appendBackgroundRepeatValue(builder, xValue, yValue);
944 } 952 }
945 return builder.toString(); 953 return builder.toString();
946 } 954 }
947 955
948 } // namespace blink 956 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySerializer.h ('k') | third_party/WebKit/Source/core/css/StylePropertySet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698