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 #ifndef NDEBUG | |
254 // FIXME: We shouldn't be modifying the tree in computePreferredLogicalWidth
s. | |
255 // Instead, we should properly hook the appropriate changes in the DOM and m
odify | |
256 // the render tree then. When that's done, we also won't need to override | |
257 // computePreferredLogicalWidths at all. | |
258 // https://bugs.webkit.org/show_bug.cgi?id=104829 | |
259 SetLayoutNeededForbiddenScope layoutForbiddenScope(this, false); | |
260 #endif | |
261 | |
262 if (!m_attached) | |
263 attachQuote(); | |
264 setTextInternal(originalText()); | |
265 | |
266 RenderText::computePreferredLogicalWidths(lead); | |
267 } | 254 } |
268 | 255 |
269 const QuotesData* RenderQuote::quotesData() const | 256 const QuotesData* RenderQuote::quotesData() const |
270 { | 257 { |
271 if (QuotesData* customQuotes = style()->quotes()) | 258 if (QuotesData* customQuotes = style()->quotes()) |
272 return customQuotes; | 259 return customQuotes; |
273 | 260 |
274 AtomicString language = style()->locale(); | 261 AtomicString language = style()->locale(); |
275 if (language.isNull()) | 262 if (language.isNull()) |
276 return basicQuotesData(); | 263 return basicQuotesData(); |
277 const QuotesData* quotes = quotesDataLanguageMap().get(language); | 264 const QuotesData* quotes = quotesDataLanguageMap().get(language); |
278 if (!quotes) | 265 if (!quotes) |
279 return basicQuotesData(); | 266 return basicQuotesData(); |
280 return quotes; | 267 return quotes; |
281 } | 268 } |
282 | 269 |
283 void RenderQuote::attachQuote() | 270 void RenderQuote::attachQuote() |
284 { | 271 { |
285 ASSERT(view()); | 272 ASSERT(view()); |
286 ASSERT(!m_attached); | 273 ASSERT(!m_attached); |
287 ASSERT(!m_next && !m_previous); | 274 ASSERT(!m_next && !m_previous); |
288 | 275 ASSERT(isRooted()); |
289 // FIXME: Don't set pref widths dirty during layout. See updateDepth() for | |
290 // more detail. | |
291 if (!isRooted()) { | |
292 setNeedsLayoutAndPrefWidthsRecalc(); | |
293 return; | |
294 } | |
295 | 276 |
296 if (!view()->renderQuoteHead()) { | 277 if (!view()->renderQuoteHead()) { |
297 view()->setRenderQuoteHead(this); | 278 view()->setRenderQuoteHead(this); |
298 m_attached = true; | 279 m_attached = true; |
299 return; | 280 return; |
300 } | 281 } |
301 | 282 |
302 for (RenderObject* predecessor = previousInPreOrder(); predecessor; predeces
sor = predecessor->previousInPreOrder()) { | 283 for (RenderObject* predecessor = previousInPreOrder(); predecessor; predeces
sor = predecessor->previousInPreOrder()) { |
303 // Skip unattached predecessors to avoid having stale m_previous pointer
s | 284 // Skip unattached predecessors to avoid having stale m_previous pointer
s |
304 // 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... |
363 case NO_OPEN_QUOTE: | 344 case NO_OPEN_QUOTE: |
364 m_depth++; | 345 m_depth++; |
365 break; | 346 break; |
366 case CLOSE_QUOTE: | 347 case CLOSE_QUOTE: |
367 case NO_CLOSE_QUOTE: | 348 case NO_CLOSE_QUOTE: |
368 if (m_depth) | 349 if (m_depth) |
369 m_depth--; | 350 m_depth--; |
370 break; | 351 break; |
371 } | 352 } |
372 } | 353 } |
373 // FIXME: Don't call setNeedsLayout or dirty our preferred widths during lay
out. | |
374 // This is likely to fail anyway as one of our ancestor will call setNeedsLa
yout(false), | |
375 // preventing the future layout to occur on |this|. The solution is to move
that to a | |
376 // pre-layout phase. | |
377 if (oldDepth != m_depth) | 354 if (oldDepth != m_depth) |
378 setNeedsLayoutAndPrefWidthsRecalc(); | 355 updateText(); |
379 } | 356 } |
380 | 357 |
381 } // namespace WebCore | 358 } // namespace WebCore |
OLD | NEW |