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

Side by Side Diff: Source/core/css/resolver/StyleResolverState.cpp

Issue 23601011: Have StyleResolver / StyleResolverState deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update StyleResolverState as well 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
« no previous file with comments | « Source/core/css/resolver/StyleResolverState.h ('k') | Source/core/dom/Document.cpp » ('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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 11 matching lines...) Expand all
22 #include "config.h" 22 #include "config.h"
23 #include "core/css/resolver/StyleResolverState.h" 23 #include "core/css/resolver/StyleResolverState.h"
24 24
25 #include "core/dom/Element.h" 25 #include "core/dom/Element.h"
26 #include "core/dom/Node.h" 26 #include "core/dom/Node.h"
27 #include "core/dom/NodeRenderStyle.h" 27 #include "core/dom/NodeRenderStyle.h"
28 #include "core/page/Page.h" 28 #include "core/page/Page.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 StyleResolverState::StyleResolverState(Document* document, Element* element, Ren derStyle* parentStyle, RenderRegion* regionForStyling) 32 StyleResolverState::StyleResolverState(Document& document, Element* element, Ren derStyle* parentStyle, RenderRegion* regionForStyling)
33 : m_regionForStyling(0) 33 : m_elementContext(element ? ElementResolveContext(element) : ElementResolve Context())
34 , m_document(element ? m_elementContext.document() : document)
35 , m_regionForStyling(0)
34 , m_applyPropertyToRegularStyle(true) 36 , m_applyPropertyToRegularStyle(true)
35 , m_applyPropertyToVisitedLinkStyle(false) 37 , m_applyPropertyToVisitedLinkStyle(false)
36 , m_lineHeightValue(0) 38 , m_lineHeightValue(0)
37 , m_styleMap(*this, m_elementStyleResources) 39 , m_styleMap(*this, m_elementStyleResources)
38 { 40 {
39 if (element) {
40 m_elementContext = ElementResolveContext(element);
41 m_document = &m_elementContext.document();
42 } else {
43 m_elementContext = ElementResolveContext();
44 m_document = document;
45 }
46
47 m_regionForStyling = regionForStyling; 41 m_regionForStyling = regionForStyling;
48 42
49 if (m_elementContext.resetStyleInheritance()) 43 if (m_elementContext.resetStyleInheritance())
50 m_parentStyle = 0; 44 m_parentStyle = 0;
51 else if (parentStyle) 45 else if (parentStyle)
52 m_parentStyle = parentStyle; 46 m_parentStyle = parentStyle;
53 else if (m_elementContext.parentNode()) 47 else if (m_elementContext.parentNode())
54 m_parentStyle = m_elementContext.parentNode()->renderStyle(); 48 m_parentStyle = m_elementContext.parentNode()->renderStyle();
55 else 49 else
56 m_parentStyle = 0; 50 m_parentStyle = 0;
57 51
58 m_style = 0; 52 m_style = 0;
59 m_elementStyleResources.clear(); 53 m_elementStyleResources.clear();
60 m_fontBuilder.clear(); 54 m_fontBuilder.clear();
61 55
62 // FIXME: StyleResolverState is never passed between documents 56 // FIXME: StyleResolverState is never passed between documents
63 // so we should be able to do this initialization at StyleResolverState 57 // so we should be able to do this initialization at StyleResolverState
64 // createion time instead of now, correct? 58 // createion time instead of now, correct?
65 if (Page* page = document->page()) 59 if (Page* page = document.page())
66 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor()); 60 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor());
67 } 61 }
68 62
69 StyleResolverState::~StyleResolverState() 63 StyleResolverState::~StyleResolverState()
70 { 64 {
71 m_elementContext = ElementResolveContext(); 65 m_elementContext = ElementResolveContext();
72 m_style = 0; 66 m_style = 0;
73 m_parentStyle = 0; 67 m_parentStyle = 0;
74 m_regionForStyling = 0; 68 m_regionForStyling = 0;
75 m_elementStyleResources.clear(); 69 m_elementStyleResources.clear();
76 m_fontBuilder.clear(); 70 m_fontBuilder.clear();
77 } 71 }
78 72
79 } // namespace WebCore 73 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolverState.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698