| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 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 SVGTextLayoutAttributesBuilder_h | 20 #ifndef SVGTextLayoutAttributesBuilder_h |
| 21 #define SVGTextLayoutAttributesBuilder_h | 21 #define SVGTextLayoutAttributesBuilder_h |
| 22 | 22 |
| 23 #include "core/layout/svg/SVGTextLayoutAttributes.h" | 23 #include "core/layout/svg/SVGTextLayoutAttributes.h" |
| 24 #include "platform/heap/Handle.h" | 24 #include "platform/heap/Handle.h" |
| 25 #include "wtf/Allocator.h" | 25 #include "wtf/Allocator.h" |
| 26 #include "wtf/Vector.h" | 26 #include "wtf/Vector.h" |
| 27 #include "wtf/text/Unicode.h" | |
| 28 | 27 |
| 29 namespace blink { | 28 namespace blink { |
| 30 | 29 |
| 31 class LayoutBoxModelObject; | 30 class LayoutBoxModelObject; |
| 32 class LayoutSVGInlineText; | |
| 33 class LayoutSVGText; | 31 class LayoutSVGText; |
| 34 class SVGTextPositioningElement; | 32 class SVGTextPositioningElement; |
| 35 | 33 |
| 36 // SVGTextLayoutAttributesBuilder performs the first layout phase for SVG text. | 34 // SVGTextLayoutAttributesBuilder performs the first layout phase for SVG text. |
| 37 // | 35 // |
| 38 // It extracts the x/y/dx/dy/rotate values from the SVGTextPositioningElements i
n the DOM. | 36 // It extracts the x/y/dx/dy/rotate values from the SVGTextPositioningElements i
n the DOM. |
| 39 // These values are propagated to the corresponding LayoutSVGInlineText layoutOb
jects. | 37 // These values are propagated to the corresponding LayoutSVGInlineText layoutOb
jects. |
| 40 // The first layout phase only extracts the relevant information needed in Layou
tBlockFlowLine | 38 // The first layout phase only extracts the relevant information needed in Layou
tBlockFlowLine |
| 41 // to create the InlineBox tree based on text chunk boundaries & BiDi informatio
n. | 39 // to create the InlineBox tree based on text chunk boundaries & BiDi informatio
n. |
| 42 // The second layout phase is carried out by SVGTextLayoutEngine. | 40 // The second layout phase is carried out by SVGTextLayoutEngine. |
| 43 | |
| 44 class SVGTextLayoutAttributesBuilder { | 41 class SVGTextLayoutAttributesBuilder { |
| 45 DISALLOW_NEW(); | 42 STACK_ALLOCATED(); |
| 46 WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder); | 43 WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder); |
| 47 public: | 44 public: |
| 48 SVGTextLayoutAttributesBuilder(); | 45 explicit SVGTextLayoutAttributesBuilder(LayoutSVGText&); |
| 49 | 46 |
| 50 void buildLayoutAttributesForTextRoot(LayoutSVGText&); | 47 void buildLayoutAttributes(); |
| 51 | |
| 52 // Invoked whenever the underlying DOM tree changes, so that m_textPositions
is rebuild. | |
| 53 void clearTextPositioningElements() { m_textPositions.clear(); } | |
| 54 unsigned numberOfTextPositioningElements() const { return m_textPositions.si
ze(); } | |
| 55 | 48 |
| 56 struct TextPosition { | 49 struct TextPosition { |
| 57 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 50 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 58 public: | 51 public: |
| 59 TextPosition(SVGTextPositioningElement* newElement = nullptr, unsigned n
ewStart = 0, unsigned newLength = 0) | 52 TextPosition(SVGTextPositioningElement* newElement = nullptr, unsigned n
ewStart = 0, unsigned newLength = 0) |
| 60 : element(newElement) | 53 : element(newElement) |
| 61 , start(newStart) | 54 , start(newStart) |
| 62 , length(newLength) | 55 , length(newLength) |
| 63 { | 56 { |
| 64 } | 57 } |
| 65 | 58 |
| 66 DECLARE_TRACE(); | 59 DECLARE_TRACE(); |
| 67 | 60 |
| 68 Member<SVGTextPositioningElement> element; | 61 Member<SVGTextPositioningElement> element; |
| 69 unsigned start; | 62 unsigned start; |
| 70 unsigned length; | 63 unsigned length; |
| 71 }; | 64 }; |
| 72 | 65 |
| 73 private: | 66 private: |
| 74 void buildCharacterDataMap(LayoutSVGText&); | 67 void buildCharacterDataMap(LayoutSVGText&); |
| 75 void buildLayoutAttributes(LayoutSVGText&) const; | 68 void buildLayoutAttributes(LayoutSVGText&) const; |
| 76 void collectTextPositioningElements(LayoutBoxModelObject&); | 69 void collectTextPositioningElements(LayoutBoxModelObject&); |
| 77 void fillCharacterDataMap(const TextPosition&); | 70 void fillCharacterDataMap(const TextPosition&); |
| 78 | 71 |
| 79 private: | 72 LayoutSVGText& m_textRoot; |
| 80 unsigned m_characterCount; | 73 unsigned m_characterCount; |
| 81 PersistentHeapVector<TextPosition> m_textPositions; | 74 HeapVector<TextPosition> m_textPositions; |
| 82 SVGCharacterDataMap m_characterDataMap; | 75 SVGCharacterDataMap m_characterDataMap; |
| 83 }; | 76 }; |
| 84 | 77 |
| 85 } // namespace blink | 78 } // namespace blink |
| 86 | 79 |
| 87 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::SVGTextLayoutAttributesBuilder
::TextPosition); | 80 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::SVGTextLayoutAttributesBuilder
::TextPosition); |
| 88 | 81 |
| 89 #endif | 82 #endif |
| OLD | NEW |