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

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 7 years 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 , m_registrationContext(initializer.registrationContext(this)) 441 , m_registrationContext(initializer.registrationContext(this))
442 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red) 442 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red)
443 #ifndef NDEBUG 443 #ifndef NDEBUG
444 , m_didDispatchViewportPropertiesChanged(false) 444 , m_didDispatchViewportPropertiesChanged(false)
445 #endif 445 #endif
446 , m_animationClock(AnimationClock::create()) 446 , m_animationClock(AnimationClock::create())
447 , m_timeline(DocumentTimeline::create(this)) 447 , m_timeline(DocumentTimeline::create(this))
448 , m_transitionTimeline(TransitionTimeline::create(this)) 448 , m_transitionTimeline(TransitionTimeline::create(this))
449 , m_templateDocumentHost(0) 449 , m_templateDocumentHost(0)
450 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 450 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
451 , m_hasViewportUnits(false)
451 { 452 {
452 setClient(this); 453 setClient(this);
453 ScriptWrappable::init(this); 454 ScriptWrappable::init(this);
454 455
455 if (m_frame) { 456 if (m_frame) {
456 provideContextFeaturesToDocumentFrom(this, m_frame->page()); 457 provideContextFeaturesToDocumentFrom(this, m_frame->page());
457 458
458 m_fetcher = m_frame->loader().activeDocumentLoader()->fetcher(); 459 m_fetcher = m_frame->loader().activeDocumentLoader()->fetcher();
459 } 460 }
460 461
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 } 1873 }
1873 1874
1874 bool Document::isPageBoxVisible(int pageIndex) 1875 bool Document::isPageBoxVisible(int pageIndex)
1875 { 1876 {
1876 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page. 1877 return styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
1877 } 1878 }
1878 1879
1879 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) 1880 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
1880 { 1881 {
1881 RefPtr<RenderStyle> style = styleForPage(pageIndex); 1882 RefPtr<RenderStyle> style = styleForPage(pageIndex);
1882 RenderView* view = renderView();
1883 1883
1884 int width = pageSize.width(); 1884 int width = pageSize.width();
1885 int height = pageSize.height(); 1885 int height = pageSize.height();
1886 switch (style->pageSizeType()) { 1886 switch (style->pageSizeType()) {
1887 case PAGE_SIZE_AUTO: 1887 case PAGE_SIZE_AUTO:
1888 break; 1888 break;
1889 case PAGE_SIZE_AUTO_LANDSCAPE: 1889 case PAGE_SIZE_AUTO_LANDSCAPE:
1890 if (width < height) 1890 if (width < height)
1891 std::swap(width, height); 1891 std::swap(width, height);
1892 break; 1892 break;
1893 case PAGE_SIZE_AUTO_PORTRAIT: 1893 case PAGE_SIZE_AUTO_PORTRAIT:
1894 if (width > height) 1894 if (width > height)
1895 std::swap(width, height); 1895 std::swap(width, height);
1896 break; 1896 break;
1897 case PAGE_SIZE_RESOLVED: { 1897 case PAGE_SIZE_RESOLVED: {
1898 LengthSize size = style->pageSize(); 1898 LengthSize size = style->pageSize();
1899 ASSERT(size.width().isFixed()); 1899 ASSERT(size.width().isFixed());
1900 ASSERT(size.height().isFixed()); 1900 ASSERT(size.height().isFixed());
1901 width = valueForLength(size.width(), 0, view); 1901 width = valueForLength(size.width(), 0);
1902 height = valueForLength(size.height(), 0, view); 1902 height = valueForLength(size.height(), 0);
1903 break; 1903 break;
1904 } 1904 }
1905 default: 1905 default:
1906 ASSERT_NOT_REACHED(); 1906 ASSERT_NOT_REACHED();
1907 } 1907 }
1908 pageSize = IntSize(width, height); 1908 pageSize = IntSize(width, height);
1909 1909
1910 // The percentage is calculated with respect to the width even for margin to p and bottom. 1910 // The percentage is calculated with respect to the width even for margin to p and bottom.
1911 // http://www.w3.org/TR/CSS2/box.html#margin-properties 1911 // http://www.w3.org/TR/CSS2/box.html#margin-properties
1912 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width, view); 1912 marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(styl e->marginTop(), width);
1913 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width, view); 1913 marginRight = style->marginRight().isAuto() ? marginRight : intValueForLengt h(style->marginRight(), width);
1914 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width, view); 1914 marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLe ngth(style->marginBottom(), width);
1915 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width, view); 1915 marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(s tyle->marginLeft(), width);
1916 } 1916 }
1917 1917
1918 void Document::setIsViewSource(bool isViewSource) 1918 void Document::setIsViewSource(bool isViewSource)
1919 { 1919 {
1920 m_isViewSource = isViewSource; 1920 m_isViewSource = isViewSource;
1921 if (!m_isViewSource) 1921 if (!m_isViewSource)
1922 return; 1922 return;
1923 1923
1924 setSecurityOrigin(SecurityOrigin::createUnique()); 1924 setSecurityOrigin(SecurityOrigin::createUnique());
1925 didUpdateSecurityOrigin(); 1925 didUpdateSecurityOrigin();
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 m_styleEngine->setSelectedStylesheetSetName(aString); 3167 m_styleEngine->setSelectedStylesheetSetName(aString);
3168 styleResolverChanged(RecalcStyleDeferred); 3168 styleResolverChanged(RecalcStyleDeferred);
3169 } 3169 }
3170 3170
3171 void Document::evaluateMediaQueryList() 3171 void Document::evaluateMediaQueryList()
3172 { 3172 {
3173 if (m_mediaQueryMatcher) 3173 if (m_mediaQueryMatcher)
3174 m_mediaQueryMatcher->styleResolverChanged(); 3174 m_mediaQueryMatcher->styleResolverChanged();
3175 } 3175 }
3176 3176
3177 void Document::notifyResizeForViewportUnits()
3178 {
3179 if (!hasViewportUnits())
3180 return;
3181 ensureStyleResolver().notifyResizeForViewportUnits();
3182 setNeedsStyleRecalcForViewportUnits();
3183 }
3184
3177 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode) 3185 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode)
3178 { 3186 {
3179 // styleResolverChanged() can be invoked during Document destruction. 3187 // styleResolverChanged() can be invoked during Document destruction.
3180 // We just skip that case. 3188 // We just skip that case.
3181 if (!m_styleEngine) 3189 if (!m_styleEngine)
3182 return; 3190 return;
3183 3191
3184 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode); 3192 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode);
3185 if (change.needsRepaint()) { 3193 if (change.needsRepaint()) {
3186 // We need to manually repaint because we avoid doing all repaints in la yout or style 3194 // We need to manually repaint because we avoid doing all repaints in la yout or style
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 } 5234 }
5227 5235
5228 FastTextAutosizer* Document::fastTextAutosizer() 5236 FastTextAutosizer* Document::fastTextAutosizer()
5229 { 5237 {
5230 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5238 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5231 m_fastTextAutosizer = FastTextAutosizer::create(this); 5239 m_fastTextAutosizer = FastTextAutosizer::create(this);
5232 return m_fastTextAutosizer.get(); 5240 return m_fastTextAutosizer.get();
5233 } 5241 }
5234 5242
5235 } // namespace WebCore 5243 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698