Chromium Code Reviews| Index: Source/core/rendering/FastTextAutosizer.cpp |
| diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp |
| index b78ade35f56f76f09015361ce9402db3f1f151a2..b6806941b5991e0f89201497654c887b6b775335 100644 |
| --- a/Source/core/rendering/FastTextAutosizer.cpp |
| +++ b/Source/core/rendering/FastTextAutosizer.cpp |
| @@ -236,6 +236,7 @@ FastTextAutosizer::FastTextAutosizer(const Document* document) |
| , m_baseMultiplier(0) |
| , m_pageNeedsAutosizing(false) |
| , m_previouslyAutosized(false) |
| + , m_updatePageInfoDeferred(false) |
| , m_firstBlock(0) |
| #ifndef NDEBUG |
| , m_blocksThatHaveBegunLayout() |
| @@ -290,7 +291,7 @@ void FastTextAutosizer::prepareClusterStack(const RenderObject* renderer) |
| void FastTextAutosizer::beginLayout(RenderBlock* block) |
| { |
| - ASSERT(enabled() && m_pageNeedsAutosizing); |
| + ASSERT(enabled() && m_pageNeedsAutosizing && !m_updatePageInfoDeferred); |
| #ifndef NDEBUG |
| m_blocksThatHaveBegunLayout.add(block); |
| #endif |
| @@ -439,7 +440,7 @@ void FastTextAutosizer::updatePageInfoInAllFrames() |
| void FastTextAutosizer::updatePageInfo() |
| { |
| - if (!enabled()) |
| + if (!enabled() || m_updatePageInfoDeferred) |
| return; |
| int previousFrameWidth = m_frameWidth; |
| @@ -987,4 +988,22 @@ FastTextAutosizer::LayoutScope::~LayoutScope() |
| m_textAutosizer->endLayout(m_block); |
| } |
| +FastTextAutosizer::DeferUpdatePageInfo::DeferUpdatePageInfo(Page* page) |
| + : m_mainFrame(page->mainFrame()) |
| +{ |
| + if (!m_mainFrame) |
| + return; |
| + |
| + if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAutosizer()) |
| + textAutosizer->m_updatePageInfoDeferred = true; |
| +} |
| + |
| +FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() |
| +{ |
|
pdr.
2014/03/25 22:23:45
Should we bail here if !m_mainFrame?
skobes
2014/03/26 00:36:50
Good catch, done.
|
| + if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAutosizer()) { |
|
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.
|
| + textAutosizer->m_updatePageInfoDeferred = false; |
| + textAutosizer->updatePageInfoInAllFrames(); |
| + } |
| +} |
| + |
| } // namespace WebCore |