Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2186)

Side by Side Diff: Source/core/layout/svg/SVGTextChunkBuilder.h

Issue 1155293005: Perform SVG text chunk processing on-the-fly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef SVGTextChunkBuilder_h 20 #ifndef SVGTextChunkBuilder_h
21 #define SVGTextChunkBuilder_h 21 #define SVGTextChunkBuilder_h
22 22
23 #include "core/layout/svg/SVGTextChunk.h"
24 #include "platform/transforms/AffineTransform.h" 23 #include "platform/transforms/AffineTransform.h"
25 #include "wtf/HashMap.h" 24 #include "wtf/HashMap.h"
26 #include "wtf/Vector.h" 25 #include "wtf/Vector.h"
27 26
28 namespace blink { 27 namespace blink {
29 28
30 class SVGInlineTextBox; 29 class SVGInlineTextBox;
31 struct SVGTextFragment; 30 struct SVGTextFragment;
32 31
33 // SVGTextChunkBuilder performs the third layout phase for SVG text. 32 // SVGTextChunkBuilder performs the third layout phase for SVG text.
34 // 33 //
35 // Phase one built the layout information from the SVG DOM stored in the LayoutS VGInlineText objects (SVGTextLayoutAttributes). 34 // Phase one built the layout information from the SVG DOM stored in the LayoutS VGInlineText objects (SVGTextLayoutAttributes).
36 // Phase two performed the actual per-character layout, computing the final posi tions for each character, stored in the SVGInlineTextBox objects (SVGTextFragmen t). 35 // Phase two performed the actual per-character layout, computing the final posi tions for each character, stored in the SVGInlineTextBox objects (SVGTextFragmen t).
37 // Phase three performs all modifications that have to be applied to each indivi dual text chunk (text-anchor & textLength). 36 // Phase three performs all modifications that have to be applied to each indivi dual text chunk (text-anchor & textLength).
38 37
39 class SVGTextChunkBuilder { 38 class SVGTextChunkBuilder {
40 WTF_MAKE_NONCOPYABLE(SVGTextChunkBuilder); 39 WTF_MAKE_NONCOPYABLE(SVGTextChunkBuilder);
41 public: 40 public:
42 SVGTextChunkBuilder(); 41 SVGTextChunkBuilder();
43 42
44 const Vector<SVGTextChunk>& textChunks() const { return m_textChunks; }
45 void processTextChunks(const Vector<SVGInlineTextBox*>&); 43 void processTextChunks(const Vector<SVGInlineTextBox*>&);
46 void finalizeTransformMatrices(const Vector<SVGInlineTextBox*>&) const; 44 void finalizeTransformMatrices(const Vector<SVGInlineTextBox*>&) const;
47 45
48 void buildTextChunks(Vector<SVGInlineTextBox*>& lineLayoutBoxes); 46 protected:
49 void layoutTextChunks(Vector<SVGInlineTextBox*>& lineLayoutBoxes); 47 virtual void handleTextChunk(const Vector<SVGInlineTextBox*>&, unsigned boxS tart, unsigned boxEnd);
f(malita) 2015/05/27 15:19:13 The first thing both impls do is create a chunk ba
fs 2015/05/27 15:28:07 I should probably have mentioned this somewhere, b
50 48
51 private: 49 private:
52 void addTextChunk(Vector<SVGInlineTextBox*>& lineLayoutBoxes, unsigned boxPo sition, unsigned boxCount);
53 void processTextChunk(const SVGTextChunk&);
54
55 void processTextLengthSpacingCorrection(bool isVerticalText, float textLengt hShift, Vector<SVGTextFragment>&, unsigned& atCharacter); 50 void processTextLengthSpacingCorrection(bool isVerticalText, float textLengt hShift, Vector<SVGTextFragment>&, unsigned& atCharacter);
56 void processTextAnchorCorrection(bool isVerticalText, float textAnchorShift, Vector<SVGTextFragment>&); 51 void processTextAnchorCorrection(bool isVerticalText, float textAnchorShift, Vector<SVGTextFragment>&);
57 52
53 HashMap<SVGInlineTextBox*, AffineTransform> m_textBoxTransformations;
54 };
55
56 class SVGTextPathChunkBuilder final : public SVGTextChunkBuilder {
57 WTF_MAKE_NONCOPYABLE(SVGTextPathChunkBuilder);
58 public:
59 SVGTextPathChunkBuilder();
60
61 float totalLength() const { return m_totalLength; }
62 unsigned totalCharacters() const { return m_totalCharacters; }
63 float totalTextAnchorShift() const { return m_totalTextAnchorShift; }
64
58 private: 65 private:
59 Vector<SVGTextChunk> m_textChunks; 66 void handleTextChunk(const Vector<SVGInlineTextBox*>&, unsigned boxStart, un signed boxEnd) override;
60 HashMap<SVGInlineTextBox*, AffineTransform> m_textBoxTransformations; 67
68 float m_totalLength;
69 unsigned m_totalCharacters;
70 float m_totalTextAnchorShift;
61 }; 71 };
62 72
63 } // namespace blink 73 } // namespace blink
64 74
65 #endif 75 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/layout/svg/SVGTextChunkBuilder.cpp » ('j') | Source/core/layout/svg/SVGTextChunkBuilder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698