<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>52735</bug_id>
          
          <creation_ts>2011-01-19 13:00:03 -0800</creation_ts>
          <short_desc>[Qt] painting of windowed plugins faulty on certain scroll events</short_desc>
          <delta_ts>2011-02-22 21:31:15 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Qt</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt, QtTriaged</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Hogan">robert</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>girish</cc>
    
    <cc>hausmann</cc>
    
    <cc>hyatt</cc>
    
    <cc>kenneth</cc>
    
    <cc>vestbo</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>336730</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-01-19 13:00:03 -0800</bug_when>
    <thetext>I noticed this while fixing the specific issue in bug 52734. The patch at bug 52734 doesn&apos;t fix it.

If you open plugins/iframe-shims.html in QtTestBrowser and resize to narrow rectangle, then shorten the window so that you can scroll up and down about 100 pixels in one step, you&apos;ll notice that after scrolling up and down once or twice (single steps, gradual scrolling won&apos;t reproduce) that the blue plugins disappear from the first two boxes in the top row. Instead they get rendered over the plugins on the two rows beneath the top row. 

I can&apos;t take a screenshot of this because ksnapshot repaints the entire screen first, which results in the plugins getting repainted properly.

This alone suggests we need to trigger an extra paint event on the frame at some point, but I&apos;m not sure when.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>342750</commentid>
    <comment_count>1</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-01-31 12:35:34 -0800</bug_when>
    <thetext>This is happening in:


void RenderWidget::paint(PaintInfo&amp; paintInfo, int tx, int ty)
{
    if (!shouldPaint(paintInfo, tx, ty))
        return;

    tx += x();
    ty += y();

    if (hasBoxDecorations() &amp;&amp; (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
        paintBoxDecorations(paintInfo, tx, ty);

    if (paintInfo.phase == PaintPhaseMask) {
        paintMask(paintInfo, tx, ty);
        return;
    }

    if (!m_frameView || paintInfo.phase != PaintPhaseForeground || style()-&gt;visibility() != VISIBLE)
        return;


Commenting out both:


    if (!shouldPaint(paintInfo, tx, ty))
        return;

and


    if (!m_frameView || paintInfo.phase != PaintPhaseForeground || style()-&gt;visibility() != VISIBLE)
        return;

fixes it. Commenting out one or the other does not. It&apos;s very hard to debug paint events so I don&apos;t really stand a chance without a few pointers, but this &apos;fixes&apos; it:

--- a/Source/WebCore/rendering/RenderReplaced.cpp
+++ b/Source/WebCore/rendering/RenderReplaced.cpp
@@ -157,18 +157,17 @@ void RenderReplaced::paint(PaintInfo&amp; paintInfo, int tx, int ty)
 
 bool RenderReplaced::shouldPaint(PaintInfo&amp; paintInfo, int&amp; tx, int&amp; ty)
 {
    if (paintInfo.phase != PaintPhaseForeground &amp;&amp; paintInfo.phase != PaintPhaseOutline &amp;&amp; paintInfo.phase != PaintPhaseSelfOutline
             &amp;&amp; paintInfo.phase != PaintPhaseSelection &amp;&amp; paintInfo.phase != PaintPhaseMask)
         return false;

     if (!paintInfo.shouldPaintWithinRoot(this))
         return false;
        
     // if we&apos;re invisible or haven&apos;t received a layout yet, then just bail.
     if (style()-&gt;visibility() != VISIBLE)
         return false;
 
-    int currentTX = tx + x();
     int currentTY = ty + y();
 
     // Early exit if the element touches the edges.
@@ -180,10 +179,9 @@ bool RenderReplaced::shouldPaint(PaintInfo&amp; paintInfo, int&amp; tx, int&amp; ty)
         top = min(selTop, top);
         bottom = max(selBottom, bottom);
     }

     int os = 2 * maximalOutlineSize(paintInfo.phase);
-    if (currentTX + leftVisualOverflow() &gt;= paintInfo.rect.right() + os || currentTX + rightVisualOverflow() &lt;= paintInfo.rect.x() - os)
-        return false;
     if (top &gt;= paintInfo.rect.bottom() + os || bottom &lt;= paintInfo.rect.y() - os)
         return false;
 
diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp
index 13b572d..8f07d40 100644
--- a/Source/WebCore/rendering/RenderWidget.cpp
+++ b/Source/WebCore/rendering/RenderWidget.cpp
@@ -260,7 +260,7 @@ void RenderWidget::paint(PaintInfo&amp; paintInfo, int tx, int ty)
         return;
     }
 
-    if (!m_frameView || paintInfo.phase != PaintPhaseForeground || style()-&gt;visibility() != VISIBLE)
+    if (!m_frameView /*|| paintInfo.phase != PaintPhaseForeground */|| style()-&gt;visibility() != VISIBLE)
         return;


I&apos;m not even sure what:


-    if (currentTX + leftVisualOverflow() &gt;= paintInfo.rect.right() + os || currentTX + rightVisualOverflow() &lt;= paintInfo.rect.x() - os)
-        return false;

is doing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>342764</commentid>
    <comment_count>2</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2011-01-31 12:51:22 -0800</bug_when>
    <thetext>Just a guess but make sure the dirty rect you pass in is correct.  There&apos;s nothing wrong with the cross-platform code there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>342789</commentid>
    <comment_count>3</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-01-31 13:37:03 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; Just a guess but make sure the dirty rect you pass in is correct.  There&apos;s nothing wrong with the cross-platform code there.

Right enough, another &apos;fix&apos; is:


--- a/Source/WebKit/qt/Api/qwebframe.cpp
+++ b/Source/WebKit/qt/Api/qwebframe.cpp
@@ -374,6 +374,7 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame:
             QRect rect = intersectedRect;
             context-&gt;translate(x, y);
             rect.translate(-x, -y);
+            view-&gt;paintContents(context, rect);
             context-&gt;translate(-scrollX, -scrollY);
             rect.translate(scrollX, scrollY);
             context-&gt;clip(view-&gt;visibleContentRect());

It looks like RenderWidget::paint() needs to test the rect using its absolute co-ordinates in the frame but QWebFrame only supplies relative co-ordinates. I imagine this is pretty unique to plugins. And Qt is the only port calling frameview-&gt;paintContents() directly when rendering the page.

So I think Qt needs to test the page for plugins/widgets and make sure they always get painted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>346196</commentid>
    <comment_count>4</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-02-05 14:48:46 -0800</bug_when>
    <thetext>There is something I don&apos;t understand about RenderWidget::paint(). If a Scroll event has moved the ScrollView down by exactly or just slightly more than the height of the RenderWidget shouldPaint() in RenderWidget::paint() will never pass.

In the case of this bug the result is that the windowed plugin does not move when a single scroll event moves the viewport down by the same amount as (or slightly more than) the height of the plugin. 

So doesn&apos;t ScrollView need to take account of this somehow?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>346288</commentid>
    <comment_count>5</comment_count>
      <attachid>81403</attachid>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-02-06 07:45:34 -0800</bug_when>
    <thetext>Created attachment 81403
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350260</commentid>
    <comment_count>6</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2011-02-12 05:03:41 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; Created an attachment (id=81403) [details]
&gt; Patch

I&apos;ve look at PluginViewSymbian and PluginViewWin - neither have the code I&apos;m altering here. I don&apos;t have the set-up for testing either of them unfortunately.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>355153</commentid>
    <comment_count>7</comment_count>
      <attachid>81403</attachid>
    <who name="Andreas Kling">kling</who>
    <bug_when>2011-02-22 02:40:16 -0800</bug_when>
    <thetext>Comment on attachment 81403
Patch

r=me, thanks for digging into this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>355219</commentid>
    <comment_count>8</comment_count>
      <attachid>81403</attachid>
    <who name="Alexis Menard (darktears)">menard</who>
    <bug_when>2011-02-22 06:17:19 -0800</bug_when>
    <thetext>Comment on attachment 81403
Patch

Sounds good to me. I agree with you conclusion investigating myself. It&apos;s really complex to reproduce, not sure we can do it through a tests. I ran the LayoutTests on my machine and didn&apos;t catch any regressions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>355833</commentid>
    <comment_count>9</comment_count>
      <attachid>81403</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-02-22 21:31:10 -0800</bug_when>
    <thetext>Comment on attachment 81403
Patch

Clearing flags on attachment: 81403

Committed r79397: &lt;http://trac.webkit.org/changeset/79397&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>355834</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-02-22 21:31:15 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>81403</attachid>
            <date>2011-02-06 07:45:34 -0800</date>
            <delta_ts>2011-02-22 21:31:10 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-52735-20110206154534.patch</filename>
            <type>text/plain</type>
            <size>1872</size>
            <attacher name="Robert Hogan">robert</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb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