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

Side by Side Diff: third_party/WebKit/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: Rebase Created 5 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 * 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/css/CSSCounterValue.h" 47 #include "core/css/CSSCounterValue.h"
48 #include "core/css/CSSCursorImageValue.h" 48 #include "core/css/CSSCursorImageValue.h"
49 #include "core/css/CSSFunctionValue.h" 49 #include "core/css/CSSFunctionValue.h"
50 #include "core/css/CSSGradientValue.h" 50 #include "core/css/CSSGradientValue.h"
51 #include "core/css/CSSGridTemplateAreasValue.h" 51 #include "core/css/CSSGridTemplateAreasValue.h"
52 #include "core/css/CSSHelper.h" 52 #include "core/css/CSSHelper.h"
53 #include "core/css/CSSImageSetValue.h" 53 #include "core/css/CSSImageSetValue.h"
54 #include "core/css/CSSPathValue.h" 54 #include "core/css/CSSPathValue.h"
55 #include "core/css/CSSPrimitiveValueMappings.h" 55 #include "core/css/CSSPrimitiveValueMappings.h"
56 #include "core/css/CSSPropertyMetadata.h" 56 #include "core/css/CSSPropertyMetadata.h"
57 #include "core/css/CSSURIValue.h"
57 #include "core/css/CSSValuePair.h" 58 #include "core/css/CSSValuePair.h"
58 #include "core/css/StylePropertySet.h" 59 #include "core/css/StylePropertySet.h"
59 #include "core/css/StyleRule.h" 60 #include "core/css/StyleRule.h"
60 #include "core/css/resolver/ElementStyleResources.h" 61 #include "core/css/resolver/ElementStyleResources.h"
61 #include "core/css/resolver/FilterOperationResolver.h" 62 #include "core/css/resolver/FilterOperationResolver.h"
62 #include "core/css/resolver/FontBuilder.h" 63 #include "core/css/resolver/FontBuilder.h"
63 #include "core/css/resolver/StyleBuilder.h" 64 #include "core/css/resolver/StyleBuilder.h"
64 #include "core/css/resolver/TransformBuilder.h" 65 #include "core/css/resolver/TransformBuilder.h"
65 #include "core/frame/LocalFrame.h" 66 #include "core/frame/LocalFrame.h"
66 #include "core/frame/Settings.h" 67 #include "core/frame/Settings.h"
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 NinePieceImage image; 563 NinePieceImage image;
563 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBorderImage, value, image); 564 CSSToStyleMap::mapNinePieceImage(state, CSSPropertyWebkitBorderImage, value, image);
564 state.style()->setBorderImage(image); 565 state.style()->setBorderImage(image);
565 } 566 }
566 567
567 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value) 568 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value)
568 { 569 {
569 if (value->isBasicShapeValue()) { 570 if (value->isBasicShapeValue()) {
570 state.style()->setClipPath(ShapeClipPathOperation::create(basicShapeForV alue(state, *value))); 571 state.style()->setClipPath(ShapeClipPathOperation::create(basicShapeForV alue(state, *value)));
571 } 572 }
572 if (value->isPrimitiveValue()) { 573 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone) {
573 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 574 state.style()->setClipPath(nullptr);
574 if (primitiveValue->getValueID() == CSSValueNone) { 575 }
575 state.style()->setClipPath(nullptr); 576 if (value->isURIValue()) {
576 } else if (primitiveValue->isURI()) { 577 String cssURLValue = toCSSURIValue(value)->value();
577 String cssURLValue = primitiveValue->getStringValue(); 578 KURL url = state.document().completeURL(cssURLValue);
578 KURL url = state.document().completeURL(cssURLValue); 579 // FIXME: It doesn't work with forward or external SVG references (see h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
579 // FIXME: It doesn't work with forward or external SVG references (s ee https://bugs.webkit.org/show_bug.cgi?id=90405) 580 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValu e, AtomicString(url.fragmentIdentifier())));
580 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL Value, AtomicString(url.fragmentIdentifier())));
581 }
582 } 581 }
583 } 582 }
584 583
585 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value) 584 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value)
586 { 585 {
587 // FIXME: We should just make this a converter 586 // FIXME: We should just make this a converter
588 FilterOperations operations; 587 FilterOperations operations;
589 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state); 588 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state);
590 state.style()->setFilter(operations); 589 state.style()->setFilter(operations);
591 } 590 }
(...skipping 29 matching lines...) Expand all
621 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i)); 620 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i));
622 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen) 621 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
623 state.style()->setTextEmphasisFill(*value); 622 state.style()->setTextEmphasisFill(*value);
624 else 623 else
625 state.style()->setTextEmphasisMark(*value); 624 state.style()->setTextEmphasisMark(*value);
626 } 625 }
627 state.style()->setTextEmphasisCustomMark(nullAtom); 626 state.style()->setTextEmphasisCustomMark(nullAtom);
628 return; 627 return;
629 } 628 }
630 629
630 if (value->isStringValue()) {
631 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
632 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
633 state.style()->setTextEmphasisCustomMark(AtomicString(toCSSStringValue(v alue)->value()));
634 return;
635 }
636
631 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 637 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
632 638
633 if (primitiveValue->isString()) {
634 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
635 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
636 state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->ge tStringValue()));
637 return;
638 }
639
640 state.style()->setTextEmphasisCustomMark(nullAtom); 639 state.style()->setTextEmphasisCustomMark(nullAtom);
641 640
642 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) { 641 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) {
643 state.style()->setTextEmphasisFill(*primitiveValue); 642 state.style()->setTextEmphasisFill(*primitiveValue);
644 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); 643 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
645 } else { 644 } else {
646 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 645 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
647 state.style()->setTextEmphasisMark(*primitiveValue); 646 state.style()->setTextEmphasisMark(*primitiveValue);
648 } 647 }
649 } 648 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 730 }
732 731
733 if (item->isFunctionValue()) { 732 if (item->isFunctionValue()) {
734 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get()); 733 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get());
735 ASSERT(functionValue->functionType() == CSSValueAttr); 734 ASSERT(functionValue->functionType() == CSSValueAttr);
736 // FIXME: Can a namespace be specified for an attr(foo)? 735 // FIXME: Can a namespace be specified for an attr(foo)?
737 if (state.style()->styleType() == NOPSEUDO) 736 if (state.style()->styleType() == NOPSEUDO)
738 state.style()->setUnique(); 737 state.style()->setUnique();
739 else 738 else
740 state.parentStyle()->setUnique(); 739 state.parentStyle()->setUnique();
741 QualifiedName attr(nullAtom, AtomicString(toCSSPrimitiveValue(functi onValue->item(0))->getStringValue()), nullAtom); 740 QualifiedName attr(nullAtom, AtomicString(toCSSCustomIdentValue(func tionValue->item(0))->value()), nullAtom);
742 const AtomicString& value = state.element()->getAttribute(attr); 741 const AtomicString& value = state.element()->getAttribute(attr);
743 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet); 742 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet);
744 didSet = true; 743 didSet = true;
745 } 744 }
746 745
747 if (!item->isPrimitiveValue()) 746 if (!item->isPrimitiveValue() && !item->isStringValue())
748 continue; 747 continue;
749 748
750 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item.get()); 749 if (item->isStringValue()) {
751 750 state.style()->setContent(toCSSStringValue(*item).value().impl(), di dSet);
752 if (contentValue->isString()) {
753 state.style()->setContent(contentValue->getStringValue().impl(), did Set);
754 didSet = true; 751 didSet = true;
755 } else { 752 } else {
756 switch (contentValue->getValueID()) { 753 switch (toCSSPrimitiveValue(*item).getValueID()) {
757 case CSSValueOpenQuote: 754 case CSSValueOpenQuote:
758 state.style()->setContent(OPEN_QUOTE, didSet); 755 state.style()->setContent(OPEN_QUOTE, didSet);
759 didSet = true; 756 didSet = true;
760 break; 757 break;
761 case CSSValueCloseQuote: 758 case CSSValueCloseQuote:
762 state.style()->setContent(CLOSE_QUOTE, didSet); 759 state.style()->setContent(CLOSE_QUOTE, didSet);
763 didSet = true; 760 didSet = true;
764 break; 761 break;
765 case CSSValueNoOpenQuote: 762 case CSSValueNoOpenQuote:
766 state.style()->setContent(NO_OPEN_QUOTE, didSet); 763 state.style()->setContent(NO_OPEN_QUOTE, didSet);
767 didSet = true; 764 didSet = true;
768 break; 765 break;
769 case CSSValueNoCloseQuote: 766 case CSSValueNoCloseQuote:
770 state.style()->setContent(NO_CLOSE_QUOTE, didSet); 767 state.style()->setContent(NO_CLOSE_QUOTE, didSet);
771 didSet = true; 768 didSet = true;
772 break; 769 break;
773 default: 770 default:
774 // normal and none do not have any effect. 771 // normal and none do not have any effect.
775 { } 772 { }
776 } 773 }
777 } 774 }
778 } 775 }
779 if (!didSet) 776 if (!didSet)
780 state.style()->clearContent(); 777 state.style()->clearContent();
781 } 778 }
782 779
783 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value) 780 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value)
784 { 781 {
785 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 782 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueAuto) {
786 if (primitiveValue->getValueID() == CSSValueAuto) {
787 state.style()->setLocale(nullAtom); 783 state.style()->setLocale(nullAtom);
Timothy Loh 2015/10/02 05:35:25 Probably more sensible to assert the id is auto in
sashab 2015/10/02 06:07:54 Ahh good call, I did this everywhere else but didn
788 } else { 784 } else {
789 ASSERT(primitiveValue->isString()); 785 state.style()->setLocale(AtomicString(toCSSStringValue(value)->value())) ;
790 state.style()->setLocale(AtomicString(primitiveValue->getStringValue())) ;
791 } 786 }
792 state.fontBuilder().setScript(state.style()->locale()); 787 state.fontBuilder().setScript(state.style()->locale());
793 } 788 }
794 789
795 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&) 790 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&)
796 { 791 {
797 } 792 }
798 793
799 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&) 794 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&)
800 { 795 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 return; 841 return;
847 case CSSValueSuper: 842 case CSSValueSuper:
848 svgStyle.setBaselineShift(BS_SUPER); 843 svgStyle.setBaselineShift(BS_SUPER);
849 return; 844 return;
850 default: 845 default:
851 ASSERT_NOT_REACHED(); 846 ASSERT_NOT_REACHED();
852 } 847 }
853 } 848 }
854 849
855 } // namespace blink 850 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698