<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[176365] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/176365">176365</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-11-19 16:17:41 -0800 (Wed, 19 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move pseudo-style code from RenderObject to RenderElement.
&lt;https://webkit.org/b/138880&gt;

Reviewed by Antti Koivisto.

Migrate get*PseudoStyle() to RenderElement, and the selection color
functions along with them. This gets rid of a DOM ancestor walk in
pseudo style lookup.

Narrow down some argument types to keep things building.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::logicalLeftSelectionGap):
(WebCore::RenderBlock::logicalRightSelectionGap):
(WebCore::styleForFirstLetter):
(WebCore::RenderBlock::updateFirstLetterStyle):
(WebCore::RenderBlock::createFirstLetterRenderer):
* rendering/RenderBlock.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::getCachedPseudoStyle):
(WebCore::RenderElement::getUncachedPseudoStyle):
(WebCore::RenderElement::selectionColor):
(WebCore::RenderElement::selectionPseudoStyle):
(WebCore::RenderElement::selectionForegroundColor):
(WebCore::RenderElement::selectionEmphasisMarkColor):
(WebCore::RenderElement::selectionBackgroundColor):
* rendering/RenderElement.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionBackgroundColor): Deleted.
(WebCore::RenderObject::selectionColor): Deleted.
(WebCore::RenderObject::selectionPseudoStyle): Deleted.
(WebCore::RenderObject::selectionForegroundColor): Deleted.
(WebCore::RenderObject::selectionEmphasisMarkColor): Deleted.
(WebCore::RenderObject::getCachedPseudoStyle): Deleted.
(WebCore::RenderObject::getUncachedPseudoStyle): Deleted.
* rendering/RenderObject.h:
* rendering/RenderText.h:
(WebCore::RenderText::getCachedPseudoStyle):
(WebCore::RenderText::selectionBackgroundColor):
(WebCore::RenderText::selectionForegroundColor):
(WebCore::RenderText::selectionEmphasisMarkColor):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintSelectionBackground):
(WebCore::SVGInlineTextBox::paint):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockh">trunk/Source/WebCore/rendering/RenderBlock.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementcpp">trunk/Source/WebCore/rendering/RenderElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementh">trunk/Source/WebCore/rendering/RenderElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTexth">trunk/Source/WebCore/rendering/RenderText.h</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp">trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/ChangeLog        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2014-11-19  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Move pseudo-style code from RenderObject to RenderElement.
+        &lt;https://webkit.org/b/138880&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Migrate get*PseudoStyle() to RenderElement, and the selection color
+        functions along with them. This gets rid of a DOM ancestor walk in
+        pseudo style lookup.
+
+        Narrow down some argument types to keep things building.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::logicalLeftSelectionGap):
+        (WebCore::RenderBlock::logicalRightSelectionGap):
+        (WebCore::styleForFirstLetter):
+        (WebCore::RenderBlock::updateFirstLetterStyle):
+        (WebCore::RenderBlock::createFirstLetterRenderer):
+        * rendering/RenderBlock.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::getCachedPseudoStyle):
+        (WebCore::RenderElement::getUncachedPseudoStyle):
+        (WebCore::RenderElement::selectionColor):
+        (WebCore::RenderElement::selectionPseudoStyle):
+        (WebCore::RenderElement::selectionForegroundColor):
+        (WebCore::RenderElement::selectionEmphasisMarkColor):
+        (WebCore::RenderElement::selectionBackgroundColor):
+        * rendering/RenderElement.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::selectionBackgroundColor): Deleted.
+        (WebCore::RenderObject::selectionColor): Deleted.
+        (WebCore::RenderObject::selectionPseudoStyle): Deleted.
+        (WebCore::RenderObject::selectionForegroundColor): Deleted.
+        (WebCore::RenderObject::selectionEmphasisMarkColor): Deleted.
+        (WebCore::RenderObject::getCachedPseudoStyle): Deleted.
+        (WebCore::RenderObject::getUncachedPseudoStyle): Deleted.
+        * rendering/RenderObject.h:
+        * rendering/RenderText.h:
+        (WebCore::RenderText::getCachedPseudoStyle):
+        (WebCore::RenderText::selectionBackgroundColor):
+        (WebCore::RenderText::selectionForegroundColor):
+        (WebCore::RenderText::selectionEmphasisMarkColor):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintSelectionBackground):
+        (WebCore::SVGInlineTextBox::paint):
+
</ins><span class="cx"> 2014-11-19  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add an optional entry transition (from selection highlight) to TextIndicator
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -1987,7 +1987,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutRect RenderBlock::logicalLeftSelectionGap(RenderBlock&amp; rootBlock, const LayoutPoint&amp; rootBlockPhysicalPosition, const LayoutSize&amp; offsetFromRootBlock,
</span><del>-    RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp; cache, const PaintInfo* paintInfo)
</del><ins>+    RenderBoxModelObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp; cache, const PaintInfo* paintInfo)
</ins><span class="cx"> {
</span><span class="cx">     LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
</span><span class="cx">     LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBlock, logicalTop, cache), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight, cache));
</span><span class="lines">@@ -2004,7 +2004,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutRect RenderBlock::logicalRightSelectionGap(RenderBlock&amp; rootBlock, const LayoutPoint&amp; rootBlockPhysicalPosition, const LayoutSize&amp; offsetFromRootBlock,
</span><del>-    RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp; cache, const PaintInfo* paintInfo)
</del><ins>+    RenderBoxModelObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp; cache, const PaintInfo* paintInfo)
</ins><span class="cx"> {
</span><span class="cx">     LayoutUnit rootBlockLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + logicalTop;
</span><span class="cx">     LayoutUnit rootBlockLogicalLeft = std::max(inlineDirectionOffset(rootBlock, offsetFromRootBlock) + logicalRight,
</span><span class="lines">@@ -2967,7 +2967,7 @@
</span><span class="cx">     return firstLineBlock;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RenderStyle&amp; styleForFirstLetter(RenderObject* firstLetterBlock, RenderObject* firstLetterContainer)
</del><ins>+static RenderStyle&amp; styleForFirstLetter(RenderElement* firstLetterBlock, RenderObject* firstLetterContainer)
</ins><span class="cx"> {
</span><span class="cx">     RenderStyle* pseudoStyle = firstLetterBlock-&gt;getCachedPseudoStyle(FIRST_LETTER, &amp;firstLetterContainer-&gt;firstLineStyle());
</span><span class="cx">     
</span><span class="lines">@@ -3048,7 +3048,7 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlock::updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* currentChild)
</del><ins>+void RenderBlock::updateFirstLetterStyle(RenderElement* firstLetterBlock, RenderObject* currentChild)
</ins><span class="cx"> {
</span><span class="cx">     RenderElement* firstLetter = currentChild-&gt;parent();
</span><span class="cx">     RenderElement* firstLetterContainer = firstLetter-&gt;parent();
</span><span class="lines">@@ -3090,7 +3090,7 @@
</span><span class="cx">         firstLetter-&gt;setStyle(pseudoStyle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlock::createFirstLetterRenderer(RenderObject* firstLetterBlock, RenderText* currentTextChild)
</del><ins>+void RenderBlock::createFirstLetterRenderer(RenderElement* firstLetterBlock, RenderText* currentTextChild)
</ins><span class="cx"> {
</span><span class="cx">     RenderElement* firstLetterContainer = currentTextChild-&gt;parent();
</span><span class="cx">     RenderStyle&amp; pseudoStyle = styleForFirstLetter(firstLetterBlock, firstLetterContainer);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.h (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.h        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderBlock.h        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -172,9 +172,9 @@
</span><span class="cx"> 
</span><span class="cx">     GapRects selectionGapRectsForRepaint(const RenderLayerModelObject* repaintContainer);
</span><span class="cx">     LayoutRect logicalLeftSelectionGap(RenderBlock&amp; rootBlock, const LayoutPoint&amp; rootBlockPhysicalPosition, const LayoutSize&amp; offsetFromRootBlock,
</span><del>-        RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp;, const PaintInfo*);
</del><ins>+        RenderBoxModelObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp;, const PaintInfo*);
</ins><span class="cx">     LayoutRect logicalRightSelectionGap(RenderBlock&amp; rootBlock, const LayoutPoint&amp; rootBlockPhysicalPosition, const LayoutSize&amp; offsetFromRootBlock,
</span><del>-        RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp;, const PaintInfo*);
</del><ins>+        RenderBoxModelObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const LogicalSelectionOffsetCaches&amp;, const PaintInfo*);
</ins><span class="cx">     void getSelectionGapInfo(SelectionState, bool&amp; leftGap, bool&amp; rightGap);
</span><span class="cx">     RenderBlock* blockBeforeWithinSelectionRoot(LayoutSize&amp; offset) const;
</span><span class="cx"> 
</span><span class="lines">@@ -421,8 +421,8 @@
</span><span class="cx">     void insertIntoTrackedRendererMaps(RenderBox&amp; descendant, TrackedDescendantsMap*&amp;, TrackedContainerMap*&amp;);
</span><span class="cx">     static void removeFromTrackedRendererMaps(RenderBox&amp; descendant, TrackedDescendantsMap*&amp;, TrackedContainerMap*&amp;);
</span><span class="cx"> 
</span><del>-    void createFirstLetterRenderer(RenderObject* firstLetterBlock, RenderText* currentTextChild);
-    void updateFirstLetterStyle(RenderObject* firstLetterBlock, RenderObject* firstLetterContainer);
</del><ins>+    void createFirstLetterRenderer(RenderElement* firstLetterBlock, RenderText* currentTextChild);
+    void updateFirstLetterStyle(RenderElement* firstLetterBlock, RenderObject* firstLetterContainer);
</ins><span class="cx"> 
</span><span class="cx">     Node* nodeForHitTest() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.cpp        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;SVGRenderSupport.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;ShadowRoot.h&quot;
</ins><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/StackStats.h&gt;
</span><span class="lines">@@ -1415,4 +1416,103 @@
</span><span class="cx">     controlStatesRendererMap().add(o, states);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RenderStyle* RenderElement::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const
+{
+    if (pseudo &lt; FIRST_INTERNAL_PSEUDOID &amp;&amp; !style().hasPseudoStyle(pseudo))
+        return nullptr;
+
+    RenderStyle* cachedStyle = style().getCachedPseudoStyle(pseudo);
+    if (cachedStyle)
+        return cachedStyle;
+
+    RefPtr&lt;RenderStyle&gt; result = getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle);
+    if (result)
+        return style().addCachedPseudoStyle(result.release());
+    return nullptr;
</ins><span class="cx"> }
</span><ins>+
+PassRefPtr&lt;RenderStyle&gt; RenderElement::getUncachedPseudoStyle(const PseudoStyleRequest&amp; pseudoStyleRequest, RenderStyle* parentStyle, RenderStyle* ownStyle) const
+{
+    if (pseudoStyleRequest.pseudoId &lt; FIRST_INTERNAL_PSEUDOID &amp;&amp; !ownStyle &amp;&amp; !style().hasPseudoStyle(pseudoStyleRequest.pseudoId))
+        return nullptr;
+
+    if (!parentStyle) {
+        ASSERT(!ownStyle);
+        parentStyle = &amp;style();
+    }
+
+    if (isAnonymous())
+        return nullptr;
+
+    if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) {
+        RefPtr&lt;RenderStyle&gt; result = document().ensureStyleResolver().styleForElement(element(), parentStyle, DisallowStyleSharing);
+        result-&gt;setStyleType(FIRST_LINE_INHERITED);
+        return result.release();
+    }
+
+    return document().ensureStyleResolver().pseudoStyleForElement(element(), pseudoStyleRequest, parentStyle);
+}
+
+Color RenderElement::selectionColor(int colorProperty) const
+{
+    // If the element is unselectable, or we are only painting the selection,
+    // don't override the foreground color with the selection foreground color.
+    if (style().userSelect() == SELECT_NONE
+        || (view().frameView().paintBehavior() &amp; PaintBehaviorSelectionOnly))
+        return Color();
+
+    if (RefPtr&lt;RenderStyle&gt; pseudoStyle = selectionPseudoStyle()) {
+        Color color = pseudoStyle-&gt;visitedDependentColor(colorProperty);
+        if (!color.isValid())
+            color = pseudoStyle-&gt;visitedDependentColor(CSSPropertyColor);
+        return color;
+    }
+
+    if (frame().selection().isFocusedAndActive())
+        return theme().activeSelectionForegroundColor();
+    return theme().inactiveSelectionForegroundColor();
+}
+
+PassRefPtr&lt;RenderStyle&gt; RenderElement::selectionPseudoStyle() const
+{
+    if (isAnonymous())
+        return nullptr;
+
+    if (ShadowRoot* root = element()-&gt;containingShadowRoot()) {
+        if (root-&gt;type() == ShadowRoot::UserAgentShadowRoot) {
+            if (Element* shadowHost = element()-&gt;shadowHost())
+                return shadowHost-&gt;renderer()-&gt;getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
+        }
+    }
+
+    return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
+}
+
+Color RenderElement::selectionForegroundColor() const
+{
+    return selectionColor(CSSPropertyWebkitTextFillColor);
+}
+
+Color RenderElement::selectionEmphasisMarkColor() const
+{
+    return selectionColor(CSSPropertyWebkitTextEmphasisColor);
+}
+
+Color RenderElement::selectionBackgroundColor() const
+{
+    if (style().userSelect() == SELECT_NONE)
+        return Color();
+
+    if (frame().selection().shouldShowBlockCursor() &amp;&amp; frame().selection().isCaret())
+        return style().visitedDependentColor(CSSPropertyColor).blendWithWhite();
+
+    RefPtr&lt;RenderStyle&gt; pseudoStyle = selectionPseudoStyle();
+    if (pseudoStyle &amp;&amp; pseudoStyle-&gt;visitedDependentColor(CSSPropertyBackgroundColor).isValid())
+        return pseudoStyle-&gt;visitedDependentColor(CSSPropertyBackgroundColor).blendWithWhite();
+
+    if (frame().selection().isFocusedAndActive())
+        return theme().activeSelectionBackgroundColor();
+    return theme().inactiveSelectionBackgroundColor();
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.h (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.h        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderElement.h        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -47,6 +47,11 @@
</span><span class="cx">     // Called to update a style that is allowed to trigger animations.
</span><span class="cx">     void setAnimatableStyle(PassRef&lt;RenderStyle&gt;);
</span><span class="cx"> 
</span><ins>+    // The pseudo element style can be cached or uncached.  Use the cached method if the pseudo element doesn't respect
+    // any pseudo classes (and therefore has no concept of changing state).
+    RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
+    PassRefPtr&lt;RenderStyle&gt; getUncachedPseudoStyle(const PseudoStyleRequest&amp;, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
+
</ins><span class="cx">     // This is null for anonymous renderers.
</span><span class="cx">     Element* element() const { return downcast&lt;Element&gt;(RenderObject::node()); }
</span><span class="cx">     Element* nonPseudoElement() const { return downcast&lt;Element&gt;(RenderObject::nonPseudoNode()); }
</span><span class="lines">@@ -59,6 +64,14 @@
</span><span class="cx"> 
</span><span class="cx">     bool canContainFixedPositionObjects() const;
</span><span class="cx"> 
</span><ins>+    Color selectionColor(int colorProperty) const;
+    PassRefPtr&lt;RenderStyle&gt; selectionPseudoStyle() const;
+
+    // Obtains the selection colors that should be used when painting a selection.
+    Color selectionBackgroundColor() const;
+    Color selectionForegroundColor() const;
+    Color selectionEmphasisMarkColor() const;
+
</ins><span class="cx">     // FIXME: Make these standalone and move to relevant files.
</span><span class="cx">     bool isRenderLayerModelObject() const;
</span><span class="cx">     bool isBoxModelObject() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;SVGRenderSupport.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><del>-#include &quot;ShadowRoot.h&quot;
</del><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;TransformState.h&quot;
</span><span class="cx"> #include &quot;htmlediting.h&quot;
</span><span class="lines">@@ -1562,68 +1561,6 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // NDEBUG
</span><span class="cx"> 
</span><del>-Color RenderObject::selectionBackgroundColor() const
-{
-    Color color;
-    if (style().userSelect() != SELECT_NONE) {
-        if (frame().selection().shouldShowBlockCursor() &amp;&amp; frame().selection().isCaret())
-            color = style().visitedDependentColor(CSSPropertyColor).blendWithWhite();
-        else {
-            RefPtr&lt;RenderStyle&gt; pseudoStyle = selectionPseudoStyle();
-            if (pseudoStyle &amp;&amp; pseudoStyle-&gt;visitedDependentColor(CSSPropertyBackgroundColor).isValid())
-                color = pseudoStyle-&gt;visitedDependentColor(CSSPropertyBackgroundColor).blendWithWhite();
-            else
-                color = frame().selection().isFocusedAndActive() ? theme().activeSelectionBackgroundColor() : theme().inactiveSelectionBackgroundColor();
-        }
-    }
-
-    return color;
-}
-
-Color RenderObject::selectionColor(int colorProperty) const
-{
-    Color color;
-    // If the element is unselectable, or we are only painting the selection,
-    // don't override the foreground color with the selection foreground color.
-    if (style().userSelect() == SELECT_NONE
-        || (view().frameView().paintBehavior() &amp; PaintBehaviorSelectionOnly))
-        return color;
-
-    if (RefPtr&lt;RenderStyle&gt; pseudoStyle = selectionPseudoStyle()) {
-        color = pseudoStyle-&gt;visitedDependentColor(colorProperty);
-        if (!color.isValid())
-            color = pseudoStyle-&gt;visitedDependentColor(CSSPropertyColor);
-    } else
-        color = frame().selection().isFocusedAndActive() ? theme().activeSelectionForegroundColor() : theme().inactiveSelectionForegroundColor();
-
-    return color;
-}
-
-PassRefPtr&lt;RenderStyle&gt; RenderObject::selectionPseudoStyle() const
-{
-    if (isAnonymous())
-        return nullptr;
-
-    if (ShadowRoot* root = m_node.containingShadowRoot()) {
-        if (root-&gt;type() == ShadowRoot::UserAgentShadowRoot) {
-            if (Element* shadowHost = m_node.shadowHost())
-                return shadowHost-&gt;renderer()-&gt;getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
-        }
-    }
-
-    return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION));
-}
-
-Color RenderObject::selectionForegroundColor() const
-{
-    return selectionColor(CSSPropertyWebkitTextFillColor);
-}
-
-Color RenderObject::selectionEmphasisMarkColor() const
-{
-    return selectionColor(CSSPropertyWebkitTextEmphasisColor);
-}
-
</del><span class="cx"> SelectionSubtreeRoot&amp; RenderObject::selectionRoot() const
</span><span class="cx"> {
</span><span class="cx">     RenderFlowThread* flowThread = flowThreadContainingBlock();
</span><span class="lines">@@ -2150,48 +2087,6 @@
</span><span class="cx">     return style().computedLineHeight();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const
-{
-    if (pseudo &lt; FIRST_INTERNAL_PSEUDOID &amp;&amp; !style().hasPseudoStyle(pseudo))
-        return 0;
-
-    RenderStyle* cachedStyle = style().getCachedPseudoStyle(pseudo);
-    if (cachedStyle)
-        return cachedStyle;
-    
-    RefPtr&lt;RenderStyle&gt; result = getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle);
-    if (result)
-        return style().addCachedPseudoStyle(result.release());
-    return 0;
-}
-
-PassRefPtr&lt;RenderStyle&gt; RenderObject::getUncachedPseudoStyle(const PseudoStyleRequest&amp; pseudoStyleRequest, RenderStyle* parentStyle, RenderStyle* ownStyle) const
-{
-    if (pseudoStyleRequest.pseudoId &lt; FIRST_INTERNAL_PSEUDOID &amp;&amp; !ownStyle &amp;&amp; !style().hasPseudoStyle(pseudoStyleRequest.pseudoId))
-        return nullptr;
-    
-    if (!parentStyle) {
-        ASSERT(!ownStyle);
-        parentStyle = &amp;style();
-    }
-
-    // FIXME: This &quot;find nearest element parent&quot; should be a helper function.
-    Node* node = this-&gt;node();
-    while (node &amp;&amp; !is&lt;Element&gt;(*node))
-        node = node-&gt;parentNode();
-    if (!node)
-        return nullptr;
-    Element&amp; element = downcast&lt;Element&gt;(*node);
-
-    if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) {
-        RefPtr&lt;RenderStyle&gt; result = document().ensureStyleResolver().styleForElement(&amp;element, parentStyle, DisallowStyleSharing);
-        result-&gt;setStyleType(FIRST_LINE_INHERITED);
-        return result.release();
-    }
-
-    return document().ensureStyleResolver().pseudoStyleForElement(&amp;element, pseudoStyleRequest, parentStyle);
-}
-
</del><span class="cx"> static Color decorationColor(RenderStyle* style)
</span><span class="cx"> {
</span><span class="cx">     Color result;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -554,11 +554,6 @@
</span><span class="cx"> 
</span><span class="cx">     inline bool preservesNewline() const;
</span><span class="cx"> 
</span><del>-    // The pseudo element style can be cached or uncached.  Use the cached method if the pseudo element doesn't respect
-    // any pseudo classes (and therefore has no concept of changing state).
-    RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
-    PassRefPtr&lt;RenderStyle&gt; getUncachedPseudoStyle(const PseudoStyleRequest&amp;, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
-    
</del><span class="cx">     virtual void updateDragState(bool dragOn);
</span><span class="cx"> 
</span><span class="cx">     RenderView&amp; view() const { return *document().renderView(); };
</span><span class="lines">@@ -782,11 +777,6 @@
</span><span class="cx">     virtual bool canBeSelectionLeaf() const { return false; }
</span><span class="cx">     bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
</span><span class="cx"> 
</span><del>-    // Obtains the selection colors that should be used when painting a selection.
-    Color selectionBackgroundColor() const;
-    Color selectionForegroundColor() const;
-    Color selectionEmphasisMarkColor() const;
-
</del><span class="cx">     // Whether or not a given block needs to paint selection gaps.
</span><span class="cx">     virtual bool shouldPaintSelectionGaps() const { return false; }
</span><span class="cx"> 
</span><span class="lines">@@ -883,9 +873,6 @@
</span><span class="cx">     void removeFromRenderFlowThread();
</span><span class="cx">     void removeFromRenderFlowThreadIncludingDescendants(bool);
</span><span class="cx"> 
</span><del>-    Color selectionColor(int colorProperty) const;
-    PassRefPtr&lt;RenderStyle&gt; selectionPseudoStyle() const;
-
</del><span class="cx">     Node* generatingPseudoHostElement() const;
</span><span class="cx"> 
</span><span class="cx">     virtual bool isWBR() const { ASSERT_NOT_REACHED(); return false; }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.h (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.h        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/RenderText.h        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -48,7 +48,12 @@
</span><span class="cx"> 
</span><span class="cx">     RenderStyle&amp; style() const;
</span><span class="cx">     RenderStyle&amp; firstLineStyle() const;
</span><ins>+    RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = nullptr) const;
</ins><span class="cx"> 
</span><ins>+    Color selectionBackgroundColor() const;
+    Color selectionForegroundColor() const;
+    Color selectionEmphasisMarkColor() const;
+
</ins><span class="cx">     virtual String originalText() const;
</span><span class="cx"> 
</span><span class="cx">     void extractTextBox(InlineTextBox&amp; box) { m_lineBoxes.extract(box); }
</span><span class="lines">@@ -247,6 +252,26 @@
</span><span class="cx">     return parent()-&gt;firstLineStyle();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline RenderStyle* RenderText::getCachedPseudoStyle(PseudoId pseudoId, RenderStyle* parentStyle) const
+{
+    return parent()-&gt;getCachedPseudoStyle(pseudoId, parentStyle);
+}
+
+inline Color RenderText::selectionBackgroundColor() const
+{
+    return parent()-&gt;selectionBackgroundColor();
+}
+
+inline Color RenderText::selectionForegroundColor() const
+{
+    return parent()-&gt;selectionForegroundColor();
+}
+
+inline Color RenderText::selectionEmphasisMarkColor() const
+{
+    return parent()-&gt;selectionEmphasisMarkColor();
+}
+
</ins><span class="cx"> void applyTextTransform(const RenderStyle&amp;, String&amp;, UChar);
</span><span class="cx"> void makeCapitalized(String*, UChar previous);
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (176364 => 176365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-11-20 00:14:13 UTC (rev 176364)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-11-20 00:17:41 UTC (rev 176365)
</span><span class="lines">@@ -189,7 +189,7 @@
</span><span class="cx">     if (renderer().style().visibility() != VISIBLE)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RenderObject&amp; parentRenderer = parent()-&gt;renderer();
</del><ins>+    auto&amp; parentRenderer = parent()-&gt;renderer();
</ins><span class="cx">     ASSERT(!parentRenderer.document().printing());
</span><span class="cx"> 
</span><span class="cx">     // Determine whether or not we're selected.
</span><span class="lines">@@ -249,7 +249,7 @@
</span><span class="cx">     // Note: We're explicitely not supporting composition &amp; custom underlines and custom highlighters - unlike InlineTextBox.
</span><span class="cx">     // If we ever need that for SVG, it's very easy to refactor and reuse the code.
</span><span class="cx"> 
</span><del>-    RenderObject&amp; parentRenderer = parent()-&gt;renderer();
</del><ins>+    auto&amp; parentRenderer = parent()-&gt;renderer();
</ins><span class="cx"> 
</span><span class="cx">     bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
</span><span class="cx">     bool hasSelection = !parentRenderer.document().printing() &amp;&amp; selectionState() != RenderObject::SelectionNone;
</span></span></pre>
</div>
</div>

</body>
</html>