OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 return isIndependentDescendant(block) || mightBeWiderOrNarrowerDescendant(bl ock) || block->isTable(); | 229 return isIndependentDescendant(block) || mightBeWiderOrNarrowerDescendant(bl ock) || block->isTable(); |
230 } | 230 } |
231 | 231 |
232 FastTextAutosizer::FastTextAutosizer(const Document* document) | 232 FastTextAutosizer::FastTextAutosizer(const Document* document) |
233 : m_document(document) | 233 : m_document(document) |
234 , m_frameWidth(0) | 234 , m_frameWidth(0) |
235 , m_layoutWidth(0) | 235 , m_layoutWidth(0) |
236 , m_baseMultiplier(0) | 236 , m_baseMultiplier(0) |
237 , m_pageNeedsAutosizing(false) | 237 , m_pageNeedsAutosizing(false) |
238 , m_previouslyAutosized(false) | 238 , m_previouslyAutosized(false) |
239 , m_updatePageInfoDeferred(false) | |
239 , m_firstBlock(0) | 240 , m_firstBlock(0) |
240 #ifndef NDEBUG | 241 #ifndef NDEBUG |
241 , m_blocksThatHaveBegunLayout() | 242 , m_blocksThatHaveBegunLayout() |
242 #endif | 243 #endif |
243 , m_superclusters() | 244 , m_superclusters() |
244 , m_clusterStack() | 245 , m_clusterStack() |
245 , m_fingerprintMapper() | 246 , m_fingerprintMapper() |
246 { | 247 { |
247 } | 248 } |
248 | 249 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 #ifndef NDEBUG | 284 #ifndef NDEBUG |
284 m_blocksThatHaveBegunLayout.add(block); | 285 m_blocksThatHaveBegunLayout.add(block); |
285 #endif | 286 #endif |
286 if (Cluster* cluster = maybeCreateCluster(block)) | 287 if (Cluster* cluster = maybeCreateCluster(block)) |
287 m_clusterStack.append(adoptPtr(cluster)); | 288 m_clusterStack.append(adoptPtr(cluster)); |
288 } | 289 } |
289 } | 290 } |
290 | 291 |
291 void FastTextAutosizer::beginLayout(RenderBlock* block) | 292 void FastTextAutosizer::beginLayout(RenderBlock* block) |
292 { | 293 { |
293 ASSERT(enabled() && m_pageNeedsAutosizing); | 294 ASSERT(enabled() && m_pageNeedsAutosizing && !m_updatePageInfoDeferred); |
294 #ifndef NDEBUG | 295 #ifndef NDEBUG |
295 m_blocksThatHaveBegunLayout.add(block); | 296 m_blocksThatHaveBegunLayout.add(block); |
296 #endif | 297 #endif |
297 | 298 |
298 if (!m_firstBlock) { | 299 if (!m_firstBlock) { |
299 m_firstBlock = block; | 300 m_firstBlock = block; |
300 prepareClusterStack(block->parent()); | 301 prepareClusterStack(block->parent()); |
301 } else if (block == currentCluster()->m_root) { | 302 } else if (block == currentCluster()->m_root) { |
302 // Ignore beginLayout on the same block twice. | 303 // Ignore beginLayout on the same block twice. |
303 // This can happen with paginated overflow. | 304 // This can happen with paginated overflow. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 ASSERT(m_document->frame()->isMainFrame()); | 433 ASSERT(m_document->frame()->isMainFrame()); |
433 | 434 |
434 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().t raverseNext()) { | 435 for (LocalFrame* frame = m_document->frame(); frame; frame = frame->tree().t raverseNext()) { |
435 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi zer()) | 436 if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosi zer()) |
436 textAutosizer->updatePageInfo(); | 437 textAutosizer->updatePageInfo(); |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 void FastTextAutosizer::updatePageInfo() | 441 void FastTextAutosizer::updatePageInfo() |
441 { | 442 { |
442 if (!enabled()) | 443 if (!enabled() || m_updatePageInfoDeferred) |
443 return; | 444 return; |
444 | 445 |
445 int previousFrameWidth = m_frameWidth; | 446 int previousFrameWidth = m_frameWidth; |
446 int previousLayoutWidth = m_layoutWidth; | 447 int previousLayoutWidth = m_layoutWidth; |
447 float previousBaseMultiplier = m_baseMultiplier; | 448 float previousBaseMultiplier = m_baseMultiplier; |
448 | 449 |
449 RenderView* renderView = toRenderView(m_document->renderer()); | 450 RenderView* renderView = toRenderView(m_document->renderer()); |
450 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->wr itingMode()); | 451 bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->wr itingMode()); |
451 | 452 |
452 LocalFrame* mainFrame = m_document->page()->mainFrame(); | 453 LocalFrame* mainFrame = m_document->page()->mainFrame(); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
980 else | 981 else |
981 m_textAutosizer = 0; | 982 m_textAutosizer = 0; |
982 } | 983 } |
983 | 984 |
984 FastTextAutosizer::LayoutScope::~LayoutScope() | 985 FastTextAutosizer::LayoutScope::~LayoutScope() |
985 { | 986 { |
986 if (m_textAutosizer) | 987 if (m_textAutosizer) |
987 m_textAutosizer->endLayout(m_block); | 988 m_textAutosizer->endLayout(m_block); |
988 } | 989 } |
989 | 990 |
991 FastTextAutosizer::DeferUpdatePageInfo::DeferUpdatePageInfo(Page* page) | |
992 : m_mainFrame(page->mainFrame()) | |
993 { | |
994 if (!m_mainFrame) | |
995 return; | |
996 | |
997 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto sizer()) | |
998 textAutosizer->m_updatePageInfoDeferred = true; | |
999 } | |
1000 | |
1001 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() | |
1002 { | |
pdr.
2014/03/25 22:23:45
Should we bail here if !m_mainFrame?
skobes
2014/03/26 00:36:50
Good catch, done.
| |
1003 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto sizer()) { | |
pdr.
2014/03/25 22:23:45
I'm a little worried about use-after-frees of m_ma
skobes
2014/03/26 00:36:50
Done.
| |
1004 textAutosizer->m_updatePageInfoDeferred = false; | |
1005 textAutosizer->updatePageInfoInAllFrames(); | |
1006 } | |
1007 } | |
1008 | |
990 } // namespace WebCore | 1009 } // namespace WebCore |
OLD | NEW |