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

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

Issue 1007013002: Make scrollWidth and scrollHeight match other DOM measurement APIs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add additional test expectation 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/dom/Element.cpp ('k') | Source/web/WebViewImpl.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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 renderer->autoscroll(position); 384 renderer->autoscroll(position);
385 } 385 }
386 386
387 LayoutUnit LayoutTextControlSingleLine::scrollWidth() const 387 LayoutUnit LayoutTextControlSingleLine::scrollWidth() const
388 { 388 {
389 if (LayoutBox* inner = innerEditorElement() ? innerEditorElement()->layoutBo x() : 0) { 389 if (LayoutBox* inner = innerEditorElement() ? innerEditorElement()->layoutBo x() : 0) {
390 // Adjust scrollWidth to inculde input element horizontal paddings and 390 // Adjust scrollWidth to inculde input element horizontal paddings and
391 // decoration width 391 // decoration width
392 LayoutUnit adjustment = clientWidth() - inner->clientWidth(); 392 LayoutUnit adjustment = clientWidth() - inner->clientWidth();
393 return innerEditorElement()->scrollWidth() + adjustment; 393 // TODO(leviw): We floor to avoid breaking JS that tries to scroll to
394 // scrollWidth - clientWidth.
395 // TODO(leviw): These values are broken when zooming. crbug.com/471412
396 return inner->scrollWidth().floor() + adjustment;
394 } 397 }
395 return LayoutBlockFlow::scrollWidth(); 398 return LayoutBlockFlow::scrollWidth();
396 } 399 }
397 400
398 LayoutUnit LayoutTextControlSingleLine::scrollHeight() const 401 LayoutUnit LayoutTextControlSingleLine::scrollHeight() const
399 { 402 {
400 if (LayoutBox* inner = innerEditorElement() ? innerEditorElement()->layoutBo x() : 0) { 403 if (LayoutBox* inner = innerEditorElement() ? innerEditorElement()->layoutBo x() : 0) {
401 // Adjust scrollHeight to include input element vertical paddings and 404 // Adjust scrollHeight to include input element vertical paddings and
402 // decoration height 405 // decoration height
403 LayoutUnit adjustment = clientHeight() - inner->clientHeight(); 406 LayoutUnit adjustment = clientHeight() - inner->clientHeight();
404 return innerEditorElement()->scrollHeight() + adjustment; 407 // TODO(leviw): We floor to avoid breaking JS that tries to scroll to
408 // scrollHeight - clientHeight.
409 // TODO(leviw): These values are broken when zooming. crbug.com/471412
410 return inner->scrollHeight().floor() + adjustment;
405 } 411 }
406 return LayoutBlockFlow::scrollHeight(); 412 return LayoutBlockFlow::scrollHeight();
407 } 413 }
408 414
409 LayoutUnit LayoutTextControlSingleLine::scrollLeft() const 415 LayoutUnit LayoutTextControlSingleLine::scrollLeft() const
410 { 416 {
411 if (innerEditorElement()) 417 if (innerEditorElement())
412 return innerEditorElement()->scrollLeft(); 418 return innerEditorElement()->scrollLeft();
413 return LayoutBlockFlow::scrollLeft(); 419 return LayoutBlockFlow::scrollLeft();
414 } 420 }
(...skipping 16 matching lines...) Expand all
431 if (innerEditorElement()) 437 if (innerEditorElement())
432 innerEditorElement()->setScrollTop(newTop); 438 innerEditorElement()->setScrollTop(newTop);
433 } 439 }
434 440
435 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const 441 HTMLInputElement* LayoutTextControlSingleLine::inputElement() const
436 { 442 {
437 return toHTMLInputElement(node()); 443 return toHTMLInputElement(node());
438 } 444 }
439 445
440 } 446 }
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698