OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. | 2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 */ | 28 */ |
29 | 29 |
30 #ifndef VTTCue_h | 30 #ifndef VTTCue_h |
31 #define VTTCue_h | 31 #define VTTCue_h |
32 | 32 |
33 #include "bindings/v8/ScriptWrappable.h" | 33 #include "bindings/v8/ScriptWrappable.h" |
34 #include "core/html/track/TextTrackCue.h" | 34 #include "core/html/track/TextTrackCue.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
| 38 class Document; |
| 39 class ExecutionContext; |
| 40 class VTTCue; |
| 41 |
| 42 // ---------------------------- |
| 43 |
| 44 class VTTCueBox FINAL : public TextTrackCueBox { |
| 45 public: |
| 46 static PassRefPtr<VTTCueBox> create(Document& document, VTTCue* cue) |
| 47 { |
| 48 return adoptRef(new VTTCueBox(document, cue)); |
| 49 } |
| 50 |
| 51 VTTCue* getCue() const { return m_cue; } |
| 52 void applyCSSProperties(const IntSize& videoSize); |
| 53 |
| 54 protected: |
| 55 VTTCueBox(Document&, VTTCue*); |
| 56 |
| 57 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; |
| 58 |
| 59 VTTCue* m_cue; |
| 60 }; |
| 61 |
| 62 // ---------------------------- |
| 63 |
38 class VTTCue FINAL : public TextTrackCue, public ScriptWrappable { | 64 class VTTCue FINAL : public TextTrackCue, public ScriptWrappable { |
39 public: | 65 public: |
40 static PassRefPtr<VTTCue> create(Document&, double startTime, double endTime
, const String& text); | 66 static PassRefPtr<VTTCue> create(Document& document, double startTime, doubl
e endTime, const String& text) |
| 67 { |
| 68 return adoptRef(new VTTCue(document, startTime, endTime, text)); |
| 69 } |
| 70 |
| 71 virtual ~VTTCue(); |
| 72 |
| 73 virtual bool isVTTCue() const OVERRIDE { return true; } |
| 74 |
| 75 const String& vertical() const; |
| 76 void setVertical(const String&, ExceptionState&); |
| 77 |
| 78 bool snapToLines() const { return m_snapToLines; } |
| 79 void setSnapToLines(bool); |
| 80 |
| 81 int line() const { return m_linePosition; } |
| 82 void setLine(int, ExceptionState&); |
| 83 |
| 84 int position() const { return m_textPosition; } |
| 85 void setPosition(int, ExceptionState&); |
| 86 |
| 87 int size() const { return m_cueSize; } |
| 88 void setSize(int, ExceptionState&); |
| 89 |
| 90 const String& align() const; |
| 91 void setAlign(const String&, ExceptionState&); |
| 92 |
| 93 const String& text() const { return m_text; } |
| 94 void setText(const String&); |
| 95 |
| 96 void parseSettings(const String&); |
| 97 |
| 98 PassRefPtr<DocumentFragment> getCueAsHTML(); |
| 99 PassRefPtr<DocumentFragment> createCueRenderingTree(); |
| 100 |
| 101 const String& regionId() const { return m_regionId; } |
| 102 void setRegionId(const String&); |
| 103 virtual void notifyRegionWhenRemovingDisplayTree(bool) OVERRIDE; |
| 104 |
| 105 virtual bool hasDisplayTree() const OVERRIDE { return m_displayTree; } |
| 106 virtual PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize)
OVERRIDE; |
| 107 virtual PassRefPtr<HTMLDivElement> element() const OVERRIDE { return m_cueBa
ckgroundBox; } |
| 108 |
| 109 virtual void updateDisplayTree(double) OVERRIDE; |
| 110 virtual void removeDisplayTree() OVERRIDE; |
| 111 void markFutureAndPastNodes(ContainerNode*, double, double); |
| 112 |
| 113 int calculateComputedLinePosition(); |
| 114 |
| 115 std::pair<double, double> getCSSPosition() const; |
| 116 |
| 117 CSSValueID getCSSAlignment() const; |
| 118 int getCSSSize() const; |
| 119 CSSValueID getCSSWritingDirection() const; |
| 120 CSSValueID getCSSWritingMode() const; |
| 121 |
| 122 enum WritingDirection { |
| 123 Horizontal = 0, |
| 124 VerticalGrowingLeft, |
| 125 VerticalGrowingRight, |
| 126 NumberOfWritingDirections |
| 127 }; |
| 128 WritingDirection getWritingDirection() const { return m_writingDirection; } |
| 129 |
| 130 enum CueAlignment { |
| 131 Start = 0, |
| 132 Middle, |
| 133 End, |
| 134 Left, |
| 135 Right, |
| 136 NumberOfAlignments |
| 137 }; |
| 138 CueAlignment getAlignment() const { return m_cueAlignment; } |
| 139 |
| 140 virtual ExecutionContext* executionContext() const OVERRIDE; |
41 | 141 |
42 private: | 142 private: |
43 VTTCue(Document&, double startTime, double endTime, const String& text); | 143 VTTCue(Document&, double startTime, double endTime, const String& text); |
| 144 |
| 145 Document& document() const; |
| 146 |
| 147 PassRefPtr<VTTCueBox> displayTreeInternal(); |
| 148 |
| 149 virtual void cueDidChange() OVERRIDE; |
| 150 |
| 151 void createVTTNodeTree(); |
| 152 void copyVTTNodeToDOMTree(ContainerNode* VTTNode, ContainerNode* root); |
| 153 |
| 154 std::pair<double, double> getPositionCoordinates() const; |
| 155 |
| 156 void determineTextDirection(); |
| 157 void calculateDisplayParameters(); |
| 158 |
| 159 enum CueSetting { |
| 160 None, |
| 161 Vertical, |
| 162 Line, |
| 163 Position, |
| 164 Size, |
| 165 Align, |
| 166 RegionId |
| 167 }; |
| 168 CueSetting settingName(const String&); |
| 169 |
| 170 String m_text; |
| 171 int m_linePosition; |
| 172 int m_computedLinePosition; |
| 173 int m_textPosition; |
| 174 int m_cueSize; |
| 175 WritingDirection m_writingDirection; |
| 176 |
| 177 CueAlignment m_cueAlignment; |
| 178 |
| 179 RefPtr<DocumentFragment> m_webVTTNodeTree; |
| 180 bool m_snapToLines; |
| 181 |
| 182 RefPtr<HTMLDivElement> m_cueBackgroundBox; |
| 183 |
| 184 bool m_displayTreeShouldChange; |
| 185 RefPtr<VTTCueBox> m_displayTree; |
| 186 |
| 187 CSSValueID m_displayDirection; |
| 188 |
| 189 int m_displaySize; |
| 190 |
| 191 std::pair<float, float> m_displayPosition; |
| 192 String m_regionId; |
| 193 bool m_notifyRegion; |
44 }; | 194 }; |
45 | 195 |
46 inline VTTCue* toVTTCue(TextTrackCue* cue) | 196 inline VTTCue* toVTTCue(TextTrackCue* cue) |
47 { | 197 { |
48 // VTTCue is currently the only TextTrackCue subclass. | 198 // VTTCue is currently the only TextTrackCue subclass. |
49 return static_cast<VTTCue*>(cue); | 199 return static_cast<VTTCue*>(cue); |
50 } | 200 } |
51 | 201 |
52 } // namespace WebCore | 202 } // namespace WebCore |
53 | 203 |
54 #endif | 204 #endif |
OLD | NEW |