Modifies the logic to compute the dimensions of the drop down menu
arrow that is used in layout tests. This modification allows the
arrow to look the right size in different device scale factors when
using zoom-for-dsf. This is achieved by using a square drop down
arrow instead of a rectangular one. This logic is similar to what
the native theme engine uses.

BUG=640256
COMPONENT=Test Runners, Mock Web Theme Engine
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2340633002
Cr-Commit-Position: refs/heads/master@{#419930}
diff --git a/components/test_runner/mock_web_theme_engine.cc b/components/test_runner/mock_web_theme_engine.cc
index fed1934d..fb0813b 100644
--- a/components/test_runner/mock_web_theme_engine.cc
+++ b/components/test_runner/mock_web_theme_engine.cc
@@ -482,24 +482,26 @@
       }
 
       // clip the drop-down arrow to be inside the select box
-      if (extraParams->menuList.arrowX - 4 > irect.fLeft)
-        irect.fLeft = extraParams->menuList.arrowX - 4;
-      if (extraParams->menuList.arrowX + 12 < irect.fRight)
-        irect.fRight = extraParams->menuList.arrowX + 12;
+      irect.fLeft =
+          std::max(irect.fLeft, extraParams->menuList.arrowX -
+                                    (extraParams->menuList.arrowSize + 1) / 2);
+      irect.fRight =
+          std::min(irect.fLeft + extraParams->menuList.arrowSize, irect.fRight);
 
       irect.fTop = extraParams->menuList.arrowY -
                    (extraParams->menuList.arrowSize) / 2;
-      irect.fBottom = extraParams->menuList.arrowY +
-                      (extraParams->menuList.arrowSize - 1) / 2;
+      irect.fBottom = irect.fTop + (extraParams->menuList.arrowSize);
+
       halfWidth = irect.width() / 2;
       quarterWidth = irect.width() / 4;
 
       if (state == WebThemeEngine::StateFocused)  // FIXME: draw differenty?
         state = WebThemeEngine::StateNormal;
       box(canvas, irect, bgColors(state));
-      triangle(canvas, irect.fLeft + quarterWidth, irect.fTop,
-               irect.fRight - quarterWidth, irect.fTop, irect.fLeft + halfWidth,
-               irect.fBottom, edgeColor);
+      triangle(canvas, irect.fLeft + quarterWidth, irect.fTop + quarterWidth,
+               irect.fRight - quarterWidth, irect.fTop + quarterWidth,
+               irect.fLeft + halfWidth, irect.fBottom - quarterWidth,
+               edgeColor);
 
       break;
 
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 7b5ca7d..3cf3337 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -254,6 +254,96 @@
 
 crbug.com/542541 [ Debug ] fast/events/click-count.html [ Pass Failure ]
 
+
+crbug.com/640256 [ Linux Win ] compositing/overflow/update-widget-positions-on-nested-frames-and-scrollers.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] css3/selectors3/html/css3-modsel-161.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] css3/selectors3/xhtml/css3-modsel-161.xml [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] css3/selectors3/xml/css3-modsel-161.xml [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] editing/pasteboard/4641033.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] editing/selection/replaced-boundaries-3.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] editing/selection/select-box.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] editing/selection/select-element-paragraph-boundary.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/block/float/float-avoidance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/block/margin-collapse/103.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/color/color-suggestion-picker-appearance-zoom125.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/color/color-suggestion-picker-appearance-zoom200.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/color/color-suggestion-picker-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/color/color-suggestion-picker-one-row-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/color/color-suggestion-picker-two-row-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/control-clip-overflow.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/control-restrict-line-height.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/form-element-geometry.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-empty.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-long.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-many.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-rtl-default.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-single-option.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-styled.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-texttransform.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-transform.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-zoom.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance-zoom090.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select-popup/popup-menu-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/003.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/004.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label01.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label02.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label03.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label04.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label06.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/HTMLOptionElement_label07.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/disabled-select-change-index.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-appearance-rtl.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-deselect-update.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-no-overflow.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-restrict-line-height.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-separator-painting.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-style-color.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/menulist-width-change.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/optgroup-rendering.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/option-script.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/option-strip-whitespace.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/option-text-clip.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-align.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-background-none.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-baseline.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-change-listbox-to-popup.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-dirty-parent-pref-widths.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-disabled-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-initial-position.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-selected.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-size-invalid.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-style.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-visual-hebrew.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/select-writing-direction-natural.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/select/selectlist-minsize.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/forms/stuff-on-my-optgroup.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/html/keygen.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/invalid/014.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/parser/document-write-option.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/replaced/replaced-breaking-mixture.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/replaced/replaced-breaking.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] fast/replaced/three-selects-break.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] http/tests/webfont/popup-menu-load-webfont-after-open.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug1188.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug18359.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug2479-3.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug29326.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug33855.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug4382.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/bugs/bug96334.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/core/margins.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] tables/mozilla/dom/tableDom.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] transforms/2d/zoom-menulist.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/parsehtmlonmainthread_coalesce/fast/parser/document-write-option.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/parsehtmlonmainthread_sync/fast/parser/document-write-option.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/prefer_compositing_to_lcd_text/compositing/overflow/update-widget-positions-on-nested-frames-and-scrollers.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/scalefactor150/fast/hidpi/static/popup-menu-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/scalefactor200/fast/hidpi/static/popup-menu-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] virtual/scalefactor200withzoom/fast/hidpi/static/popup-menu-appearance.html [ NeedsRebaseline ]
+crbug.com/640256 [ Linux Win ] webaudio/constructor/convolver.html [ NeedsRebaseline ]
+crbug.com/640256 [ Win ] fast/forms/select-popup/popup-menu-appearance-tall.html [ NeedsRebaseline ]
+
 # TODO(oshima): Mac Android are currently not supported.
 crbug.com/567837 [ Mac Android ] virtual/scalefactor200withzoom/fast/hidpi/static [ Skip ]
 
diff --git a/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp b/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
index a135ca7ab..63d9025 100644
--- a/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
+++ b/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
@@ -42,6 +42,7 @@
 namespace {
 
 const unsigned defaultButtonBackgroundColor = 0xffdddddd;
+const unsigned dropdownMenuListArrowPadding = 3;
 
 bool useMockTheme()
 {
@@ -262,11 +263,13 @@
     if (useMockTheme()) {
         // The size and position of the drop-down button is different between
         // the mock theme and the regular aura theme.
-        int spacingTop = (box.borderTop() + box.paddingTop()).toInt();
-        int spacingBottom = (box.borderBottom() + box.paddingBottom()).toInt();
-        int spacingRight = (box.borderRight() + box.paddingRight()).toInt();
-        extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? rect.x() + 4 + spacingRight: right - 10 - spacingRight;
-        extraParams.menuList.arrowSize = rect.height() - spacingBottom - spacingTop;
+        int extraPadding = dropdownMenuListArrowPadding * box.styleRef().effectiveZoom();
+        // The width available for the arrow is based on the padding provided
+        // in the child LayoutBox.
+        int arrowBoxWidth = ((box.styleRef().direction() == RTL) ? box.firstChildBox()->paddingLeft() : box.firstChildBox()->paddingRight()).toInt();
+        int arrowSize = std::min(arrowBoxWidth, rect.height()) - 2 * extraPadding;
+        extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? rect.x() + extraPadding + (arrowSize / 2) : right - (arrowSize / 2) - extraPadding;
+        extraParams.menuList.arrowSize = arrowSize;
     } else {
         const int arrowSize = 6;
         const int arrowPadding = 6;