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

Side by Side Diff: Source/core/rendering/RenderObject.h

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 enum BoxDecorationState { 534 enum BoxDecorationState {
535 NoBoxDecorations, 535 NoBoxDecorations,
536 HasBoxDecorationsAndBackgroundObscurationStatusInvalid, 536 HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
537 HasBoxDecorationsAndBackgroundIsKnownToBeObscured, 537 HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
538 HasBoxDecorationsAndBackgroundMayBeVisible, 538 HasBoxDecorationsAndBackgroundMayBeVisible,
539 }; 539 };
540 bool hasBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; } 540 bool hasBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
541 bool backgroundIsKnownToBeObscured(); 541 bool backgroundIsKnownToBeObscured();
542 bool borderImageIsLoadedAndCanBeRendered() const; 542 bool borderImageIsLoadedAndCanBeRendered() const;
543 bool mustRepaintBackgroundOrBorder() const; 543 bool mustRepaintBackgroundOrBorder() const;
544 bool hasBackground() const { return style()->hasBackground(); } 544 bool hasBackground() const
545 {
546 StyleColor color = resolveColor(CSSPropertyBackgroundColor);
547 if (color.isValid() && color.alpha())
548 return true;
549 return style()->hasBackgroundImage();
550 }
545 bool hasEntirelyFixedBackground() const; 551 bool hasEntirelyFixedBackground() const;
546 552
547 bool needsLayout() const 553 bool needsLayout() const
548 { 554 {
549 return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout() 555 return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
550 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout(); 556 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout();
551 } 557 }
552 558
553 bool selfNeedsLayout() const { return m_bitfields.needsLayout(); } 559 bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
554 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); } 560 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 758
753 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; } 759 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
754 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; } 760 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
755 761
756 RenderStyle* style() const { return m_style.get(); } 762 RenderStyle* style() const { return m_style.get(); }
757 RenderStyle* firstLineStyle() const { return document()->styleSheetCollectio n()->usesFirstLineRules() ? cachedFirstLineStyle() : style(); } 763 RenderStyle* firstLineStyle() const { return document()->styleSheetCollectio n()->usesFirstLineRules() ? cachedFirstLineStyle() : style(); }
758 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle () : style(); } 764 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle () : style(); }
759 765
760 inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const 766 inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const
761 { 767 {
762 return styleToUse->visitedDependentColor(colorProperty); 768 StyleColor styleColor = resolveCurrentColor(styleToUse, colorProperty);
769 return styleColor.color();
763 } 770 }
764 771
765 inline Color resolveColor(int colorProperty) const 772 inline Color resolveColor(int colorProperty) const
766 { 773 {
767 return style()->visitedDependentColor(colorProperty); 774 StyleColor styleColor = resolveCurrentColor(style(), colorProperty);
775 return styleColor.color();
768 } 776 }
769 777
770 inline Color resolveColor(int colorProperty, Color fallback) const 778 inline Color resolveColor(int colorProperty, Color fallbackIfInvalid) const
771 { 779 {
772 Color color = resolveColor(colorProperty); 780 StyleColor styleColor = resolveCurrentColor(style(), colorProperty);
773 return color.isValid() ? color : fallback; 781 return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid;
774 } 782 }
775 783
776 inline Color resolveColor(Color color) const 784 inline Color resolveColor(StyleColor color) const
777 { 785 {
778 return color; 786 return resolveCurrentColor(color).color();
787 }
788
789 inline Color resolveColor(StyleColor color, Color fallbackIfInvalid) const
790 {
791 StyleColor styleColor = resolveCurrentColor(color);
792 return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid;
793 }
794
795 inline StyleColor resolveStyleColor(int colorProperty) const
796 {
797 return resolveCurrentColor(style(), colorProperty);
798 }
799
800 inline StyleColor resolveStyleColor(const RenderStyle* styleToUse, int color Property) const
801 {
802 return resolveCurrentColor(styleToUse, colorProperty);
779 } 803 }
780 804
781 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a 805 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
782 // given new style, without accessing the cache. 806 // given new style, without accessing the cache.
783 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const; 807 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
784 808
785 // Anonymous blocks that are part of of a continuation chain will return the ir inline continuation's outline style instead. 809 // Anonymous blocks that are part of of a continuation chain will return the ir inline continuation's outline style instead.
786 // This is typically only relevant when repainting. 810 // This is typically only relevant when repainting.
787 virtual RenderStyle* outlineStyleForRepaint() const { return style(); } 811 virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
788 812
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 void removeFromRenderFlowThreadRecursive(RenderFlowThread*); 1038 void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
1015 1039
1016 bool shouldRepaintForStyleDifference(StyleDifference) const; 1040 bool shouldRepaintForStyleDifference(StyleDifference) const;
1017 bool hasImmediateNonWhitespaceTextChild() const; 1041 bool hasImmediateNonWhitespaceTextChild() const;
1018 1042
1019 RenderStyle* cachedFirstLineStyle() const; 1043 RenderStyle* cachedFirstLineStyle() const;
1020 StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensi tiveProperties) const; 1044 StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensi tiveProperties) const;
1021 1045
1022 Color selectionColor(int colorProperty) const; 1046 Color selectionColor(int colorProperty) const;
1023 1047
1048 inline StyleColor resolveCurrentColor(const RenderStyle* styleToUse, int col orProperty) const
1049 {
1050 StyleColor styleColor = styleToUse->visitedDependentColor(colorProperty) ;
1051 if (UNLIKELY(styleColor.isCurrentColor()))
1052 styleColor = styleToUse->visitedDependentColor(CSSPropertyColor);
1053
1054 // In the unlikely case that CSSPropertyColor is also 'currentColor'
1055 // the color of the nearest ancestor with a valid color is used.
1056 for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentCol or()) && object && object->style(); object = object->parent())
1057 styleColor = object->style()->visitedDependentColor(CSSPropertyColor );
1058
1059 return styleColor;
1060 }
1061
1062 inline StyleColor resolveCurrentColor(StyleColor color) const
1063 {
1064 StyleColor styleColor = color;
1065 for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentCol or()) && object && object->style(); object = object->parent())
1066 styleColor = object->style()->visitedDependentColor(CSSPropertyColor );
1067 return styleColor;
1068 }
1069
1024 #ifndef NDEBUG 1070 #ifndef NDEBUG
1025 void checkBlockPositionedObjectsNeedLayout(); 1071 void checkBlockPositionedObjectsNeedLayout();
1026 #endif 1072 #endif
1027 1073
1028 RefPtr<RenderStyle> m_style; 1074 RefPtr<RenderStyle> m_style;
1029 1075
1030 Node* m_node; 1076 Node* m_node;
1031 1077
1032 RenderObject* m_parent; 1078 RenderObject* m_parent;
1033 RenderObject* m_previous; 1079 RenderObject* m_previous;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 // Outside the WebCore namespace for ease of invocation from gdb. 1392 // Outside the WebCore namespace for ease of invocation from gdb.
1347 void showTree(const WebCore::RenderObject*); 1393 void showTree(const WebCore::RenderObject*);
1348 void showLineTree(const WebCore::RenderObject*); 1394 void showLineTree(const WebCore::RenderObject*);
1349 void showRenderTree(const WebCore::RenderObject* object1); 1395 void showRenderTree(const WebCore::RenderObject* object1);
1350 // We don't make object2 an optional parameter so that showRenderTree 1396 // We don't make object2 an optional parameter so that showRenderTree
1351 // can be called from gdb easily. 1397 // can be called from gdb easily.
1352 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderO bject* object2); 1398 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderO bject* object2);
1353 #endif 1399 #endif
1354 1400
1355 #endif // RenderObject_h 1401 #endif // RenderObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698