Changeset 55617 in webkit
- Timestamp:
- Mar 6, 2010 4:26:08 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55614 r55617 1 2010-03-06 Yuta Kitamura <yutak@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Fix decoration position in search input field. 6 7 This patch fixes rendering of input field of "search" type, whose decoration 8 (loupe icon and close button) was wrongly positioned when the input field was 9 contained in a block with -webkit-transform property. 10 11 Chromium bug: http://crbug.com/20439 12 13 [Chromium] Decoration of "search" input field is wrongly rendered 14 https://bugs.webkit.org/show_bug.cgi?id=30245 15 16 No new tests, since this patch fixes an existing test 17 (fast/forms/search-transformed.html) in Chromium layout tests. 18 19 * rendering/RenderThemeChromiumSkia.cpp: 20 (WebCore::RenderThemeChromiumSkia::convertToPaintingRect): Added. This method 21 does almost the same thing as RenderThemeMac::convertToPaintingRect. 22 (WebCore::RenderThemeChromiumSkia::paintSearchFieldCancelButton): The position 23 of the icon should not depend on its absolute position. 24 (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsDecoration): Ditto. 25 (WebCore::RenderThemeChromiumSkia::paintSearchFieldResultsButton): Ditto. 26 * rendering/RenderThemeChromiumSkia.h: Added new method. 27 1 28 2010-03-06 Ilya Tikhonovsky <loislo@chromium.org> 2 29 -
trunk/WebCore/rendering/RenderThemeChromiumSkia.cpp
r53289 r55617 404 404 } 405 405 406 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) 407 { 408 IntRect bounds = r; 409 ASSERT(o->parent()); 410 if (!o->parent() || !o->parent()->isBox()) 406 IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const 407 { 408 // Compute an offset between the part renderer and the input renderer. 409 IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer)); 410 // Move the rect into partRenderer's coords. 411 partRect.move(offsetFromInputRenderer); 412 // Account for the local drawing offset. 413 partRect.move(localOffset.x(), localOffset.y()); 414 415 return partRect; 416 } 417 418 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 419 { 420 // Get the renderer of <input> element. 421 Node* input = cancelButtonObject->node()->shadowAncestorNode(); 422 if (!input->renderer()->isBox()) 411 423 return false; 412 413 RenderBox* parentRenderBox = toRenderBox(o->parent()); 414 415 IntRect parentBox = parentRenderBox->absoluteContentBox(); 416 417 // Make sure the scaled button stays square and will fit in its parent's box 418 bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); 419 bounds.setWidth(bounds.height()); 420 424 RenderBox* inputRenderBox = toRenderBox(input->renderer()); 425 IntRect inputContentBox = inputRenderBox->contentBoxRect(); 426 427 // Make sure the scaled button stays square and will fit in its parent's box. 428 int cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height())); 429 // Calculate cancel button's coordinates relative to the input element. 421 430 // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will 422 431 // be one pixel closer to the bottom of the field. This tends to look better with the text. 423 bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); 432 IntRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(), 433 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, 434 cancelButtonSize, cancelButtonSize); 435 IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r); 424 436 425 437 static Image* cancelImage = Image::loadPlatformResource("searchCancel").releaseRef(); 426 438 static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef(); 427 i.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage, o->style()->colorSpace(), bounds); 439 paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage, 440 cancelButtonObject->style()->colorSpace(), paintingRect); 428 441 return false; 429 442 } … … 446 459 } 447 460 448 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)449 { 450 IntRect bounds = r;451 ASSERT(o->parent());452 if (! o->parent() || !o->parent()->isBox())461 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* magnifierObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 462 { 463 // Get the renderer of <input> element. 464 Node* input = magnifierObject->node()->shadowAncestorNode(); 465 if (!input->renderer()->isBox()) 453 466 return false; 454 455 RenderBox* parentRenderBox = toRenderBox(o->parent()); 456 IntRect parentBox = parentRenderBox->absoluteContentBox(); 457 458 // Make sure the scaled decoration stays square and will fit in its parent's box 459 bounds.setHeight(std::min(parentBox.width(), std::min(parentBox.height(), bounds.height()))); 460 bounds.setWidth(bounds.height()); 461 467 RenderBox* inputRenderBox = toRenderBox(input->renderer()); 468 IntRect inputContentBox = inputRenderBox->contentBoxRect(); 469 470 // Make sure the scaled decoration stays square and will fit in its parent's box. 471 int magnifierSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height())); 472 // Calculate decoration's coordinates relative to the input element. 462 473 // Center the decoration vertically. Round up though, so if it has to be one pixel off-center, it will 463 474 // be one pixel closer to the bottom of the field. This tends to look better with the text. 464 bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); 475 IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), 476 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2, 477 magnifierSize, magnifierSize); 478 IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); 465 479 466 480 static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef(); 467 i.context->drawImage(magnifierImage, o->style()->colorSpace(), bounds);481 paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect); 468 482 return false; 469 483 } … … 480 494 } 481 495 482 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)483 { 484 IntRect bounds = r;485 ASSERT(o->parent());486 if (! o->parent())496 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnifierObject, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 497 { 498 // Get the renderer of <input> element. 499 Node* input = magnifierObject->node()->shadowAncestorNode(); 500 if (!input->renderer()->isBox()) 487 501 return false; 488 if (!o->parent() || !o->parent()->isBox()) 489 return false; 490 491 RenderBox* parentRenderBox = toRenderBox(o->parent()); 492 IntRect parentBox = parentRenderBox->absoluteContentBox(); 493 494 // Make sure the scaled decoration will fit in its parent's box 495 bounds.setHeight(std::min(parentBox.height(), bounds.height())); 496 bounds.setWidth(std::min(parentBox.width(), static_cast<int>(bounds.height() * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize))); 497 498 // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will 499 // be one pixel closer to the bottom of the field. This tends to look better with the text. 500 bounds.setY(parentBox.y() + (parentBox.height() - bounds.height() + 1) / 2); 502 RenderBox* inputRenderBox = toRenderBox(input->renderer()); 503 IntRect inputContentBox = inputRenderBox->contentBoxRect(); 504 505 // Make sure the scaled decoration will fit in its parent's box. 506 int magnifierHeight = std::min(inputContentBox.height(), r.height()); 507 int magnifierWidth = std::min(inputContentBox.width(), static_cast<int>(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize)); 508 IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(), 509 inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2, 510 magnifierWidth, magnifierHeight); 511 IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r); 501 512 502 513 static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef(); 503 i.context->drawImage(magnifierImage, o->style()->colorSpace(), bounds);514 paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect); 504 515 return false; 505 516 } -
trunk/WebCore/rendering/RenderThemeChromiumSkia.h
r51428 r55617 154 154 int menuListInternalPadding(RenderStyle*, int paddingType) const; 155 155 bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); 156 IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const; 156 157 }; 157 158
Note: See TracChangeset
for help on using the changeset viewer.