OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. 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 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void SVGTextQuery::collectTextBoxesInFlowBox(InlineFlowBox* flowBox) | 85 void SVGTextQuery::collectTextBoxesInFlowBox(InlineFlowBox* flowBox) |
86 { | 86 { |
87 if (!flowBox) | 87 if (!flowBox) |
88 return; | 88 return; |
89 | 89 |
90 for (InlineBox* child = flowBox->firstChild(); child; child = child->nextOnL
ine()) { | 90 for (InlineBox* child = flowBox->firstChild(); child; child = child->nextOnL
ine()) { |
91 if (child->isInlineFlowBox()) { | 91 if (child->isInlineFlowBox()) { |
92 // Skip generated content. | 92 // Skip generated content. |
93 if (!child->renderer()->node()) | 93 if (!child->renderer().node()) |
94 continue; | 94 continue; |
95 | 95 |
96 collectTextBoxesInFlowBox(toInlineFlowBox(child)); | 96 collectTextBoxesInFlowBox(toInlineFlowBox(child)); |
97 continue; | 97 continue; |
98 } | 98 } |
99 | 99 |
100 if (child->isSVGInlineTextBox()) | 100 if (child->isSVGInlineTextBox()) |
101 m_textBoxes.append(toSVGInlineTextBox(child)); | 101 m_textBoxes.append(toSVGInlineTextBox(child)); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 bool SVGTextQuery::executeQuery(Data* queryData, ProcessTextFragmentCallback fra
gmentCallback) const | 105 bool SVGTextQuery::executeQuery(Data* queryData, ProcessTextFragmentCallback fra
gmentCallback) const |
106 { | 106 { |
107 ASSERT(!m_textBoxes.isEmpty()); | 107 ASSERT(!m_textBoxes.isEmpty()); |
108 | 108 |
109 unsigned processedCharacters = 0; | 109 unsigned processedCharacters = 0; |
110 unsigned textBoxCount = m_textBoxes.size(); | 110 unsigned textBoxCount = m_textBoxes.size(); |
111 | 111 |
112 // Loop over all text boxes | 112 // Loop over all text boxes |
113 for (unsigned textBoxPosition = 0; textBoxPosition < textBoxCount; ++textBox
Position) { | 113 for (unsigned textBoxPosition = 0; textBoxPosition < textBoxCount; ++textBox
Position) { |
114 queryData->textBox = m_textBoxes.at(textBoxPosition); | 114 queryData->textBox = m_textBoxes.at(textBoxPosition); |
115 queryData->textRenderer = toRenderSVGInlineText(queryData->textBox->text
Renderer()); | 115 queryData->textRenderer = &toRenderSVGInlineText(queryData->textBox->tex
tRenderer()); |
116 ASSERT(queryData->textRenderer); | |
117 ASSERT(queryData->textRenderer->style()); | 116 ASSERT(queryData->textRenderer->style()); |
118 ASSERT(queryData->textRenderer->style()->svgStyle()); | 117 ASSERT(queryData->textRenderer->style()->svgStyle()); |
119 | 118 |
120 queryData->isVerticalText = queryData->textRenderer->style()->svgStyle()
->isVerticalWritingMode(); | 119 queryData->isVerticalText = queryData->textRenderer->style()->svgStyle()
->isVerticalWritingMode(); |
121 const Vector<SVGTextFragment>& fragments = queryData->textBox->textFragm
ents(); | 120 const Vector<SVGTextFragment>& fragments = queryData->textBox->textFragm
ents(); |
122 | 121 |
123 // Loop over all text fragments in this text box, firing a callback for
each. | 122 // Loop over all text fragments in this text box, firing a callback for
each. |
124 unsigned fragmentCount = fragments.size(); | 123 unsigned fragmentCount = fragments.size(); |
125 for (unsigned i = 0; i < fragmentCount; ++i) { | 124 for (unsigned i = 0; i < fragmentCount; ++i) { |
126 const SVGTextFragment& fragment = fragments.at(i); | 125 const SVGTextFragment& fragment = fragments.at(i); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return -1; | 539 return -1; |
541 | 540 |
542 CharacterNumberAtPositionData data(position); | 541 CharacterNumberAtPositionData data(position); |
543 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) | 542 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) |
544 return -1; | 543 return -1; |
545 | 544 |
546 return data.processedCharacters; | 545 return data.processedCharacters; |
547 } | 546 } |
548 | 547 |
549 } | 548 } |
OLD | NEW |