| 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->layoutObject().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 unsigned processedCharacters = 0; | 107 unsigned processedCharacters = 0; |
| 108 unsigned textBoxCount = m_textBoxes.size(); | 108 unsigned textBoxCount = m_textBoxes.size(); |
| 109 | 109 |
| 110 // Loop over all text boxes | 110 // Loop over all text boxes |
| 111 for (unsigned textBoxPosition = 0; textBoxPosition < textBoxCount; ++textBox
Position) { | 111 for (unsigned textBoxPosition = 0; textBoxPosition < textBoxCount; ++textBox
Position) { |
| 112 queryData->textBox = m_textBoxes.at(textBoxPosition); | 112 queryData->textBox = m_textBoxes.at(textBoxPosition); |
| 113 queryData->textRenderer = &toLayoutSVGInlineText(queryData->textBox->ren
derer()); | 113 queryData->textRenderer = &toLayoutSVGInlineText(queryData->textBox->lay
outObject()); |
| 114 ASSERT(queryData->textRenderer->style()); | 114 ASSERT(queryData->textRenderer->style()); |
| 115 | 115 |
| 116 queryData->isVerticalText = queryData->textRenderer->style()->svgStyle()
.isVerticalWritingMode(); | 116 queryData->isVerticalText = queryData->textRenderer->style()->svgStyle()
.isVerticalWritingMode(); |
| 117 const Vector<SVGTextFragment>& fragments = queryData->textBox->textFragm
ents(); | 117 const Vector<SVGTextFragment>& fragments = queryData->textBox->textFragm
ents(); |
| 118 | 118 |
| 119 // Loop over all text fragments in this text box, firing a callback for
each. | 119 // Loop over all text fragments in this text box, firing a callback for
each. |
| 120 unsigned fragmentCount = fragments.size(); | 120 unsigned fragmentCount = fragments.size(); |
| 121 for (unsigned i = 0; i < fragmentCount; ++i) { | 121 for (unsigned i = 0; i < fragmentCount; ++i) { |
| 122 const SVGTextFragment& fragment = fragments.at(i); | 122 const SVGTextFragment& fragment = fragments.at(i); |
| 123 if ((this->*fragmentCallback)(queryData, fragment)) | 123 if ((this->*fragmentCallback)(queryData, fragment)) |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const | 508 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const |
| 509 { | 509 { |
| 510 CharacterNumberAtPositionData data(position); | 510 CharacterNumberAtPositionData data(position); |
| 511 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) | 511 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) |
| 512 return -1; | 512 return -1; |
| 513 | 513 |
| 514 return data.processedCharacters; | 514 return data.processedCharacters; |
| 515 } | 515 } |
| 516 | 516 |
| 517 } | 517 } |
| OLD | NEW |