• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 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 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 TextMetrics_h
27 #define TextMetrics_h
28 
29 #include "bindings/core/v8/ScriptWrappable.h"
30 #include "platform/heap/Handle.h"
31 #include "wtf/PassRefPtr.h"
32 #include "wtf/RefCounted.h"
33 
34 namespace blink {
35 
36 class TextMetrics FINAL : public RefCountedWillBeGarbageCollected<TextMetrics>, public ScriptWrappable {
37     DEFINE_WRAPPERTYPEINFO();
38 public:
create()39     static PassRefPtrWillBeRawPtr<TextMetrics> create() { return adoptRefWillBeNoop(new TextMetrics); }
40 
width()41     float width() const { return m_width; }
setWidth(float w)42     void setWidth(float w) { m_width = w; }
43 
actualBoundingBoxLeft()44     float actualBoundingBoxLeft() const { return m_actualBoundingBoxLeft; }
setActualBoundingBoxLeft(float actualBoundingBoxLeft)45     void setActualBoundingBoxLeft(float actualBoundingBoxLeft) { m_actualBoundingBoxLeft = actualBoundingBoxLeft; }
46 
actualBoundingBoxRight()47     float actualBoundingBoxRight() const { return m_actualBoundingBoxRight; }
setActualBoundingBoxRight(float actualBoundingBoxRight)48     void setActualBoundingBoxRight(float actualBoundingBoxRight) { m_actualBoundingBoxRight = actualBoundingBoxRight; }
49 
fontBoundingBoxAscent()50     float fontBoundingBoxAscent() const { return m_fontBoundingBoxAscent; }
setFontBoundingBoxAscent(float fontBoundingBoxAscent)51     void setFontBoundingBoxAscent(float fontBoundingBoxAscent) { m_fontBoundingBoxAscent = fontBoundingBoxAscent; }
52 
fontBoundingBoxDescent()53     float fontBoundingBoxDescent() const { return m_fontBoundingBoxDescent; }
setFontBoundingBoxDescent(float fontBoundingBoxDescent)54     void setFontBoundingBoxDescent(float fontBoundingBoxDescent) { m_fontBoundingBoxDescent = fontBoundingBoxDescent; }
55 
actualBoundingBoxAscent()56     float actualBoundingBoxAscent() const { return m_actualBoundingBoxAscent; }
setActualBoundingBoxAscent(float actualBoundingBoxAscent)57     void setActualBoundingBoxAscent(float actualBoundingBoxAscent) { m_actualBoundingBoxAscent = actualBoundingBoxAscent; }
58 
actualBoundingBoxDescent()59     float actualBoundingBoxDescent() const { return m_actualBoundingBoxDescent; }
setActualBoundingBoxDescent(float actualBoundingBoxDescent)60     void setActualBoundingBoxDescent(float actualBoundingBoxDescent) { m_actualBoundingBoxDescent = actualBoundingBoxDescent; }
61 
emHeightAscent()62     float emHeightAscent() const { return m_emHeightAscent; }
setEmHeightAscent(float emHeightAscent)63     void setEmHeightAscent(float emHeightAscent) { m_emHeightAscent = emHeightAscent; }
64 
emHeightDescent()65     float emHeightDescent() const { return m_emHeightDescent; }
setEmHeightDescent(float emHeightDescent)66     void setEmHeightDescent(float emHeightDescent) { m_emHeightDescent = emHeightDescent; }
67 
hangingBaseline()68     float hangingBaseline() const { return m_hangingBaseline; }
setHangingBaseline(float hangingBaseline)69     void setHangingBaseline(float hangingBaseline) { m_hangingBaseline = hangingBaseline; }
70 
alphabeticBaseline()71     float alphabeticBaseline() const { return m_alphabeticBaseline; }
setAlphabeticBaseline(float alphabeticBaseline)72     void setAlphabeticBaseline(float alphabeticBaseline) { m_alphabeticBaseline = alphabeticBaseline; }
73 
ideographicBaseline()74     float ideographicBaseline() const { return m_ideographicBaseline; }
setIdeographicBaseline(float ideographicBaseline)75     void setIdeographicBaseline(float ideographicBaseline) { m_ideographicBaseline = ideographicBaseline; }
76 
trace(Visitor *)77     void trace(Visitor*) { }
78 
79 private:
TextMetrics()80     TextMetrics()
81         : m_width(0)
82         , m_actualBoundingBoxLeft(0)
83         , m_actualBoundingBoxRight(0)
84         , m_fontBoundingBoxAscent(0)
85         , m_fontBoundingBoxDescent(0)
86         , m_actualBoundingBoxAscent(0)
87         , m_actualBoundingBoxDescent(0)
88         , m_emHeightAscent(0)
89         , m_emHeightDescent(0)
90         , m_hangingBaseline(0)
91         , m_alphabeticBaseline(0)
92         , m_ideographicBaseline(0) { }
93 
94     // x-direction
95     float m_width;
96     float m_actualBoundingBoxLeft;
97     float m_actualBoundingBoxRight;
98 
99     // y-direction
100     float m_fontBoundingBoxAscent;
101     float m_fontBoundingBoxDescent;
102     float m_actualBoundingBoxAscent;
103     float m_actualBoundingBoxDescent;
104     float m_emHeightAscent;
105     float m_emHeightDescent;
106     float m_hangingBaseline;
107     float m_alphabeticBaseline;
108     float m_ideographicBaseline;
109 };
110 
111 } // namespace blink
112 
113 #endif // TextMetrics_h
114