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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMeterElement.cpp

Issue 1747763002: Remove OSX-specific <meter> rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLMeterElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMeterElement.cpp b/third_party/WebKit/Source/core/html/HTMLMeterElement.cpp
index 0a47b3fd59f3c0ea86175fb1794ada3572162395..3d3b6ed031b8648c17c2cb4c98601233c18b8ba9 100644
--- a/third_party/WebKit/Source/core/html/HTMLMeterElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMeterElement.cpp
@@ -27,10 +27,10 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/frame/UseCounter.h"
+#include "core/html/HTMLDivElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
-#include "core/html/shadow/MeterShadowElement.h"
-#include "core/layout/LayoutMeter.h"
-#include "core/layout/LayoutTheme.h"
+#include "core/layout/LayoutObject.h"
+#include "core/style/ComputedStyle.h"
namespace blink {
@@ -56,30 +56,16 @@ PassRefPtrWillBeRawPtr<HTMLMeterElement> HTMLMeterElement::create(Document& docu
LayoutObject* HTMLMeterElement::createLayoutObject(const ComputedStyle& style)
{
switch (style.appearance()) {
- case ContinuousCapacityLevelIndicatorPart:
- UseCounter::count(document(), UseCounter::MeterElementWithContinuousCapacityAppearance);
- break;
- case DiscreteCapacityLevelIndicatorPart:
- UseCounter::count(document(), UseCounter::MeterElementWithDiscreteCapacityAppearance);
- break;
case MeterPart:
UseCounter::count(document(), UseCounter::MeterElementWithMeterAppearance);
break;
case NoControlPart:
UseCounter::count(document(), UseCounter::MeterElementWithNoneAppearance);
break;
- case RatingLevelIndicatorPart:
- UseCounter::count(document(), UseCounter::MeterElementWithRatingAppearance);
- break;
- case RelevancyLevelIndicatorPart:
- UseCounter::count(document(), UseCounter::MeterElementWithRelevancyAppearance);
- break;
default:
break;
}
- if (openShadowRoot() || !LayoutTheme::theme().supportsMeter(style.appearance()))
- return LayoutObject::createObject(this, style);
- return new LayoutMeter(this);
+ return LayoutObject::createObject(this, style);
}
void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value)
@@ -200,32 +186,22 @@ double HTMLMeterElement::valueRatio() const
void HTMLMeterElement::didElementStateChange()
{
- m_value->setWidthPercentage(valueRatio()*100);
- m_value->updatePseudo();
- if (LayoutMeter* layoutMeter = this->layoutMeter())
- layoutMeter->updateFromElement();
-}
-
-LayoutMeter* HTMLMeterElement::layoutMeter() const
-{
- if (layoutObject() && layoutObject()->isMeter())
- return toLayoutMeter(layoutObject());
-
- LayoutObject* layoutObject = userAgentShadowRoot()->firstChild()->layoutObject();
- return toLayoutMeter(layoutObject);
+ updateValueAppearance(valueRatio() * 100);
}
void HTMLMeterElement::didAddUserAgentShadowRoot(ShadowRoot& root)
{
ASSERT(!m_value);
- RefPtrWillBeRawPtr<MeterInnerElement> inner = MeterInnerElement::create(document());
+ RefPtrWillBeRawPtr<HTMLDivElement> inner = HTMLDivElement::create(document());
+ inner->setShadowPseudoId(AtomicString("-webkit-meter-inner-element", AtomicString::ConstructFromLiteral));
root.appendChild(inner);
- RefPtrWillBeRawPtr<MeterBarElement> bar = MeterBarElement::create(document());
- m_value = MeterValueElement::create(document());
- m_value->setWidthPercentage(0);
- m_value->updatePseudo();
+ RefPtrWillBeRawPtr<HTMLDivElement> bar = HTMLDivElement::create(document());
+ bar->setShadowPseudoId(AtomicString("-webkit-meter-bar", AtomicString::ConstructFromLiteral));
+
+ m_value = HTMLDivElement::create(document());
+ updateValueAppearance(0);
bar->appendChild(m_value);
inner->appendChild(bar);
@@ -237,6 +213,26 @@ void HTMLMeterElement::willAddFirstAuthorShadowRoot()
lazyReattachIfAttached();
}
+void HTMLMeterElement::updateValueAppearance(double percentage)
+{
+ DEFINE_STATIC_LOCAL(AtomicString, optimumPseudoId, ("-webkit-meter-optimum-value", AtomicString::ConstructFromLiteral));
+ DEFINE_STATIC_LOCAL(AtomicString, suboptimumPseudoId, ("-webkit-meter-suboptimum-value", AtomicString::ConstructFromLiteral));
+ DEFINE_STATIC_LOCAL(AtomicString, evenLessGoodPseudoId, ("-webkit-meter-even-less-good-value", AtomicString::ConstructFromLiteral));
+
+ m_value->setInlineStyleProperty(CSSPropertyWidth, percentage, CSSPrimitiveValue::UnitType::Percentage);
+ switch (gaugeRegion()) {
+ case GaugeRegionOptimum:
+ m_value->setShadowPseudoId(optimumPseudoId);
+ break;
+ case GaugeRegionSuboptimal:
+ m_value->setShadowPseudoId(suboptimumPseudoId);
+ break;
+ case GaugeRegionEvenLessGood:
+ m_value->setShadowPseudoId(evenLessGoodPseudoId);
+ break;
+ }
+}
+
DEFINE_TRACE(HTMLMeterElement)
{
visitor->trace(m_value);

Powered by Google App Engine
This is Rietveld 408576698