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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY); 1773 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user Modify() == READ_ONLY);
1774 } 1774 }
1775 1775
1776 Color RenderObject::selectionBackgroundColor() const 1776 Color RenderObject::selectionBackgroundColor() const
1777 { 1777 {
1778 if (!isSelectable()) 1778 if (!isSelectable())
1779 return Color::transparent; 1779 return Color::transparent;
1780 1780
1781 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) 1781 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)))
1782 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blend WithWhite(); 1782 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColor).blend WithWhite();
1783
1784 // If the element is in shadow tree of input element, then get the PseudoSty le
1785 // from the input element.
1786 if (node() && node()->shadowHost()) {
1787 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.
1788 if (shadowHostRenderer && shadowHostRenderer->isTextControl()) {
1789 if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncache dPseudoStyle(PseudoStyleRequest(SELECTION)))
1790 return resolveColor(pseudoStyle.get(), CSSPropertyBackgroundColo r).blendWithWhite();
1791 }
1792 }
1793
1783 return frame()->selection().isFocusedAndActive() ? 1794 return frame()->selection().isFocusedAndActive() ?
1784 RenderTheme::theme().activeSelectionBackgroundColor() : 1795 RenderTheme::theme().activeSelectionBackgroundColor() :
1785 RenderTheme::theme().inactiveSelectionBackgroundColor(); 1796 RenderTheme::theme().inactiveSelectionBackgroundColor();
1786 } 1797 }
1787 1798
1788 Color RenderObject::selectionColor(int colorProperty) const 1799 Color RenderObject::selectionColor(int colorProperty) const
1789 { 1800 {
1790 // If the element is unselectable, or we are only painting the selection, 1801 // If the element is unselectable, or we are only painting the selection,
1791 // don't override the foreground color with the selection foreground color. 1802 // don't override the foreground color with the selection foreground color.
1792 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly)) 1803 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele ctionOnly))
1793 return resolveColor(colorProperty); 1804 return resolveColor(colorProperty);
1794 1805
1795 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION))) 1806 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyle(PseudoStyleRequ est(SELECTION)))
1796 return resolveColor(pseudoStyle.get(), colorProperty); 1807 return resolveColor(pseudoStyle.get(), colorProperty);
1808
1809 // If the element is in shadow tree of input element, then get the PseudoSty le
1810 // from the input element.
1811 if (node() && node()->shadowHost()) {
1812 RenderObject* shadowHostRenderer = node()->shadowHost()->renderer();
1813 if (shadowHostRenderer && shadowHostRenderer->isTextControl()) {
1814 if (RefPtr<RenderStyle> pseudoStyle = shadowHostRenderer->getUncache dPseudoStyle(PseudoStyleRequest(SELECTION)))
1815 return resolveColor(pseudoStyle.get(), colorProperty);
1816 }
1817 }
1818
1797 if (!RenderTheme::theme().supportsSelectionForegroundColors()) 1819 if (!RenderTheme::theme().supportsSelectionForegroundColors())
1798 return resolveColor(colorProperty); 1820 return resolveColor(colorProperty);
1799 return frame()->selection().isFocusedAndActive() ? 1821 return frame()->selection().isFocusedAndActive() ?
1800 RenderTheme::theme().activeSelectionForegroundColor() : 1822 RenderTheme::theme().activeSelectionForegroundColor() :
1801 RenderTheme::theme().inactiveSelectionForegroundColor(); 1823 RenderTheme::theme().inactiveSelectionForegroundColor();
1802 } 1824 }
1803 1825
1804 Color RenderObject::selectionForegroundColor() const 1826 Color RenderObject::selectionForegroundColor() const
1805 { 1827 {
1806 return selectionColor(CSSPropertyWebkitTextFillColor); 1828 return selectionColor(CSSPropertyWebkitTextFillColor);
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 { 3390 {
3369 if (object1) { 3391 if (object1) {
3370 const WebCore::RenderObject* root = object1; 3392 const WebCore::RenderObject* root = object1;
3371 while (root->parent()) 3393 while (root->parent())
3372 root = root->parent(); 3394 root = root->parent();
3373 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3395 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3374 } 3396 }
3375 } 3397 }
3376 3398
3377 #endif 3399 #endif
OLDNEW
« 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