summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderThemeChromiumSkia.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/rendering/RenderThemeChromiumSkia.cpp
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/rendering/RenderThemeChromiumSkia.cpp')
-rw-r--r--WebCore/rendering/RenderThemeChromiumSkia.cpp117
1 files changed, 54 insertions, 63 deletions
diff --git a/WebCore/rendering/RenderThemeChromiumSkia.cpp b/WebCore/rendering/RenderThemeChromiumSkia.cpp
index 7d3bcec..8b3b388 100644
--- a/WebCore/rendering/RenderThemeChromiumSkia.cpp
+++ b/WebCore/rendering/RenderThemeChromiumSkia.cpp
@@ -403,28 +403,41 @@ void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelecto
style->setHeight(Length(cancelButtonSize, Fixed));
}
-bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
{
- IntRect bounds = r;
- ASSERT(o->parent());
- if (!o->parent() || !o->parent()->isBox())
- return false;
-
- RenderBox* parentRenderBox = toRenderBox(o->parent());
+ // Compute an offset between the part renderer and the input renderer.
+ IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
+ // Move the rect into partRenderer's coords.
+ partRect.move(offsetFromInputRenderer);
+ // Account for the local drawing offset.
+ partRect.move(localOffset.x(), localOffset.y());
- IntRect parentBox = parentRenderBox->absoluteContentBox();
+ return partRect;
+}
- // Make sure the scaled button stays square and will fit in its parent's box
- bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
- bounds.setWidth(bounds.height());
+bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
+{
+ // Get the renderer of <input> element.
+ Node* input = cancelButtonObject->node()->shadowAncestorNode();
+ if (!input->renderer()->isBox())
+ return false;
+ RenderBox* inputRenderBox = toRenderBox(input->renderer());
+ IntRect inputContentBox = inputRenderBox->contentBoxRect();
+ // Make sure the scaled button stays square and will fit in its parent's box.
+ int cancelButtonSize = std::min(inputContentBox.width(), std::min(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.
- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
+ IntRect 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").releaseRef();
static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef();
- i.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage, o->style()->colorSpace(), bounds);
+ paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage,
+ cancelButtonObject->style()->colorSpace(), paintingRect);
return false;
}
@@ -445,26 +458,27 @@ void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(CSSStyleSe
style->setHeight(Length(magnifierSize, Fixed));
}
-bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* magnifierObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
- IntRect bounds = r;
- ASSERT(o->parent());
- if (!o->parent() || !o->parent()->isBox())
+ // 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();
- RenderBox* parentRenderBox = toRenderBox(o->parent());
- IntRect parentBox = parentRenderBox->absoluteContentBox();
-
- // Make sure the scaled decoration stays square and will fit in its parent's box
- bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height())));
- bounds.setWidth(bounds.height());
-
+ // Make sure the scaled decoration stays square and will fit in its parent's box.
+ int magnifierSize = std::min(inputContentBox.width(), std::min(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.
- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
+ IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
+ inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
+ magnifierSize, magnifierSize);
+ IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef();
- i.context->drawImage(magnifierImage, o->style()->colorSpace(), bounds);
+ paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect);
return false;
}
@@ -479,28 +493,25 @@ void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelect
style->setHeight(Length(magnifierHeight, Fixed));
}
-bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnifierObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
- IntRect bounds = r;
- ASSERT(o->parent());
- if (!o->parent())
- return false;
- if (!o->parent() || !o->parent()->isBox())
+ // 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();
- RenderBox* parentRenderBox = toRenderBox(o->parent());
- IntRect parentBox = parentRenderBox->absoluteContentBox();
-
- // Make sure the scaled decoration will fit in its parent's box
- bounds.setHeight(std::min(parentBox.height(), bounds.height()));
- bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)));
-
- // 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.
- bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2);
+ // 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();
- i.context->drawImage(magnifierImage, o->style()->colorSpace(), bounds);
+ paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect);
return false;
}
@@ -721,26 +732,6 @@ int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) cons
return menuListInternalPadding(style, BottomPadding);
}
-int RenderThemeChromiumSkia::buttonInternalPaddingLeft() const
-{
- return 3;
-}
-
-int RenderThemeChromiumSkia::buttonInternalPaddingRight() const
-{
- return 3;
-}
-
-int RenderThemeChromiumSkia::buttonInternalPaddingTop() const
-{
- return 1;
-}
-
-int RenderThemeChromiumSkia::buttonInternalPaddingBottom() const
-{
- return 1;
-}
-
#if ENABLE(VIDEO)
bool RenderThemeChromiumSkia::shouldRenderMediaControlPart(ControlPart part, Element* e)
{