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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rebased :\ Created 6 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 , m_registrationContext(initializer.registrationContext(this)) 443 , m_registrationContext(initializer.registrationContext(this))
444 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red) 444 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red)
445 #ifndef NDEBUG 445 #ifndef NDEBUG
446 , m_didDispatchViewportPropertiesChanged(false) 446 , m_didDispatchViewportPropertiesChanged(false)
447 #endif 447 #endif
448 , m_animationClock(AnimationClock::create()) 448 , m_animationClock(AnimationClock::create())
449 , m_timeline(DocumentTimeline::create(this)) 449 , m_timeline(DocumentTimeline::create(this))
450 , m_transitionTimeline(TransitionTimeline::create(this)) 450 , m_transitionTimeline(TransitionTimeline::create(this))
451 , m_templateDocumentHost(0) 451 , m_templateDocumentHost(0)
452 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 452 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
453 , m_hasViewportUnits(false)
453 { 454 {
454 setClient(this); 455 setClient(this);
455 ScriptWrappable::init(this); 456 ScriptWrappable::init(this);
456 457
457 if (m_frame) { 458 if (m_frame) {
458 provideContextFeaturesToDocumentFrom(this, m_frame->page()); 459 provideContextFeaturesToDocumentFrom(this, m_frame->page());
459 460
460 m_fetcher = m_frame->loader().activeDocumentLoader()->fetcher(); 461 m_fetcher = m_frame->loader().activeDocumentLoader()->fetcher();
461 } 462 }
462 463
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 } 1893 }
1893 1894
1894 bool Document::isPageBoxVisible(int pageIndex) 1895 bool Document::isPageBoxVisible(int pageIndex)
1895 { 1896 {
1896 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page. 1897 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
1897 } 1898 }
1898 1899
1899 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) 1900 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
1900 { 1901 {
1901 RefPtr<RenderStyle> style = styleForPage(pageIndex); 1902 RefPtr<RenderStyle> style = styleForPage(pageIndex);
1902 RenderView* view = renderView();
1903 1903
1904 int width = pageSize.width(); 1904 int width = pageSize.width();
1905 int height = pageSize.height(); 1905 int height = pageSize.height();
1906 switch (style->pageSizeType()) { 1906 switch (style->pageSizeType()) {
1907 case PAGE_SIZE_AUTO: 1907 case PAGE_SIZE_AUTO:
1908 break; 1908 break;
1909 case PAGE_SIZE_AUTO_LANDSCAPE: 1909 case PAGE_SIZE_AUTO_LANDSCAPE:
1910 if (width < height) 1910 if (width < height)
1911 std::swap(width, height); 1911 std::swap(width, height);
1912 break; 1912 break;
1913 case PAGE_SIZE_AUTO_PORTRAIT: 1913 case PAGE_SIZE_AUTO_PORTRAIT:
1914 if (width > height) 1914 if (width > height)
1915 std::swap(width, height); 1915 std::swap(width, height);
1916 break; 1916 break;
1917 case PAGE_SIZE_RESOLVED: { 1917 case PAGE_SIZE_RESOLVED: {
1918 LengthSize size = style->pageSize(); 1918 LengthSize size = style->pageSize();
1919 ASSERT(size.width().isFixed()); 1919 ASSERT(size.width().isFixed());
1920 ASSERT(size.height().isFixed()); 1920 ASSERT(size.height().isFixed());
1921 width = valueForLength(size.width(), 0, view); 1921 width = valueForLength(size.width(), 0);
1922 height = valueForLength(size.height(), 0, view); 1922 height = valueForLength(size.height(), 0);
1923 break; 1923 break;
1924 } 1924 }
1925 default: 1925 default:
1926 ASSERT_NOT_REACHED(); 1926 ASSERT_NOT_REACHED();
1927 } 1927 }
1928 pageSize = IntSize(width, height); 1928 pageSize = IntSize(width, height);
1929 1929
1930 // The percentage is calculated with respect to the width even for margin to p and bottom. 1930 // The percentage is calculated with respect to the width even for margin to p and bottom.
1931 // http://www.w3.org/TR/CSS2/box.html#margin-properties 1931 // http://www.w3.org/TR/CSS2/box.html#margin-properties
1932 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width, view); 1932 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width);
1933 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width, view); 1933 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width);
1934 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width, view); 1934 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width);
1935 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width, view); 1935 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width);
1936 } 1936 }
1937 1937
1938 void Document::setIsViewSource(bool isViewSource) 1938 void Document::setIsViewSource(bool isViewSource)
1939 { 1939 {
1940 m_isViewSource = isViewSource; 1940 m_isViewSource = isViewSource;
1941 if (!m_isViewSource) 1941 if (!m_isViewSource)
1942 return; 1942 return;
1943 1943
1944 setSecurityOrigin(SecurityOrigin::createUnique()); 1944 setSecurityOrigin(SecurityOrigin::createUnique());
1945 didUpdateSecurityOrigin(); 1945 didUpdateSecurityOrigin();
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 m_styleEngine->setSelectedStylesheetSetName(aString); 3193 m_styleEngine->setSelectedStylesheetSetName(aString);
3194 styleResolverChanged(RecalcStyleDeferred); 3194 styleResolverChanged(RecalcStyleDeferred);
3195 } 3195 }
3196 3196
3197 void Document::evaluateMediaQueryList() 3197 void Document::evaluateMediaQueryList()
3198 { 3198 {
3199 if (m_mediaQueryMatcher) 3199 if (m_mediaQueryMatcher)
3200 m_mediaQueryMatcher->styleResolverChanged(); 3200 m_mediaQueryMatcher->styleResolverChanged();
3201 } 3201 }
3202 3202
3203 void Document::notifyResizeForViewportUnits()
3204 {
3205 if (!hasViewportUnits())
3206 return;
3207 ensureStyleResolver().notifyResizeForViewportUnits();
3208 setNeedsStyleRecalcForViewportUnits();
3209 }
3210
3203 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode) 3211 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode)
3204 { 3212 {
3205 // styleResolverChanged() can be invoked during Document destruction. 3213 // styleResolverChanged() can be invoked during Document destruction.
3206 // We just skip that case. 3214 // We just skip that case.
3207 if (!m_styleEngine) 3215 if (!m_styleEngine)
3208 return; 3216 return;
3209 3217
3210 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode); 3218 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode);
3211 if (change.needsRepaint()) { 3219 if (change.needsRepaint()) {
3212 // We need to manually repaint because we avoid doing all repaints in la yout or style 3220 // We need to manually repaint because we avoid doing all repaints in la yout or style
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
5272 } 5280 }
5273 5281
5274 FastTextAutosizer* Document::fastTextAutosizer() 5282 FastTextAutosizer* Document::fastTextAutosizer()
5275 { 5283 {
5276 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5284 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5277 m_fastTextAutosizer = FastTextAutosizer::create(this); 5285 m_fastTextAutosizer = FastTextAutosizer::create(this);
5278 return m_fastTextAutosizer.get(); 5286 return m_fastTextAutosizer.get();
5279 } 5287 }
5280 5288
5281 } // namespace WebCore 5289 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698