| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 void RenderQuote::willBeDestroyed() | 48 void RenderQuote::willBeDestroyed() |
| 49 { | 49 { |
| 50 detachQuote(); | 50 detachQuote(); |
| 51 RenderText::willBeDestroyed(); | 51 RenderText::willBeDestroyed(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void RenderQuote::willBeRemovedFromTree() | 54 void RenderQuote::willBeRemovedFromTree() |
| 55 { | 55 { |
| 56 RenderText::willBeRemovedFromTree(); | 56 RenderText::willBeRemovedFromTree(); |
| 57 detachQuote(); |
| 58 } |
| 57 | 59 |
| 58 detachQuote(); | 60 void RenderQuote::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
le) |
| 61 { |
| 62 RenderText::styleDidChange(diff, oldStyle); |
| 63 updateText(); |
| 59 } | 64 } |
| 60 | 65 |
| 61 typedef HashMap<AtomicString, const QuotesData*, CaseFoldingHash> QuotesMap; | 66 typedef HashMap<AtomicString, const QuotesData*, CaseFoldingHash> QuotesMap; |
| 62 | 67 |
| 63 static const QuotesMap& quotesDataLanguageMap() | 68 static const QuotesMap& quotesDataLanguageMap() |
| 64 { | 69 { |
| 65 DEFINE_STATIC_LOCAL(QuotesMap, staticQuotesMap, ()); | 70 DEFINE_STATIC_LOCAL(QuotesMap, staticQuotesMap, ()); |
| 66 if (staticQuotesMap.size()) | 71 if (staticQuotesMap.size()) |
| 67 return staticQuotesMap; | 72 return staticQuotesMap; |
| 68 | 73 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return quotesData()->getCloseQuote(m_depth - 1).impl(); | 243 return quotesData()->getCloseQuote(m_depth - 1).impl(); |
| 239 case OPEN_QUOTE: | 244 case OPEN_QUOTE: |
| 240 return quotesData()->getOpenQuote(m_depth).impl(); | 245 return quotesData()->getOpenQuote(m_depth).impl(); |
| 241 } | 246 } |
| 242 ASSERT_NOT_REACHED(); | 247 ASSERT_NOT_REACHED(); |
| 243 return StringImpl::empty(); | 248 return StringImpl::empty(); |
| 244 } | 249 } |
| 245 | 250 |
| 246 void RenderQuote::updateText() | 251 void RenderQuote::updateText() |
| 247 { | 252 { |
| 248 computePreferredLogicalWidths(0); | 253 setText(originalText()); |
| 249 } | |
| 250 | |
| 251 void RenderQuote::computePreferredLogicalWidths(float lead) | |
| 252 { | |
| 253 if (!m_attached) | |
| 254 attachQuote(); | |
| 255 setTextInternal(originalText()); | |
| 256 RenderText::computePreferredLogicalWidths(lead); | |
| 257 } | 254 } |
| 258 | 255 |
| 259 const QuotesData* RenderQuote::quotesData() const | 256 const QuotesData* RenderQuote::quotesData() const |
| 260 { | 257 { |
| 261 if (QuotesData* customQuotes = style()->quotes()) | 258 if (QuotesData* customQuotes = style()->quotes()) |
| 262 return customQuotes; | 259 return customQuotes; |
| 263 | 260 |
| 264 AtomicString language = style()->locale(); | 261 AtomicString language = style()->locale(); |
| 265 if (language.isNull()) | 262 if (language.isNull()) |
| 266 return basicQuotesData(); | 263 return basicQuotesData(); |
| 267 const QuotesData* quotes = quotesDataLanguageMap().get(language); | 264 const QuotesData* quotes = quotesDataLanguageMap().get(language); |
| 268 if (!quotes) | 265 if (!quotes) |
| 269 return basicQuotesData(); | 266 return basicQuotesData(); |
| 270 return quotes; | 267 return quotes; |
| 271 } | 268 } |
| 272 | 269 |
| 273 void RenderQuote::attachQuote() | 270 void RenderQuote::attachQuote() |
| 274 { | 271 { |
| 275 ASSERT(view()); | 272 ASSERT(view()); |
| 276 ASSERT(!m_attached); | 273 ASSERT(!m_attached); |
| 277 ASSERT(!m_next && !m_previous); | 274 ASSERT(!m_next && !m_previous); |
| 278 | 275 ASSERT(isRooted()); |
| 279 // FIXME: Don't set pref widths dirty during layout. See updateDepth() for | |
| 280 // more detail. | |
| 281 if (!isRooted()) { | |
| 282 setNeedsLayoutAndPrefWidthsRecalc(); | |
| 283 return; | |
| 284 } | |
| 285 | 276 |
| 286 if (!view()->renderQuoteHead()) { | 277 if (!view()->renderQuoteHead()) { |
| 287 view()->setRenderQuoteHead(this); | 278 view()->setRenderQuoteHead(this); |
| 288 m_attached = true; | 279 m_attached = true; |
| 289 return; | 280 return; |
| 290 } | 281 } |
| 291 | 282 |
| 292 for (RenderObject* predecessor = previousInPreOrder(); predecessor; predeces
sor = predecessor->previousInPreOrder()) { | 283 for (RenderObject* predecessor = previousInPreOrder(); predecessor; predeces
sor = predecessor->previousInPreOrder()) { |
| 293 // Skip unattached predecessors to avoid having stale m_previous pointer
s | 284 // Skip unattached predecessors to avoid having stale m_previous pointer
s |
| 294 // if the previous node is never attached and is then destroyed. | 285 // if the previous node is never attached and is then destroyed. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 case NO_OPEN_QUOTE: | 344 case NO_OPEN_QUOTE: |
| 354 m_depth++; | 345 m_depth++; |
| 355 break; | 346 break; |
| 356 case CLOSE_QUOTE: | 347 case CLOSE_QUOTE: |
| 357 case NO_CLOSE_QUOTE: | 348 case NO_CLOSE_QUOTE: |
| 358 if (m_depth) | 349 if (m_depth) |
| 359 m_depth--; | 350 m_depth--; |
| 360 break; | 351 break; |
| 361 } | 352 } |
| 362 } | 353 } |
| 363 // FIXME: Don't call setNeedsLayout or dirty our preferred widths during lay
out. | |
| 364 // This is likely to fail anyway as one of our ancestor will call setNeedsLa
yout(false), | |
| 365 // preventing the future layout to occur on |this|. The solution is to move
that to a | |
| 366 // pre-layout phase. | |
| 367 if (oldDepth != m_depth) | 354 if (oldDepth != m_depth) |
| 368 setNeedsLayoutAndPrefWidthsRecalc(); | 355 updateText(); |
| 369 } | 356 } |
| 370 | 357 |
| 371 } // namespace WebCore | 358 } // namespace WebCore |
| OLD | NEW |