| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
| 3 * Copyright (C) 2006 Apple Computer Inc. | 3 * Copyright (C) 2006 Apple Computer Inc. |
| 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 6 * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved. | 6 * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, res
ize the root box as well as the LayoutSVGText parent block. | 66 // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, res
ize the root box as well as the LayoutSVGText parent block. |
| 67 FloatRectWillBeLayoutRect childRect; | 67 FloatRectWillBeLayoutRect childRect; |
| 68 layoutChildBoxes(this, &childRect); | 68 layoutChildBoxes(this, &childRect); |
| 69 layoutRootBox(childRect); | 69 layoutRootBox(childRect); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGText
LayoutEngine& characterLayout) | 72 void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGText
LayoutEngine& characterLayout) |
| 73 { | 73 { |
| 74 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { | 74 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { |
| 75 if (child->isSVGInlineTextBox()) { | 75 if (child->isSVGInlineTextBox()) { |
| 76 ASSERT(child->renderer().isSVGInlineText()); | 76 ASSERT(child->layoutObject().isSVGInlineText()); |
| 77 characterLayout.layoutInlineTextBox(toSVGInlineTextBox(child)); | 77 characterLayout.layoutInlineTextBox(toSVGInlineTextBox(child)); |
| 78 } else { | 78 } else { |
| 79 // Skip generated content. | 79 // Skip generated content. |
| 80 Node* node = child->renderer().node(); | 80 Node* node = child->layoutObject().node(); |
| 81 if (!node) | 81 if (!node) |
| 82 continue; | 82 continue; |
| 83 | 83 |
| 84 SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child); | 84 SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child); |
| 85 bool isTextPath = isSVGTextPathElement(*node); | 85 bool isTextPath = isSVGTextPathElement(*node); |
| 86 if (isTextPath) { | 86 if (isTextPath) { |
| 87 // Build text chunks for all <textPath> children, using the line
layout algorithm. | 87 // Build text chunks for all <textPath> children, using the line
layout algorithm. |
| 88 // This is needeed as text-anchor is just an additional startOff
set for text paths. | 88 // This is needeed as text-anchor is just an additional startOff
set for text paths. |
| 89 SVGTextLayoutEngine lineLayout(characterLayout.layoutAttributes(
)); | 89 SVGTextLayoutEngine lineLayout(characterLayout.layoutAttributes(
)); |
| 90 layoutCharactersInTextBoxes(flowBox, lineLayout); | 90 layoutCharactersInTextBoxes(flowBox, lineLayout); |
| 91 | 91 |
| 92 characterLayout.beginTextPathLayout(&child->renderer(), lineLayo
ut); | 92 characterLayout.beginTextPathLayout(&child->layoutObject(), line
Layout); |
| 93 } | 93 } |
| 94 | 94 |
| 95 layoutCharactersInTextBoxes(flowBox, characterLayout); | 95 layoutCharactersInTextBoxes(flowBox, characterLayout); |
| 96 | 96 |
| 97 if (isTextPath) | 97 if (isTextPath) |
| 98 characterLayout.endTextPathLayout(); | 98 characterLayout.endTextPathLayout(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, FloatRectWillBeLay
outRect* childRect) | 103 void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, FloatRectWillBeLay
outRect* childRect) |
| 104 { | 104 { |
| 105 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { | 105 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { |
| 106 FloatRectWillBeLayoutRect boxRect; | 106 FloatRectWillBeLayoutRect boxRect; |
| 107 if (child->isSVGInlineTextBox()) { | 107 if (child->isSVGInlineTextBox()) { |
| 108 ASSERT(child->renderer().isSVGInlineText()); | 108 ASSERT(child->layoutObject().isSVGInlineText()); |
| 109 | 109 |
| 110 SVGInlineTextBox* textBox = toSVGInlineTextBox(child); | 110 SVGInlineTextBox* textBox = toSVGInlineTextBox(child); |
| 111 boxRect = textBox->calculateBoundaries(); | 111 boxRect = textBox->calculateBoundaries(); |
| 112 textBox->setX(boxRect.x()); | 112 textBox->setX(boxRect.x()); |
| 113 textBox->setY(boxRect.y()); | 113 textBox->setY(boxRect.y()); |
| 114 textBox->setLogicalWidth(boxRect.width()); | 114 textBox->setLogicalWidth(boxRect.width()); |
| 115 textBox->setLogicalHeight(boxRect.height()); | 115 textBox->setLogicalHeight(boxRect.height()); |
| 116 } else { | 116 } else { |
| 117 // Skip generated content. | 117 // Skip generated content. |
| 118 if (!child->renderer().node()) | 118 if (!child->layoutObject().node()) |
| 119 continue; | 119 continue; |
| 120 | 120 |
| 121 SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child); | 121 SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child); |
| 122 layoutChildBoxes(flowBox); | 122 layoutChildBoxes(flowBox); |
| 123 | 123 |
| 124 boxRect = flowBox->calculateBoundaries(); | 124 boxRect = flowBox->calculateBoundaries(); |
| 125 flowBox->setX(boxRect.x()); | 125 flowBox->setX(boxRect.x()); |
| 126 flowBox->setY(boxRect.y()); | 126 flowBox->setY(boxRect.y()); |
| 127 flowBox->setLogicalWidth(boxRect.width()); | 127 flowBox->setLogicalWidth(boxRect.width()); |
| 128 flowBox->setLogicalHeight(boxRect.height()); | 128 flowBox->setLogicalHeight(boxRect.height()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 139 // Finally, assign the root block position, now that all content is laid out
. | 139 // Finally, assign the root block position, now that all content is laid out
. |
| 140 // FIXME: the call to enclosingLayoutRect() below is temporary and should be
removed once | 140 // FIXME: the call to enclosingLayoutRect() below is temporary and should be
removed once |
| 141 // the transition to LayoutUnit-based types is complete (crbug.com/321237) | 141 // the transition to LayoutUnit-based types is complete (crbug.com/321237) |
| 142 LayoutRect boundingRect = childRect.enclosingLayoutRect(); | 142 LayoutRect boundingRect = childRect.enclosingLayoutRect(); |
| 143 parentBlock.setLocation(boundingRect.location()); | 143 parentBlock.setLocation(boundingRect.location()); |
| 144 parentBlock.setSize(boundingRect.size()); | 144 parentBlock.setSize(boundingRect.size()); |
| 145 | 145 |
| 146 // Position all children relative to the parent block. | 146 // Position all children relative to the parent block. |
| 147 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) { | 147 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) { |
| 148 // Skip generated content. | 148 // Skip generated content. |
| 149 if (!child->renderer().node()) | 149 if (!child->layoutObject().node()) |
| 150 continue; | 150 continue; |
| 151 child->adjustPosition(-childRect.x(), -childRect.y()); | 151 child->adjustPosition(-childRect.x(), -childRect.y()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Position ourselves. | 154 // Position ourselves. |
| 155 setX(0); | 155 setX(0); |
| 156 setY(0); | 156 setY(0); |
| 157 setLogicalWidth(childRect.width()); | 157 setLogicalWidth(childRect.width()); |
| 158 setLogicalHeight(childRect.height()); | 158 setLogicalHeight(childRect.height()); |
| 159 setLineTopBottomPositions(0, boundingRect.height(), 0, boundingRect.height()
); | 159 setLineTopBottomPositions(0, boundingRect.height(), 0, boundingRect.height()
); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 *last = temp; | 233 *last = temp; |
| 234 ++first; | 234 ++first; |
| 235 continue; | 235 continue; |
| 236 } | 236 } |
| 237 | 237 |
| 238 SVGInlineTextBox* firstTextBox = toSVGInlineTextBox(*first); | 238 SVGInlineTextBox* firstTextBox = toSVGInlineTextBox(*first); |
| 239 SVGInlineTextBox* lastTextBox = toSVGInlineTextBox(*last); | 239 SVGInlineTextBox* lastTextBox = toSVGInlineTextBox(*last); |
| 240 | 240 |
| 241 // Reordering is only necessary for BiDi text that is _absolutely_ posit
ioned. | 241 // Reordering is only necessary for BiDi text that is _absolutely_ posit
ioned. |
| 242 if (firstTextBox->len() == 1 && firstTextBox->len() == lastTextBox->len(
)) { | 242 if (firstTextBox->len() == 1 && firstTextBox->len() == lastTextBox->len(
)) { |
| 243 LayoutSVGInlineText& firstContext = toLayoutSVGInlineText(firstTextB
ox->renderer()); | 243 LayoutSVGInlineText& firstContext = toLayoutSVGInlineText(firstTextB
ox->layoutObject()); |
| 244 LayoutSVGInlineText& lastContext = toLayoutSVGInlineText(lastTextBox
->renderer()); | 244 LayoutSVGInlineText& lastContext = toLayoutSVGInlineText(lastTextBox
->layoutObject()); |
| 245 | 245 |
| 246 SVGTextLayoutAttributes* firstAttributes = 0; | 246 SVGTextLayoutAttributes* firstAttributes = 0; |
| 247 SVGTextLayoutAttributes* lastAttributes = 0; | 247 SVGTextLayoutAttributes* lastAttributes = 0; |
| 248 findFirstAndLastAttributesInVector(attributes, &firstContext, &lastC
ontext, firstAttributes, lastAttributes); | 248 findFirstAndLastAttributesInVector(attributes, &firstContext, &lastC
ontext, firstAttributes, lastAttributes); |
| 249 swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTe
xtBox->start(), lastTextBox->start()); | 249 swapItemsInLayoutAttributes(firstAttributes, lastAttributes, firstTe
xtBox->start(), lastTextBox->start()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 InlineBox* temp = *first; | 252 InlineBox* temp = *first; |
| 253 *first = *last; | 253 *first = *last; |
| 254 *last = temp; | 254 *last = temp; |
| 255 | 255 |
| 256 ++first; | 256 ++first; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 void SVGRootInlineBox::reorderValueLists(Vector<SVGTextLayoutAttributes*>& attri
butes) | 260 void SVGRootInlineBox::reorderValueLists(Vector<SVGTextLayoutAttributes*>& attri
butes) |
| 261 { | 261 { |
| 262 Vector<InlineBox*> leafBoxesInLogicalOrder; | 262 Vector<InlineBox*> leafBoxesInLogicalOrder; |
| 263 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder, reverseInlineBoxRang
eAndValueListsIfNeeded, &attributes); | 263 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder, reverseInlineBoxRang
eAndValueListsIfNeeded, &attributes); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace blink | 266 } // namespace blink |
| OLD | NEW |