2011-04-04 MORITA Hajime <morrita@google.com>
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 22:15:57 +0000 (22:15 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 22:15:57 +0000 (22:15 +0000)
        Reviewed by Dimitri Glazkov.

        Convert <meter> shadow DOM to a DOM-based shadow.
        https://bugs.webkit.org/show_bug.cgi?id=50661

        Updated expectations due to shadow structure chagne.
        Also updated meter-styles.html pixel result because the render tree is now laid out
        as normal flexboxes and its layout result is actually different,
        especially if there are non-zero borders on shadow elements.

        * fast/dom/HTMLMeterElement/meter-styles.html:
        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-changing-pseudo-expected.txt:
        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.checksum:
        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png:
        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.txt:
2011-04-04  MORITA Hajime  <morrita@google.com>

        Reviewed by Dimitri Glazkov.

        Convert <meter> shadow DOM to a DOM-based shadow.
        https://bugs.webkit.org/show_bug.cgi?id=50661

        Eliminated a large part of <meter> custom layout code,
        which is replaced by a shadow tree.
        Note that the shadow tree is created on construction time and
        will remain during the host HTMLMeterElement lifecycle.

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * css/CSSMutableStyleDeclaration.cpp:
        (WebCore::CSSMutableStyleDeclaration::setProperty):
        * css/CSSMutableStyleDeclaration.h:
        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::pseudoId):
        (WebCore::nameToPseudoTypeMap):
        (WebCore::CSSSelector::extractPseudoType):
        * css/CSSSelector.h:
        * css/html.css:
        (meter):
        (meter::-webkit-meter-bar):
        (meter::-webkit-meter-optimum-value):
        (meter::-webkit-meter-suboptimum-value):
        (meter::-webkit-meter-even-less-good-value):
        * html/HTMLMeterElement.cpp:
        (WebCore::HTMLMeterElement::~HTMLMeterElement):
        (WebCore::HTMLMeterElement::parseMappedAttribute):
        (WebCore::HTMLMeterElement::attach):
        (WebCore::HTMLMeterElement::valueRatio):
        (WebCore::HTMLMeterElement::didElementStateChange):
        (WebCore::HTMLMeterElement::createShadowSubtree):
        * html/HTMLMeterElement.h:
        * html/shadow/MeterShadowElement.cpp: Added.
        (WebCore::MeterShadowElement::MeterShadowElement):
        (WebCore::MeterShadowElement::meterElement):
        (WebCore::MeterShadowElement::rendererIsNeeded):
        (WebCore::MeterBarElement::shadowPseudoId):
        (WebCore::MeterValueElement::shadowPseudoId):
        (WebCore::MeterValueElement::setWidthPercentage):
        * html/shadow/MeterShadowElement.h: Added.
        (WebCore::MeterBarElement::MeterBarElement):
        (WebCore::MeterBarElement::create):
        (WebCore::MeterValueElement::MeterValueElement):
        (WebCore::MeterValueElement::create):
        * rendering/RenderMeter.cpp:
        (WebCore::RenderMeter::RenderMeter):
        (WebCore::RenderMeter::~RenderMeter):
        (WebCore::RenderMeter::valueRatio):
        * rendering/RenderMeter.h:
        (WebCore::RenderMeter::renderName):
        (WebCore::RenderMeter::isMeter):
        (WebCore::RenderMeter::requiresForcedStyleRecalcPropagation):
        (WebCore::RenderMeter::canHaveChildren):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82880 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLMeterElement/meter-styles.html
LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-changing-pseudo-expected.txt
LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.checksum
LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png
LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.txt
Source/WebCore/Android.mk
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSMutableStyleDeclaration.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.h
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/css/html.css
Source/WebCore/html/HTMLMeterElement.cpp
Source/WebCore/html/HTMLMeterElement.h
Source/WebCore/html/shadow/MeterShadowElement.cpp [new file with mode: 0644]
Source/WebCore/html/shadow/MeterShadowElement.h [new file with mode: 0644]
Source/WebCore/rendering/RenderMeter.cpp
Source/WebCore/rendering/RenderMeter.h

index 8cb81f6..5e5531a 100644 (file)
@@ -1,3 +1,21 @@
+2011-04-04  MORITA Hajime  <morrita@google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        Convert <meter> shadow DOM to a DOM-based shadow.
+        https://bugs.webkit.org/show_bug.cgi?id=50661
+        
+        Updated expectations due to shadow structure chagne.
+        Also updated meter-styles.html pixel result because the render tree is now laid out
+        as normal flexboxes and its layout result is actually different,
+        especially if there are non-zero borders on shadow elements.
+
+        * fast/dom/HTMLMeterElement/meter-styles.html:
+        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-changing-pseudo-expected.txt:
+        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.checksum:
+        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png:
+        * platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.txt:
+
 2011-04-04  Adrienne Walker  <enne@google.com>
 
         Unreviewed, update Chromium Snow Leopard image baselines.
index c8cabc4..05a13fe 100644 (file)
@@ -12,6 +12,8 @@ if (window.layoutTestController)
   li { margin: 0.2em; list-style-type: none; }
   meter.barstyled::-webkit-meter-bar { background: gray; border-style: solid; border-width: 2px; border-color: #222; }
   meter.valstyled::-webkit-meter-optimum-value { background: green; border-style: solid; border-width: 2px; border-color: #7c7; }
+  meter#bar-paddings { -webkit-appearance: none; }
+  meter#bar-paddings::-webkit-meter-bar { padding: 5px; }
 </style>
 </head>
 <body>
@@ -55,5 +57,10 @@ if (window.layoutTestController)
     <li><meter style="-webkit-appearance: meter" min="0" max="100" low="30" high="60" optimum="100" value="80" ></meter> has "meter" appearance, should be themed.</li>
   </ul>
   </div>
+  <h2>Providing bar paddings</h2>
+  <div style="background-color: #eee">
+    <meter id="bar-paddings" min="0" max="100" low="30" high="60" optimum="50" value="50" ></meter> has "padding" on the bar.
+  </ul>
+  </div>
 </body>
 </html>
index 68200b3..90730ba 100644 (file)
@@ -12,5 +12,5 @@ layer at (0,0) size 800x600
       RenderBlock (anonymous) at (0,92) size 784x16
         RenderMeter {METER} at (0,0) size 80x16
           RenderBlock {DIV} at (0,0) size 80x16 [bgcolor=#808080]
-          RenderBlock {DIV} at (0,0) size 72x16 [bgcolor=#008000]
+            RenderBlock {DIV} at (0,0) size 72x16 [bgcolor=#008000]
         RenderText {#text} at (0,0) size 0x0
index 282474a..88c4057 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png and b/LayoutTests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png differ
index f82378c..23a8d88 100644 (file)
@@ -10,17 +10,17 @@ layer at (0,0) size 800x600
         RenderListItem {LI} at (43,0) size 732x18
           RenderMeter {METER} at (0,1) size 80x16
             RenderBlock {DIV} at (0,0) size 80x16
-            RenderBlock {DIV} at (0,0) size 20x16
+              RenderBlock {DIV} at (0,0) size 20x16
           RenderText {#text} at (80,0) size 4x18
             text run at (80,0) width 4: " "
           RenderMeter {METER} at (84,1) size 80x16
             RenderBlock {DIV} at (0,0) size 80x16
-            RenderBlock {DIV} at (0,0) size 36x16
+              RenderBlock {DIV} at (0,0) size 36x16
           RenderText {#text} at (164,0) size 4x18
             text run at (164,0) width 4: " "
           RenderMeter {METER} at (168,1) size 80x16
             RenderBlock {DIV} at (0,0) size 80x16
-            RenderBlock {DIV} at (0,0) size 60x16
+              RenderBlock {DIV} at (0,0) size 60x16
         RenderListItem {LI} at (43,21) size 732x41
           RenderMeter {METER} at (0,0) size 30x40
           RenderText {#text} at (30,23) size 4x18
@@ -32,30 +32,30 @@ layer at (0,0) size 800x600
       RenderBlock {H2} at (3,86) size 778x18
         RenderText {#text} at (0,0) size 150x18
           text run at (0,0) width 150: "Providing meter styles"
-      RenderBlock {DIV} at (0,107) size 784x102 [bgcolor=#EEEEEE]
-        RenderBlock {UL} at (3,0) size 778x102
-          RenderListItem {LI} at (43,0) size 732x32
-            RenderMeter {METER} at (0,0) size 230x31 [bgcolor=#AAAACC] [border: (10px solid #222244) (50px solid #222244) (5px solid #222244) (100px solid #222244)]
-              RenderBlock {DIV} at (100,10) size 80x16
-              RenderBlock {DIV} at (100,10) size 64x16
-            RenderText {#text} at (230,14) size 70x18
-              text run at (230,14) width 70: " has border"
-          RenderListItem {LI} at (43,35) size 732x32
-            RenderMeter {METER} at (0,0) size 230x31 [bgcolor=#AAAACC]
-              RenderBlock {DIV} at (100,10) size 80x16
-              RenderBlock {DIV} at (100,10) size 64x16
-            RenderText {#text} at (230,14) size 80x18
-              text run at (230,14) width 80: " has padding"
-          RenderListItem {LI} at (43,70) size 732x32
+      RenderBlock {DIV} at (0,107) size 784x74 [bgcolor=#EEEEEE]
+        RenderBlock {UL} at (3,0) size 778x74
+          RenderListItem {LI} at (43,0) size 732x18
+            RenderMeter {METER} at (0,1) size 150x16 [bgcolor=#AAAACC] [border: (10px solid #222244) (50px solid #222244) (5px solid #222244) (100px solid #222244)]
+              RenderBlock {DIV} at (100,10) size 0x1
+                RenderBlock {DIV} at (0,0) size 0x1
+            RenderText {#text} at (150,0) size 70x18
+              text run at (150,0) width 70: " has border"
+          RenderListItem {LI} at (43,21) size 732x18
+            RenderMeter {METER} at (0,1) size 150x16 [bgcolor=#AAAACC]
+              RenderBlock {DIV} at (100,10) size 0x1
+                RenderBlock {DIV} at (0,0) size 0x1
+            RenderText {#text} at (150,0) size 80x18
+              text run at (150,0) width 80: " has padding"
+          RenderListItem {LI} at (43,42) size 732x32
             RenderMeter {METER} at (100,10) size 80x16 [bgcolor=#AAAACC]
               RenderBlock {DIV} at (0,0) size 80x16
-              RenderBlock {DIV} at (0,0) size 64x16
+                RenderBlock {DIV} at (0,0) size 64x16
             RenderText {#text} at (230,14) size 73x18
               text run at (230,14) width 73: " has margin"
-      RenderBlock {H2} at (3,212) size 778x18
+      RenderBlock {H2} at (3,184) size 778x18
         RenderText {#text} at (0,0) size 224x18
           text run at (0,0) width 224: "Providing bar and/or value styles"
-      RenderBlock {DIV} at (0,233) size 784x165 [bgcolor=#EEEEEE]
+      RenderBlock {DIV} at (0,205) size 784x165 [bgcolor=#EEEEEE]
         RenderBlock {UL} at (3,0) size 778x81
           RenderBlock (anonymous) at (40,0) size 738x18
             RenderText {#text} at (0,0) size 475x18
@@ -79,33 +79,42 @@ layer at (0,0) size 800x600
           RenderListItem {LI} at (43,21) size 732x18
             RenderMeter {METER} at (0,1) size 80x16
               RenderBlock {DIV} at (0,0) size 80x16
-              RenderBlock {DIV} at (0,0) size 64x16 [bgcolor=#008000] [border: (2px solid #77CC77)]
+                RenderBlock {DIV} at (0,0) size 64x16 [bgcolor=#008000] [border: (2px solid #77CC77)]
             RenderText {#text} at (80,0) size 270x18
               text run at (80,0) width 270: " has bar style, should have solid value part."
           RenderListItem {LI} at (43,42) size 732x18
             RenderMeter {METER} at (0,1) size 80x16
               RenderBlock {DIV} at (0,0) size 80x16 [bgcolor=#808080] [border: (2px solid #222222)]
-              RenderBlock {DIV} at (0,0) size 64x16
+                RenderBlock {DIV} at (2,2) size 60x12
             RenderText {#text} at (80,0) size 255x18
               text run at (80,0) width 255: " has value style, should be solid bar part."
           RenderListItem {LI} at (43,63) size 732x18
             RenderMeter {METER} at (0,1) size 80x16
               RenderBlock {DIV} at (0,0) size 80x16 [bgcolor=#808080] [border: (2px solid #222222)]
-              RenderBlock {DIV} at (0,0) size 64x16 [bgcolor=#008000] [border: (2px solid #77CC77)]
+                RenderBlock {DIV} at (2,2) size 60x12 [bgcolor=#008000] [border: (2px solid #77CC77)]
             RenderText {#text} at (80,0) size 235x18
               text run at (80,0) width 235: " should have solid bar and value part."
-      RenderBlock {H2} at (3,401) size 778x18
+      RenderBlock {H2} at (3,373) size 778x18
         RenderText {#text} at (0,0) size 156x18
           text run at (0,0) width 156: "Providing appearances"
-      RenderBlock {DIV} at (0,422) size 784x39 [bgcolor=#EEEEEE]
+      RenderBlock {DIV} at (0,394) size 784x39 [bgcolor=#EEEEEE]
         RenderBlock {UL} at (3,0) size 778x39
           RenderListItem {LI} at (43,0) size 732x18
             RenderMeter {METER} at (0,1) size 80x16
               RenderBlock {DIV} at (0,0) size 80x16
-              RenderBlock {DIV} at (0,0) size 64x16
+                RenderBlock {DIV} at (0,0) size 64x16
             RenderText {#text} at (80,0) size 375x18
               text run at (80,0) width 375: " has \"none\" appearance, should be styled with default style."
           RenderListItem {LI} at (43,21) size 732x18
             RenderMeter {METER} at (0,1) size 80x16
             RenderText {#text} at (80,0) size 276x18
               text run at (80,0) width 276: " has \"meter\" appearance, should be themed."
+      RenderBlock {H2} at (3,436) size 778x18
+        RenderText {#text} at (0,0) size 161x18
+          text run at (0,0) width 161: "Providing bar paddings"
+      RenderBlock {DIV} at (0,457) size 784x18 [bgcolor=#EEEEEE]
+        RenderMeter {METER} at (0,1) size 80x16
+          RenderBlock {DIV} at (0,0) size 80x16
+            RenderBlock {DIV} at (5,5) size 35x6
+        RenderText {#text} at (80,0) size 165x18
+          text run at (80,0) width 165: " has \"padding\" on the bar."
index 90f50d6..7b4bc15 100644 (file)
@@ -354,6 +354,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
        html/parser/XSSFilter.cpp \
        \
        html/shadow/MediaControls.cpp \
+       html/shadow/MeterShadowElement.cpp \
        html/shadow/SliderThumbElement.cpp \
        html/shadow/TextControlInnerElements.cpp \
        \
index cc55037..7a9f55e 100644 (file)
@@ -873,6 +873,7 @@ SET(WebCore_SOURCES
     html/parser/XSSFilter.cpp
 
     html/shadow/MediaControls.cpp
+    html/shadow/MeterShadowElement.cpp
     html/shadow/SliderThumbElement.cpp
     html/shadow/TextControlInnerElements.cpp
 
index f73f8c0..fb94cc9 100644 (file)
@@ -1,3 +1,66 @@
+2011-04-04  MORITA Hajime  <morrita@google.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        Convert <meter> shadow DOM to a DOM-based shadow.
+        https://bugs.webkit.org/show_bug.cgi?id=50661
+        
+        Eliminated a large part of <meter> custom layout code,
+        which is replaced by a shadow tree.
+        Note that the shadow tree is created on construction time and
+        will remain during the host HTMLMeterElement lifecycle.
+        
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::setProperty):
+        * css/CSSMutableStyleDeclaration.h:
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId):
+        (WebCore::nameToPseudoTypeMap):
+        (WebCore::CSSSelector::extractPseudoType):
+        * css/CSSSelector.h:
+        * css/html.css:
+        (meter):
+        (meter::-webkit-meter-bar):
+        (meter::-webkit-meter-optimum-value):
+        (meter::-webkit-meter-suboptimum-value):
+        (meter::-webkit-meter-even-less-good-value):
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::~HTMLMeterElement):
+        (WebCore::HTMLMeterElement::parseMappedAttribute):
+        (WebCore::HTMLMeterElement::attach):
+        (WebCore::HTMLMeterElement::valueRatio):
+        (WebCore::HTMLMeterElement::didElementStateChange):
+        (WebCore::HTMLMeterElement::createShadowSubtree):
+        * html/HTMLMeterElement.h:
+        * html/shadow/MeterShadowElement.cpp: Added.
+        (WebCore::MeterShadowElement::MeterShadowElement):        
+        (WebCore::MeterShadowElement::meterElement):
+        (WebCore::MeterShadowElement::rendererIsNeeded):
+        (WebCore::MeterBarElement::shadowPseudoId):
+        (WebCore::MeterValueElement::shadowPseudoId):
+        (WebCore::MeterValueElement::setWidthPercentage):
+        * html/shadow/MeterShadowElement.h: Added.
+        (WebCore::MeterBarElement::MeterBarElement):
+        (WebCore::MeterBarElement::create):
+        (WebCore::MeterValueElement::MeterValueElement):
+        (WebCore::MeterValueElement::create):
+        * rendering/RenderMeter.cpp:
+        (WebCore::RenderMeter::RenderMeter):
+        (WebCore::RenderMeter::~RenderMeter):
+        (WebCore::RenderMeter::valueRatio):
+        * rendering/RenderMeter.h:
+        (WebCore::RenderMeter::renderName):
+        (WebCore::RenderMeter::isMeter):
+        (WebCore::RenderMeter::requiresForcedStyleRecalcPropagation):
+        (WebCore::RenderMeter::canHaveChildren):
+
 2011-04-04  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Gustavo Noronha Silva.
index e04dfd2..fbe5fa5 100644 (file)
@@ -1921,6 +1921,8 @@ webcore_sources += \
        Source/WebCore/html/parser/XSSFilter.h \
        Source/WebCore/html/shadow/MediaControls.cpp \
        Source/WebCore/html/shadow/MediaControls.h \
+       Source/WebCore/html/shadow/MeterShadowElement.cpp \
+       Source/WebCore/html/shadow/MeterShadowElement.h \
        Source/WebCore/html/shadow/ProgressBarValueElement.h \
        Source/WebCore/html/shadow/SliderThumbElement.cpp \
        Source/WebCore/html/shadow/SliderThumbElement.h \
index fd43e79..69b2b72 100644 (file)
             'html/parser/XSSFilter.h',
             'html/shadow/MediaControls.cpp',
             'html/shadow/MediaControls.h',
+            'html/shadow/MeterShadowElement.cpp',
+            'html/shadow/MeterShadowElement.h',
             'html/shadow/ProgressBarValueElement.h',
             'html/shadow/SliderThumbElement.cpp',
             'html/shadow/SliderThumbElement.h',
index 4c2e19f..3e4bad9 100644 (file)
@@ -800,6 +800,7 @@ SOURCES += \
     html/parser/TextViewSourceParser.cpp \
     html/parser/XSSFilter.cpp \
     html/shadow/MediaControls.cpp \
+    html/shadow/MeterShadowElement.cpp \
     html/shadow/SliderThumbElement.cpp \
     html/shadow/TextControlInnerElements.cpp \
     inspector/ConsoleMessage.cpp \
index 5f3c464..2b60293 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\html\shadow\MeterShadowElement.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\html\shadow\MeterShadowElement.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\html\shadow\ProgressBarValueElement.h"
                                        >
                                </File>
index 64ea10a..f49693a 100644 (file)
                A77B41A012E675A90054343D /* TextEventInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = A77B419F12E675A90054343D /* TextEventInputType.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */ = {isa = PBXBuildFile; fileRef = A77D0011133B0AEB00D6658C /* TextChecking.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; };
+               A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */; };
+               A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */; };
                A78FE13B12366B1000ACE8D0 /* SpellChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */; };
                A78FE13C12366B1000ACE8D0 /* SpellChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = A78FE13A12366B1000ACE8D0 /* SpellChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A795463E0B5C4C80007B438F /* DragDataMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A795463D0B5C4C80007B438F /* DragDataMac.mm */; };
                A77B419F12E675A90054343D /* TextEventInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEventInputType.h; sourceTree = "<group>"; };
                A77D0011133B0AEB00D6658C /* TextChecking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecking.h; sourceTree = "<group>"; };
                A784941A0B5FE507001E237A /* Clipboard.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Clipboard.cpp; sourceTree = "<group>"; };
+               A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeterShadowElement.cpp; sourceTree = "<group>"; };
+               A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeterShadowElement.h; sourceTree = "<group>"; };
                A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellChecker.cpp; sourceTree = "<group>"; };
                A78FE13A12366B1000ACE8D0 /* SpellChecker.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = SpellChecker.h; sourceTree = "<group>"; };
                A795463D0B5C4C80007B438F /* DragDataMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragDataMac.mm; sourceTree = "<group>"; };
                        children = (
                                4157AF7F12F1FB0400A8C6F5 /* MediaControls.cpp */,
                                4157AF7E12F1FB0400A8C6F5 /* MediaControls.h */,
+                               A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */,
+                               A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */,
                                A7FE819B12FA677700850C1E /* ProgressBarValueElement.h */,
                                4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */,
                                4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */,
                                41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */,
                                89878569122CA064003AABDA /* Metadata.h in Headers */,
                                8987856A122CA064003AABDA /* MetadataCallback.h in Headers */,
+                               A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */,
                                BC772C4F0C4EB3040083285F /* MIMETypeRegistry.h in Headers */,
                                C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */,
                                F55B3DC61251F12D003EF269 /* MonthInputType.h in Headers */,
                                75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */,
                                E1ADECC00E76ACF1004A1A5E /* MessagePort.cpp in Sources */,
                                41BF700B0FE86F49005E8DEC /* MessagePortChannel.cpp in Sources */,
+                               A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */,
                                BC772C4E0C4EB3040083285F /* MIMETypeRegistry.cpp in Sources */,
                                BC772C5E0C4EB3440083285F /* MIMETypeRegistryMac.mm in Sources */,
                                C6D74AE409AA290A000B0A52 /* ModifySelectionListLevel.cpp in Sources */,
index f3f26aa..9caf234 100644 (file)
@@ -605,6 +605,15 @@ bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool imp
     return true;
 }
 
+bool CSSMutableStyleDeclaration::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important, bool notifyChanged)
+{
+    CSSProperty property(propertyID, CSSPrimitiveValue::create(value, unit), important);
+    setPropertyInternal(property);
+    if (notifyChanged)
+        setNeedsStyleRecalc();
+    return true;
+}
+
 void CSSMutableStyleDeclaration::setStringProperty(int propertyId, const String &value, CSSPrimitiveValue::UnitTypes type, bool important)
 {
     ASSERT(!m_iteratorCount);
index ca17f11..ea8ab3f 100644 (file)
@@ -109,6 +109,7 @@ public:
     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
 
     bool setProperty(int propertyID, int value, bool important = false, bool notifyChanged = true);
+    bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes, bool important = false, bool notifyChanged = true);
     bool setProperty(int propertyID, const String& value, bool important = false, bool notifyChanged = true);
 
     String removeProperty(int propertyID, bool notifyChanged = true, bool returnText = false);
@@ -117,7 +118,7 @@ public:
     void setLengthProperty(int propertyId, const String& value, bool important, bool multiLength = false);
     void setStringProperty(int propertyId, const String& value, CSSPrimitiveValue::UnitTypes, bool important = false); // parsed string value
     void setImageProperty(int propertyId, const String& url, bool important = false);
+
     // The following parses an entire new style declaration.
     void parseDeclaration(const String& styleDeclaration);
 
index ba13932..3bb4a88 100644 (file)
@@ -160,24 +160,6 @@ PseudoId CSSSelector::pseudoId(PseudoType type)
         return INNER_SPIN_BUTTON;
     case PseudoOuterSpinButton:
         return OUTER_SPIN_BUTTON;
-#if ENABLE(METER_TAG)
-    case PseudoMeterBar:
-        return METER_BAR;
-    case PseudoMeterOptimum:
-        return METER_OPTIMUM;
-    case PseudoMeterSuboptimal:
-        return METER_SUBOPTIMAL;
-    case PseudoMeterEvenLessGood:
-        return METER_EVEN_LESS_GOOD;
-#else
-    case PseudoMeterBar:
-    case PseudoMeterOptimum:
-    case PseudoMeterSuboptimal:
-    case PseudoMeterEvenLessGood:
-        ASSERT_NOT_REACHED();
-        return NOPSEUDO;
-#endif
-
 #if ENABLE(FULLSCREEN_API)
     case PseudoFullScreen:
         return FULL_SCREEN;
@@ -303,13 +285,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
     DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type"));
     DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional"));
     DEFINE_STATIC_LOCAL(AtomicString, outerSpinButton, ("-webkit-outer-spin-button"));
-#if ENABLE(METER_TAG)
-    DEFINE_STATIC_LOCAL(AtomicString, meterBar, ("-webkit-meter-bar"));
-    DEFINE_STATIC_LOCAL(AtomicString, meterOptimumValue, ("-webkit-meter-optimum-value"));
-    DEFINE_STATIC_LOCAL(AtomicString, meterSuboptimalValue, ("-webkit-meter-suboptimal-value"));
-    DEFINE_STATIC_LOCAL(AtomicString, meterEvenLessGoodValue, ("-webkit-meter-even-less-good-value"));
-#endif
-
     DEFINE_STATIC_LOCAL(AtomicString, required, ("required"));
     DEFINE_STATIC_LOCAL(AtomicString, resizer, ("-webkit-resizer"));
     DEFINE_STATIC_LOCAL(AtomicString, root, ("root"));
@@ -397,12 +372,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
         nameToPseudoType->set(nthLastChild.impl(), CSSSelector::PseudoNthLastChild);
         nameToPseudoType->set(nthLastOfType.impl(), CSSSelector::PseudoNthLastOfType);
         nameToPseudoType->set(outerSpinButton.impl(), CSSSelector::PseudoOuterSpinButton);
-#if ENABLE(METER_TAG)
-        nameToPseudoType->set(meterBar.impl(), CSSSelector::PseudoMeterBar);
-        nameToPseudoType->set(meterOptimumValue.impl(), CSSSelector::PseudoMeterOptimum);
-        nameToPseudoType->set(meterSuboptimalValue.impl(), CSSSelector::PseudoMeterSuboptimal);
-        nameToPseudoType->set(meterEvenLessGoodValue.impl(), CSSSelector::PseudoMeterEvenLessGood);
-#endif
         nameToPseudoType->set(root.impl(), CSSSelector::PseudoRoot);
         nameToPseudoType->set(windowInactive.impl(), CSSSelector::PseudoWindowInactive);
         nameToPseudoType->set(decrement.impl(), CSSSelector::PseudoDecrement);
@@ -477,11 +446,6 @@ void CSSSelector::extractPseudoType() const
     case PseudoInputSpeechButton:
 #endif
     case PseudoInnerSpinButton:
-    case PseudoMeterBar:
-    case PseudoMeterOptimum:
-    case PseudoMeterSuboptimal:
-    case PseudoMeterEvenLessGood:
-    case PseudoOuterSpinButton:
     case PseudoResizer:
     case PseudoScrollbar:
     case PseudoScrollbarCorner:
index cec3202..43e6d80 100644 (file)
@@ -182,10 +182,6 @@ namespace WebCore {
             PseudoSearchDecoration,
             PseudoSearchResultsDecoration,
             PseudoSearchResultsButton,
-            PseudoMeterBar,
-            PseudoMeterOptimum,
-            PseudoMeterSuboptimal,
-            PseudoMeterEvenLessGood,
             PseudoInputListButton,
 #if ENABLE(INPUT_SPEECH)
             PseudoInputSpeechButton,
index 4b6362f..ed61740 100644 (file)
@@ -673,34 +673,35 @@ output {
 
 meter {
     -webkit-appearance: meter;
-    display: inline-block;
+    -webkit-box-sizing: border-box;
+    display: inline-box;
     height: 1em;
     width: 5em;
     vertical-align: -0.2em;
 }
 
-meter::-webkit-meter {
-    -webkit-appearance: meter;
-}
-
 meter::-webkit-meter-bar {
-    -webkit-appearance: meter;
     background: -webkit-gradient(linear, left top, left bottom, from(#ddd), to(#ddd), color-stop(0.20, #eee), color-stop(0.45, #ccc), color-stop(0.55, #ccc));
+    height: 100%;
+    -webkit-box-sizing: border-box;
 }
 
 meter::-webkit-meter-optimum-value {
-    -webkit-appearance: meter;
     background: -webkit-gradient(linear, left top, left bottom, from(#ad7), to(#ad7), color-stop(0.20, #cea), color-stop(0.45, #7a3), color-stop(0.55, #7a3));
+    height: 100%;
+    -webkit-box-sizing: border-box;
 }
 
-meter::-webkit-meter-suboptimal-value {
-    -webkit-appearance: meter;
+meter::-webkit-meter-suboptimum-value {
     background: -webkit-gradient(linear, left top, left bottom, from(#fe7), to(#fe7), color-stop(0.20, #ffc), color-stop(0.45, #db3), color-stop(0.55, #db3));
+    height: 100%;
+    -webkit-box-sizing: border-box;
 }
 
 meter::-webkit-meter-even-less-good-value {
-    -webkit-appearance: meter;
     background: -webkit-gradient(linear, left top, left bottom, from(#f77), to(#f77), color-stop(0.20, #fcc), color-stop(0.45, #d44), color-stop(0.55, #d44));
+    height: 100%;
+    -webkit-box-sizing: border-box;
 }
 
 /* progress */
index 2ebf57e..7687283 100644 (file)
@@ -29,6 +29,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "MeterShadowElement.h"
 #include "RenderMeter.h"
 #include <wtf/StdLibExtras.h>
 
@@ -42,9 +43,15 @@ HTMLMeterElement::HTMLMeterElement(const QualifiedName& tagName, Document* docum
     ASSERT(hasTagName(meterTag));
 }
 
+HTMLMeterElement::~HTMLMeterElement()
+{
+}
+
 PassRefPtr<HTMLMeterElement> HTMLMeterElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
 {
-    return adoptRef(new HTMLMeterElement(tagName, document, form));
+    RefPtr<HTMLMeterElement> meter = adoptRef(new HTMLMeterElement(tagName, document, form));
+    meter->createShadowSubtree();
+    return meter;
 }
 
 RenderObject* HTMLMeterElement::createRenderer(RenderArena* arena, RenderStyle*)
@@ -60,18 +67,16 @@ const AtomicString& HTMLMeterElement::formControlType() const
 
 void HTMLMeterElement::parseMappedAttribute(Attribute* attribute)
 {
-    if (attribute->name() == valueAttr || attribute->name() == minAttr || attribute->name() == maxAttr || attribute->name() == lowAttr || attribute->name() == highAttr || attribute->name() == optimumAttr) {
-        if (renderer())
-            renderer()->updateFromElement();
-    } else
+    if (attribute->name() == valueAttr || attribute->name() == minAttr || attribute->name() == maxAttr || attribute->name() == lowAttr || attribute->name() == highAttr || attribute->name() == optimumAttr)
+        didElementStateChange();
+    else
         HTMLFormControlElement::parseMappedAttribute(attribute);
 }
 
 void HTMLMeterElement::attach()
 {
     HTMLFormControlElement::attach();
-    if (renderer())
-        renderer()->updateFromElement();
+    didElementStateChange();
 }
 
 double HTMLMeterElement::min() const
@@ -203,5 +208,30 @@ HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const
     return GaugeRegionSuboptimal;
 }
 
+double HTMLMeterElement::valueRatio() const
+{
+    double min = this->min();
+    double max = this->max();
+    double value = this->value();
+
+    if (max <= min)
+        return 0;
+    return (value - min) / (max - min);
+}
+
+void HTMLMeterElement::didElementStateChange()
+{
+    m_value->setWidthPercentage(valueRatio()*100);
+}
+
+void HTMLMeterElement::createShadowSubtree()
+{
+    RefPtr<MeterBarElement> bar = MeterBarElement::create(document());
+    m_value = MeterValueElement::create(document());
+    ExceptionCode ec = 0;
+    bar->appendChild(m_value, ec);
+    setShadowRoot(bar);
+}
+
 } // namespace
 #endif
index d5038e0..5ce1193 100644 (file)
@@ -26,6 +26,8 @@
 
 namespace WebCore {
 
+class MeterValueElement;
+
 class HTMLMeterElement : public HTMLFormControlElement {
 public:
     static PassRefPtr<HTMLMeterElement> create(const QualifiedName&, Document*, HTMLFormElement*);
@@ -54,19 +56,23 @@ public:
     double optimum() const;
     void setOptimum(double, ExceptionCode&);
 
+    double valueRatio() const;
     GaugeRegion gaugeRegion() const;
+
 private:
     HTMLMeterElement(const QualifiedName&, Document*, HTMLFormElement*);
+    virtual ~HTMLMeterElement();
 
     virtual bool recalcWillValidate() const { return false; }
-
     virtual const AtomicString& formControlType() const;
-
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
-
     virtual void parseMappedAttribute(Attribute*);
-
     virtual void attach();
+
+    void didElementStateChange();
+    void createShadowSubtree();
+
+    RefPtr<MeterValueElement> m_value;
 };
 
 } // namespace
diff --git a/Source/WebCore/html/shadow/MeterShadowElement.cpp b/Source/WebCore/html/shadow/MeterShadowElement.cpp
new file mode 100644 (file)
index 0000000..224ee87
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(METER_TAG)
+#include "MeterShadowElement.h"
+
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPropertyNames.h"
+#include "HTMLMeterElement.h"
+#include "HTMLNames.h"
+#include "RenderMeter.h"
+#include "RenderTheme.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+MeterShadowElement::MeterShadowElement(Document* document) 
+    : HTMLDivElement(HTMLNames::divTag, document)
+{
+}
+
+HTMLMeterElement* MeterShadowElement::meterElement() const
+{
+    Node* node = const_cast<MeterShadowElement*>(this)->shadowAncestorNode();
+    ASSERT(!node || meterTag == toElement(node)->tagQName());
+    return static_cast<HTMLMeterElement*>(node);
+}
+
+bool MeterShadowElement::rendererIsNeeded(RenderStyle* style)
+{
+    RenderMeter* meterRenderer = toRenderMeter(meterElement()->renderer());
+    return meterRenderer && meterRenderer->theme()->supportsMeter(meterRenderer->style()->appearance()) && HTMLDivElement::rendererIsNeeded(style);
+}
+
+
+const AtomicString& MeterBarElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, pseudId, ("-webkit-meter-bar"));
+    return pseudId;
+}
+
+
+const AtomicString& MeterValueElement::shadowPseudoId() const
+{
+    DEFINE_STATIC_LOCAL(AtomicString, optimumPseudId, ("-webkit-meter-optimum-value"));
+    DEFINE_STATIC_LOCAL(AtomicString, suboptimumPseudId, ("-webkit-meter-suboptimum-value"));
+    DEFINE_STATIC_LOCAL(AtomicString, evenLessGoodPseudId, ("-webkit-meter-even-less-good-value"));
+
+    HTMLMeterElement* meter = meterElement();
+    if (!meter)
+        return optimumPseudId;
+
+    switch (meter->gaugeRegion()) {
+    case HTMLMeterElement::GaugeRegionOptimum:
+        return optimumPseudId;
+    case HTMLMeterElement::GaugeRegionSuboptimal:
+        return suboptimumPseudId;
+    case HTMLMeterElement::GaugeRegionEvenLessGood:
+        return evenLessGoodPseudId;
+    default:
+        ASSERT_NOT_REACHED();
+        return optimumPseudId;
+    }
+}
+
+void MeterValueElement::setWidthPercentage(double width)
+{
+    getInlineStyleDecl()->setProperty(CSSPropertyWidth, width, CSSPrimitiveValue::CSS_PERCENTAGE);
+}
+
+
+}
+
+#endif
+
diff --git a/Source/WebCore/html/shadow/MeterShadowElement.h b/Source/WebCore/html/shadow/MeterShadowElement.h
new file mode 100644 (file)
index 0000000..93626df
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MeterShadowElement_h
+#define MeterShadowElement_h
+
+#include "HTMLDivElement.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class HTMLMeterElement;
+
+class MeterShadowElement : public HTMLDivElement {
+public:
+    MeterShadowElement(Document*);
+    HTMLMeterElement* meterElement() const;
+
+private:
+    virtual bool rendererIsNeeded(RenderStyle*);
+};
+
+class MeterBarElement : public MeterShadowElement {
+public:
+    MeterBarElement(Document* document) 
+        : MeterShadowElement(document)
+    {
+    }
+
+    static PassRefPtr<MeterBarElement> create(Document*);
+    virtual const AtomicString& shadowPseudoId() const;
+};
+
+inline PassRefPtr<MeterBarElement> MeterBarElement::create(Document* document)
+{
+    return adoptRef(new MeterBarElement(document));
+}
+
+
+class MeterValueElement : public MeterShadowElement {
+public:
+    MeterValueElement(Document* document) 
+        : MeterShadowElement(document)
+    {
+    }
+
+    virtual const AtomicString& shadowPseudoId() const;
+    static PassRefPtr<MeterValueElement> create(Document*);
+    void setWidthPercentage(double);
+};
+
+inline PassRefPtr<MeterValueElement> MeterValueElement::create(Document* document)
+{
+    return adoptRef(new MeterValueElement(document));
+}
+
+}
+
+#endif
index 2456325..683bcc4 100644 (file)
@@ -36,27 +36,12 @@ namespace WebCore {
 using namespace HTMLNames;
 
 RenderMeter::RenderMeter(HTMLMeterElement* element)
-    : RenderIndicator(element)
+    : RenderBlock(element)
 {
 }
 
 RenderMeter::~RenderMeter()
 {
-    detachShadows();
-}
-
-PassRefPtr<ShadowBlockElement> RenderMeter::createPart(PseudoId pseudoId)
-{
-    RefPtr<ShadowBlockElement> element = ShadowBlockElement::createForPart(toHTMLElement(node()), pseudoId);
-    if (element->renderer())
-        addChild(element->renderer());
-    return element;
-}
-
-void RenderMeter::updateFromElement()
-{
-    updateShadows();
-    RenderIndicator::updateFromElement();
 }
 
 void RenderMeter::computeLogicalWidth()
@@ -71,105 +56,9 @@ void RenderMeter::computeLogicalHeight()
     setHeight(theme()->meterSizeForBounds(this, frameRect()).height());
 }
 
-void RenderMeter::layoutParts()
-{
-    if (shadowAttached()) {
-        m_barPart->layoutAsPart(barPartRect());
-        m_valuePart->layoutAsPart(valuePartRect());
-    }
-}
-
-void RenderMeter::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
-{
-    RenderBlock::styleDidChange(diff, oldStyle);
-
-    if (!oldStyle)
-        return;
-
-    if (oldStyle->appearance() != style()->appearance()) {
-        detachShadows();
-        updateShadows();
-    }
-}
-
-bool RenderMeter::shouldHaveParts() const
-{
-    return !theme()->supportsMeter(style()->appearance());
-}
-
 double RenderMeter::valueRatio() const
 {
-    HTMLMeterElement* element = static_cast<HTMLMeterElement*>(node());
-    double min = element->min();
-    double max = element->max();
-    double value = element->value();
-
-    if (max <= min)
-        return 0;
-    return (value - min) / (max - min);
-}
-
-IntRect RenderMeter::barPartRect() const
-{
-    return IntRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), lround(width() - borderLeft() - paddingLeft() - borderRight() - paddingRight()), height()  - borderTop() - paddingTop() - borderBottom() - paddingBottom());
-}
-
-IntRect RenderMeter::valuePartRect() const
-{
-    IntRect rect = barPartRect();
-    int width = static_cast<int>(rect.width()*valueRatio());
-    if (!style()->isLeftToRightDirection()) {
-        rect.setX(rect.x() + (rect.width() - width));
-        rect.setWidth(width);
-    } else
-        rect.setWidth(width);
-
-    return rect;
-}
-
-PseudoId RenderMeter::valuePseudoId() const
-{
-    HTMLMeterElement* element = static_cast<HTMLMeterElement*>(node());
-
-    switch (element->gaugeRegion()) {
-    case HTMLMeterElement::GaugeRegionOptimum:
-        return METER_OPTIMUM;
-    case HTMLMeterElement::GaugeRegionSuboptimal:
-        return METER_SUBOPTIMAL;
-    case HTMLMeterElement::GaugeRegionEvenLessGood:
-        return METER_EVEN_LESS_GOOD;
-    }
-
-    ASSERT_NOT_REACHED();
-    return NOPSEUDO;
-}
-
-PseudoId RenderMeter::barPseudoId() const
-{
-    return METER_BAR;
-}
-
-void RenderMeter::detachShadows()
-{
-    if (shadowAttached()) {
-        m_valuePart->detach();
-        m_valuePart = 0;
-        m_barPart->detach();
-        m_barPart = 0;
-    }
-}
-
-void RenderMeter::updateShadows()
-{
-    if (!shadowAttached() && shouldHaveParts()) {
-        m_barPart = createPart(barPseudoId());
-        m_valuePart = createPart(valuePseudoId());
-    }
-
-    if (shadowAttached()) {
-        m_barPart->updateStyleForPart(barPseudoId());
-        m_valuePart->updateStyleForPart(valuePseudoId());
-    }
+    return static_cast<HTMLMeterElement*>(node())->valueRatio();
 }
 
 } // namespace WebCore
index f12364f..96d0619 100644 (file)
@@ -32,36 +32,21 @@ namespace WebCore {
 class HTMLMeterElement;
 class ShadowBlockElement;
 
-class RenderMeter : public RenderIndicator {
+class RenderMeter : public RenderBlock {
 public:
     RenderMeter(HTMLMeterElement*);
     virtual ~RenderMeter();
 
 private:
-    virtual const char* renderName() const { return "RenderMeter"; }
-    virtual bool isMeter() const { return true; }
-    virtual void updateFromElement();
     virtual void computeLogicalWidth();
     virtual void computeLogicalHeight();
 
-    virtual void layoutParts();
-    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
-
-    void updateShadows();
-    void detachShadows();
-
-    bool shadowAttached() const { return m_barPart; }
-    IntRect valuePartRect() const;
-    PseudoId valuePseudoId() const;
-    IntRect barPartRect() const;
-    PseudoId barPseudoId() const;
+    virtual const char* renderName() const { return "RenderMeter"; }
+    virtual bool isMeter() const { return true; }
+    virtual bool requiresForcedStyleRecalcPropagation() const { return true; }
+    virtual bool canHaveChildren() const { return false; }
 
     double valueRatio() const;
-    bool shouldHaveParts() const;
-    PassRefPtr<ShadowBlockElement> createPart(PseudoId);
-
-    RefPtr<ShadowBlockElement> m_barPart;
-    RefPtr<ShadowBlockElement> m_valuePart;
 };
 
 inline RenderMeter* toRenderMeter(RenderObject* object)