summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/InlineBox.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/InlineBox.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/InlineBox.cpp')
-rw-r--r--Source/WebCore/rendering/InlineBox.cpp114
1 files changed, 67 insertions, 47 deletions
diff --git a/Source/WebCore/rendering/InlineBox.cpp b/Source/WebCore/rendering/InlineBox.cpp
index eb2b90efb..9266c1ce3 100644
--- a/Source/WebCore/rendering/InlineBox.cpp
+++ b/Source/WebCore/rendering/InlineBox.cpp
@@ -24,13 +24,11 @@
#include "Frame.h"
#include "HitTestResult.h"
#include "InlineFlowBox.h"
-#include "Page.h"
-#include "PaintInfo.h"
#include "RenderBlockFlow.h"
#include "RenderLineBreak.h"
#include "RootInlineBox.h"
-#ifndef NDEBUG
+#if ENABLE(TREE_DEBUGGING)
#include <stdio.h>
#endif
@@ -40,9 +38,11 @@ struct SameSizeAsInlineBox {
virtual ~SameSizeAsInlineBox() { }
void* a[4];
FloatPoint b;
- float c;
- uint32_t d : 32;
+ float c[2];
+ unsigned d; /*InlineBoxBitfields m_bitfields is padded to 32bits*/
#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
+ bool i;
+ unsigned s;
bool f;
#endif
};
@@ -50,11 +50,31 @@ struct SameSizeAsInlineBox {
COMPILE_ASSERT(sizeof(InlineBox) == sizeof(SameSizeAsInlineBox), InlineBox_size_guard);
#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
+
+void InlineBox::assertNotDeleted() const
+{
+ ASSERT(m_deletionSentinel == deletionSentinelNotDeletedValue);
+}
+
InlineBox::~InlineBox()
{
- if (!m_hasBadParent && m_parent)
+ invalidateParentChildList();
+ m_deletionSentinel = deletionSentinelDeletedValue;
+}
+
+void InlineBox::setHasBadParent()
+{
+ assertNotDeleted();
+ m_hasBadParent = true;
+}
+
+void InlineBox::invalidateParentChildList()
+{
+ assertNotDeleted();
+ if (!m_hasBadParent && m_parent && m_isEverInChildList)
m_parent->setHasBadChildList();
}
+
#endif
void InlineBox::removeFromParent()
@@ -63,45 +83,42 @@ void InlineBox::removeFromParent()
parent()->removeChild(this);
}
-#ifndef NDEBUG
+#if ENABLE(TREE_DEBUGGING)
+
const char* InlineBox::boxName() const
{
return "InlineBox";
}
-void InlineBox::showTreeForThis() const
+void InlineBox::showNodeTreeForThis() const
{
- m_renderer.showTreeForThis();
+ m_renderer.showNodeTreeForThis();
}
void InlineBox::showLineTreeForThis() const
{
- m_renderer.containingBlock()->showLineTreeAndMark(this, "*");
+ m_renderer.containingBlock()->showLineTreeForThis();
}
-void InlineBox::showLineTreeAndMark(const InlineBox* markedBox1, const char* markedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const RenderObject* obj, int depth) const
+void InlineBox::showLineTreeAndMark(const InlineBox* markedBox, int depth) const
{
- int printedCharacters = 0;
- if (this == markedBox1)
- printedCharacters += fprintf(stderr, "%s", markedLabel1);
- if (this == markedBox2)
- printedCharacters += fprintf(stderr, "%s", markedLabel2);
- if (&m_renderer == obj)
- printedCharacters += fprintf(stderr, "*");
- for (; printedCharacters < depth * 2; printedCharacters++)
- fputc(' ', stderr);
-
- showBox(printedCharacters);
+ showLineBox(markedBox == this, depth);
}
-void InlineBox::showBox(int printedCharacters) const
+void InlineBox::showLineBox(bool mark, int depth) const
{
- printedCharacters += fprintf(stderr, "%s\t%p", boxName(), this);
- for (; printedCharacters < showTreeCharacterOffset; printedCharacters++)
+ fprintf(stderr, "-------- %c-", isDirty() ? 'D' : '-');
+ int printedCharacters = 0;
+ if (mark) {
+ fprintf(stderr, "*");
+ ++printedCharacters;
+ }
+ while (++printedCharacters <= depth * 2)
fputc(' ', stderr);
- fprintf(stderr, "\t%s %p\n", renderer().renderName(), &renderer());
+ fprintf(stderr, "%s (%.2f, %.2f) (%.2f, %.2f) (%p) renderer->(%p)\n", boxName(), x(), y(), width(), height(), this, &renderer());
}
-#endif
+
+#endif // ENABLE(TREE_DEBUGGING)
float InlineBox::logicalHeight() const
{
@@ -111,8 +128,8 @@ float InlineBox::logicalHeight() const
const RenderStyle& lineStyle = this->lineStyle();
if (renderer().isTextOrLineBreak())
return behavesLikeText() ? lineStyle.fontMetrics().height() : 0;
- if (renderer().isBox() && parent())
- return isHorizontal() ? toRenderBox(renderer()).height() : toRenderBox(renderer()).width();
+ if (is<RenderBox>(renderer()) && parent())
+ return isHorizontal() ? downcast<RenderBox>(renderer()).height() : downcast<RenderBox>(renderer()).width();
ASSERT(isInlineFlowBox());
RenderBoxModelObject* flowObject = boxModelObject();
@@ -158,24 +175,25 @@ void InlineBox::adjustPosition(float dx, float dy)
{
m_topLeft.move(dx, dy);
+ if (m_renderer.isOutOfFlowPositioned())
+ return;
+
if (m_renderer.isReplaced())
- toRenderBox(renderer()).move(dx, dy);
+ downcast<RenderBox>(renderer()).move(dx, dy);
}
const RootInlineBox& InlineBox::root() const
{
if (parent())
return parent()->root();
- ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
- return toRootInlineBox(*this);
+ return downcast<RootInlineBox>(*this);
}
RootInlineBox& InlineBox::root()
{
if (parent())
return parent()->root();
- ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
- return toRootInlineBox(*this);
+ return downcast<RootInlineBox>(*this);
}
bool InlineBox::nextOnLineExists() const
@@ -204,9 +222,9 @@ bool InlineBox::previousOnLineExists() const
InlineBox* InlineBox::nextLeafChild() const
{
- InlineBox* leaf = 0;
+ InlineBox* leaf = nullptr;
for (InlineBox* box = nextOnLine(); box && !leaf; box = box->nextOnLine())
- leaf = box->isLeaf() ? box : toInlineFlowBox(box)->firstLeafChild();
+ leaf = box->isLeaf() ? box : downcast<InlineFlowBox>(*box).firstLeafChild();
if (!leaf && parent())
leaf = parent()->nextLeafChild();
return leaf;
@@ -214,9 +232,9 @@ InlineBox* InlineBox::nextLeafChild() const
InlineBox* InlineBox::prevLeafChild() const
{
- InlineBox* leaf = 0;
+ InlineBox* leaf = nullptr;
for (InlineBox* box = prevOnLine(); box && !leaf; box = box->prevOnLine())
- leaf = box->isLeaf() ? box : toInlineFlowBox(box)->lastLeafChild();
+ leaf = box->isLeaf() ? box : downcast<InlineFlowBox>(*box).lastLeafChild();
if (!leaf && parent())
leaf = parent()->prevLeafChild();
return leaf;
@@ -226,7 +244,7 @@ InlineBox* InlineBox::nextLeafChildIgnoringLineBreak() const
{
InlineBox* leaf = nextLeafChild();
if (leaf && leaf->isLineBreak())
- return 0;
+ return nullptr;
return leaf;
}
@@ -234,7 +252,7 @@ InlineBox* InlineBox::prevLeafChildIgnoringLineBreak() const
{
InlineBox* leaf = prevLeafChild();
if (leaf && leaf->isLineBreak())
- return 0;
+ return nullptr;
return leaf;
}
@@ -309,18 +327,20 @@ LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point)
} // namespace WebCore
-#ifndef NDEBUG
+#if ENABLE(TREE_DEBUGGING)
-void showTree(const WebCore::InlineBox* b)
+void showNodeTree(const WebCore::InlineBox* inlineBox)
{
- if (b)
- b->showTreeForThis();
+ if (!inlineBox)
+ return;
+ inlineBox->showNodeTreeForThis();
}
-void showLineTree(const WebCore::InlineBox* b)
+void showLineTree(const WebCore::InlineBox* inlineBox)
{
- if (b)
- b->showLineTreeForThis();
+ if (!inlineBox)
+ return;
+ inlineBox->showLineTreeForThis();
}
#endif