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

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

Issue 19232002: Do not modify document in StyleResolverState (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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') | no next file » | 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 29 matching lines...) Expand all
40 NodeRenderingContext context(element); 40 NodeRenderingContext context(element);
41 m_parentNode = context.parentNodeForRenderingAndStyle(); 41 m_parentNode = context.parentNodeForRenderingAndStyle();
42 m_distributedToInsertionPoint = context.insertionPoint(); 42 m_distributedToInsertionPoint = context.insertionPoint();
43 m_resetStyleInheritance = context.resetStyleInheritance(); 43 m_resetStyleInheritance = context.resetStyleInheritance();
44 44
45 Node* documentElement = document()->documentElement(); 45 Node* documentElement = document()->documentElement();
46 RenderStyle* documentStyle = document()->renderStyle(); 46 RenderStyle* documentStyle = document()->renderStyle();
47 m_rootElementStyle = documentElement && element != documentElement ? documen tElement->renderStyle() : documentStyle; 47 m_rootElementStyle = documentElement && element != documentElement ? documen tElement->renderStyle() : documentStyle;
48 } 48 }
49 49
50 StyleResolveScope::StyleResolveScope(StyleResolverState* state, Document* docume nt, Element* e, RenderStyle* parentStyle, RenderRegion* regionForStyling) 50 StyleResolveScope::StyleResolveScope(StyleResolverState* state, const Document* document, Element* e, RenderStyle* parentStyle, RenderRegion* regionForStyling)
51 : m_state(state) 51 : m_state(state)
52 { 52 {
53 m_state->initForStyleResolve(document, e, parentStyle, regionForStyling); 53 m_state->initForStyleResolve(document, e, parentStyle, regionForStyling);
54 } 54 }
55 55
56 StyleResolveScope::~StyleResolveScope() 56 StyleResolveScope::~StyleResolveScope()
57 { 57 {
58 m_state->clear(); 58 m_state->clear();
59 } 59 }
60 60
61 void StyleResolverState::clear() 61 void StyleResolverState::clear()
62 { 62 {
63 m_elementContext = ElementResolveContext(); 63 m_elementContext = ElementResolveContext();
64 m_style = 0; 64 m_style = 0;
65 m_parentStyle = 0; 65 m_parentStyle = 0;
66 m_regionForStyling = 0; 66 m_regionForStyling = 0;
67 m_elementStyleResources.clear(); 67 m_elementStyleResources.clear();
68 } 68 }
69 69
70 void StyleResolverState::initForStyleResolve(Document* newDocument, Element* new Element, RenderStyle* parentStyle, RenderRegion* regionForStyling) 70 void StyleResolverState::initForStyleResolve(const Document* newDocument, Elemen t* newElement, RenderStyle* parentStyle, RenderRegion* regionForStyling)
71 { 71 {
72 ASSERT(!element() || document() == newDocument); 72 ASSERT(!element() || document() == newDocument);
73 if (newElement != element()) { 73 if (newElement != element()) {
74 if (newElement) 74 if (newElement)
75 m_elementContext = ElementResolveContext(newElement); 75 m_elementContext = ElementResolveContext(newElement);
76 else 76 else
77 m_elementContext = ElementResolveContext(); 77 m_elementContext = ElementResolveContext();
78
79 // FIXME: This method should not be modifying Document.
80 if (m_elementContext.isDocumentElement()) {
81 document()->setDirectionSetOnDocumentElement(false);
82 document()->setWritingModeSetOnDocumentElement(false);
83 }
84 } 78 }
85 79
86 m_regionForStyling = regionForStyling; 80 m_regionForStyling = regionForStyling;
87 81
88 if (m_elementContext.resetStyleInheritance()) 82 if (m_elementContext.resetStyleInheritance())
89 m_parentStyle = 0; 83 m_parentStyle = 0;
90 else if (parentStyle) 84 else if (parentStyle)
91 m_parentStyle = parentStyle; 85 m_parentStyle = parentStyle;
92 else if (m_elementContext.parentNode()) 86 else if (m_elementContext.parentNode())
93 m_parentStyle = m_elementContext.parentNode()->renderStyle(); 87 m_parentStyle = m_elementContext.parentNode()->renderStyle();
94 else 88 else
95 m_parentStyle = 0; 89 m_parentStyle = 0;
96 90
97 m_style = 0; 91 m_style = 0;
98 m_elementStyleResources.clear(); 92 m_elementStyleResources.clear();
99 m_fontDirty = false; 93 m_fontDirty = false;
100 94
101 // FIXME: StyleResolverState is never passed between documents 95 // FIXME: StyleResolverState is never passed between documents
102 // so we should be able to do this initialization at StyleResolverState 96 // so we should be able to do this initialization at StyleResolverState
103 // createion time instead of now, correct? 97 // createion time instead of now, correct?
104 if (Page* page = newDocument->page()) 98 if (Page* page = newDocument->page())
105 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor()); 99 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor());
106 } 100 }
107 101
108 } // namespace WebCore 102 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolverState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698