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

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

Issue 1306823004: Split out String, URI and CustomIdent from CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_attr_values
Patch Set: Review feedback from alan 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 * 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. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 564 }
565 565
566 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value) 566 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value)
567 { 567 {
568 if (value->isPrimitiveValue()) { 568 if (value->isPrimitiveValue()) {
569 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 569 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
570 if (primitiveValue->getValueID() == CSSValueNone) { 570 if (primitiveValue->getValueID() == CSSValueNone) {
571 state.style()->setClipPath(nullptr); 571 state.style()->setClipPath(nullptr);
572 } else if (primitiveValue->isShape()) { 572 } else if (primitiveValue->isShape()) {
573 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue()))); 573 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue())));
574 } else if (primitiveValue->isURI()) {
575 String cssURLValue = primitiveValue->getStringValue();
576 KURL url = state.document().completeURL(cssURLValue);
577 // FIXME: It doesn't work with forward or external SVG references (s ee https://bugs.webkit.org/show_bug.cgi?id=90405)
578 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL Value, AtomicString(url.fragmentIdentifier())));
579 } 574 }
575 } else if (value->isURIValue()) {
576 String cssURLValue = toCSSURIValue(value)->value();
577 KURL url = state.document().completeURL(cssURLValue);
578 // FIXME: It doesn't work with forward or external SVG references (see h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
579 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValu e, AtomicString(url.fragmentIdentifier())));
580 } 580 }
581 } 581 }
582 582
583 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value) 583 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value)
584 { 584 {
585 // FIXME: We should just make this a converter 585 // FIXME: We should just make this a converter
586 FilterOperations operations; 586 FilterOperations operations;
587 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state); 587 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state);
588 state.style()->setFilter(operations); 588 state.style()->setFilter(operations);
589 } 589 }
(...skipping 29 matching lines...) Expand all
619 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i)); 619 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i));
620 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen) 620 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
621 state.style()->setTextEmphasisFill(*value); 621 state.style()->setTextEmphasisFill(*value);
622 else 622 else
623 state.style()->setTextEmphasisMark(*value); 623 state.style()->setTextEmphasisMark(*value);
624 } 624 }
625 state.style()->setTextEmphasisCustomMark(nullAtom); 625 state.style()->setTextEmphasisCustomMark(nullAtom);
626 return; 626 return;
627 } 627 }
628 628
629 if (value->isStringValue()) {
630 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
631 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
632 state.style()->setTextEmphasisCustomMark(AtomicString(toCSSStringValue(v alue)->value()));
633 return;
634 }
635
629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 636 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
630
631 if (primitiveValue->isString()) {
632 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
633 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
634 state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->ge tStringValue()));
635 return;
636 }
637
638 state.style()->setTextEmphasisCustomMark(nullAtom); 637 state.style()->setTextEmphasisCustomMark(nullAtom);
639 638
640 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) { 639 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) {
641 state.style()->setTextEmphasisFill(*primitiveValue); 640 state.style()->setTextEmphasisFill(*primitiveValue);
642 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); 641 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
643 } else { 642 } else {
644 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 643 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
645 state.style()->setTextEmphasisMark(*primitiveValue); 644 state.style()->setTextEmphasisMark(*primitiveValue);
646 } 645 }
647 } 646 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 728 }
730 729
731 if (item->isFunctionValue()) { 730 if (item->isFunctionValue()) {
732 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get()); 731 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get());
733 ASSERT(functionValue->functionType() == CSSValueAttr); 732 ASSERT(functionValue->functionType() == CSSValueAttr);
734 // FIXME: Can a namespace be specified for an attr(foo)? 733 // FIXME: Can a namespace be specified for an attr(foo)?
735 if (state.style()->styleType() == NOPSEUDO) 734 if (state.style()->styleType() == NOPSEUDO)
736 state.style()->setUnique(); 735 state.style()->setUnique();
737 else 736 else
738 state.parentStyle()->setUnique(); 737 state.parentStyle()->setUnique();
739 QualifiedName attr(nullAtom, AtomicString(toCSSPrimitiveValue(functi onValue->item(0))->getStringValue()), nullAtom); 738 QualifiedName attr(nullAtom, AtomicString(toCSSCustomIdentValue(func tionValue->item(0))->value()), nullAtom);
740 const AtomicString& value = state.element()->getAttribute(attr); 739 const AtomicString& value = state.element()->getAttribute(attr);
741 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet); 740 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet);
742 didSet = true; 741 didSet = true;
743 } 742 }
744 743
745 if (!item->isPrimitiveValue()) 744 if (item->isStringValue()) {
746 continue; 745 CSSStringValue* contentValue = toCSSStringValue(item.get());
747 746 state.style()->setContent(contentValue->value().impl(), didSet);
748 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item.get());
749
750 if (contentValue->isString()) {
751 state.style()->setContent(contentValue->getStringValue().impl(), did Set);
752 didSet = true; 747 didSet = true;
753 } else { 748 } else if (item->isPrimitiveValue()) {
749 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item.get());
754 switch (contentValue->getValueID()) { 750 switch (contentValue->getValueID()) {
755 case CSSValueOpenQuote: 751 case CSSValueOpenQuote:
756 state.style()->setContent(OPEN_QUOTE, didSet); 752 state.style()->setContent(OPEN_QUOTE, didSet);
757 didSet = true; 753 didSet = true;
758 break; 754 break;
759 case CSSValueCloseQuote: 755 case CSSValueCloseQuote:
760 state.style()->setContent(CLOSE_QUOTE, didSet); 756 state.style()->setContent(CLOSE_QUOTE, didSet);
761 didSet = true; 757 didSet = true;
762 break; 758 break;
763 case CSSValueNoOpenQuote: 759 case CSSValueNoOpenQuote:
764 state.style()->setContent(NO_OPEN_QUOTE, didSet); 760 state.style()->setContent(NO_OPEN_QUOTE, didSet);
765 didSet = true; 761 didSet = true;
766 break; 762 break;
767 case CSSValueNoCloseQuote: 763 case CSSValueNoCloseQuote:
768 state.style()->setContent(NO_CLOSE_QUOTE, didSet); 764 state.style()->setContent(NO_CLOSE_QUOTE, didSet);
769 didSet = true; 765 didSet = true;
770 break; 766 break;
771 default: 767 default:
772 // normal and none do not have any effect. 768 // normal and none do not have any effect.
773 { } 769 { }
774 } 770 }
771 } else {
772 continue;
775 } 773 }
776 } 774 }
777 if (!didSet) 775 if (!didSet)
778 state.style()->clearContent(); 776 state.style()->clearContent();
779 } 777 }
780 778
781 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value) 779 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value)
782 { 780 {
783 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 781 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueAuto) {
784 if (primitiveValue->getValueID() == CSSValueAuto) {
785 state.style()->setLocale(nullAtom); 782 state.style()->setLocale(nullAtom);
786 } else { 783 } else {
787 ASSERT(primitiveValue->isString()); 784 state.style()->setLocale(AtomicString(toCSSStringValue(value)->value())) ;
788 state.style()->setLocale(AtomicString(primitiveValue->getStringValue())) ;
789 } 785 }
790 state.fontBuilder().setScript(state.style()->locale()); 786 state.fontBuilder().setScript(state.style()->locale());
791 } 787 }
792 788
793 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&) 789 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&)
794 { 790 {
795 } 791 }
796 792
797 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&) 793 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&)
798 { 794 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 return; 840 return;
845 case CSSValueSuper: 841 case CSSValueSuper:
846 svgStyle.setBaselineShift(BS_SUPER); 842 svgStyle.setBaselineShift(BS_SUPER);
847 return; 843 return;
848 default: 844 default:
849 ASSERT_NOT_REACHED(); 845 ASSERT_NOT_REACHED();
850 } 846 }
851 } 847 }
852 848
853 } // namespace blink 849 } // namespace blink
OLDNEW
« Source/core/css/CSSStringValueBase.h ('K') | « Source/core/css/resolver/StyleBuilderConverter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698