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

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

Issue 18276003: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removing extra parens (whoops) 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') | 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 16 matching lines...) Expand all
27 #include "core/dom/NodeRenderStyle.h" 27 #include "core/dom/NodeRenderStyle.h"
28 #include "core/dom/NodeRenderingContext.h" 28 #include "core/dom/NodeRenderingContext.h"
29 #include "core/dom/VisitedLinkState.h" 29 #include "core/dom/VisitedLinkState.h"
30 #include "core/page/Page.h" 30 #include "core/page/Page.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 void StyleResolverState::clear() 34 void StyleResolverState::clear()
35 { 35 {
36 m_element = 0; 36 m_element = 0;
37 m_childIndex = 0;
37 m_styledElement = 0; 38 m_styledElement = 0;
38 m_parentStyle = 0; 39 m_parentStyle = 0;
39 m_parentNode = 0; 40 m_parentNode = 0;
40 m_regionForStyling = 0; 41 m_regionForStyling = 0;
41 m_elementStyleResources.clear(); 42 m_elementStyleResources.clear();
42 } 43 }
43 44
44 void StyleResolverState::initElement(Element* element) 45 void StyleResolverState::initElement(Element* element, int childIndex)
45 { 46 {
46 if (m_element == element) 47 if (m_element == element)
47 return; 48 return;
48 49
49 m_element = element; 50 m_element = element;
50 m_styledElement = element && element->isStyledElement() ? element : 0; 51 m_styledElement = element && element->isStyledElement() ? element : 0;
51 m_elementLinkState = element ? element->document()->visitedLinkState()->dete rmineLinkState(element) : NotInsideLink; 52 m_elementLinkState = element ? element->document()->visitedLinkState()->dete rmineLinkState(element) : NotInsideLink;
52 53
53 if (!element || element != element->document()->documentElement()) 54 if (!element || element != element->document()->documentElement())
54 return; 55 return;
55 56
56 element->document()->setDirectionSetOnDocumentElement(false); 57 element->document()->setDirectionSetOnDocumentElement(false);
57 element->document()->setWritingModeSetOnDocumentElement(false); 58 element->document()->setWritingModeSetOnDocumentElement(false);
58 } 59 }
59 60
60 void StyleResolverState::initForStyleResolve(Document* document, Element* e, Ren derStyle* parentStyle, RenderRegion* regionForStyling) 61 void StyleResolverState::initForStyleResolve(Document* document, Element* e, int childIndex, RenderStyle* parentStyle, RenderRegion* regionForStyling)
61 { 62 {
62 initElement(e); 63 initElement(e, childIndex);
63 64
64 m_regionForStyling = regionForStyling; 65 m_regionForStyling = regionForStyling;
65 66
66 if (e) { 67 if (e) {
67 NodeRenderingContext context(e); 68 NodeRenderingContext context(e);
68 m_parentNode = context.parentNodeForRenderingAndStyle(); 69 m_parentNode = context.parentNodeForRenderingAndStyle();
69 m_parentStyle = context.resetStyleInheritance() ? 0 : 70 m_parentStyle = context.resetStyleInheritance() ? 0 :
70 parentStyle ? parentStyle : 71 parentStyle ? parentStyle :
71 m_parentNode ? m_parentNode->renderStyle() : 0; 72 m_parentNode ? m_parentNode->renderStyle() : 0;
72 m_distributedToInsertionPoint = context.insertionPoint(); 73 m_distributedToInsertionPoint = context.insertionPoint();
73 } else { 74 } else {
74 m_parentNode = 0; 75 m_parentNode = 0;
75 m_parentStyle = parentStyle; 76 m_parentStyle = parentStyle;
76 m_distributedToInsertionPoint = false; 77 m_distributedToInsertionPoint = false;
77 } 78 }
78 79
79 Node* docElement = e ? e->document()->documentElement() : 0; 80 Node* docElement = e ? e->document()->documentElement() : 0;
80 RenderStyle* docStyle = document->renderStyle(); 81 RenderStyle* docStyle = document->renderStyle();
81 m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle () : docStyle; 82 m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle () : docStyle;
82 83
83 m_style = 0; 84 m_style = 0;
84 m_elementStyleResources.clear(); 85 m_elementStyleResources.clear();
85 m_fontDirty = false; 86 m_fontDirty = false;
86 87
87 if (Page* page = document->page()) 88 if (Page* page = document->page())
88 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor()); 89 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor());
89 } 90 }
90 91
91 } // namespace WebCore 92 } // 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