Skip to content
Permalink
Browse files
Input ::selection pseudo class does not work leading to hidden selection
https://bugs.webkit.org/show_bug.cgi?id=38943

Source/WebCore:

Patch by Svetlana Redchenko <redchenko@yandex-team.ru> on 2014-05-18
Reviewed by Darin Adler.

Test: fast/selectors/input-with-selection-pseudo-element.html

When text is selected inside input element, it should change the
color and background color according to the ::selection pseudo element.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionBackgroundColor):
(WebCore::RenderObject::selectionColor):
(WebCore::RenderObject::selectionPseudoStyle):
* rendering/RenderObject.h:

LayoutTests:

Patch by Svetlana Redchenko <redchenko@yandex-team.ru> on 2014-05-18
Reviewed by Darin Adler.

* fast/selectors/input-with-selection-pseudo-element-expected.html: Added.
* fast/selectors/input-with-selection-pseudo-element.html: Added.

Canonical link: https://commits.webkit.org/151083@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
redchenko authored and webkit-commit-queue committed May 18, 2014
1 parent af798bc commit 2b21e0423a3f791ed0c1f667b027836e66ec39d3
Showing 6 changed files with 63 additions and 2 deletions.
@@ -1,3 +1,13 @@
2014-05-18 Svetlana Redchenko <redchenko@yandex-team.ru>

Input ::selection pseudo class does not work leading to hidden selection
https://bugs.webkit.org/show_bug.cgi?id=38943

Reviewed by Darin Adler.

* fast/selectors/input-with-selection-pseudo-element-expected.html: Added.
* fast/selectors/input-with-selection-pseudo-element.html: Added.

2014-05-18 Maciej Stachowiak <mjs@apple.com>

REGRESSION (r156546): Default media controls are laid out incorrectly when media element is styled with direction:rtl
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<div style="border:5px solid; width:100px; font-size:16px; font-family:sans-serif;">
<span style="background-color:rgba(63, 128, 33, 0.95); color:yellow;">Hello</span>
</div>
<br>Fix for ::selection pseudo element to work on input elements.
<br>The above selected text in the input box should have green background and yellow color.
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<style>
::selection { background-color: rgba(63, 128, 33, 0.95); color: yellow; }
</style>
<input id="inputText" type="text" value="Hello" style="border:5px solid; width:100px; font-size:16px; font-family:sans-serif; padding:0; margin:0; outline:none;"><br>
<br>Fix for ::selection pseudo element to work on input elements.
<br>The above selected text in the input box should have green background and yellow color.
<script>
document.getElementById('inputText').select();
</script>
@@ -1,3 +1,21 @@
2014-05-18 Svetlana Redchenko <redchenko@yandex-team.ru>

Input ::selection pseudo class does not work leading to hidden selection
https://bugs.webkit.org/show_bug.cgi?id=38943

Reviewed by Darin Adler.

Test: fast/selectors/input-with-selection-pseudo-element.html

When text is selected inside input element, it should change the
color and background color according to the ::selection pseudo element.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionBackgroundColor):
(WebCore::RenderObject::selectionColor):
(WebCore::RenderObject::selectionPseudoStyle):
* rendering/RenderObject.h:

2014-05-18 Sam Weinig <sam@webkit.org>

[WebKit2] Implement ScriptMessageHandlers
@@ -62,6 +62,7 @@
#include "RenderView.h"
#include "SVGRenderSupport.h"
#include "Settings.h"
#include "ShadowRoot.h"
#include "StyleResolver.h"
#include "TransformState.h"
#include "htmlediting.h"
@@ -1499,7 +1500,7 @@ Color RenderObject::selectionBackgroundColor() const
if (frame().selection().shouldShowBlockCursor() && frame().selection().isCaret())
color = style().visitedDependentColor(CSSPropertyColor).blendWithWhite();
else {
RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
RefPtr<RenderStyle> pseudoStyle = selectionPseudoStyle();
if (pseudoStyle && pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).isValid())
color = pseudoStyle->visitedDependentColor(CSSPropertyBackgroundColor).blendWithWhite();
else
@@ -1519,7 +1520,7 @@ Color RenderObject::selectionColor(int colorProperty) const
|| (view().frameView().paintBehavior() & PaintBehaviorSelectionOnly))
return color;

if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequest(SELECTION))) {
if (RefPtr<RenderStyle> pseudoStyle = selectionPseudoStyle()) {
color = pseudoStyle->visitedDependentColor(colorProperty);
if (!color.isValid())
color = pseudoStyle->visitedDependentColor(CSSPropertyColor);
@@ -1529,6 +1530,21 @@ Color RenderObject::selectionColor(int colorProperty) const
return color;
}

PassRefPtr<RenderStyle> RenderObject::selectionPseudoStyle() const
{
if (isAnonymous())
return nullptr;

if (ShadowRoot* root = m_node.containingShadowRoot()) {
if (root->type() == ShadowRoot::UserAgentShadowRoot) {
if (Element* shadowHost = m_node.shadowHost())
return shadowHost->renderer()->getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
}
}

return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
}

Color RenderObject::selectionForegroundColor() const
{
return selectionColor(CSSPropertyWebkitTextFillColor);
@@ -897,6 +897,7 @@ class RenderObject : public CachedImageClient {
void removeFromRenderFlowThreadRecursive(RenderFlowThread*);

Color selectionColor(int colorProperty) const;
PassRefPtr<RenderStyle> selectionPseudoStyle() const;

Node* generatingPseudoHostElement() const;

0 comments on commit 2b21e04

Please sign in to comment.