Changeset 116353 in webkit
- Timestamp:
- May 7, 2012 2:30:57 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116349 r116353 1 2012-05-07 Shezan Baig <shezbaig.wk@gmail.com> 2 3 Selection Background Color Error 4 https://bugs.webkit.org/show_bug.cgi?id=80382 5 6 Reviewed by David Hyatt. 7 8 Added new test case for selection background color. 9 10 * fast/backgrounds/selection-background-color.html: Added. 11 * fast/backgrounds/selection-background-color-expected.html: Added. 12 1 13 2012-05-07 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r116351 r116353 1 2012-05-07 Shezan Baig <shezbaig.wk@gmail.com> 2 3 Selection Background Color Error 4 https://bugs.webkit.org/show_bug.cgi?id=80382 5 6 Reviewed by David Hyatt. 7 8 Determine the text colors and selection colors before painting the 9 background behind the text. This is because when determining whether 10 to invert the selection background, the selection text color should be 11 used instead of the regular text color. With this patch, the selection 12 text color is passed to 'paintSelection' so that the selection 13 background can be compared against it, instead of comparing against the 14 CSSPropertyColor value. 15 16 Test: fast/backgrounds/selection-background-color.html 17 18 * rendering/InlineTextBox.cpp: 19 (WebCore::InlineTextBox::paint): 20 Pass selection text color to paintSelection 21 22 (WebCore::InlineTextBox::paintSelection): 23 Use the selection text color instead of CSSPropertyColor 24 25 * rendering/InlineTextBox.h: 26 (InlineTextBox): 27 Adjust signature of paintSelection to accept text color 28 1 29 2012-05-07 David Reveman <reveman@chromium.org> 2 30 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r114784 r116353 535 535 bool useCustomUnderlines = containsComposition && renderer()->frame()->editor()->compositionUsesCustomUnderlines(); 536 536 537 // Set our font. 538 const Font& font = styleToUse->font(); 539 540 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent()); 541 542 if (combinedText) 543 combinedText->adjustTextOrigin(textOrigin, boxRect); 544 545 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 546 // and composition underlines. 547 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseTextClip && !isPrinting) { 548 #if PLATFORM(MAC) 549 // Custom highlighters go behind everything else. 550 if (styleToUse->highlight() != nullAtom && !context->paintingDisabled()) 551 paintCustomHighlight(adjustedPaintOffset, styleToUse->highlight()); 552 #endif 553 554 if (containsComposition && !useCustomUnderlines) 555 paintCompositionBackground(context, boxOrigin, styleToUse, font, 556 renderer()->frame()->editor()->compositionStart(), 557 renderer()->frame()->editor()->compositionEnd()); 558 559 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); 560 561 if (haveSelection && !useCustomUnderlines) 562 paintSelection(context, boxOrigin, styleToUse, font); 563 } 564 565 if (Frame* frame = renderer()->frame()) { 566 if (Page* page = frame->page()) { 567 // FIXME: Right now, InlineTextBoxes never call addRelevantUnpaintedObject() even though they might 568 // legitimately be unpainted if they are waiting on a slow-loading web font. We should fix that, and 569 // when we do, we will have to account for the fact the InlineTextBoxes do not always have unique 570 // renderers and Page currently relies on each unpainted object having a unique renderer. 571 if (paintInfo.phase == PaintPhaseForeground) 572 page->addRelevantRepaintedObject(renderer(), IntRect(boxOrigin.x(), boxOrigin.y(), logicalWidth(), logicalHeight())); 573 } 574 } 575 576 // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only). 537 // Determine the text colors and selection colors. 577 538 Color textFillColor; 578 539 Color textStrokeColor; … … 661 622 } 662 623 624 // Set our font. 625 const Font& font = styleToUse->font(); 626 627 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent()); 628 629 if (combinedText) 630 combinedText->adjustTextOrigin(textOrigin, boxRect); 631 632 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 633 // and composition underlines. 634 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseTextClip && !isPrinting) { 635 #if PLATFORM(MAC) 636 // Custom highlighters go behind everything else. 637 if (styleToUse->highlight() != nullAtom && !context->paintingDisabled()) 638 paintCustomHighlight(adjustedPaintOffset, styleToUse->highlight()); 639 #endif 640 641 if (containsComposition && !useCustomUnderlines) 642 paintCompositionBackground(context, boxOrigin, styleToUse, font, 643 renderer()->frame()->editor()->compositionStart(), 644 renderer()->frame()->editor()->compositionEnd()); 645 646 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); 647 648 if (haveSelection && !useCustomUnderlines) 649 paintSelection(context, boxOrigin, styleToUse, font, selectionFillColor); 650 } 651 652 if (Frame* frame = renderer()->frame()) { 653 if (Page* page = frame->page()) { 654 // FIXME: Right now, InlineTextBoxes never call addRelevantUnpaintedObject() even though they might 655 // legitimately be unpainted if they are waiting on a slow-loading web font. We should fix that, and 656 // when we do, we will have to account for the fact the InlineTextBoxes do not always have unique 657 // renderers and Page currently relies on each unpainted object having a unique renderer. 658 if (paintInfo.phase == PaintPhaseForeground) 659 page->addRelevantRepaintedObject(renderer(), IntRect(boxOrigin.x(), boxOrigin.y(), logicalWidth(), logicalHeight())); 660 } 661 } 662 663 // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only). 663 664 int length = m_len; 664 665 int maximumLength; … … 807 808 } 808 809 809 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font )810 void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, Color textColor) 810 811 { 811 812 if (context->paintingDisabled()) … … 818 819 return; 819 820 820 Color textColor = style->visitedDependentColor(CSSPropertyColor);821 821 Color c = renderer()->selectionBackgroundColor(); 822 822 if (!c.isValid() || c.alpha() == 0) … … 824 824 825 825 // If the text color ends up being the same as the selection background, invert the selection 826 // background. This should basically never happen, since the selection has transparency.826 // background. 827 827 if (textColor == c) 828 828 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); -
trunk/Source/WebCore/rendering/InlineTextBox.h
r114220 r116353 182 182 private: 183 183 void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, int decoration, const ShadowData*); 184 void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font& );184 void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, Color textColor); 185 185 void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar); 186 186 void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
Note: See TracChangeset
for help on using the changeset viewer.