OLD | NEW |
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 Loading... |
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 |
OLD | NEW |