| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "core/CSSPropertyNames.h" | 35 #include "core/CSSPropertyNames.h" |
| 36 #include "core/HTMLNames.h" | 36 #include "core/HTMLNames.h" |
| 37 #include "core/html/HTMLMeterElement.h" | 37 #include "core/html/HTMLMeterElement.h" |
| 38 #include "core/layout/LayoutMeter.h" | 38 #include "core/layout/LayoutMeter.h" |
| 39 #include "core/layout/LayoutTheme.h" | 39 #include "core/layout/LayoutTheme.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 using namespace HTMLNames; | 43 using namespace HTMLNames; |
| 44 | 44 |
| 45 inline MeterFallbackElement::MeterFallbackElement(Document& document) |
| 46 : HTMLDivElement(document) |
| 47 { |
| 48 setHasCustomStyleCallbacks(); |
| 49 } |
| 50 |
| 51 DEFINE_NODE_FACTORY(MeterFallbackElement) |
| 52 |
| 53 PassRefPtr<ComputedStyle> MeterFallbackElement::customStyleForLayoutObject() |
| 54 { |
| 55 Element* host = shadowHost(); |
| 56 RefPtr<ComputedStyle> style = originalStyleForLayoutObject(); |
| 57 if (!host || !host->computedStyle() || host->computedStyle()->appearance() !
= MeterPart) |
| 58 return style.release; |
| 59 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); |
| 60 newStyle->setDisplay(NONE); |
| 61 return newStyle.release(); |
| 62 } |
| 63 |
| 45 inline MeterShadowElement::MeterShadowElement(Document& document) | 64 inline MeterShadowElement::MeterShadowElement(Document& document) |
| 46 : HTMLDivElement(document) | 65 : HTMLDivElement(document) |
| 47 { | 66 { |
| 48 } | 67 } |
| 49 | 68 |
| 50 HTMLMeterElement* MeterShadowElement::meterElement() const | 69 HTMLMeterElement* MeterShadowElement::meterElement() const |
| 51 { | 70 { |
| 52 return toHTMLMeterElement(shadowHost()); | 71 return toHTMLMeterElement(shadowHost()); |
| 53 } | 72 } |
| 54 | 73 |
| 55 bool MeterShadowElement::layoutObjectIsNeeded(const ComputedStyle& style) | 74 bool MeterShadowElement::layoutObjectIsNeeded(const ComputedStyle& style) |
| 56 { | 75 { |
| 57 LayoutObject* layoutObject = meterElement()->layoutObject(); | 76 LayoutObject* layoutObject = meterElement()->layoutObject(); |
| 58 return layoutObject && !LayoutTheme::theme().supportsMeter(layoutObject->sty
le()->appearance()) && HTMLDivElement::layoutObjectIsNeeded(style); | 77 return layoutObject && !LayoutTheme::theme().supportsMeter(layoutObject->sty
le()->appearance()) && HTMLDivElement::layoutObjectIsNeeded(style); |
| 59 } | 78 } |
| 60 | 79 |
| 61 inline MeterInnerElement::MeterInnerElement(Document& document) | 80 inline MeterInnerElement::MeterInnerElement(Document& document) |
| 62 : MeterShadowElement(document) | 81 : MeterShadowElement(document) |
| 63 { | 82 { |
| 83 setHasCustomStyleCallbacks(); |
| 64 } | 84 } |
| 65 | 85 |
| 66 PassRefPtrWillBeRawPtr<MeterInnerElement> MeterInnerElement::create(Document& do
cument) | 86 PassRefPtrWillBeRawPtr<MeterInnerElement> MeterInnerElement::create(Document& do
cument) |
| 67 { | 87 { |
| 68 RefPtrWillBeRawPtr<MeterInnerElement> element = adoptRefWillBeNoop(new Meter
InnerElement(document)); | 88 RefPtrWillBeRawPtr<MeterInnerElement> element = adoptRefWillBeNoop(new Meter
InnerElement(document)); |
| 69 element->setShadowPseudoId(AtomicString("-webkit-meter-inner-element", Atomi
cString::ConstructFromLiteral)); | 89 element->setShadowPseudoId(AtomicString("-webkit-meter-inner-element", Atomi
cString::ConstructFromLiteral)); |
| 70 return element.release(); | 90 return element.release(); |
| 71 } | 91 } |
| 72 | 92 |
| 73 bool MeterInnerElement::layoutObjectIsNeeded(const ComputedStyle& style) | 93 bool MeterInnerElement::layoutObjectIsNeeded(const ComputedStyle& style) |
| 74 { | 94 { |
| 75 if (meterElement()->openShadowRoot()) | 95 if (meterElement()->openShadowRoot()) |
| 76 return HTMLDivElement::layoutObjectIsNeeded(style); | 96 return HTMLDivElement::layoutObjectIsNeeded(style); |
| 77 | 97 |
| 78 LayoutObject* layoutObject = meterElement()->layoutObject(); | 98 LayoutObject* layoutObject = meterElement()->layoutObject(); |
| 79 return layoutObject && !LayoutTheme::theme().supportsMeter(layoutObject->sty
le()->appearance()) && HTMLDivElement::layoutObjectIsNeeded(style); | 99 return layoutObject && !LayoutTheme::theme().supportsMeter(layoutObject->sty
le()->appearance()) && HTMLDivElement::layoutObjectIsNeeded(style); |
| 80 } | 100 } |
| 81 | 101 |
| 82 LayoutObject* MeterInnerElement::createLayoutObject(const ComputedStyle&) | 102 LayoutObject* MeterInnerElement::createLayoutObject(const ComputedStyle&) |
| 83 { | 103 { |
| 84 return new LayoutMeter(this); | 104 return new LayoutMeter(this); |
| 85 } | 105 } |
| 86 | 106 |
| 107 PassRefPtr<ComputedStyle> MeterInnerElement::customStyleForLayoutObject() |
| 108 { |
| 109 Element* host = shadowHost(); |
| 110 RefPtr<ComputedStyle> style = originalStyleForLayoutObject(); |
| 111 if (!host || !host->computedStyle() || host->computedStyle()->appearance() =
= MeterPart) |
| 112 return style.release; |
| 113 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); |
| 114 newStyle->setDisplay(NONE); |
| 115 return newStyle.release(); |
| 116 } |
| 117 |
| 87 inline MeterBarElement::MeterBarElement(Document& document) | 118 inline MeterBarElement::MeterBarElement(Document& document) |
| 88 : MeterShadowElement(document) | 119 : MeterShadowElement(document) |
| 89 { | 120 { |
| 90 } | 121 } |
| 91 | 122 |
| 92 PassRefPtrWillBeRawPtr<MeterBarElement> MeterBarElement::create(Document& docume
nt) | 123 PassRefPtrWillBeRawPtr<MeterBarElement> MeterBarElement::create(Document& docume
nt) |
| 93 { | 124 { |
| 94 RefPtrWillBeRawPtr<MeterBarElement> element = adoptRefWillBeNoop(new MeterBa
rElement(document)); | 125 RefPtrWillBeRawPtr<MeterBarElement> element = adoptRefWillBeNoop(new MeterBa
rElement(document)); |
| 95 element->setShadowPseudoId(AtomicString("-webkit-meter-bar", AtomicString::C
onstructFromLiteral)); | 126 element->setShadowPseudoId(AtomicString("-webkit-meter-bar", AtomicString::C
onstructFromLiteral)); |
| 96 return element.release(); | 127 return element.release(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return optimumPseudoId; | 161 return optimumPseudoId; |
| 131 } | 162 } |
| 132 } | 163 } |
| 133 | 164 |
| 134 void MeterValueElement::setWidthPercentage(double width) | 165 void MeterValueElement::setWidthPercentage(double width) |
| 135 { | 166 { |
| 136 setInlineStyleProperty(CSSPropertyWidth, width, CSSPrimitiveValue::UnitType:
:Percentage); | 167 setInlineStyleProperty(CSSPropertyWidth, width, CSSPrimitiveValue::UnitType:
:Percentage); |
| 137 } | 168 } |
| 138 | 169 |
| 139 } | 170 } |
| OLD | NEW |