OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2011 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2011 Nokia Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #include "core/layout/LayoutQuote.h" | 22 #include "core/layout/LayoutQuote.h" |
23 | 23 |
| 24 #include "core/dom/PseudoElement.h" |
24 #include "core/layout/LayoutTextFragment.h" | 25 #include "core/layout/LayoutTextFragment.h" |
25 #include "core/layout/LayoutView.h" | 26 #include "core/layout/LayoutView.h" |
26 #include "wtf/StdLibExtras.h" | 27 #include "wtf/StdLibExtras.h" |
27 #include "wtf/text/AtomicString.h" | 28 #include "wtf/text/AtomicString.h" |
28 | 29 |
29 #include <algorithm> | 30 #include <algorithm> |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 LayoutQuote::LayoutQuote(Document* node, QuoteType quote) | 34 LayoutQuote::LayoutQuote(PseudoElement& pseudo, QuoteType quote) |
34 : LayoutInline(nullptr), | 35 : LayoutInline(nullptr), |
35 m_type(quote), | 36 m_type(quote), |
36 m_depth(0), | 37 m_depth(0), |
37 m_next(nullptr), | 38 m_next(nullptr), |
38 m_previous(nullptr), | 39 m_previous(nullptr), |
| 40 m_owningPseudo(&pseudo), |
39 m_attached(false) { | 41 m_attached(false) { |
40 setDocumentForAnonymous(node); | 42 setDocumentForAnonymous(&pseudo.document()); |
41 } | 43 } |
42 | 44 |
43 LayoutQuote::~LayoutQuote() { | 45 LayoutQuote::~LayoutQuote() { |
44 ASSERT(!m_attached); | 46 ASSERT(!m_attached); |
45 ASSERT(!m_next && !m_previous); | 47 ASSERT(!m_next && !m_previous); |
46 } | 48 } |
47 | 49 |
48 void LayoutQuote::willBeDestroyed() { | 50 void LayoutQuote::willBeDestroyed() { |
49 detachQuote(); | 51 detachQuote(); |
50 LayoutInline::willBeDestroyed(); | 52 LayoutInline::willBeDestroyed(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (m_text == text) | 259 if (m_text == text) |
258 return; | 260 return; |
259 | 261 |
260 m_text = text; | 262 m_text = text; |
261 | 263 |
262 LayoutTextFragment* fragment = findFragmentChild(); | 264 LayoutTextFragment* fragment = findFragmentChild(); |
263 if (fragment) { | 265 if (fragment) { |
264 fragment->setStyle(mutableStyle()); | 266 fragment->setStyle(mutableStyle()); |
265 fragment->setContentString(m_text.impl()); | 267 fragment->setContentString(m_text.impl()); |
266 } else { | 268 } else { |
267 fragment = new LayoutTextFragment(&document(), m_text.impl()); | 269 fragment = |
| 270 LayoutTextFragment::createAnonymous(*m_owningPseudo, m_text.impl()); |
268 fragment->setStyle(mutableStyle()); | 271 fragment->setStyle(mutableStyle()); |
269 addChild(fragment); | 272 addChild(fragment); |
270 } | 273 } |
271 } | 274 } |
272 | 275 |
273 LayoutTextFragment* LayoutQuote::findFragmentChild() const { | 276 LayoutTextFragment* LayoutQuote::findFragmentChild() const { |
274 // We walk from the end of the child list because, if we've had a first-letter | 277 // We walk from the end of the child list because, if we've had a first-letter |
275 // LayoutObject inserted then the remaining text will be at the end. | 278 // LayoutObject inserted then the remaining text will be at the end. |
276 while (LayoutObject* child = lastChild()) { | 279 while (LayoutObject* child = lastChild()) { |
277 if (child->isText() && toLayoutText(child)->isTextFragment()) | 280 if (child->isText() && toLayoutText(child)->isTextFragment()) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (m_depth) | 393 if (m_depth) |
391 m_depth--; | 394 m_depth--; |
392 break; | 395 break; |
393 } | 396 } |
394 } | 397 } |
395 if (oldDepth != m_depth) | 398 if (oldDepth != m_depth) |
396 updateText(); | 399 updateText(); |
397 } | 400 } |
398 | 401 |
399 } // namespace blink | 402 } // namespace blink |
OLD | NEW |