| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 , m_verticalAdvanceY(fontFaceElement->verticalAdvanceY()) | 55 , m_verticalAdvanceY(fontFaceElement->verticalAdvanceY()) |
| 56 { | 56 { |
| 57 ASSERT_ARG(fontFaceElement, fontFaceElement); | 57 ASSERT_ARG(fontFaceElement, fontFaceElement); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void SVGFontData::initializeFontData(SimpleFontData* fontData, float fontSize) | 60 void SVGFontData::initializeFontData(SimpleFontData* fontData, float fontSize) |
| 61 { | 61 { |
| 62 ASSERT(fontData); | 62 ASSERT(fontData); |
| 63 | 63 |
| 64 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); | 64 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| 65 ASSERT(svgFontFaceElement); | 65 ASSERT(svgFontFaceElement && svgFontFaceElement->inDocument()); |
| 66 | 66 |
| 67 SVGFontElement* svgFontElement = svgFontFaceElement->associatedFontElement()
; | 67 SVGFontElement* svgFontElement = svgFontFaceElement->associatedFontElement()
; |
| 68 ASSERT(svgFontElement); | 68 ASSERT(svgFontElement); |
| 69 GlyphData missingGlyphData; | 69 GlyphData missingGlyphData; |
| 70 missingGlyphData.fontData = fontData; | 70 missingGlyphData.fontData = fontData; |
| 71 missingGlyphData.glyph = svgFontElement->missingGlyph(); | 71 missingGlyphData.glyph = svgFontElement->missingGlyph(); |
| 72 fontData->setMissingGlyphData(missingGlyphData); | 72 fontData->setMissingGlyphData(missingGlyphData); |
| 73 | 73 |
| 74 fontData->setZeroWidthSpaceGlyph(0); | 74 fontData->setZeroWidthSpaceGlyph(0); |
| 75 fontData->determinePitch(); | 75 fontData->determinePitch(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Estimate maximum character width. | 117 // Estimate maximum character width. |
| 118 Glyph letterWGlyph = glyphPageZero->glyphForCharacter('W'); | 118 Glyph letterWGlyph = glyphPageZero->glyphForCharacter('W'); |
| 119 fontData->setMaxCharWidth(letterWGlyph ? fontData->widthForGlyph(letterWGlyp
h) : ascent); | 119 fontData->setMaxCharWidth(letterWGlyph ? fontData->widthForGlyph(letterWGlyp
h) : ascent); |
| 120 } | 120 } |
| 121 | 121 |
| 122 float SVGFontData::widthForSVGGlyph(Glyph glyph, float fontSize) const | 122 float SVGFontData::widthForSVGGlyph(Glyph glyph, float fontSize) const |
| 123 { | 123 { |
| 124 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); | 124 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| 125 ASSERT(svgFontFaceElement); | 125 ASSERT(svgFontFaceElement); |
| 126 // RenderView::clearSelection is invoked while removing some element, e.g. |
| 127 // Document::nodeWillBeRemoved => FrameSelection::nodeWillBeRemoved => Rende
rView::clearSelection. |
| 128 // Since recalc style has not been executed yet, RenderStyle might have some
reference to |
| 129 // SVGFontFaceElement which was also removed. |
| 130 // In this case, use default horizontalAdvanceX instead of associatedFontEle
ment's one. |
| 131 if (!svgFontFaceElement->inDocument()) |
| 132 return m_horizontalAdvanceX * scaleEmToUnits(fontSize, svgFontFaceElemen
t->unitsPerEm()); |
| 126 | 133 |
| 127 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontEl
ement(); | 134 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontEl
ement(); |
| 128 ASSERT(associatedFontElement); | 135 ASSERT(associatedFontElement); |
| 129 | 136 |
| 130 SVGGlyph svgGlyph = associatedFontElement->svgGlyphForGlyph(glyph); | 137 SVGGlyph svgGlyph = associatedFontElement->svgGlyphForGlyph(glyph); |
| 131 SVGGlyphElement::inheritUnspecifiedAttributes(svgGlyph, this); | 138 SVGGlyphElement::inheritUnspecifiedAttributes(svgGlyph, this); |
| 132 return svgGlyph.horizontalAdvanceX * scaleEmToUnits(fontSize, svgFontFaceEle
ment->unitsPerEm()); | 139 return svgGlyph.horizontalAdvanceX * scaleEmToUnits(fontSize, svgFontFaceEle
ment->unitsPerEm()); |
| 133 } | 140 } |
| 134 | 141 |
| 135 bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& gly
phData, bool mirror, int currentCharacter, unsigned& advanceLength) const | 142 bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& gly
phData, bool mirror, int currentCharacter, unsigned& advanceLength) const |
| (...skipping 12 matching lines...) Expand all Loading... |
| 148 remainingTextInRun = String(run.data16(currentCharacter), run.characters
Length() - currentCharacter); | 155 remainingTextInRun = String(run.data16(currentCharacter), run.characters
Length() - currentCharacter); |
| 149 remainingTextInRun = Character::normalizeSpaces(remainingTextInRun.chara
cters16(), remainingTextInRun.length()); | 156 remainingTextInRun = Character::normalizeSpaces(remainingTextInRun.chara
cters16(), remainingTextInRun.length()); |
| 150 } | 157 } |
| 151 | 158 |
| 152 if (mirror) | 159 if (mirror) |
| 153 remainingTextInRun = createStringWithMirroredCharacters(remainingTextInR
un); | 160 remainingTextInRun = createStringWithMirroredCharacters(remainingTextInR
un); |
| 154 if (!currentCharacter && arabicForms.isEmpty()) | 161 if (!currentCharacter && arabicForms.isEmpty()) |
| 155 arabicForms = charactersWithArabicForm(remainingTextInRun, mirror); | 162 arabicForms = charactersWithArabicForm(remainingTextInRun, mirror); |
| 156 | 163 |
| 157 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); | 164 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); |
| 158 ASSERT(svgFontFaceElement); | 165 ASSERT(svgFontFaceElement && svgFontFaceElement->inDocument()); |
| 159 | 166 |
| 160 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontEl
ement(); | 167 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontEl
ement(); |
| 161 ASSERT(associatedFontElement); | 168 ASSERT(associatedFontElement); |
| 162 | 169 |
| 163 RenderObject* renderObject = 0; | 170 RenderObject* renderObject = 0; |
| 164 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) | 171 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) |
| 165 renderObject = static_cast<SVGTextRunRenderingContext*>(renderingContext
)->renderer(); | 172 renderObject = static_cast<SVGTextRunRenderingContext*>(renderingContext
)->renderer(); |
| 166 | 173 |
| 167 String language; | 174 String language; |
| 168 bool isVerticalText = false; | 175 bool isVerticalText = false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 226 |
| 220 return false; | 227 return false; |
| 221 } | 228 } |
| 222 | 229 |
| 223 bool SVGFontData::fillSVGGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData
) const | 230 bool SVGFontData::fillSVGGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData
) const |
| 224 { | 231 { |
| 225 ASSERT(fontData->isCustomFont()); | 232 ASSERT(fontData->isCustomFont()); |
| 226 ASSERT(fontData->isSVGFont()); | 233 ASSERT(fontData->isSVGFont()); |
| 227 | 234 |
| 228 SVGFontFaceElement* fontFaceElement = this->svgFontFaceElement(); | 235 SVGFontFaceElement* fontFaceElement = this->svgFontFaceElement(); |
| 229 ASSERT(fontFaceElement); | 236 ASSERT(fontFaceElement && fontFaceElement->inDocument()); |
| 230 | 237 |
| 231 SVGFontElement* fontElement = fontFaceElement->associatedFontElement(); | 238 SVGFontElement* fontElement = fontFaceElement->associatedFontElement(); |
| 232 ASSERT(fontElement); | 239 ASSERT(fontElement); |
| 233 | 240 |
| 234 if (bufferLength == length) | 241 if (bufferLength == length) |
| 235 return fillBMPGlyphs(fontElement, pageToFill, offset, length, buffer, fo
ntData); | 242 return fillBMPGlyphs(fontElement, pageToFill, offset, length, buffer, fo
ntData); |
| 236 | 243 |
| 237 ASSERT(bufferLength == 2 * length); | 244 ASSERT(bufferLength == 2 * length); |
| 238 return fillNonBMPGlyphs(fontElement, pageToFill, offset, length, buffer, fon
tData); | 245 return fillNonBMPGlyphs(fontElement, pageToFill, offset, length, buffer, fon
tData); |
| 239 } | 246 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 mirroredCharacters.append(mirroredChar(character)); | 317 mirroredCharacters.append(mirroredChar(character)); |
| 311 } | 318 } |
| 312 } | 319 } |
| 313 | 320 |
| 314 return mirroredCharacters.toString(); | 321 return mirroredCharacters.toString(); |
| 315 } | 322 } |
| 316 | 323 |
| 317 } // namespace WebCore | 324 } // namespace WebCore |
| 318 | 325 |
| 319 #endif | 326 #endif |
| OLD | NEW |