Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| index 24d0131ae325d01d5b7145bbc8bd1cbb5600983c..9db5a6675923e12ae6dc24691cfed613bae29d0f 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -1384,8 +1384,7 @@ Color LayoutObject::selectionBackgroundColor() const { |
| if (!isSelectable()) |
| return Color::transparent; |
| - if (RefPtr<ComputedStyle> pseudoStyle = |
| - getUncachedPseudoStyleFromParentOrShadowHost()) |
| + if (RefPtr<ComputedStyle> pseudoStyle = getUncachedSelectionStyle()) |
| return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor) |
| .blendWithWhite(); |
| return frame()->selection().isFocusedAndActive() |
| @@ -1401,8 +1400,7 @@ Color LayoutObject::selectionColor( |
| if (!isSelectable() || (globalPaintFlags & GlobalPaintSelectionOnly)) |
| return resolveColor(colorProperty); |
| - if (RefPtr<ComputedStyle> pseudoStyle = |
| - getUncachedPseudoStyleFromParentOrShadowHost()) |
| + if (RefPtr<ComputedStyle> pseudoStyle = getUncachedSelectionStyle()) |
| return resolveColor(*pseudoStyle, colorProperty); |
| if (!LayoutTheme::theme().supportsSelectionForegroundColors()) |
| return resolveColor(colorProperty); |
| @@ -3067,11 +3065,15 @@ PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle( |
| element, pseudoStyleRequest, parentStyle, parentStyle); |
| } |
| -PassRefPtr<ComputedStyle> |
| -LayoutObject::getUncachedPseudoStyleFromParentOrShadowHost() const { |
| +PassRefPtr<ComputedStyle> LayoutObject::getUncachedSelectionStyle() const { |
| if (!node()) |
| return nullptr; |
| + // In Blink, ::selection only applies to direct children of the element on |
| + // which ::selection is matched. In order to be able to style ::selection |
| + // inside elements implemented with a UA shadow tree, like input::selection, |
| + // we use calculate ::selection style on the shadow host for elements inside |
|
mstensho (USE GERRIT)
2017/03/03 12:06:34
I have problems parsing the sentence. -"use"?
rune
2017/03/03 12:13:56
Done.
|
| + // the UA shadow. |
| if (ShadowRoot* root = node()->containingShadowRoot()) { |
| if (root->type() == ShadowRootType::UserAgent) { |
| if (Element* shadowHost = node()->ownerShadowHost()) { |
| @@ -3081,7 +3083,20 @@ LayoutObject::getUncachedPseudoStyleFromParentOrShadowHost() const { |
| } |
| } |
| - return getUncachedPseudoStyle(PseudoStyleRequest(PseudoIdSelection)); |
| + // If we request ::selection style for LayoutText, query ::selection style on |
| + // the parent element instead as that is the node for which ::selection |
|
mstensho (USE GERRIT)
2017/03/03 12:06:34
Needs moar comma. Before "as"?
rune
2017/03/03 12:13:57
Done.
|
| + // matches. |
| + const LayoutObject* selectionLayoutObject = this; |
| + Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
| + if (!element) |
| + return nullptr; |
| + if (element != node()) { |
| + selectionLayoutObject = element->layoutObject(); |
| + if (!selectionLayoutObject) |
| + return nullptr; |
| + } |
| + return selectionLayoutObject->getUncachedPseudoStyle( |
| + PseudoStyleRequest(PseudoIdSelection)); |
| } |
| void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) { |