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, |
(...skipping 25 matching lines...) Expand all Loading... |
36 m_type(quote), | 36 m_type(quote), |
37 m_depth(0), | 37 m_depth(0), |
38 m_next(nullptr), | 38 m_next(nullptr), |
39 m_previous(nullptr), | 39 m_previous(nullptr), |
40 m_owningPseudo(&pseudo), | 40 m_owningPseudo(&pseudo), |
41 m_attached(false) { | 41 m_attached(false) { |
42 setDocumentForAnonymous(&pseudo.document()); | 42 setDocumentForAnonymous(&pseudo.document()); |
43 } | 43 } |
44 | 44 |
45 LayoutQuote::~LayoutQuote() { | 45 LayoutQuote::~LayoutQuote() { |
46 ASSERT(!m_attached); | 46 DCHECK(!m_attached); |
47 ASSERT(!m_next && !m_previous); | 47 DCHECK(!m_next); |
| 48 DCHECK(!m_previous); |
48 } | 49 } |
49 | 50 |
50 void LayoutQuote::willBeDestroyed() { | 51 void LayoutQuote::willBeDestroyed() { |
51 detachQuote(); | 52 detachQuote(); |
52 LayoutInline::willBeDestroyed(); | 53 LayoutInline::willBeDestroyed(); |
53 } | 54 } |
54 | 55 |
55 void LayoutQuote::willBeRemovedFromTree() { | 56 void LayoutQuote::willBeRemovedFromTree() { |
56 LayoutInline::willBeRemovedFromTree(); | 57 LayoutInline::willBeRemovedFromTree(); |
57 detachQuote(); | 58 detachQuote(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if (const QuotesData* customQuotes = style()->quotes()) | 303 if (const QuotesData* customQuotes = style()->quotes()) |
303 return customQuotes; | 304 return customQuotes; |
304 | 305 |
305 if (const QuotesData* quotes = quotesDataForLanguage(style()->locale())) | 306 if (const QuotesData* quotes = quotesDataForLanguage(style()->locale())) |
306 return quotes; | 307 return quotes; |
307 | 308 |
308 return basicQuotesData(); | 309 return basicQuotesData(); |
309 } | 310 } |
310 | 311 |
311 void LayoutQuote::attachQuote() { | 312 void LayoutQuote::attachQuote() { |
312 ASSERT(view()); | 313 DCHECK(view()); |
313 ASSERT(!m_attached); | 314 DCHECK(!m_attached); |
314 ASSERT(!m_next && !m_previous); | 315 DCHECK(!m_next); |
315 ASSERT(isRooted()); | 316 DCHECK(!m_previous); |
| 317 DCHECK(isRooted()); |
316 | 318 |
317 if (!view()->layoutQuoteHead()) { | 319 if (!view()->layoutQuoteHead()) { |
318 view()->setLayoutQuoteHead(this); | 320 view()->setLayoutQuoteHead(this); |
319 m_attached = true; | 321 m_attached = true; |
320 return; | 322 return; |
321 } | 323 } |
322 | 324 |
323 for (LayoutObject* predecessor = previousInPreOrder(); predecessor; | 325 for (LayoutObject* predecessor = previousInPreOrder(); predecessor; |
324 predecessor = predecessor->previousInPreOrder()) { | 326 predecessor = predecessor->previousInPreOrder()) { |
325 // Skip unattached predecessors to avoid having stale m_previous pointers | 327 // Skip unattached predecessors to avoid having stale m_previous pointers |
(...skipping 12 matching lines...) Expand all Loading... |
338 m_next = view()->layoutQuoteHead(); | 340 m_next = view()->layoutQuoteHead(); |
339 view()->setLayoutQuoteHead(this); | 341 view()->setLayoutQuoteHead(this); |
340 if (m_next) | 342 if (m_next) |
341 m_next->m_previous = this; | 343 m_next->m_previous = this; |
342 } | 344 } |
343 m_attached = true; | 345 m_attached = true; |
344 | 346 |
345 for (LayoutQuote* quote = this; quote; quote = quote->m_next) | 347 for (LayoutQuote* quote = this; quote; quote = quote->m_next) |
346 quote->updateDepth(); | 348 quote->updateDepth(); |
347 | 349 |
348 ASSERT(!m_next || m_next->m_attached); | 350 DCHECK(!m_next || m_next->m_attached); |
349 ASSERT(!m_next || m_next->m_previous == this); | 351 DCHECK(!m_next || m_next->m_previous == this); |
350 ASSERT(!m_previous || m_previous->m_attached); | 352 DCHECK(!m_previous || m_previous->m_attached); |
351 ASSERT(!m_previous || m_previous->m_next == this); | 353 DCHECK(!m_previous || m_previous->m_next == this); |
352 } | 354 } |
353 | 355 |
354 void LayoutQuote::detachQuote() { | 356 void LayoutQuote::detachQuote() { |
355 ASSERT(!m_next || m_next->m_attached); | 357 DCHECK(!m_next || m_next->m_attached); |
356 ASSERT(!m_previous || m_previous->m_attached); | 358 DCHECK(!m_previous || m_previous->m_attached); |
357 if (!m_attached) | 359 if (!m_attached) |
358 return; | 360 return; |
359 | 361 |
360 // Reset our attached status at this point because it's possible for | 362 // Reset our attached status at this point because it's possible for |
361 // updateDepth() to call into attachQuote(). Attach quote walks the layout | 363 // updateDepth() to call into attachQuote(). Attach quote walks the layout |
362 // tree looking for quotes that are attached and does work on them. | 364 // tree looking for quotes that are attached and does work on them. |
363 m_attached = false; | 365 m_attached = false; |
364 | 366 |
365 if (m_previous) | 367 if (m_previous) |
366 m_previous->m_next = m_next; | 368 m_previous->m_next = m_next; |
367 else if (view()) | 369 else if (view()) |
368 view()->setLayoutQuoteHead(m_next); | 370 view()->setLayoutQuoteHead(m_next); |
369 if (m_next) | 371 if (m_next) |
370 m_next->m_previous = m_previous; | 372 m_next->m_previous = m_previous; |
371 if (!documentBeingDestroyed()) { | 373 if (!documentBeingDestroyed()) { |
372 for (LayoutQuote* quote = m_next; quote; quote = quote->m_next) | 374 for (LayoutQuote* quote = m_next; quote; quote = quote->m_next) |
373 quote->updateDepth(); | 375 quote->updateDepth(); |
374 } | 376 } |
375 m_next = nullptr; | 377 m_next = nullptr; |
376 m_previous = nullptr; | 378 m_previous = nullptr; |
377 m_depth = 0; | 379 m_depth = 0; |
378 } | 380 } |
379 | 381 |
380 void LayoutQuote::updateDepth() { | 382 void LayoutQuote::updateDepth() { |
381 ASSERT(m_attached); | 383 DCHECK(m_attached); |
382 int oldDepth = m_depth; | 384 int oldDepth = m_depth; |
383 m_depth = 0; | 385 m_depth = 0; |
384 if (m_previous) { | 386 if (m_previous) { |
385 m_depth = m_previous->m_depth; | 387 m_depth = m_previous->m_depth; |
386 switch (m_previous->m_type) { | 388 switch (m_previous->m_type) { |
387 case OPEN_QUOTE: | 389 case OPEN_QUOTE: |
388 case NO_OPEN_QUOTE: | 390 case NO_OPEN_QUOTE: |
389 m_depth++; | 391 m_depth++; |
390 break; | 392 break; |
391 case CLOSE_QUOTE: | 393 case CLOSE_QUOTE: |
392 case NO_CLOSE_QUOTE: | 394 case NO_CLOSE_QUOTE: |
393 if (m_depth) | 395 if (m_depth) |
394 m_depth--; | 396 m_depth--; |
395 break; | 397 break; |
396 } | 398 } |
397 } | 399 } |
398 if (oldDepth != m_depth) | 400 if (oldDepth != m_depth) |
399 updateText(); | 401 updateText(); |
400 } | 402 } |
401 | 403 |
402 } // namespace blink | 404 } // namespace blink |
OLD | NEW |