Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1343)

Unified Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 209413002: Avoid unnecessary invalidations on resize. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@crap
Patch Set: Assert !m_updatePageInfoDeferred in beginLayout. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698