summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/svg/SVGRootInlineBox.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/svg/SVGRootInlineBox.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGRootInlineBox.cpp')
-rw-r--r--Source/WebCore/rendering/svg/SVGRootInlineBox.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp b/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp
index ec628b168..c6d23f57c 100644
--- a/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp
+++ b/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
- * Copyright (C) 2006 Apple Computer Inc.
+ * Copyright (C) 2006 Apple Inc.
* Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
* Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved.
@@ -24,9 +24,9 @@
#include "config.h"
#include "SVGRootInlineBox.h"
-#if ENABLE(SVG)
#include "GraphicsContext.h"
#include "RenderSVGText.h"
+#include "RenderSVGTextPath.h"
#include "SVGInlineFlowBox.h"
#include "SVGInlineTextBox.h"
#include "SVGNames.h"
@@ -43,48 +43,44 @@ SVGRootInlineBox::SVGRootInlineBox(RenderSVGText& renderSVGText)
RenderSVGText& SVGRootInlineBox::renderSVGText()
{
- return toRenderSVGText(blockFlow());
+ return downcast<RenderSVGText>(blockFlow());
}
-void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit)
+void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
- ASSERT(!paintInfo.context->paintingDisabled());
+ ASSERT(!paintInfo.context().paintingDisabled());
bool isPrinting = renderSVGText().document().printing();
bool hasSelection = !isPrinting && selectionState() != RenderObject::SelectionNone;
+ bool shouldPaintSelectionHighlight = !(paintInfo.paintBehavior & PaintBehaviorSkipSelectionHighlight);
PaintInfo childPaintInfo(paintInfo);
- if (hasSelection) {
+ if (hasSelection && shouldPaintSelectionHighlight) {
for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
- if (child->isSVGInlineTextBox())
- toSVGInlineTextBox(child)->paintSelectionBackground(childPaintInfo);
- else if (child->isSVGInlineFlowBox())
- toSVGInlineFlowBox(child)->paintSelectionBackground(childPaintInfo);
+ if (is<SVGInlineTextBox>(*child))
+ downcast<SVGInlineTextBox>(*child).paintSelectionBackground(childPaintInfo);
+ else if (is<SVGInlineFlowBox>(*child))
+ downcast<SVGInlineFlowBox>(*child).paintSelectionBackground(childPaintInfo);
}
}
SVGRenderingContext renderingContext(renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
if (renderingContext.isRenderingPrepared()) {
- for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
- if (child->isSVGInlineTextBox())
- SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(&toSVGInlineTextBox(child)->renderer());
-
- child->paint(paintInfo, LayoutPoint(), 0, 0);
- }
+ for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
+ child->paint(paintInfo, paintOffset, 0, 0);
}
}
void SVGRootInlineBox::computePerCharacterLayoutInformation()
{
- RenderSVGText* textRoot = toRenderSVGText(&blockFlow());
- ASSERT(textRoot);
+ auto& textRoot = downcast<RenderSVGText>(blockFlow());
- Vector<SVGTextLayoutAttributes*>& layoutAttributes = textRoot->layoutAttributes();
+ Vector<SVGTextLayoutAttributes*>& layoutAttributes = textRoot.layoutAttributes();
if (layoutAttributes.isEmpty())
return;
- if (textRoot->needsReordering())
+ if (textRoot.needsReordering())
reorderValueLists(layoutAttributes);
// Perform SVG text layout phase two (see SVGTextLayoutEngine for details).
@@ -104,31 +100,27 @@ void SVGRootInlineBox::computePerCharacterLayoutInformation()
void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGTextLayoutEngine& characterLayout)
{
for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
- if (child->isSVGInlineTextBox()) {
- ASSERT(child->renderer().isSVGInlineText());
-
- SVGInlineTextBox* textBox = toSVGInlineTextBox(child);
- characterLayout.layoutInlineTextBox(textBox);
+ if (is<SVGInlineTextBox>(*child)) {
+ ASSERT(is<RenderSVGInlineText>(child->renderer()));
+ characterLayout.layoutInlineTextBox(downcast<SVGInlineTextBox>(*child));
} else {
// Skip generated content.
Node* node = child->renderer().node();
if (!node)
continue;
- ASSERT_WITH_SECURITY_IMPLICATION(child->isInlineFlowBox());
-
- SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child);
+ auto& flowBox = downcast<SVGInlineFlowBox>(*child);
bool isTextPath = node->hasTagName(SVGNames::textPathTag);
if (isTextPath) {
// Build text chunks for all <textPath> children, using the line layout algorithm.
// This is needeed as text-anchor is just an additional startOffset for text paths.
SVGTextLayoutEngine lineLayout(characterLayout.layoutAttributes());
- layoutCharactersInTextBoxes(flowBox, lineLayout);
+ layoutCharactersInTextBoxes(&flowBox, lineLayout);
- characterLayout.beginTextPathLayout(&child->renderer(), lineLayout);
+ characterLayout.beginTextPathLayout(downcast<RenderSVGTextPath>(child->renderer()), lineLayout);
}
- layoutCharactersInTextBoxes(flowBox, characterLayout);
+ layoutCharactersInTextBoxes(&flowBox, characterLayout);
if (isTextPath)
characterLayout.endTextPathLayout();
@@ -140,30 +132,28 @@ void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, FloatRect* childRe
{
for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
FloatRect boxRect;
- if (child->isSVGInlineTextBox()) {
- ASSERT(child->renderer().isSVGInlineText());
-
- SVGInlineTextBox* textBox = toSVGInlineTextBox(child);
- boxRect = textBox->calculateBoundaries();
- textBox->setX(boxRect.x());
- textBox->setY(boxRect.y());
- textBox->setLogicalWidth(boxRect.width());
- textBox->setLogicalHeight(boxRect.height());
+ if (is<SVGInlineTextBox>(*child)) {
+ ASSERT(is<RenderSVGInlineText>(child->renderer()));
+
+ auto& textBox = downcast<SVGInlineTextBox>(*child);
+ boxRect = textBox.calculateBoundaries();
+ textBox.setX(boxRect.x());
+ textBox.setY(boxRect.y());
+ textBox.setLogicalWidth(boxRect.width());
+ textBox.setLogicalHeight(boxRect.height());
} else {
// Skip generated content.
if (!child->renderer().node())
continue;
- ASSERT_WITH_SECURITY_IMPLICATION(child->isInlineFlowBox());
-
- SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child);
- layoutChildBoxes(flowBox);
+ auto& flowBox = downcast<SVGInlineFlowBox>(*child);
+ layoutChildBoxes(&flowBox);
- boxRect = flowBox->calculateBoundaries();
- flowBox->setX(boxRect.x());
- flowBox->setY(boxRect.y());
- flowBox->setLogicalWidth(boxRect.width());
- flowBox->setLogicalHeight(boxRect.height());
+ boxRect = flowBox.calculateBoundaries();
+ flowBox.setX(boxRect.x());
+ flowBox.setY(boxRect.y());
+ flowBox.setLogicalWidth(boxRect.width());
+ flowBox.setLogicalHeight(boxRect.height());
}
if (childRect)
childRect->unite(boxRect);
@@ -203,7 +193,7 @@ InlineBox* SVGRootInlineBox::closestLeafChildForPosition(const LayoutPoint& poin
return firstLeaf;
// FIXME: Check for vertical text!
- InlineBox* closestLeaf = 0;
+ InlineBox* closestLeaf = nullptr;
for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChild()) {
if (!leaf->isSVGInlineTextBox())
continue;
@@ -220,6 +210,18 @@ InlineBox* SVGRootInlineBox::closestLeafChildForPosition(const LayoutPoint& poin
return closestLeaf ? closestLeaf : lastLeaf;
}
+bool SVGRootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction hitTestAction)
+{
+ for (InlineBox* leaf = firstLeafChild(); leaf; leaf = leaf->nextLeafChild()) {
+ if (!leaf->isSVGInlineTextBox())
+ continue;
+ if (leaf->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom, hitTestAction))
+ return true;
+ }
+
+ return false;
+}
+
static inline void swapItemsInLayoutAttributes(SVGTextLayoutAttributes* firstAttributes, SVGTextLayoutAttributes* lastAttributes, unsigned firstPosition, unsigned lastPosition)
{
SVGCharacterDataMap::iterator itFirst = firstAttributes->characterDataMap().find(firstPosition + 1);
@@ -246,8 +248,8 @@ static inline void swapItemsInLayoutAttributes(SVGTextLayoutAttributes* firstAtt
static inline void findFirstAndLastAttributesInVector(Vector<SVGTextLayoutAttributes*>& attributes, RenderSVGInlineText* firstContext, RenderSVGInlineText* lastContext,
SVGTextLayoutAttributes*& first, SVGTextLayoutAttributes*& last)
{
- first = 0;
- last = 0;
+ first = nullptr;
+ last = nullptr;
unsigned attributesSize = attributes.size();
for (unsigned i = 0; i < attributesSize; ++i) {
@@ -274,7 +276,7 @@ static inline void reverseInlineBoxRangeAndValueListsIfNeeded(void* userData, Ve
if (first == last || first == --last)
return;
- if (!(*last)->isSVGInlineTextBox() || !(*first)->isSVGInlineTextBox()) {
+ if (!is<SVGInlineTextBox>(**last) || !is<SVGInlineTextBox>(**first)) {
InlineBox* temp = *first;
*first = *last;
*last = temp;
@@ -282,18 +284,18 @@ static inline void reverseInlineBoxRangeAndValueListsIfNeeded(void* userData, Ve
continue;
}
- SVGInlineTextBox* firstTextBox = toSVGInlineTextBox(*first);
- SVGInlineTextBox* lastTextBox = toSVGInlineTextBox(*last);
+ auto& firstTextBox = downcast<SVGInlineTextBox>(**first);
+ auto& lastTextBox = downcast<SVGInlineTextBox>(**last);
// Reordering is only necessary for BiDi text that is _absolutely_ positioned.
- if (firstTextBox->len() == 1 && firstTextBox->len() == lastTextBox->len()) {
- RenderSVGInlineText& firstContext = firstTextBox->renderer();
- RenderSVGInlineText& lastContext = lastTextBox->renderer();
+ if (firstTextBox.len() == 1 && firstTextBox.len() == lastTextBox.len()) {
+ RenderSVGInlineText& firstContext = firstTextBox.renderer();
+ RenderSVGInlineText& lastContext = lastTextBox.renderer();
- SVGTextLayoutAttributes* firstAttributes = 0;
- SVGTextLayoutAttributes* lastAttributes = 0;
+ SVGTextLayoutAttributes* firstAttributes = nullptr;
+ SVGTextLayoutAttributes* lastAttributes = nullptr;
findFirstAndLastAttributesInVector(attributes, &firstContext, &lastContext, firstAttributes, lastAttributes);
- swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTextBox->start(), lastTextBox->start());
+ swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTextBox.start(), lastTextBox.start());
}
InlineBox* temp = *first;
@@ -311,5 +313,3 @@ void SVGRootInlineBox::reorderValueLists(Vector<SVGTextLayoutAttributes*>& attri
}
} // namespace WebCore
-
-#endif // ENABLE(SVG)