OLD | NEW |
---|---|
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 22 matching lines...) Expand all Loading... | |
33 #include "core/editing/EditingBoundary.h" | 33 #include "core/editing/EditingBoundary.h" |
34 #include "core/editing/FrameSelection.h" | 34 #include "core/editing/FrameSelection.h" |
35 #include "core/editing/htmlediting.h" | 35 #include "core/editing/htmlediting.h" |
36 #include "core/html/HTMLElement.h" | 36 #include "core/html/HTMLElement.h" |
37 #include "core/page/EventHandler.h" | 37 #include "core/page/EventHandler.h" |
38 #include "core/page/Frame.h" | 38 #include "core/page/Frame.h" |
39 #include "core/page/FrameView.h" | 39 #include "core/page/FrameView.h" |
40 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
41 #include "core/page/Settings.h" | 41 #include "core/page/Settings.h" |
42 #include "core/page/animation/AnimationController.h" | 42 #include "core/page/animation/AnimationController.h" |
43 #include "core/platform/Partitions.h" | |
43 #include "core/platform/graphics/FloatQuad.h" | 44 #include "core/platform/graphics/FloatQuad.h" |
44 #include "core/platform/graphics/GraphicsContext.h" | 45 #include "core/platform/graphics/GraphicsContext.h" |
45 #include "core/platform/graphics/transforms/TransformState.h" | 46 #include "core/platform/graphics/transforms/TransformState.h" |
46 #include "core/rendering/FlowThreadController.h" | 47 #include "core/rendering/FlowThreadController.h" |
47 #include "core/rendering/HitTestResult.h" | 48 #include "core/rendering/HitTestResult.h" |
48 #include "core/rendering/RenderArena.h" | |
49 #include "core/rendering/RenderCounter.h" | 49 #include "core/rendering/RenderCounter.h" |
50 #include "core/rendering/RenderDeprecatedFlexibleBox.h" | 50 #include "core/rendering/RenderDeprecatedFlexibleBox.h" |
51 #include "core/rendering/RenderFlexibleBox.h" | 51 #include "core/rendering/RenderFlexibleBox.h" |
52 #include "core/rendering/RenderGeometryMap.h" | 52 #include "core/rendering/RenderGeometryMap.h" |
53 #include "core/rendering/RenderGrid.h" | 53 #include "core/rendering/RenderGrid.h" |
54 #include "core/rendering/RenderImage.h" | 54 #include "core/rendering/RenderImage.h" |
55 #include "core/rendering/RenderImageResourceStyleImage.h" | 55 #include "core/rendering/RenderImageResourceStyleImage.h" |
56 #include "core/rendering/RenderInline.h" | 56 #include "core/rendering/RenderInline.h" |
57 #include "core/rendering/RenderLayer.h" | 57 #include "core/rendering/RenderLayer.h" |
58 #include "core/rendering/RenderLayerBacking.h" | 58 #include "core/rendering/RenderLayerBacking.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
80 #include <algorithm> | 80 #include <algorithm> |
81 #include <stdio.h> | 81 #include <stdio.h> |
82 | 82 |
83 using namespace std; | 83 using namespace std; |
84 | 84 |
85 namespace WebCore { | 85 namespace WebCore { |
86 | 86 |
87 using namespace HTMLNames; | 87 using namespace HTMLNames; |
88 | 88 |
89 #ifndef NDEBUG | 89 #ifndef NDEBUG |
90 static void* baseOfRenderObjectBeingDeleted; | |
91 | 90 |
92 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende rObject* renderObject, bool isForbidden) | 91 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende rObject* renderObject, bool isForbidden) |
93 : m_renderObject(renderObject) | 92 : m_renderObject(renderObject) |
94 , m_preexistingForbidden(m_renderObject->isSetNeedsLayoutForbidden()) | 93 , m_preexistingForbidden(m_renderObject->isSetNeedsLayoutForbidden()) |
95 { | 94 { |
96 m_renderObject->setNeedsLayoutIsForbidden(isForbidden); | 95 m_renderObject->setNeedsLayoutIsForbidden(isForbidden); |
97 } | 96 } |
98 | 97 |
99 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() | 98 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() |
100 { | 99 { |
101 m_renderObject->setNeedsLayoutIsForbidden(m_preexistingForbidden); | 100 m_renderObject->setNeedsLayoutIsForbidden(m_preexistingForbidden); |
102 } | 101 } |
103 #endif | 102 #endif |
104 | 103 |
105 struct SameSizeAsRenderObject { | 104 struct SameSizeAsRenderObject { |
106 virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer. | 105 virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer. |
107 void* pointers[5]; | 106 void* pointers[5]; |
108 #ifndef NDEBUG | 107 #ifndef NDEBUG |
109 unsigned m_debugBitfields : 2; | 108 unsigned m_debugBitfields : 2; |
110 #endif | 109 #endif |
111 unsigned m_bitfields; | 110 unsigned m_bitfields; |
112 }; | 111 }; |
113 | 112 |
114 COMPILE_ASSERT(sizeof(RenderObject) == sizeof(SameSizeAsRenderObject), RenderObj ect_should_stay_small); | 113 COMPILE_ASSERT(sizeof(RenderObject) == sizeof(SameSizeAsRenderObject), RenderObj ect_should_stay_small); |
115 | 114 |
116 bool RenderObject::s_affectsParentBlock = false; | 115 bool RenderObject::s_affectsParentBlock = false; |
117 | 116 |
118 RenderObjectAncestorLineboxDirtySet* RenderObject::s_ancestorLineboxDirtySet = 0 ; | 117 RenderObjectAncestorLineboxDirtySet* RenderObject::s_ancestorLineboxDirtySet = 0 ; |
119 | 118 |
120 void* RenderObject::operator new(size_t sz, RenderArena* renderArena) | 119 #if ENABLE(PARTITION_ALLOC) |
120 void* RenderObject::operator new(size_t sz) | |
121 { | 121 { |
122 return renderArena->allocate(sz); | 122 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
esprehn
2013/06/20 09:15:44
This is bad, now you don't pack the render tree fo
| |
123 } | 123 } |
124 | 124 |
125 void RenderObject::operator delete(void* ptr, size_t sz) | 125 void RenderObject::operator delete(void* ptr) |
126 { | 126 { |
127 ASSERT(baseOfRenderObjectBeingDeleted == ptr); | 127 partitionFree(ptr); |
128 | |
129 // Stash size where destroy can find it. | |
130 *(size_t *)ptr = sz; | |
131 } | 128 } |
129 #endif | |
132 | 130 |
133 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) | 131 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) |
134 { | 132 { |
135 Document* doc = element->document(); | 133 Document* doc = element->document(); |
136 RenderArena* arena = doc->renderArena(); | |
137 | 134 |
138 // Minimal support for content properties replacing an entire element. | 135 // Minimal support for content properties replacing an entire element. |
139 // Works only if we have exactly one piece of content and it's a URL. | 136 // Works only if we have exactly one piece of content and it's a URL. |
140 // Otherwise acts as if we didn't support this feature. | 137 // Otherwise acts as if we didn't support this feature. |
141 const ContentData* contentData = style->contentData(); | 138 const ContentData* contentData = style->contentData(); |
142 if (contentData && !contentData->next() && contentData->isImage() && !elemen t->isPseudoElement()) { | 139 if (contentData && !contentData->next() && contentData->isImage() && !elemen t->isPseudoElement()) { |
143 RenderImage* image = new (arena) RenderImage(element); | 140 RenderImage* image = new RenderImage(element); |
144 // RenderImageResourceStyleImage requires a style being present on the i mage but we don't want to | 141 // RenderImageResourceStyleImage requires a style being present on the i mage but we don't want to |
145 // trigger a style change now as the node is not fully attached. Moving this code to style change | 142 // trigger a style change now as the node is not fully attached. Moving this code to style change |
146 // doesn't make sense as it should be run once at renderer creation. | 143 // doesn't make sense as it should be run once at renderer creation. |
147 image->setStyleInternal(style); | 144 image->setStyleInternal(style); |
148 if (const StyleImage* styleImage = static_cast<const ImageContentData*>( contentData)->image()) { | 145 if (const StyleImage* styleImage = static_cast<const ImageContentData*>( contentData)->image()) { |
149 image->setImageResource(RenderImageResourceStyleImage::create(const_ cast<StyleImage*>(styleImage))); | 146 image->setImageResource(RenderImageResourceStyleImage::create(const_ cast<StyleImage*>(styleImage))); |
150 image->setIsGeneratedContent(); | 147 image->setIsGeneratedContent(); |
151 } else | 148 } else |
152 image->setImageResource(RenderImageResource::create()); | 149 image->setImageResource(RenderImageResource::create()); |
153 image->setStyleInternal(0); | 150 image->setStyleInternal(0); |
154 return image; | 151 return image; |
155 } | 152 } |
156 | 153 |
157 if (element->hasTagName(rubyTag)) { | 154 if (element->hasTagName(rubyTag)) { |
158 if (style->display() == INLINE) | 155 if (style->display() == INLINE) |
159 return new (arena) RenderRubyAsInline(element); | 156 return new RenderRubyAsInline(element); |
160 else if (style->display() == BLOCK) | 157 else if (style->display() == BLOCK) |
161 return new (arena) RenderRubyAsBlock(element); | 158 return new RenderRubyAsBlock(element); |
162 } | 159 } |
163 // treat <rt> as ruby text ONLY if it still has its default treatment of blo ck | 160 // treat <rt> as ruby text ONLY if it still has its default treatment of blo ck |
164 if (element->hasTagName(rtTag) && style->display() == BLOCK) | 161 if (element->hasTagName(rtTag) && style->display() == BLOCK) |
165 return new (arena) RenderRubyText(element); | 162 return new RenderRubyText(element); |
166 if (RuntimeEnabledFeatures::cssRegionsEnabled() && style->isDisplayRegionTyp e() && !style->regionThread().isEmpty() && doc->renderView()) | 163 if (RuntimeEnabledFeatures::cssRegionsEnabled() && style->isDisplayRegionTyp e() && !style->regionThread().isEmpty() && doc->renderView()) |
167 return new (arena) RenderRegion(element, 0); | 164 return new RenderRegion(element, 0); |
168 switch (style->display()) { | 165 switch (style->display()) { |
169 case NONE: | 166 case NONE: |
170 return 0; | 167 return 0; |
171 case INLINE: | 168 case INLINE: |
172 return new (arena) RenderInline(element); | 169 return new RenderInline(element); |
173 case BLOCK: | 170 case BLOCK: |
174 case INLINE_BLOCK: | 171 case INLINE_BLOCK: |
175 case RUN_IN: | 172 case RUN_IN: |
176 case COMPACT: | 173 case COMPACT: |
177 if ((!style->hasAutoColumnCount() || !style->hasAutoColumnWidth()) && do c->regionBasedColumnsEnabled()) | 174 if ((!style->hasAutoColumnCount() || !style->hasAutoColumnWidth()) && do c->regionBasedColumnsEnabled()) |
178 return new (arena) RenderMultiColumnBlock(element); | 175 return new RenderMultiColumnBlock(element); |
179 return new (arena) RenderBlock(element); | 176 return new RenderBlock(element); |
180 case LIST_ITEM: | 177 case LIST_ITEM: |
181 return new (arena) RenderListItem(element); | 178 return new RenderListItem(element); |
182 case TABLE: | 179 case TABLE: |
183 case INLINE_TABLE: | 180 case INLINE_TABLE: |
184 return new (arena) RenderTable(element); | 181 return new RenderTable(element); |
185 case TABLE_ROW_GROUP: | 182 case TABLE_ROW_GROUP: |
186 case TABLE_HEADER_GROUP: | 183 case TABLE_HEADER_GROUP: |
187 case TABLE_FOOTER_GROUP: | 184 case TABLE_FOOTER_GROUP: |
188 return new (arena) RenderTableSection(element); | 185 return new RenderTableSection(element); |
189 case TABLE_ROW: | 186 case TABLE_ROW: |
190 return new (arena) RenderTableRow(element); | 187 return new RenderTableRow(element); |
191 case TABLE_COLUMN_GROUP: | 188 case TABLE_COLUMN_GROUP: |
192 case TABLE_COLUMN: | 189 case TABLE_COLUMN: |
193 return new (arena) RenderTableCol(element); | 190 return new RenderTableCol(element); |
194 case TABLE_CELL: | 191 case TABLE_CELL: |
195 return new (arena) RenderTableCell(element); | 192 return new RenderTableCell(element); |
196 case TABLE_CAPTION: | 193 case TABLE_CAPTION: |
197 return new (arena) RenderTableCaption(element); | 194 return new RenderTableCaption(element); |
198 case BOX: | 195 case BOX: |
199 case INLINE_BOX: | 196 case INLINE_BOX: |
200 return new (arena) RenderDeprecatedFlexibleBox(element); | 197 return new RenderDeprecatedFlexibleBox(element); |
201 case FLEX: | 198 case FLEX: |
202 case INLINE_FLEX: | 199 case INLINE_FLEX: |
203 return new (arena) RenderFlexibleBox(element); | 200 return new RenderFlexibleBox(element); |
204 case GRID: | 201 case GRID: |
205 case INLINE_GRID: | 202 case INLINE_GRID: |
206 return new (arena) RenderGrid(element); | 203 return new RenderGrid(element); |
207 case LAZY_BLOCK: | 204 case LAZY_BLOCK: |
208 return new (arena) RenderLazyBlock(element); | 205 return new RenderLazyBlock(element); |
209 } | 206 } |
210 | 207 |
211 return 0; | 208 return 0; |
212 } | 209 } |
213 | 210 |
214 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("Rend erObject")); | 211 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("Rend erObject")); |
215 | 212 |
216 RenderObject::RenderObject(Node* node) | 213 RenderObject::RenderObject(Node* node) |
217 : CachedImageClient() | 214 : CachedImageClient() |
218 , m_style(0) | 215 , m_style(0) |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2566 } | 2563 } |
2567 | 2564 |
2568 destroyRoot->destroy(); | 2565 destroyRoot->destroy(); |
2569 | 2566 |
2570 // WARNING: |this| is deleted here. | 2567 // WARNING: |this| is deleted here. |
2571 } | 2568 } |
2572 | 2569 |
2573 void RenderObject::destroy() | 2570 void RenderObject::destroy() |
2574 { | 2571 { |
2575 willBeDestroyed(); | 2572 willBeDestroyed(); |
2576 arenaDelete(renderArena(), this); | 2573 postDestroy(); |
2577 } | 2574 } |
2578 | 2575 |
2579 void RenderObject::arenaDelete(RenderArena* arena, void* base) | 2576 void RenderObject::postDestroy() |
2580 { | 2577 { |
2581 if (m_style) { | 2578 if (m_style) { |
2582 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bg Layer = bgLayer->next()) { | 2579 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bg Layer = bgLayer->next()) { |
2583 if (StyleImage* backgroundImage = bgLayer->image()) | 2580 if (StyleImage* backgroundImage = bgLayer->image()) |
2584 backgroundImage->removeClient(this); | 2581 backgroundImage->removeClient(this); |
2585 } | 2582 } |
2586 | 2583 |
2587 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; mask Layer = maskLayer->next()) { | 2584 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; mask Layer = maskLayer->next()) { |
2588 if (StyleImage* maskImage = maskLayer->image()) | 2585 if (StyleImage* maskImage = maskLayer->image()) |
2589 maskImage->removeClient(this); | 2586 maskImage->removeClient(this); |
2590 } | 2587 } |
2591 | 2588 |
2592 if (StyleImage* borderImage = m_style->borderImage().image()) | 2589 if (StyleImage* borderImage = m_style->borderImage().image()) |
2593 borderImage->removeClient(this); | 2590 borderImage->removeClient(this); |
2594 | 2591 |
2595 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) | 2592 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) |
2596 maskBoxImage->removeClient(this); | 2593 maskBoxImage->removeClient(this); |
2597 } | 2594 } |
2598 | 2595 |
2599 #ifndef NDEBUG | |
2600 void* savedBase = baseOfRenderObjectBeingDeleted; | |
2601 baseOfRenderObjectBeingDeleted = base; | |
2602 #endif | |
2603 delete this; | 2596 delete this; |
2604 #ifndef NDEBUG | |
2605 baseOfRenderObjectBeingDeleted = savedBase; | |
2606 #endif | |
2607 | |
2608 // Recover the size left there for us by operator delete and free the memory . | |
2609 arena->free(*(size_t*)base, base); | |
2610 } | 2597 } |
2611 | 2598 |
2612 VisiblePosition RenderObject::positionForPoint(const LayoutPoint&) | 2599 VisiblePosition RenderObject::positionForPoint(const LayoutPoint&) |
2613 { | 2600 { |
2614 return createVisiblePosition(caretMinOffset(), DOWNSTREAM); | 2601 return createVisiblePosition(caretMinOffset(), DOWNSTREAM); |
2615 } | 2602 } |
2616 | 2603 |
2617 void RenderObject::updateDragState(bool dragOn) | 2604 void RenderObject::updateDragState(bool dragOn) |
2618 { | 2605 { |
2619 bool valueChanged = (dragOn != isDragging()); | 2606 bool valueChanged = (dragOn != isDragging()); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3232 { | 3219 { |
3233 if (object1) { | 3220 if (object1) { |
3234 const WebCore::RenderObject* root = object1; | 3221 const WebCore::RenderObject* root = object1; |
3235 while (root->parent()) | 3222 while (root->parent()) |
3236 root = root->parent(); | 3223 root = root->parent(); |
3237 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3224 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3238 } | 3225 } |
3239 } | 3226 } |
3240 | 3227 |
3241 #endif | 3228 #endif |
OLD | NEW |