OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "TextAutosizer.h" | 71 #include "TextAutosizer.h" |
72 #include "TextResourceDecoder.h" | 72 #include "TextResourceDecoder.h" |
73 #include "TextStream.h" | 73 #include "TextStream.h" |
74 | 74 |
75 #include <wtf/CurrentTime.h> | 75 #include <wtf/CurrentTime.h> |
76 #include <wtf/TemporaryChange.h> | 76 #include <wtf/TemporaryChange.h> |
77 #include <wtf/UnusedParam.h> | 77 #include <wtf/UnusedParam.h> |
78 | 78 |
79 #if USE(ACCELERATED_COMPOSITING) | 79 #if USE(ACCELERATED_COMPOSITING) |
80 #include "RenderLayerCompositor.h" | 80 #include "RenderLayerCompositor.h" |
81 #include "TiledBacking.h" | |
82 #endif | 81 #endif |
83 | 82 |
84 #if ENABLE(SVG) | 83 #if ENABLE(SVG) |
85 #include "RenderSVGRoot.h" | 84 #include "RenderSVGRoot.h" |
86 #include "SVGDocument.h" | 85 #include "SVGDocument.h" |
87 #include "SVGSVGElement.h" | 86 #include "SVGSVGElement.h" |
88 #endif | 87 #endif |
89 | 88 |
90 #if USE(TILED_BACKING_STORE) | |
91 #include "TiledBackingStore.h" | |
92 #endif | |
93 | |
94 #if PLATFORM(CHROMIUM) | 89 #if PLATFORM(CHROMIUM) |
95 #include "TraceEvent.h" | 90 #include "TraceEvent.h" |
96 #endif | 91 #endif |
97 | 92 |
98 namespace WebCore { | 93 namespace WebCore { |
99 | 94 |
100 using namespace HTMLNames; | 95 using namespace HTMLNames; |
101 | 96 |
102 double FrameView::sCurrentPaintTimeStamp = 0.0; | 97 double FrameView::sCurrentPaintTimeStamp = 0.0; |
103 | 98 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 { | 731 { |
737 RenderView* renderView = this->renderView(); | 732 RenderView* renderView = this->renderView(); |
738 if (!renderView) | 733 if (!renderView) |
739 return; | 734 return; |
740 | 735 |
741 // This call will make sure the cached hasAcceleratedCompositing is updated
from the pref | 736 // This call will make sure the cached hasAcceleratedCompositing is updated
from the pref |
742 renderView->compositor()->cacheAcceleratedCompositingFlags(); | 737 renderView->compositor()->cacheAcceleratedCompositingFlags(); |
743 renderView->compositor()->updateCompositingLayers(CompositingUpdateAfterLayo
ut); | 738 renderView->compositor()->updateCompositingLayers(CompositingUpdateAfterLayo
ut); |
744 } | 739 } |
745 | 740 |
746 void FrameView::clearBackingStores() | |
747 { | |
748 RenderView* renderView = this->renderView(); | |
749 if (!renderView) | |
750 return; | |
751 | |
752 RenderLayerCompositor* compositor = renderView->compositor(); | |
753 ASSERT(compositor->inCompositingMode()); | |
754 compositor->enableCompositingMode(false); | |
755 compositor->clearBackingForAllLayers(); | |
756 } | |
757 | |
758 void FrameView::restoreBackingStores() | |
759 { | |
760 RenderView* renderView = this->renderView(); | |
761 if (!renderView) | |
762 return; | |
763 | |
764 RenderLayerCompositor* compositor = renderView->compositor(); | |
765 compositor->enableCompositingMode(true); | |
766 compositor->updateCompositingLayers(CompositingUpdateAfterLayout); | |
767 } | |
768 | |
769 bool FrameView::usesCompositedScrolling() const | 741 bool FrameView::usesCompositedScrolling() const |
770 { | 742 { |
771 RenderView* renderView = this->renderView(); | 743 RenderView* renderView = this->renderView(); |
772 if (!renderView) | 744 if (!renderView) |
773 return false; | 745 return false; |
774 if (m_frame->settings() && m_frame->settings()->compositedScrollingForFrames
Enabled()) | 746 if (m_frame->settings() && m_frame->settings()->compositedScrollingForFrames
Enabled()) |
775 return renderView->compositor()->inForcedCompositingMode(); | 747 return renderView->compositor()->inForcedCompositingMode(); |
776 return false; | 748 return false; |
777 } | 749 } |
778 | 750 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 // Now set our scrollbar state for the layout. | 1120 // Now set our scrollbar state for the layout. |
1149 ScrollbarMode currentHMode = horizontalScrollbarMode(); | 1121 ScrollbarMode currentHMode = horizontalScrollbarMode(); |
1150 ScrollbarMode currentVMode = verticalScrollbarMode(); | 1122 ScrollbarMode currentVMode = verticalScrollbarMode(); |
1151 | 1123 |
1152 if (m_firstLayout || (hMode != currentHMode || vMode != currentVMode
)) { | 1124 if (m_firstLayout || (hMode != currentHMode || vMode != currentVMode
)) { |
1153 if (m_firstLayout) { | 1125 if (m_firstLayout) { |
1154 setScrollbarsSuppressed(true); | 1126 setScrollbarsSuppressed(true); |
1155 | 1127 |
1156 m_firstLayout = false; | 1128 m_firstLayout = false; |
1157 m_firstLayoutCallbackPending = true; | 1129 m_firstLayoutCallbackPending = true; |
1158 if (useFixedLayout() && !fixedLayoutSize().isEmpty() && dele
gatesScrolling()) | 1130 m_lastViewportSize = visibleContentRect(IncludeScrollbars).s
ize(); |
1159 m_lastViewportSize = fixedLayoutSize(); | |
1160 else | |
1161 m_lastViewportSize = visibleContentRect(IncludeScrollbar
s).size(); | |
1162 m_lastZoomFactor = root->style()->zoom(); | 1131 m_lastZoomFactor = root->style()->zoom(); |
1163 | 1132 |
1164 // Set the initial vMode to AlwaysOn if we're auto. | 1133 // Set the initial vMode to AlwaysOn if we're auto. |
1165 if (vMode == ScrollbarAuto) | 1134 if (vMode == ScrollbarAuto) |
1166 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This cau
ses a vertical scrollbar to appear. | 1135 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This cau
ses a vertical scrollbar to appear. |
1167 // Set the initial hMode to AlwaysOff if we're auto. | 1136 // Set the initial hMode to AlwaysOff if we're auto. |
1168 if (hMode == ScrollbarAuto) | 1137 if (hMode == ScrollbarAuto) |
1169 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This
causes a horizontal scrollbar to disappear. | 1138 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This
causes a horizontal scrollbar to disappear. |
1170 | 1139 |
1171 setScrollbarModes(hMode, vMode); | 1140 setScrollbarModes(hMode, vMode); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 | 1718 |
1750 if (newScrollPosition == scrollPosition()) | 1719 if (newScrollPosition == scrollPosition()) |
1751 return; | 1720 return; |
1752 | 1721 |
1753 if (requestScrollPositionUpdate(newScrollPosition)) | 1722 if (requestScrollPositionUpdate(newScrollPosition)) |
1754 return; | 1723 return; |
1755 | 1724 |
1756 ScrollView::setScrollPosition(newScrollPosition); | 1725 ScrollView::setScrollPosition(newScrollPosition); |
1757 } | 1726 } |
1758 | 1727 |
1759 void FrameView::delegatesScrollingDidChange() | |
1760 { | |
1761 #if USE(ACCELERATED_COMPOSITING) | |
1762 // When we switch to delgatesScrolling mode, we should destroy the scrolling
/clipping layers in RenderLayerCompositor. | |
1763 if (hasCompositedContent()) | |
1764 clearBackingStores(); | |
1765 #endif | |
1766 } | |
1767 | |
1768 void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect) | 1728 void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect) |
1769 { | 1729 { |
1770 bool visibleContentSizeDidChange = false; | 1730 bool visibleContentSizeDidChange = false; |
1771 if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) { | 1731 if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) { |
1772 // When the viewport size changes or the content is scaled, we need to | 1732 // When the viewport size changes or the content is scaled, we need to |
1773 // reposition the fixed and sticky positioned elements. | 1733 // reposition the fixed and sticky positioned elements. |
1774 setViewportConstrainedObjectsNeedLayout(); | 1734 setViewportConstrainedObjectsNeedLayout(); |
1775 visibleContentSizeDidChange = true; | 1735 visibleContentSizeDidChange = true; |
1776 } | 1736 } |
1777 | 1737 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 // If the main thread updates the scroll position for this FrameView, we sho
uld return | 1847 // If the main thread updates the scroll position for this FrameView, we sho
uld return |
1888 // ScrollAnimator::isRubberBandInProgress(). | 1848 // ScrollAnimator::isRubberBandInProgress(). |
1889 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 1849 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
1890 return scrollAnimator->isRubberBandInProgress(); | 1850 return scrollAnimator->isRubberBandInProgress(); |
1891 | 1851 |
1892 return false; | 1852 return false; |
1893 } | 1853 } |
1894 | 1854 |
1895 bool FrameView::requestScrollPositionUpdate(const IntPoint& position) | 1855 bool FrameView::requestScrollPositionUpdate(const IntPoint& position) |
1896 { | 1856 { |
1897 #if ENABLE(THREADED_SCROLLING) | |
1898 if (Page* page = m_frame->page()) { | |
1899 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) | |
1900 return scrollingCoordinator->requestScrollPositionUpdate(this, posit
ion); | |
1901 } | |
1902 #else | |
1903 UNUSED_PARAM(position); | |
1904 #endif | |
1905 | |
1906 return false; | 1857 return false; |
1907 } | 1858 } |
1908 | 1859 |
1909 HostWindow* FrameView::hostWindow() const | 1860 HostWindow* FrameView::hostWindow() const |
1910 { | 1861 { |
1911 Page* page = frame() ? frame()->page() : 0; | 1862 Page* page = frame() ? frame()->page() : 0; |
1912 if (!page) | 1863 if (!page) |
1913 return 0; | 1864 return 0; |
1914 return page->chrome(); | 1865 return page->chrome(); |
1915 } | 1866 } |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 for (unsigned i = 0; i < maxUpdateWidgetsIterations; i++) { | 2472 for (unsigned i = 0; i < maxUpdateWidgetsIterations; i++) { |
2522 if (updateWidgets()) | 2473 if (updateWidgets()) |
2523 break; | 2474 break; |
2524 } | 2475 } |
2525 | 2476 |
2526 if (page) { | 2477 if (page) { |
2527 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) | 2478 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) |
2528 scrollingCoordinator->frameViewLayoutUpdated(this); | 2479 scrollingCoordinator->frameViewLayoutUpdated(this); |
2529 } | 2480 } |
2530 | 2481 |
2531 #if USE(ACCELERATED_COMPOSITING) | |
2532 if (renderView && renderView->usesCompositing()) | |
2533 renderView->compositor()->frameViewDidLayout(); | |
2534 #endif | |
2535 | |
2536 scrollToAnchor(); | 2482 scrollToAnchor(); |
2537 | 2483 |
2538 m_actionScheduler->resume(); | 2484 m_actionScheduler->resume(); |
2539 | 2485 |
2540 if (renderView && !renderView->printing()) { | 2486 if (renderView && !renderView->printing()) { |
2541 IntSize currentSize; | 2487 IntSize currentSize; |
2542 if (useFixedLayout() && !fixedLayoutSize().isEmpty() && delegatesScrolli
ng()) | 2488 currentSize = visibleContentRect(IncludeScrollbars).size(); |
2543 currentSize = fixedLayoutSize(); | |
2544 else | |
2545 currentSize = visibleContentRect(IncludeScrollbars).size(); | |
2546 float currentZoomFactor = renderView->style()->zoom(); | 2489 float currentZoomFactor = renderView->style()->zoom(); |
2547 bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || c
urrentZoomFactor != m_lastZoomFactor); | 2490 bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || c
urrentZoomFactor != m_lastZoomFactor); |
2548 m_lastViewportSize = currentSize; | 2491 m_lastViewportSize = currentSize; |
2549 m_lastZoomFactor = currentZoomFactor; | 2492 m_lastZoomFactor = currentZoomFactor; |
2550 if (resized) { | 2493 if (resized) { |
2551 m_frame->eventHandler()->sendResizeEvent(); | 2494 m_frame->eventHandler()->sendResizeEvent(); |
2552 | 2495 |
2553 if (InspectorInstrumentation::hasFrontends()) { | 2496 if (InspectorInstrumentation::hasFrontends()) { |
2554 if (page) { | 2497 if (page) { |
2555 if (page->mainFrame() == m_frame) { | 2498 if (page->mainFrame() == m_frame) { |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3455 | 3398 |
3456 if (shouldAdjustViewSize) | 3399 if (shouldAdjustViewSize) |
3457 adjustViewSize(); | 3400 adjustViewSize(); |
3458 } | 3401 } |
3459 | 3402 |
3460 IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRe
ct& rendererRect) const | 3403 IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRe
ct& rendererRect) const |
3461 { | 3404 { |
3462 IntRect rect = pixelSnappedIntRect(enclosingLayoutRect(renderer->localToAbso
luteQuad(FloatRect(rendererRect)).boundingBox())); | 3405 IntRect rect = pixelSnappedIntRect(enclosingLayoutRect(renderer->localToAbso
luteQuad(FloatRect(rendererRect)).boundingBox())); |
3463 | 3406 |
3464 // Convert from page ("absolute") to FrameView coordinates. | 3407 // Convert from page ("absolute") to FrameView coordinates. |
3465 if (!delegatesScrolling()) | 3408 rect.moveBy(-scrollPosition()); |
3466 rect.moveBy(-scrollPosition()); | |
3467 | 3409 |
3468 return rect; | 3410 return rect; |
3469 } | 3411 } |
3470 | 3412 |
3471 IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect
& viewRect) const | 3413 IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect
& viewRect) const |
3472 { | 3414 { |
3473 IntRect rect = viewRect; | 3415 IntRect rect = viewRect; |
3474 | 3416 |
3475 // Convert from FrameView coords into page ("absolute") coordinates. | 3417 // Convert from FrameView coords into page ("absolute") coordinates. |
3476 if (!delegatesScrolling()) | 3418 rect.moveBy(scrollPosition()); |
3477 rect.moveBy(scrollPosition()); | |
3478 | 3419 |
3479 // FIXME: we don't have a way to map an absolute rect down to a local quad,
so just | 3420 // FIXME: we don't have a way to map an absolute rect down to a local quad,
so just |
3480 // move the rect for now. | 3421 // move the rect for now. |
3481 rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(),
UseTransforms))); | 3422 rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(),
UseTransforms))); |
3482 return rect; | 3423 return rect; |
3483 } | 3424 } |
3484 | 3425 |
3485 IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntP
oint& rendererPoint) const | 3426 IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntP
oint& rendererPoint) const |
3486 { | 3427 { |
3487 IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, Us
eTransforms)); | 3428 IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, Us
eTransforms)); |
3488 | 3429 |
3489 // Convert from page ("absolute") to FrameView coordinates. | 3430 // Convert from page ("absolute") to FrameView coordinates. |
3490 if (!delegatesScrolling()) | 3431 point.moveBy(-scrollPosition()); |
3491 point.moveBy(-scrollPosition()); | |
3492 return point; | 3432 return point; |
3493 } | 3433 } |
3494 | 3434 |
3495 IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoi
nt& viewPoint) const | 3435 IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoi
nt& viewPoint) const |
3496 { | 3436 { |
3497 IntPoint point = viewPoint; | 3437 IntPoint point = viewPoint; |
3498 | 3438 |
3499 // Convert from FrameView coords into page ("absolute") coordinates. | 3439 // Convert from FrameView coords into page ("absolute") coordinates. |
3500 if (!delegatesScrolling()) | 3440 point += IntSize(scrollX(), scrollY()); |
3501 point += IntSize(scrollX(), scrollY()); | |
3502 | 3441 |
3503 return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms)); | 3442 return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms)); |
3504 } | 3443 } |
3505 | 3444 |
3506 IntRect FrameView::convertToContainingView(const IntRect& localRect) const | 3445 IntRect FrameView::convertToContainingView(const IntRect& localRect) const |
3507 { | 3446 { |
3508 if (const ScrollView* parentScrollView = parent()) { | 3447 if (const ScrollView* parentScrollView = parent()) { |
3509 if (parentScrollView->isFrameView()) { | 3448 if (parentScrollView->isFrameView()) { |
3510 const FrameView* parentView = toFrameView(parentScrollView); | 3449 const FrameView* parentView = toFrameView(parentScrollView); |
3511 // Get our renderer in the parent view | 3450 // Get our renderer in the parent view |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 | 3636 |
3698 bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) | 3637 bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) |
3699 { | 3638 { |
3700 // Note that to allow for rubber-band over-scroll behavior, even non-scrolla
ble views | 3639 // Note that to allow for rubber-band over-scroll behavior, even non-scrolla
ble views |
3701 // should handle wheel events. | 3640 // should handle wheel events. |
3702 #if !ENABLE(RUBBER_BANDING) | 3641 #if !ENABLE(RUBBER_BANDING) |
3703 if (!isScrollable()) | 3642 if (!isScrollable()) |
3704 return false; | 3643 return false; |
3705 #endif | 3644 #endif |
3706 | 3645 |
3707 if (delegatesScrolling()) { | |
3708 IntSize offset = scrollOffset(); | |
3709 IntSize newOffset = IntSize(offset.width() - wheelEvent.deltaX(), offset
.height() - wheelEvent.deltaY()); | |
3710 if (offset != newOffset) { | |
3711 ScrollView::scrollTo(newOffset); | |
3712 scrollPositionChanged(); | |
3713 frame()->loader()->client()->didChangeScrollOffset(); | |
3714 } | |
3715 return true; | |
3716 } | |
3717 | |
3718 // We don't allow mouse wheeling to happen in a ScrollView that has had its
scrollbars explicitly disabled. | 3646 // We don't allow mouse wheeling to happen in a ScrollView that has had its
scrollbars explicitly disabled. |
3719 if (!canHaveScrollbars()) | 3647 if (!canHaveScrollbars()) |
3720 return false; | 3648 return false; |
3721 | 3649 |
3722 #if ENABLE(THREADED_SCROLLING) | 3650 #if ENABLE(THREADED_SCROLLING) |
3723 if (Page* page = m_frame->page()) { | 3651 if (Page* page = m_frame->page()) { |
3724 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) { | 3652 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) { |
3725 if (scrollingCoordinator->coordinatesScrollingForFrameView(this)) | 3653 if (scrollingCoordinator->coordinatesScrollingForFrameView(this)) |
3726 return scrollingCoordinator->handleWheelEvent(this, wheelEvent); | 3654 return scrollingCoordinator->handleWheelEvent(this, wheelEvent); |
3727 } | 3655 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3763 if (frame() && frame()->document()) | 3691 if (frame() && frame()->document()) |
3764 return frame()->document()->existingAXObjectCache(); | 3692 return frame()->document()->existingAXObjectCache(); |
3765 return 0; | 3693 return 0; |
3766 } | 3694 } |
3767 | 3695 |
3768 void FrameView::setScrollingPerformanceLoggingEnabled(bool) | 3696 void FrameView::setScrollingPerformanceLoggingEnabled(bool) |
3769 { | 3697 { |
3770 } | 3698 } |
3771 | 3699 |
3772 } // namespace WebCore | 3700 } // namespace WebCore |
OLD | NEW |