| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/html/HTMLAnchorElement.h" | 37 #include "core/html/HTMLAnchorElement.h" |
| 38 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/HTMLHtmlElement.h" | 39 #include "core/html/HTMLHtmlElement.h" |
| 40 #include "core/html/HTMLTableElement.h" | 40 #include "core/html/HTMLTableElement.h" |
| 41 #include "core/page/EventHandler.h" | 41 #include "core/page/EventHandler.h" |
| 42 #include "core/page/Frame.h" | 42 #include "core/page/Frame.h" |
| 43 #include "core/page/FrameView.h" | 43 #include "core/page/FrameView.h" |
| 44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 45 #include "core/page/Settings.h" | 45 #include "core/page/Settings.h" |
| 46 #include "core/page/animation/AnimationController.h" | 46 #include "core/page/animation/AnimationController.h" |
| 47 #include "core/platform/Partitions.h" |
| 47 #include "core/platform/graphics/FloatQuad.h" | 48 #include "core/platform/graphics/FloatQuad.h" |
| 48 #include "core/platform/graphics/GraphicsContext.h" | 49 #include "core/platform/graphics/GraphicsContext.h" |
| 49 #include "core/platform/graphics/transforms/TransformState.h" | 50 #include "core/platform/graphics/transforms/TransformState.h" |
| 50 #include "core/rendering/FlowThreadController.h" | 51 #include "core/rendering/FlowThreadController.h" |
| 51 #include "core/rendering/HitTestResult.h" | 52 #include "core/rendering/HitTestResult.h" |
| 52 #include "core/rendering/RenderArena.h" | |
| 53 #include "core/rendering/RenderCounter.h" | 53 #include "core/rendering/RenderCounter.h" |
| 54 #include "core/rendering/RenderDeprecatedFlexibleBox.h" | 54 #include "core/rendering/RenderDeprecatedFlexibleBox.h" |
| 55 #include "core/rendering/RenderFlexibleBox.h" | 55 #include "core/rendering/RenderFlexibleBox.h" |
| 56 #include "core/rendering/RenderGeometryMap.h" | 56 #include "core/rendering/RenderGeometryMap.h" |
| 57 #include "core/rendering/RenderGrid.h" | 57 #include "core/rendering/RenderGrid.h" |
| 58 #include "core/rendering/RenderImage.h" | 58 #include "core/rendering/RenderImage.h" |
| 59 #include "core/rendering/RenderImageResourceStyleImage.h" | 59 #include "core/rendering/RenderImageResourceStyleImage.h" |
| 60 #include "core/rendering/RenderInline.h" | 60 #include "core/rendering/RenderInline.h" |
| 61 #include "core/rendering/RenderLayer.h" | 61 #include "core/rendering/RenderLayer.h" |
| 62 #include "core/rendering/RenderLayerBacking.h" | 62 #include "core/rendering/RenderLayerBacking.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 84 #include <algorithm> | 84 #include <algorithm> |
| 85 #include <stdio.h> | 85 #include <stdio.h> |
| 86 | 86 |
| 87 using namespace std; | 87 using namespace std; |
| 88 | 88 |
| 89 namespace WebCore { | 89 namespace WebCore { |
| 90 | 90 |
| 91 using namespace HTMLNames; | 91 using namespace HTMLNames; |
| 92 | 92 |
| 93 #ifndef NDEBUG | 93 #ifndef NDEBUG |
| 94 static void* baseOfRenderObjectBeingDeleted; | |
| 95 | 94 |
| 96 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende
rObject* renderObject, bool isForbidden) | 95 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende
rObject* renderObject, bool isForbidden) |
| 97 : m_renderObject(renderObject) | 96 : m_renderObject(renderObject) |
| 98 , m_preexistingForbidden(m_renderObject->isSetNeedsLayoutForbidden()) | 97 , m_preexistingForbidden(m_renderObject->isSetNeedsLayoutForbidden()) |
| 99 { | 98 { |
| 100 m_renderObject->setNeedsLayoutIsForbidden(isForbidden); | 99 m_renderObject->setNeedsLayoutIsForbidden(isForbidden); |
| 101 } | 100 } |
| 102 | 101 |
| 103 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() | 102 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() |
| 104 { | 103 { |
| 105 m_renderObject->setNeedsLayoutIsForbidden(m_preexistingForbidden); | 104 m_renderObject->setNeedsLayoutIsForbidden(m_preexistingForbidden); |
| 106 } | 105 } |
| 107 #endif | 106 #endif |
| 108 | 107 |
| 109 struct SameSizeAsRenderObject { | 108 struct SameSizeAsRenderObject { |
| 110 virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer. | 109 virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer. |
| 111 void* pointers[5]; | 110 void* pointers[5]; |
| 112 #ifndef NDEBUG | 111 #ifndef NDEBUG |
| 113 unsigned m_debugBitfields : 2; | 112 unsigned m_debugBitfields : 2; |
| 114 #endif | 113 #endif |
| 115 unsigned m_bitfields; | 114 unsigned m_bitfields; |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 COMPILE_ASSERT(sizeof(RenderObject) == sizeof(SameSizeAsRenderObject), RenderObj
ect_should_stay_small); | 117 COMPILE_ASSERT(sizeof(RenderObject) == sizeof(SameSizeAsRenderObject), RenderObj
ect_should_stay_small); |
| 119 | 118 |
| 120 bool RenderObject::s_affectsParentBlock = false; | 119 bool RenderObject::s_affectsParentBlock = false; |
| 121 | 120 |
| 122 RenderObjectAncestorLineboxDirtySet* RenderObject::s_ancestorLineboxDirtySet = 0
; | 121 RenderObjectAncestorLineboxDirtySet* RenderObject::s_ancestorLineboxDirtySet = 0
; |
| 123 | 122 |
| 124 void* RenderObject::operator new(size_t sz, RenderArena* renderArena) | 123 void* RenderObject::operator new(size_t sz) |
| 125 { | 124 { |
| 126 return renderArena->allocate(sz); | 125 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void RenderObject::operator delete(void* ptr, size_t sz) | 128 void RenderObject::operator delete(void* ptr) |
| 130 { | 129 { |
| 131 ASSERT(baseOfRenderObjectBeingDeleted == ptr); | 130 partitionFree(ptr); |
| 132 | |
| 133 // Stash size where destroy can find it. | |
| 134 *(size_t *)ptr = sz; | |
| 135 } | 131 } |
| 136 | 132 |
| 137 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) | 133 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) |
| 138 { | 134 { |
| 139 Document* doc = element->document(); | 135 Document* doc = element->document(); |
| 140 RenderArena* arena = doc->renderArena(); | |
| 141 | 136 |
| 142 // Minimal support for content properties replacing an entire element. | 137 // Minimal support for content properties replacing an entire element. |
| 143 // Works only if we have exactly one piece of content and it's a URL. | 138 // Works only if we have exactly one piece of content and it's a URL. |
| 144 // Otherwise acts as if we didn't support this feature. | 139 // Otherwise acts as if we didn't support this feature. |
| 145 const ContentData* contentData = style->contentData(); | 140 const ContentData* contentData = style->contentData(); |
| 146 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { | 141 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { |
| 147 RenderImage* image = new (arena) RenderImage(element); | 142 RenderImage* image = new RenderImage(element); |
| 148 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to | 143 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to |
| 149 // trigger a style change now as the node is not fully attached. Moving
this code to style change | 144 // trigger a style change now as the node is not fully attached. Moving
this code to style change |
| 150 // doesn't make sense as it should be run once at renderer creation. | 145 // doesn't make sense as it should be run once at renderer creation. |
| 151 image->setStyleInternal(style); | 146 image->setStyleInternal(style); |
| 152 if (const StyleImage* styleImage = static_cast<const ImageContentData*>(
contentData)->image()) { | 147 if (const StyleImage* styleImage = static_cast<const ImageContentData*>(
contentData)->image()) { |
| 153 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); | 148 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); |
| 154 image->setIsGeneratedContent(); | 149 image->setIsGeneratedContent(); |
| 155 } else | 150 } else |
| 156 image->setImageResource(RenderImageResource::create()); | 151 image->setImageResource(RenderImageResource::create()); |
| 157 image->setStyleInternal(0); | 152 image->setStyleInternal(0); |
| 158 return image; | 153 return image; |
| 159 } | 154 } |
| 160 | 155 |
| 161 if (element->hasTagName(rubyTag)) { | 156 if (element->hasTagName(rubyTag)) { |
| 162 if (style->display() == INLINE) | 157 if (style->display() == INLINE) |
| 163 return new (arena) RenderRubyAsInline(element); | 158 return new RenderRubyAsInline(element); |
| 164 else if (style->display() == BLOCK) | 159 else if (style->display() == BLOCK) |
| 165 return new (arena) RenderRubyAsBlock(element); | 160 return new RenderRubyAsBlock(element); |
| 166 } | 161 } |
| 167 // treat <rt> as ruby text ONLY if it still has its default treatment of blo
ck | 162 // treat <rt> as ruby text ONLY if it still has its default treatment of blo
ck |
| 168 if (element->hasTagName(rtTag) && style->display() == BLOCK) | 163 if (element->hasTagName(rtTag) && style->display() == BLOCK) |
| 169 return new (arena) RenderRubyText(element); | 164 return new RenderRubyText(element); |
| 170 if (RuntimeEnabledFeatures::cssRegionsEnabled() && style->isDisplayRegionTyp
e() && !style->regionThread().isEmpty() && doc->renderView()) | 165 if (RuntimeEnabledFeatures::cssRegionsEnabled() && style->isDisplayRegionTyp
e() && !style->regionThread().isEmpty() && doc->renderView()) |
| 171 return new (arena) RenderRegion(element, 0); | 166 return new RenderRegion(element, 0); |
| 172 switch (style->display()) { | 167 switch (style->display()) { |
| 173 case NONE: | 168 case NONE: |
| 174 return 0; | 169 return 0; |
| 175 case INLINE: | 170 case INLINE: |
| 176 return new (arena) RenderInline(element); | 171 return new RenderInline(element); |
| 177 case BLOCK: | 172 case BLOCK: |
| 178 case INLINE_BLOCK: | 173 case INLINE_BLOCK: |
| 179 case RUN_IN: | 174 case RUN_IN: |
| 180 case COMPACT: | 175 case COMPACT: |
| 181 if ((!style->hasAutoColumnCount() || !style->hasAutoColumnWidth()) && do
c->regionBasedColumnsEnabled()) | 176 if ((!style->hasAutoColumnCount() || !style->hasAutoColumnWidth()) && do
c->regionBasedColumnsEnabled()) |
| 182 return new (arena) RenderMultiColumnBlock(element); | 177 return new RenderMultiColumnBlock(element); |
| 183 return new (arena) RenderBlock(element); | 178 return new RenderBlock(element); |
| 184 case LIST_ITEM: | 179 case LIST_ITEM: |
| 185 return new (arena) RenderListItem(element); | 180 return new RenderListItem(element); |
| 186 case TABLE: | 181 case TABLE: |
| 187 case INLINE_TABLE: | 182 case INLINE_TABLE: |
| 188 return new (arena) RenderTable(element); | 183 return new RenderTable(element); |
| 189 case TABLE_ROW_GROUP: | 184 case TABLE_ROW_GROUP: |
| 190 case TABLE_HEADER_GROUP: | 185 case TABLE_HEADER_GROUP: |
| 191 case TABLE_FOOTER_GROUP: | 186 case TABLE_FOOTER_GROUP: |
| 192 return new (arena) RenderTableSection(element); | 187 return new RenderTableSection(element); |
| 193 case TABLE_ROW: | 188 case TABLE_ROW: |
| 194 return new (arena) RenderTableRow(element); | 189 return new RenderTableRow(element); |
| 195 case TABLE_COLUMN_GROUP: | 190 case TABLE_COLUMN_GROUP: |
| 196 case TABLE_COLUMN: | 191 case TABLE_COLUMN: |
| 197 return new (arena) RenderTableCol(element); | 192 return new RenderTableCol(element); |
| 198 case TABLE_CELL: | 193 case TABLE_CELL: |
| 199 return new (arena) RenderTableCell(element); | 194 return new RenderTableCell(element); |
| 200 case TABLE_CAPTION: | 195 case TABLE_CAPTION: |
| 201 return new (arena) RenderTableCaption(element); | 196 return new RenderTableCaption(element); |
| 202 case BOX: | 197 case BOX: |
| 203 case INLINE_BOX: | 198 case INLINE_BOX: |
| 204 return new (arena) RenderDeprecatedFlexibleBox(element); | 199 return new RenderDeprecatedFlexibleBox(element); |
| 205 case FLEX: | 200 case FLEX: |
| 206 case INLINE_FLEX: | 201 case INLINE_FLEX: |
| 207 return new (arena) RenderFlexibleBox(element); | 202 return new RenderFlexibleBox(element); |
| 208 case GRID: | 203 case GRID: |
| 209 case INLINE_GRID: | 204 case INLINE_GRID: |
| 210 return new (arena) RenderGrid(element); | 205 return new RenderGrid(element); |
| 211 case LAZY_BLOCK: | 206 case LAZY_BLOCK: |
| 212 return new (arena) RenderLazyBlock(element); | 207 return new RenderLazyBlock(element); |
| 213 } | 208 } |
| 214 | 209 |
| 215 return 0; | 210 return 0; |
| 216 } | 211 } |
| 217 | 212 |
| 218 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("Rend
erObject")); | 213 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("Rend
erObject")); |
| 219 | 214 |
| 220 RenderObject::RenderObject(Node* node) | 215 RenderObject::RenderObject(Node* node) |
| 221 : CachedImageClient() | 216 : CachedImageClient() |
| 222 , m_style(0) | 217 , m_style(0) |
| (...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 } | 2622 } |
| 2628 | 2623 |
| 2629 destroyRoot->destroy(); | 2624 destroyRoot->destroy(); |
| 2630 | 2625 |
| 2631 // WARNING: |this| is deleted here. | 2626 // WARNING: |this| is deleted here. |
| 2632 } | 2627 } |
| 2633 | 2628 |
| 2634 void RenderObject::destroy() | 2629 void RenderObject::destroy() |
| 2635 { | 2630 { |
| 2636 willBeDestroyed(); | 2631 willBeDestroyed(); |
| 2637 arenaDelete(renderArena(), this); | 2632 postDestroy(); |
| 2638 } | 2633 } |
| 2639 | 2634 |
| 2640 void RenderObject::arenaDelete(RenderArena* arena, void* base) | 2635 void RenderObject::postDestroy() |
| 2641 { | 2636 { |
| 2637 // It seems ugly that this is not in willBeDestroyed(). |
| 2642 if (m_style) { | 2638 if (m_style) { |
| 2643 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bg
Layer = bgLayer->next()) { | 2639 for (const FillLayer* bgLayer = m_style->backgroundLayers(); bgLayer; bg
Layer = bgLayer->next()) { |
| 2644 if (StyleImage* backgroundImage = bgLayer->image()) | 2640 if (StyleImage* backgroundImage = bgLayer->image()) |
| 2645 backgroundImage->removeClient(this); | 2641 backgroundImage->removeClient(this); |
| 2646 } | 2642 } |
| 2647 | 2643 |
| 2648 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; mask
Layer = maskLayer->next()) { | 2644 for (const FillLayer* maskLayer = m_style->maskLayers(); maskLayer; mask
Layer = maskLayer->next()) { |
| 2649 if (StyleImage* maskImage = maskLayer->image()) | 2645 if (StyleImage* maskImage = maskLayer->image()) |
| 2650 maskImage->removeClient(this); | 2646 maskImage->removeClient(this); |
| 2651 } | 2647 } |
| 2652 | 2648 |
| 2653 if (StyleImage* borderImage = m_style->borderImage().image()) | 2649 if (StyleImage* borderImage = m_style->borderImage().image()) |
| 2654 borderImage->removeClient(this); | 2650 borderImage->removeClient(this); |
| 2655 | 2651 |
| 2656 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) | 2652 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) |
| 2657 maskBoxImage->removeClient(this); | 2653 maskBoxImage->removeClient(this); |
| 2658 } | 2654 } |
| 2659 | 2655 |
| 2660 #ifndef NDEBUG | |
| 2661 void* savedBase = baseOfRenderObjectBeingDeleted; | |
| 2662 baseOfRenderObjectBeingDeleted = base; | |
| 2663 #endif | |
| 2664 delete this; | 2656 delete this; |
| 2665 #ifndef NDEBUG | |
| 2666 baseOfRenderObjectBeingDeleted = savedBase; | |
| 2667 #endif | |
| 2668 | |
| 2669 // Recover the size left there for us by operator delete and free the memory
. | |
| 2670 arena->free(*(size_t*)base, base); | |
| 2671 } | 2657 } |
| 2672 | 2658 |
| 2673 VisiblePosition RenderObject::positionForPoint(const LayoutPoint&) | 2659 VisiblePosition RenderObject::positionForPoint(const LayoutPoint&) |
| 2674 { | 2660 { |
| 2675 return createVisiblePosition(caretMinOffset(), DOWNSTREAM); | 2661 return createVisiblePosition(caretMinOffset(), DOWNSTREAM); |
| 2676 } | 2662 } |
| 2677 | 2663 |
| 2678 void RenderObject::updateDragState(bool dragOn) | 2664 void RenderObject::updateDragState(bool dragOn) |
| 2679 { | 2665 { |
| 2680 bool valueChanged = (dragOn != isDragging()); | 2666 bool valueChanged = (dragOn != isDragging()); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3279 { | 3265 { |
| 3280 if (object1) { | 3266 if (object1) { |
| 3281 const WebCore::RenderObject* root = object1; | 3267 const WebCore::RenderObject* root = object1; |
| 3282 while (root->parent()) | 3268 while (root->parent()) |
| 3283 root = root->parent(); | 3269 root = root->parent(); |
| 3284 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3270 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3285 } | 3271 } |
| 3286 } | 3272 } |
| 3287 | 3273 |
| 3288 #endif | 3274 #endif |
| OLD | NEW |