~ubuntu-branches/ubuntu/jaunty/kde4libs/jaunty

« back to all changes in this revision

Viewing changes to khtml/rendering/render_canvas.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Wenning, Jonathan Thomas, Andreas Wenning
  • Date: 2009-04-01 05:55:52 UTC
  • mfrom: (1.1.29 upstream)
  • Revision ID: james.westby@ubuntu.com-20090401055552-uel5di5f3xiftax3
Tags: 4:4.2.2-0ubuntu1
[ Jonathan Thomas ]
* New upstream release (LP: #344709, #348823):
  - Bump upstreamversion and runtimedeps in debian/rules
  - Remove kubuntu_65_kcmdlineargs_decoding_svn934640.diff, applied upstream

[ Andreas Wenning ]
* Remove patch kubuntu_69_do_not_show_plasma_popups_over_screensaver.diff,
  applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
5
5
 *           (C) 2003 Apple Computer, Inc.
6
6
 *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
7
 
 *           (C) 2007-2008 Germain Garand (germain@ebooksfrance.org)
 
7
 *           (C) 2007-2009 Germain Garand (germain@ebooksfrance.org)
8
8
 *
9
9
 * This library is free software; you can redistribute it and/or
10
10
 * modify it under the terms of the GNU Library General Public
33
33
#include <kdebug.h>
34
34
#include <kglobal.h>
35
35
#include <QScrollBar>
 
36
#if QT_VERSION < 0x040500
 
37
    #define SCROLLBAR_WIDTH_HACK
 
38
    #include <QStyle>
 
39
    #include <QLayout>
 
40
    #include <QStyleOption>
 
41
#endif
36
42
 
37
43
using namespace khtml;
38
44
 
232
238
 
233
239
    if (!m_pagedMode && m_view) {
234
240
 
 
241
        // we need to adjust the document's size to make sure we don't enter
 
242
        // an endless cycle of scrollbars being added, then removed at the next layout.
 
243
 
235
244
        bool vss = m_view->verticalScrollBar()->isVisible();
236
245
        bool hss = m_view->horizontalScrollBar()->isVisible();
237
 
        QSize s = m_view->maximumViewportSize();
238
 
 
239
 
        int zoomedDocWidth = m_cachedDocWidth*zLevel/100;
240
 
        int zoomedDocHeight = m_cachedDocHeight*zLevel/100;
241
 
        if ( zoomedDocWidth > s.width() )
242
 
            s.setWidth( s.width()-m_view->verticalScrollBar()->sizeHint().width() );
243
 
        if ( zoomedDocHeight > s.height() )
244
 
            s.setHeight( s.height()-m_view->horizontalScrollBar()->sizeHint().height() );
245
 
   
 
246
 
 
247
        // calculate the extent of scrollbars
 
248
        int vsPixSize = m_view->verticalScrollBar()->sizeHint().width();
 
249
        int hsPixSize = m_view->horizontalScrollBar()->sizeHint().height();
 
250
 
 
251
#ifdef SCROLLBAR_WIDTH_HACK 
 
252
        // ### hackish turnaround for a bug in QAbstractScrollArea triggered by Oxygen.
 
253
        QStyleOption opt(0);
 
254
        opt.init(m_view);
 
255
        if (m_view->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, m_view)) {
 
256
            int fudge = m_view->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)*2;
 
257
            vsPixSize += fudge;
 
258
            hsPixSize += fudge;
 
259
        }
 
260
#endif
 
261
 
 
262
        // this variable holds the size the viewport will have after the inner content is resized to
 
263
        // the new document dimensions
 
264
        QSize viewport = m_view->maximumViewportSize();
 
265
 
 
266
        // of course, if the scrollbar policy isn't auto, there's no point adjusting any value..
 
267
        int overrideH = m_view->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded ? 0 : hDocH;
 
268
        int overrideW = m_view->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded ? 0 : hDocW;
 
269
        
 
270
        if ( !overrideW && hDocW > viewport.width() )
 
271
            viewport.setHeight( viewport.height() - hsPixSize );
 
272
        if ( !overrideH && hDocH > viewport.height() )
 
273
            viewport.setWidth( viewport.width() - vsPixSize );
 
274
            
246
275
        // if we are about to show a scrollbar, and the document is sized to the viewport w or h,
247
276
        // then reserve the scrollbar space so that it doesn't trigger the _other_ scrollbar
248
277
 
249
 
        if (!vss && m_width - m_view->verticalScrollBar()->sizeHint().width() == s.width() &&
250
 
            zoomedDocWidth <= m_width)
251
 
            hDocW = qMin( zoomedDocWidth, s.width() );
 
278
        if (!vss && m_width - vsPixSize == viewport.width() &&
 
279
            hDocW <= m_width)
 
280
            hDocW = qMin( hDocW, viewport.width() );
252
281
 
253
 
        if (!hss && m_height - m_view->horizontalScrollBar()->sizeHint().height() == s.height() &&
254
 
            zoomedDocHeight <= m_height)
255
 
            hDocH = qMin( zoomedDocHeight, s.height() );
 
282
        if (!hss && m_height - hsPixSize == viewport.height() &&
 
283
            hDocH <= m_height)
 
284
            hDocH = qMin( hDocH, viewport.height() );
256
285
 
257
286
        // likewise, if a scrollbar is shown, and we have a cunning plan to turn it off,
258
287
        // think again if we are falling downright in the hysteresis zone
259
288
 
260
 
        if (vss && s.width() > zoomedDocWidth && zoomedDocWidth > m_view->visibleWidth())
261
 
            hDocW = s.width()+1;
262
 
 
263
 
        if (hss && s.height() > zoomedDocHeight && zoomedDocHeight > m_view->visibleHeight())
264
 
            hDocH = s.height()+1;
265
 
 
266
 
        m_view->resizeContents(hDocW, hDocH);
267
 
 
268
 
        setWidth( m_viewportWidth = s.width() );
269
 
        setHeight( m_viewportHeight = s.height() );
 
289
        if (vss && viewport.width() > hDocW && hDocW > m_view->visibleWidth())
 
290
            hDocW = viewport.width()+1;
 
291
 
 
292
        if (hss && viewport.height() > hDocH && hDocH > m_view->visibleHeight())
 
293
            hDocH = viewport.height()+1;
 
294
 
 
295
        m_view->resizeContents((overrideW ? overrideW : hDocW), (overrideH ? overrideH : hDocH));
 
296
 
270
297
    }
271
298
    layer()->resize( qMax( m_cachedDocWidth,int( m_width ) ), qMax( m_cachedDocHeight,m_height ) );
272
299
}
318
345
           int d1, d2, d3, d4;
319
346
           const BackgroundLayer* bgLayer = ro->style()->backgroundLayers();
320
347
           while (bgLayer) {
321
 
               CachedImage* bg = bgLayer->backgroundAttachment() ? 0 : bgLayer->backgroundImage();
 
348
               CachedImage* bg = bgLayer->backgroundAttachment() == BGAFIXED ? bgLayer->backgroundImage() : 0;
322
349
               if (bg && bg->isComplete() && !bg->isTransparent() && !bg->isErrorImage()) {
323
350
                   int xpos, ypos;
324
351
                   absolutePosition(xpos,ypos);