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

Side by Side Diff: Source/core/rendering/RenderScrollbarPart.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rename browser zoom to page zoom 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
« no previous file with comments | « Source/core/rendering/RenderReplaced.cpp ('k') | Source/core/rendering/RenderTable.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 { 81 {
82 if (m_part == ScrollbarBGPart) { 82 if (m_part == ScrollbarBGPart) {
83 computeScrollbarWidth(); 83 computeScrollbarWidth();
84 setHeight(m_scrollbar->height()); 84 setHeight(m_scrollbar->height());
85 } else { 85 } else {
86 setWidth(m_scrollbar->width()); 86 setWidth(m_scrollbar->width());
87 computeScrollbarHeight(); 87 computeScrollbarHeight();
88 } 88 }
89 } 89 }
90 90
91 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength, RenderView* renderView) 91 static int calcScrollbarThicknessUsing(SizeType sizeType, const Length& length, int containingLength)
92 { 92 {
93 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto())) 93 if (!length.isIntrinsicOrAuto() || (sizeType == MinSize && length.isAuto()))
94 return minimumValueForLength(length, containingLength, renderView); 94 return minimumValueForLength(length, containingLength);
95 return ScrollbarTheme::theme()->scrollbarThickness(); 95 return ScrollbarTheme::theme()->scrollbarThickness();
96 } 96 }
97 97
98 void RenderScrollbarPart::computeScrollbarWidth() 98 void RenderScrollbarPart::computeScrollbarWidth()
99 { 99 {
100 if (!m_scrollbar->owningRenderer()) 100 if (!m_scrollbar->owningRenderer())
101 return; 101 return;
102 RenderView* renderView = view();
103 // FIXME: We are querying layout information but nothing guarantees that it' s up-to-date, especially since we are called at style change. 102 // FIXME: We are querying layout information but nothing guarantees that it' s up-to-date, especially since we are called at style change.
104 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders. 103 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
105 int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owni ngRenderer()->style()->borderLeftWidth() - m_scrollbar->owningRenderer()->style( )->borderRightWidth(); 104 int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owni ngRenderer()->style()->borderLeftWidth() - m_scrollbar->owningRenderer()->style( )->borderRightWidth();
106 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v isibleSize, renderView); 105 int w = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->width(), v isibleSize);
107 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis ibleSize, renderView); 106 int minWidth = calcScrollbarThicknessUsing(MinSize, style()->minWidth(), vis ibleSize);
108 int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknes sUsing(MaxSize, style()->maxWidth(), visibleSize, renderView); 107 int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknes sUsing(MaxSize, style()->maxWidth(), visibleSize);
109 setWidth(max(minWidth, min(maxWidth, w))); 108 setWidth(max(minWidth, min(maxWidth, w)));
110 109
111 // Buttons and track pieces can all have margins along the axis of the scrol lbar. 110 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
112 m_marginBox.setLeft(minimumValueForLength(style()->marginLeft(), visibleSize , renderView)); 111 m_marginBox.setLeft(minimumValueForLength(style()->marginLeft(), visibleSize ));
113 m_marginBox.setRight(minimumValueForLength(style()->marginRight(), visibleSi ze, renderView)); 112 m_marginBox.setRight(minimumValueForLength(style()->marginRight(), visibleSi ze));
114 } 113 }
115 114
116 void RenderScrollbarPart::computeScrollbarHeight() 115 void RenderScrollbarPart::computeScrollbarHeight()
117 { 116 {
118 if (!m_scrollbar->owningRenderer()) 117 if (!m_scrollbar->owningRenderer())
119 return; 118 return;
120 RenderView* renderView = view();
121 // FIXME: We are querying layout information but nothing guarantees that it' s up-to-date, especially since we are called at style change. 119 // FIXME: We are querying layout information but nothing guarantees that it' s up-to-date, especially since we are called at style change.
122 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders. 120 // FIXME: Querying the style's border information doesn't work on table cell s with collapsing borders.
123 int visibleSize = m_scrollbar->owningRenderer()->height() - m_scrollbar->ow ningRenderer()->style()->borderTopWidth() - m_scrollbar->owningRenderer()->style ()->borderBottomWidth(); 121 int visibleSize = m_scrollbar->owningRenderer()->height() - m_scrollbar->ow ningRenderer()->style()->borderTopWidth() - m_scrollbar->owningRenderer()->style ()->borderBottomWidth();
124 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), visibleSize, renderView); 122 int h = calcScrollbarThicknessUsing(MainOrPreferredSize, style()->height(), visibleSize);
125 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v isibleSize, renderView); 123 int minHeight = calcScrollbarThicknessUsing(MinSize, style()->minHeight(), v isibleSize);
126 int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThickn essUsing(MaxSize, style()->maxHeight(), visibleSize, renderView); 124 int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThickn essUsing(MaxSize, style()->maxHeight(), visibleSize);
127 setHeight(max(minHeight, min(maxHeight, h))); 125 setHeight(max(minHeight, min(maxHeight, h)));
128 126
129 // Buttons and track pieces can all have margins along the axis of the scrol lbar. 127 // Buttons and track pieces can all have margins along the axis of the scrol lbar.
130 m_marginBox.setTop(minimumValueForLength(style()->marginTop(), visibleSize, renderView)); 128 m_marginBox.setTop(minimumValueForLength(style()->marginTop(), visibleSize)) ;
131 m_marginBox.setBottom(minimumValueForLength(style()->marginBottom(), visible Size, renderView)); 129 m_marginBox.setBottom(minimumValueForLength(style()->marginBottom(), visible Size));
132 } 130 }
133 131
134 void RenderScrollbarPart::computePreferredLogicalWidths() 132 void RenderScrollbarPart::computePreferredLogicalWidths()
135 { 133 {
136 if (!preferredLogicalWidthsDirty()) 134 if (!preferredLogicalWidthsDirty())
137 return; 135 return;
138 136
139 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0; 137 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
140 138
141 clearPreferredLogicalWidthsDirty(); 139 clearPreferredLogicalWidthsDirty();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 196 }
199 197
200 RenderObject* RenderScrollbarPart::rendererOwningScrollbar() const 198 RenderObject* RenderScrollbarPart::rendererOwningScrollbar() const
201 { 199 {
202 if (!m_scrollbar) 200 if (!m_scrollbar)
203 return 0; 201 return 0;
204 return m_scrollbar->owningRenderer(); 202 return m_scrollbar->owningRenderer();
205 } 203 }
206 204
207 } 205 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderReplaced.cpp ('k') | Source/core/rendering/RenderTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698