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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 220343006: Fix for ::selection pseudo element to work on input elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added Layout Test Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY); 1780 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY);
1781 } 1781 }
1782 1782
1783 Color RenderObject::selectionBackgroundColor() const 1783 Color RenderObject::selectionBackgroundColor() const
1784 { 1784 {
1785 if (!isSelectable()) 1785 if (!isSelectable())
1786 return Color::transparent; 1786 return Color::transparent;
1787 1787
1788 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) 1788 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)))
1789 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blend WithWhite(); 1789 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blend WithWhite();
1790
1791 // If the element is in shadow tree of input element, then get the PseudoSty le
1792 // from the input element.
1793 if (node() && node()->shadowHost()) {
1794 RenderObject* shadowHostRenderer = node()->shadowHost()->renderer();
1795 if (shadowHostRenderer->isTextControl()) {
ojan 2014/04/09 01:57:53 Special casing text controls is not right. For exa
1796 if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncache dPseudoStyle(PseudoStyleRequest(SELECTION)))
1797 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColo r).blendWithWhite();
1798 }
1799 }
1800
1790 return frame()->selection().isFocusedAndActive() ? 1801 return frame()->selection().isFocusedAndActive() ?
1791 RenderTheme::theme().activeSelectionBackgroundColor() : 1802 RenderTheme::theme().activeSelectionBackgroundColor() :
1792 RenderTheme::theme().inactiveSelectionBackgroundColor(); 1803 RenderTheme::theme().inactiveSelectionBackgroundColor();
1793 } 1804 }
1794 1805
1795 Color RenderObject::selectionColor(int colorProperty) const 1806 Color RenderObject::selectionColor(int colorProperty) const
1796 { 1807 {
1797 // If the element is unselectable, or we are only painting the selection, 1808 // If the element is unselectable, or we are only painting the selection,
1798 // don't override the foreground color with the selection foreground color. 1809 // don't override the foreground color with the selection foreground color.
1799 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly)) 1810 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly))
1800 return resolveColor(colorProperty); 1811 return resolveColor(colorProperty);
1801 1812
1802 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) 1813 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)))
1803 return resolveColor(pseudoStyle.get(), colorProperty); 1814 return resolveColor(pseudoStyle.get(), colorProperty);
1815
1816 // If the element is in shadow tree of input element, then get the PseudoSty le
1817 // from the input element.
1818 if (node() && node()->shadowHost()) {
1819 RenderObject* shadowHostRenderer = node()->shadowHost()->renderer();
1820 if (shadowHostRenderer->isTextControl()) {
1821 if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncache dPseudoStyle(PseudoStyleRequest(SELECTION)))
1822 return resolveColor(pseudoStyle.get(), colorProperty);
1823 }
1824 }
1825
1804 if (!RenderTheme::theme().supportsSelectionForegroundColors()) 1826 if (!RenderTheme::theme().supportsSelectionForegroundColors())
1805 return resolveColor(colorProperty); 1827 return resolveColor(colorProperty);
1806 return frame()->selection().isFocusedAndActive() ? 1828 return frame()->selection().isFocusedAndActive() ?
1807 RenderTheme::theme().activeSelectionForegroundColor() : 1829 RenderTheme::theme().activeSelectionForegroundColor() :
1808 RenderTheme::theme().inactiveSelectionForegroundColor(); 1830 RenderTheme::theme().inactiveSelectionForegroundColor();
1809 } 1831 }
1810 1832
1811 Color RenderObject::selectionForegroundColor() const 1833 Color RenderObject::selectionForegroundColor() const
1812 { 1834 {
1813 return selectionColor(CSSPropertyWebkitTextFillColor); 1835 return selectionColor(CSSPropertyWebkitTextFillColor);
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 { 3397 {
3376 if (object1) { 3398 if (object1) {
3377 const WebCore::RenderObject* root = object1; 3399 const WebCore::RenderObject* root = object1;
3378 while (root->parent()) 3400 while (root->parent())
3379 root = root->parent(); 3401 root = root->parent();
3380 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3402 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3381 } 3403 }
3382 } 3404 }
3383 3405
3384 #endif 3406 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698