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

Side by Side Diff: Source/core/layout/LayoutObject.cpp

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Doug's review. Created 5 years, 10 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
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectInlines.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 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) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 rendererForFirstLineStyle = renderer->parent(); 2617 rendererForFirstLineStyle = renderer->parent();
2618 2618
2619 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt yle->isRenderButton()) { 2619 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt yle->isRenderButton()) {
2620 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl ock()) { 2620 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl ock()) {
2621 if (type == Cached) 2621 if (type == Cached)
2622 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); 2622 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
2623 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR ST_LINE), style, firstLineBlock == renderer ? style : 0); 2623 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR ST_LINE), style, firstLineBlock == renderer ? style : 0);
2624 } 2624 }
2625 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine Style->isRenderInline() 2625 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine Style->isRenderInline()
2626 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { 2626 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) {
2627 LayoutStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLin eStyle(); 2627 const LayoutStyle* parentStyle = rendererForFirstLineStyle->parent()->fi rstLineStyle();
2628 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { 2628 if (parentStyle != rendererForFirstLineStyle->parent()->style()) {
2629 if (type == Cached) { 2629 if (type == Cached) {
2630 // A first-line style is in effect. Cache a first-line style for ourselves. 2630 // A first-line style is in effect. Cache a first-line style for ourselves.
2631 rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE _INHERITED); 2631 rendererForFirstLineStyle->mutableStyle()->setHasPseudoStyle(FIR ST_LINE_INHERITED);
2632 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN E_INHERITED, parentStyle); 2632 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN E_INHERITED, parentStyle);
2633 } 2633 }
2634 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle Request(FIRST_LINE_INHERITED), parentStyle, style); 2634 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle Request(FIRST_LINE_INHERITED), parentStyle, style);
2635 } 2635 }
2636 } 2636 }
2637 return nullptr; 2637 return nullptr;
2638 } 2638 }
2639 2639
2640 PassRefPtr<LayoutStyle> LayoutObject::uncachedFirstLineStyle(LayoutStyle* style) const 2640 PassRefPtr<LayoutStyle> LayoutObject::uncachedFirstLineStyle(LayoutStyle* style) const
2641 { 2641 {
2642 if (!document().styleEngine()->usesFirstLineRules()) 2642 if (!document().styleEngine()->usesFirstLineRules())
2643 return nullptr; 2643 return nullptr;
2644 2644
2645 ASSERT(!isText()); 2645 ASSERT(!isText());
2646 2646
2647 return firstLineStyleForCachedUncachedType(Uncached, this, style); 2647 return firstLineStyleForCachedUncachedType(Uncached, this, style);
2648 } 2648 }
2649 2649
2650 LayoutStyle* LayoutObject::cachedFirstLineStyle() const 2650 LayoutStyle* LayoutObject::cachedFirstLineStyle() const
2651 { 2651 {
2652 ASSERT(document().styleEngine()->usesFirstLineRules()); 2652 ASSERT(document().styleEngine()->usesFirstLineRules());
2653 2653
2654 if (RefPtr<LayoutStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get())) 2654 if (RefPtr<LayoutStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get()))
2655 return style.get(); 2655 return style.get();
2656 2656
2657 return m_style.get(); 2657 return m_style.get();
2658 } 2658 }
2659 2659
2660 LayoutStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, LayoutStyle* pa rentStyle) const 2660 LayoutStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const LayoutSty le* parentStyle) const
2661 { 2661 {
2662 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) 2662 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
2663 return 0; 2663 return 0;
2664 2664
2665 LayoutStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); 2665 LayoutStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo);
2666 if (cachedStyle) 2666 if (cachedStyle)
2667 return cachedStyle; 2667 return cachedStyle;
2668 2668
2669 RefPtr<LayoutStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud o), parentStyle); 2669 RefPtr<LayoutStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud o), parentStyle);
2670 if (result) 2670 if (result)
2671 return style()->addCachedPseudoStyle(result.release()); 2671 return mutableStyle()->addCachedPseudoStyle(result.release());
2672 return 0; 2672 return 0;
2673 } 2673 }
2674 2674
2675 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe quest& pseudoStyleRequest, LayoutStyle* parentStyle, LayoutStyle* ownStyle) cons t 2675 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe quest& pseudoStyleRequest, const LayoutStyle* parentStyle, const LayoutStyle* ow nStyle) const
2676 { 2676 {
2677 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) 2677 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId))
2678 return nullptr; 2678 return nullptr;
2679 2679
2680 if (!parentStyle) { 2680 if (!parentStyle) {
2681 ASSERT(!ownStyle); 2681 ASSERT(!ownStyle);
2682 parentStyle = style(); 2682 parentStyle = style();
2683 } 2683 }
2684 2684
2685 if (!node()) 2685 if (!node())
(...skipping 24 matching lines...) Expand all
2710 } 2710 }
2711 } 2711 }
2712 } 2712 }
2713 2713
2714 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); 2714 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
2715 } 2715 }
2716 2716
2717 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle) 2717 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle)
2718 { 2718 {
2719 LayoutObject* curr = this; 2719 LayoutObject* curr = this;
2720 LayoutStyle* styleToUse = 0; 2720 const LayoutStyle* styleToUse = 0;
2721 unsigned currDecs = TextDecorationNone; 2721 unsigned currDecs = TextDecorationNone;
2722 Color resultColor; 2722 Color resultColor;
2723 TextDecorationStyle resultStyle; 2723 TextDecorationStyle resultStyle;
2724 do { 2724 do {
2725 styleToUse = curr->style(firstlineStyle); 2725 styleToUse = curr->style(firstlineStyle);
2726 currDecs = styleToUse->textDecoration(); 2726 currDecs = styleToUse->textDecoration();
2727 currDecs &= decorations; 2727 currDecs &= decorations;
2728 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor); 2728 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor);
2729 resultStyle = styleToUse->textDecorationStyle(); 2729 resultStyle = styleToUse->textDecorationStyle();
2730 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below. 2730 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 { 3184 {
3185 if (object1) { 3185 if (object1) {
3186 const blink::LayoutObject* root = object1; 3186 const blink::LayoutObject* root = object1;
3187 while (root->parent()) 3187 while (root->parent())
3188 root = root->parent(); 3188 root = root->parent();
3189 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3189 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3190 } 3190 }
3191 } 3191 }
3192 3192
3193 #endif 3193 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.h ('k') | Source/core/layout/LayoutObjectInlines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698