Title: [184675] trunk
Revision
184675
Author
[email protected]
Date
2015-05-20 16:34:48 -0700 (Wed, 20 May 2015)

Log Message

REGRESSION (r172591): Can no longer style <optgroup> with colors (LayoutTests/fast/forms/select/optgroup-rendering.html)
https://bugs.webkit.org/show_bug.cgi?id=145227
Source/WebCore:

rdar://problem/20967472

Reviewed by Darin Adler.

Test: fast/forms/select/select-painting.html

Use computedStyle() consistently for option and optgroup items.

* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::paintItemForeground):
(WebCore::RenderListBox::paintItemBackground):

    We can always use computedStyle() and it can't be null. If there was renderer style it would return that.

* rendering/RenderMenuList.cpp:
(RenderMenuList::itemStyle):
(RenderMenuList::getItemBackgroundColor):

LayoutTests:


Reviewed by Darin Adler.

Add ref test for select painting.

* fast/forms/select/select-painting-expected.html: Added.
* fast/forms/select/select-painting.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (184674 => 184675)


--- trunk/LayoutTests/ChangeLog	2015-05-20 23:33:07 UTC (rev 184674)
+++ trunk/LayoutTests/ChangeLog	2015-05-20 23:34:48 UTC (rev 184675)
@@ -1,3 +1,15 @@
+2015-05-20  Antti Koivisto  <[email protected]>
+
+        REGRESSION (r172591): Can no longer style <optgroup> with colors (LayoutTests/fast/forms/select/optgroup-rendering.html)
+        https://bugs.webkit.org/show_bug.cgi?id=145227
+
+        Reviewed by Darin Adler.
+
+        Add ref test for select painting.
+
+        * fast/forms/select/select-painting-expected.html: Added.
+        * fast/forms/select/select-painting.html: Added.
+
 2015-05-20  Daniel Bates  <[email protected]>
 
         AX: AutoFill button is not accessible with VoiceOver

Added: trunk/LayoutTests/fast/forms/select/select-painting-expected.html (0 => 184675)


--- trunk/LayoutTests/fast/forms/select/select-painting-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select/select-painting-expected.html	2015-05-20 23:34:48 UTC (rev 184675)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+
+.select  {
+    width: 100px;
+    height:100px;
+    font-family: sans-serif;
+    font-size: 12px;
+    border: 1px solid black;
+    box-sizing: border-box;
+}
+
+.option {
+    margin-left: 2px;
+    margin-bottom: 1px;
+}
+.optgroup {
+    margin-left: 2px;
+    margin-bottom: 1px;
+    font-weight: bold
+}
+
+#cover {
+    position: absolute;
+    width: 100px;
+    height:300px;
+    background-color: black;
+    left: 80px;
+    top: 0px;
+}
+.red { color: red; }
+</style>
+</head>
+<body>
+<div class=select>
+    <div class=option>One</div>
+    <div class="option red">Two</div>
+</div>
+<div class=select>
+    <div class=optgroup>Optgroup1</div>
+    <div class="optgroup red">Optgroup2</div>
+</div>
+<div id=cover></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/select/select-painting.html (0 => 184675)


--- trunk/LayoutTests/fast/forms/select/select-painting.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select/select-painting.html	2015-05-20 23:34:48 UTC (rev 184675)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+select {
+    width: 100px;
+    height:100px;
+    font-family: sans-serif;
+    font-size: 12px;
+    border: 1px solid black;
+    box-sizing: border-box;
+}
+#cover {
+    position: absolute;
+    width: 100px;
+    height:300px;
+    background-color: black;
+    left: 80px;
+    top: 0px;
+}
+.red { color: red; }
+</style>
+</head>
+<body>
+<select size="4">
+    <option>One</option>
+    <option class=red>Two</option>
+</select><br><select size="4">
+    <optgroup label="Optgroup1"></optgroup>
+    <optgroup label="Optgroup2" class=red></optgroup>
+</select>
+<div id=cover></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (184674 => 184675)


--- trunk/Source/WebCore/ChangeLog	2015-05-20 23:33:07 UTC (rev 184674)
+++ trunk/Source/WebCore/ChangeLog	2015-05-20 23:34:48 UTC (rev 184675)
@@ -1,3 +1,25 @@
+2015-05-20  Antti Koivisto  <[email protected]>
+
+        REGRESSION (r172591): Can no longer style <optgroup> with colors (LayoutTests/fast/forms/select/optgroup-rendering.html)
+        https://bugs.webkit.org/show_bug.cgi?id=145227
+        rdar://problem/20967472
+
+        Reviewed by Darin Adler.
+
+        Test: fast/forms/select/select-painting.html
+
+        Use computedStyle() consistently for option and optgroup items.
+
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::paintItemForeground):
+        (WebCore::RenderListBox::paintItemBackground):
+
+            We can always use computedStyle() and it can't be null. If there was renderer style it would return that.
+
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::itemStyle):
+        (RenderMenuList::getItemBackgroundColor):
+
 2015-05-19  Jer Noble  <[email protected]>
 
         Touching HTMLMediaElement.h or MediaPlayer.h causes a world rebuild.

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (184674 => 184675)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2015-05-20 23:33:07 UTC (rev 184674)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2015-05-20 23:34:48 UTC (rev 184675)
@@ -374,11 +374,9 @@
     const Vector<HTMLElement*>& listItems = selectElement().listItems();
     HTMLElement* listItemElement = listItems[listIndex];
 
-    RenderStyle* itemStyle = listItemElement->renderStyle();
-    if (!itemStyle)
-        itemStyle = &style();
+    RenderStyle& itemStyle = *listItemElement->computedStyle();
 
-    if (itemStyle->visibility() == HIDDEN)
+    if (itemStyle.visibility() == HIDDEN)
         return;
 
     String itemText;
@@ -389,7 +387,7 @@
         itemText = downcast<HTMLOptGroupElement>(*listItemElement).groupLabelText();
     applyTextTransform(style(), itemText, ' ');
 
-    Color textColor = listItemElement->renderStyle() ? listItemElement->renderStyle()->visitedDependentColor(CSSPropertyColor) : style().visitedDependentColor(CSSPropertyColor);
+    Color textColor = itemStyle.visitedDependentColor(CSSPropertyColor);
     if (isOptionElement && downcast<HTMLOptionElement>(*listItemElement).selected()) {
         if (frame().selection().isFocusedAndActive() && document().focusedElement() == &selectElement())
             textColor = theme().activeListBoxSelectionForegroundColor();
@@ -398,13 +396,13 @@
             textColor = theme().inactiveListBoxSelectionForegroundColor();
     }
 
-    ColorSpace colorSpace = itemStyle->colorSpace();
+    ColorSpace colorSpace = itemStyle.colorSpace();
     paintInfo.context->setFillColor(textColor, colorSpace);
 
-    TextRun textRun(itemText, 0, 0, AllowTrailingExpansion, itemStyle->direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding);
+    TextRun textRun(itemText, 0, 0, AllowTrailingExpansion, itemStyle.direction(), isOverride(itemStyle.unicodeBidi()), true, TextRun::NoRounding);
     FontCascade itemFont = style().fontCascade();
     LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex);
-    r.move(itemOffsetForAlignment(textRun, itemStyle, itemFont, r));
+    r.move(itemOffsetForAlignment(textRun, &itemStyle, itemFont, r));
 
     if (is<HTMLOptGroupElement>(*listItemElement)) {
         FontDescription d = itemFont.fontDescription();
@@ -421,6 +419,7 @@
 {
     const Vector<HTMLElement*>& listItems = selectElement().listItems();
     HTMLElement* listItemElement = listItems[listIndex];
+    RenderStyle& itemStyle = *listItemElement->computedStyle();
 
     Color backColor;
     if (is<HTMLOptionElement>(*listItemElement) && downcast<HTMLOptionElement>(*listItemElement).selected()) {
@@ -429,11 +428,11 @@
         else
             backColor = theme().inactiveListBoxSelectionBackgroundColor();
     } else
-        backColor = listItemElement->renderStyle() ? listItemElement->renderStyle()->visitedDependentColor(CSSPropertyBackgroundColor) : style().visitedDependentColor(CSSPropertyBackgroundColor);
+        backColor = itemStyle.visitedDependentColor(CSSPropertyBackgroundColor);
 
     // Draw the background for this list box item
-    if (!listItemElement->renderStyle() || listItemElement->renderStyle()->visibility() != HIDDEN) {
-        ColorSpace colorSpace = listItemElement->renderStyle() ? listItemElement->renderStyle()->colorSpace() : style().colorSpace();
+    if (itemStyle.visibility() != HIDDEN) {
+        ColorSpace colorSpace = itemStyle.colorSpace();
         LayoutRect itemRect = itemBoundingBoxRect(paintOffset, listIndex);
         itemRect.intersect(controlClipRect(paintOffset));
         paintInfo.context->fillRect(snappedIntRect(itemRect), backColor, colorSpace);

Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (184674 => 184675)


--- trunk/Source/WebCore/rendering/RenderMenuList.cpp	2015-05-20 23:33:07 UTC (rev 184674)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp	2015-05-20 23:34:48 UTC (rev 184675)
@@ -522,10 +522,10 @@
     bool itemHasCustomBackgroundColor;
     getItemBackgroundColor(listIndex, itemBackgroundColor, itemHasCustomBackgroundColor);
 
-    RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
-    return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor, style->fontCascade(), style->visibility() == VISIBLE,
-        style->display() == NONE, true, style->textIndent(), style->direction(), isOverride(style->unicodeBidi()),
-        itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : PopupMenuStyle::DefaultBackgroundColor) : menuStyle();
+    RenderStyle& style = *element->computedStyle();
+    return PopupMenuStyle(style.visitedDependentColor(CSSPropertyColor), itemBackgroundColor, style.fontCascade(), style.visibility() == VISIBLE,
+        style.display() == NONE, true, style.textIndent(), style.direction(), isOverride(style.unicodeBidi()),
+        itemHasCustomBackgroundColor ? PopupMenuStyle::CustomBackgroundColor : PopupMenuStyle::DefaultBackgroundColor);
 }
 
 void RenderMenuList::getItemBackgroundColor(unsigned listIndex, Color& itemBackgroundColor, bool& itemHasCustomBackgroundColor) const
@@ -538,9 +538,7 @@
     }
     HTMLElement* element = listItems[listIndex];
 
-    Color backgroundColor;
-    if (element->renderStyle())
-        backgroundColor = element->renderStyle()->visitedDependentColor(CSSPropertyBackgroundColor);
+    Color backgroundColor = element->computedStyle()->visitedDependentColor(CSSPropertyBackgroundColor);
     itemHasCustomBackgroundColor = backgroundColor.isValid() && backgroundColor.alpha();
     // If the item has an opaque background color, return that.
     if (!backgroundColor.hasAlpha()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to