Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / layout / LayoutQuote.h
blob5cff0666b9dc06d4821e2a6ac0541dc4f110485b
1 /*
2 * Copyright (C) 2011 Nokia Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 #ifndef LayoutQuote_h
23 #define LayoutQuote_h
25 #include "core/layout/LayoutInline.h"
26 #include "core/style/ComputedStyle.h"
27 #include "core/style/ComputedStyleConstants.h"
28 #include "core/style/QuotesData.h"
30 namespace blink {
32 class Document;
33 class LayoutTextFragment;
35 // LayoutQuote is the layout object associated with generated quotes
36 // ("content: open-quote | close-quote | no-open-quote | no-close-quote").
37 // http://www.w3.org/TR/CSS2/generate.html#quotes-insert
39 // This object is generated thus always anonymous.
41 // For performance reasons, LayoutQuotes form a doubly-linked list. See |m_next|
42 // and |m_previous| below.
43 class LayoutQuote final : public LayoutInline {
44 public:
45 LayoutQuote(Document*, const QuoteType);
46 ~LayoutQuote() override;
47 void attachQuote();
49 const char* name() const override { return "LayoutQuote"; }
51 private:
52 void detachQuote();
54 void willBeDestroyed() override;
55 bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectQuote || LayoutInline::isOfType(type); }
56 void styleDidChange(StyleDifference, const ComputedStyle*) override;
57 void willBeRemovedFromTree() override;
59 String computeText() const;
60 void updateText();
61 const QuotesData* quotesData() const;
62 void updateDepth();
63 bool isAttached() { return m_attached; }
65 LayoutTextFragment* findFragmentChild() const;
67 // Type of this LayoutQuote: open-quote, close-quote, no-open-quote,
68 // no-close-quote.
69 QuoteType m_type;
71 // Number of open quotes in the tree. Also called the nesting level
72 // in CSS 2.1.
73 // Used to determine if a LayoutQuote is invalid (closing quote without a
74 // matching opening quote) and which quote character to use (see the 'quote'
75 // property that is used to define quote character pairs).
76 int m_depth;
78 // The next and previous LayoutQuote in layout tree order.
79 // LayoutQuotes are linked together by this doubly-linked list.
80 // Those are used to compute |m_depth| in an efficient manner.
81 LayoutQuote* m_next;
82 LayoutQuote* m_previous;
84 // This tracks whether this LayoutQuote was inserted into the layout tree
85 // and its position in the linked list is correct (m_next and m_previous).
86 // It's used for both performance (avoid unneeded tree walks to find the
87 // previous and next quotes) and conformance (|m_depth| relies on an
88 // up-to-date linked list positions).
89 bool m_attached;
91 // Cached text for this quote.
92 String m_text;
95 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutQuote, isQuote());
97 } // namespace blink
99 #endif // LayoutQuote_h