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

Side by Side Diff: Source/core/layout/LayoutTextControlSingleLine.cpp

Issue 1025213002: Begin tracking why layout is invalidated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutText.cpp ('k') | Source/core/layout/LayoutVideo.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) 2006, 2007, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // and type=search if the text height is taller than the contentHeight() 108 // and type=search if the text height is taller than the contentHeight()
109 // because of compability. 109 // because of compability.
110 110
111 LayoutBox* innerEditorRenderer = innerEditorElement()->layoutBox(); 111 LayoutBox* innerEditorRenderer = innerEditorElement()->layoutBox();
112 bool innerEditorRendererHadLayout = innerEditorRenderer && innerEditorRender er->needsLayout(); 112 bool innerEditorRendererHadLayout = innerEditorRenderer && innerEditorRender er->needsLayout();
113 LayoutBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem ent()->layoutBox() : 0; 113 LayoutBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem ent()->layoutBox() : 0;
114 114
115 // To ensure consistency between layouts, we need to reset any conditionally overriden height. 115 // To ensure consistency between layouts, we need to reset any conditionally overriden height.
116 if (innerEditorRenderer && !innerEditorRenderer->styleRef().logicalHeight(). isAuto()) { 116 if (innerEditorRenderer && !innerEditorRenderer->styleRef().logicalHeight(). isAuto()) {
117 innerEditorRenderer->mutableStyleRef().setLogicalHeight(Length(Auto)); 117 innerEditorRenderer->mutableStyleRef().setLogicalHeight(Length(Auto));
118 layoutScope.setNeedsLayout(innerEditorRenderer); 118 layoutScope.setNeedsLayout(innerEditorRenderer, LayoutInvalidationReason ::TextControlChanged);
119 HTMLElement* placeholderElement = inputElement()->placeholderElement(); 119 HTMLElement* placeholderElement = inputElement()->placeholderElement();
120 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement- >layoutBox() : 0) 120 if (LayoutBox* placeholderBox = placeholderElement ? placeholderElement- >layoutBox() : 0)
121 layoutScope.setNeedsLayout(placeholderBox); 121 layoutScope.setNeedsLayout(placeholderBox, LayoutInvalidationReason: :TextControlChanged);
122 } 122 }
123 if (viewPortRenderer && !viewPortRenderer->styleRef().logicalHeight().isAuto ()) { 123 if (viewPortRenderer && !viewPortRenderer->styleRef().logicalHeight().isAuto ()) {
124 viewPortRenderer->mutableStyleRef().setLogicalHeight(Length(Auto)); 124 viewPortRenderer->mutableStyleRef().setLogicalHeight(Length(Auto));
125 layoutScope.setNeedsLayout(viewPortRenderer); 125 layoutScope.setNeedsLayout(viewPortRenderer, LayoutInvalidationReason::T extControlChanged);
126 } 126 }
127 127
128 LayoutBlockFlow::layoutBlock(false); 128 LayoutBlockFlow::layoutBlock(false);
129 129
130 Element* container = containerElement(); 130 Element* container = containerElement();
131 LayoutBox* containerRenderer = container ? container->layoutBox() : 0; 131 LayoutBox* containerRenderer = container ? container->layoutBox() : 0;
132 132
133 // Set the text block height 133 // Set the text block height
134 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight(); 134 LayoutUnit desiredLogicalHeight = textBlockLogicalHeight();
135 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit(); 135 LayoutUnit logicalHeightLimit = computeLogicalHeightLimit();
136 if (innerEditorRenderer && innerEditorRenderer->logicalHeight() > logicalHei ghtLimit) { 136 if (innerEditorRenderer && innerEditorRenderer->logicalHeight() > logicalHei ghtLimit) {
137 if (desiredLogicalHeight != innerEditorRenderer->logicalHeight()) 137 if (desiredLogicalHeight != innerEditorRenderer->logicalHeight())
138 layoutScope.setNeedsLayout(this); 138 layoutScope.setNeedsLayout(this, LayoutInvalidationReason::TextContr olChanged);
139 139
140 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight; 140 m_desiredInnerEditorLogicalHeight = desiredLogicalHeight;
141 141
142 innerEditorRenderer->mutableStyleRef().setLogicalHeight(Length(desiredLo gicalHeight, Fixed)); 142 innerEditorRenderer->mutableStyleRef().setLogicalHeight(Length(desiredLo gicalHeight, Fixed));
143 layoutScope.setNeedsLayout(innerEditorRenderer); 143 layoutScope.setNeedsLayout(innerEditorRenderer, LayoutInvalidationReason ::TextControlChanged);
144 if (viewPortRenderer) { 144 if (viewPortRenderer) {
145 viewPortRenderer->mutableStyleRef().setLogicalHeight(Length(desiredL ogicalHeight, Fixed)); 145 viewPortRenderer->mutableStyleRef().setLogicalHeight(Length(desiredL ogicalHeight, Fixed));
146 layoutScope.setNeedsLayout(viewPortRenderer); 146 layoutScope.setNeedsLayout(viewPortRenderer, LayoutInvalidationReaso n::TextControlChanged);
147 } 147 }
148 } 148 }
149 // The container might be taller because of decoration elements. 149 // The container might be taller because of decoration elements.
150 if (containerRenderer) { 150 if (containerRenderer) {
151 containerRenderer->layoutIfNeeded(); 151 containerRenderer->layoutIfNeeded();
152 LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight(); 152 LayoutUnit containerLogicalHeight = containerRenderer->logicalHeight();
153 if (containerLogicalHeight > logicalHeightLimit) { 153 if (containerLogicalHeight > logicalHeightLimit) {
154 containerRenderer->mutableStyleRef().setLogicalHeight(Length(logical HeightLimit, Fixed)); 154 containerRenderer->mutableStyleRef().setLogicalHeight(Length(logical HeightLimit, Fixed));
155 layoutScope.setNeedsLayout(this); 155 layoutScope.setNeedsLayout(this, LayoutInvalidationReason::TextContr olChanged);
156 } else if (containerRenderer->logicalHeight() < contentLogicalHeight()) { 156 } else if (containerRenderer->logicalHeight() < contentLogicalHeight()) {
157 containerRenderer->mutableStyleRef().setLogicalHeight(Length(content LogicalHeight(), Fixed)); 157 containerRenderer->mutableStyleRef().setLogicalHeight(Length(content LogicalHeight(), Fixed));
158 layoutScope.setNeedsLayout(this); 158 layoutScope.setNeedsLayout(this, LayoutInvalidationReason::TextContr olChanged);
159 } else { 159 } else {
160 containerRenderer->mutableStyleRef().setLogicalHeight(Length(contain erLogicalHeight, Fixed)); 160 containerRenderer->mutableStyleRef().setLogicalHeight(Length(contain erLogicalHeight, Fixed));
161 } 161 }
162 } 162 }
163 163
164 // We ensure that the inner editor renderer is laid out at least once. This is 164 // We ensure that the inner editor renderer is laid out at least once. This is
165 // required as the logic below assumes that we don't carry over previous lay out values. 165 // required as the logic below assumes that we don't carry over previous lay out values.
166 if (innerEditorRenderer && !innerEditorRendererHadLayout) 166 if (innerEditorRenderer && !innerEditorRendererHadLayout)
167 layoutScope.setNeedsLayout(innerEditorRenderer); 167 layoutScope.setNeedsLayout(innerEditorRenderer, LayoutInvalidationReason ::TextControlChanged);
168 168
169 // If we need another layout pass, we have changed one of children's height so we need to relayout them. 169 // If we need another layout pass, we have changed one of children's height so we need to relayout them.
170 if (needsLayout()) 170 if (needsLayout())
171 LayoutBlockFlow::layoutBlock(true); 171 LayoutBlockFlow::layoutBlock(true);
172 172
173 // Center the child block in the block progression direction (vertical cente ring for horizontal text fields). 173 // Center the child block in the block progression direction (vertical cente ring for horizontal text fields).
174 if (!container && innerEditorRenderer && innerEditorRenderer->size().height( ) != contentLogicalHeight()) { 174 if (!container && innerEditorRenderer && innerEditorRenderer->size().height( ) != contentLogicalHeight()) {
175 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co ntentLogicalHeight(); 175 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co ntentLogicalHeight();
176 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - ( logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2))); 176 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - ( logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
177 } else { 177 } else {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 viewPortRenderer->mutableStyleRef().setHeight(Length()); 239 viewPortRenderer->mutableStyleRef().setHeight(Length());
240 viewPortRenderer->mutableStyleRef().setWidth(Length()); 240 viewPortRenderer->mutableStyleRef().setWidth(Length());
241 } 241 }
242 Element* container = containerElement(); 242 Element* container = containerElement();
243 if (LayoutObject* containerRenderer = container ? container->layoutObject() : 0) { 243 if (LayoutObject* containerRenderer = container ? container->layoutObject() : 0) {
244 containerRenderer->mutableStyleRef().setHeight(Length()); 244 containerRenderer->mutableStyleRef().setHeight(Length());
245 containerRenderer->mutableStyleRef().setWidth(Length()); 245 containerRenderer->mutableStyleRef().setWidth(Length());
246 } 246 }
247 LayoutObject* innerEditorRenderer = innerEditorElement()->layoutObject(); 247 LayoutObject* innerEditorRenderer = innerEditorElement()->layoutObject();
248 if (innerEditorRenderer && diff.needsFullLayout()) 248 if (innerEditorRenderer && diff.needsFullLayout())
249 innerEditorRenderer->setNeedsLayoutAndFullPaintInvalidation(); 249 innerEditorRenderer->setNeedsLayoutAndFullPaintInvalidation(LayoutInvali dationReason::StyleChange);
250 if (HTMLElement* placeholder = inputElement()->placeholderElement()) 250 if (HTMLElement* placeholder = inputElement()->placeholderElement())
251 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB eTruncated() ? CSSValueEllipsis : CSSValueClip); 251 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldB eTruncated() ? CSSValueEllipsis : CSSValueClip);
252 setHasOverflowClip(false); 252 setHasOverflowClip(false);
253 } 253 }
254 254
255 void LayoutTextControlSingleLine::capsLockStateMayHaveChanged() 255 void LayoutTextControlSingleLine::capsLockStateMayHaveChanged()
256 { 256 {
257 if (!node()) 257 if (!node())
258 return; 258 return;
259 259
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (innerEditorElement()) 431 if (innerEditorElement())
432 innerEditorElement()->setScrollTop(newTop); 432 innerEditorElement()->setScrollTop(newTop);
433 } 433 }
434 434
435 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const 435 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const
436 { 436 {
437 return toHTMLInputElement(node()); 437 return toHTMLInputElement(node());
438 } 438 }
439 439
440 } 440 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutText.cpp ('k') | Source/core/layout/LayoutVideo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698