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