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 57 matching lines...) Loading... |
68 #include "core/rendering/RenderView.h" | 68 #include "core/rendering/RenderView.h" |
69 #include "core/rendering/RenderWidget.h" | 69 #include "core/rendering/RenderWidget.h" |
70 #include "core/rendering/TextAutosizer.h" | 70 #include "core/rendering/TextAutosizer.h" |
71 #include "core/rendering/compositing/CompositedLayerMapping.h" | 71 #include "core/rendering/compositing/CompositedLayerMapping.h" |
72 #include "core/rendering/compositing/CompositedSelectionBound.h" | 72 #include "core/rendering/compositing/CompositedSelectionBound.h" |
73 #include "core/rendering/compositing/RenderLayerCompositor.h" | 73 #include "core/rendering/compositing/RenderLayerCompositor.h" |
74 #include "core/rendering/style/RenderStyle.h" | 74 #include "core/rendering/style/RenderStyle.h" |
75 #include "core/rendering/svg/RenderSVGRoot.h" | 75 #include "core/rendering/svg/RenderSVGRoot.h" |
76 #include "core/svg/SVGDocumentExtensions.h" | 76 #include "core/svg/SVGDocumentExtensions.h" |
77 #include "core/svg/SVGSVGElement.h" | 77 #include "core/svg/SVGSVGElement.h" |
| 78 #include "platform/HostWindow.h" |
78 #include "platform/RuntimeEnabledFeatures.h" | 79 #include "platform/RuntimeEnabledFeatures.h" |
79 #include "platform/ScriptForbiddenScope.h" | 80 #include "platform/ScriptForbiddenScope.h" |
80 #include "platform/TraceEvent.h" | 81 #include "platform/TraceEvent.h" |
81 #include "platform/fonts/FontCache.h" | 82 #include "platform/fonts/FontCache.h" |
82 #include "platform/geometry/FloatRect.h" | 83 #include "platform/geometry/FloatRect.h" |
83 #include "platform/graphics/GraphicsContext.h" | 84 #include "platform/graphics/GraphicsContext.h" |
| 85 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 86 #include "platform/graphics/GraphicsLayer.h" |
84 #include "platform/graphics/GraphicsLayerDebugInfo.h" | 87 #include "platform/graphics/GraphicsLayerDebugInfo.h" |
85 #include "platform/scroll/ScrollAnimator.h" | 88 #include "platform/scroll/ScrollAnimator.h" |
86 #include "platform/scroll/ScrollbarTheme.h" | 89 #include "platform/scroll/ScrollbarTheme.h" |
87 #include "platform/text/TextStream.h" | 90 #include "platform/text/TextStream.h" |
88 #include "wtf/CurrentTime.h" | 91 #include "wtf/CurrentTime.h" |
| 92 #include "wtf/StdLibExtras.h" |
89 #include "wtf/TemporaryChange.h" | 93 #include "wtf/TemporaryChange.h" |
90 | 94 |
91 namespace blink { | 95 namespace blink { |
92 | 96 |
93 using namespace HTMLNames; | 97 using namespace HTMLNames; |
94 | 98 |
95 double FrameView::s_currentFrameTimeStamp = 0.0; | 99 double FrameView::s_currentFrameTimeStamp = 0.0; |
96 bool FrameView::s_inPaintContents = false; | 100 bool FrameView::s_inPaintContents = false; |
97 | 101 |
98 // The maximum number of updateWidgets iterations that should be done before ret
urning. | 102 // The maximum number of updateWidgets iterations that should be done before ret
urning. |
(...skipping 18 matching lines...) Loading... |
117 , m_inProgrammaticScroll(false) | 121 , m_inProgrammaticScroll(false) |
118 , m_safeToPropagateScrollToParent(true) | 122 , m_safeToPropagateScrollToParent(true) |
119 , m_isTrackingPaintInvalidations(false) | 123 , m_isTrackingPaintInvalidations(false) |
120 , m_scrollCorner(nullptr) | 124 , m_scrollCorner(nullptr) |
121 , m_visibleContentScaleFactor(1) | 125 , m_visibleContentScaleFactor(1) |
122 , m_inputEventsScaleFactorForEmulation(1) | 126 , m_inputEventsScaleFactorForEmulation(1) |
123 , m_layoutSizeFixedToFrameSize(true) | 127 , m_layoutSizeFixedToFrameSize(true) |
124 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) | 128 , m_didScrollTimer(this, &FrameView::didScrollTimerFired) |
125 , m_needsUpdateWidgetPositions(false) | 129 , m_needsUpdateWidgetPositions(false) |
126 , m_topControlsViewportAdjustment(0) | 130 , m_topControlsViewportAdjustment(0) |
| 131 , m_horizontalScrollbarMode(ScrollbarAuto) |
| 132 , m_verticalScrollbarMode(ScrollbarAuto) |
| 133 , m_horizontalScrollbarLock(false) |
| 134 , m_verticalScrollbarLock(false) |
| 135 , m_scrollbarsAvoidingResizer(0) |
| 136 , m_scrollbarsSuppressed(false) |
| 137 , m_inUpdateScrollbars(false) |
| 138 , m_drawPanScrollIcon(false) |
| 139 , m_clipsRepaints(true) |
127 { | 140 { |
128 ASSERT(m_frame); | 141 ASSERT(m_frame); |
129 init(); | 142 init(); |
130 | 143 |
131 if (!m_frame->isMainFrame()) | 144 if (!m_frame->isMainFrame()) |
132 return; | 145 return; |
133 | 146 |
134 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); | 147 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); |
135 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); | 148 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); |
136 } | 149 } |
(...skipping 187 matching lines...) Loading... |
324 { | 337 { |
325 IntRect oldRect = frameRect(); | 338 IntRect oldRect = frameRect(); |
326 if (newRect == oldRect) | 339 if (newRect == oldRect) |
327 return; | 340 return; |
328 | 341 |
329 // Autosized font sizes depend on the width of the viewing area. | 342 // Autosized font sizes depend on the width of the viewing area. |
330 bool autosizerNeedsUpdating = false; | 343 bool autosizerNeedsUpdating = false; |
331 if (newRect.width() != oldRect.width() && m_frame->isMainFrame() && m_frame-
>settings()->textAutosizingEnabled()) | 344 if (newRect.width() != oldRect.width() && m_frame->isMainFrame() && m_frame-
>settings()->textAutosizingEnabled()) |
332 autosizerNeedsUpdating = true; | 345 autosizerNeedsUpdating = true; |
333 | 346 |
334 ScrollView::setFrameRect(newRect); | 347 setFrameRectInternal(newRect); |
335 | 348 |
336 updateScrollableAreaSet(); | 349 updateScrollableAreaSet(); |
337 | 350 |
338 if (autosizerNeedsUpdating) { | 351 if (autosizerNeedsUpdating) { |
339 // This needs to be after the call to ScrollView::setFrameRect, because
it reads the new width. | 352 // This needs to be after the call to ScrollView::setFrameRect, because
it reads the new width. |
340 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) | 353 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) |
341 textAutosizer->updatePageInfoInAllFrames(); | 354 textAutosizer->updatePageInfoInAllFrames(); |
342 } | 355 } |
343 | 356 |
344 if (RenderView* renderView = this->renderView()) { | 357 if (RenderView* renderView = this->renderView()) { |
(...skipping 15 matching lines...) Loading... |
360 } | 373 } |
361 | 374 |
362 RenderView* FrameView::renderView() const | 375 RenderView* FrameView::renderView() const |
363 { | 376 { |
364 return frame().contentRenderer(); | 377 return frame().contentRenderer(); |
365 } | 378 } |
366 | 379 |
367 void FrameView::setCanHaveScrollbars(bool canHaveScrollbars) | 380 void FrameView::setCanHaveScrollbars(bool canHaveScrollbars) |
368 { | 381 { |
369 m_canHaveScrollbars = canHaveScrollbars; | 382 m_canHaveScrollbars = canHaveScrollbars; |
370 ScrollView::setCanHaveScrollbars(canHaveScrollbars); | 383 setCanHaveScrollbarsInternal(canHaveScrollbars); |
371 } | 384 } |
372 | 385 |
373 bool FrameView::shouldUseCustomScrollbars(Element*& customScrollbarElement, Loca
lFrame*& customScrollbarFrame) | 386 bool FrameView::shouldUseCustomScrollbars(Element*& customScrollbarElement, Loca
lFrame*& customScrollbarFrame) |
374 { | 387 { |
375 customScrollbarElement = 0; | 388 customScrollbarElement = 0; |
376 customScrollbarFrame = 0; | 389 customScrollbarFrame = 0; |
377 | 390 |
378 if (Settings* settings = m_frame->settings()) { | 391 if (Settings* settings = m_frame->settings()) { |
379 if (!settings->allowCustomScrollbarInMainFrame() && m_frame->isMainFrame
()) | 392 if (!settings->allowCustomScrollbarInMainFrame() && m_frame->isMainFrame
()) |
380 return false; | 393 return false; |
(...skipping 27 matching lines...) Loading... |
408 } | 421 } |
409 | 422 |
410 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio
n) | 423 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientatio
n) |
411 { | 424 { |
412 Element* customScrollbarElement = 0; | 425 Element* customScrollbarElement = 0; |
413 LocalFrame* customScrollbarFrame = 0; | 426 LocalFrame* customScrollbarFrame = 0; |
414 if (shouldUseCustomScrollbars(customScrollbarElement, customScrollbarFrame)) | 427 if (shouldUseCustomScrollbars(customScrollbarElement, customScrollbarFrame)) |
415 return RenderScrollbar::createCustomScrollbar(this, orientation, customS
crollbarElement, customScrollbarFrame); | 428 return RenderScrollbar::createCustomScrollbar(this, orientation, customS
crollbarElement, customScrollbarFrame); |
416 | 429 |
417 // Nobody set a custom style, so we just use a native scrollbar. | 430 // Nobody set a custom style, so we just use a native scrollbar. |
418 return ScrollView::createScrollbar(orientation); | 431 return createScrollbarInternal(orientation); |
419 } | 432 } |
420 | 433 |
421 void FrameView::setContentsSize(const IntSize& size) | 434 void FrameView::setContentsSize(const IntSize& size) |
422 { | 435 { |
423 if (size == contentsSize()) | 436 if (size == contentsSize()) |
424 return; | 437 return; |
425 | 438 |
426 ScrollView::setContentsSize(size); | 439 setContentsSizeInternal(size); |
427 ScrollView::contentsResized(); | 440 ScrollableArea::contentsResized(); |
428 | 441 |
429 Page* page = frame().page(); | 442 Page* page = frame().page(); |
430 if (!page) | 443 if (!page) |
431 return; | 444 return; |
432 | 445 |
433 updateScrollableAreaSet(); | 446 updateScrollableAreaSet(); |
434 | 447 |
435 page->chrome().contentsSizeChanged(m_frame.get(), size); | 448 page->chrome().contentsSizeChanged(m_frame.get(), size); |
436 } | 449 } |
437 | 450 |
(...skipping 14 matching lines...) Loading... |
452 void FrameView::adjustViewSize() | 465 void FrameView::adjustViewSize() |
453 { | 466 { |
454 RenderView* renderView = this->renderView(); | 467 RenderView* renderView = this->renderView(); |
455 if (!renderView) | 468 if (!renderView) |
456 return; | 469 return; |
457 | 470 |
458 ASSERT(m_frame->view() == this); | 471 ASSERT(m_frame->view() == this); |
459 | 472 |
460 const IntRect rect = renderView->documentRect(); | 473 const IntRect rect = renderView->documentRect(); |
461 const IntSize& size = rect.size(); | 474 const IntSize& size = rect.size(); |
462 ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->docume
nt()->printing(), size == contentsSize()); | 475 setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printi
ng(), size == contentsSize()); |
463 | 476 |
464 setContentsSize(size); | 477 setContentsSize(size); |
465 } | 478 } |
466 | 479 |
467 void FrameView::applyOverflowToViewportAndSetRenderer(RenderObject* o, Scrollbar
Mode& hMode, ScrollbarMode& vMode) | 480 void FrameView::applyOverflowToViewportAndSetRenderer(RenderObject* o, Scrollbar
Mode& hMode, ScrollbarMode& vMode) |
468 { | 481 { |
469 // Handle the overflow:hidden/scroll case for the body/html elements. WinIE
treats | 482 // Handle the overflow:hidden/scroll case for the body/html elements. WinIE
treats |
470 // overflow:hidden and overflow:scroll on <body> as applying to the document
's | 483 // overflow:hidden and overflow:scroll on <body> as applying to the document
's |
471 // scrollbars. The CSS2.1 draft states that HTML UAs should use the <html>
or <body> element and XML/XHTML UAs should | 484 // scrollbars. The CSS2.1 draft states that HTML UAs should use the <html>
or <body> element and XML/XHTML UAs should |
472 // use the root element. | 485 // use the root element. |
(...skipping 822 matching lines...) Loading... |
1295 if (RenderPart* frameRenderer = m_frame->ownerRenderer()) { | 1308 if (RenderPart* frameRenderer = m_frame->ownerRenderer()) { |
1296 if (isEnclosedInCompositingLayer()) { | 1309 if (isEnclosedInCompositingLayer()) { |
1297 LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->padding
Left(), | 1310 LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->padding
Left(), |
1298 frameRenderer->borderTop() + frameRenderer->paddingT
op(), | 1311 frameRenderer->borderTop() + frameRenderer->paddingT
op(), |
1299 visibleWidth(), visibleHeight()); | 1312 visibleWidth(), visibleHeight()); |
1300 frameRenderer->invalidatePaintRectangle(rect); | 1313 frameRenderer->invalidatePaintRectangle(rect); |
1301 return; | 1314 return; |
1302 } | 1315 } |
1303 } | 1316 } |
1304 | 1317 |
1305 ScrollView::scrollContentsSlowPath(updateRect); | 1318 scrollContentsSlowPathInternal(updateRect); |
1306 } | 1319 } |
1307 | 1320 |
1308 void FrameView::restoreScrollbar() | 1321 void FrameView::restoreScrollbar() |
1309 { | 1322 { |
1310 setScrollbarsSuppressed(false); | 1323 setScrollbarsSuppressed(false); |
1311 } | 1324 } |
1312 | 1325 |
1313 bool FrameView::scrollToFragment(const KURL& url) | 1326 bool FrameView::scrollToFragment(const KURL& url) |
1314 { | 1327 { |
1315 // If our URL has no ref, then we have no place we need to jump to. | 1328 // If our URL has no ref, then we have no place we need to jump to. |
(...skipping 114 matching lines...) Loading... |
1430 if (newScrollPosition == scrollPositionDouble()) | 1443 if (newScrollPosition == scrollPositionDouble()) |
1431 return; | 1444 return; |
1432 | 1445 |
1433 if (scrollBehavior == ScrollBehaviorAuto) { | 1446 if (scrollBehavior == ScrollBehaviorAuto) { |
1434 RenderObject* renderer = m_frame->document()->documentElement() ? m_fram
e->document()->documentElement()->renderer() : 0; | 1447 RenderObject* renderer = m_frame->document()->documentElement() ? m_fram
e->document()->documentElement()->renderer() : 0; |
1435 if (renderer) | 1448 if (renderer) |
1436 scrollBehavior = renderer->style()->scrollBehavior(); | 1449 scrollBehavior = renderer->style()->scrollBehavior(); |
1437 else | 1450 else |
1438 scrollBehavior = ScrollBehaviorInstant; | 1451 scrollBehavior = ScrollBehaviorInstant; |
1439 } | 1452 } |
1440 ScrollView::setScrollPosition(newScrollPosition, scrollBehavior); | 1453 setScrollPositionInternal(newScrollPosition, scrollBehavior); |
1441 } | 1454 } |
1442 | 1455 |
1443 void FrameView::setScrollPositionNonProgrammatically(const IntPoint& scrollPoint
) | 1456 void FrameView::setScrollPositionNonProgrammatically(const IntPoint& scrollPoint
) |
1444 { | 1457 { |
1445 IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint); | 1458 IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint); |
1446 | 1459 |
1447 if (newScrollPosition == scrollPosition()) | 1460 if (newScrollPosition == scrollPosition()) |
1448 return; | 1461 return; |
1449 | 1462 |
1450 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, fal
se); | 1463 TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, fal
se); |
(...skipping 140 matching lines...) Loading... |
1591 if (m_isTrackingPaintInvalidations) { | 1604 if (m_isTrackingPaintInvalidations) { |
1592 IntRect paintInvalidationRect = r; | 1605 IntRect paintInvalidationRect = r; |
1593 paintInvalidationRect.move(-scrollOffset()); | 1606 paintInvalidationRect.move(-scrollOffset()); |
1594 m_trackedPaintInvalidationRects.append(paintInvalidationRect); | 1607 m_trackedPaintInvalidationRects.append(paintInvalidationRect); |
1595 // FIXME: http://crbug.com/368518. Eventually, invalidateContentRectangl
eForPaint | 1608 // FIXME: http://crbug.com/368518. Eventually, invalidateContentRectangl
eForPaint |
1596 // is going away entirely once all layout tests are FCM. In the short | 1609 // is going away entirely once all layout tests are FCM. In the short |
1597 // term, no code should be tracking non-composited FrameView paint inval
idations. | 1610 // term, no code should be tracking non-composited FrameView paint inval
idations. |
1598 RELEASE_ASSERT_NOT_REACHED(); | 1611 RELEASE_ASSERT_NOT_REACHED(); |
1599 } | 1612 } |
1600 | 1613 |
1601 ScrollView::contentRectangleForPaintInvalidation(r); | 1614 contentRectangleForPaintInvalidationInternal(r); |
1602 } | 1615 } |
1603 | 1616 |
1604 void FrameView::contentsResized() | 1617 void FrameView::contentsResized() |
1605 { | 1618 { |
1606 if (m_frame->isMainFrame() && m_frame->document()) { | 1619 if (m_frame->isMainFrame() && m_frame->document()) { |
1607 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) | 1620 if (TextAutosizer* textAutosizer = m_frame->document()->textAutosizer()) |
1608 textAutosizer->updatePageInfoInAllFrames(); | 1621 textAutosizer->updatePageInfoInAllFrames(); |
1609 } | 1622 } |
1610 | 1623 |
1611 ScrollView::contentsResized(); | 1624 ScrollableArea::contentsResized(); |
1612 setNeedsLayout(); | 1625 setNeedsLayout(); |
1613 } | 1626 } |
1614 | 1627 |
1615 void FrameView::scrollbarExistenceDidChange() | 1628 void FrameView::scrollbarExistenceDidChange() |
1616 { | 1629 { |
1617 // We check to make sure the view is attached to a frame() as this method ca
n | 1630 // We check to make sure the view is attached to a frame() as this method ca
n |
1618 // be triggered before the view is attached by LocalFrame::createView(...) s
etting | 1631 // be triggered before the view is attached by LocalFrame::createView(...) s
etting |
1619 // various values such as setScrollBarModes(...) for example. An ASSERT is | 1632 // various values such as setScrollBarModes(...) for example. An ASSERT is |
1620 // triggered when a view is layout before being attached to a frame(). | 1633 // triggered when a view is layout before being attached to a frame(). |
1621 if (!frame().view()) | 1634 if (!frame().view()) |
(...skipping 458 matching lines...) Loading... |
2080 | 2093 |
2081 bool FrameView::isActive() const | 2094 bool FrameView::isActive() const |
2082 { | 2095 { |
2083 Page* page = frame().page(); | 2096 Page* page = frame().page(); |
2084 return page && page->focusController().isActive(); | 2097 return page && page->focusController().isActive(); |
2085 } | 2098 } |
2086 | 2099 |
2087 void FrameView::scrollTo(const DoublePoint& newPosition) | 2100 void FrameView::scrollTo(const DoublePoint& newPosition) |
2088 { | 2101 { |
2089 DoublePoint position = scrollPositionDouble(); | 2102 DoublePoint position = scrollPositionDouble(); |
2090 ScrollView::scrollTo(newPosition); | 2103 scrollToInternal(newPosition); |
2091 if (position != scrollPositionDouble()) { | 2104 if (position != scrollPositionDouble()) { |
2092 updateLayersAndCompositingAfterScrollIfNeeded(); | 2105 updateLayersAndCompositingAfterScrollIfNeeded(); |
2093 scrollPositionChanged(); | 2106 scrollPositionChanged(); |
2094 } | 2107 } |
2095 frame().loader().client()->didChangeScrollOffset(); | 2108 frame().loader().client()->didChangeScrollOffset(); |
2096 } | 2109 } |
2097 | 2110 |
2098 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
t) | 2111 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
t) |
2099 { | 2112 { |
2100 // Add in our offset within the FrameView. | 2113 // Add in our offset within the FrameView. |
(...skipping 115 matching lines...) Loading... |
2216 bool FrameView::shouldSuspendScrollAnimations() const | 2229 bool FrameView::shouldSuspendScrollAnimations() const |
2217 { | 2230 { |
2218 return m_frame->loader().state() != FrameStateComplete; | 2231 return m_frame->loader().state() != FrameStateComplete; |
2219 } | 2232 } |
2220 | 2233 |
2221 void FrameView::scrollbarStyleChanged() | 2234 void FrameView::scrollbarStyleChanged() |
2222 { | 2235 { |
2223 // FIXME: Why does this only apply to the main frame? | 2236 // FIXME: Why does this only apply to the main frame? |
2224 if (!m_frame->isMainFrame()) | 2237 if (!m_frame->isMainFrame()) |
2225 return; | 2238 return; |
2226 ScrollView::scrollbarStyleChanged(); | 2239 scrollbarStyleChangedInternal(); |
2227 } | 2240 } |
2228 | 2241 |
2229 void FrameView::notifyPageThatContentAreaWillPaint() const | 2242 void FrameView::notifyPageThatContentAreaWillPaint() const |
2230 { | 2243 { |
2231 Page* page = m_frame->page(); | 2244 Page* page = m_frame->page(); |
2232 if (!page) | 2245 if (!page) |
2233 return; | 2246 return; |
2234 | 2247 |
2235 contentAreaWillPaint(); | 2248 contentAreaWillPaint(); |
2236 | 2249 |
(...skipping 60 matching lines...) Loading... |
2297 if (cornerStyle) { | 2310 if (cornerStyle) { |
2298 if (!m_scrollCorner) | 2311 if (!m_scrollCorner) |
2299 m_scrollCorner = RenderScrollbarPart::createAnonymous(doc); | 2312 m_scrollCorner = RenderScrollbarPart::createAnonymous(doc); |
2300 m_scrollCorner->setStyle(cornerStyle.release()); | 2313 m_scrollCorner->setStyle(cornerStyle.release()); |
2301 invalidateScrollCorner(cornerRect); | 2314 invalidateScrollCorner(cornerRect); |
2302 } else if (m_scrollCorner) { | 2315 } else if (m_scrollCorner) { |
2303 m_scrollCorner->destroy(); | 2316 m_scrollCorner->destroy(); |
2304 m_scrollCorner = nullptr; | 2317 m_scrollCorner = nullptr; |
2305 } | 2318 } |
2306 | 2319 |
2307 ScrollView::updateScrollCorner(); | 2320 updateScrollCornerInternal(); |
2308 } | 2321 } |
2309 | 2322 |
2310 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne
rRect) | 2323 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne
rRect) |
2311 { | 2324 { |
2312 if (m_scrollCorner) { | 2325 if (m_scrollCorner) { |
2313 bool needsBackgorund = m_frame->isMainFrame(); | 2326 bool needsBackgorund = m_frame->isMainFrame(); |
2314 if (needsBackgorund) | 2327 if (needsBackgorund) |
2315 context->fillRect(cornerRect, baseBackgroundColor()); | 2328 context->fillRect(cornerRect, baseBackgroundColor()); |
2316 ScrollbarPainter::paintIntoRect(m_scrollCorner, context, cornerRect.loca
tion(), cornerRect); | 2329 ScrollbarPainter::paintIntoRect(m_scrollCorner, context, cornerRect.loca
tion(), cornerRect); |
2317 return; | 2330 return; |
2318 } | 2331 } |
2319 | 2332 |
2320 ScrollView::paintScrollCorner(context, cornerRect); | 2333 paintScrollCornerInternal(context, cornerRect); |
2321 } | 2334 } |
2322 | 2335 |
2323 void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const I
ntRect& rect) | 2336 void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const I
ntRect& rect) |
2324 { | 2337 { |
2325 bool needsBackgorund = bar->isCustomScrollbar() && m_frame->isMainFrame(); | 2338 bool needsBackgorund = bar->isCustomScrollbar() && m_frame->isMainFrame(); |
2326 if (needsBackgorund) { | 2339 if (needsBackgorund) { |
2327 IntRect toFill = bar->frameRect(); | 2340 IntRect toFill = bar->frameRect(); |
2328 toFill.intersect(rect); | 2341 toFill.intersect(rect); |
2329 context->fillRect(toFill, baseBackgroundColor()); | 2342 context->fillRect(toFill, baseBackgroundColor()); |
2330 } | 2343 } |
2331 | 2344 |
2332 ScrollView::paintScrollbar(context, bar, rect); | 2345 paintScrollbarInternal(context, bar, rect); |
2333 } | 2346 } |
2334 | 2347 |
2335 Color FrameView::documentBackgroundColor() const | 2348 Color FrameView::documentBackgroundColor() const |
2336 { | 2349 { |
2337 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of | 2350 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of |
2338 // the document and the body against the base background color of the frame
view. | 2351 // the document and the body against the base background color of the frame
view. |
2339 // Background images are unfortunately impractical to include. | 2352 // Background images are unfortunately impractical to include. |
2340 | 2353 |
2341 Color result = baseBackgroundColor(); | 2354 Color result = baseBackgroundColor(); |
2342 if (!frame().document()) | 2355 if (!frame().document()) |
(...skipping 177 matching lines...) Loading... |
2520 void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori
zontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRec
t) | 2533 void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori
zontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRec
t) |
2521 { | 2534 { |
2522 if (m_frame->document()->printing()) | 2535 if (m_frame->document()->printing()) |
2523 return; | 2536 return; |
2524 | 2537 |
2525 if (m_frame->isMainFrame()) { | 2538 if (m_frame->isMainFrame()) { |
2526 if (m_frame->page()->chrome().client().paintCustomOverhangArea(context,
horizontalOverhangArea, verticalOverhangArea, dirtyRect)) | 2539 if (m_frame->page()->chrome().client().paintCustomOverhangArea(context,
horizontalOverhangArea, verticalOverhangArea, dirtyRect)) |
2527 return; | 2540 return; |
2528 } | 2541 } |
2529 | 2542 |
2530 ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOver
hangArea, dirtyRect); | 2543 paintOverhangAreasInternal(context, horizontalOverhangArea, verticalOverhang
Area, dirtyRect); |
2531 } | 2544 } |
2532 | 2545 |
2533 void FrameView::updateWidgetPositionsIfNeeded() | 2546 void FrameView::updateWidgetPositionsIfNeeded() |
2534 { | 2547 { |
2535 if (!m_needsUpdateWidgetPositions) | 2548 if (!m_needsUpdateWidgetPositions) |
2536 return; | 2549 return; |
2537 | 2550 |
2538 m_needsUpdateWidgetPositions = false; | 2551 m_needsUpdateWidgetPositions = false; |
2539 | 2552 |
2540 updateWidgetPositions(); | 2553 updateWidgetPositions(); |
(...skipping 201 matching lines...) Loading... |
2742 IntPoint point = viewPoint; | 2755 IntPoint point = viewPoint; |
2743 | 2756 |
2744 // Convert from FrameView coords into page ("absolute") coordinates. | 2757 // Convert from FrameView coords into page ("absolute") coordinates. |
2745 point += IntSize(scrollX(), scrollY()); | 2758 point += IntSize(scrollX(), scrollY()); |
2746 | 2759 |
2747 return roundedIntPoint(renderer.absoluteToLocal(point, UseTransforms)); | 2760 return roundedIntPoint(renderer.absoluteToLocal(point, UseTransforms)); |
2748 } | 2761 } |
2749 | 2762 |
2750 IntRect FrameView::convertToContainingView(const IntRect& localRect) const | 2763 IntRect FrameView::convertToContainingView(const IntRect& localRect) const |
2751 { | 2764 { |
2752 if (const ScrollView* parentScrollView = toScrollView(parent())) { | 2765 if (const FrameView* parentScrollView = toFrameView(parent())) { |
2753 if (parentScrollView->isFrameView()) { | 2766 if (parentScrollView->isFrameView()) { |
2754 const FrameView* parentView = toFrameView(parentScrollView); | 2767 const FrameView* parentView = parentScrollView; |
2755 // Get our renderer in the parent view | 2768 // Get our renderer in the parent view |
2756 RenderPart* renderer = m_frame->ownerRenderer(); | 2769 RenderPart* renderer = m_frame->ownerRenderer(); |
2757 if (!renderer) | 2770 if (!renderer) |
2758 return localRect; | 2771 return localRect; |
2759 | 2772 |
2760 IntRect rect(localRect); | 2773 IntRect rect(localRect); |
2761 // Add borders and padding?? | 2774 // Add borders and padding?? |
2762 rect.move(renderer->borderLeft() + renderer->paddingLeft(), | 2775 rect.move(renderer->borderLeft() + renderer->paddingLeft(), |
2763 renderer->borderTop() + renderer->paddingTop()); | 2776 renderer->borderTop() + renderer->paddingTop()); |
2764 return parentView->convertFromRenderer(*renderer, rect); | 2777 return parentView->convertFromRenderer(*renderer, rect); |
2765 } | 2778 } |
2766 | 2779 |
2767 return Widget::convertToContainingView(localRect); | 2780 return Widget::convertToContainingView(localRect); |
2768 } | 2781 } |
2769 | 2782 |
2770 return localRect; | 2783 return localRect; |
2771 } | 2784 } |
2772 | 2785 |
2773 IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const | 2786 IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const |
2774 { | 2787 { |
2775 if (const ScrollView* parentScrollView = toScrollView(parent())) { | 2788 if (const FrameView* parentScrollView = toFrameView(parent())) { |
2776 if (parentScrollView->isFrameView()) { | 2789 if (parentScrollView->isFrameView()) { |
2777 const FrameView* parentView = toFrameView(parentScrollView); | 2790 const FrameView* parentView = parentScrollView; |
2778 | 2791 |
2779 // Get our renderer in the parent view | 2792 // Get our renderer in the parent view |
2780 RenderPart* renderer = m_frame->ownerRenderer(); | 2793 RenderPart* renderer = m_frame->ownerRenderer(); |
2781 if (!renderer) | 2794 if (!renderer) |
2782 return parentRect; | 2795 return parentRect; |
2783 | 2796 |
2784 IntRect rect = parentView->convertToRenderer(*renderer, parentRect); | 2797 IntRect rect = parentView->convertToRenderer(*renderer, parentRect); |
2785 // Subtract borders and padding | 2798 // Subtract borders and padding |
2786 rect.move(-renderer->borderLeft() - renderer->paddingLeft(), | 2799 rect.move(-renderer->borderLeft() - renderer->paddingLeft(), |
2787 -renderer->borderTop() - renderer->paddingTop()); | 2800 -renderer->borderTop() - renderer->paddingTop()); |
2788 return rect; | 2801 return rect; |
2789 } | 2802 } |
2790 | 2803 |
2791 return Widget::convertFromContainingView(parentRect); | 2804 return Widget::convertFromContainingView(parentRect); |
2792 } | 2805 } |
2793 | 2806 |
2794 return parentRect; | 2807 return parentRect; |
2795 } | 2808 } |
2796 | 2809 |
2797 IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const | 2810 IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const |
2798 { | 2811 { |
2799 if (const ScrollView* parentScrollView = toScrollView(parent())) { | 2812 if (const FrameView* parentScrollView = toFrameView(parent())) { |
2800 if (parentScrollView->isFrameView()) { | 2813 if (parentScrollView->isFrameView()) { |
2801 const FrameView* parentView = toFrameView(parentScrollView); | 2814 const FrameView* parentView = parentScrollView; |
2802 | 2815 |
2803 // Get our renderer in the parent view | 2816 // Get our renderer in the parent view |
2804 RenderPart* renderer = m_frame->ownerRenderer(); | 2817 RenderPart* renderer = m_frame->ownerRenderer(); |
2805 if (!renderer) | 2818 if (!renderer) |
2806 return localPoint; | 2819 return localPoint; |
2807 | 2820 |
2808 IntPoint point(localPoint); | 2821 IntPoint point(localPoint); |
2809 | 2822 |
2810 // Add borders and padding | 2823 // Add borders and padding |
2811 point.move(renderer->borderLeft() + renderer->paddingLeft(), | 2824 point.move(renderer->borderLeft() + renderer->paddingLeft(), |
2812 renderer->borderTop() + renderer->paddingTop()); | 2825 renderer->borderTop() + renderer->paddingTop()); |
2813 return parentView->convertFromRenderer(*renderer, point); | 2826 return parentView->convertFromRenderer(*renderer, point); |
2814 } | 2827 } |
2815 | 2828 |
2816 return Widget::convertToContainingView(localPoint); | 2829 return Widget::convertToContainingView(localPoint); |
2817 } | 2830 } |
2818 | 2831 |
2819 return localPoint; | 2832 return localPoint; |
2820 } | 2833 } |
2821 | 2834 |
2822 IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const | 2835 IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const |
2823 { | 2836 { |
2824 if (const ScrollView* parentScrollView = toScrollView(parent())) { | 2837 if (const FrameView* parentScrollView = toFrameView(parent())) { |
2825 if (parentScrollView->isFrameView()) { | 2838 if (parentScrollView->isFrameView()) { |
2826 const FrameView* parentView = toFrameView(parentScrollView); | 2839 const FrameView* parentView = parentScrollView; |
2827 | 2840 |
2828 // Get our renderer in the parent view | 2841 // Get our renderer in the parent view |
2829 RenderPart* renderer = m_frame->ownerRenderer(); | 2842 RenderPart* renderer = m_frame->ownerRenderer(); |
2830 if (!renderer) | 2843 if (!renderer) |
2831 return parentPoint; | 2844 return parentPoint; |
2832 | 2845 |
2833 IntPoint point = parentView->convertToRenderer(*renderer, parentPoin
t); | 2846 IntPoint point = parentView->convertToRenderer(*renderer, parentPoin
t); |
2834 // Subtract borders and padding | 2847 // Subtract borders and padding |
2835 point.move(-renderer->borderLeft() - renderer->paddingLeft(), | 2848 point.move(-renderer->borderLeft() - renderer->paddingLeft(), |
2836 -renderer->borderTop() - renderer->paddingTop()); | 2849 -renderer->borderTop() - renderer->paddingTop()); |
(...skipping 71 matching lines...) Loading... |
2908 | 2921 |
2909 void FrameView::removeScrollableArea(ScrollableArea* scrollableArea) | 2922 void FrameView::removeScrollableArea(ScrollableArea* scrollableArea) |
2910 { | 2923 { |
2911 if (!m_scrollableAreas) | 2924 if (!m_scrollableAreas) |
2912 return; | 2925 return; |
2913 m_scrollableAreas->remove(scrollableArea); | 2926 m_scrollableAreas->remove(scrollableArea); |
2914 } | 2927 } |
2915 | 2928 |
2916 void FrameView::setParent(Widget* widget) | 2929 void FrameView::setParent(Widget* widget) |
2917 { | 2930 { |
2918 ScrollView::setParent(widget); | 2931 setParentInternal(widget); |
2919 updateScrollableAreaSet(); | 2932 updateScrollableAreaSet(); |
2920 } | 2933 } |
2921 | 2934 |
2922 void FrameView::removeChild(Widget* widget) | 2935 void FrameView::removeChild(Widget* widget) |
2923 { | 2936 { |
2924 if (widget->isFrameView()) | 2937 if (widget->isFrameView()) |
2925 removeScrollableArea(toFrameView(widget)); | 2938 removeScrollableArea(toFrameView(widget)); |
2926 | 2939 |
2927 ScrollView::removeChild(widget); | 2940 removeChildInternal(widget); |
2928 } | 2941 } |
2929 | 2942 |
2930 bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) | 2943 bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent) |
2931 { | 2944 { |
2932 bool allowScrolling = userInputScrollable(HorizontalScrollbar) || userInputS
crollable(VerticalScrollbar); | 2945 bool allowScrolling = userInputScrollable(HorizontalScrollbar) || userInputS
crollable(VerticalScrollbar); |
2933 | 2946 |
2934 // Note that to allow for rubber-band over-scroll behavior, even non-scrolla
ble views | 2947 // Note that to allow for rubber-band over-scroll behavior, even non-scrolla
ble views |
2935 // should handle wheel events. | 2948 // should handle wheel events. |
2936 #if !USE(RUBBER_BANDING) | 2949 #if !USE(RUBBER_BANDING) |
2937 if (!isScrollable()) | 2950 if (!isScrollable()) |
(...skipping 50 matching lines...) Loading... |
2988 if (!page || !page->settings().deviceSupportsMouse()) | 3001 if (!page || !page->settings().deviceSupportsMouse()) |
2989 return; | 3002 return; |
2990 page->chrome().setCursor(cursor); | 3003 page->chrome().setCursor(cursor); |
2991 } | 3004 } |
2992 | 3005 |
2993 void FrameView::frameRectsChanged() | 3006 void FrameView::frameRectsChanged() |
2994 { | 3007 { |
2995 if (layoutSizeFixedToFrameSize()) | 3008 if (layoutSizeFixedToFrameSize()) |
2996 setLayoutSizeInternal(frameRect().size()); | 3009 setLayoutSizeInternal(frameRect().size()); |
2997 | 3010 |
2998 ScrollView::frameRectsChanged(); | 3011 frameRectsChangedInternal(); |
2999 } | 3012 } |
3000 | 3013 |
3001 void FrameView::setLayoutSizeInternal(const IntSize& size) | 3014 void FrameView::setLayoutSizeInternal(const IntSize& size) |
3002 { | 3015 { |
3003 if (m_layoutSize == size) | 3016 if (m_layoutSize == size) |
3004 return; | 3017 return; |
3005 | 3018 |
3006 m_layoutSize = size; | 3019 m_layoutSize = size; |
3007 contentsResized(); | 3020 contentsResized(); |
3008 } | 3021 } |
(...skipping 26 matching lines...) Loading... |
3035 visibleContentSizeF.scale(1 / visibleContentScaleFactor()); | 3048 visibleContentSizeF.scale(1 / visibleContentScaleFactor()); |
3036 IntSize visibleSize = expandedIntSize(visibleContentSizeF); | 3049 IntSize visibleSize = expandedIntSize(visibleContentSizeF); |
3037 | 3050 |
3038 IntPoint maximumOffset( | 3051 IntPoint maximumOffset( |
3039 contentsWidth() - visibleSize.width() - scrollOrigin().x(), | 3052 contentsWidth() - visibleSize.width() - scrollOrigin().x(), |
3040 contentsHeight() - visibleSize.height() - scrollOrigin().y()); | 3053 contentsHeight() - visibleSize.height() - scrollOrigin().y()); |
3041 maximumOffset.clampNegativeToZero(); | 3054 maximumOffset.clampNegativeToZero(); |
3042 return maximumOffset; | 3055 return maximumOffset; |
3043 } | 3056 } |
3044 | 3057 |
| 3058 // --- ScrollView --- |
| 3059 |
| 3060 void FrameView::addChild(PassRefPtr<Widget> prpChild) |
| 3061 { |
| 3062 Widget* child = prpChild.get(); |
| 3063 ASSERT(child != this && !child->parent()); |
| 3064 child->setParent(this); |
| 3065 m_children.add(prpChild); |
| 3066 } |
| 3067 |
| 3068 void FrameView::removeChildInternal(Widget* child) |
| 3069 { |
| 3070 ASSERT(child->parent() == this); |
| 3071 child->setParent(0); |
| 3072 m_children.remove(child); |
| 3073 } |
| 3074 |
| 3075 void FrameView::setHasHorizontalScrollbar(bool hasBar) |
| 3076 { |
| 3077 if (hasBar && !m_horizontalScrollbar) { |
| 3078 m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); |
| 3079 addChild(m_horizontalScrollbar.get()); |
| 3080 didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar); |
| 3081 m_horizontalScrollbar->styleChanged(); |
| 3082 } else if (!hasBar && m_horizontalScrollbar) { |
| 3083 willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar); |
| 3084 // If the scrollbar has been marked as overlapping the window resizer, |
| 3085 // then its removal should reduce the count. |
| 3086 if (m_horizontalScrollbar->overlapsResizer()) |
| 3087 adjustScrollbarsAvoidingResizerCount(-1); |
| 3088 removeChild(m_horizontalScrollbar.get()); |
| 3089 m_horizontalScrollbar = nullptr; |
| 3090 } |
| 3091 } |
| 3092 |
| 3093 void FrameView::setHasVerticalScrollbar(bool hasBar) |
| 3094 { |
| 3095 if (hasBar && !m_verticalScrollbar) { |
| 3096 m_verticalScrollbar = createScrollbar(VerticalScrollbar); |
| 3097 addChild(m_verticalScrollbar.get()); |
| 3098 didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); |
| 3099 m_verticalScrollbar->styleChanged(); |
| 3100 } else if (!hasBar && m_verticalScrollbar) { |
| 3101 willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); |
| 3102 // If the scrollbar has been marked as overlapping the window resizer, |
| 3103 // then its removal should reduce the count. |
| 3104 if (m_verticalScrollbar->overlapsResizer()) |
| 3105 adjustScrollbarsAvoidingResizerCount(-1); |
| 3106 removeChild(m_verticalScrollbar.get()); |
| 3107 m_verticalScrollbar = nullptr; |
| 3108 } |
| 3109 } |
| 3110 |
| 3111 PassRefPtr<Scrollbar> FrameView::createScrollbarInternal(ScrollbarOrientation or
ientation) |
| 3112 { |
| 3113 return Scrollbar::create(this, orientation, RegularScrollbar); |
| 3114 } |
| 3115 |
| 3116 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode ve
rticalMode, |
| 3117 bool horizontalLock, bool verticalLock) |
| 3118 { |
| 3119 bool needsUpdate = false; |
| 3120 |
| 3121 if (horizontalMode != horizontalScrollbarMode() && !m_horizontalScrollbarLoc
k) { |
| 3122 m_horizontalScrollbarMode = horizontalMode; |
| 3123 needsUpdate = true; |
| 3124 } |
| 3125 |
| 3126 if (verticalMode != verticalScrollbarMode() && !m_verticalScrollbarLock) { |
| 3127 m_verticalScrollbarMode = verticalMode; |
| 3128 needsUpdate = true; |
| 3129 } |
| 3130 |
| 3131 if (horizontalLock) |
| 3132 setHorizontalScrollbarLock(); |
| 3133 |
| 3134 if (verticalLock) |
| 3135 setVerticalScrollbarLock(); |
| 3136 |
| 3137 if (!needsUpdate) |
| 3138 return; |
| 3139 |
| 3140 updateScrollbars(scrollOffsetDouble()); |
| 3141 |
| 3142 if (!layerForScrolling()) |
| 3143 return; |
| 3144 blink::WebLayer* layer = layerForScrolling()->platformLayer(); |
| 3145 if (!layer) |
| 3146 return; |
| 3147 layer->setUserScrollable(userInputScrollable(HorizontalScrollbar), userInput
Scrollable(VerticalScrollbar)); |
| 3148 } |
| 3149 |
| 3150 void FrameView::scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& ver
ticalMode) const |
| 3151 { |
| 3152 horizontalMode = m_horizontalScrollbarMode; |
| 3153 verticalMode = m_verticalScrollbarMode; |
| 3154 } |
| 3155 |
| 3156 void FrameView::setCanHaveScrollbarsInternal(bool canScroll) |
| 3157 { |
| 3158 ScrollbarMode newHorizontalMode; |
| 3159 ScrollbarMode newVerticalMode; |
| 3160 |
| 3161 scrollbarModes(newHorizontalMode, newVerticalMode); |
| 3162 |
| 3163 if (canScroll && newVerticalMode == ScrollbarAlwaysOff) |
| 3164 newVerticalMode = ScrollbarAuto; |
| 3165 else if (!canScroll) |
| 3166 newVerticalMode = ScrollbarAlwaysOff; |
| 3167 |
| 3168 if (canScroll && newHorizontalMode == ScrollbarAlwaysOff) |
| 3169 newHorizontalMode = ScrollbarAuto; |
| 3170 else if (!canScroll) |
| 3171 newHorizontalMode = ScrollbarAlwaysOff; |
| 3172 |
| 3173 setScrollbarModes(newHorizontalMode, newVerticalMode); |
| 3174 } |
| 3175 |
| 3176 void FrameView::setClipsRepaints(bool clipsRepaints) |
| 3177 { |
| 3178 m_clipsRepaints = clipsRepaints; |
| 3179 } |
| 3180 |
| 3181 IntSize FrameView::unscaledVisibleContentSize(IncludeScrollbarsInRect scrollbarI
nclusion) const |
| 3182 { |
| 3183 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(frameRect
().size()) : frameRect().size(); |
| 3184 } |
| 3185 |
| 3186 IntSize FrameView::excludeScrollbars(const IntSize& size) const |
| 3187 { |
| 3188 int verticalScrollbarWidth = 0; |
| 3189 int horizontalScrollbarHeight = 0; |
| 3190 |
| 3191 if (Scrollbar* verticalBar = verticalScrollbar()) |
| 3192 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
| 3193 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 3194 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
| 3195 |
| 3196 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), |
| 3197 std::max(0, size.height() - horizontalScrollbarHeight)); |
| 3198 |
| 3199 } |
| 3200 |
| 3201 IntRect FrameView::visibleContentRect(IncludeScrollbarsInRect scollbarInclusion)
const |
| 3202 { |
| 3203 FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion)
; |
| 3204 visibleContentSize.scale(1 / visibleContentScaleFactor()); |
| 3205 return IntRect(flooredIntPoint(m_scrollPosition), expandedIntSize(visibleCon
tentSize)); |
| 3206 } |
| 3207 |
| 3208 IntSize FrameView::contentsSize() const |
| 3209 { |
| 3210 return m_contentsSize; |
| 3211 } |
| 3212 |
| 3213 void FrameView::setContentsSizeInternal(const IntSize& newSize) |
| 3214 { |
| 3215 if (contentsSize() == newSize) |
| 3216 return; |
| 3217 m_contentsSize = newSize; |
| 3218 updateScrollbars(scrollOffsetDouble()); |
| 3219 updateOverhangAreas(); |
| 3220 } |
| 3221 |
| 3222 IntPoint FrameView::minimumScrollPosition() const |
| 3223 { |
| 3224 return IntPoint(-scrollOrigin().x(), -scrollOrigin().y()); |
| 3225 } |
| 3226 |
| 3227 IntPoint FrameView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint)
const |
| 3228 { |
| 3229 if (!constrainsScrollingToContentEdge()) |
| 3230 return scrollPoint; |
| 3231 |
| 3232 IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); |
| 3233 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); |
| 3234 return newScrollPosition; |
| 3235 } |
| 3236 |
| 3237 DoublePoint FrameView::adjustScrollPositionWithinRange(const DoublePoint& scroll
Point) const |
| 3238 { |
| 3239 if (!constrainsScrollingToContentEdge()) |
| 3240 return scrollPoint; |
| 3241 DoublePoint newScrollPosition = scrollPoint.shrunkTo( |
| 3242 maximumScrollPosition().x(), maximumScrollPosition().y()); |
| 3243 newScrollPosition = newScrollPosition.expandedTo( |
| 3244 minimumScrollPosition().x(), minimumScrollPosition().y()); |
| 3245 return newScrollPosition; |
| 3246 } |
| 3247 |
| 3248 void FrameView::adjustScrollbarOpacity() |
| 3249 { |
| 3250 if (m_horizontalScrollbar && layerForHorizontalScrollbar()) { |
| 3251 bool isOpaqueScrollbar = !m_horizontalScrollbar->isOverlayScrollbar(); |
| 3252 layerForHorizontalScrollbar()->setContentsOpaque(isOpaqueScrollbar); |
| 3253 } |
| 3254 if (m_verticalScrollbar && layerForVerticalScrollbar()) { |
| 3255 bool isOpaqueScrollbar = !m_verticalScrollbar->isOverlayScrollbar(); |
| 3256 layerForVerticalScrollbar()->setContentsOpaque(isOpaqueScrollbar); |
| 3257 } |
| 3258 } |
| 3259 |
| 3260 int FrameView::scrollSize(ScrollbarOrientation orientation) const |
| 3261 { |
| 3262 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS
crollbar : m_verticalScrollbar).get(); |
| 3263 |
| 3264 // If no scrollbars are present, the content may still be scrollable. |
| 3265 if (!scrollbar) { |
| 3266 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); |
| 3267 scrollSize.clampNegativeToZero(); |
| 3268 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS
ize.height(); |
| 3269 } |
| 3270 |
| 3271 return scrollbar->totalSize() - scrollbar->visibleSize(); |
| 3272 } |
| 3273 |
| 3274 void FrameView::notifyPageThatContentAreaWillPaintInternal() const |
| 3275 { |
| 3276 } |
| 3277 |
| 3278 void FrameView::setScrollOffset(const IntPoint& offset) |
| 3279 { |
| 3280 scrollTo(DoublePoint(adjustScrollPositionWithinRange(offset))); |
| 3281 } |
| 3282 |
| 3283 void FrameView::setScrollOffset(const DoublePoint& offset) |
| 3284 { |
| 3285 scrollTo(adjustScrollPositionWithinRange(offset)); |
| 3286 } |
| 3287 |
| 3288 void FrameView::scrollToInternal(const DoublePoint& newPosition) |
| 3289 { |
| 3290 DoubleSize scrollDelta = newPosition - m_scrollPosition; |
| 3291 if (scrollDelta.isZero()) |
| 3292 return; |
| 3293 m_scrollPosition = newPosition; |
| 3294 |
| 3295 if (scrollbarsSuppressed()) |
| 3296 return; |
| 3297 |
| 3298 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
| 3299 if (isFrameView()) |
| 3300 m_pendingScrollDelta += scrollDelta; |
| 3301 else |
| 3302 scrollContents(flooredIntSize(scrollDelta)); |
| 3303 } |
| 3304 |
| 3305 void FrameView::setScrollPositionInternal(const DoublePoint& scrollPoint, Scroll
Behavior scrollBehavior) |
| 3306 { |
| 3307 DoublePoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint)
; |
| 3308 |
| 3309 if (newScrollPosition == scrollPositionDouble()) |
| 3310 return; |
| 3311 |
| 3312 if (scrollBehavior == ScrollBehaviorInstant) { |
| 3313 DoubleSize newOffset(newScrollPosition.x(), newScrollPosition.y()); |
| 3314 updateScrollbars(newOffset); |
| 3315 } else { |
| 3316 programmaticallyScrollSmoothlyToOffset(toFloatPoint(newScrollPosition)); |
| 3317 } |
| 3318 } |
| 3319 |
| 3320 bool FrameView::scroll(ScrollDirection direction, ScrollGranularity granularity) |
| 3321 { |
| 3322 ScrollDirection physicalDirection = |
| 3323 toPhysicalDirection(direction, isVerticalDocument(), isFlippedDocument()
); |
| 3324 |
| 3325 return ScrollableArea::scroll(physicalDirection, granularity); |
| 3326 } |
| 3327 |
| 3328 IntSize FrameView::overhangAmount() const |
| 3329 { |
| 3330 IntSize stretch; |
| 3331 |
| 3332 IntPoint currentScrollPosition = scrollPosition(); |
| 3333 IntPoint minScrollPosition = minimumScrollPosition(); |
| 3334 IntPoint maxScrollPosition = maximumScrollPosition(); |
| 3335 |
| 3336 if (currentScrollPosition.x() < minScrollPosition.x()) |
| 3337 stretch.setWidth(currentScrollPosition.x() - minScrollPosition.x()); |
| 3338 if (currentScrollPosition.x() > maxScrollPosition.x()) |
| 3339 stretch.setWidth(currentScrollPosition.x() - maxScrollPosition.x()); |
| 3340 |
| 3341 if (currentScrollPosition.y() < minScrollPosition.y()) |
| 3342 stretch.setHeight(currentScrollPosition.y() - minScrollPosition.y()); |
| 3343 if (currentScrollPosition.y() > maxScrollPosition.y()) |
| 3344 stretch.setHeight(currentScrollPosition.y() - maxScrollPosition.y()); |
| 3345 |
| 3346 return stretch; |
| 3347 } |
| 3348 |
| 3349 void FrameView::windowResizerRectChanged() |
| 3350 { |
| 3351 updateScrollbars(scrollOffsetDouble()); |
| 3352 } |
| 3353 |
| 3354 static bool useOverlayScrollbars() |
| 3355 { |
| 3356 // FIXME: Need to detect the presence of CSS custom scrollbars, which are no
n-overlay regardless the ScrollbarTheme. |
| 3357 return ScrollbarTheme::theme()->usesOverlayScrollbars(); |
| 3358 } |
| 3359 |
| 3360 void FrameView::computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool&
newHasVerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOptio
n option) const |
| 3361 { |
| 3362 bool hasHorizontalScrollbar = m_horizontalScrollbar; |
| 3363 bool hasVerticalScrollbar = m_verticalScrollbar; |
| 3364 |
| 3365 newHasHorizontalScrollbar = hasHorizontalScrollbar; |
| 3366 newHasVerticalScrollbar = hasVerticalScrollbar; |
| 3367 |
| 3368 ScrollbarMode hScroll = m_horizontalScrollbarMode; |
| 3369 ScrollbarMode vScroll = m_verticalScrollbarMode; |
| 3370 |
| 3371 if (hScroll != ScrollbarAuto) |
| 3372 newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn); |
| 3373 if (vScroll != ScrollbarAuto) |
| 3374 newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn); |
| 3375 |
| 3376 if (m_scrollbarsSuppressed || (hScroll != ScrollbarAuto && vScroll != Scroll
barAuto)) |
| 3377 return; |
| 3378 |
| 3379 if (hScroll == ScrollbarAuto) |
| 3380 newHasHorizontalScrollbar = docSize.width() > visibleWidth(); |
| 3381 if (vScroll == ScrollbarAuto) |
| 3382 newHasVerticalScrollbar = docSize.height() > visibleHeight(); |
| 3383 |
| 3384 if (useOverlayScrollbars()) |
| 3385 return; |
| 3386 |
| 3387 IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size(); |
| 3388 |
| 3389 bool attemptToRemoveScrollbars = (option == FirstPass |
| 3390 && docSize.width() <= fullVisibleSize.width() && docSize.height() <= ful
lVisibleSize.height()); |
| 3391 if (attemptToRemoveScrollbars) { |
| 3392 if (hScroll == ScrollbarAuto) |
| 3393 newHasHorizontalScrollbar = false; |
| 3394 if (vScroll == ScrollbarAuto) |
| 3395 newHasVerticalScrollbar = false; |
| 3396 } |
| 3397 |
| 3398 // If we ever turn one scrollbar off, always turn the other one off too. |
| 3399 // Never ever try to both gain/lose a scrollbar in the same pass. |
| 3400 if (!newHasHorizontalScrollbar && hasHorizontalScrollbar && vScroll != Scrol
lbarAlwaysOn) |
| 3401 newHasVerticalScrollbar = false; |
| 3402 if (!newHasVerticalScrollbar && hasVerticalScrollbar && hScroll != Scrollbar
AlwaysOn) |
| 3403 newHasHorizontalScrollbar = false; |
| 3404 } |
| 3405 |
| 3406 void FrameView::updateScrollbarGeometry() |
| 3407 { |
| 3408 if (m_horizontalScrollbar) { |
| 3409 int clientWidth = visibleWidth(); |
| 3410 IntRect oldRect(m_horizontalScrollbar->frameRect()); |
| 3411 IntRect hBarRect((shouldPlaceVerticalScrollbarOnLeft() && m_verticalScro
llbar) ? m_verticalScrollbar->width() : 0, |
| 3412 height() - m_horizontalScrollbar->height(), |
| 3413 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), |
| 3414 m_horizontalScrollbar->height()); |
| 3415 m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRe
ct, m_horizontalScrollbar.get())); |
| 3416 if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRe
ct()) |
| 3417 m_horizontalScrollbar->invalidate(); |
| 3418 |
| 3419 if (m_scrollbarsSuppressed) |
| 3420 m_horizontalScrollbar->setSuppressInvalidation(true); |
| 3421 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); |
| 3422 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
| 3423 m_horizontalScrollbar->offsetDidChange(); |
| 3424 if (m_scrollbarsSuppressed) |
| 3425 m_horizontalScrollbar->setSuppressInvalidation(false); |
| 3426 } |
| 3427 |
| 3428 if (m_verticalScrollbar) { |
| 3429 int clientHeight = visibleHeight(); |
| 3430 IntRect oldRect(m_verticalScrollbar->frameRect()); |
| 3431 IntRect vBarRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - m
_verticalScrollbar->width()), |
| 3432 0, |
| 3433 m_verticalScrollbar->width(), |
| 3434 height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height()
: 0)); |
| 3435 m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect
, m_verticalScrollbar.get())); |
| 3436 if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect
()) |
| 3437 m_verticalScrollbar->invalidate(); |
| 3438 |
| 3439 if (m_scrollbarsSuppressed) |
| 3440 m_verticalScrollbar->setSuppressInvalidation(true); |
| 3441 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
| 3442 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
| 3443 m_verticalScrollbar->offsetDidChange(); |
| 3444 if (m_scrollbarsSuppressed) |
| 3445 m_verticalScrollbar->setSuppressInvalidation(false); |
| 3446 } |
| 3447 } |
| 3448 |
| 3449 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar*
scrollbar) |
| 3450 { |
| 3451 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov
erlap |
| 3452 // if necessary. |
| 3453 IntRect adjustedRect(rect); |
| 3454 bool overlapsResizer = false; |
| 3455 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { |
| 3456 IntRect resizerRect = convertFromContainingWindow(windowResizerRect()); |
| 3457 if (rect.intersects(resizerRect)) { |
| 3458 if (scrollbar->orientation() == HorizontalScrollbar) { |
| 3459 int overlap = rect.maxX() - resizerRect.x(); |
| 3460 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) { |
| 3461 adjustedRect.setWidth(rect.width() - overlap); |
| 3462 overlapsResizer = true; |
| 3463 } |
| 3464 } else { |
| 3465 int overlap = rect.maxY() - resizerRect.y(); |
| 3466 if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) { |
| 3467 adjustedRect.setHeight(rect.height() - overlap); |
| 3468 overlapsResizer = true; |
| 3469 } |
| 3470 } |
| 3471 } |
| 3472 } |
| 3473 if (overlapsResizer != scrollbar->overlapsResizer()) { |
| 3474 scrollbar->setOverlapsResizer(overlapsResizer); |
| 3475 adjustScrollbarsAvoidingResizerCount(overlapsResizer ? 1 : -1); |
| 3476 } |
| 3477 return adjustedRect; |
| 3478 } |
| 3479 |
| 3480 bool FrameView::adjustScrollbarExistence(ComputeScrollbarExistenceOption option) |
| 3481 { |
| 3482 ASSERT(m_inUpdateScrollbars); |
| 3483 |
| 3484 // If we came in here with the view already needing a layout, then go ahead
and do that |
| 3485 // first. (This will be the common case, e.g., when the page changes due to
window resizing for example). |
| 3486 // This layout will not re-enter updateScrollbars and does not count towards
our max layout pass total. |
| 3487 if (!m_scrollbarsSuppressed) |
| 3488 scrollbarExistenceDidChange(); |
| 3489 |
| 3490 bool hasHorizontalScrollbar = m_horizontalScrollbar; |
| 3491 bool hasVerticalScrollbar = m_verticalScrollbar; |
| 3492 |
| 3493 bool newHasHorizontalScrollbar = false; |
| 3494 bool newHasVerticalScrollbar = false; |
| 3495 computeScrollbarExistence(newHasHorizontalScrollbar, newHasVerticalScrollbar
, contentsSize(), option); |
| 3496 |
| 3497 bool scrollbarExistenceChanged = hasHorizontalScrollbar != newHasHorizontalS
crollbar || hasVerticalScrollbar != newHasVerticalScrollbar; |
| 3498 if (!scrollbarExistenceChanged) |
| 3499 return false; |
| 3500 |
| 3501 setHasHorizontalScrollbar(newHasHorizontalScrollbar); |
| 3502 setHasVerticalScrollbar(newHasVerticalScrollbar); |
| 3503 |
| 3504 if (m_scrollbarsSuppressed) |
| 3505 return true; |
| 3506 |
| 3507 if (!useOverlayScrollbars()) |
| 3508 contentsResized(); |
| 3509 scrollbarExistenceDidChange(); |
| 3510 return true; |
| 3511 } |
| 3512 |
| 3513 void FrameView::updateScrollbars(const DoubleSize& desiredOffset) |
| 3514 { |
| 3515 if (scrollbarsDisabled()) { |
| 3516 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
| 3517 return; |
| 3518 } |
| 3519 |
| 3520 if (m_inUpdateScrollbars) |
| 3521 return; |
| 3522 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); |
| 3523 |
| 3524 IntSize oldVisibleSize = visibleSize(); |
| 3525 |
| 3526 bool scrollbarExistenceChanged = false; |
| 3527 int maxUpdateScrollbarsPass = useOverlayScrollbars() || m_scrollbarsSuppress
ed ? 1 : 3; |
| 3528 for (int updateScrollbarsPass = 0; updateScrollbarsPass < maxUpdateScrollbar
sPass; updateScrollbarsPass++) { |
| 3529 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental : First
Pass)) |
| 3530 break; |
| 3531 scrollbarExistenceChanged = true; |
| 3532 } |
| 3533 |
| 3534 updateScrollbarGeometry(); |
| 3535 |
| 3536 if (scrollbarExistenceChanged) { |
| 3537 // FIXME: Is frameRectsChanged really necessary here? Have any frame rec
ts changed? |
| 3538 frameRectsChanged(); |
| 3539 positionScrollbarLayers(); |
| 3540 updateScrollCorner(); |
| 3541 } |
| 3542 |
| 3543 // FIXME: We don't need to do this if we are composited. |
| 3544 IntSize newVisibleSize = visibleSize(); |
| 3545 if (newVisibleSize.width() > oldVisibleSize.width()) { |
| 3546 if (shouldPlaceVerticalScrollbarOnLeft()) |
| 3547 invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize
.width(), newVisibleSize.height())); |
| 3548 else |
| 3549 invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.wid
th() - oldVisibleSize.width(), newVisibleSize.height())); |
| 3550 } |
| 3551 if (newVisibleSize.height() > oldVisibleSize.height()) |
| 3552 invalidateRect(IntRect(0, oldVisibleSize.height(), newVisibleSize.width(
), newVisibleSize.height() - oldVisibleSize.height())); |
| 3553 |
| 3554 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
| 3555 } |
| 3556 |
| 3557 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) |
| 3558 { |
| 3559 DoublePoint adjustedScrollPosition = DoublePoint(offset); |
| 3560 |
| 3561 if (!isRubberBandInProgress()) |
| 3562 adjustedScrollPosition = adjustScrollPositionWithinRange(adjustedScrollP
osition); |
| 3563 |
| 3564 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged(
)) { |
| 3565 ScrollableArea::scrollToOffsetWithoutAnimation(toFloatPoint(adjustedScro
llPosition)); |
| 3566 resetScrollOriginChanged(); |
| 3567 } |
| 3568 } |
| 3569 |
| 3570 const int panIconSizeLength = 16; |
| 3571 |
| 3572 IntRect FrameView::rectToCopyOnScroll() const |
| 3573 { |
| 3574 IntRect scrollViewRect = convertToContainingWindow(IntRect((shouldPlaceVerti
calScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0,
0, visibleWidth(), visibleHeight())); |
| 3575 if (hasOverlayScrollbars()) { |
| 3576 int verticalScrollbarWidth = (verticalScrollbar() && !hasLayerForVertica
lScrollbar()) ? verticalScrollbar()->width() : 0; |
| 3577 int horizontalScrollbarHeight = (horizontalScrollbar() && !hasLayerForHo
rizontalScrollbar()) ? horizontalScrollbar()->height() : 0; |
| 3578 |
| 3579 scrollViewRect.setWidth(scrollViewRect.width() - verticalScrollbarWidth)
; |
| 3580 scrollViewRect.setHeight(scrollViewRect.height() - horizontalScrollbarHe
ight); |
| 3581 } |
| 3582 return scrollViewRect; |
| 3583 } |
| 3584 |
| 3585 void FrameView::scrollContentsIfNeeded() |
| 3586 { |
| 3587 if (m_pendingScrollDelta.isZero()) |
| 3588 return; |
| 3589 DoubleSize scrollDelta = m_pendingScrollDelta; |
| 3590 m_pendingScrollDelta = DoubleSize(); |
| 3591 // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
| 3592 scrollContents(flooredIntSize(scrollDelta)); |
| 3593 } |
| 3594 |
| 3595 void FrameView::scrollContents(const IntSize& scrollDelta) |
| 3596 { |
| 3597 HostWindow* window = hostWindow(); |
| 3598 if (!window) |
| 3599 return; |
| 3600 |
| 3601 IntRect clipRect = windowClipRect(); |
| 3602 IntRect updateRect = clipRect; |
| 3603 updateRect.intersect(rectToCopyOnScroll()); |
| 3604 |
| 3605 if (m_drawPanScrollIcon) { |
| 3606 // FIXME: the pan icon is broken when accelerated compositing is on, sin
ce it will draw under the compositing layers. |
| 3607 // https://bugs.webkit.org/show_bug.cgi?id=47837 |
| 3608 int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + std::max(abs
(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint w
hat's necessary |
| 3609 IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x()
- (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySq
uareSizeLength / 2)); |
| 3610 IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation, Int
Size(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength)); |
| 3611 panScrollIconDirtyRect.intersect(clipRect); |
| 3612 window->invalidateContentsAndRootView(panScrollIconDirtyRect); |
| 3613 } |
| 3614 |
| 3615 if (!scrollContentsFastPath(-scrollDelta)) |
| 3616 scrollContentsSlowPath(updateRect); |
| 3617 |
| 3618 // Invalidate the overhang areas if they are visible. |
| 3619 updateOverhangAreas(); |
| 3620 |
| 3621 // This call will move children with native widgets (plugins) and invalidate
them as well. |
| 3622 frameRectsChanged(); |
| 3623 } |
| 3624 |
| 3625 void FrameView::scrollContentsSlowPathInternal(const IntRect& updateRect) |
| 3626 { |
| 3627 hostWindow()->invalidateContentsForSlowScroll(updateRect); |
| 3628 } |
| 3629 |
| 3630 IntPoint FrameView::rootViewToContents(const IntPoint& rootViewPoint) const |
| 3631 { |
| 3632 IntPoint viewPoint = convertFromContainingWindow(rootViewPoint); |
| 3633 return viewPoint + scrollOffset(); |
| 3634 } |
| 3635 |
| 3636 IntPoint FrameView::contentsToRootView(const IntPoint& contentsPoint) const |
| 3637 { |
| 3638 IntPoint viewPoint = contentsPoint - scrollOffset(); |
| 3639 return convertToContainingWindow(viewPoint); |
| 3640 } |
| 3641 |
| 3642 IntRect FrameView::rootViewToContents(const IntRect& rootViewRect) const |
| 3643 { |
| 3644 IntRect viewRect = convertFromContainingWindow(rootViewRect); |
| 3645 viewRect.move(scrollOffset()); |
| 3646 return viewRect; |
| 3647 } |
| 3648 |
| 3649 IntRect FrameView::contentsToRootView(const IntRect& contentsRect) const |
| 3650 { |
| 3651 IntRect viewRect = contentsRect; |
| 3652 viewRect.move(-scrollOffset()); |
| 3653 return convertToContainingWindow(viewRect); |
| 3654 } |
| 3655 |
| 3656 IntPoint FrameView::windowToContents(const IntPoint& windowPoint) const |
| 3657 { |
| 3658 IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 3659 return viewPoint + scrollOffset(); |
| 3660 } |
| 3661 |
| 3662 FloatPoint FrameView::windowToContents(const FloatPoint& windowPoint) const |
| 3663 { |
| 3664 FloatPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 3665 return viewPoint + scrollOffset(); |
| 3666 } |
| 3667 |
| 3668 IntPoint FrameView::contentsToWindow(const IntPoint& contentsPoint) const |
| 3669 { |
| 3670 IntPoint viewPoint = contentsPoint - scrollOffset(); |
| 3671 return convertToContainingWindow(viewPoint); |
| 3672 } |
| 3673 |
| 3674 IntRect FrameView::windowToContents(const IntRect& windowRect) const |
| 3675 { |
| 3676 IntRect viewRect = convertFromContainingWindow(windowRect); |
| 3677 viewRect.move(scrollOffset()); |
| 3678 return viewRect; |
| 3679 } |
| 3680 |
| 3681 IntRect FrameView::contentsToWindow(const IntRect& contentsRect) const |
| 3682 { |
| 3683 IntRect viewRect = contentsRect; |
| 3684 viewRect.move(-scrollOffset()); |
| 3685 return convertToContainingWindow(viewRect); |
| 3686 } |
| 3687 |
| 3688 IntRect FrameView::contentsToScreen(const IntRect& rect) const |
| 3689 { |
| 3690 HostWindow* window = hostWindow(); |
| 3691 if (!window) |
| 3692 return IntRect(); |
| 3693 return window->rootViewToScreen(contentsToRootView(rect)); |
| 3694 } |
| 3695 |
| 3696 bool FrameView::containsScrollbarsAvoidingResizer() const |
| 3697 { |
| 3698 return !m_scrollbarsAvoidingResizer; |
| 3699 } |
| 3700 |
| 3701 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) |
| 3702 { |
| 3703 int oldCount = m_scrollbarsAvoidingResizer; |
| 3704 m_scrollbarsAvoidingResizer += overlapDelta; |
| 3705 if (parent()) { |
| 3706 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(overlapDelta
); |
| 3707 } else if (!scrollbarsSuppressed()) { |
| 3708 // If we went from n to 0 or from 0 to n and we're the outermost view, |
| 3709 // we need to invalidate the windowResizerRect(), since it will now need
to paint |
| 3710 // differently. |
| 3711 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) |
| 3712 || (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) |
| 3713 invalidateRect(windowResizerRect()); |
| 3714 } |
| 3715 } |
| 3716 |
| 3717 void FrameView::setParentInternal(Widget* parentView) |
| 3718 { |
| 3719 if (parentView == parent()) |
| 3720 return; |
| 3721 |
| 3722 if (m_scrollbarsAvoidingResizer && parent()) |
| 3723 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(-m_scrollbar
sAvoidingResizer); |
| 3724 |
| 3725 Widget::setParent(parentView); |
| 3726 |
| 3727 if (m_scrollbarsAvoidingResizer && parent()) |
| 3728 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(m_scrollbars
AvoidingResizer); |
| 3729 } |
| 3730 |
| 3731 void FrameView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppres
s) |
| 3732 { |
| 3733 if (suppressed == m_scrollbarsSuppressed) |
| 3734 return; |
| 3735 |
| 3736 m_scrollbarsSuppressed = suppressed; |
| 3737 |
| 3738 if (repaintOnUnsuppress && !suppressed) { |
| 3739 if (m_horizontalScrollbar) |
| 3740 m_horizontalScrollbar->invalidate(); |
| 3741 if (m_verticalScrollbar) |
| 3742 m_verticalScrollbar->invalidate(); |
| 3743 |
| 3744 // Invalidate the scroll corner too on unsuppress. |
| 3745 invalidateRect(scrollCornerRect()); |
| 3746 } |
| 3747 } |
| 3748 |
| 3749 Scrollbar* FrameView::scrollbarAtWindowPoint(const IntPoint& windowPoint) |
| 3750 { |
| 3751 IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 3752 return scrollbarAtViewPoint(viewPoint); |
| 3753 } |
| 3754 |
| 3755 Scrollbar* FrameView::scrollbarAtViewPoint(const IntPoint& viewPoint) |
| 3756 { |
| 3757 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe
sting() && m_horizontalScrollbar->frameRect().contains(viewPoint)) |
| 3758 return m_horizontalScrollbar.get(); |
| 3759 if (m_verticalScrollbar && m_verticalScrollbar->shouldParticipateInHitTestin
g() && m_verticalScrollbar->frameRect().contains(viewPoint)) |
| 3760 return m_verticalScrollbar.get(); |
| 3761 return 0; |
| 3762 } |
| 3763 |
| 3764 void FrameView::setFrameRectInternal(const IntRect& newRect) |
| 3765 { |
| 3766 IntRect oldRect = frameRect(); |
| 3767 |
| 3768 if (newRect == oldRect) |
| 3769 return; |
| 3770 |
| 3771 Widget::setFrameRect(newRect); |
| 3772 |
| 3773 updateScrollbars(scrollOffsetDouble()); |
| 3774 |
| 3775 frameRectsChanged(); |
| 3776 } |
| 3777 |
| 3778 void FrameView::frameRectsChangedInternal() |
| 3779 { |
| 3780 HashSet<RefPtr<Widget> >::const_iterator end = m_children.end(); |
| 3781 for (HashSet<RefPtr<Widget> >::const_iterator current = m_children.begin();
current != end; ++current) |
| 3782 (*current)->frameRectsChanged(); |
| 3783 } |
| 3784 |
| 3785 static void positionScrollbarLayer(GraphicsLayer* graphicsLayer, Scrollbar* scro
llbar) |
| 3786 { |
| 3787 if (!graphicsLayer || !scrollbar) |
| 3788 return; |
| 3789 |
| 3790 IntRect scrollbarRect = scrollbar->frameRect(); |
| 3791 graphicsLayer->setPosition(scrollbarRect.location()); |
| 3792 |
| 3793 if (scrollbarRect.size() == graphicsLayer->size()) |
| 3794 return; |
| 3795 |
| 3796 graphicsLayer->setSize(scrollbarRect.size()); |
| 3797 |
| 3798 if (graphicsLayer->hasContentsLayer()) { |
| 3799 graphicsLayer->setContentsRect(IntRect(0, 0, scrollbarRect.width(), scro
llbarRect.height())); |
| 3800 return; |
| 3801 } |
| 3802 |
| 3803 graphicsLayer->setDrawsContent(true); |
| 3804 graphicsLayer->setNeedsDisplay(); |
| 3805 } |
| 3806 |
| 3807 static void positionScrollCornerLayer(GraphicsLayer* graphicsLayer, const IntRec
t& cornerRect) |
| 3808 { |
| 3809 if (!graphicsLayer) |
| 3810 return; |
| 3811 graphicsLayer->setDrawsContent(!cornerRect.isEmpty()); |
| 3812 graphicsLayer->setPosition(cornerRect.location()); |
| 3813 if (cornerRect.size() != graphicsLayer->size()) |
| 3814 graphicsLayer->setNeedsDisplay(); |
| 3815 graphicsLayer->setSize(cornerRect.size()); |
| 3816 } |
| 3817 |
| 3818 void FrameView::positionScrollbarLayers() |
| 3819 { |
| 3820 positionScrollbarLayer(layerForHorizontalScrollbar(), horizontalScrollbar())
; |
| 3821 positionScrollbarLayer(layerForVerticalScrollbar(), verticalScrollbar()); |
| 3822 positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect()); |
| 3823 } |
| 3824 |
| 3825 bool FrameView::userInputScrollable(ScrollbarOrientation orientation) const |
| 3826 { |
| 3827 ScrollbarMode mode = (orientation == HorizontalScrollbar) ? |
| 3828 m_horizontalScrollbarMode : m_verticalScrollbarMode; |
| 3829 |
| 3830 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; |
| 3831 } |
| 3832 |
| 3833 bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const |
| 3834 { |
| 3835 return false; |
| 3836 } |
| 3837 |
| 3838 void FrameView::contentRectangleForPaintInvalidationInternal(const IntRect& rect
) |
| 3839 { |
| 3840 IntRect paintRect = rect; |
| 3841 if (clipsPaintInvalidations()) |
| 3842 paintRect.intersect(visibleContentRect()); |
| 3843 if (paintRect.isEmpty()) |
| 3844 return; |
| 3845 |
| 3846 if (HostWindow* window = hostWindow()) |
| 3847 window->invalidateContentsAndRootView(contentsToWindow(paintRect)); |
| 3848 } |
| 3849 |
| 3850 IntRect FrameView::scrollCornerRect() const |
| 3851 { |
| 3852 IntRect cornerRect; |
| 3853 |
| 3854 if (hasOverlayScrollbars()) |
| 3855 return cornerRect; |
| 3856 |
| 3857 if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) { |
| 3858 cornerRect.unite(IntRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : m_ho
rizontalScrollbar->width(), |
| 3859 height() - m_horizontalScrollbar->height(), |
| 3860 width() - m_horizontalScrollbar->width(), |
| 3861 m_horizontalScrollbar->height())); |
| 3862 } |
| 3863 |
| 3864 if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) { |
| 3865 cornerRect.unite(IntRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (wid
th() - m_verticalScrollbar->width()), |
| 3866 m_verticalScrollbar->height(), |
| 3867 m_verticalScrollbar->width(), |
| 3868 height() - m_verticalScrollbar->height())); |
| 3869 } |
| 3870 |
| 3871 return cornerRect; |
| 3872 } |
| 3873 |
| 3874 bool FrameView::isScrollCornerVisible() const |
| 3875 { |
| 3876 return !scrollCornerRect().isEmpty(); |
| 3877 } |
| 3878 |
| 3879 void FrameView::scrollbarStyleChangedInternal() |
| 3880 { |
| 3881 adjustScrollbarOpacity(); |
| 3882 contentsResized(); |
| 3883 updateScrollbars(scrollOffsetDouble()); |
| 3884 positionScrollbarLayers(); |
| 3885 } |
| 3886 |
| 3887 void FrameView::updateScrollCornerInternal() |
| 3888 { |
| 3889 } |
| 3890 |
| 3891 void FrameView::paintScrollCornerInternal(GraphicsContext* context, const IntRec
t& cornerRect) |
| 3892 { |
| 3893 ScrollbarTheme::theme()->paintScrollCorner(context, cornerRect); |
| 3894 } |
| 3895 |
| 3896 void FrameView::paintScrollbarInternal(GraphicsContext* context, Scrollbar* bar,
const IntRect& rect) |
| 3897 { |
| 3898 bar->paint(context, rect); |
| 3899 } |
| 3900 |
| 3901 void FrameView::invalidateScrollCornerRect(const IntRect& rect) |
| 3902 { |
| 3903 invalidateRect(rect); |
| 3904 } |
| 3905 |
| 3906 void FrameView::paintScrollbars(GraphicsContext* context, const IntRect& rect) |
| 3907 { |
| 3908 if (m_horizontalScrollbar && !layerForHorizontalScrollbar()) |
| 3909 paintScrollbar(context, m_horizontalScrollbar.get(), rect); |
| 3910 if (m_verticalScrollbar && !layerForVerticalScrollbar()) |
| 3911 paintScrollbar(context, m_verticalScrollbar.get(), rect); |
| 3912 |
| 3913 if (layerForScrollCorner()) |
| 3914 return; |
| 3915 paintScrollCorner(context, scrollCornerRect()); |
| 3916 } |
| 3917 |
| 3918 void FrameView::paintPanScrollIcon(GraphicsContext* context) |
| 3919 { |
| 3920 DEFINE_STATIC_REF(Image, panScrollIcon, (Image::loadPlatformResource("panIco
n"))); |
| 3921 IntPoint iconGCPoint = m_panScrollIconPoint; |
| 3922 if (parent()) |
| 3923 iconGCPoint = toFrameView(parent())->windowToContents(iconGCPoint); |
| 3924 context->drawImage(panScrollIcon, iconGCPoint); |
| 3925 } |
| 3926 |
| 3927 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
| 3928 { |
| 3929 notifyPageThatContentAreaWillPaint(); |
| 3930 |
| 3931 IntRect documentDirtyRect = rect; |
| 3932 IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect().size()
); |
| 3933 documentDirtyRect.intersect(visibleAreaWithoutScrollbars); |
| 3934 |
| 3935 if (!documentDirtyRect.isEmpty()) { |
| 3936 GraphicsContextStateSaver stateSaver(*context); |
| 3937 |
| 3938 context->translate(x() - scrollX(), y() - scrollY()); |
| 3939 context->clip(visibleContentRect()); |
| 3940 |
| 3941 documentDirtyRect.moveBy(-location() + scrollPosition()); |
| 3942 paintContents(context, documentDirtyRect); |
| 3943 } |
| 3944 |
| 3945 calculateAndPaintOverhangAreas(context, rect); |
| 3946 |
| 3947 // Now paint the scrollbars. |
| 3948 if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar
)) { |
| 3949 GraphicsContextStateSaver stateSaver(*context); |
| 3950 IntRect scrollViewDirtyRect = rect; |
| 3951 IntRect visibleAreaWithScrollbars(location(), visibleContentRect(Include
Scrollbars).size()); |
| 3952 scrollViewDirtyRect.intersect(visibleAreaWithScrollbars); |
| 3953 context->translate(x(), y()); |
| 3954 scrollViewDirtyRect.moveBy(-location()); |
| 3955 context->clip(IntRect(IntPoint(), visibleAreaWithScrollbars.size())); |
| 3956 |
| 3957 paintScrollbars(context, scrollViewDirtyRect); |
| 3958 } |
| 3959 |
| 3960 // Paint the panScroll Icon |
| 3961 if (m_drawPanScrollIcon) |
| 3962 paintPanScrollIcon(context); |
| 3963 } |
| 3964 |
| 3965 void FrameView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRec
t, IntRect& verticalOverhangRect) |
| 3966 { |
| 3967 int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) |
| 3968 ? verticalScrollbar()->width() : 0; |
| 3969 int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) |
| 3970 ? horizontalScrollbar()->height() : 0; |
| 3971 |
| 3972 int physicalScrollY = scrollPosition().y() + scrollOrigin().y(); |
| 3973 if (physicalScrollY < 0) { |
| 3974 horizontalOverhangRect = frameRect(); |
| 3975 horizontalOverhangRect.setHeight(-physicalScrollY); |
| 3976 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - vertica
lScrollbarWidth); |
| 3977 } else if (contentsHeight() && physicalScrollY > contentsHeight() - visibleH
eight()) { |
| 3978 int height = physicalScrollY - (contentsHeight() - visibleHeight()); |
| 3979 horizontalOverhangRect = frameRect(); |
| 3980 horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScro
llbarHeight); |
| 3981 horizontalOverhangRect.setHeight(height); |
| 3982 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - vertica
lScrollbarWidth); |
| 3983 } |
| 3984 |
| 3985 int physicalScrollX = scrollPosition().x() + scrollOrigin().x(); |
| 3986 if (physicalScrollX < 0) { |
| 3987 verticalOverhangRect.setWidth(-physicalScrollX); |
| 3988 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhang
Rect.height() - horizontalScrollbarHeight); |
| 3989 verticalOverhangRect.setX(frameRect().x()); |
| 3990 if (horizontalOverhangRect.y() == frameRect().y()) |
| 3991 verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.h
eight()); |
| 3992 else |
| 3993 verticalOverhangRect.setY(frameRect().y()); |
| 3994 } else if (contentsWidth() && physicalScrollX > contentsWidth() - visibleWid
th()) { |
| 3995 int width = physicalScrollX - (contentsWidth() - visibleWidth()); |
| 3996 verticalOverhangRect.setWidth(width); |
| 3997 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhang
Rect.height() - horizontalScrollbarHeight); |
| 3998 verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbar
Width); |
| 3999 if (horizontalOverhangRect.y() == frameRect().y()) |
| 4000 verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.h
eight()); |
| 4001 else |
| 4002 verticalOverhangRect.setY(frameRect().y()); |
| 4003 } |
| 4004 } |
| 4005 |
| 4006 void FrameView::updateOverhangAreas() |
| 4007 { |
| 4008 HostWindow* window = hostWindow(); |
| 4009 if (!window) |
| 4010 return; |
| 4011 |
| 4012 IntRect horizontalOverhangRect; |
| 4013 IntRect verticalOverhangRect; |
| 4014 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); |
| 4015 if (!horizontalOverhangRect.isEmpty()) |
| 4016 window->invalidateContentsAndRootView(horizontalOverhangRect); |
| 4017 if (!verticalOverhangRect.isEmpty()) |
| 4018 window->invalidateContentsAndRootView(verticalOverhangRect); |
| 4019 } |
| 4020 |
| 4021 void FrameView::paintOverhangAreasInternal(GraphicsContext* context, const IntRe
ct& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect&
dirtyRect) |
| 4022 { |
| 4023 ScrollbarTheme::theme()->paintOverhangBackground(context, horizontalOverhang
Rect, verticalOverhangRect, dirtyRect); |
| 4024 ScrollbarTheme::theme()->paintOverhangShadows(context, scrollOffset(), horiz
ontalOverhangRect, verticalOverhangRect, dirtyRect); |
| 4025 } |
| 4026 |
| 4027 void FrameView::calculateAndPaintOverhangAreas(GraphicsContext* context, const I
ntRect& dirtyRect) |
| 4028 { |
| 4029 IntRect horizontalOverhangRect; |
| 4030 IntRect verticalOverhangRect; |
| 4031 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); |
| 4032 |
| 4033 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) |
| 4034 paintOverhangAreas(context, horizontalOverhangRect, verticalOverhangRect
, dirtyRect); |
| 4035 } |
| 4036 |
| 4037 void FrameView::calculateAndPaintOverhangBackground(GraphicsContext* context, co
nst IntRect& dirtyRect) |
| 4038 { |
| 4039 IntRect horizontalOverhangRect; |
| 4040 IntRect verticalOverhangRect; |
| 4041 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); |
| 4042 |
| 4043 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) |
| 4044 ScrollbarTheme::theme()->paintOverhangBackground(context, horizontalOver
hangRect, verticalOverhangRect, dirtyRect); |
| 4045 } |
| 4046 |
| 4047 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
| 4048 { |
| 4049 if (!scrollbarCornerPresent()) |
| 4050 return false; |
| 4051 |
| 4052 IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 4053 |
| 4054 if (m_horizontalScrollbar) { |
| 4055 int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y(); |
| 4056 int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m
_horizontalScrollbar->frameRect().height(); |
| 4057 int horizontalScrollbarXMin = m_horizontalScrollbar->frameRect().x() + m
_horizontalScrollbar->frameRect().width(); |
| 4058 |
| 4059 return viewPoint.y() > horizontalScrollbarYMin && viewPoint.y() < horizo
ntalScrollbarYMax && viewPoint.x() > horizontalScrollbarXMin; |
| 4060 } |
| 4061 |
| 4062 int verticalScrollbarXMin = m_verticalScrollbar->frameRect().x(); |
| 4063 int verticalScrollbarXMax = m_verticalScrollbar->frameRect().x() + m_vertica
lScrollbar->frameRect().width(); |
| 4064 int verticalScrollbarYMin = m_verticalScrollbar->frameRect().y() + m_vertica
lScrollbar->frameRect().height(); |
| 4065 |
| 4066 return viewPoint.x() > verticalScrollbarXMin && viewPoint.x() < verticalScro
llbarXMax && viewPoint.y() > verticalScrollbarYMin; |
| 4067 } |
| 4068 |
| 4069 bool FrameView::scrollbarCornerPresent() const |
| 4070 { |
| 4071 return (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() >
0) |
| 4072 || (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0)
; |
| 4073 } |
| 4074 |
| 4075 IntRect FrameView::convertFromScrollbarToContainingView(const Scrollbar* scrollb
ar, const IntRect& localRect) const |
| 4076 { |
| 4077 // Scrollbars won't be transformed within us |
| 4078 IntRect newRect = localRect; |
| 4079 newRect.moveBy(scrollbar->location()); |
| 4080 return newRect; |
| 4081 } |
| 4082 |
| 4083 IntRect FrameView::convertFromContainingViewToScrollbar(const Scrollbar* scrollb
ar, const IntRect& parentRect) const |
| 4084 { |
| 4085 IntRect newRect = parentRect; |
| 4086 // Scrollbars won't be transformed within us |
| 4087 newRect.moveBy(-scrollbar->location()); |
| 4088 return newRect; |
| 4089 } |
| 4090 |
| 4091 // FIXME: test these on windows |
| 4092 IntPoint FrameView::convertFromScrollbarToContainingView(const Scrollbar* scroll
bar, const IntPoint& localPoint) const |
| 4093 { |
| 4094 // Scrollbars won't be transformed within us |
| 4095 IntPoint newPoint = localPoint; |
| 4096 newPoint.moveBy(scrollbar->location()); |
| 4097 return newPoint; |
| 4098 } |
| 4099 |
| 4100 IntPoint FrameView::convertFromContainingViewToScrollbar(const Scrollbar* scroll
bar, const IntPoint& parentPoint) const |
| 4101 { |
| 4102 IntPoint newPoint = parentPoint; |
| 4103 // Scrollbars won't be transformed within us |
| 4104 newPoint.moveBy(-scrollbar->location()); |
| 4105 return newPoint; |
| 4106 } |
| 4107 |
| 4108 void FrameView::setParentVisible(bool visible) |
| 4109 { |
| 4110 if (isParentVisible() == visible) |
| 4111 return; |
| 4112 |
| 4113 Widget::setParentVisible(visible); |
| 4114 |
| 4115 if (!isSelfVisible()) |
| 4116 return; |
| 4117 |
| 4118 HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
| 4119 for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end;
++it) |
| 4120 (*it)->setParentVisible(visible); |
| 4121 } |
| 4122 |
| 4123 void FrameView::show() |
| 4124 { |
| 4125 if (!isSelfVisible()) { |
| 4126 setSelfVisible(true); |
| 4127 if (isParentVisible()) { |
| 4128 HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
| 4129 for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it
!= end; ++it) |
| 4130 (*it)->setParentVisible(true); |
| 4131 } |
| 4132 } |
| 4133 |
| 4134 Widget::show(); |
| 4135 } |
| 4136 |
| 4137 void FrameView::hide() |
| 4138 { |
| 4139 if (isSelfVisible()) { |
| 4140 if (isParentVisible()) { |
| 4141 HashSet<RefPtr<Widget> >::iterator end = m_children.end(); |
| 4142 for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it
!= end; ++it) |
| 4143 (*it)->setParentVisible(false); |
| 4144 } |
| 4145 setSelfVisible(false); |
| 4146 } |
| 4147 |
| 4148 Widget::hide(); |
| 4149 } |
| 4150 |
| 4151 void FrameView::addPanScrollIcon(const IntPoint& iconPosition) |
| 4152 { |
| 4153 HostWindow* window = hostWindow(); |
| 4154 if (!window) |
| 4155 return; |
| 4156 m_drawPanScrollIcon = true; |
| 4157 m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , i
conPosition.y() - panIconSizeLength / 2); |
| 4158 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); |
| 4159 } |
| 4160 |
| 4161 void FrameView::removePanScrollIcon() |
| 4162 { |
| 4163 HostWindow* window = hostWindow(); |
| 4164 if (!window) |
| 4165 return; |
| 4166 m_drawPanScrollIcon = false; |
| 4167 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); |
| 4168 } |
| 4169 |
| 4170 void FrameView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll
, bool updatePositionSynchronously) |
| 4171 { |
| 4172 if (scrollOrigin() == origin) |
| 4173 return; |
| 4174 |
| 4175 ScrollableArea::setScrollOrigin(origin); |
| 4176 |
| 4177 // Update if the scroll origin changes, since our position will be different
if the content size did not change. |
| 4178 if (updatePositionAtAll && updatePositionSynchronously) |
| 4179 updateScrollbars(scrollOffsetDouble()); |
| 4180 } |
| 4181 |
3045 } // namespace blink | 4182 } // namespace blink |
OLD | NEW |