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

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: Created 6 years, 9 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 | « no previous file | 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 ee7c9c519961a8cd7c08afe823552b02850ec49f..d46ad24a5e79fa2a38b8183ccafb255be3c0d1cf 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -1780,6 +1780,17 @@ Color RenderObject::selectionBackgroundColor() const
if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blendWithWhite();
+
+ // If the element is in shadow tree of input element, then get the PseudoStyle
+ // from the input element.
+ if (node() && node()->shadowHost()) {
+ RenderObject* shadowHostRenderer = node()->shadowHost()->renderer();
esprehn 2014/04/03 19:59:07 Your host must have a renderer if you do. The null
deepak.sa 2014/04/07 15:20:00 Done.
+ if (shadowHostRenderer && shadowHostRenderer->isTextControl()) {
+ if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
+ return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blendWithWhite();
+ }
+ }
+
return frame()->selection().isFocusedAndActive() ?
RenderTheme::theme().activeSelectionBackgroundColor() :
RenderTheme::theme().inactiveSelectionBackgroundColor();
@@ -1794,6 +1805,17 @@ Color RenderObject::selectionColor(int colorProperty) const
if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
return resolveColor(pseudoStyle.get(), colorProperty);
+
+ // If the element is in shadow tree of input element, then get the PseudoStyle
+ // from the input element.
+ if (node() && node()->shadowHost()) {
+ RenderObject* shadowHostRenderer = node()->shadowHost()->renderer();
+ if (shadowHostRenderer && shadowHostRenderer->isTextControl()) {
+ if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)))
+ return resolveColor(pseudoStyle.get(), colorProperty);
+ }
+ }
+
if (!RenderTheme::theme().supportsSelectionForegroundColors())
return resolveColor(colorProperty);
return frame()->selection().isFocusedAndActive() ?
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698