<!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>[42393] trunk/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/42393">42393</a></dd>
<dt>Author</dt> <dd>darin@chromium.org</dd>
<dt>Date</dt> <dd>2009-04-10 10:24:22 -0700 (Fri, 10 Apr 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-04-10  Finnur Thorarinsson  &lt;finnur.webkit@gmail.com&gt;

        Reviewed by John Sullivan.

        Fixing: https://bugs.webkit.org/show_bug.cgi?id=25117
        (TextMatches don't have a concept of active match)

        For the ports that use the DocumentMarker as highlighting for FindInPage it is
        useful to have a flag that specifies which marker is active, so it can be drawn
        in a different color.

        This allows me to remove the hack to use the SelectionController to highlight
        the active match (in the ChromiumWin port).

        * dom/Document.cpp:
        (WebCore::Document::setMarkersActive):
        * dom/Document.h:
        * dom/DocumentMarker.h:
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::paintTextMatchMarker):
        * rendering/RenderTheme.cpp:
        (WebCore::RenderTheme::platformActiveTextSearchHighlightColor):
        (WebCore::RenderTheme::platformInactiveTextSearchHighlightColor):
        * rendering/RenderTheme.h:
        * rendering/RenderThemeChromiumWin.cpp:
        (WebCore::RenderThemeChromiumWin::platformActiveSelectionBackgroundColor):
        (WebCore::RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor):
        (WebCore::RenderThemeChromiumWin::platformActiveTextSearchHighlightColor):
        (WebCore::RenderThemeChromiumWin::platformInactiveTextSearchHighlightColor):
        * rendering/RenderThemeChromiumWin.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoredomDocumentcpp">trunk/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkWebCoredomDocumenth">trunk/WebCore/dom/Document.h</a></li>
<li><a href="#trunkWebCoredomDocumentMarkerh">trunk/WebCore/dom/DocumentMarker.h</a></li>
<li><a href="#trunkWebCorerenderingInlineTextBoxcpp">trunk/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderThemecpp">trunk/WebCore/rendering/RenderTheme.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderThemeh">trunk/WebCore/rendering/RenderTheme.h</a></li>
<li><a href="#trunkWebCorerenderingRenderThemeChromiumWincpp">trunk/WebCore/rendering/RenderThemeChromiumWin.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderThemeChromiumWinh">trunk/WebCore/rendering/RenderThemeChromiumWin.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/ChangeLog        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2009-04-10  Finnur Thorarinsson  &lt;finnur.webkit@gmail.com&gt;
+
+        Reviewed by John Sullivan.
+
+        Fixing: https://bugs.webkit.org/show_bug.cgi?id=25117
+        (TextMatches don't have a concept of active match)
+
+        For the ports that use the DocumentMarker as highlighting for FindInPage it is
+        useful to have a flag that specifies which marker is active, so it can be drawn
+        in a different color.
+
+        This allows me to remove the hack to use the SelectionController to highlight
+        the active match (in the ChromiumWin port).
+
+        * dom/Document.cpp:
+        (WebCore::Document::setMarkersActive):
+        * dom/Document.h:
+        * dom/DocumentMarker.h:
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paintTextMatchMarker):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::platformActiveTextSearchHighlightColor):
+        (WebCore::RenderTheme::platformInactiveTextSearchHighlightColor):
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeChromiumWin.cpp:
+        (WebCore::RenderThemeChromiumWin::platformActiveSelectionBackgroundColor):
+        (WebCore::RenderThemeChromiumWin::platformInactiveSelectionBackgroundColor):
+        (WebCore::RenderThemeChromiumWin::platformActiveTextSearchHighlightColor):
+        (WebCore::RenderThemeChromiumWin::platformInactiveTextSearchHighlightColor):
+        * rendering/RenderThemeChromiumWin.h:
+
</ins><span class="cx"> 2009-04-10  Pamela Greene  &lt;pam@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Dimitri Glazkov.
</span></span></pre></div>
<a id="trunkWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.cpp (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.cpp        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/dom/Document.cpp        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -3701,6 +3701,54 @@
</span><span class="cx">         node-&gt;renderer()-&gt;repaint();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Document::setMarkersActive(Range* range, bool active)
+{
+    if (m_markers.isEmpty())
+        return;
+
+    ExceptionCode ec = 0;
+    Node* startContainer = range-&gt;startContainer(ec);
+    Node* endContainer = range-&gt;endContainer(ec);
+
+    Node* pastLastNode = range-&gt;pastLastNode();
+    for (Node* node = range-&gt;firstNode(); node != pastLastNode; node = node-&gt;traverseNextNode()) {
+        int startOffset = node == startContainer ? range-&gt;startOffset(ec) : 0;
+        int endOffset = node == endContainer ? range-&gt;endOffset(ec) : INT_MAX;
+        setMarkersActive(node, startOffset, endOffset, active);
+    }
+}
+
+void Document::setMarkersActive(Node* node, unsigned startOffset, unsigned endOffset, bool active)
+{
+    MarkerMapVectorPair* vectorPair = m_markers.get(node);
+    if (!vectorPair)
+        return;
+
+    Vector&lt;DocumentMarker&gt;&amp; markers = vectorPair-&gt;first;
+    Vector&lt;IntRect&gt;&amp; rects = vectorPair-&gt;second;
+    ASSERT(markers.size() == rects.size());
+
+    bool docDirty = false;
+    for (size_t i = 0; i != markers.size(); ++i) {
+        DocumentMarker &amp;marker = markers[i];
+
+        // Markers are returned in order, so stop if we are now past the specified range.
+        if (marker.startOffset &gt;= endOffset)
+            break;
+
+        // Skip marker that is wrong type or before target.
+        if (marker.endOffset &lt; startOffset || marker.type != DocumentMarker::TextMatch)
+            continue;
+
+        marker.activeMatch = active;
+        docDirty = true;
+    }
+
+    // repaint the affected node
+    if (docDirty &amp;&amp; node-&gt;renderer())
+        node-&gt;renderer()-&gt;repaint();
+}
+
</ins><span class="cx"> #if ENABLE(XSLT)
</span><span class="cx"> 
</span><span class="cx"> void Document::applyXSLTransform(ProcessingInstruction* pi)
</span></span></pre></div>
<a id="trunkWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Document.h (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Document.h        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/dom/Document.h        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -701,6 +701,8 @@
</span><span class="cx">     void setRenderedRectForMarker(Node*, DocumentMarker, const IntRect&amp;);
</span><span class="cx">     void invalidateRenderedRectsForMarkersInRect(const IntRect&amp;);
</span><span class="cx">     void shiftMarkers(Node*, unsigned startOffset, int delta, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
</span><ins>+    void setMarkersActive(Range*, bool);
+    void setMarkersActive(Node*, unsigned startOffset, unsigned endOffset, bool);
</ins><span class="cx"> 
</span><span class="cx">     DocumentMarker* markerContainingPoint(const IntPoint&amp;, DocumentMarker::MarkerType = DocumentMarker::AllMarkers);
</span><span class="cx">     Vector&lt;DocumentMarker&gt; markersForNode(Node*);
</span></span></pre></div>
<a id="trunkWebCoredomDocumentMarkerh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/DocumentMarker.h (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/DocumentMarker.h        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/dom/DocumentMarker.h        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -30,6 +30,8 @@
</span><span class="cx"> 
</span><span class="cx"> // A range of a node within a document that is &quot;marked&quot;, such as the range of a misspelled word.
</span><span class="cx"> // It optionally includes a description that could be displayed in the user interface.
</span><ins>+// It also optionally includes a flag specifying whether the match is active, which is ignored
+// for all types other than type TextMatch.
</ins><span class="cx"> struct DocumentMarker {
</span><span class="cx"> 
</span><span class="cx">     enum MarkerType {
</span><span class="lines">@@ -43,6 +45,7 @@
</span><span class="cx">     unsigned startOffset;
</span><span class="cx">     unsigned endOffset;
</span><span class="cx">     String description;
</span><ins>+    bool activeMatch;
</ins><span class="cx"> 
</span><span class="cx">     bool operator==(const DocumentMarker&amp; o) const
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/InlineTextBox.cpp (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/InlineTextBox.cpp        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/rendering/InlineTextBox.cpp        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -738,7 +738,9 @@
</span><span class="cx">      
</span><span class="cx">     // Optionally highlight the text
</span><span class="cx">     if (renderer()-&gt;document()-&gt;frame()-&gt;markedTextMatchesAreHighlighted()) {
</span><del>-        Color color = theme()-&gt;platformTextSearchHighlightColor();
</del><ins>+        Color color = marker.activeMatch ?
+            theme()-&gt;platformActiveTextSearchHighlightColor() :
+            theme()-&gt;platformInactiveTextSearchHighlightColor();
</ins><span class="cx">         pt-&gt;save();
</span><span class="cx">         updateGraphicsContext(pt, color, color, 0);  // Don't draw text at all!
</span><span class="cx">         pt-&gt;clip(IntRect(tx + m_x, ty + y, m_width, h));
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderThemecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderTheme.cpp (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderTheme.cpp        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/rendering/RenderTheme.cpp        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -847,9 +847,14 @@
</span><span class="cx">     return Color();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Color RenderTheme::platformTextSearchHighlightColor() const
</del><ins>+Color RenderTheme::platformActiveTextSearchHighlightColor() const
</ins><span class="cx"> {
</span><del>-    return Color(255, 255, 0);
</del><ins>+    return Color(255, 150, 50); // Orange.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Color RenderTheme::platformInactiveTextSearchHighlightColor() const
+{
+    return Color(255, 255, 0); // Yellow.
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderThemeh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderTheme.h (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderTheme.h        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/rendering/RenderTheme.h        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -117,7 +117,9 @@
</span><span class="cx">     Color inactiveListBoxSelectionBackgroundColor() const;
</span><span class="cx">     Color inactiveListBoxSelectionForegroundColor() const;
</span><span class="cx"> 
</span><del>-    virtual Color platformTextSearchHighlightColor() const;
</del><ins>+    // Highlighting colors for TextMatches.
+    virtual Color platformActiveTextSearchHighlightColor() const;
+    virtual Color platformInactiveTextSearchHighlightColor() const;
</ins><span class="cx"> 
</span><span class="cx">     virtual void platformColorsDidChange();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderThemeChromiumWincpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderThemeChromiumWin.cpp (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderThemeChromiumWin.cpp        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/rendering/RenderThemeChromiumWin.cpp        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -135,8 +135,6 @@
</span><span class="cx"> static FontDescription menuFont;
</span><span class="cx"> static FontDescription labelFont;
</span><span class="cx"> 
</span><del>-bool RenderThemeChromiumWin::m_findInPageMode = false;
-
</del><span class="cx"> // Internal static helper functions.  We don't put them in an anonymous
</span><span class="cx"> // namespace so they have easier access to the WebCore namespace.
</span><span class="cx"> 
</span><span class="lines">@@ -276,8 +274,6 @@
</span><span class="cx"> {
</span><span class="cx">     if (ChromiumBridge::layoutTestMode())
</span><span class="cx">         return Color(&quot;#0000FF&quot;);  // Royal blue.
</span><del>-    if (m_findInPageMode)
-        return Color(255, 150, 50, 200);  // Orange.
</del><span class="cx">     COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
</span><span class="cx">     return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
</span><span class="cx"> }
</span><span class="lines">@@ -286,8 +282,6 @@
</span><span class="cx"> {
</span><span class="cx">     if (ChromiumBridge::layoutTestMode())
</span><span class="cx">         return Color(&quot;#999999&quot;);  // Medium gray.
</span><del>-    if (m_findInPageMode)
-        return Color(255, 150, 50, 200);  // Orange.
</del><span class="cx">     COLORREF color = GetSysColor(COLOR_GRAYTEXT);
</span><span class="cx">     return Color(GetRValue(color), GetGValue(color), GetBValue(color), 255);
</span><span class="cx"> }
</span><span class="lines">@@ -305,11 +299,16 @@
</span><span class="cx">     return Color::white;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Color RenderThemeChromiumWin::platformTextSearchHighlightColor() const
</del><ins>+Color RenderThemeChromiumWin::platformActiveTextSearchHighlightColor() const
</ins><span class="cx"> {
</span><del>-    return Color(255, 255, 150);
</del><ins>+    return Color(255, 150, 50);  // Orange.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Color RenderThemeChromiumWin::platformInactiveTextSearchHighlightColor() const
+{
+    return Color(255, 255, 150); // Yellow.
+}
+
</ins><span class="cx"> double RenderThemeChromiumWin::caretBlinkInterval() const
</span><span class="cx"> {
</span><span class="cx">     // Disable the blinking caret in layout test mode, as it introduces
</span><span class="lines">@@ -826,13 +825,4 @@
</span><span class="cx">     return padding;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// static
-void RenderThemeChromiumWin::setFindInPageMode(bool enable) {
-  if (m_findInPageMode == enable)
-      return;
-
-  m_findInPageMode = enable;
-  theme()-&gt;platformColorsDidChange();
-}
-
</del><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderThemeChromiumWinh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderThemeChromiumWin.h (42392 => 42393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderThemeChromiumWin.h        2009-04-10 17:13:52 UTC (rev 42392)
+++ trunk/WebCore/rendering/RenderThemeChromiumWin.h        2009-04-10 17:24:22 UTC (rev 42393)
</span><span class="lines">@@ -61,7 +61,8 @@
</span><span class="cx">         virtual Color platformInactiveSelectionBackgroundColor() const;
</span><span class="cx">         virtual Color platformActiveSelectionForegroundColor() const;
</span><span class="cx">         virtual Color platformInactiveSelectionForegroundColor() const;
</span><del>-        virtual Color platformTextSearchHighlightColor() const;
</del><ins>+        virtual Color platformActiveTextSearchHighlightColor() const;
+        virtual Color platformInactiveTextSearchHighlightColor() const;
</ins><span class="cx"> 
</span><span class="cx">         virtual double caretBlinkInterval() const;
</span><span class="cx"> 
</span><span class="lines">@@ -133,10 +134,6 @@
</span><span class="cx">         // object.
</span><span class="cx">         static void setDefaultFontSize(int);
</span><span class="cx"> 
</span><del>-        // Enables/Disables FindInPage mode, which (if enabled) overrides the
-        // selection rect color to be orange.
-        static void setFindInPageMode(bool);
-
</del><span class="cx">     private:
</span><span class="cx">         unsigned determineState(RenderObject*);
</span><span class="cx">         unsigned determineSliderThumbState(RenderObject*);
</span><span class="lines">@@ -147,9 +144,6 @@
</span><span class="cx">         bool paintTextFieldInternal(RenderObject*, const RenderObject::PaintInfo&amp;, const IntRect&amp;, bool);
</span><span class="cx"> 
</span><span class="cx">         int menuListInternalPadding(RenderStyle*, int paddingType) const;
</span><del>-
-        // A flag specifying whether we are in Find-in-page mode or not.
-        static bool m_findInPageMode;
</del><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>