OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1377 bool LayoutObject::isSelectable() const { | 1377 bool LayoutObject::isSelectable() const { |
1378 return !isInert() && | 1378 return !isInert() && |
1379 !(style()->userSelect() == SELECT_NONE && | 1379 !(style()->userSelect() == SELECT_NONE && |
1380 style()->userModify() == READ_ONLY); | 1380 style()->userModify() == READ_ONLY); |
1381 } | 1381 } |
1382 | 1382 |
1383 Color LayoutObject::selectionBackgroundColor() const { | 1383 Color LayoutObject::selectionBackgroundColor() const { |
1384 if (!isSelectable()) | 1384 if (!isSelectable()) |
1385 return Color::transparent; | 1385 return Color::transparent; |
1386 | 1386 |
1387 if (RefPtr<ComputedStyle> pseudoStyle = | 1387 if (RefPtr<ComputedStyle> pseudoStyle = getUncachedSelectionStyle()) |
1388 getUncachedPseudoStyleFromParentOrShadowHost()) | |
1389 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor) | 1388 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor) |
1390 .blendWithWhite(); | 1389 .blendWithWhite(); |
1391 return frame()->selection().isFocusedAndActive() | 1390 return frame()->selection().isFocusedAndActive() |
1392 ? LayoutTheme::theme().activeSelectionBackgroundColor() | 1391 ? LayoutTheme::theme().activeSelectionBackgroundColor() |
1393 : LayoutTheme::theme().inactiveSelectionBackgroundColor(); | 1392 : LayoutTheme::theme().inactiveSelectionBackgroundColor(); |
1394 } | 1393 } |
1395 | 1394 |
1396 Color LayoutObject::selectionColor( | 1395 Color LayoutObject::selectionColor( |
1397 int colorProperty, | 1396 int colorProperty, |
1398 const GlobalPaintFlags globalPaintFlags) const { | 1397 const GlobalPaintFlags globalPaintFlags) const { |
1399 // If the element is unselectable, or we are only painting the selection, | 1398 // If the element is unselectable, or we are only painting the selection, |
1400 // don't override the foreground color with the selection foreground color. | 1399 // don't override the foreground color with the selection foreground color. |
1401 if (!isSelectable() || (globalPaintFlags & GlobalPaintSelectionOnly)) | 1400 if (!isSelectable() || (globalPaintFlags & GlobalPaintSelectionOnly)) |
1402 return resolveColor(colorProperty); | 1401 return resolveColor(colorProperty); |
1403 | 1402 |
1404 if (RefPtr<ComputedStyle> pseudoStyle = | 1403 if (RefPtr<ComputedStyle> pseudoStyle = getUncachedSelectionStyle()) |
1405 getUncachedPseudoStyleFromParentOrShadowHost()) | |
1406 return resolveColor(*pseudoStyle, colorProperty); | 1404 return resolveColor(*pseudoStyle, colorProperty); |
1407 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) | 1405 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) |
1408 return resolveColor(colorProperty); | 1406 return resolveColor(colorProperty); |
1409 return frame()->selection().isFocusedAndActive() | 1407 return frame()->selection().isFocusedAndActive() |
1410 ? LayoutTheme::theme().activeSelectionForegroundColor() | 1408 ? LayoutTheme::theme().activeSelectionForegroundColor() |
1411 : LayoutTheme::theme().inactiveSelectionForegroundColor(); | 1409 : LayoutTheme::theme().inactiveSelectionForegroundColor(); |
1412 } | 1410 } |
1413 | 1411 |
1414 Color LayoutObject::selectionForegroundColor( | 1412 Color LayoutObject::selectionForegroundColor( |
1415 const GlobalPaintFlags globalPaintFlags) const { | 1413 const GlobalPaintFlags globalPaintFlags) const { |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3060 document().ensureStyleResolver().styleForElement( | 3058 document().ensureStyleResolver().styleForElement( |
3061 element, parentStyle, parentStyle, DisallowStyleSharing); | 3059 element, parentStyle, parentStyle, DisallowStyleSharing); |
3062 result->setStyleType(PseudoIdFirstLineInherited); | 3060 result->setStyleType(PseudoIdFirstLineInherited); |
3063 return result.release(); | 3061 return result.release(); |
3064 } | 3062 } |
3065 | 3063 |
3066 return document().ensureStyleResolver().pseudoStyleForElement( | 3064 return document().ensureStyleResolver().pseudoStyleForElement( |
3067 element, pseudoStyleRequest, parentStyle, parentStyle); | 3065 element, pseudoStyleRequest, parentStyle, parentStyle); |
3068 } | 3066 } |
3069 | 3067 |
3070 PassRefPtr<ComputedStyle> | 3068 PassRefPtr<ComputedStyle> LayoutObject::getUncachedSelectionStyle() const { |
3071 LayoutObject::getUncachedPseudoStyleFromParentOrShadowHost() const { | |
3072 if (!node()) | 3069 if (!node()) |
3073 return nullptr; | 3070 return nullptr; |
3074 | 3071 |
3072 // In Blink, ::selection only applies to direct children of the element on | |
3073 // which ::selection is matched. In order to be able to style ::selection | |
3074 // inside elements implemented with a UA shadow tree, like input::selection, | |
3075 // 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.
| |
3076 // the UA shadow. | |
3075 if (ShadowRoot* root = node()->containingShadowRoot()) { | 3077 if (ShadowRoot* root = node()->containingShadowRoot()) { |
3076 if (root->type() == ShadowRootType::UserAgent) { | 3078 if (root->type() == ShadowRootType::UserAgent) { |
3077 if (Element* shadowHost = node()->ownerShadowHost()) { | 3079 if (Element* shadowHost = node()->ownerShadowHost()) { |
3078 return shadowHost->layoutObject()->getUncachedPseudoStyle( | 3080 return shadowHost->layoutObject()->getUncachedPseudoStyle( |
3079 PseudoStyleRequest(PseudoIdSelection)); | 3081 PseudoStyleRequest(PseudoIdSelection)); |
3080 } | 3082 } |
3081 } | 3083 } |
3082 } | 3084 } |
3083 | 3085 |
3084 return getUncachedPseudoStyle(PseudoStyleRequest(PseudoIdSelection)); | 3086 // If we request ::selection style for LayoutText, query ::selection style on |
3087 // 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.
| |
3088 // matches. | |
3089 const LayoutObject* selectionLayoutObject = this; | |
3090 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | |
3091 if (!element) | |
3092 return nullptr; | |
3093 if (element != node()) { | |
3094 selectionLayoutObject = element->layoutObject(); | |
3095 if (!selectionLayoutObject) | |
3096 return nullptr; | |
3097 } | |
3098 return selectionLayoutObject->getUncachedPseudoStyle( | |
3099 PseudoStyleRequest(PseudoIdSelection)); | |
3085 } | 3100 } |
3086 | 3101 |
3087 void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) { | 3102 void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) { |
3088 // Convert the style regions to absolute coordinates. | 3103 // Convert the style regions to absolute coordinates. |
3089 if (style()->visibility() != EVisibility::kVisible || !isBox()) | 3104 if (style()->visibility() != EVisibility::kVisible || !isBox()) |
3090 return; | 3105 return; |
3091 | 3106 |
3092 if (style()->getDraggableRegionMode() == DraggableRegionNone) | 3107 if (style()->getDraggableRegionMode() == DraggableRegionNone) |
3093 return; | 3108 return; |
3094 | 3109 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3531 const blink::LayoutObject* root = object1; | 3546 const blink::LayoutObject* root = object1; |
3532 while (root->parent()) | 3547 while (root->parent()) |
3533 root = root->parent(); | 3548 root = root->parent(); |
3534 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3549 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3535 } else { | 3550 } else { |
3536 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3551 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
3537 } | 3552 } |
3538 } | 3553 } |
3539 | 3554 |
3540 #endif | 3555 #endif |
OLD | NEW |