Title: [169024] trunk
- Revision
- 169024
- Author
- [email protected]
- Date
- 2014-05-18 16:25:17 -0700 (Sun, 18 May 2014)
Log Message
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 <[email protected]> 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 <[email protected]> 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (169023 => 169024)
--- trunk/LayoutTests/ChangeLog 2014-05-18 23:12:37 UTC (rev 169023)
+++ trunk/LayoutTests/ChangeLog 2014-05-18 23:25:17 UTC (rev 169024)
@@ -1,3 +1,13 @@
+2014-05-18 Svetlana Redchenko <[email protected]>
+
+ 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 <[email protected]>
REGRESSION (r156546): Default media controls are laid out incorrectly when media element is styled with direction:rtl
Added: trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element-expected.html (0 => 169024)
--- trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element-expected.html (rev 0)
+++ trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element-expected.html 2014-05-18 23:25:17 UTC (rev 169024)
@@ -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.
\ No newline at end of file
Added: trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element.html (0 => 169024)
--- trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element.html (rev 0)
+++ trunk/LayoutTests/fast/selectors/input-with-selection-pseudo-element.html 2014-05-18 23:25:17 UTC (rev 169024)
@@ -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>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (169023 => 169024)
--- trunk/Source/WebCore/ChangeLog 2014-05-18 23:12:37 UTC (rev 169023)
+++ trunk/Source/WebCore/ChangeLog 2014-05-18 23:25:17 UTC (rev 169024)
@@ -1,3 +1,21 @@
+2014-05-18 Svetlana Redchenko <[email protected]>
+
+ 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 <[email protected]>
[WebKit2] Implement ScriptMessageHandlers
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (169023 => 169024)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2014-05-18 23:12:37 UTC (rev 169023)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2014-05-18 23:25:17 UTC (rev 169024)
@@ -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 @@
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 @@
|| (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 @@
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);
Modified: trunk/Source/WebCore/rendering/RenderObject.h (169023 => 169024)
--- trunk/Source/WebCore/rendering/RenderObject.h 2014-05-18 23:12:37 UTC (rev 169023)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2014-05-18 23:25:17 UTC (rev 169024)
@@ -897,6 +897,7 @@
void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
Color selectionColor(int colorProperty) const;
+ PassRefPtr<RenderStyle> selectionPseudoStyle() const;
Node* generatingPseudoHostElement() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes