Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3158 m_styleEngine->setSelectedStylesheetSetName(aString); | 3158 m_styleEngine->setSelectedStylesheetSetName(aString); |
| 3159 styleResolverChanged(RecalcStyleDeferred); | 3159 styleResolverChanged(RecalcStyleDeferred); |
| 3160 } | 3160 } |
| 3161 | 3161 |
| 3162 void Document::evaluateMediaQueryList() | 3162 void Document::evaluateMediaQueryList() |
| 3163 { | 3163 { |
| 3164 if (m_mediaQueryMatcher) | 3164 if (m_mediaQueryMatcher) |
| 3165 m_mediaQueryMatcher->styleResolverChanged(); | 3165 m_mediaQueryMatcher->styleResolverChanged(); |
| 3166 } | 3166 } |
| 3167 | 3167 |
| 3168 void Document::notifyResizeForViewportUnits() | |
| 3169 { | |
| 3170 if (!hasViewportUnits()) | |
| 3171 return; | |
| 3172 ensureStyleResolver().notifyResizeForViewportUnits(); | |
|
esprehn
2013/12/18 01:03:55
Do you really need to force creation of the style
Timothy Loh
2013/12/18 01:54:43
I think the only case where we won't end up creati
| |
| 3173 setNeedsStyleRecalcForViewportUnits(); | |
| 3174 } | |
| 3175 | |
| 3168 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode) | 3176 void Document::styleResolverChanged(RecalcStyleTime updateTime, StyleResolverUpd ateMode updateMode) |
| 3169 { | 3177 { |
| 3170 // styleResolverChanged() can be invoked during Document destruction. | 3178 // styleResolverChanged() can be invoked during Document destruction. |
| 3171 // We just skip that case. | 3179 // We just skip that case. |
| 3172 if (!m_styleEngine) | 3180 if (!m_styleEngine) |
| 3173 return; | 3181 return; |
| 3174 | 3182 |
| 3175 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode); | 3183 StyleResolverChange change = m_styleEngine->resolverChanged(updateTime, upda teMode); |
| 3176 if (change.needsRepaint()) { | 3184 if (change.needsRepaint()) { |
| 3177 // We need to manually repaint because we avoid doing all repaints in la yout or style | 3185 // We need to manually repaint because we avoid doing all repaints in la yout or style |
| (...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5227 } | 5235 } |
| 5228 | 5236 |
| 5229 FastTextAutosizer* Document::fastTextAutosizer() | 5237 FastTextAutosizer* Document::fastTextAutosizer() |
| 5230 { | 5238 { |
| 5231 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) | 5239 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) |
| 5232 m_fastTextAutosizer = FastTextAutosizer::create(this); | 5240 m_fastTextAutosizer = FastTextAutosizer::create(this); |
| 5233 return m_fastTextAutosizer.get(); | 5241 return m_fastTextAutosizer.get(); |
| 5234 } | 5242 } |
| 5235 | 5243 |
| 5236 } // namespace WebCore | 5244 } // namespace WebCore |
| OLD | NEW |