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

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

Issue 2770123003: Replace ASSERT with DCHECK in core/layout/ excluding subdirs (Closed)
Patch Set: Split some DCHECKs and add DCHECK_ops wherever possible Created 3 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
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2005 Apple Computer, Inc. 2 * Copyright (C) 2005 Apple Computer, Inc.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 using namespace HTMLNames; 25 using namespace HTMLNames;
26 26
27 LayoutButton::LayoutButton(Element* element) 27 LayoutButton::LayoutButton(Element* element)
28 : LayoutFlexibleBox(element), m_inner(nullptr) {} 28 : LayoutFlexibleBox(element), m_inner(nullptr) {}
29 29
30 LayoutButton::~LayoutButton() {} 30 LayoutButton::~LayoutButton() {}
31 31
32 void LayoutButton::addChild(LayoutObject* newChild, LayoutObject* beforeChild) { 32 void LayoutButton::addChild(LayoutObject* newChild, LayoutObject* beforeChild) {
33 if (!m_inner) { 33 if (!m_inner) {
34 // Create an anonymous block. 34 // Create an anonymous block.
35 ASSERT(!firstChild()); 35 DCHECK(!firstChild());
36 m_inner = createAnonymousBlock(style()->display()); 36 m_inner = createAnonymousBlock(style()->display());
37 LayoutFlexibleBox::addChild(m_inner); 37 LayoutFlexibleBox::addChild(m_inner);
38 } 38 }
39 39
40 m_inner->addChild(newChild, beforeChild); 40 m_inner->addChild(newChild, beforeChild);
41 } 41 }
42 42
43 void LayoutButton::removeChild(LayoutObject* oldChild) { 43 void LayoutButton::removeChild(LayoutObject* oldChild) {
44 if (oldChild == m_inner || !m_inner) { 44 if (oldChild == m_inner || !m_inner) {
45 LayoutFlexibleBox::removeChild(oldChild); 45 LayoutFlexibleBox::removeChild(oldChild);
46 m_inner = 0; 46 m_inner = 0;
47 47
48 } else if (oldChild->parent() == this) { 48 } else if (oldChild->parent() == this) {
49 // We aren't the inner node, but we're getting removed from the button, this 49 // We aren't the inner node, but we're getting removed from the button, this
50 // can happen with things like scrollable area resizer's. 50 // can happen with things like scrollable area resizer's.
51 LayoutFlexibleBox::removeChild(oldChild); 51 LayoutFlexibleBox::removeChild(oldChild);
52 52
53 } else { 53 } else {
54 m_inner->removeChild(oldChild); 54 m_inner->removeChild(oldChild);
55 } 55 }
56 } 56 }
57 57
58 void LayoutButton::updateAnonymousChildStyle(const LayoutObject& child, 58 void LayoutButton::updateAnonymousChildStyle(const LayoutObject& child,
59 ComputedStyle& childStyle) const { 59 ComputedStyle& childStyle) const {
60 ASSERT(!m_inner || &child == m_inner); 60 DCHECK(!m_inner || &child == m_inner);
61 61
62 childStyle.setFlexGrow(1.0f); 62 childStyle.setFlexGrow(1.0f);
63 // min-width: 0; is needed for correct shrinking. 63 // min-width: 0; is needed for correct shrinking.
64 childStyle.setMinWidth(Length(0, Fixed)); 64 childStyle.setMinWidth(Length(0, Fixed));
65 // Use margin:auto instead of align-items:center to get safe centering, i.e. 65 // Use margin:auto instead of align-items:center to get safe centering, i.e.
66 // when the content overflows, treat it the same as align-items: flex-start. 66 // when the content overflows, treat it the same as align-items: flex-start.
67 childStyle.setMarginTop(Length()); 67 childStyle.setMarginTop(Length());
68 childStyle.setMarginBottom(Length()); 68 childStyle.setMarginBottom(Length());
69 childStyle.setFlexDirection(style()->flexDirection()); 69 childStyle.setFlexDirection(style()->flexDirection());
70 childStyle.setJustifyContent(style()->justifyContent()); 70 childStyle.setJustifyContent(style()->justifyContent());
71 childStyle.setFlexWrap(style()->flexWrap()); 71 childStyle.setFlexWrap(style()->flexWrap());
72 // TODO (lajava): An anonymous box must not be used to resolve children's auto 72 // TODO (lajava): An anonymous box must not be used to resolve children's auto
73 // values. 73 // values.
74 childStyle.setAlignItems(style()->alignItems()); 74 childStyle.setAlignItems(style()->alignItems());
75 childStyle.setAlignContent(style()->alignContent()); 75 childStyle.setAlignContent(style()->alignContent());
76 } 76 }
77 77
78 LayoutRect LayoutButton::controlClipRect( 78 LayoutRect LayoutButton::controlClipRect(
79 const LayoutPoint& additionalOffset) const { 79 const LayoutPoint& additionalOffset) const {
80 // Clip to the padding box to at least give content the extra padding space. 80 // Clip to the padding box to at least give content the extra padding space.
81 LayoutRect rect(additionalOffset, size()); 81 LayoutRect rect(additionalOffset, size());
82 rect.expand(borderInsets()); 82 rect.expand(borderInsets());
83 return rect; 83 return rect;
84 } 84 }
85 85
86 int LayoutButton::baselinePosition(FontBaseline baseline, 86 int LayoutButton::baselinePosition(FontBaseline baseline,
87 bool firstLine, 87 bool firstLine,
88 LineDirectionMode direction, 88 LineDirectionMode direction,
89 LinePositionMode linePositionMode) const { 89 LinePositionMode linePositionMode) const {
90 ASSERT(linePositionMode == PositionOnContainingLine); 90 DCHECK_EQ(linePositionMode, PositionOnContainingLine);
91 // We want to call the LayoutBlock version of firstLineBoxBaseline to 91 // We want to call the LayoutBlock version of firstLineBoxBaseline to
92 // avoid LayoutFlexibleBox synthesizing a baseline that we don't want. 92 // avoid LayoutFlexibleBox synthesizing a baseline that we don't want.
93 // We use this check as a proxy for "are there any line boxes in this button" 93 // We use this check as a proxy for "are there any line boxes in this button"
94 if (!hasLineIfEmpty() && LayoutBlock::firstLineBoxBaseline() == -1) { 94 if (!hasLineIfEmpty() && LayoutBlock::firstLineBoxBaseline() == -1) {
95 // To ensure that we have a consistent baseline when we have no children, 95 // To ensure that we have a consistent baseline when we have no children,
96 // even when we have the anonymous LayoutBlock child, we calculate the 96 // even when we have the anonymous LayoutBlock child, we calculate the
97 // baseline for the empty case manually here. 97 // baseline for the empty case manually here.
98 if (direction == HorizontalLine) { 98 if (direction == HorizontalLine) {
99 return (marginTop() + size().height() - borderBottom() - paddingBottom() - 99 return (marginTop() + size().height() - borderBottom() - paddingBottom() -
100 horizontalScrollbarHeight()) 100 horizontalScrollbarHeight())
101 .toInt(); 101 .toInt();
102 } 102 }
103 return (marginRight() + size().width() - borderLeft() - paddingLeft() - 103 return (marginRight() + size().width() - borderLeft() - paddingLeft() -
104 verticalScrollbarWidth()) 104 verticalScrollbarWidth())
105 .toInt(); 105 .toInt();
106 } 106 }
107 return LayoutFlexibleBox::baselinePosition(baseline, firstLine, direction, 107 return LayoutFlexibleBox::baselinePosition(baseline, firstLine, direction,
108 linePositionMode); 108 linePositionMode);
109 } 109 }
110 110
111 // For compatibility with IE/FF we only clip overflow on input elements. 111 // For compatibility with IE/FF we only clip overflow on input elements.
112 bool LayoutButton::hasControlClip() const { 112 bool LayoutButton::hasControlClip() const {
113 return !isHTMLButtonElement(node()); 113 return !isHTMLButtonElement(node());
114 } 114 }
115 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698