bool RenderThemeChromiumWin::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r) { if (!o->isBox()) return false; const RenderBox* box = toRenderBox(o); // Take padding and border into account. If the MenuList is smaller than // the size of a button, make sure to shrink it appropriately and not put // its x position to the left of the menulist. const int buttonWidth = menuListButtonWidth(); int spacingLeft = box->borderLeft() + box->paddingLeft(); int spacingRight = box->borderRight() + box->paddingRight(); int spacingTop = box->borderTop() + box->paddingTop(); int spacingBottom = box->borderBottom() + box->paddingBottom(); int buttonX; if (r.maxX() - r.x() < buttonWidth) buttonX = r.x(); else buttonX = o->style()->direction() == LTR ? r.maxX() - spacingRight - buttonWidth : r.x() + spacingLeft; // Compute the rectangle of the button in the destination image. IntRect rect(buttonX, r.y() + spacingTop, std::min(buttonWidth, r.maxX() - r.x()), r.height() - (spacingTop + spacingBottom)); // Get the correct theme data for a textfield and paint the menu. ThemePainter painter(i.context, rect); WebKit::WebCanvas* canvas = painter.context()->platformContext()->canvas(); WebKit::Platform::current()->themeEngine()->paintMenuList(canvas, CP_DROPDOWNBUTTON, determineState(o), determineClassicState(o), WebKit::WebRect(painter.drawRect())); return false; }
// Used to paint unstyled menulists (i.e. with the default border) bool RenderThemeChromiumWin::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) { if (!o->isBox()) return false; const RenderBox* box = toRenderBox(o); int borderRight = box->borderRight(); int borderLeft = box->borderLeft(); int borderTop = box->borderTop(); int borderBottom = box->borderBottom(); // If all the borders are 0, then tell skia not to paint the border on the // textfield. FIXME: http://b/1210017 Figure out how to get Windows to not // draw individual borders and then pass that to skia so we can avoid // drawing any borders that are set to 0. For non-zero borders, we draw the // border, but webkit just draws over it. bool drawEdges = !(!borderRight && !borderLeft && !borderTop && !borderBottom); paintTextFieldInternal(o, i, r, drawEdges); // Take padding and border into account. If the MenuList is smaller than // the size of a button, make sure to shrink it appropriately and not put // its x position to the left of the menulist. const int buttonWidth = menuListButtonWidth(); int spacingLeft = borderLeft + box->paddingLeft(); int spacingRight = borderRight + box->paddingRight(); int spacingTop = borderTop + box->paddingTop(); int spacingBottom = borderBottom + box->paddingBottom(); int buttonX; if (r.right() - r.x() < buttonWidth) buttonX = r.x(); else buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - buttonWidth : r.x() + spacingLeft; // Compute the rectangle of the button in the destination image. IntRect rect(buttonX, r.y() + spacingTop, std::min(buttonWidth, r.right() - r.x()), r.height() - (spacingTop + spacingBottom)); // Get the correct theme data for a textfield and paint the menu. ThemePainter painter(i.context, rect); ChromiumBridge::paintMenuList(painter.context(), CP_DROPDOWNBUTTON, determineState(o), determineClassicState(o), painter.drawRect()); return false; }