| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "config.h" | 20 #include "config.h" |
| 21 #include "core/rendering/InlineBox.h" | 21 #include "core/rendering/InlineBox.h" |
| 22 | 22 |
| 23 #include "core/dom/WebCoreMemoryInstrumentation.h" | 23 #include "core/dom/WebCoreMemoryInstrumentation.h" |
| 24 #include "core/platform/Partitions.h" |
| 24 #include "core/platform/graphics/FontMetrics.h" | 25 #include "core/platform/graphics/FontMetrics.h" |
| 25 #include "core/rendering/InlineFlowBox.h" | 26 #include "core/rendering/InlineFlowBox.h" |
| 26 #include "core/rendering/PaintInfo.h" | 27 #include "core/rendering/PaintInfo.h" |
| 27 #include "core/rendering/RenderArena.h" | |
| 28 #include "core/rendering/RenderBlock.h" | 28 #include "core/rendering/RenderBlock.h" |
| 29 #include "core/rendering/RootInlineBox.h" | 29 #include "core/rendering/RootInlineBox.h" |
| 30 | 30 |
| 31 #ifndef NDEBUG | 31 #ifndef NDEBUG |
| 32 #include <stdio.h> | 32 #include <stdio.h> |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using namespace std; | 35 using namespace std; |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 struct SameSizeAsInlineBox { | 39 struct SameSizeAsInlineBox { |
| 40 virtual ~SameSizeAsInlineBox() { } | 40 virtual ~SameSizeAsInlineBox() { } |
| 41 void* a[4]; | 41 void* a[4]; |
| 42 FloatPoint b; | 42 FloatPoint b; |
| 43 float c; | 43 float c; |
| 44 uint32_t d : 32; | 44 uint32_t d : 32; |
| 45 #ifndef NDEBUG | 45 #ifndef NDEBUG |
| 46 bool f; | 46 bool f; |
| 47 #endif | 47 #endif |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 COMPILE_ASSERT(sizeof(InlineBox) == sizeof(SameSizeAsInlineBox), InlineBox_size_
guard); | 50 COMPILE_ASSERT(sizeof(InlineBox) == sizeof(SameSizeAsInlineBox), InlineBox_size_
guard); |
| 51 | 51 |
| 52 #ifndef NDEBUG | 52 #ifndef NDEBUG |
| 53 static bool inInlineBoxDetach; | |
| 54 #endif | |
| 55 | |
| 56 #ifndef NDEBUG | |
| 57 | 53 |
| 58 InlineBox::~InlineBox() | 54 InlineBox::~InlineBox() |
| 59 { | 55 { |
| 60 if (!m_hasBadParent && m_parent) | 56 if (!m_hasBadParent && m_parent) |
| 61 m_parent->setHasBadChildList(); | 57 m_parent->setHasBadChildList(); |
| 62 } | 58 } |
| 63 | 59 |
| 64 #endif | 60 #endif |
| 65 | 61 |
| 66 void InlineBox::remove() | 62 void InlineBox::remove() |
| 67 { | 63 { |
| 68 if (parent()) | 64 if (parent()) |
| 69 parent()->removeChild(this); | 65 parent()->removeChild(this); |
| 70 } | 66 } |
| 71 | 67 |
| 72 void InlineBox::destroy(RenderArena* renderArena) | 68 void InlineBox::destroy() |
| 73 { | 69 { |
| 74 #ifndef NDEBUG | |
| 75 inInlineBoxDetach = true; | |
| 76 #endif | |
| 77 delete this; | 70 delete this; |
| 78 #ifndef NDEBUG | |
| 79 inInlineBoxDetach = false; | |
| 80 #endif | |
| 81 | |
| 82 // Recover the size left there for us by operator delete and free the memory
. | |
| 83 renderArena->free(*(size_t *)this, this); | |
| 84 } | 71 } |
| 85 | 72 |
| 86 void* InlineBox::operator new(size_t sz, RenderArena* renderArena) | 73 #if ENABLE(PARTITION_ALLOC) |
| 74 void* InlineBox::operator new(size_t sz) |
| 87 { | 75 { |
| 88 return renderArena->allocate(sz); | 76 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
| 89 } | 77 } |
| 90 | 78 |
| 91 void InlineBox::operator delete(void* ptr, size_t sz) | 79 void InlineBox::operator delete(void* ptr) |
| 92 { | 80 { |
| 93 ASSERT(inInlineBoxDetach); | 81 partitionFree(ptr); |
| 94 | |
| 95 // Stash size where destroy can find it. | |
| 96 *(size_t *)ptr = sz; | |
| 97 } | 82 } |
| 83 #endif |
| 98 | 84 |
| 99 #ifndef NDEBUG | 85 #ifndef NDEBUG |
| 100 const char* InlineBox::boxName() const | 86 const char* InlineBox::boxName() const |
| 101 { | 87 { |
| 102 return "InlineBox"; | 88 return "InlineBox"; |
| 103 } | 89 } |
| 104 | 90 |
| 105 void InlineBox::showTreeForThis() const | 91 void InlineBox::showTreeForThis() const |
| 106 { | 92 { |
| 107 if (m_renderer) | 93 if (m_renderer) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return m_renderer->caretMaxOffset(); | 163 return m_renderer->caretMaxOffset(); |
| 178 } | 164 } |
| 179 | 165 |
| 180 void InlineBox::dirtyLineBoxes() | 166 void InlineBox::dirtyLineBoxes() |
| 181 { | 167 { |
| 182 markDirty(); | 168 markDirty(); |
| 183 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) | 169 for (InlineFlowBox* curr = parent(); curr && !curr->isDirty(); curr = curr->
parent()) |
| 184 curr->markDirty(); | 170 curr->markDirty(); |
| 185 } | 171 } |
| 186 | 172 |
| 187 void InlineBox::deleteLine(RenderArena* arena) | 173 void InlineBox::deleteLine() |
| 188 { | 174 { |
| 189 if (!m_bitfields.extracted() && m_renderer->isBox()) | 175 if (!m_bitfields.extracted() && m_renderer->isBox()) |
| 190 toRenderBox(m_renderer)->setInlineBoxWrapper(0); | 176 toRenderBox(m_renderer)->setInlineBoxWrapper(0); |
| 191 destroy(arena); | 177 destroy(); |
| 192 } | 178 } |
| 193 | 179 |
| 194 void InlineBox::extractLine() | 180 void InlineBox::extractLine() |
| 195 { | 181 { |
| 196 m_bitfields.setExtracted(true); | 182 m_bitfields.setExtracted(true); |
| 197 if (m_renderer->isBox()) | 183 if (m_renderer->isBox()) |
| 198 toRenderBox(m_renderer)->setInlineBoxWrapper(0); | 184 toRenderBox(m_renderer)->setInlineBoxWrapper(0); |
| 199 } | 185 } |
| 200 | 186 |
| 201 void InlineBox::attachLine() | 187 void InlineBox::attachLine() |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 b->showTreeForThis(); | 396 b->showTreeForThis(); |
| 411 } | 397 } |
| 412 | 398 |
| 413 void showLineTree(const WebCore::InlineBox* b) | 399 void showLineTree(const WebCore::InlineBox* b) |
| 414 { | 400 { |
| 415 if (b) | 401 if (b) |
| 416 b->showLineTreeForThis(); | 402 b->showLineTreeForThis(); |
| 417 } | 403 } |
| 418 | 404 |
| 419 #endif | 405 #endif |
| OLD | NEW |