<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200165] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200165">200165</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2016-04-27 18:53:31 -0700 (Wed, 27 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>RTL non-native &lt;select&gt; buttons should have arrows on the left
https://bugs.webkit.org/show_bug.cgi?id=157112
&lt;rdar://problem/25894441&gt;

Reviewed by Simon Fraser.

Source/WebCore:

The &lt;select&gt; elements that are completely rendered by WebCore
(i.e. not the native controls) always assumed that they
were left-to-right.

This change allows the button to handle both directions,
swapping the side the little arrows are rendered on, as
well as the padding of the text label.

Test: fast/forms/select-non-native-rendering-direction.html

* rendering/RenderMenuList.cpp:
(RenderMenuList::clientPaddingLeft): This must take into account
the direction of the element.
(RenderMenuList::clientPaddingRight): Ditto.
* rendering/RenderThemeMac.mm: Change the left and right constants
to use the terms before and after.
(WebCore::RenderThemeMac::paintMenuListButtonDecorations): The left
and right positions must take the direction into account, which
means different calculations.
(WebCore::RenderThemeMac::popupInternalPaddingBox): Similarly for
the padding that is used to position the text label.

LayoutTests:

New test that checks the layout of WebCore-drawn &lt;select&gt;
elements in right-to-left mode.

* fast/forms/select-non-native-rendering-direction.html: Added.
* platform/mac/fast/forms/select-non-native-rendering-direction-expected.png: Added.
* platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMenuListcpp">trunk/Source/WebCore/rendering/RenderMenuList.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderThemeMacmm">trunk/Source/WebCore/rendering/RenderThemeMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformsselectnonnativerenderingdirectionhtml">trunk/LayoutTests/fast/forms/select-non-native-rendering-direction.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsselectnonnativerenderingdirectionexpectedpng">trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformsselectnonnativerenderingdirectionexpectedtxt">trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200164 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-28 01:33:14 UTC (rev 200164)
+++ trunk/LayoutTests/ChangeLog        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-04-27  Dean Jackson  &lt;dino@apple.com&gt;
+
+        RTL non-native &lt;select&gt; buttons should have arrows on the left
+        https://bugs.webkit.org/show_bug.cgi?id=157112
+        &lt;rdar://problem/25894441&gt;
+
+        Reviewed by Simon Fraser.
+
+        New test that checks the layout of WebCore-drawn &lt;select&gt;
+        elements in right-to-left mode.
+
+        * fast/forms/select-non-native-rendering-direction.html: Added.
+        * platform/mac/fast/forms/select-non-native-rendering-direction-expected.png: Added.
+        * platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt: Added.
+
</ins><span class="cx"> 2016-04-27  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: Implement native IDBFactory.getAllDatabaseNames for WebInspector.
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsselectnonnativerenderingdirectionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/select-non-native-rendering-direction.html (0 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/select-non-native-rendering-direction.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/select-non-native-rendering-direction.html        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+&lt;style&gt;
+select {
+    border: 1px solid black;
+}
+&lt;/style&gt;
+&lt;div&gt;
+Left to right select:
+&lt;select&gt;
+&lt;option&gt;Alabama&lt;/option&gt;
+&lt;option&gt;Alaska&lt;/option&gt;
+&lt;option&gt;Arizona&lt;/option&gt;
+&lt;option&gt;Arkansas&lt;/option&gt;
+&lt;option&gt;California&lt;/option&gt;
+&lt;option&gt;Colorado&lt;/option&gt;
+&lt;option&gt;Connecticut&lt;/option&gt;
+&lt;option&gt;Delaware&lt;/option&gt;
+&lt;option&gt;Florida&lt;/option&gt;
+&lt;option&gt;Georgia&lt;/option&gt;
+&lt;option&gt;Hawaii&lt;/option&gt;
+&lt;option&gt;Idaho&lt;/option&gt;
+&lt;option&gt;Illinois&lt;/option&gt;
+&lt;option&gt;Indiana&lt;/option&gt;
+&lt;option&gt;Iowa&lt;/option&gt;
+&lt;option&gt;Kansas&lt;/option&gt;
+&lt;option&gt;Kentucky&lt;/option&gt;
+&lt;option&gt;Louisiana&lt;/option&gt;
+&lt;option&gt;Maine&lt;/option&gt;
+&lt;option&gt;Maryland&lt;/option&gt;
+&lt;option&gt;Massachusetts&lt;/option&gt;
+&lt;option&gt;Michigan&lt;/option&gt;
+&lt;option&gt;Minnesota&lt;/option&gt;
+&lt;option&gt;Mississippi&lt;/option&gt;
+&lt;option&gt;Missouri&lt;/option&gt;
+&lt;option&gt;Montana&lt;/option&gt;
+&lt;option&gt;Nebraska&lt;/option&gt;
+&lt;option&gt;Nevada&lt;/option&gt;
+&lt;option&gt;New Hampshire&lt;/option&gt;
+&lt;option&gt;New Jersey&lt;/option&gt;
+&lt;option&gt;New Mexico&lt;/option&gt;
+&lt;option&gt;New York&lt;/option&gt;
+&lt;option&gt;North Carolina&lt;/option&gt;
+&lt;option&gt;North Dakota&lt;/option&gt;
+&lt;option&gt;Ohio&lt;/option&gt;
+&lt;option&gt;Oklahoma&lt;/option&gt;
+&lt;option&gt;Oregon&lt;/option&gt;
+&lt;option&gt;Pennsylvania&lt;/option&gt;
+&lt;option&gt;Rhode Island&lt;/option&gt;
+&lt;option&gt;South Carolina&lt;/option&gt;
+&lt;option&gt;South Dakota&lt;/option&gt;
+&lt;option&gt;Tennessee&lt;/option&gt;
+&lt;option&gt;Texas&lt;/option&gt;
+&lt;option&gt;Utah&lt;/option&gt;
+&lt;option&gt;Vermont&lt;/option&gt;
+&lt;option&gt;Virginia&lt;/option&gt;
+&lt;option&gt;Washington&lt;/option&gt;
+&lt;option&gt;West Virginia&lt;/option&gt;
+&lt;option&gt;Wisconsin&lt;/option&gt;
+&lt;option&gt;Wyoming&lt;/option&gt;
+&lt;/select&gt;
+&lt;/div&gt;
+
+&lt;div dir=&quot;rtl&quot;&gt;
+Right to left select:
+&lt;select&gt;
+&lt;option&gt;Alabama&lt;/option&gt;
+&lt;option&gt;Alaska&lt;/option&gt;
+&lt;option&gt;Arizona&lt;/option&gt;
+&lt;option&gt;Arkansas&lt;/option&gt;
+&lt;option&gt;California&lt;/option&gt;
+&lt;option&gt;Colorado&lt;/option&gt;
+&lt;option&gt;Connecticut&lt;/option&gt;
+&lt;option&gt;Delaware&lt;/option&gt;
+&lt;option&gt;Florida&lt;/option&gt;
+&lt;option&gt;Georgia&lt;/option&gt;
+&lt;option&gt;Hawaii&lt;/option&gt;
+&lt;option&gt;Idaho&lt;/option&gt;
+&lt;option&gt;Illinois&lt;/option&gt;
+&lt;option&gt;Indiana&lt;/option&gt;
+&lt;option&gt;Iowa&lt;/option&gt;
+&lt;option&gt;Kansas&lt;/option&gt;
+&lt;option&gt;Kentucky&lt;/option&gt;
+&lt;option&gt;Louisiana&lt;/option&gt;
+&lt;option&gt;Maine&lt;/option&gt;
+&lt;option&gt;Maryland&lt;/option&gt;
+&lt;option&gt;Massachusetts&lt;/option&gt;
+&lt;option&gt;Michigan&lt;/option&gt;
+&lt;option&gt;Minnesota&lt;/option&gt;
+&lt;option&gt;Mississippi&lt;/option&gt;
+&lt;option&gt;Missouri&lt;/option&gt;
+&lt;option&gt;Montana&lt;/option&gt;
+&lt;option&gt;Nebraska&lt;/option&gt;
+&lt;option&gt;Nevada&lt;/option&gt;
+&lt;option&gt;New Hampshire&lt;/option&gt;
+&lt;option&gt;New Jersey&lt;/option&gt;
+&lt;option&gt;New Mexico&lt;/option&gt;
+&lt;option&gt;New York&lt;/option&gt;
+&lt;option&gt;North Carolina&lt;/option&gt;
+&lt;option&gt;North Dakota&lt;/option&gt;
+&lt;option&gt;Ohio&lt;/option&gt;
+&lt;option&gt;Oklahoma&lt;/option&gt;
+&lt;option&gt;Oregon&lt;/option&gt;
+&lt;option&gt;Pennsylvania&lt;/option&gt;
+&lt;option&gt;Rhode Island&lt;/option&gt;
+&lt;option&gt;South Carolina&lt;/option&gt;
+&lt;option&gt;South Dakota&lt;/option&gt;
+&lt;option&gt;Tennessee&lt;/option&gt;
+&lt;option&gt;Texas&lt;/option&gt;
+&lt;option&gt;Utah&lt;/option&gt;
+&lt;option&gt;Vermont&lt;/option&gt;
+&lt;option&gt;Virginia&lt;/option&gt;
+&lt;option&gt;Washington&lt;/option&gt;
+&lt;option&gt;West Virginia&lt;/option&gt;
+&lt;option&gt;Wisconsin&lt;/option&gt;
+&lt;option&gt;Wyoming&lt;/option&gt;
+&lt;/select&gt;
+&lt;/div&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/forms/select-non-native-rendering-direction.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsplatformmacfastformsselectnonnativerenderingdirectionexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastformsselectnonnativerenderingdirectionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt (0 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x22
+        RenderText {#text} at (0,1) size 127x18
+          text run at (0,1) width 127: &quot;Left to right select: &quot;
+        RenderMenuList {SELECT} at (128,2) size 116x18 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+          RenderBlock (anonymous) at (1,1) size 113x16
+            RenderText at (8,1) size 47x13
+              text run at (8,1) width 47: &quot;Alabama&quot;
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,22) size 784x22
+        RenderText {#text} at (657,1) size 127x18
+          text run at (657,1) width 10 RTL: &quot;: &quot;
+          text run at (666,1) width 118: &quot;Right to left select&quot;
+        RenderMenuList {SELECT} at (540,2) size 116x18 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+          RenderBlock (anonymous) at (1,1) size 113x16
+            RenderText at (58,1) size 47x13
+              text run at (58,1) width 47: &quot;Alabama&quot;
+        RenderText {#text} at (0,0) size 0x0
</ins><span class="cx">Property changes on: trunk/LayoutTests/platform/mac/fast/forms/select-non-native-rendering-direction-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200164 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-28 01:33:14 UTC (rev 200164)
+++ trunk/Source/WebCore/ChangeLog        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-04-27  Dean Jackson  &lt;dino@apple.com&gt;
+
+        RTL non-native &lt;select&gt; buttons should have arrows on the left
+        https://bugs.webkit.org/show_bug.cgi?id=157112
+        &lt;rdar://problem/25894441&gt;
+
+        Reviewed by Simon Fraser.
+
+        The &lt;select&gt; elements that are completely rendered by WebCore
+        (i.e. not the native controls) always assumed that they
+        were left-to-right.
+
+        This change allows the button to handle both directions,
+        swapping the side the little arrows are rendered on, as
+        well as the padding of the text label.
+
+        Test: fast/forms/select-non-native-rendering-direction.html
+
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::clientPaddingLeft): This must take into account
+        the direction of the element.
+        (RenderMenuList::clientPaddingRight): Ditto.
+        * rendering/RenderThemeMac.mm: Change the left and right constants
+        to use the terms before and after.
+        (WebCore::RenderThemeMac::paintMenuListButtonDecorations): The left
+        and right positions must take the direction into account, which
+        means different calculations.
+        (WebCore::RenderThemeMac::popupInternalPaddingBox): Similarly for
+        the padding that is used to position the text label.
+
</ins><span class="cx"> 2016-04-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CSS and SVG animations should run at 60fps
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMenuListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (200164 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMenuList.cpp        2016-04-28 01:33:14 UTC (rev 200164)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -591,24 +591,27 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const int endOfLinePadding = 2;
+
</ins><span class="cx"> LayoutUnit RenderMenuList::clientPaddingLeft() const
</span><span class="cx"> {
</span><del>-    return paddingLeft() + m_innerBlock-&gt;paddingLeft();
-}
-
-const int endOfLinePadding = 2;
-LayoutUnit RenderMenuList::clientPaddingRight() const
-{
-    if (style().appearance() == MenulistPart || style().appearance() == MenulistButtonPart) {
</del><ins>+    if ((style().appearance() == MenulistPart || style().appearance() == MenulistButtonPart) &amp;&amp; style().direction() == RTL) {
</ins><span class="cx">         // For these appearance values, the theme applies padding to leave room for the
</span><span class="cx">         // drop-down button. But leaving room for the button inside the popup menu itself
</span><span class="cx">         // looks strange, so we return a small default padding to avoid having a large empty
</span><span class="cx">         // space appear on the side of the popup menu.
</span><span class="cx">         return endOfLinePadding;
</span><span class="cx">     }
</span><del>-
</del><span class="cx">     // If the appearance isn't MenulistPart, then the select is styled (non-native), so
</span><span class="cx">     // we want to return the user specified padding.
</span><ins>+    return paddingLeft() + m_innerBlock-&gt;paddingLeft();
+}
+
+LayoutUnit RenderMenuList::clientPaddingRight() const
+{
+    if ((style().appearance() == MenulistPart || style().appearance() == MenulistButtonPart) &amp;&amp; style().direction() == LTR)
+        return endOfLinePadding;
+
</ins><span class="cx">     return paddingRight() + m_innerBlock-&gt;paddingRight();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderThemeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (200164 => 200165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-04-28 01:33:14 UTC (rev 200164)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm        2016-04-28 01:53:31 UTC (rev 200165)
</span><span class="lines">@@ -1161,8 +1161,8 @@
</span><span class="cx"> const float baseArrowHeight = 4.0f;
</span><span class="cx"> const float baseArrowWidth = 5.0f;
</span><span class="cx"> const float baseSpaceBetweenArrows = 2.0f;
</span><del>-const int arrowPaddingLeft = 6;
-const int arrowPaddingRight = 6;
</del><ins>+const int arrowPaddingBefore = 6;
+const int arrowPaddingAfter = 6;
</ins><span class="cx"> const int paddingBeforeSeparator = 4;
</span><span class="cx"> const int baseBorderRadius = 5;
</span><span class="cx"> const int styledPopupPaddingLeft = 8;
</span><span class="lines">@@ -1278,6 +1278,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderThemeMac::paintMenuListButtonDecorations(const RenderBox&amp; renderer, const PaintInfo&amp; paintInfo, const FloatRect&amp; rect)
</span><span class="cx"> {
</span><ins>+    bool isRTL = renderer.style().direction() == RTL;
</ins><span class="cx">     IntRect bounds = IntRect(rect.x() + renderer.style().borderLeftWidth(),
</span><span class="cx">         rect.y() + renderer.style().borderTopWidth(),
</span><span class="cx">         rect.width() - renderer.style().borderLeftWidth() - renderer.style().borderRightWidth(),
</span><span class="lines">@@ -1290,10 +1291,14 @@
</span><span class="cx">     float centerY = bounds.y() + bounds.height() / 2.0f;
</span><span class="cx">     float arrowHeight = baseArrowHeight * fontScale;
</span><span class="cx">     float arrowWidth = baseArrowWidth * fontScale;
</span><del>-    float leftEdge = bounds.maxX() - arrowPaddingRight * renderer.style().effectiveZoom() - arrowWidth;
</del><ins>+    float leftEdge;
+    if (isRTL)
+        leftEdge = bounds.x() + arrowPaddingAfter * renderer.style().effectiveZoom();
+    else
+        leftEdge = bounds.maxX() - arrowPaddingAfter * renderer.style().effectiveZoom() - arrowWidth;
</ins><span class="cx">     float spaceBetweenArrows = baseSpaceBetweenArrows * fontScale;
</span><span class="cx"> 
</span><del>-    if (bounds.width() &lt; arrowWidth + arrowPaddingLeft * renderer.style().effectiveZoom())
</del><ins>+    if (bounds.width() &lt; arrowWidth + arrowPaddingBefore * renderer.style().effectiveZoom())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     GraphicsContextStateSaver stateSaver(paintInfo.context());
</span><span class="lines">@@ -1322,18 +1327,22 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Should the separator thickness and space be scaled up by fontScale?
</span><span class="cx">     int separatorSpace = 2; // Deliberately ignores zoom since it looks nicer if it stays thin.
</span><del>-    int leftEdgeOfSeparator = static_cast&lt;int&gt;(leftEdge - arrowPaddingLeft * renderer.style().effectiveZoom()); // FIXME: Round?
</del><ins>+    int leftEdgeOfSeparator;
+    if (isRTL)
+        leftEdgeOfSeparator = static_cast&lt;int&gt;(roundf(leftEdge + arrowWidth + arrowPaddingBefore * renderer.style().effectiveZoom()));
+    else
+        leftEdgeOfSeparator = static_cast&lt;int&gt;(roundf(leftEdge - arrowPaddingBefore * renderer.style().effectiveZoom()));
</ins><span class="cx"> 
</span><span class="cx">     // Draw the separator to the left of the arrows
</span><span class="cx">     paintInfo.context().setStrokeThickness(1); // Deliberately ignores zoom since it looks nicer if it stays thin.
</span><span class="cx">     paintInfo.context().setStrokeStyle(SolidStroke);
</span><span class="cx">     paintInfo.context().setStrokeColor(leftSeparatorColor);
</span><span class="cx">     paintInfo.context().drawLine(IntPoint(leftEdgeOfSeparator, bounds.y()),
</span><del>-                                IntPoint(leftEdgeOfSeparator, bounds.maxY()));
</del><ins>+        IntPoint(leftEdgeOfSeparator, bounds.maxY()));
</ins><span class="cx"> 
</span><span class="cx">     paintInfo.context().setStrokeColor(rightSeparatorColor);
</span><span class="cx">     paintInfo.context().drawLine(IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.y()),
</span><del>-                                IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.maxY()));
</del><ins>+        IntPoint(leftEdgeOfSeparator + separatorSpace, bounds.maxY()));
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1383,9 +1392,14 @@
</span><span class="cx"> 
</span><span class="cx">     if (style.appearance() == MenulistButtonPart) {
</span><span class="cx">         float arrowWidth = baseArrowWidth * (style.fontSize() / baseFontSize);
</span><ins>+        float rightPadding = ceilf(arrowWidth + (arrowPaddingBefore + arrowPaddingAfter + paddingBeforeSeparator) * style.effectiveZoom());
+        float leftPadding = styledPopupPaddingLeft * style.effectiveZoom();
+        if (style.direction() == RTL)
+            std::swap(rightPadding, leftPadding);
</ins><span class="cx">         return { static_cast&lt;int&gt;(styledPopupPaddingTop * style.effectiveZoom()),
</span><del>-            static_cast&lt;int&gt;(ceilf(arrowWidth + (arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator) * style.effectiveZoom())),
-            static_cast&lt;int&gt;(styledPopupPaddingBottom * style.effectiveZoom()), static_cast&lt;int&gt;(styledPopupPaddingLeft * style.effectiveZoom()) };
</del><ins>+            static_cast&lt;int&gt;(rightPadding),
+            static_cast&lt;int&gt;(styledPopupPaddingBottom * style.effectiveZoom()),
+            static_cast&lt;int&gt;(leftPadding) };
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return { 0, 0, 0, 0 };
</span></span></pre>
</div>
</div>

</body>
</html>