Home | History | Annotate | Download | only in track
      1 /*
      2  * Copyright (C) 2013 Apple Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef TextTrackCueGeneric_h
     27 #define TextTrackCueGeneric_h
     28 
     29 #include "core/html/track/TextTrackCue.h"
     30 #include "core/platform/graphics/Color.h"
     31 
     32 namespace WebCore {
     33 
     34 class ExceptionState;
     35 class GenericCueData;
     36 
     37 // A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
     38 class TextTrackCueGeneric : public TextTrackCue {
     39 public:
     40     static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext* context, double start, double end, const String& content)
     41     {
     42         return adoptRef(new TextTrackCueGeneric(context, start, end, content));
     43     }
     44 
     45     virtual ~TextTrackCueGeneric() { }
     46 
     47     virtual PassRefPtr<TextTrackCueBox> createDisplayTree() OVERRIDE;
     48 
     49     virtual void setLine(int, ExceptionState&) OVERRIDE;
     50     virtual void setPosition(int, ExceptionState&) OVERRIDE;
     51 
     52     bool useDefaultPosition() const { return m_defaultPosition; }
     53 
     54     double baseFontSizeRelativeToVideoHeight() const { return m_baseFontSizeRelativeToVideoHeight; }
     55     void setBaseFontSizeRelativeToVideoHeight(double size) { m_baseFontSizeRelativeToVideoHeight = size; }
     56 
     57     double fontSizeMultiplier() const { return m_fontSizeMultiplier; }
     58     void setFontSizeMultiplier(double size) { m_fontSizeMultiplier = size; }
     59 
     60     String fontName() const { return m_fontName; }
     61     void setFontName(String name) { m_fontName = name; }
     62 
     63     Color foregroundColor() const { return m_foregroundColor; }
     64     void setForegroundColor(Color color) { m_foregroundColor = color; }
     65 
     66     Color backgroundColor() const { return m_backgroundColor; }
     67     void setBackgroundColor(Color color) { m_backgroundColor = color; }
     68 
     69     virtual void videoSizeDidChange(const IntSize&);
     70 
     71     virtual bool operator==(const TextTrackCue&) const OVERRIDE;
     72     virtual bool operator!=(const TextTrackCue& cue) const OVERRIDE
     73     {
     74         return !(*this == cue);
     75     }
     76 
     77     virtual TextTrackCue::CueType cueType() const OVERRIDE { return TextTrackCue::Generic; }
     78 
     79 private:
     80     TextTrackCueGeneric(ScriptExecutionContext*, double start, double end, const String&);
     81 
     82     Color m_foregroundColor;
     83     Color m_backgroundColor;
     84     double m_baseFontSizeRelativeToVideoHeight;
     85     double m_fontSizeMultiplier;
     86     String m_fontName;
     87     bool m_defaultPosition;
     88 };
     89 
     90 } // namespace WebCore
     91 
     92 #endif
     93