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

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

Issue 709613003: To ensure consistency between layouts, we need to reset any overriden top for centering the textfie… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updates Created 6 years, 1 month 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) 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 26 matching lines...) Expand all
37 #include "platform/fonts/SimpleFontData.h" 37 #include "platform/fonts/SimpleFontData.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 using namespace HTMLNames; 41 using namespace HTMLNames;
42 42
43 RenderTextControlSingleLine::RenderTextControlSingleLine(HTMLInputElement* eleme nt) 43 RenderTextControlSingleLine::RenderTextControlSingleLine(HTMLInputElement* eleme nt)
44 : RenderTextControl(element) 44 : RenderTextControl(element)
45 , m_shouldDrawCapsLockIndicator(false) 45 , m_shouldDrawCapsLockIndicator(false)
46 , m_desiredInnerEditorLogicalHeight(-1) 46 , m_desiredInnerEditorLogicalHeight(-1)
47 , m_hasOverridenInnerEditorLogicalTop(false)
47 { 48 {
48 } 49 }
49 50
50 RenderTextControlSingleLine::~RenderTextControlSingleLine() 51 RenderTextControlSingleLine::~RenderTextControlSingleLine()
51 { 52 {
52 } 53 }
53 54
54 inline Element* RenderTextControlSingleLine::containerElement() const 55 inline Element* RenderTextControlSingleLine::containerElement() const
55 { 56 {
56 return inputElement()->userAgentShadowRoot()->getElementById(ShadowElementNa mes::textFieldContainer()); 57 return inputElement()->userAgentShadowRoot()->getElementById(ShadowElementNa mes::textFieldContainer());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 RenderBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem ent()->renderBox() : 0; 110 RenderBox* viewPortRenderer = editingViewPortElement() ? editingViewPortElem ent()->renderBox() : 0;
110 111
111 // To ensure consistency between layouts, we need to reset any conditionally overriden height. 112 // To ensure consistency between layouts, we need to reset any conditionally overriden height.
112 if (innerEditorRenderer && !innerEditorRenderer->style()->logicalHeight().is Auto()) { 113 if (innerEditorRenderer && !innerEditorRenderer->style()->logicalHeight().is Auto()) {
113 innerEditorRenderer->style()->setLogicalHeight(Length(Auto)); 114 innerEditorRenderer->style()->setLogicalHeight(Length(Auto));
114 layoutScope.setNeedsLayout(innerEditorRenderer); 115 layoutScope.setNeedsLayout(innerEditorRenderer);
115 HTMLElement* placeholderElement = inputElement()->placeholderElement(); 116 HTMLElement* placeholderElement = inputElement()->placeholderElement();
116 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement- >renderBox() : 0) 117 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement- >renderBox() : 0)
117 layoutScope.setNeedsLayout(placeholderBox); 118 layoutScope.setNeedsLayout(placeholderBox);
118 } 119 }
120 if (m_hasOverridenInnerEditorLogicalTop) {
121 layoutScope.setNeedsLayout(innerEditorRenderer);
122 m_hasOverridenInnerEditorLogicalTop = false;
123 }
119 if (viewPortRenderer && !viewPortRenderer->style()->logicalHeight().isAuto() ) { 124 if (viewPortRenderer && !viewPortRenderer->style()->logicalHeight().isAuto() ) {
120 viewPortRenderer->style()->setLogicalHeight(Length(Auto)); 125 viewPortRenderer->style()->setLogicalHeight(Length(Auto));
121 layoutScope.setNeedsLayout(viewPortRenderer); 126 layoutScope.setNeedsLayout(viewPortRenderer);
122 } 127 }
123 128
124 RenderBlockFlow::layoutBlock(false); 129 RenderBlockFlow::layoutBlock(false);
125 130
126 Element* container = containerElement(); 131 Element* container = containerElement();
127 RenderBox* containerRenderer = container ? container->renderBox() : 0; 132 RenderBox* containerRenderer = container ? container->renderBox() : 0;
128 133
(...skipping 28 matching lines...) Expand all
157 } 162 }
158 163
159 // If we need another layout pass, we have changed one of children's height so we need to relayout them. 164 // If we need another layout pass, we have changed one of children's height so we need to relayout them.
160 if (needsLayout()) 165 if (needsLayout())
161 RenderBlockFlow::layoutBlock(true); 166 RenderBlockFlow::layoutBlock(true);
162 167
163 // Center the child block in the block progression direction (vertical cente ring for horizontal text fields). 168 // Center the child block in the block progression direction (vertical cente ring for horizontal text fields).
164 if (!container && innerEditorRenderer && innerEditorRenderer->height() != co ntentLogicalHeight()) { 169 if (!container && innerEditorRenderer && innerEditorRenderer->height() != co ntentLogicalHeight()) {
165 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co ntentLogicalHeight(); 170 LayoutUnit logicalHeightDiff = innerEditorRenderer->logicalHeight() - co ntentLogicalHeight();
166 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - ( logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2))); 171 innerEditorRenderer->setLogicalTop(innerEditorRenderer->logicalTop() - ( logicalHeightDiff / 2 + layoutMod(logicalHeightDiff, 2)));
172 m_hasOverridenInnerEditorLogicalTop = true;
167 } else 173 } else
168 centerContainerIfNeeded(containerRenderer); 174 centerContainerIfNeeded(containerRenderer);
Julien - ping for review 2014/11/19 01:13:27 This also overrides the logical top under some con
169 175
170 HTMLElement* placeholderElement = inputElement()->placeholderElement(); 176 HTMLElement* placeholderElement = inputElement()->placeholderElement();
171 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->ren derBox() : 0) { 177 if (RenderBox* placeholderBox = placeholderElement ? placeholderElement->ren derBox() : 0) {
172 LayoutSize innerEditorSize; 178 LayoutSize innerEditorSize;
173 179
174 if (innerEditorRenderer) 180 if (innerEditorRenderer)
175 innerEditorSize = innerEditorRenderer->size(); 181 innerEditorSize = innerEditorRenderer->size();
176 placeholderBox->style()->setWidth(Length(innerEditorSize.width() - place holderBox->borderAndPaddingWidth(), Fixed)); 182 placeholderBox->style()->setWidth(Length(innerEditorSize.width() - place holderBox->borderAndPaddingWidth(), Fixed));
177 placeholderBox->style()->setHeight(Length(innerEditorSize.height() - pla ceholderBox->borderAndPaddingHeight(), Fixed)); 183 placeholderBox->style()->setHeight(Length(innerEditorSize.height() - pla ceholderBox->borderAndPaddingHeight(), Fixed));
178 bool neededLayout = placeholderBox->needsLayout(); 184 bool neededLayout = placeholderBox->needsLayout();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (innerEditorElement()) 418 if (innerEditorElement())
413 innerEditorElement()->setScrollTop(newTop); 419 innerEditorElement()->setScrollTop(newTop);
414 } 420 }
415 421
416 HTMLInputElement* RenderTextControlSingleLine::inputElement() const 422 HTMLInputElement* RenderTextControlSingleLine::inputElement() const
417 { 423 {
418 return toHTMLInputElement(node()); 424 return toHTMLInputElement(node());
419 } 425 }
420 426
421 } 427 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698