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

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 patch after splitting 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
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 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 rendererForFirstLineStyle = renderer->parent(); 2613 rendererForFirstLineStyle = renderer->parent();
2614 2614
2615 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt yle->isRenderButton()) { 2615 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt yle->isRenderButton()) {
2616 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl ock()) { 2616 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl ock()) {
2617 if (type == Cached) 2617 if (type == Cached)
2618 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); 2618 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
2619 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR ST_LINE), style, firstLineBlock == renderer ? style : 0); 2619 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR ST_LINE), style, firstLineBlock == renderer ? style : 0);
2620 } 2620 }
2621 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine Style->isRenderInline() 2621 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine Style->isRenderInline()
2622 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { 2622 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) {
2623 LayoutStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLin eStyle(); 2623 const LayoutStyle* parentStyle = rendererForFirstLineStyle->parent()->fi rstLineStyle();
2624 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { 2624 if (parentStyle != rendererForFirstLineStyle->parent()->style()) {
2625 if (type == Cached) { 2625 if (type == Cached) {
2626 // A first-line style is in effect. Cache a first-line style for ourselves. 2626 // A first-line style is in effect. Cache a first-line style for ourselves.
2627 rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE _INHERITED); 2627 rendererForFirstLineStyle->mutableStyle()->setHasPseudoStyle(FIR ST_LINE_INHERITED);
2628 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN E_INHERITED, parentStyle); 2628 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN E_INHERITED, parentStyle);
2629 } 2629 }
2630 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle Request(FIRST_LINE_INHERITED), parentStyle, style); 2630 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle Request(FIRST_LINE_INHERITED), parentStyle, style);
2631 } 2631 }
2632 } 2632 }
2633 return nullptr; 2633 return nullptr;
2634 } 2634 }
2635 2635
2636 PassRefPtr<LayoutStyle> LayoutObject::uncachedFirstLineStyle(LayoutStyle* style) const 2636 PassRefPtr<LayoutStyle> LayoutObject::uncachedFirstLineStyle(LayoutStyle* style) const
2637 { 2637 {
2638 if (!document().styleEngine()->usesFirstLineRules()) 2638 if (!document().styleEngine()->usesFirstLineRules())
2639 return nullptr; 2639 return nullptr;
2640 2640
2641 ASSERT(!isText()); 2641 ASSERT(!isText());
2642 2642
2643 return firstLineStyleForCachedUncachedType(Uncached, this, style); 2643 return firstLineStyleForCachedUncachedType(Uncached, this, style);
2644 } 2644 }
2645 2645
2646 LayoutStyle* LayoutObject::cachedFirstLineStyle() const 2646 LayoutStyle* LayoutObject::cachedFirstLineStyle() const
2647 { 2647 {
2648 ASSERT(document().styleEngine()->usesFirstLineRules()); 2648 ASSERT(document().styleEngine()->usesFirstLineRules());
2649 2649
2650 if (RefPtr<LayoutStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get())) 2650 if (RefPtr<LayoutStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get()))
2651 return style.get(); 2651 return style.get();
2652 2652
2653 return m_style.get(); 2653 return m_style.get();
2654 } 2654 }
2655 2655
2656 LayoutStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, LayoutStyle* pa rentStyle) const 2656 LayoutStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, const LayoutSty le* parentStyle) const
2657 { 2657 {
2658 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) 2658 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
2659 return 0; 2659 return 0;
2660 2660
2661 LayoutStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); 2661 LayoutStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo);
2662 if (cachedStyle) 2662 if (cachedStyle)
2663 return cachedStyle; 2663 return cachedStyle;
2664 2664
2665 RefPtr<LayoutStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud o), parentStyle); 2665 RefPtr<LayoutStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud o), parentStyle);
2666 if (result) 2666 if (result)
2667 return style()->addCachedPseudoStyle(result.release()); 2667 return mutableStyle()->addCachedPseudoStyle(result.release());
2668 return 0; 2668 return 0;
2669 } 2669 }
2670 2670
2671 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe quest& pseudoStyleRequest, LayoutStyle* parentStyle, LayoutStyle* ownStyle) cons t 2671 PassRefPtr<LayoutStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe quest& pseudoStyleRequest, const LayoutStyle* parentStyle, const LayoutStyle* ow nStyle) const
2672 { 2672 {
2673 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) 2673 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId))
2674 return nullptr; 2674 return nullptr;
2675 2675
2676 if (!parentStyle) { 2676 if (!parentStyle) {
2677 ASSERT(!ownStyle); 2677 ASSERT(!ownStyle);
2678 parentStyle = style(); 2678 parentStyle = style();
2679 } 2679 }
2680 2680
2681 if (!node()) 2681 if (!node())
(...skipping 24 matching lines...) Expand all
2706 } 2706 }
2707 } 2707 }
2708 } 2708 }
2709 2709
2710 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); 2710 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
2711 } 2711 }
2712 2712
2713 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle) 2713 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug h, bool quirksMode, bool firstlineStyle)
2714 { 2714 {
2715 LayoutObject* curr = this; 2715 LayoutObject* curr = this;
2716 LayoutStyle* styleToUse = 0; 2716 const LayoutStyle* styleToUse = 0;
2717 unsigned currDecs = TextDecorationNone; 2717 unsigned currDecs = TextDecorationNone;
2718 Color resultColor; 2718 Color resultColor;
2719 TextDecorationStyle resultStyle; 2719 TextDecorationStyle resultStyle;
2720 do { 2720 do {
2721 styleToUse = curr->style(firstlineStyle); 2721 styleToUse = curr->style(firstlineStyle);
2722 currDecs = styleToUse->textDecoration(); 2722 currDecs = styleToUse->textDecoration();
2723 currDecs &= decorations; 2723 currDecs &= decorations;
2724 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor); 2724 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio nColor);
2725 resultStyle = styleToUse->textDecorationStyle(); 2725 resultStyle = styleToUse->textDecorationStyle();
2726 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below. 2726 // Parameter 'decorations' is cast as an int to enable the bitwise opera tions below.
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 { 3175 {
3176 if (object1) { 3176 if (object1) {
3177 const blink::LayoutObject* root = object1; 3177 const blink::LayoutObject* root = object1;
3178 while (root->parent()) 3178 while (root->parent())
3179 root = root->parent(); 3179 root = root->parent();
3180 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3180 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3181 } 3181 }
3182 } 3182 }
3183 3183
3184 #endif 3184 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698