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 |
| 104 virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& contain
er) OVERRIDE; |
| 105 |
| 106 virtual void updateDisplayTree(double movieTime) OVERRIDE; |
| 107 virtual void removeDisplayTree() OVERRIDE; |
| 108 virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) OVERRIDE
; |
| 109 |
| 110 void markFutureAndPastNodes(ContainerNode*, double previousTimestamp, double
movieTime); |
| 111 |
| 112 int calculateComputedLinePosition(); |
| 113 |
| 114 std::pair<double, double> getCSSPosition() const; |
| 115 |
| 116 CSSValueID getCSSAlignment() const; |
| 117 int getCSSSize() const; |
| 118 CSSValueID getCSSWritingDirection() const; |
| 119 CSSValueID getCSSWritingMode() const; |
| 120 |
| 121 enum WritingDirection { |
| 122 Horizontal = 0, |
| 123 VerticalGrowingLeft, |
| 124 VerticalGrowingRight, |
| 125 NumberOfWritingDirections |
| 126 }; |
| 127 WritingDirection getWritingDirection() const { return m_writingDirection; } |
| 128 |
| 129 enum CueAlignment { |
| 130 Start = 0, |
| 131 Middle, |
| 132 End, |
| 133 Left, |
| 134 Right, |
| 135 NumberOfAlignments |
| 136 }; |
| 137 CueAlignment getAlignment() const { return m_cueAlignment; } |
| 138 |
| 139 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 140 |
| 141 virtual String toString() const; |
41 | 142 |
42 private: | 143 private: |
43 VTTCue(Document&, double startTime, double endTime, const String& text); | 144 VTTCue(Document&, double startTime, double endTime, const String& text); |
| 145 |
| 146 Document& document() const; |
| 147 |
| 148 PassRefPtr<VTTCueBox> displayTreeInternal(); |
| 149 PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize); |
| 150 |
| 151 virtual void cueDidChange() OVERRIDE; |
| 152 |
| 153 void createVTTNodeTree(); |
| 154 void copyVTTNodeToDOMTree(ContainerNode* vttNode, ContainerNode* root); |
| 155 |
| 156 std::pair<double, double> getPositionCoordinates() const; |
| 157 |
| 158 void determineTextDirection(); |
| 159 void calculateDisplayParameters(); |
| 160 |
| 161 enum CueSetting { |
| 162 None, |
| 163 Vertical, |
| 164 Line, |
| 165 Position, |
| 166 Size, |
| 167 Align, |
| 168 RegionId |
| 169 }; |
| 170 CueSetting settingName(const String&); |
| 171 |
| 172 String m_text; |
| 173 int m_linePosition; |
| 174 int m_computedLinePosition; |
| 175 int m_textPosition; |
| 176 int m_cueSize; |
| 177 WritingDirection m_writingDirection; |
| 178 |
| 179 CueAlignment m_cueAlignment; |
| 180 |
| 181 RefPtr<DocumentFragment> m_vttNodeTree; |
| 182 bool m_snapToLines; |
| 183 |
| 184 RefPtr<HTMLDivElement> m_cueBackgroundBox; |
| 185 |
| 186 bool m_displayTreeShouldChange; |
| 187 RefPtr<VTTCueBox> m_displayTree; |
| 188 |
| 189 CSSValueID m_displayDirection; |
| 190 |
| 191 int m_displaySize; |
| 192 |
| 193 std::pair<float, float> m_displayPosition; |
| 194 String m_regionId; |
| 195 bool m_notifyRegion; |
44 }; | 196 }; |
45 | 197 |
46 inline VTTCue* toVTTCue(TextTrackCue* cue) | 198 inline VTTCue* toVTTCue(TextTrackCue* cue) |
47 { | 199 { |
48 // VTTCue is currently the only TextTrackCue subclass. | 200 // VTTCue is currently the only TextTrackCue subclass. |
49 return static_cast<VTTCue*>(cue); | 201 return static_cast<VTTCue*>(cue); |
50 } | 202 } |
51 | 203 |
52 } // namespace WebCore | 204 } // namespace WebCore |
53 | 205 |
54 #endif | 206 #endif |
OLD | NEW |