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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2716583002: Avoid negative content box sizes. (Closed)
Patch Set: code review Created 3 years, 9 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 | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | 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) 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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 child = child->nextSibling(); 502 child = child->nextSibling();
503 } 503 }
504 invalidateBackgroundObscurationStatus(); 504 invalidateBackgroundObscurationStatus();
505 clearNeedsLayout(); 505 clearNeedsLayout();
506 } 506 }
507 507
508 // More IE extensions. clientWidth and clientHeight represent the interior of 508 // More IE extensions. clientWidth and clientHeight represent the interior of
509 // an object excluding border and scrollbar. 509 // an object excluding border and scrollbar.
510 DISABLE_CFI_PERF 510 DISABLE_CFI_PERF
511 LayoutUnit LayoutBox::clientWidth() const { 511 LayoutUnit LayoutBox::clientWidth() const {
512 return m_frameRect.width() - borderLeft() - borderRight() - 512 // We need to clamp negative values. The scrollbar may be wider than the
513 verticalScrollbarWidth(); 513 // padding box. Another reason: While border side values are currently limited
514 // to 2^20px (a recent change in the code), if this limit is raised again in
515 // the future, we'd have ill effects of saturated arithmetic otherwise.
516 return (m_frameRect.width() - borderLeft() - borderRight() -
517 verticalScrollbarWidth())
518 .clampNegativeToZero();
514 } 519 }
515 520
516 DISABLE_CFI_PERF 521 DISABLE_CFI_PERF
517 LayoutUnit LayoutBox::clientHeight() const { 522 LayoutUnit LayoutBox::clientHeight() const {
518 return m_frameRect.height() - borderTop() - borderBottom() - 523 // We need to clamp negative values. The scrollbar may be wider than the
519 horizontalScrollbarHeight(); 524 // padding box. Another reason: While border side values are currently limited
525 // to 2^20px (a recent change in the code), if this limit is raised again in
526 // the future, we'd have ill effects of saturated arithmetic otherwise.
527 return (m_frameRect.height() - borderTop() - borderBottom() -
528 horizontalScrollbarHeight())
529 .clampNegativeToZero();
520 } 530 }
521 531
522 int LayoutBox::pixelSnappedClientWidth() const { 532 int LayoutBox::pixelSnappedClientWidth() const {
523 return snapSizeToPixel(clientWidth(), location().x() + clientLeft()); 533 return snapSizeToPixel(clientWidth(), location().x() + clientLeft());
524 } 534 }
525 535
526 DISABLE_CFI_PERF 536 DISABLE_CFI_PERF
527 int LayoutBox::pixelSnappedClientHeight() const { 537 int LayoutBox::pixelSnappedClientHeight() const {
528 return snapSizeToPixel(clientHeight(), location().y() + clientTop()); 538 return snapSizeToPixel(clientHeight(), location().y() + clientTop());
529 } 539 }
(...skipping 5185 matching lines...) Expand 10 before | Expand all | Expand 10 after
5715 block->adjustChildDebugRect(rect); 5725 block->adjustChildDebugRect(rect);
5716 5726
5717 return rect; 5727 return rect;
5718 } 5728 }
5719 5729
5720 bool LayoutBox::shouldClipOverflow() const { 5730 bool LayoutBox::shouldClipOverflow() const {
5721 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); 5731 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip();
5722 } 5732 }
5723 5733
5724 } // namespace blink 5734 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698