Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1020)

Unified Diff: rendering/RenderThemeChromiumSkia.cpp

Issue 269030: Fix decoration position in search input field.... (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « rendering/RenderThemeChromiumSkia.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rendering/RenderThemeChromiumSkia.cpp
===================================================================
--- rendering/RenderThemeChromiumSkia.cpp (revision 49502)
+++ rendering/RenderThemeChromiumSkia.cpp (working copy)
@@ -372,17 +372,28 @@
style->setHeight(Length(cancelButtonSize, Fixed));
}
-bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+IntRect RenderThemeChromiumSkia::calculateParentBoxOfSearchFieldItem(RenderObject* o, const IntRect& r)
{
- IntRect bounds = r;
ASSERT(o->parent());
- if (!o->parent() || !o->parent()->isBox())
- return false;
+ if (!o->isBox() || !o->parent() || !o->parent()->isBox())
+ return IntRect();
+ RenderBox* renderBox = toRenderBox(o);
RenderBox* parentRenderBox = toRenderBox(o->parent());
- IntRect parentBox = parentRenderBox->absoluteContentBox();
+ IntPoint parentBoxPoint = r.location();
+ parentBoxPoint.move(-renderBox->x(), -renderBox->y()); // Restore parent box's location from r.
+ IntRect parentBox(parentBoxPoint, parentRenderBox->contentBoxRect().size());
+ return parentBox;
+}
+bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+{
+ IntRect bounds = r;
+ IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r);
+ if (parentBox.isEmpty())
+ return false;
+
// 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());
@@ -417,13 +428,10 @@
bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
IntRect bounds = r;
- ASSERT(o->parent());
- if (!o->parent() || !o->parent()->isBox())
+ IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r);
+ if (parentBox.isEmpty())
return false;
- 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());
@@ -451,15 +459,10 @@
bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
IntRect bounds = r;
- ASSERT(o->parent());
- if (!o->parent())
+ IntRect parentBox = calculateParentBoxOfSearchFieldItem(o, r);
+ if (parentBox.isEmpty())
return false;
- if (!o->parent() || !o->parent()->isBox())
- return false;
- 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)));
« no previous file with comments | « rendering/RenderThemeChromiumSkia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698