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

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

Issue 23581008: Revert r154797: "Move isValid/isCurrentColor from Color to StyleColor" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 enum BoxDecorationState { 523 enum BoxDecorationState {
524 NoBoxDecorations, 524 NoBoxDecorations,
525 HasBoxDecorationsAndBackgroundObscurationStatusInvalid, 525 HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
526 HasBoxDecorationsAndBackgroundIsKnownToBeObscured, 526 HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
527 HasBoxDecorationsAndBackgroundMayBeVisible, 527 HasBoxDecorationsAndBackgroundMayBeVisible,
528 }; 528 };
529 bool hasBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; } 529 bool hasBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
530 bool backgroundIsKnownToBeObscured(); 530 bool backgroundIsKnownToBeObscured();
531 bool borderImageIsLoadedAndCanBeRendered() const; 531 bool borderImageIsLoadedAndCanBeRendered() const;
532 bool mustRepaintBackgroundOrBorder() const; 532 bool mustRepaintBackgroundOrBorder() const;
533 bool hasBackground() const 533 bool hasBackground() const { return style()->hasBackground(); }
534 {
535 StyleColor color = resolveColor(CSSPropertyBackgroundColor);
536 if (color.isValid() && color.alpha())
537 return true;
538 return style()->hasBackgroundImage();
539 }
540 bool hasEntirelyFixedBackground() const; 534 bool hasEntirelyFixedBackground() const;
541 535
542 bool needsLayout() const 536 bool needsLayout() const
543 { 537 {
544 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout() 538 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout()
545 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout(); 539 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout();
546 } 540 }
547 541
548 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); } 542 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); }
549 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); } 543 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 747
754 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; } 748 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
755 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; } 749 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
756 750
757 RenderStyle* style() const { return m_style.get(); } 751 RenderStyle* style() const { return m_style.get(); }
758 RenderStyle* firstLineStyle() const { return document().styleSheetCollection s()->usesFirstLineRules() ? cachedFirstLineStyle() : style(); } 752 RenderStyle* firstLineStyle() const { return document().styleSheetCollection s()->usesFirstLineRules() ? cachedFirstLineStyle() : style(); }
759 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle () : style(); } 753 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle () : style(); }
760 754
761 inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const 755 inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const
762 { 756 {
763 StyleColor styleColor = resolveCurrentColor(styleToUse, colorProperty); 757 return styleToUse->visitedDependentColor(colorProperty);
764 return styleColor.color();
765 } 758 }
766 759
767 inline Color resolveColor(int colorProperty) const 760 inline Color resolveColor(int colorProperty) const
768 { 761 {
769 StyleColor styleColor = resolveCurrentColor(style(), colorProperty); 762 return style()->visitedDependentColor(colorProperty);
770 return styleColor.color();
771 } 763 }
772 764
773 inline Color resolveColor(int colorProperty, Color fallbackIfInvalid) const 765 inline Color resolveColor(int colorProperty, Color fallback) const
774 { 766 {
775 StyleColor styleColor = resolveCurrentColor(style(), colorProperty); 767 Color color = resolveColor(colorProperty);
776 return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid; 768 return color.isValid() ? color : fallback;
777 } 769 }
778 770
779 inline Color resolveColor(StyleColor color) const 771 inline Color resolveColor(Color color) const
780 { 772 {
781 return resolveCurrentColor(color).color(); 773 return color;
782 }
783
784 inline Color resolveColor(StyleColor color, Color fallbackIfInvalid) const
785 {
786 StyleColor styleColor = resolveCurrentColor(color);
787 return styleColor.isValid() ? styleColor.color() : fallbackIfInvalid;
788 }
789
790 inline StyleColor resolveStyleColor(int colorProperty) const
791 {
792 return resolveCurrentColor(style(), colorProperty);
793 }
794
795 inline StyleColor resolveStyleColor(const RenderStyle* styleToUse, int color Property) const
796 {
797 return resolveCurrentColor(styleToUse, colorProperty);
798 } 774 }
799 775
800 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a 776 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
801 // given new style, without accessing the cache. 777 // given new style, without accessing the cache.
802 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const; 778 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
803 779
804 // Anonymous blocks that are part of of a continuation chain will return the ir inline continuation's outline style instead. 780 // Anonymous blocks that are part of of a continuation chain will return the ir inline continuation's outline style instead.
805 // This is typically only relevant when repainting. 781 // This is typically only relevant when repainting.
806 virtual RenderStyle* outlineStyleForRepaint() const { return style(); } 782 virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
807 783
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 void removeFromRenderFlowThreadRecursive(RenderFlowThread*); 1013 void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
1038 1014
1039 bool shouldRepaintForStyleDifference(StyleDifference) const; 1015 bool shouldRepaintForStyleDifference(StyleDifference) const;
1040 bool hasImmediateNonWhitespaceTextChild() const; 1016 bool hasImmediateNonWhitespaceTextChild() const;
1041 1017
1042 RenderStyle* cachedFirstLineStyle() const; 1018 RenderStyle* cachedFirstLineStyle() const;
1043 StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensi tiveProperties) const; 1019 StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensi tiveProperties) const;
1044 1020
1045 Color selectionColor(int colorProperty) const; 1021 Color selectionColor(int colorProperty) const;
1046 1022
1047 inline StyleColor resolveCurrentColor(const RenderStyle* styleToUse, int col orProperty) const
1048 {
1049 StyleColor styleColor = styleToUse->visitedDependentColor(colorProperty) ;
1050 if (UNLIKELY(styleColor.isCurrentColor()))
1051 styleColor = styleToUse->visitedDependentColor(CSSPropertyColor);
1052
1053 // In the unlikely case that CSSPropertyColor is also 'currentColor'
1054 // the color of the nearest ancestor with a valid color is used.
1055 for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentCol or()) && object && object->style(); object = object->parent())
1056 styleColor = object->style()->visitedDependentColor(CSSPropertyColor );
1057
1058 return styleColor;
1059 }
1060
1061 inline StyleColor resolveCurrentColor(StyleColor color) const
1062 {
1063 StyleColor styleColor = color;
1064 for (const RenderObject* object = this; UNLIKELY(styleColor.isCurrentCol or()) && object && object->style(); object = object->parent())
1065 styleColor = object->style()->visitedDependentColor(CSSPropertyColor );
1066 return styleColor;
1067 }
1068
1069 void removeShapeImageClient(ShapeValue*); 1023 void removeShapeImageClient(ShapeValue*);
1070 1024
1071 #ifndef NDEBUG 1025 #ifndef NDEBUG
1072 void checkBlockPositionedObjectsNeedLayout(); 1026 void checkBlockPositionedObjectsNeedLayout();
1073 #endif 1027 #endif
1074 1028
1075 RefPtr<RenderStyle> m_style; 1029 RefPtr<RenderStyle> m_style;
1076 1030
1077 Node* m_node; 1031 Node* m_node;
1078 1032
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 // Outside the WebCore namespace for ease of invocation from gdb. 1344 // Outside the WebCore namespace for ease of invocation from gdb.
1391 void showTree(const WebCore::RenderObject*); 1345 void showTree(const WebCore::RenderObject*);
1392 void showLineTree(const WebCore::RenderObject*); 1346 void showLineTree(const WebCore::RenderObject*);
1393 void showRenderTree(const WebCore::RenderObject* object1); 1347 void showRenderTree(const WebCore::RenderObject* object1);
1394 // We don't make object2 an optional parameter so that showRenderTree 1348 // We don't make object2 an optional parameter so that showRenderTree
1395 // can be called from gdb easily. 1349 // can be called from gdb easily.
1396 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderO bject* object2); 1350 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderO bject* object2);
1397 #endif 1351 #endif
1398 1352
1399 #endif // RenderObject_h 1353 #endif // RenderObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698