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.
25 #include "core/layout/LayoutInline.h"
26 #include "core/style/ComputedStyle.h"
27 #include "core/style/ComputedStyleConstants.h"
28 #include "core/style/QuotesData.h"
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
{
45 LayoutQuote(Document
*, const QuoteType
);
46 ~LayoutQuote() override
;
49 const char* name() const override
{ return "LayoutQuote"; }
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;
61 const QuotesData
* quotesData() const;
63 bool isAttached() { return m_attached
; }
65 LayoutTextFragment
* findFragmentChild() const;
67 // Type of this LayoutQuote: open-quote, close-quote, no-open-quote,
71 // Number of open quotes in the tree. Also called the nesting level
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).
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.
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).
91 // Cached text for this quote.
95 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutQuote
, isQuote());
99 #endif // LayoutQuote_h