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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLProgressElement.cpp

Issue 1947423004: Simplify HTMLProgressElement::didElementStateChange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | 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) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (layoutObject() && layoutObject()->isProgress()) 68 if (layoutObject() && layoutObject()->isProgress())
69 return toLayoutProgress(layoutObject()); 69 return toLayoutProgress(layoutObject());
70 70
71 LayoutObject* layoutObject = userAgentShadowRoot()->firstChild()->layoutObje ct(); 71 LayoutObject* layoutObject = userAgentShadowRoot()->firstChild()->layoutObje ct();
72 ASSERT_WITH_SECURITY_IMPLICATION(!layoutObject || layoutObject->isProgress() ); 72 ASSERT_WITH_SECURITY_IMPLICATION(!layoutObject || layoutObject->isProgress() );
73 return toLayoutProgress(layoutObject); 73 return toLayoutProgress(layoutObject);
74 } 74 }
75 75
76 void HTMLProgressElement::parseAttribute(const QualifiedName& name, const Atomic String& oldValue, const AtomicString& value) 76 void HTMLProgressElement::parseAttribute(const QualifiedName& name, const Atomic String& oldValue, const AtomicString& value)
77 { 77 {
78 if (name == valueAttr) 78 if (name == valueAttr) {
79 if (oldValue.isNull() != value.isNull())
80 pseudoStateChanged(CSSSelector::PseudoIndeterminate);
79 didElementStateChange(); 81 didElementStateChange();
80 else if (name == maxAttr) 82 } else if (name == maxAttr) {
81 didElementStateChange(); 83 didElementStateChange();
82 else 84 } else {
83 LabelableElement::parseAttribute(name, oldValue, value); 85 LabelableElement::parseAttribute(name, oldValue, value);
86 }
84 } 87 }
85 88
86 void HTMLProgressElement::attach(const AttachContext& context) 89 void HTMLProgressElement::attach(const AttachContext& context)
87 { 90 {
88 LabelableElement::attach(context); 91 LabelableElement::attach(context);
89 if (LayoutProgressItem layoutItem = LayoutProgressItem(layoutProgress())) 92 if (LayoutProgressItem layoutItem = LayoutProgressItem(layoutProgress()))
90 layoutItem.updateFromElement(); 93 layoutItem.updateFromElement();
91 } 94 }
92 95
93 double HTMLProgressElement::value() const 96 double HTMLProgressElement::value() const
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 132 }
130 133
131 bool HTMLProgressElement::isDeterminate() const 134 bool HTMLProgressElement::isDeterminate() const
132 { 135 {
133 return fastHasAttribute(valueAttr); 136 return fastHasAttribute(valueAttr);
134 } 137 }
135 138
136 void HTMLProgressElement::didElementStateChange() 139 void HTMLProgressElement::didElementStateChange()
137 { 140 {
138 m_value->setWidthPercentage(position() * 100); 141 m_value->setWidthPercentage(position() * 100);
139 if (LayoutProgressItem layoutItem = LayoutProgressItem(layoutProgress())) { 142 if (LayoutProgressItem layoutItem = LayoutProgressItem(layoutProgress()))
140 bool wasDeterminate = layoutItem.isDeterminate();
141 layoutItem.updateFromElement(); 143 layoutItem.updateFromElement();
142 if (wasDeterminate != isDeterminate())
143 pseudoStateChanged(CSSSelector::PseudoIndeterminate);
144 }
145 } 144 }
146 145
147 void HTMLProgressElement::didAddUserAgentShadowRoot(ShadowRoot& root) 146 void HTMLProgressElement::didAddUserAgentShadowRoot(ShadowRoot& root)
148 { 147 {
149 ASSERT(!m_value); 148 ASSERT(!m_value);
150 149
151 ProgressInnerElement* inner = ProgressInnerElement::create(document()); 150 ProgressInnerElement* inner = ProgressInnerElement::create(document());
152 inner->setShadowPseudoId(AtomicString("-webkit-progress-inner-element")); 151 inner->setShadowPseudoId(AtomicString("-webkit-progress-inner-element"));
153 root.appendChild(inner); 152 root.appendChild(inner);
154 153
(...skipping 13 matching lines...) Expand all
168 return !isDeterminate(); 167 return !isDeterminate();
169 } 168 }
170 169
171 DEFINE_TRACE(HTMLProgressElement) 170 DEFINE_TRACE(HTMLProgressElement)
172 { 171 {
173 visitor->trace(m_value); 172 visitor->trace(m_value);
174 LabelableElement::trace(visitor); 173 LabelableElement::trace(visitor);
175 } 174 }
176 175
177 } // namespace blink 176 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698