Changeset 87152 in webkit
- Timestamp:
- May 24, 2011 8:27:36 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 38 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r87150 r87152 1618 1618 rendering/svg/SVGTextLayoutEngineBaseline.cpp 1619 1619 rendering/svg/SVGTextLayoutEngineSpacing.cpp 1620 rendering/svg/SVGTextRunRenderingContext.cpp 1620 1621 rendering/svg/SVGTextMetrics.cpp 1621 1622 rendering/svg/SVGTextQuery.cpp … … 1672 1673 svg/SVGFilterPrimitiveStandardAttributes.cpp 1673 1674 svg/SVGFitToViewBox.cpp 1674 svg/SVGFont.cpp1675 1675 svg/SVGFontData.cpp 1676 1676 svg/SVGFontElement.cpp -
trunk/Source/WebCore/ChangeLog
r87151 r87152 1 2011-05-24 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Antti Koivisto. 4 5 Remove platform layering violation: TextRun stores RenderObjects for SVG Fonts support 6 https://bugs.webkit.org/show_bug.cgi?id=60254 7 8 First part: 9 Remove a long-standing layering violation in TextRun: it stores RenderObject/RenderSVGResource pointers for SVG Fonts support. 10 Replace the two Render* pointers with a single RefPtr<AbstractRenderingContext>. AbstractRenderingContext is a helper class, 11 that can be derived from in order to associate additional data with a TextRun. This effectively reduces the memory consumption of TextRun. 12 13 Introduce rendering/TextRunRenderingContext.h, which inherits from TextRun::AbstractRenderingContext and holds additional data. 14 If the primary font in use is a SVG Font then allocate a TextRunRenderingContext object and store it in the RefPtr<AbstractRenderingContext> 15 in TextRun. If the primary font is not a SVG Font, don't even allocate the TextRunRenderingContext structure, as we won't need the context data. 16 SVG Fonts glyph matching only works within a context, so we need access to the RenderObject that's drawing the text. 17 18 This is the main preparation patch for the SVG Fonts rewrite, that will allow us to share the simple text code path for SVG Fonts as well, 19 making all CSS text properties work for HTML text using SVG Fonts, and allows proper integration within the GlyphPage concept. Soon 20 we can intermix WOFF/SVG & native fonts, within segment font declarations. 21 22 Second part: 23 Remove a long-standing layering violation in SimpleFontData: it stores SVGFontData objects, that are living in svg/. 24 Use the same concept as above, introduce SimpleFontData::AbstractFontData, and let SVGFontData inherit from AbstractFontData and extent it. 25 If SVG Fonts are used, CSSFontFaceSource will create a SVGFontData object and pass it as PassOwnPtr<AbstractFontData> to SimpleFontData. 26 27 All layering violations are gone now, SVG Fonts are cleanly integrated now. 28 Doesn't affect any tests yet, refactoring only. 29 30 * CMakeLists.txt: 31 * GNUmakefile.list.am: 32 * WebCore.gypi: 33 * WebCore.pro: 34 * WebCore.vcproj/WebCore.vcproj: 35 * WebCore.xcodeproj/project.pbxproj: 36 * css/CSSFontFaceSource.cpp: 37 (WebCore::CSSFontFaceSource::getFontData): 38 * platform/graphics/Font.cpp: 39 (WebCore::Font::drawText): 40 (WebCore::Font::width): 41 (WebCore::Font::selectionRectForText): 42 (WebCore::Font::offsetForPosition): 43 * platform/graphics/Font.h: 44 * platform/graphics/SimpleFontData.cpp: 45 (WebCore::SimpleFontData::SimpleFontData): 46 (WebCore::SimpleFontData::~SimpleFontData): 47 * platform/graphics/SimpleFontData.h: 48 (WebCore::SimpleFontData::FontData::~FontData): 49 (WebCore::SimpleFontData::fontMetrics): 50 (WebCore::SimpleFontData::setMaxCharWidth): 51 (WebCore::SimpleFontData::setAvgCharWidth): 52 (WebCore::SimpleFontData::setSpaceWidth): 53 (WebCore::SimpleFontData::setSpaceGlyph): 54 (WebCore::SimpleFontData::setZeroWidthSpaceGlyph): 55 (WebCore::SimpleFontData::fontData): 56 (WebCore::SimpleFontData::isSVGFont): 57 (WebCore::SimpleFontData::setMissingGlyphData): 58 * platform/graphics/TextRun.h: 59 (WebCore::TextRun::TextRun): 60 (WebCore::TextRun::setAllowTabs): 61 (WebCore::TextRun::setXPos): 62 (WebCore::TextRun::RenderingContext::~RenderingContext): 63 (WebCore::TextRun::renderingContext): 64 (WebCore::TextRun::setRenderingContext): 65 * rendering/EllipsisBox.cpp: 66 (WebCore::EllipsisBox::paint): 67 (WebCore::EllipsisBox::selectionRect): 68 (WebCore::EllipsisBox::paintSelection): 69 * rendering/InlineTextBox.cpp: 70 (WebCore::InlineTextBox::selectionRect): 71 (WebCore::InlineTextBox::paint): 72 (WebCore::InlineTextBox::paintSelection): 73 (WebCore::InlineTextBox::paintCompositionBackground): 74 (WebCore::InlineTextBox::paintSpellingOrGrammarMarker): 75 (WebCore::InlineTextBox::paintTextMatchMarker): 76 (WebCore::InlineTextBox::computeRectForReplacementMarker): 77 (WebCore::InlineTextBox::offsetForPosition): 78 (WebCore::InlineTextBox::positionForOffset): 79 (WebCore::InlineTextBox::constructTextRun): 80 * rendering/InlineTextBox.h: 81 * rendering/RenderBlock.cpp: 82 (WebCore::stripTrailingSpace): 83 (WebCore::RenderBlock::constructTextRun): 84 * rendering/RenderBlock.h: 85 * rendering/RenderBlockLineLayout.cpp: 86 (WebCore::setLogicalWidthForTextRun): 87 (WebCore::textWidth): 88 (WebCore::tryHyphenating): 89 (WebCore::RenderBlock::LineBreaker::nextLineBreak): 90 (WebCore::RenderBlock::checkLinesForTextOverflow): 91 * rendering/RenderCombineText.cpp: 92 (WebCore::RenderCombineText::combineText): 93 * rendering/RenderFileUploadControl.cpp: 94 (WebCore::RenderFileUploadControl::paintObject): 95 (WebCore::RenderFileUploadControl::computePreferredLogicalWidths): 96 * rendering/RenderFlexibleBox.cpp: 97 (WebCore::RenderFlexibleBox::applyLineClamp): 98 * rendering/RenderImage.cpp: 99 (WebCore::RenderImage::setImageSizeForAltText): 100 (WebCore::RenderImage::paintReplaced): 101 * rendering/RenderListBox.cpp: 102 (WebCore::RenderListBox::updateFromElement): 103 * rendering/RenderListMarker.cpp: 104 (WebCore::RenderListMarker::paint): 105 (WebCore::RenderListMarker::computePreferredLogicalWidths): 106 (WebCore::RenderListMarker::getRelativeMarkerRect): 107 * rendering/RenderText.cpp: 108 (WebCore::RenderText::widthFromCache): 109 (WebCore::RenderText::trimmedPrefWidths): 110 (WebCore::RenderText::computePreferredLogicalWidths): 111 (WebCore::RenderText::width): 112 * rendering/RenderTextControl.cpp: 113 (WebCore::RenderTextControl::getAvgCharWidth): 114 * rendering/svg/RenderSVGAllInOne.cpp: 115 * rendering/svg/SVGInlineTextBox.cpp: 116 (WebCore::SVGInlineTextBox::offsetForPositionInFragment): 117 (WebCore::SVGInlineTextBox::prepareGraphicsContextForTextPainting): 118 (WebCore::SVGInlineTextBox::restoreGraphicsContextAfterTextPainting): 119 (WebCore::SVGInlineTextBox::constructTextRun): 120 (WebCore::SVGInlineTextBox::paintText): 121 * rendering/svg/SVGTextLayoutEngineSpacing.cpp: 122 (WebCore::SVGTextLayoutEngineSpacing::calculateSVGKerning): 123 * rendering/svg/SVGTextMetrics.cpp: 124 (WebCore::constructTextRun): 125 (WebCore::SVGTextMetrics::measureCharacterRange): 126 * rendering/svg/SVGTextRunRenderingContext.cpp: Copied from svg/SVGFont.cpp. 127 (WebCore::svgFontAndFontFaceElementForFontData): 128 (WebCore::firstParentRendererForNonTextNode): 129 (WebCore::referencingRenderObjectFromRun): 130 (WebCore::activePaintingResourceFromRun): 131 (WebCore::SVGTextRunWalker::walk): 132 (WebCore::floatWidthMissingGlyphCallback): 133 (WebCore::floatWidthOfSubStringUsingSVGFont): 134 (WebCore::SVGTextRunRenderingContext::floatWidthUsingSVGFont): 135 (WebCore::SVGTextRunRenderingContext::drawTextUsingSVGFont): 136 (WebCore::SVGTextRunRenderingContext::selectionRectForTextUsingSVGFont): 137 (WebCore::SVGTextRunRenderingContext::offsetForPositionForTextUsingSVGFont): 138 * rendering/svg/SVGTextRunRenderingContext.h: Added. 139 (WebCore::SVGTextRunRenderingContext::create): 140 (WebCore::SVGTextRunRenderingContext::context): 141 (WebCore::SVGTextRunRenderingContext::activePaintingResource): 142 (WebCore::SVGTextRunRenderingContext::setActivePaintingResource): 143 (WebCore::SVGTextRunRenderingContext::SVGTextRunRenderingContext): 144 (WebCore::textRunNeedsRenderingContext): 145 * svg/SVGAllInOne.cpp: 146 * svg/SVGFont.cpp: Removed. 147 * svg/SVGFontData.cpp: 148 (WebCore::SVGFontData::initializeFontData): 149 * svg/SVGFontData.h: 150 (WebCore::SVGFontData::create): 151 (WebCore::SVGFontData::isSVGFontData): 152 * svg/SVGGlyphElement.cpp: 153 (WebCore::SVGGlyphElement::SVGGlyphElement): 154 (WebCore::SVGGlyphElement::buildGenericGlyphIdentifier): 155 (WebCore::SVGGlyphElement::buildGlyphIdentifier): 156 * svg/SVGHKernElement.cpp: 157 (WebCore::SVGHKernElement::SVGHKernElement): 158 (WebCore::SVGHKernElement::buildHorizontalKerningPair): 159 * svg/SVGVKernElement.cpp: 160 (WebCore::SVGVKernElement::SVGVKernElement): 161 (WebCore::SVGVKernElement::buildVerticalKerningPair): 162 * svg/SVGVKernElement.h: 163 1 164 2011-05-24 Ryuan Choi <ryuan.choi@samsung.com> 2 165 -
trunk/Source/WebCore/GNUmakefile.list.am
r87150 r87152 3092 3092 Source/WebCore/rendering/svg/SVGTextQuery.cpp \ 3093 3093 Source/WebCore/rendering/svg/SVGTextQuery.h \ 3094 Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp \ 3095 Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h \ 3094 3096 Source/WebCore/rendering/TableLayout.h \ 3095 3097 Source/WebCore/rendering/TrailingFloatsRootInlineBox.h \ … … 3389 3391 Source/WebCore/svg/SVGFitToViewBox.cpp \ 3390 3392 Source/WebCore/svg/SVGFitToViewBox.h \ 3391 Source/WebCore/svg/SVGFont.cpp \3392 3393 Source/WebCore/svg/SVGFontData.cpp \ 3393 3394 Source/WebCore/svg/SVGFontData.h \ -
trunk/Source/WebCore/WebCore.gypi
r87150 r87152 5483 5483 'rendering/svg/SVGTextQuery.cpp', 5484 5484 'rendering/svg/SVGTextQuery.h', 5485 'rendering/svg/SVGTextRunRenderingContext.cpp', 5486 'rendering/svg/SVGTextRunRenderingContext.h', 5485 5487 'storage/AbstractDatabase.cpp', 5486 5488 'storage/ChangeVersionWrapper.cpp', … … 5734 5736 'svg/SVGFitToViewBox.cpp', 5735 5737 'svg/SVGFitToViewBox.h', 5736 'svg/SVGFont.cpp',5737 5738 'svg/SVGFontData.cpp', 5738 5739 'svg/SVGFontData.h', -
trunk/Source/WebCore/WebCore.pro
r87150 r87152 2253 2253 rendering/svg/SVGTextMetrics.h \ 2254 2254 rendering/svg/SVGTextQuery.h \ 2255 rendering/svg/SVGTextRunRenderingContext.h \ 2255 2256 rendering/TransformState.h \ 2256 2257 svg/animation/SMILTimeContainer.h \ … … 3209 3210 rendering/svg/SVGTextMetrics.cpp \ 3210 3211 rendering/svg/SVGTextQuery.cpp \ 3212 rendering/svg/SVGTextRunRenderingContext.cpp \ 3211 3213 svg/SVGDocumentExtensions.cpp \ 3212 3214 svg/SVGImageLoader.cpp \ … … 3262 3264 svg/SVGFilterPrimitiveStandardAttributes.cpp \ 3263 3265 svg/SVGFitToViewBox.cpp \ 3264 svg/SVGFont.cpp \3265 3266 svg/SVGFontData.cpp \ 3266 3267 svg/SVGFontElement.cpp \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r87150 r87152 41527 41527 > 41528 41528 </File> 41529 <File 41530 RelativePath="..\rendering\svg\SVGTextRunRenderingContext.cpp" 41531 > 41532 <FileConfiguration 41533 Name="Debug|Win32" 41534 ExcludedFromBuild="true" 41535 > 41536 <Tool 41537 Name="VCCLCompilerTool" 41538 /> 41539 </FileConfiguration> 41540 <FileConfiguration 41541 Name="Release|Win32" 41542 ExcludedFromBuild="true" 41543 > 41544 <Tool 41545 Name="VCCLCompilerTool" 41546 /> 41547 </FileConfiguration> 41548 <FileConfiguration 41549 Name="Debug_Cairo_CFLite|Win32" 41550 ExcludedFromBuild="true" 41551 > 41552 <Tool 41553 Name="VCCLCompilerTool" 41554 /> 41555 </FileConfiguration> 41556 <FileConfiguration 41557 Name="Release_Cairo_CFLite|Win32" 41558 ExcludedFromBuild="true" 41559 > 41560 <Tool 41561 Name="VCCLCompilerTool" 41562 /> 41563 </FileConfiguration> 41564 <FileConfiguration 41565 Name="Debug_All|Win32" 41566 ExcludedFromBuild="true" 41567 > 41568 <Tool 41569 Name="VCCLCompilerTool" 41570 /> 41571 </FileConfiguration> 41572 <FileConfiguration 41573 Name="Production|Win32" 41574 ExcludedFromBuild="true" 41575 > 41576 <Tool 41577 Name="VCCLCompilerTool" 41578 /> 41579 </FileConfiguration> 41580 </File> 41581 <File 41582 RelativePath="..\rendering\svg\SVGTextRunRenderingContext.h" 41583 > 41584 </File> 41529 41585 </Filter> 41530 41586 </Filter> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r87150 r87152 99 99 085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */; }; 100 100 085B92BB0EFDE73D00E6123C /* FormDataBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 085B92B90EFDE73D00E6123C /* FormDataBuilder.h */; settings = {ATTRIBUTES = (); }; }; 101 085CD275138BB8E000907F2D /* SVGTextRunRenderingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 085CD274138BB8E000907F2D /* SVGTextRunRenderingContext.h */; }; 101 102 08641D4712142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */; }; 102 103 08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4377 4378 B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990C0D00D8B900BB825C /* SVGImage.h */; }; 4378 4379 B25599A50D00D8BA00BB825C /* EmptyClients.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990D0D00D8B900BB825C /* EmptyClients.h */; }; 4379 B262B8040D1F32D000158F09 /* SVGFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B262B8030D1F32D000158F09 /* SVGFont.cpp */; };4380 4380 B266CD4D0C3AEC6500EB08D2 /* JSSVGException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B266CD4B0C3AEC6500EB08D2 /* JSSVGException.cpp */; }; 4381 4381 B266CD4E0C3AEC6500EB08D2 /* JSSVGException.h in Headers */ = {isa = PBXBuildFile; fileRef = B266CD4C0C3AEC6500EB08D2 /* JSSVGException.h */; }; … … 6495 6495 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataBuilder.cpp; sourceTree = "<group>"; }; 6496 6496 085B92B90EFDE73D00E6123C /* FormDataBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormDataBuilder.h; sourceTree = "<group>"; }; 6497 085CD274138BB8E000907F2D /* SVGTextRunRenderingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextRunRenderingContext.h; sourceTree = "<group>"; }; 6497 6498 08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageResourceStyleImage.cpp; sourceTree = "<group>"; }; 6498 6499 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResourceStyleImage.h; sourceTree = "<group>"; }; … … 6536 6537 08C925180FCC7C4A00480DEC /* FilterEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterEffect.h; path = filters/FilterEffect.h; sourceTree = "<group>"; }; 6537 6538 08CA3D4312894A3800FFF260 /* SVGStaticPropertyWithParentTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGStaticPropertyWithParentTearOff.h; sourceTree = "<group>"; }; 6539 08D29440138669E40097C89B /* SVGTextRunRenderingContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextRunRenderingContext.cpp; sourceTree = "<group>"; }; 6538 6540 08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedEnumeration.h; sourceTree = "<group>"; }; 6539 6541 08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLengthCustom.cpp; sourceTree = "<group>"; }; … … 10807 10809 B255990C0D00D8B900BB825C /* SVGImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGImage.h; sourceTree = "<group>"; }; 10808 10810 B255990D0D00D8B900BB825C /* EmptyClients.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EmptyClients.h; sourceTree = "<group>"; }; 10809 B262B8030D1F32D000158F09 /* SVGFont.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFont.cpp; sourceTree = "<group>"; };10810 10811 B266CD4B0C3AEC6500EB08D2 /* JSSVGException.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGException.cpp; sourceTree = "<group>"; }; 10811 10812 B266CD4C0C3AEC6500EB08D2 /* JSSVGException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGException.h; sourceTree = "<group>"; }; … … 12779 12780 0854B0121255E4E600B9CDD0 /* SVGTextQuery.cpp */, 12780 12781 0854B0131255E4E600B9CDD0 /* SVGTextQuery.h */, 12782 08D29440138669E40097C89B /* SVGTextRunRenderingContext.cpp */, 12783 085CD274138BB8E000907F2D /* SVGTextRunRenderingContext.h */, 12781 12784 ); 12782 12785 path = svg; … … 17308 17311 B222787C0D00BF200071B782 /* SVGFitToViewBox.h */, 17309 17312 B222787D0D00BF200071B782 /* SVGFitToViewBox.idl */, 17310 B262B8030D1F32D000158F09 /* SVGFont.cpp */,17311 17313 B237C8A50D344D110013F707 /* SVGFontData.cpp */, 17312 17314 B237C8A60D344D110013F707 /* SVGFontData.h */, … … 20183 20185 85B498F30ADB336A00925CBB /* DOMCSSValueInternal.h in Headers */, 20184 20186 858C383C0AA8ED8200B187A4 /* DOMCSSValueList.h in Headers */, 20185 C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */,20186 20187 85909D2B0ACC7D5500DF01F1 /* DOMCSSValueListInternal.h in Headers */, 20187 20188 E10B9CCC0B747A44003ED890 /* DOMCustomXPathNSResolver.h in Headers */, … … 22064 22065 37919C240B7D188600A56998 /* PositionIterator.h in Headers */, 22065 22066 FE80D7D10E9C1F25000D6F75 /* PositionOptions.h in Headers */, 22067 C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */, 22066 22068 B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */, 22067 22069 A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */, … … 22631 22633 B2227AD10D00BF220071B782 /* SVGTextPositioningElement.h in Headers */, 22632 22634 0854B0251255E4E600B9CDD0 /* SVGTextQuery.h in Headers */, 22635 085CD275138BB8E000907F2D /* SVGTextRunRenderingContext.h in Headers */, 22633 22636 B2227AD40D00BF220071B782 /* SVGTitleElement.h in Headers */, 22634 22637 B2227AD70D00BF220071B782 /* SVGTransform.h in Headers */, … … 25282 25285 B2227A0E0D00BF220071B782 /* SVGFilterPrimitiveStandardAttributes.cpp in Sources */, 25283 25286 B2227A110D00BF220071B782 /* SVGFitToViewBox.cpp in Sources */, 25284 B262B8040D1F32D000158F09 /* SVGFont.cpp in Sources */,25285 25287 B237C8A70D344D110013F707 /* SVGFontData.cpp in Sources */, 25286 25288 B2A1F2AA0CEF0ABF00442F6A /* SVGFontElement.cpp in Sources */, -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r84836 r87152 155 155 } 156 156 157 fontData = adoptPtr(new SimpleFontData( adoptPtr(new SVGFontData(fontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));157 fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); 158 158 } 159 159 } else … … 171 171 // In-Document SVG Fonts 172 172 if (m_svgFontFaceElement) 173 fontData = adoptPtr(new SimpleFontData( adoptPtr(new SVGFontData(m_svgFontFaceElement.get())), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));173 fontData = adoptPtr(new SimpleFontData(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic)); 174 174 #endif 175 175 } -
trunk/Source/WebCore/platform/graphics/Font.cpp
r86667 r87152 137 137 138 138 #if ENABLE(SVG_FONTS) 139 if ( primaryFont()->isSVGFont()) {140 drawTextUsingSVGFont(context, run, point, from, to);139 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) { 140 renderingContext->drawTextUsingSVGFont(*this, context, run, point, from, to); 141 141 return; 142 142 } … … 179 179 { 180 180 #if ENABLE(SVG_FONTS) 181 if ( primaryFont()->isSVGFont())182 return floatWidthUsingSVGFont(run);181 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 182 return renderingContext->floatWidthUsingSVGFont(*this, run); 183 183 #endif 184 184 … … 196 196 float Font::width(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const 197 197 { 198 #if !ENABLE(SVG_FONTS) 198 #if ENABLE(SVG_FONTS) 199 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 200 return renderingContext->floatWidthUsingSVGFont(*this, run, extraCharsAvailable, charsConsumed, glyphName); 201 #else 199 202 UNUSED_PARAM(extraCharsAvailable); 200 #else201 if (primaryFont()->isSVGFont())202 return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);203 203 #endif 204 204 … … 215 215 { 216 216 #if ENABLE(SVG_FONTS) 217 if ( primaryFont()->isSVGFont())218 return selectionRectForTextUsingSVGFont(run, point, h, from, to);219 #endif 220 217 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 218 return renderingContext->selectionRectForTextUsingSVGFont(*this, run, point, h, from, to); 219 #endif 220 221 221 to = (to == -1 ? run.length() : to); 222 222 … … 230 230 { 231 231 #if ENABLE(SVG_FONTS) 232 if ( primaryFont()->isSVGFont())233 return offsetForPositionForTextUsingSVGFont(run, x, includePartialGlyphs);232 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 233 return renderingContext->offsetForPositionForTextUsingSVGFont(*this, run, x, includePartialGlyphs); 234 234 #endif 235 235 … … 239 239 return offsetForPositionForComplexText(run, x, includePartialGlyphs); 240 240 } 241 242 #if ENABLE(SVG_FONTS)243 bool Font::isSVGFont() const244 {245 return primaryFont()->isSVGFont();246 }247 #endif248 241 249 242 String Font::normalizeSpaces(const UChar* characters, unsigned length) -
trunk/Source/WebCore/platform/graphics/Font.h
r84609 r87152 51 51 class GlyphPageTreeNode; 52 52 class GraphicsContext; 53 class SVGFontElement;54 53 class TextRun; 55 54 … … 158 157 159 158 private: 160 #if ENABLE(SVG_FONTS)161 void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;162 float floatWidthUsingSVGFont(const TextRun&) const;163 float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;164 FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const FloatPoint&, int h, int from, int to) const;165 int offsetForPositionForTextUsingSVGFont(const TextRun&, float position, bool includePartialGlyphs) const;166 #endif167 168 159 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; 169 160 … … 221 212 static String normalizeSpaces(const UChar*, unsigned length); 222 213 223 #if ENABLE(SVG_FONTS)224 bool isSVGFont() const;225 SVGFontElement* svgFont() const;226 #endif227 228 214 bool needsTranscoding() const { return m_needsTranscoding; } 229 215 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r85853 r87152 34 34 #include "FontCache.h" 35 35 36 #if ENABLE(SVG_FONTS)37 #include "SVGFontData.h"38 #include "SVGFontElement.h"39 #include "SVGFontFaceElement.h"40 #include "SVGGlyphElement.h"41 #endif42 43 36 #include <wtf/MathExtras.h> 44 37 #include <wtf/UnusedParam.h> … … 64 57 } 65 58 66 #if ENABLE(SVG_FONTS) 67 SimpleFontData::SimpleFontData(PassOwnPtr<SVGFontData> svgFontData, int size, bool syntheticBold, bool syntheticItalic) 59 SimpleFontData::SimpleFontData(PassOwnPtr<SimpleFontData::FontData> fontData, int size, bool syntheticBold, bool syntheticItalic) 68 60 : m_platformData(FontPlatformData(size, syntheticBold, syntheticItalic)) 61 , m_fontData(fontData) 69 62 , m_treatAsFixedPitch(false) 70 , m_svgFontData(svgFontData)71 63 , m_isCustomFont(true) 72 64 , m_isLoading(false) … … 75 67 , m_hasVerticalGlyphs(false) 76 68 { 77 SVGFontFaceElement* svgFontFaceElement = m_svgFontData->svgFontFaceElement(); 78 unsigned unitsPerEm = svgFontFaceElement->unitsPerEm(); 79 80 float scale = size; 81 if (unitsPerEm) 82 scale /= unitsPerEm; 83 84 float xHeight = svgFontFaceElement->xHeight() * scale; 85 float ascent = svgFontFaceElement->ascent() * scale; 86 float descent = svgFontFaceElement->descent() * scale; 87 float lineGap = 0.1f * size; 88 89 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement(); 90 if (!xHeight) { 91 // Fallback if x_heightAttr is not specified for the font element. 92 Vector<SVGGlyph> letterXGlyphs; 93 associatedFontElement->getGlyphIdentifiersForString(String("x", 1), letterXGlyphs); 94 xHeight = letterXGlyphs.isEmpty() ? 2 * ascent / 3 : letterXGlyphs.first().horizontalAdvanceX * scale; 95 } 96 97 m_fontMetrics.setUnitsPerEm(unitsPerEm); 98 m_fontMetrics.setAscent(ascent); 99 m_fontMetrics.setDescent(descent); 100 m_fontMetrics.setLineGap(lineGap); 101 m_fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap)); 102 m_fontMetrics.setXHeight(xHeight); 103 104 Vector<SVGGlyph> spaceGlyphs; 105 associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs); 106 m_spaceWidth = spaceGlyphs.isEmpty() ? xHeight : spaceGlyphs.first().horizontalAdvanceX * scale; 107 108 Vector<SVGGlyph> numeralZeroGlyphs; 109 associatedFontElement->getGlyphIdentifiersForString(String("0", 1), numeralZeroGlyphs); 110 m_avgCharWidth = numeralZeroGlyphs.isEmpty() ? m_spaceWidth : numeralZeroGlyphs.first().horizontalAdvanceX * scale; 111 112 Vector<SVGGlyph> letterWGlyphs; 113 associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs); 114 m_maxCharWidth = letterWGlyphs.isEmpty() ? ascent : letterWGlyphs.first().horizontalAdvanceX * scale; 115 116 // FIXME: is there a way we can get the space glyph from the SVGGlyph above? 117 m_spaceGlyph = 0; 118 m_zeroWidthSpaceGlyph = 0; 119 determinePitch(); 120 m_missingGlyphData.fontData = this; 121 m_missingGlyphData.glyph = 0; 122 } 123 #endif 69 m_fontData->initializeFontData(this, size); 70 } 124 71 125 72 #if !(PLATFORM(QT) && !HAVE(QRAWFONT)) … … 187 134 { 188 135 #if ENABLE(SVG_FONTS) 189 if (!m_ svgFontData || !m_svgFontData->svgFontFaceElement())136 if (!m_fontData) 190 137 #endif 191 138 platformDestroy(); -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r86401 r87152 65 65 class FontDescription; 66 66 class SharedBuffer; 67 class SVGFontData;68 67 69 68 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMarkVariant }; … … 72 71 class SimpleFontData : public FontData { 73 72 public: 73 class FontData { 74 WTF_MAKE_FAST_ALLOCATED; 75 public: 76 virtual ~FontData() { } 77 78 virtual void initializeFontData(SimpleFontData*, int) = 0; 79 }; 80 81 // Used to create platform fonts. 74 82 SimpleFontData(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false); 75 #if ENABLE(SVG_FONTS) 76 SimpleFontData(PassOwnPtr<SVGFontData>, int size, bool syntheticBold, bool syntheticItalic); 77 #endif 83 84 // Used to create SVG Fonts. 85 SimpleFontData(PassOwnPtr<SimpleFontData::FontData>, int size, bool syntheticBold, bool syntheticItalic); 86 78 87 virtual ~SimpleFontData(); 79 88 … … 105 114 bool isTextOrientationFallback() const { return m_isTextOrientationFallback; } 106 115 116 FontMetrics& fontMetrics() { return m_fontMetrics; } 107 117 const FontMetrics& fontMetrics() const { return m_fontMetrics; } 118 108 119 float maxCharWidth() const { return m_maxCharWidth; } 120 void setMaxCharWidth(float maxCharWidth) { m_maxCharWidth = maxCharWidth; } 121 109 122 float avgCharWidth() const { return m_avgCharWidth; } 123 void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; } 110 124 111 125 FloatRect boundsForGlyph(Glyph) const; … … 115 129 116 130 float spaceWidth() const { return m_spaceWidth; } 131 void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; } 117 132 118 133 #if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROME) … … 121 136 122 137 Glyph spaceGlyph() const { return m_spaceGlyph; } 138 void setSpaceGlyph(Glyph spaceGlyph) { m_spaceGlyph = spaceGlyph; } 139 void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; } 123 140 bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; } 124 141 … … 129 146 Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; } 130 147 131 #if ENABLE(SVG_FONTS) 132 SVGFontData* svgFontData() const { return m_svgFontData.get(); } 133 bool isSVGFont() const { return m_svgFontData; } 134 #else 135 bool isSVGFont() const { return false; } 136 #endif 148 SimpleFontData::FontData* fontData() const { return m_fontData.get(); } 149 bool isSVGFont() const { return m_fontData; } 137 150 138 151 virtual bool isCustomFont() const { return m_isCustomFont; } … … 141 154 142 155 const GlyphData& missingGlyphData() const { return m_missingGlyphData; } 156 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; } 143 157 144 158 #ifndef NDEBUG … … 209 223 210 224 FontPlatformData m_platformData; 225 OwnPtr<SimpleFontData::FontData> m_fontData; 211 226 212 227 mutable OwnPtr<GlyphMetricsMap<FloatRect> > m_glyphToBoundsMap; … … 214 229 215 230 bool m_treatAsFixedPitch; 216 217 #if ENABLE(SVG_FONTS)218 OwnPtr<SVGFontData> m_svgFontData;219 #endif220 221 231 bool m_isCustomFont; // Whether or not we are custom font loaded via @font-face 222 232 bool m_isLoading; // Whether or not this custom font is still in the act of loading. -
trunk/Source/WebCore/platform/graphics/TextRun.h
r85143 r87152 25 25 #define TextRun_h 26 26 27 #include "PlatformString.h"28 27 #include "TextDirection.h" 28 #include <wtf/RefCounted.h> 29 #include <wtf/text/WTFString.h> 29 30 30 31 namespace WebCore { 31 32 32 class RenderObject; 33 class RenderSVGResource; 33 class FloatPoint; 34 class FloatRect; 35 class Font; 36 class GraphicsContext; 34 37 35 38 class TextRun { … … 57 60 , m_directionalOverride(directionalOverride) 58 61 , m_disableSpacing(false) 59 #if ENABLE(SVG_FONTS)60 , m_referencingRenderObject(0)61 , m_activePaintingResource(0)62 #endif63 62 { 64 63 } … … 77 76 , m_directionalOverride(directionalOverride) 78 77 , m_disableSpacing(false) 79 #if ENABLE(SVG_FONTS)80 , m_referencingRenderObject(0)81 , m_activePaintingResource(0)82 #endif83 78 { 84 79 } … … 98 93 99 94 bool allowTabs() const { return m_allowTabs; } 95 void setAllowTabs(bool allowTabs) { m_allowTabs = allowTabs; } 100 96 float xPos() const { return m_xpos; } 97 void setXPos(float xPos) { m_xpos = xPos; } 101 98 float expansion() const { return m_expansion; } 102 99 bool allowsLeadingExpansion() const { return m_expansionBehavior & AllowLeadingExpansion; } … … 112 109 void setDirectionalOverride(bool override) { m_directionalOverride = override; } 113 110 111 class RenderingContext : public RefCounted<RenderingContext> { 112 public: 113 virtual ~RenderingContext() { } 114 114 115 #if ENABLE(SVG_FONTS) 115 RenderObject* referencingRenderObject() const { return m_referencingRenderObject; } 116 void setReferencingRenderObject(RenderObject* object) { m_referencingRenderObject = object; } 116 // FIXME: Note that the SVG Font integration APIs will be more abstract and simpler once the SVG Fonts rewrite patch lands (59085). 117 virtual void drawTextUsingSVGFont(const Font&, GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const = 0; 118 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&) const = 0; 119 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const = 0; 120 virtual FloatRect selectionRectForTextUsingSVGFont(const Font&, const TextRun&, const FloatPoint&, int h, int from, int to) const = 0; 121 virtual int offsetForPositionForTextUsingSVGFont(const Font&, const TextRun&, float position, bool includePartialGlyphs) const = 0; 122 #endif 123 }; 117 124 118 RenderSVGResource* activePaintingResource() const { return m_activePaintingResource; } 119 void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; } 120 #endif 125 RenderingContext* renderingContext() const { return m_renderingContext.get(); } 126 void setRenderingContext(PassRefPtr<RenderingContext> context) { m_renderingContext = context; } 121 127 122 128 private: … … 137 143 bool m_directionalOverride; // Was this direction set by an override character. 138 144 bool m_disableSpacing; 139 140 #if ENABLE(SVG_FONTS) 141 RenderObject* m_referencingRenderObject; 142 RenderSVGResource* m_activePaintingResource; 143 #endif 145 RefPtr<RenderingContext> m_renderingContext; 144 146 }; 145 147 -
trunk/Source/WebCore/rendering/EllipsisBox.cpp
r87018 r87152 45 45 } 46 46 47 const Font& font = style->font(); 47 48 if (selectionState() != RenderObject::SelectionNone) { 48 paintSelection(context, tx, ty, style, style->font());49 paintSelection(context, tx, ty, style, font); 49 50 50 51 // Select the correct color for painting the text. … … 55 56 56 57 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 57 context->drawText( style->font(), RenderBlock::constructTextRunAllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent()));58 context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent())); 58 59 59 60 // Restore the regular fill color. … … 75 76 { 76 77 RenderStyle* style = m_renderer->style(m_firstLine); 77 const Font& f = style->font();78 const Font& font = style->font(); 78 79 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 79 return enclosingIntRect(f .selectionRectForText(RenderBlock::constructTextRunAllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + root()->selectionTop()), root()->selectionHeight()));80 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(m_x + tx, m_y + ty + root()->selectionTop()), root()->selectionHeight())); 80 81 } 81 82 … … 97 98 context->clip(IntRect(m_x + tx, y + ty, m_logicalWidth, h)); 98 99 // FIXME: Why is this always LTR? Fix by passing correct text run flags below. 99 context->drawHighlightForText(font, RenderBlock::constructTextRun AllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + y), h, c, style->colorSpace());100 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(m_x + tx, m_y + ty + y), h, c, style->colorSpace()); 100 101 } 101 102 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r87018 r87152 42 42 #include "RenderRubyText.h" 43 43 #include "RenderTheme.h" 44 #include "SVGTextRunRenderingContext.h" 44 45 #include "Text.h" 45 #include "TextRun.h"46 46 #include "break_lines.h" 47 47 #include <wtf/AlwaysInline.h> … … 183 183 int selHeight = selectionHeight(); 184 184 RenderStyle* styleToUse = textObj->style(m_firstLine); 185 const Font& f = styleToUse->font();185 const Font& font = styleToUse->font(); 186 186 187 187 BufferForAppendingHyphen charactersWithHyphen; 188 188 bool respectHyphen = ePos == m_len && hasHyphen(); 189 TextRun textRun = constructTextRun(styleToUse, respectHyphen ? &charactersWithHyphen : 0);189 TextRun textRun = constructTextRun(styleToUse, font, respectHyphen ? &charactersWithHyphen : 0); 190 190 if (respectHyphen) 191 191 endPos = textRun.length(); 192 192 193 IntRect r = enclosingIntRect(f .selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));193 IntRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos)); 194 194 195 195 int logicalWidth = r.width(); … … 644 644 645 645 BufferForAppendingHyphen charactersWithHyphen; 646 TextRun textRun = constructTextRun(styleToUse, characters, length, hasHyphen() ? &charactersWithHyphen : 0);646 TextRun textRun = constructTextRun(styleToUse, font, characters, length, hasHyphen() ? &charactersWithHyphen : 0); 647 647 if (hasHyphen()) 648 648 length = textRun.length(); … … 681 681 updateGraphicsContext(context, emphasisMarkColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace()); 682 682 683 static TextRun objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);683 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1)); 684 684 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementCharacterTextRun : textRun; 685 685 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : textOrigin; … … 707 707 updateGraphicsContext(context, selectionEmphasisMarkColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace()); 708 708 709 static TextRun objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);709 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1)); 710 710 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementCharacterTextRun : textRun; 711 711 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : textOrigin; … … 809 809 BufferForAppendingHyphen charactersWithHyphen; 810 810 bool respectHyphen = ePos == length && hasHyphen(); 811 TextRun textRun = constructTextRun(style, characters, length, respectHyphen ? &charactersWithHyphen : 0);811 TextRun textRun = constructTextRun(style, font, characters, length, respectHyphen ? &charactersWithHyphen : 0); 812 812 if (respectHyphen) 813 813 ePos = textRun.length(); … … 844 844 int selHeight = selectionHeight(); 845 845 FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); 846 context->drawHighlightForText(font, constructTextRun(style ), localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);846 context->drawHighlightForText(font, constructTextRun(style, font), localOrigin, selHeight, c, style->colorSpace(), sPos, ePos); 847 847 } 848 848 … … 1002 1002 int selHeight = selectionHeight(); 1003 1003 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); 1004 TextRun run = constructTextRun(style );1004 TextRun run = constructTextRun(style, font); 1005 1005 1006 1006 // FIXME: Convert the document markers to float rects. … … 1047 1047 int sPos = max(marker.startOffset() - m_start, (unsigned)0); 1048 1048 int ePos = min(marker.endOffset() - m_start, (unsigned)m_len); 1049 TextRun run = constructTextRun(style );1049 TextRun run = constructTextRun(style, font); 1050 1050 // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates. 1051 1051 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, selectionTop()), selHeight, sPos, ePos)); … … 1074 1074 int sPos = max(marker.startOffset() - m_start, (unsigned)0); 1075 1075 int ePos = min(marker.endOffset() - m_start, (unsigned)m_len); 1076 TextRun run = constructTextRun(style );1076 TextRun run = constructTextRun(style, font); 1077 1077 IntPoint startPoint = IntPoint(m_x, y); 1078 1078 … … 1233 1233 RenderText* text = toRenderText(renderer()); 1234 1234 RenderStyle* style = text->style(m_firstLine); 1235 const Font * f = &style->font();1236 int offset = f ->offsetForPosition(constructTextRun(style), lineOffset - logicalLeft(), includePartialGlyphs);1235 const Font& font = style->font(); 1236 int offset = font.offsetForPosition(constructTextRun(style, font), lineOffset - logicalLeft(), includePartialGlyphs); 1237 1237 if (blockIsInOppositeDirection && (!offset || offset == m_len)) 1238 1238 return !offset ? m_len : 0; … … 1251 1251 RenderStyle* styleToUse = text->style(m_firstLine); 1252 1252 ASSERT(styleToUse); 1253 const Font& f = styleToUse->font();1253 const Font& font = styleToUse->font(); 1254 1254 int from = !isLeftToRightDirection() ? offset - m_start : 0; 1255 1255 int to = !isLeftToRightDirection() ? m_len : offset - m_start; 1256 1256 // FIXME: Do we need to add rightBearing here? 1257 return f .selectionRectForText(constructTextRun(styleToUse), IntPoint(logicalLeft(), 0), 0, from, to).maxX();1257 return font.selectionRectForText(constructTextRun(styleToUse, font), IntPoint(logicalLeft(), 0), 0, from, to).maxX(); 1258 1258 } 1259 1259 … … 1282 1282 } 1283 1283 1284 TextRun InlineTextBox::constructTextRun(RenderStyle* style, BufferForAppendingHyphen* charactersWithHyphen) const1284 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, BufferForAppendingHyphen* charactersWithHyphen) const 1285 1285 { 1286 1286 ASSERT(style); … … 1290 1290 ASSERT(textRenderer->characters()); 1291 1291 1292 return constructTextRun(style, textRenderer->characters() + start(), len(), charactersWithHyphen);1293 } 1294 1295 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const UChar* characters, int length, BufferForAppendingHyphen* charactersWithHyphen) const1292 return constructTextRun(style, font, textRenderer->characters() + start(), len(), charactersWithHyphen); 1293 } 1294 1295 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, const UChar* characters, int length, BufferForAppendingHyphen* charactersWithHyphen) const 1296 1296 { 1297 1297 ASSERT(style); … … 1303 1303 adjustCharactersAndLengthForHyphen(*charactersWithHyphen, style, characters, length); 1304 1304 1305 // FIXME: Remove TextRuns all-in-one-constructor and use explicit setters here. 1306 return TextRun(characters, length, textRenderer->allowTabs(), textPos(), expansion(), expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered()); 1305 TextRun run(characters, length, textRenderer->allowTabs(), textPos(), expansion(), expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered()); 1306 if (textRunNeedsRenderingContext(font)) 1307 run.setRenderingContext(SVGTextRunRenderingContext::create(textRenderer)); 1308 1309 return run; 1307 1310 } 1308 1311 -
trunk/Source/WebCore/rendering/InlineTextBox.h
r86819 r87152 100 100 int selectionHeight(); 101 101 102 TextRun constructTextRun(RenderStyle*, BufferForAppendingHyphen* = 0) const;103 TextRun constructTextRun(RenderStyle*, const UChar*, int length, BufferForAppendingHyphen* = 0) const;102 TextRun constructTextRun(RenderStyle*, const Font&, BufferForAppendingHyphen* = 0) const; 103 TextRun constructTextRun(RenderStyle*, const Font&, const UChar*, int length, BufferForAppendingHyphen* = 0) const; 104 104 105 105 public: -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r87101 r87152 52 52 #include "RenderView.h" 53 53 #include "Settings.h" 54 #include " TextRun.h"54 #include "SVGTextRunRenderingContext.h" 55 55 #include "TransformState.h" 56 56 #include <wtf/StdLibExtras.h> … … 4708 4708 const UChar space = ' '; 4709 4709 const Font& font = t->style()->font(); // FIXME: This ignores first-line. 4710 float spaceWidth = font.width( TextRun(&space, 1));4710 float spaceWidth = font.width(RenderBlock::constructTextRun(t, font, &space, 1, t->style())); 4711 4711 inlineMax -= spaceWidth + font.wordSpacing(); 4712 4712 if (inlineMin > inlineMax) … … 6317 6317 } 6318 6318 6319 TextRun RenderBlock::constructTextRun AllowTrailingExpansion(const UChar* characters, int length, RenderStyle* style, TextRunFlags flags)6319 TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, const UChar* characters, int length, RenderStyle* style, TextRun::ExpansionBehavior expansion, TextRunFlags flags) 6320 6320 { 6321 6321 ASSERT(style); … … 6330 6330 } 6331 6331 6332 // FIXME: Remove TextRuns all-in-one-constructor and use explicit setters here. 6333 return TextRun(characters, length, false, 0, 0, TextRun::AllowTrailingExpansion, textDirection, directionalOverride); 6334 } 6335 6336 TextRun RenderBlock::constructTextRunAllowTrailingExpansion(const String& string, RenderStyle* style, TextRunFlags flags) 6337 { 6338 return constructTextRunAllowTrailingExpansion(string.characters(), string.length(), style, flags); 6332 TextRun run(characters, length, false, 0, 0, expansion, textDirection, directionalOverride); 6333 if (textRunNeedsRenderingContext(font)) 6334 run.setRenderingContext(SVGTextRunRenderingContext::create(context)); 6335 6336 return run; 6337 } 6338 6339 TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, const String& string, RenderStyle* style, TextRun::ExpansionBehavior expansion, TextRunFlags flags) 6340 { 6341 return constructTextRun(context, font, string.characters(), string.length(), style, expansion, flags); 6339 6342 } 6340 6343 -
trunk/Source/WebCore/rendering/RenderBlock.h
r87101 r87152 28 28 #include "RenderLineBoxList.h" 29 29 #include "RootInlineBox.h" 30 #include "TextRun.h" 30 31 #include <wtf/OwnPtr.h> 31 32 #include <wtf/ListHashSet.h> … … 170 171 static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&); 171 172 172 static TextRun constructTextRunAllowTrailingExpansion(const String&, RenderStyle*, TextRunFlags = DefaultTextRunFlags); 173 static TextRun constructTextRunAllowTrailingExpansion(const UChar*, int length, RenderStyle*, TextRunFlags = DefaultTextRunFlags); 173 static TextRun constructTextRun(RenderObject* context, const Font&, const String&, RenderStyle*, 174 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags); 175 176 static TextRun constructTextRun(RenderObject* context, const Font&, const UChar*, int length, RenderStyle*, 177 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags); 174 178 175 179 ColumnInfo* columnInfo() const; -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r87026 r87152 37 37 #include "Settings.h" 38 38 #include "TextBreakIterator.h" 39 #include "TextRun.h"40 39 #include "TrailingFloatsRootInlineBox.h" 41 40 #include "VerticalPositionCache.h" … … 483 482 if (static_cast<InlineTextBox*>(run->m_box)->hasHyphen()) { 484 483 const AtomicString& hyphenString = renderer->style()->hyphenString(); 485 hyphenWidth = renderer->style(lineInfo.isFirstLine())->font().width(TextRun(hyphenString.characters(), hyphenString.length())); 484 const Font& font = renderer->style(lineInfo.isFirstLine())->font(); 485 hyphenWidth = font.width(RenderBlock::constructTextRun(renderer, font, hyphenString.string(), renderer->style())); 486 486 } 487 487 run->m_box->setLogicalWidth(renderer->width(run->m_start, run->m_stop - run->m_start, xPos, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow) + hyphenWidth); … … 1577 1577 if (isFixedPitch || (!from && len == text->textLength()) || text->style()->hasTextCombine()) 1578 1578 return text->width(from, len, font, xPos); 1579 return font.width(TextRun(text->characters() + from, len, !collapseWhiteSpace, xPos)); 1579 TextRun run = RenderBlock::constructTextRun(text, font, text->characters() + from, len, text->style()); 1580 run.setAllowTabs(!collapseWhiteSpace); 1581 run.setXPos(xPos); 1582 return font.width(run); 1580 1583 } 1581 1584 … … 1593 1596 1594 1597 const AtomicString& hyphenString = text->style()->hyphenString(); 1595 int hyphenWidth = font.width( TextRun(hyphenString.characters(), hyphenString.length()));1598 int hyphenWidth = font.width(RenderBlock::constructTextRun(text, font, hyphenString.string(), text->style())); 1596 1599 1597 1600 float maxPrefixWidth = availableWidth - xPos - hyphenWidth - lastSpaceWordSpacing; … … 1601 1604 return; 1602 1605 1603 unsigned prefixLength = font.offsetForPosition(TextRun(text->characters() + lastSpace, pos - lastSpace, !collapseWhiteSpace, xPos + lastSpaceWordSpacing), maxPrefixWidth, false); 1606 TextRun run = RenderBlock::constructTextRun(text, font, text->characters() + lastSpace, pos - lastSpace, text->style()); 1607 run.setAllowTabs(!collapseWhiteSpace); 1608 run.setXPos(xPos + lastSpaceWordSpacing); 1609 1610 unsigned prefixLength = font.offsetForPosition(run, maxPrefixWidth, false); 1604 1611 if (prefixLength < static_cast<unsigned>(minimumPrefixLength)) 1605 1612 return; … … 2044 2051 // Non-zero only when kerning is enabled, in which case we measure words with their trailing 2045 2052 // space, then subtract its width. 2046 float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width( TextRun(&space, 1)) + wordSpacing : 0;2053 float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0; 2047 2054 2048 2055 float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true); … … 2073 2080 if (c == softHyphen && autoWrap && !hyphenWidth && style->hyphens() != HyphensNone) { 2074 2081 const AtomicString& hyphenString = style->hyphenString(); 2075 hyphenWidth = f.width( TextRun(hyphenString.characters(), hyphenString.length()));2082 hyphenWidth = f.width(constructTextRun(t, f, hyphenString.string(), current.m_obj->style())); 2076 2083 width.addUncommittedWidth(hyphenWidth); 2077 2084 } … … 2404 2411 // Determine the width of the ellipsis using the current font. 2405 2412 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP) if horizontal ellipsis is "not renderable" 2406 TextRun ellipsisRun(&horizontalEllipsis, 1);2413 const Font& font = style()->font(); 2407 2414 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); 2408 2415 const Font& firstLineFont = firstLineStyle()->font(); 2409 const Font& font = style()->font(); 2410 int firstLineEllipsisWidth = firstLineFont.width(ellipsisRun); 2411 int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(ellipsisRun); 2416 int firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsis, 1, firstLineStyle())); 2417 int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style())); 2412 2418 2413 2419 // For LTR text truncation, we want to get the right edge of our padding box, and then we want to see -
trunk/Source/WebCore/rendering/RenderCombineText.cpp
r81251 r87152 22 22 #include "RenderCombineText.h" 23 23 24 #include " TextRun.h"24 #include "RenderBlock.h" 25 25 26 26 namespace WebCore { … … 94 94 return; 95 95 96 TextRun run = TextRun(String(text()));96 TextRun run = RenderBlock::constructTextRun(this, originalFont(), String(text()), style()); 97 97 FontDescription description = originalFont().fontDescription(); 98 98 float emWidth = description.computedSize() * textCombineMargin; -
trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp
r86739 r87152 222 222 if (paintInfo.phase == PaintPhaseForeground) { 223 223 const String& displayedFilename = fileTextValue(); 224 TextRun textRun = constructTextRunAllowTrailingExpansion(displayedFilename, style(), RespectDirection | RespectDirectionOverride); 224 const Font& font = style()->font(); 225 TextRun textRun = constructTextRun(this, font, displayedFilename, style(), TextRun::AllowTrailingExpansion, RespectDirection | RespectDirectionOverride); 225 226 226 227 // Determine where the filename should be placed … … 232 233 textX = contentLeft + buttonAndIconWidth; 233 234 else 234 textX = contentLeft + contentWidth() - buttonAndIconWidth - style()->font().width(textRun);235 textX = contentLeft + contentWidth() - buttonAndIconWidth - font.width(textRun); 235 236 // We want to match the button's baseline 236 237 RenderButton* buttonRenderer = toRenderButton(m_button->renderer()); … … 242 243 243 244 // Draw the filename 244 paintInfo.context->drawBidiText( style()->font(), textRun, IntPoint(textX, textY));245 paintInfo.context->drawBidiText(font, textRun, IntPoint(textX, textY)); 245 246 246 247 if (m_fileChooser->icon()) { … … 272 273 ASSERT(style); 273 274 275 const Font& font = style->font(); 274 276 if (style->width().isFixed() && style->width().value() > 0) 275 277 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeContentBoxLogicalWidth(style->width().value()); … … 278 280 // (using "0" as the nominal character). 279 281 const UChar ch = '0'; 280 float charWidth = style->font().width(constructTextRunAllowTrailingExpansion(String(&ch, 1), style));282 float charWidth = font.width(constructTextRun(this, font, String(&ch, 1), style, TextRun::AllowTrailingExpansion)); 281 283 m_maxPreferredLogicalWidth = (int)ceilf(charWidth * defaultWidthNumChars); 282 284 } -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r86389 r87152 28 28 #include "RenderLayer.h" 29 29 #include "RenderView.h" 30 #include "TextRun.h"31 30 #include <wtf/StdLibExtras.h> 32 31 #include <wtf/unicode/CharacterNames.h> … … 903 902 InlineBox* anchorBox = lastLine->lastChild(); 904 903 if (anchorBox && anchorBox->renderer()->style()->isLink()) 905 totalWidth = anchorBox->logicalWidth() + font.width( TextRun(ellipsisAndSpace, 2));904 totalWidth = anchorBox->logicalWidth() + font.width(constructTextRun(this, font, ellipsisAndSpace, 2, style())); 906 905 else { 907 906 anchorBox = 0; 908 totalWidth = font.width( TextRun(&horizontalEllipsis, 1));907 totalWidth = font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style())); 909 908 } 910 909 -
trunk/Source/WebCore/rendering/RenderImage.cpp
r86739 r87152 40 40 #include "RenderLayer.h" 41 41 #include "RenderView.h" 42 #include "TextRun.h"43 42 #include <wtf/UnusedParam.h> 44 43 … … 105 104 if (!m_altText.isEmpty()) { 106 105 const Font& font = style()->font(); 107 IntSize textSize(min(font.width( TextRun(m_altText)), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight));106 IntSize textSize(min(font.width(RenderBlock::constructTextRun(this, font, m_altText, style())), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight)); 108 107 imageSize = imageSize.expandedTo(textSize); 109 108 } … … 287 286 // Only draw the alt text if it'll fit within the content box, 288 287 // and only if it fits above the error image. 289 TextRun textRun (text);288 TextRun textRun = RenderBlock::constructTextRun(this, font, text, style()); 290 289 int textWidth = font.width(textRun); 291 290 if (errorPictureDrawn) { -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r87101 r87152 57 57 #include "SelectElement.h" 58 58 #include "SpatialNavigation.h" 59 #include "TextRun.h"60 59 #include <math.h> 61 60 … … 121 120 if (!text.isEmpty()) { 122 121 // FIXME: Why is this always LTR? Can't text direction affect the width? 123 float textWidth = itemFont.width(constructTextRun AllowTrailingExpansion(text, style()));122 float textWidth = itemFont.width(constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion)); 124 123 width = max(width, textWidth); 125 124 } -
trunk/Source/WebCore/rendering/RenderListMarker.cpp
r86197 r87152 32 32 #include "RenderListItem.h" 33 33 #include "RenderView.h" 34 #include "TextRun.h"35 34 #include <wtf/unicode/CharacterNames.h> 36 35 … … 1254 1253 return; 1255 1254 1256 TextRun textRun(m_text); 1255 const Font& font = style()->font(); 1256 TextRun textRun = RenderBlock::constructTextRun(this, font, m_text, style()); 1257 1257 1258 1258 GraphicsContextStateSaver stateSaver(*context, false); … … 1270 1270 1271 1271 if (type == Asterisks || type == Footnotes) 1272 context->drawText( style()->font(), textRun, textOrigin);1272 context->drawText(font, textRun, textOrigin); 1273 1273 else { 1274 1274 // Text is not arbitrary. We can judge whether it's RTL from the first character, … … 1281 1281 for (int i = 0; i < length; ++i) 1282 1282 reversedText[length - i - 1] = m_text[i]; 1283 textRun = TextRun(reversedText.data(), length); 1284 } 1285 1286 const Font& font = style()->font(); 1283 textRun.setText(reversedText.data(), length); 1284 } 1285 1287 1286 const UChar suffix = listMarkerSuffix(type, m_listItem->value()); 1288 1287 if (style()->isLeftToRightDirection()) { 1289 1288 int width = font.width(textRun); 1290 context->drawText( style()->font(), textRun, textOrigin);1289 context->drawText(font, textRun, textOrigin); 1291 1290 UChar suffixSpace[2] = { suffix, ' ' }; 1292 context->drawText( style()->font(), TextRun(suffixSpace, 2), textOrigin + IntSize(width, 0));1291 context->drawText(font, RenderBlock::constructTextRun(this, font, suffixSpace, 2, style()), textOrigin + IntSize(width, 0)); 1293 1292 } else { 1294 1293 UChar spaceSuffix[2] = { ' ', suffix }; 1295 TextRun spaceSuffixRun (spaceSuffix, 2);1294 TextRun spaceSuffixRun = RenderBlock::constructTextRun(this, font, spaceSuffix, 2, style()); 1296 1295 int width = font.width(spaceSuffixRun); 1297 context->drawText( style()->font(), spaceSuffixRun, textOrigin);1298 context->drawText( style()->font(), textRun, textOrigin + IntSize(width, 0));1296 context->drawText(font, spaceSuffixRun, textOrigin); 1297 context->drawText(font, textRun, textOrigin + IntSize(width, 0)); 1299 1298 } 1300 1299 } … … 1456 1455 int itemWidth = font.width(m_text); 1457 1456 UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' }; 1458 int suffixSpaceWidth = font.width( TextRun(suffixSpace, 2));1457 int suffixSpaceWidth = font.width(RenderBlock::constructTextRun(this, font, suffixSpace, 2, style())); 1459 1458 logicalWidth = itemWidth + suffixSpaceWidth; 1460 1459 } … … 1679 1678 int itemWidth = font.width(m_text); 1680 1679 UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' }; 1681 int suffixSpaceWidth = font.width( TextRun(suffixSpace, 2));1680 int suffixSpaceWidth = font.width(RenderBlock::constructTextRun(this, font, suffixSpace, 2, style())); 1682 1681 relativeRect = IntRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height()); 1683 1682 } -
trunk/Source/WebCore/rendering/RenderText.cpp
r85677 r87152 41 41 #include "TextBreakIterator.h" 42 42 #include "TextResourceDecoder.h" 43 #include "TextRun.h"44 43 #include "VisiblePosition.h" 45 44 #include "break_lines.h" … … 632 631 } 633 632 634 return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos), fallbackFonts, glyphOverflow); 633 TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + start, len, style()); 634 run.setAllowTabs(allowTabs()); 635 run.setXPos(xPos); 636 return f.width(run, fallbackFonts, glyphOverflow); 635 637 } 636 638 … … 677 679 StringImpl& text = *m_text.impl(); 678 680 if (text[0] == ' ' || (text[0] == '\n' && !style()->preserveNewline()) || text[0] == '\t') { 679 const Font& f = style()->font(); // FIXME: This ignores first-line.681 const Font& font = style()->font(); // FIXME: This ignores first-line. 680 682 if (stripFrontSpaces) { 681 683 const UChar space = ' '; 682 float spaceWidth = f .width(TextRun(&space, 1));684 float spaceWidth = font.width(RenderBlock::constructTextRun(this, font, &space, 1, style())); 683 685 maxW -= spaceWidth; 684 686 } else 685 maxW += f .wordSpacing();687 maxW += font.wordSpacing(); 686 688 } 687 689 … … 916 918 currMaxWidth = 0; 917 919 } else { 918 currMaxWidth += f.width(TextRun(txt + i, 1, allowTabs(), leadWidth + currMaxWidth)); 920 TextRun run = RenderBlock::constructTextRun(this, f, txt + i, 1, style()); 921 run.setAllowTabs(allowTabs()); 922 run.setXPos(leadWidth + currMaxWidth); 923 924 currMaxWidth += f.width(run); 919 925 glyphOverflow.right = 0; 920 926 needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1; … … 1290 1296 } else 1291 1297 w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow); 1292 } else 1293 w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos), fallbackFonts, glyphOverflow); 1298 } else { 1299 TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + from, len, style()); 1300 run.setAllowTabs(allowTabs()); 1301 run.setXPos(xPos); 1302 w = f.width(run, fallbackFonts, glyphOverflow); 1303 } 1294 1304 1295 1305 return w; -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r87067 r87152 41 41 #include "TextControlInnerElements.h" 42 42 #include "TextIterator.h" 43 #include "TextRun.h"44 43 #include <wtf/unicode/CharacterNames.h> 45 44 … … 535 534 536 535 const UChar ch = '0'; 537 return style()->font().width(constructTextRunAllowTrailingExpansion(String(&ch, 1), style())); 536 const Font& font = style()->font(); 537 return font.width(constructTextRun(this, font, String(&ch, 1), style(), TextRun::AllowTrailingExpansion)); 538 538 } 539 539 -
trunk/Source/WebCore/rendering/svg/RenderSVGAllInOne.cpp
r81540 r87152 73 73 #include "SVGTextLayoutEngineBaseline.cpp" 74 74 #include "SVGTextLayoutEngineSpacing.cpp" 75 #include "SVGTextRunRenderingContext.cpp" 75 76 #include "SVGTextMetrics.cpp" 76 77 #include "SVGTextQuery.cpp" -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r85143 r87152 33 33 #include "SVGImageBufferTools.h" 34 34 #include "SVGRootInlineBox.h" 35 #include " TextRun.h"35 #include "SVGTextRunRenderingContext.h" 36 36 37 37 using namespace std; … … 67 67 ASSERT(style); 68 68 69 TextRun textRun (constructTextRun(style, fragment));69 TextRun textRun = constructTextRun(style, fragment); 70 70 71 71 // Eventually handle lengthAdjust="spacingAndGlyphs". … … 380 380 { 381 381 bool acquiredResource = acquirePaintingResource(context, scalingFactor, parent()->renderer(), style); 382 if (!acquiredResource) 383 return false; 382 384 383 385 #if ENABLE(SVG_FONTS) 384 386 // SVG Fonts need access to the painting resource used to draw the current text chunk. 385 if (acquiredResource) 386 textRun.setActivePaintingResource(m_paintingResource); 387 TextRun::RenderingContext* renderingContext = textRun.renderingContext(); 388 if (renderingContext) 389 static_cast<SVGTextRunRenderingContext*>(renderingContext)->setActivePaintingResource(m_paintingResource); 387 390 #endif 388 391 389 return acquiredResource;392 return true; 390 393 } 391 394 … … 395 398 396 399 #if ENABLE(SVG_FONTS) 397 textRun.setActivePaintingResource(0); 400 TextRun::RenderingContext* renderingContext = textRun.renderingContext(); 401 if (renderingContext) 402 static_cast<SVGTextRunRenderingContext*>(renderingContext)->setActivePaintingResource(0); 403 #else 404 UNUSED_PARAM(textRun); 398 405 #endif 399 406 } … … 416 423 , m_dirOverride || style->visuallyOrdered() /* directionalOverride */); 417 424 418 #if ENABLE(SVG_FONTS) 419 run.setReferencingRenderObject(text); 420 #endif 425 if (textRunNeedsRenderingContext(style->font())) 426 run.setRenderingContext(SVGTextRunRenderingContext::create(text)); 421 427 422 428 // We handle letter & word spacing ourselves. … … 660 666 661 667 // Fast path if there is no selection, just draw the whole chunk part using the regular style 662 TextRun textRun (constructTextRun(style, fragment));668 TextRun textRun = constructTextRun(style, fragment); 663 669 if (!hasSelection || startPosition >= endPosition) { 664 670 paintTextWithShadows(context, style, textRun, fragment, 0, fragment.length); … … 674 680 SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, selectionStyle); 675 681 676 TextRun selectionTextRun (constructTextRun(selectionStyle, fragment));682 TextRun selectionTextRun = constructTextRun(selectionStyle, fragment); 677 683 paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition); 678 684 -
trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp
r76442 r87152 27 27 28 28 #if ENABLE(SVG_FONTS) 29 #include "SVGFontData.h" 29 30 #include "SVGFontElement.h" 31 #include "SVGFontFaceElement.h" 30 32 #endif 31 33 … … 41 43 { 42 44 #if ENABLE(SVG_FONTS) 43 if (!m_font.isSVGFont()) { 45 const SimpleFontData* fontData = m_font.primaryFont(); 46 if (!fontData->isSVGFont()) { 44 47 m_lastGlyph.isValid = false; 45 48 return 0; 46 49 } 47 50 48 SVGFontElement* svgFont = m_font.svgFont(); 49 ASSERT(svgFont); 51 ASSERT(fontData->isCustomFont()); 52 ASSERT(fontData->isSVGFont()); 53 54 const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->fontData()); 55 SVGFontFaceElement* svgFontFace = svgFontData->svgFontFaceElement(); 56 ASSERT(svgFontFace); 57 58 SVGFontElement* svgFont = svgFontFace->associatedFontElement(); 59 if (!svgFont) { 60 m_lastGlyph.isValid = false; 61 return 0; 62 } 50 63 51 64 float kerning = 0; -
trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp
r85143 r87152 24 24 25 25 #include "RenderSVGInlineText.h" 26 #include " TextRun.h"26 #include "SVGTextRunRenderingContext.h" 27 27 28 28 namespace WebCore { … … 87 87 , style->unicodeBidi() == Override /* directionalOverride */); 88 88 89 #if ENABLE(SVG_FONTS) 90 run.setReferencingRenderObject(text); 91 #endif 89 if (textRunNeedsRenderingContext(style->font())) 90 run.setRenderingContext(SVGTextRunRenderingContext::create(text)); 92 91 93 92 // We handle letter & word spacing ourselves. … … 99 98 { 100 99 ASSERT(text); 101 TextRun run(constructTextRun(text, text->characters(), position, length)); 102 return SVGTextMetrics(text, run, position, text->textLength()); 100 return SVGTextMetrics(text, constructTextRun(text, text->characters(), position, length), position, text->textLength()); 103 101 } 104 102 -
trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
r86823 r87152 1 1 /* 2 2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) Research In Motion Limited 2010 . All rights reserved.3 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 37 37 #include "SVGMissingGlyphElement.h" 38 38 #include "SVGNames.h" 39 #include "SVGTextRunRenderingContext.h" 39 40 #include "SimpleFontData.h" 40 #include "TextRun.h"41 41 #include "XMLNames.h" 42 42 … … 60 60 static inline const SVGFontData* svgFontAndFontFaceElementForFontData(const SimpleFontData* fontData, SVGFontFaceElement*& fontFace, SVGFontElement*& font) 61 61 { 62 ASSERT(fontData); 62 63 ASSERT(fontData->isCustomFont()); 63 64 ASSERT(fontData->isSVGFont()); 64 65 65 const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData-> svgFontData());66 const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->fontData()); 66 67 67 68 fontFace = svgFontData->svgFontFaceElement(); … … 70 71 font = fontFace->associatedFontElement(); 71 72 return svgFontData; 73 } 74 75 static inline RenderObject* firstParentRendererForNonTextNode(RenderObject* renderer) 76 { 77 ASSERT(renderer); 78 RenderObject* newRenderer = renderer->isText() ? renderer->parent() : renderer; 79 ASSERT(newRenderer->node()); 80 ASSERT(newRenderer->node()->isElementNode()); 81 return newRenderer; 82 } 83 84 static inline RenderObject* referencingRenderObjectFromRun(const TextRun& run) 85 { 86 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 87 return static_cast<SVGTextRunRenderingContext*>(renderingContext)->renderer(); 88 return 0; 89 } 90 91 static inline RenderSVGResource* activePaintingResourceFromRun(const TextRun& run) 92 { 93 if (TextRun::RenderingContext* renderingContext = run.renderingContext()) 94 return static_cast<SVGTextRunRenderingContext*>(renderingContext)->activePaintingResource(); 95 return 0; 72 96 } 73 97 … … 101 125 int endOfScanRange = to + m_walkerData.extraCharsAvailable; 102 126 127 RenderObject* renderObject = referencingRenderObjectFromRun(run); 128 RenderObject* parentRenderObject = firstParentRendererForNonTextNode(renderObject); 129 103 130 bool haveAltGlyph = false; 104 131 SVGGlyph altGlyphIdentifier; 105 if (RenderObject* renderObject = run.referencingRenderObject()) { 106 RenderObject* parentRenderer = renderObject->parent(); 107 ASSERT(parentRenderer); 108 if (parentRenderer->node() && parentRenderer->node()->hasTagName(SVGNames::altGlyphTag)) { 109 SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(parentRenderer->node())->glyphElement(); 110 if (glyphElement) { 111 haveAltGlyph = true; 112 altGlyphIdentifier = glyphElement->buildGlyphIdentifier(); 113 altGlyphIdentifier.isValid = true; 114 altGlyphIdentifier.unicodeStringLength = to - from; 115 } 132 Node* node = parentRenderObject->node(); 133 if (node->hasTagName(SVGNames::altGlyphTag)) { 134 if (SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(node)->glyphElement()) { 135 haveAltGlyph = true; 136 altGlyphIdentifier = glyphElement->buildGlyphIdentifier(); 137 altGlyphIdentifier.isValid = true; 138 altGlyphIdentifier.unicodeStringLength = to - from; 116 139 } 117 140 } … … 158 181 // Fallback to system font fallback 159 182 TextRun subRun(run); 183 subRun.setRenderingContext(0); 160 184 subRun.setText(subRun.data(i), 1); 161 185 … … 211 235 font.update(data.font->fontSelector()); 212 236 213 data.length += font.width(run); 214 } 215 216 217 SVGFontElement* Font::svgFont() const 218 { 219 if (!isSVGFont()) 220 return 0; 237 TextRun fallbackRun(run); 238 fallbackRun.setRenderingContext(0); 239 data.length += font.width(fallbackRun); 240 } 241 242 static float floatWidthOfSubStringUsingSVGFont(const Font& font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed, String& glyphName) 243 { 244 int newFrom = to > from ? from : to; 245 int newTo = to > from ? to : from; 246 247 from = newFrom; 248 to = newTo; 221 249 222 250 SVGFontElement* fontElement = 0; 223 251 SVGFontFaceElement* fontFaceElement = 0; 224 if (svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement)) 225 return fontElement; 226 227 return 0; 228 } 229 230 static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed, String& glyphName) 231 { 232 int newFrom = to > from ? from : to; 233 int newTo = to > from ? to : from; 234 235 from = newFrom; 236 to = newTo; 237 238 SVGFontElement* fontElement = 0; 239 SVGFontFaceElement* fontFaceElement = 0; 240 241 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(font->primaryFont(), fontFaceElement, fontElement)) { 252 253 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(font.primaryFont(), fontFaceElement, fontElement)) { 242 254 if (!fontElement) 243 255 return 0.0f; … … 245 257 SVGTextRunWalkerMeasuredLengthData data; 246 258 247 data.font = font;259 data.font = &font; 248 260 data.at = from; 249 261 data.from = from; … … 251 263 data.extraCharsAvailable = extraCharsAvailable; 252 264 data.charsConsumed = 0; 253 data.scale = convertEmUnitToPixel(font ->size(), fontFaceElement->unitsPerEm(), 1.0f);265 data.scale = convertEmUnitToPixel(font.size(), fontFaceElement->unitsPerEm(), 1.0f); 254 266 data.length = 0.0f; 255 267 256 String language; 257 bool isVerticalText = false; // Holds true for HTML text 258 259 // TODO: language matching & svg glyphs should be possible for HTML text, too. 260 if (RenderObject* renderObject = run.referencingRenderObject()) { 261 RenderObject* parentRenderer = renderObject->parent(); 262 ASSERT(parentRenderer); 263 isVerticalText = isVerticalWritingMode(parentRenderer->style()->svgStyle()); 264 265 if (SVGElement* element = static_cast<SVGElement*>(parentRenderer->node())) 266 language = element->getAttribute(XMLNames::langAttr); 267 } 268 RenderObject* renderObject = referencingRenderObjectFromRun(run); 269 RenderObject* parentRenderObject = firstParentRendererForNonTextNode(renderObject); 270 271 String language = toElement(parentRenderObject->node())->getAttribute(XMLNames::langAttr); 272 bool isVerticalText = isVerticalWritingMode(parentRenderObject->style()->svgStyle()); 268 273 269 274 SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback); … … 277 282 } 278 283 279 float Font::floatWidthUsingSVGFont(const TextRun& run) const284 float SVGTextRunRenderingContext::floatWidthUsingSVGFont(const Font& font, const TextRun& run) const 280 285 { 281 286 int charsConsumed; 282 287 String glyphName; 283 return floatWidthOfSubStringUsingSVGFont( this, run, 0, 0, run.length(), charsConsumed, glyphName);284 } 285 286 float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const287 { 288 return floatWidthOfSubStringUsingSVGFont( this, run, extraCharsAvailable, 0, run.length(), charsConsumed, glyphName);288 return floatWidthOfSubStringUsingSVGFont(font, run, 0, 0, run.length(), charsConsumed, glyphName); 289 } 290 291 float SVGTextRunRenderingContext::floatWidthUsingSVGFont(const Font& font, const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const 292 { 293 return floatWidthOfSubStringUsingSVGFont(font, run, extraCharsAvailable, 0, run.length(), charsConsumed, glyphName); 289 294 } 290 295 … … 311 316 } 312 317 313 void Font::drawTextUsingSVGFont(GraphicsContext* context, const TextRun& run, 314 const FloatPoint& point, int from, int to) const 318 void SVGTextRunRenderingContext::drawTextUsingSVGFont(const Font& font, GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const 315 319 { 316 320 SVGFontElement* fontElement = 0; 317 321 SVGFontFaceElement* fontFaceElement = 0; 318 322 319 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData( primaryFont(), fontFaceElement, fontElement)) {323 if (const SVGFontData* fontData = svgFontAndFontFaceElementForFontData(font.primaryFont(), fontFaceElement, fontElement)) { 320 324 if (!fontElement) 321 325 return; … … 323 327 SVGTextRunWalkerDrawTextData data; 324 328 FloatPoint currentPoint = point; 325 float scale = convertEmUnitToPixel(size(), fontFaceElement->unitsPerEm(), 1.0f); 326 327 RenderSVGResource* activePaintingResource = run.activePaintingResource(); 328 329 // If renderObject is not set, we're dealing for HTML text rendered using SVG Fonts. 330 if (!run.referencingRenderObject()) { 331 ASSERT(!activePaintingResource); 332 329 float scale = convertEmUnitToPixel(font.size(), fontFaceElement->unitsPerEm(), 1.0f); 330 331 // We can only paint SVGFonts if a context is available. 332 RenderObject* renderObject = referencingRenderObjectFromRun(run); 333 RenderObject* parentRenderObject = firstParentRendererForNonTextNode(renderObject); 334 335 // If activePaintingResource is not set, we're dealing for HTML text rendered using SVG Fonts. 336 RenderSVGResource* activePaintingResource = activePaintingResourceFromRun(run); 337 if (!activePaintingResource) { 333 338 // TODO: We're only supporting simple filled HTML text so far. 334 339 RenderSVGResourceSolidColor* solidPaintingResource = RenderSVGResource::sharedSolidPaintingResource(); … … 338 343 } 339 344 340 ASSERT(activePaintingResource);341 342 345 int charsConsumed; 343 346 String glyphName; 344 bool isVerticalText = false; 345 float xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName); 347 float xStartOffset = floatWidthOfSubStringUsingSVGFont(font, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName); 346 348 FloatPoint glyphOrigin; 347 349 348 String language; 349 350 // TODO: language matching & svg glyphs should be possible for HTML text, too. 351 RenderObject* referencingRenderObject = run.referencingRenderObject(); 352 RenderObject* referencingRenderObjectParent = referencingRenderObject ? referencingRenderObject->parent() : 0; 353 RenderStyle* referencingRenderObjectParentStyle = 0; 354 if (referencingRenderObject) { 355 ASSERT(referencingRenderObjectParent); 356 referencingRenderObjectParentStyle = referencingRenderObjectParent->style(); 357 358 isVerticalText = isVerticalWritingMode(referencingRenderObjectParentStyle->svgStyle()); 359 if (SVGElement* element = static_cast<SVGElement*>(referencingRenderObjectParent->node())) 360 language = element->getAttribute(XMLNames::langAttr); 361 } 362 350 Node* node = parentRenderObject->node(); 351 String language = toElement(node)->getAttribute(XMLNames::langAttr); 352 353 RenderStyle* parentRenderObjectStyle = parentRenderObject->style(); 354 bool isVerticalText = isVerticalWritingMode(parentRenderObjectStyle->svgStyle()); 363 355 if (!isVerticalText) { 364 356 glyphOrigin.setX(fontData->horizontalOriginX() * scale); … … 395 387 glyphPath.transform(glyphPathTransform); 396 388 397 if (activePaintingResource->applyResource( referencingRenderObjectParent, referencingRenderObjectParentStyle, context, resourceMode)) {398 if (re ferencingRenderObject) {399 RenderSVGInlineText* textRenderer = toRenderSVGInlineText(referencingRenderObject);389 if (activePaintingResource->applyResource(parentRenderObject, parentRenderObjectStyle, context, resourceMode)) { 390 if (renderObject && renderObject->isSVGInlineText()) { 391 const RenderSVGInlineText* textRenderer = toRenderSVGInlineText(renderObject); 400 392 context->setStrokeThickness(context->strokeThickness() * textRenderer->scalingFactor()); 401 393 } 402 activePaintingResource->postApplyResource( referencingRenderObjectParent, context, resourceMode, &glyphPath);394 activePaintingResource->postApplyResource(parentRenderObject, context, resourceMode, &glyphPath); 403 395 } 404 396 } … … 410 402 } else { 411 403 // Handle system font fallback 412 FontDescription fontDescription( m_fontDescription);404 FontDescription fontDescription(font.fontDescription()); 413 405 fontDescription.setFamily(FontFamily()); 414 406 Font font(fontDescription, 0, 0); // spacing handled by SVG text code. 415 font.update(font Selector());407 font.update(font.fontSelector()); 416 408 417 409 TextRun fallbackCharacterRun(run); 410 fallbackCharacterRun.setRenderingContext(0); 418 411 fallbackCharacterRun.setText(&data.fallbackCharacters[run.rtl() ? data.fallbackCharacters.size() - fallbackCharacterIndex - 1 : fallbackCharacterIndex], 1); 419 412 font.drawText(context, fallbackCharacterRun, currentPoint); … … 430 423 } 431 424 432 FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const FloatPoint& point, int height, int from, int to) const425 FloatRect SVGTextRunRenderingContext::selectionRectForTextUsingSVGFont(const Font& font, const TextRun& run, const FloatPoint& point, int height, int from, int to) const 433 426 { 434 427 int charsConsumed; 435 428 String glyphName; 436 429 437 return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont( this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName),438 point.y(), floatWidthOfSubStringUsingSVGFont( this, run, 0, from, to, charsConsumed, glyphName), height);439 } 440 441 int Font::offsetForPositionForTextUsingSVGFont(const TextRun&, float, bool) const430 return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(font, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName), 431 point.y(), floatWidthOfSubStringUsingSVGFont(font, run, 0, from, to, charsConsumed, glyphName), height); 432 } 433 434 int SVGTextRunRenderingContext::offsetForPositionForTextUsingSVGFont(const Font&, const TextRun&, float, bool) const 442 435 { 443 436 // TODO: Fix text selection when HTML text is drawn using a SVG Font -
trunk/Source/WebCore/svg/SVGAllInOne.cpp
r84522 r87152 78 78 #include "SVGFilterPrimitiveStandardAttributes.cpp" 79 79 #include "SVGFitToViewBox.cpp" 80 #include "SVGFont.cpp"81 80 #include "SVGFontData.cpp" 82 81 #include "SVGFontElement.cpp" -
trunk/Source/WebCore/svg/SVGFontData.cpp
r66397 r87152 23 23 #include "SVGFontData.h" 24 24 25 #include "SVGFontElement.h" 26 #include "SVGGlyph.h" 27 25 28 namespace WebCore { 26 29 … … 37 40 } 38 41 42 void SVGFontData::initializeFontData(SimpleFontData* fontData, int size) 43 { 44 ASSERT(fontData); 45 46 SVGFontFaceElement* svgFontFaceElement = this->svgFontFaceElement(); 47 unsigned unitsPerEm = svgFontFaceElement->unitsPerEm(); 48 49 float scale = size; 50 if (unitsPerEm) 51 scale /= unitsPerEm; 52 53 float xHeight = svgFontFaceElement->xHeight() * scale; 54 float ascent = svgFontFaceElement->ascent() * scale; 55 float descent = svgFontFaceElement->descent() * scale; 56 float lineGap = 0.1f * size; 57 58 SVGFontElement* associatedFontElement = svgFontFaceElement->associatedFontElement(); 59 if (!xHeight) { 60 // Fallback if x_heightAttr is not specified for the font element. 61 Vector<SVGGlyph> letterXGlyphs; 62 associatedFontElement->getGlyphIdentifiersForString(String("x", 1), letterXGlyphs); 63 xHeight = letterXGlyphs.isEmpty() ? 2 * ascent / 3 : letterXGlyphs.first().horizontalAdvanceX * scale; 64 } 65 66 FontMetrics& fontMetrics = fontData->fontMetrics(); 67 fontMetrics.setUnitsPerEm(unitsPerEm); 68 fontMetrics.setAscent(ascent); 69 fontMetrics.setDescent(descent); 70 fontMetrics.setLineGap(lineGap); 71 fontMetrics.setLineSpacing(roundf(ascent) + roundf(descent) + roundf(lineGap)); 72 fontMetrics.setXHeight(xHeight); 73 74 Vector<SVGGlyph> spaceGlyphs; 75 associatedFontElement->getGlyphIdentifiersForString(String(" ", 1), spaceGlyphs); 76 fontData->setSpaceWidth(spaceGlyphs.isEmpty() ? xHeight : spaceGlyphs.first().horizontalAdvanceX * scale); 77 78 Vector<SVGGlyph> numeralZeroGlyphs; 79 associatedFontElement->getGlyphIdentifiersForString(String("0", 1), numeralZeroGlyphs); 80 fontData->setAvgCharWidth(numeralZeroGlyphs.isEmpty() ? fontData->spaceWidth() : numeralZeroGlyphs.first().horizontalAdvanceX * scale); 81 82 Vector<SVGGlyph> letterWGlyphs; 83 associatedFontElement->getGlyphIdentifiersForString(String("W", 1), letterWGlyphs); 84 fontData->setMaxCharWidth(letterWGlyphs.isEmpty() ? ascent : letterWGlyphs.first().horizontalAdvanceX * scale); 85 86 // FIXME: is there a way we can get the space glyph from the SVGGlyph above? 87 fontData->setSpaceGlyph(0); 88 fontData->setZeroWidthSpaceGlyph(0); 89 fontData->determinePitch(); 90 91 GlyphData missingGlyphData; 92 missingGlyphData.fontData = fontData; 93 missingGlyphData.glyph = 0; 94 fontData->setMissingGlyphData(missingGlyphData); 95 } 96 39 97 } // namespace WebCore 40 98 -
trunk/Source/WebCore/svg/SVGFontData.h
r76248 r87152 22 22 23 23 #if ENABLE(SVG_FONTS) 24 #include "SimpleFontData.h" 24 25 #include "SVGFontFaceElement.h" 25 26 26 27 namespace WebCore { 27 28 28 class SVGFontData { 29 WTF_MAKE_NONCOPYABLE(SVGFontData); WTF_MAKE_FAST_ALLOCATED; 29 class SVGFontData : public SimpleFontData::FontData { 30 30 public: 31 SVGFontData(SVGFontFaceElement*); 31 static PassOwnPtr<SVGFontData> create(SVGFontFaceElement* element) 32 { 33 return adoptPtr(new SVGFontData(element)); 34 } 35 32 36 virtual ~SVGFontData() { } 37 38 virtual bool isSVGFontData() const { return true; } 39 virtual void initializeFontData(SimpleFontData*, int size); 33 40 34 41 SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; } … … 43 50 44 51 private: 52 SVGFontData(SVGFontFaceElement*); 53 45 54 // Ths SVGFontFaceElement is kept alive -- 46 55 // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document -
trunk/Source/WebCore/svg/SVGGlyphElement.cpp
r86050 r87152 31 31 #include "SVGNames.h" 32 32 #include "SVGPathParserFactory.h" 33 #include "SimpleFontData.h"34 #include "XMLNames.h"35 33 36 34 namespace WebCore { 37 38 using namespace SVGNames;39 35 40 36 inline SVGGlyphElement::SVGGlyphElement(const QualifiedName& tagName, Document* document) 41 37 : SVGStyledElement(tagName, document) 42 38 { 43 ASSERT(hasTagName( glyphTag));39 ASSERT(hasTagName(SVGNames::glyphTag)); 44 40 } 45 41 … … 151 147 { 152 148 SVGGlyph identifier; 153 identifier.pathData = parsePathData(element->getAttribute( dAttr));149 identifier.pathData = parsePathData(element->getAttribute(SVGNames::dAttr)); 154 150 155 151 // Spec: The horizontal advance after rendering the glyph in horizontal orientation. … … 157 153 // value of the font's horiz-adv-x attribute. Glyph widths are required to be non-negative, 158 154 // even if the glyph is typically rendered right-to-left, as in Hebrew and Arabic scripts. 159 identifier.horizontalAdvanceX = parseSVGGlyphAttribute(element, horiz_adv_xAttr);155 identifier.horizontalAdvanceX = parseSVGGlyphAttribute(element, SVGNames::horiz_adv_xAttr); 160 156 161 157 // Spec: The X-coordinate in the font coordinate system of the origin of the glyph to be 162 158 // used when drawing vertically oriented text. If the attribute is not specified, the effect 163 159 // is as if the attribute were set to the value of the font's vert-origin-x attribute. 164 identifier.verticalOriginX = parseSVGGlyphAttribute(element, vert_origin_xAttr);160 identifier.verticalOriginX = parseSVGGlyphAttribute(element, SVGNames::vert_origin_xAttr); 165 161 166 162 // Spec: The Y-coordinate in the font coordinate system of the origin of a glyph to be 167 163 // used when drawing vertically oriented text. If the attribute is not specified, the effect 168 164 // is as if the attribute were set to the value of the font's vert-origin-y attribute. 169 identifier.verticalOriginY = parseSVGGlyphAttribute(element, vert_origin_yAttr);165 identifier.verticalOriginY = parseSVGGlyphAttribute(element, SVGNames::vert_origin_yAttr); 170 166 171 167 // Spec: The vertical advance after rendering a glyph in vertical orientation. 172 168 // If the attribute is not specified, the effect is as if the attribute were set to the 173 169 // value of the font's vert-adv-y attribute. 174 identifier.verticalAdvanceY = parseSVGGlyphAttribute(element, vert_adv_yAttr);170 identifier.verticalAdvanceY = parseSVGGlyphAttribute(element, SVGNames::vert_adv_yAttr); 175 171 176 172 return identifier; … … 180 176 { 181 177 SVGGlyph identifier(buildGenericGlyphIdentifier(this)); 182 identifier.glyphName = getAttribute( glyph_nameAttr);183 identifier.orientation = parseOrientation(getAttribute( orientationAttr));184 identifier.arabicForm = parseArabicForm(getAttribute( arabic_formAttr));178 identifier.glyphName = getAttribute(SVGNames::glyph_nameAttr); 179 identifier.orientation = parseOrientation(getAttribute(SVGNames::orientationAttr)); 180 identifier.arabicForm = parseArabicForm(getAttribute(SVGNames::arabic_formAttr)); 185 181 186 182 String language = getAttribute(SVGNames::langAttr); -
trunk/Source/WebCore/svg/SVGHKernElement.cpp
r86050 r87152 25 25 #include "SVGHKernElement.h" 26 26 27 #include "SVGFontData.h"28 27 #include "SVGFontElement.h" 29 28 #include "SVGFontFaceElement.h" 30 29 #include "SVGNames.h" 31 #include "SimpleFontData.h"32 #include "XMLNames.h"33 30 34 31 namespace WebCore { 35 36 using namespace SVGNames;37 32 38 33 inline SVGHKernElement::SVGHKernElement(const QualifiedName& tagName, Document* document) 39 34 : SVGElement(tagName, document) 40 35 { 41 ASSERT(hasTagName( hkernTag));36 ASSERT(hasTagName(SVGNames::hkernTag)); 42 37 } 43 38 … … 69 64 void SVGHKernElement::buildHorizontalKerningPair(KerningPairVector& kerningPairs) 70 65 { 71 String u1 = getAttribute( u1Attr);72 String g1 = getAttribute( g1Attr);73 String u2 = getAttribute( u2Attr);74 String g2 = getAttribute( g2Attr);66 String u1 = getAttribute(SVGNames::u1Attr); 67 String g1 = getAttribute(SVGNames::g1Attr); 68 String u2 = getAttribute(SVGNames::u2Attr); 69 String g2 = getAttribute(SVGNames::g2Attr); 75 70 if ((u1.isEmpty() && g1.isEmpty()) || (u2.isEmpty() && g2.isEmpty())) 76 71 return; … … 81 76 && parseKerningUnicodeString(u1, kerningPair.unicodeRange1, kerningPair.unicodeName1) 82 77 && parseKerningUnicodeString(u2, kerningPair.unicodeRange2, kerningPair.unicodeName2)) { 83 kerningPair.kerning = getAttribute( kAttr).string().toFloat();78 kerningPair.kerning = getAttribute(SVGNames::kAttr).string().toFloat(); 84 79 kerningPairs.append(kerningPair); 85 80 } -
trunk/Source/WebCore/svg/SVGVKernElement.cpp
r86050 r87152 23 23 #include "SVGVKernElement.h" 24 24 25 #include "SVGFontData.h"26 25 #include "SVGFontElement.h" 27 26 #include "SVGFontFaceElement.h" 28 27 #include "SVGNames.h" 29 #include "SimpleFontData.h"30 #include "XMLNames.h"31 28 32 29 namespace WebCore { 33 34 using namespace SVGNames;35 30 36 31 inline SVGVKernElement::SVGVKernElement(const QualifiedName& tagName, Document* document) 37 32 : SVGElement(tagName, document) 38 33 { 39 ASSERT(hasTagName( vkernTag));34 ASSERT(hasTagName(SVGNames::vkernTag)); 40 35 } 41 36 … … 67 62 void SVGVKernElement::buildVerticalKerningPair(KerningPairVector& kerningPairs) 68 63 { 69 String u1 = getAttribute( u1Attr);70 String g1 = getAttribute( g1Attr);71 String u2 = getAttribute( u2Attr);72 String g2 = getAttribute( g2Attr);64 String u1 = getAttribute(SVGNames::u1Attr); 65 String g1 = getAttribute(SVGNames::g1Attr); 66 String u2 = getAttribute(SVGNames::u2Attr); 67 String g2 = getAttribute(SVGNames::g2Attr); 73 68 if ((u1.isEmpty() && g1.isEmpty()) || (u2.isEmpty() && g2.isEmpty())) 74 69 return; … … 79 74 && parseKerningUnicodeString(u1, kerningPair.unicodeRange1, kerningPair.unicodeName1) 80 75 && parseKerningUnicodeString(u2, kerningPair.unicodeRange2, kerningPair.unicodeName2)) { 81 kerningPair.kerning = getAttribute( kAttr).string().toFloat();76 kerningPair.kerning = getAttribute(SVGNames::kAttr).string().toFloat(); 82 77 kerningPairs.append(kerningPair); 83 78 } -
trunk/Source/WebCore/svg/SVGVKernElement.h
r87125 r87152 31 31 namespace WebCore { 32 32 33 class SVGFontData;34 35 33 class SVGVKernElement : public SVGElement { 36 34 public:
Note: See TracChangeset
for help on using the changeset viewer.