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

Unified 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: Addressing comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/linux/fast/selectors/input-with-selection-pseudo-element-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderObject.cpp
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index 9c8086c3227d76a293079398053446b5ce96de1c..8859c394b148db83ef0f47fa02a3fae398c03884 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -1788,8 +1788,18 @@ Color RenderObject::selectionBackgroundColor() const
if (!isSelectable())
return Color::transparent;
- if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
+ RefPtr<RenderStyle> pseudoStyle;
+ if (node() && node()->shadowHost()) {
+ // If the element is in shadow tree of input element, then get the PseudoStyle
+ // from the input element.
+ pseudoStyle = node()->shadowHost()->renderer()->getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
+ } else {
+ pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
+ }
+
+ if (pseudoStyle)
return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blendWithWhite();
+
return frame()->selection().isFocusedAndActive() ?
RenderTheme::theme().activeSelectionBackgroundColor() :
RenderTheme::theme().inactiveSelectionBackgroundColor();
@@ -1802,8 +1812,18 @@ Color RenderObject::selectionColor(int colorProperty) const
if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSelectionOnly))
return resolveColor(colorProperty);
- if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
+ RefPtr<RenderStyle> pseudoStyle;
+ if (node() && node()->shadowHost()) {
+ // If the element is in shadow tree of input element, then get the PseudoStyle
+ // from the input element.
+ pseudoStyle = node()->shadowHost()->renderer()->getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
+ } else {
+ pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
esprehn 2014/04/09 20:36:06 Why isn't this in a method, you do the exact same
+ }
+
+ if (pseudoStyle)
return resolveColor(pseudoStyle.get(), colorProperty);
+
if (!RenderTheme::theme().supportsSelectionForegroundColors())
return resolveColor(colorProperty);
return frame()->selection().isFocusedAndActive() ?
« no previous file with comments | « LayoutTests/platform/linux/fast/selectors/input-with-selection-pseudo-element-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698