bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r) { // Get the renderer of <input> element. Node* input = cancelButtonObject->node()->shadowHost(); RenderObject* baseRenderer = input ? input->renderer() : cancelButtonObject; if (!baseRenderer->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(baseRenderer); LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height())); // Calculate cancel button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(), inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, cancelButtonSize, cancelButtonSize); IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r); static Image* cancelImage = Image::loadPlatformResource("searchCancel").leakRef(); static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").leakRef(); paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage, cancelButtonObject->style()->colorSpace(), paintingRect); return false; }
bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* magnifierObject, const PaintInfo& paintInfo, const IntRect& r) { // Get the renderer of <input> element. if (!magnifierObject->node()) return false; Node* input = magnifierObject->node()->shadowHost(); RenderObject* baseRenderer = input ? input->renderer() : magnifierObject; if (!baseRenderer->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(baseRenderer); LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled decoration stays square and will fit in its parent's box. LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height())); // Calculate decoration's coordinates relative to the input element. // Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2, magnifierSize, magnifierSize); IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searchMagnifier"))); paintInfo.context->drawImage(magnifierImage, paintingRect); return false; }
bool ThemePainterDefault::paintSearchFieldCancelButton( const LayoutObject& cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r) { // Get the layoutObject of <input> element. if (!cancelButtonObject.node()) return false; Node* input = cancelButtonObject.node()->ownerShadowHost(); const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : cancelButtonObject; if (!baseLayoutObject.isBox()) return false; const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), LayoutUnit(r.height()))); // Calculate cancel button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one // pixel off-center, it will be one pixel closer to the bottom of the field. // This tends to look better with the text. LayoutRect cancelButtonRect( cancelButtonObject.offsetFromAncestorContainer(&inputLayoutBox).width(), inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, cancelButtonSize, cancelButtonSize); IntRect paintingRect = convertToPaintingRect( inputLayoutBox, cancelButtonObject, cancelButtonRect, r); DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCancel"))); DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("searchCancelPressed"))); paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage, paintingRect); return false; }
bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnifierObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { // Get the renderer of <input> element. Node* input = magnifierObject->node()->shadowAncestorNode(); if (!input->renderer()->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(input->renderer()); IntRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled decoration will fit in its parent's box. int magnifierHeight = std::min(inputContentBox.height(), r.height()); int magnifierWidth = std::min(inputContentBox.width(), static_cast<int>(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)); IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2, magnifierWidth, magnifierHeight); IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef(); paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect); return false; }