| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/inspector/InspectorTraceEvents.h" | 49 #include "core/inspector/InspectorTraceEvents.h" |
| 50 #include "core/loader/FrameLoader.h" | 50 #include "core/loader/FrameLoader.h" |
| 51 #include "core/loader/FrameLoaderClient.h" | 51 #include "core/loader/FrameLoaderClient.h" |
| 52 #include "core/page/Chrome.h" | 52 #include "core/page/Chrome.h" |
| 53 #include "core/page/ChromeClient.h" | 53 #include "core/page/ChromeClient.h" |
| 54 #include "core/page/EventHandler.h" | 54 #include "core/page/EventHandler.h" |
| 55 #include "core/page/FocusController.h" | 55 #include "core/page/FocusController.h" |
| 56 #include "core/page/FrameTree.h" | 56 #include "core/page/FrameTree.h" |
| 57 #include "core/page/Page.h" | 57 #include "core/page/Page.h" |
| 58 #include "core/page/scrolling/ScrollingCoordinator.h" | 58 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 59 #include "core/paint/LayerPainter.h" | 59 #include "core/paint/FramePainter.h" |
| 60 #include "core/paint/ScrollbarPainter.h" | |
| 61 #include "core/rendering/RenderCounter.h" | 60 #include "core/rendering/RenderCounter.h" |
| 62 #include "core/rendering/RenderEmbeddedObject.h" | 61 #include "core/rendering/RenderEmbeddedObject.h" |
| 63 #include "core/rendering/RenderLayer.h" | 62 #include "core/rendering/RenderLayer.h" |
| 64 #include "core/rendering/RenderListBox.h" | 63 #include "core/rendering/RenderListBox.h" |
| 65 #include "core/rendering/RenderPart.h" | 64 #include "core/rendering/RenderPart.h" |
| 66 #include "core/rendering/RenderScrollbar.h" | 65 #include "core/rendering/RenderScrollbar.h" |
| 67 #include "core/rendering/RenderScrollbarPart.h" | 66 #include "core/rendering/RenderScrollbarPart.h" |
| 68 #include "core/rendering/RenderTheme.h" | 67 #include "core/rendering/RenderTheme.h" |
| 69 #include "core/rendering/RenderView.h" | 68 #include "core/rendering/RenderView.h" |
| 70 #include "core/rendering/TextAutosizer.h" | 69 #include "core/rendering/TextAutosizer.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 90 #include "platform/text/TextStream.h" | 89 #include "platform/text/TextStream.h" |
| 91 #include "wtf/CurrentTime.h" | 90 #include "wtf/CurrentTime.h" |
| 92 #include "wtf/StdLibExtras.h" | 91 #include "wtf/StdLibExtras.h" |
| 93 #include "wtf/TemporaryChange.h" | 92 #include "wtf/TemporaryChange.h" |
| 94 | 93 |
| 95 namespace blink { | 94 namespace blink { |
| 96 | 95 |
| 97 using namespace HTMLNames; | 96 using namespace HTMLNames; |
| 98 | 97 |
| 99 double FrameView::s_currentFrameTimeStamp = 0.0; | 98 double FrameView::s_currentFrameTimeStamp = 0.0; |
| 100 bool FrameView::s_inPaintContents = false; | |
| 101 | 99 |
| 102 // The maximum number of updateWidgets iterations that should be done before ret
urning. | 100 // The maximum number of updateWidgets iterations that should be done before ret
urning. |
| 103 static const unsigned maxUpdateWidgetsIterations = 2; | 101 static const unsigned maxUpdateWidgetsIterations = 2; |
| 104 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; | 102 static const double resourcePriorityUpdateDelayAfterScroll = 0.250; |
| 105 | 103 |
| 106 FrameView::FrameView(LocalFrame* frame) | 104 FrameView::FrameView(LocalFrame* frame) |
| 107 : m_frame(frame) | 105 : m_frame(frame) |
| 108 , m_canHaveScrollbars(true) | 106 , m_canHaveScrollbars(true) |
| 109 , m_slowRepaintObjectCount(0) | 107 , m_slowRepaintObjectCount(0) |
| 110 , m_hasPendingLayout(false) | 108 , m_hasPendingLayout(false) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 131 #if ENABLE(OILPAN) && ENABLE(ASSERT) | 129 #if ENABLE(OILPAN) && ENABLE(ASSERT) |
| 132 , m_hasBeenDisposed(false) | 130 , m_hasBeenDisposed(false) |
| 133 #endif | 131 #endif |
| 134 , m_horizontalScrollbarMode(ScrollbarAuto) | 132 , m_horizontalScrollbarMode(ScrollbarAuto) |
| 135 , m_verticalScrollbarMode(ScrollbarAuto) | 133 , m_verticalScrollbarMode(ScrollbarAuto) |
| 136 , m_horizontalScrollbarLock(false) | 134 , m_horizontalScrollbarLock(false) |
| 137 , m_verticalScrollbarLock(false) | 135 , m_verticalScrollbarLock(false) |
| 138 , m_scrollbarsAvoidingResizer(0) | 136 , m_scrollbarsAvoidingResizer(0) |
| 139 , m_scrollbarsSuppressed(false) | 137 , m_scrollbarsSuppressed(false) |
| 140 , m_inUpdateScrollbars(false) | 138 , m_inUpdateScrollbars(false) |
| 141 , m_drawPanScrollIcon(false) | 139 , m_shouldDrawPanScrollIcon(false) |
| 142 , m_clipsRepaints(true) | 140 , m_clipsRepaints(true) |
| 143 { | 141 { |
| 144 ASSERT(m_frame); | 142 ASSERT(m_frame); |
| 145 init(); | 143 init(); |
| 146 | 144 |
| 147 if (!m_frame->isMainFrame()) | 145 if (!m_frame->isMainFrame()) |
| 148 return; | 146 return; |
| 149 | 147 |
| 150 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); | 148 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); |
| 151 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); | 149 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); |
| (...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 m_scrollCorner->setStyle(cornerStyle.release()); | 2355 m_scrollCorner->setStyle(cornerStyle.release()); |
| 2358 invalidateScrollCorner(cornerRect); | 2356 invalidateScrollCorner(cornerRect); |
| 2359 } else if (m_scrollCorner) { | 2357 } else if (m_scrollCorner) { |
| 2360 m_scrollCorner->destroy(); | 2358 m_scrollCorner->destroy(); |
| 2361 m_scrollCorner = nullptr; | 2359 m_scrollCorner = nullptr; |
| 2362 } | 2360 } |
| 2363 | 2361 |
| 2364 updateScrollCornerInternal(); | 2362 updateScrollCornerInternal(); |
| 2365 } | 2363 } |
| 2366 | 2364 |
| 2367 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& corne
rRect) | |
| 2368 { | |
| 2369 if (m_scrollCorner) { | |
| 2370 bool needsBackgorund = m_frame->isMainFrame(); | |
| 2371 if (needsBackgorund) | |
| 2372 context->fillRect(cornerRect, baseBackgroundColor()); | |
| 2373 ScrollbarPainter::paintIntoRect(m_scrollCorner, context, cornerRect.loca
tion(), cornerRect); | |
| 2374 return; | |
| 2375 } | |
| 2376 | |
| 2377 paintScrollCornerInternal(context, cornerRect); | |
| 2378 } | |
| 2379 | |
| 2380 void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const I
ntRect& rect) | |
| 2381 { | |
| 2382 bool needsBackgorund = bar->isCustomScrollbar() && m_frame->isMainFrame(); | |
| 2383 if (needsBackgorund) { | |
| 2384 IntRect toFill = bar->frameRect(); | |
| 2385 toFill.intersect(rect); | |
| 2386 context->fillRect(toFill, baseBackgroundColor()); | |
| 2387 } | |
| 2388 | |
| 2389 paintScrollbarInternal(context, bar, rect); | |
| 2390 } | |
| 2391 | |
| 2392 Color FrameView::documentBackgroundColor() const | 2365 Color FrameView::documentBackgroundColor() const |
| 2393 { | 2366 { |
| 2394 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of | 2367 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of |
| 2395 // the document and the body against the base background color of the frame
view. | 2368 // the document and the body against the base background color of the frame
view. |
| 2396 // Background images are unfortunately impractical to include. | 2369 // Background images are unfortunately impractical to include. |
| 2397 | 2370 |
| 2398 Color result = baseBackgroundColor(); | 2371 Color result = baseBackgroundColor(); |
| 2399 if (!frame().document()) | 2372 if (!frame().document()) |
| 2400 return result; | 2373 return result; |
| 2401 | 2374 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 } | 2427 } |
| 2455 | 2428 |
| 2456 void FrameView::setWasScrolledByUser(bool wasScrolledByUser) | 2429 void FrameView::setWasScrolledByUser(bool wasScrolledByUser) |
| 2457 { | 2430 { |
| 2458 if (m_inProgrammaticScroll) | 2431 if (m_inProgrammaticScroll) |
| 2459 return; | 2432 return; |
| 2460 m_maintainScrollPositionAnchor = nullptr; | 2433 m_maintainScrollPositionAnchor = nullptr; |
| 2461 m_wasScrolledByUser = wasScrolledByUser; | 2434 m_wasScrolledByUser = wasScrolledByUser; |
| 2462 } | 2435 } |
| 2463 | 2436 |
| 2464 void FrameView::paintContents(GraphicsContext* p, const IntRect& rect) | |
| 2465 { | |
| 2466 Document* document = m_frame->document(); | |
| 2467 | |
| 2468 #ifndef NDEBUG | |
| 2469 bool fillWithRed; | |
| 2470 if (document->printing()) | |
| 2471 fillWithRed = false; // Printing, don't fill with red (can't remember wh
y). | |
| 2472 else if (m_frame->owner()) | |
| 2473 fillWithRed = false; // Subframe, don't fill with red. | |
| 2474 else if (isTransparent()) | |
| 2475 fillWithRed = false; // Transparent, don't fill with red. | |
| 2476 else if (m_paintBehavior & PaintBehaviorSelectionOnly) | |
| 2477 fillWithRed = false; // Selections are transparent, don't fill with red. | |
| 2478 else if (m_nodeToDraw) | |
| 2479 fillWithRed = false; // Element images are transparent, don't fill with
red. | |
| 2480 else | |
| 2481 fillWithRed = true; | |
| 2482 | |
| 2483 if (fillWithRed) | |
| 2484 p->fillRect(rect, Color(0xFF, 0, 0)); | |
| 2485 #endif | |
| 2486 | |
| 2487 RenderView* renderView = this->renderView(); | |
| 2488 if (!renderView) { | |
| 2489 WTF_LOG_ERROR("called FrameView::paint with nil renderer"); | |
| 2490 return; | |
| 2491 } | |
| 2492 | |
| 2493 RELEASE_ASSERT(!needsLayout()); | |
| 2494 ASSERT(document->lifecycle().state() >= DocumentLifecycle::CompositingClean)
; | |
| 2495 | |
| 2496 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data"
, InspectorPaintEvent::data(renderView, rect, 0)); | |
| 2497 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | |
| 2498 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | |
| 2499 InspectorInstrumentation::willPaint(renderView, 0); | |
| 2500 | |
| 2501 bool isTopLevelPainter = !s_inPaintContents; | |
| 2502 s_inPaintContents = true; | |
| 2503 | |
| 2504 FontCachePurgePreventer fontCachePurgePreventer; | |
| 2505 | |
| 2506 PaintBehavior oldPaintBehavior = m_paintBehavior; | |
| 2507 | |
| 2508 if (FrameView* parentView = parentFrameView()) { | |
| 2509 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) | |
| 2510 m_paintBehavior |= PaintBehaviorFlattenCompositingLayers; | |
| 2511 } | |
| 2512 | |
| 2513 if (m_paintBehavior == PaintBehaviorNormal) | |
| 2514 document->markers().invalidateRenderedRectsForMarkersInRect(rect); | |
| 2515 | |
| 2516 if (document->printing()) | |
| 2517 m_paintBehavior |= PaintBehaviorFlattenCompositingLayers; | |
| 2518 | |
| 2519 ASSERT(!m_isPainting); | |
| 2520 m_isPainting = true; | |
| 2521 | |
| 2522 // m_nodeToDraw is used to draw only one element (and its descendants) | |
| 2523 RenderObject* renderer = m_nodeToDraw ? m_nodeToDraw->renderer() : 0; | |
| 2524 RenderLayer* rootLayer = renderView->layer(); | |
| 2525 | |
| 2526 #if ENABLE(ASSERT) | |
| 2527 renderView->assertSubtreeIsLaidOut(); | |
| 2528 RenderObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(*rootLayer-
>renderer()); | |
| 2529 #endif | |
| 2530 | |
| 2531 LayerPainter layerPainter(*rootLayer); | |
| 2532 | |
| 2533 layerPainter.paint(p, rect, m_paintBehavior, renderer); | |
| 2534 | |
| 2535 if (rootLayer->containsDirtyOverlayScrollbars()) | |
| 2536 layerPainter.paintOverlayScrollbars(p, rect, m_paintBehavior, renderer); | |
| 2537 | |
| 2538 m_isPainting = false; | |
| 2539 | |
| 2540 m_paintBehavior = oldPaintBehavior; | |
| 2541 m_lastPaintTime = currentTime(); | |
| 2542 | |
| 2543 // Regions may have changed as a result of the visibility/z-index of element
changing. | |
| 2544 if (document->annotatedRegionsDirty()) | |
| 2545 updateAnnotatedRegions(); | |
| 2546 | |
| 2547 if (isTopLevelPainter) { | |
| 2548 // Everything that happens after paintContents completions is considered | |
| 2549 // to be part of the next frame. | |
| 2550 s_currentFrameTimeStamp = currentTime(); | |
| 2551 s_inPaintContents = false; | |
| 2552 } | |
| 2553 | |
| 2554 InspectorInstrumentation::didPaint(renderView, 0, p, rect); | |
| 2555 } | |
| 2556 | |
| 2557 void FrameView::setPaintBehavior(PaintBehavior behavior) | 2437 void FrameView::setPaintBehavior(PaintBehavior behavior) |
| 2558 { | 2438 { |
| 2559 m_paintBehavior = behavior; | 2439 m_paintBehavior = behavior; |
| 2560 } | 2440 } |
| 2561 | 2441 |
| 2562 PaintBehavior FrameView::paintBehavior() const | 2442 PaintBehavior FrameView::paintBehavior() const |
| 2563 { | 2443 { |
| 2564 return m_paintBehavior; | 2444 return m_paintBehavior; |
| 2565 } | 2445 } |
| 2566 | 2446 |
| 2567 bool FrameView::isPainting() const | 2447 bool FrameView::isPainting() const |
| 2568 { | 2448 { |
| 2569 return m_isPainting; | 2449 return m_isPainting; |
| 2570 } | 2450 } |
| 2571 | 2451 |
| 2572 void FrameView::setNodeToDraw(Node* node) | 2452 void FrameView::setNodeToDraw(Node* node) |
| 2573 { | 2453 { |
| 2574 m_nodeToDraw = node; | 2454 m_nodeToDraw = node; |
| 2575 } | 2455 } |
| 2576 | 2456 |
| 2577 void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& hori
zontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRec
t) | |
| 2578 { | |
| 2579 if (m_frame->document()->printing()) | |
| 2580 return; | |
| 2581 | |
| 2582 if (m_frame->isMainFrame()) { | |
| 2583 if (m_frame->page()->chrome().client().paintCustomOverhangArea(context,
horizontalOverhangArea, verticalOverhangArea, dirtyRect)) | |
| 2584 return; | |
| 2585 } | |
| 2586 | |
| 2587 paintOverhangAreasInternal(context, horizontalOverhangArea, verticalOverhang
Area, dirtyRect); | |
| 2588 } | |
| 2589 | |
| 2590 void FrameView::updateWidgetPositionsIfNeeded() | 2457 void FrameView::updateWidgetPositionsIfNeeded() |
| 2591 { | 2458 { |
| 2592 if (!m_needsUpdateWidgetPositions) | 2459 if (!m_needsUpdateWidgetPositions) |
| 2593 return; | 2460 return; |
| 2594 | 2461 |
| 2595 m_needsUpdateWidgetPositions = false; | 2462 m_needsUpdateWidgetPositions = false; |
| 2596 | 2463 |
| 2597 updateWidgetPositions(); | 2464 updateWidgetPositions(); |
| 2598 } | 2465 } |
| 2599 | 2466 |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3633 void FrameView::scrollContents(const IntSize& scrollDelta) | 3500 void FrameView::scrollContents(const IntSize& scrollDelta) |
| 3634 { | 3501 { |
| 3635 HostWindow* window = hostWindow(); | 3502 HostWindow* window = hostWindow(); |
| 3636 if (!window) | 3503 if (!window) |
| 3637 return; | 3504 return; |
| 3638 | 3505 |
| 3639 IntRect clipRect = windowClipRect(); | 3506 IntRect clipRect = windowClipRect(); |
| 3640 IntRect updateRect = clipRect; | 3507 IntRect updateRect = clipRect; |
| 3641 updateRect.intersect(rectToCopyOnScroll()); | 3508 updateRect.intersect(rectToCopyOnScroll()); |
| 3642 | 3509 |
| 3643 if (m_drawPanScrollIcon) { | 3510 if (m_shouldDrawPanScrollIcon) { |
| 3644 // FIXME: the pan icon is broken when accelerated compositing is on, sin
ce it will draw under the compositing layers. | 3511 // FIXME: the pan icon is broken when accelerated compositing is on, sin
ce it will draw under the compositing layers. |
| 3645 // https://bugs.webkit.org/show_bug.cgi?id=47837 | 3512 // https://bugs.webkit.org/show_bug.cgi?id=47837 |
| 3646 int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + std::max(abs
(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint w
hat's necessary | 3513 int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + std::max(abs
(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint w
hat's necessary |
| 3647 IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x()
- (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySq
uareSizeLength / 2)); | 3514 IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x()
- (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySq
uareSizeLength / 2)); |
| 3648 IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation, Int
Size(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength)); | 3515 IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation, Int
Size(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength)); |
| 3649 panScrollIconDirtyRect.intersect(clipRect); | 3516 panScrollIconDirtyRect.intersect(clipRect); |
| 3650 window->invalidateContentsAndRootView(panScrollIconDirtyRect); | 3517 window->invalidateContentsAndRootView(panScrollIconDirtyRect); |
| 3651 } | 3518 } |
| 3652 | 3519 |
| 3653 if (!scrollContentsFastPath(-scrollDelta)) | 3520 if (!scrollContentsFastPath(-scrollDelta)) |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 adjustScrollbarOpacity(); | 3791 adjustScrollbarOpacity(); |
| 3925 contentsResized(); | 3792 contentsResized(); |
| 3926 updateScrollbars(scrollOffsetDouble()); | 3793 updateScrollbars(scrollOffsetDouble()); |
| 3927 positionScrollbarLayers(); | 3794 positionScrollbarLayers(); |
| 3928 } | 3795 } |
| 3929 | 3796 |
| 3930 void FrameView::updateScrollCornerInternal() | 3797 void FrameView::updateScrollCornerInternal() |
| 3931 { | 3798 { |
| 3932 } | 3799 } |
| 3933 | 3800 |
| 3934 void FrameView::paintScrollCornerInternal(GraphicsContext* context, const IntRec
t& cornerRect) | |
| 3935 { | |
| 3936 ScrollbarTheme::theme()->paintScrollCorner(context, cornerRect); | |
| 3937 } | |
| 3938 | |
| 3939 void FrameView::paintScrollbarInternal(GraphicsContext* context, Scrollbar* bar,
const IntRect& rect) | |
| 3940 { | |
| 3941 bar->paint(context, rect); | |
| 3942 } | |
| 3943 | |
| 3944 void FrameView::invalidateScrollCornerRect(const IntRect& rect) | 3801 void FrameView::invalidateScrollCornerRect(const IntRect& rect) |
| 3945 { | 3802 { |
| 3946 invalidateRect(rect); | 3803 invalidateRect(rect); |
| 3947 } | 3804 } |
| 3948 | 3805 |
| 3949 void FrameView::paintScrollbars(GraphicsContext* context, const IntRect& rect) | |
| 3950 { | |
| 3951 if (m_horizontalScrollbar && !layerForHorizontalScrollbar()) | |
| 3952 paintScrollbar(context, m_horizontalScrollbar.get(), rect); | |
| 3953 if (m_verticalScrollbar && !layerForVerticalScrollbar()) | |
| 3954 paintScrollbar(context, m_verticalScrollbar.get(), rect); | |
| 3955 | |
| 3956 if (layerForScrollCorner()) | |
| 3957 return; | |
| 3958 paintScrollCorner(context, scrollCornerRect()); | |
| 3959 } | |
| 3960 | |
| 3961 void FrameView::paintPanScrollIcon(GraphicsContext* context) | 3806 void FrameView::paintPanScrollIcon(GraphicsContext* context) |
| 3962 { | 3807 { |
| 3963 DEFINE_STATIC_REF(Image, panScrollIcon, (Image::loadPlatformResource("panIco
n"))); | 3808 DEFINE_STATIC_REF(Image, panScrollIcon, (Image::loadPlatformResource("panIco
n"))); |
| 3964 IntPoint iconGCPoint = m_panScrollIconPoint; | 3809 IntPoint iconGCPoint = m_panScrollIconPoint; |
| 3965 if (parent()) | 3810 if (parent()) |
| 3966 iconGCPoint = toFrameView(parent())->windowToContents(iconGCPoint); | 3811 iconGCPoint = toFrameView(parent())->windowToContents(iconGCPoint); |
| 3967 context->drawImage(panScrollIcon, iconGCPoint); | 3812 context->drawImage(panScrollIcon, iconGCPoint); |
| 3968 } | 3813 } |
| 3969 | 3814 |
| 3970 void FrameView::paint(GraphicsContext* context, const IntRect& rect) | 3815 void FrameView::paint(GraphicsContext* context, const IntRect& rect) |
| 3971 { | 3816 { |
| 3972 notifyPageThatContentAreaWillPaint(); | 3817 FramePainter(*this).paint(context, rect); |
| 3818 } |
| 3973 | 3819 |
| 3974 IntRect documentDirtyRect = rect; | 3820 void FrameView::paintContents(GraphicsContext* context, const IntRect& damageRec
t) |
| 3975 IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect().size()
); | 3821 { |
| 3976 documentDirtyRect.intersect(visibleAreaWithoutScrollbars); | 3822 FramePainter(*this).paintContents(context, damageRect); |
| 3977 | |
| 3978 if (!documentDirtyRect.isEmpty()) { | |
| 3979 GraphicsContextStateSaver stateSaver(*context); | |
| 3980 | |
| 3981 context->translate(x() - scrollX(), y() - scrollY()); | |
| 3982 context->clip(visibleContentRect()); | |
| 3983 | |
| 3984 documentDirtyRect.moveBy(-location() + scrollPosition()); | |
| 3985 paintContents(context, documentDirtyRect); | |
| 3986 } | |
| 3987 | |
| 3988 calculateAndPaintOverhangAreas(context, rect); | |
| 3989 | |
| 3990 // Now paint the scrollbars. | |
| 3991 if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar
)) { | |
| 3992 GraphicsContextStateSaver stateSaver(*context); | |
| 3993 IntRect scrollViewDirtyRect = rect; | |
| 3994 IntRect visibleAreaWithScrollbars(location(), visibleContentRect(Include
Scrollbars).size()); | |
| 3995 scrollViewDirtyRect.intersect(visibleAreaWithScrollbars); | |
| 3996 context->translate(x(), y()); | |
| 3997 scrollViewDirtyRect.moveBy(-location()); | |
| 3998 context->clip(IntRect(IntPoint(), visibleAreaWithScrollbars.size())); | |
| 3999 | |
| 4000 paintScrollbars(context, scrollViewDirtyRect); | |
| 4001 } | |
| 4002 | |
| 4003 // Paint the panScroll Icon | |
| 4004 if (m_drawPanScrollIcon) | |
| 4005 paintPanScrollIcon(context); | |
| 4006 } | 3823 } |
| 4007 | 3824 |
| 4008 void FrameView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRec
t, IntRect& verticalOverhangRect) | 3825 void FrameView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRec
t, IntRect& verticalOverhangRect) |
| 4009 { | 3826 { |
| 4010 int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) | 3827 int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i
sOverlayScrollbar()) |
| 4011 ? verticalScrollbar()->width() : 0; | 3828 ? verticalScrollbar()->width() : 0; |
| 4012 int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) | 3829 int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb
ar()->isOverlayScrollbar()) |
| 4013 ? horizontalScrollbar()->height() : 0; | 3830 ? horizontalScrollbar()->height() : 0; |
| 4014 | 3831 |
| 4015 int physicalScrollY = scrollPosition().y() + scrollOrigin().y(); | 3832 int physicalScrollY = scrollPosition().y() + scrollOrigin().y(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 | 3871 |
| 4055 IntRect horizontalOverhangRect; | 3872 IntRect horizontalOverhangRect; |
| 4056 IntRect verticalOverhangRect; | 3873 IntRect verticalOverhangRect; |
| 4057 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); | 3874 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); |
| 4058 if (!horizontalOverhangRect.isEmpty()) | 3875 if (!horizontalOverhangRect.isEmpty()) |
| 4059 window->invalidateContentsAndRootView(horizontalOverhangRect); | 3876 window->invalidateContentsAndRootView(horizontalOverhangRect); |
| 4060 if (!verticalOverhangRect.isEmpty()) | 3877 if (!verticalOverhangRect.isEmpty()) |
| 4061 window->invalidateContentsAndRootView(verticalOverhangRect); | 3878 window->invalidateContentsAndRootView(verticalOverhangRect); |
| 4062 } | 3879 } |
| 4063 | 3880 |
| 4064 void FrameView::paintOverhangAreasInternal(GraphicsContext* context, const IntRe
ct& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect&
dirtyRect) | |
| 4065 { | |
| 4066 ScrollbarTheme::theme()->paintOverhangBackground(context, horizontalOverhang
Rect, verticalOverhangRect, dirtyRect); | |
| 4067 ScrollbarTheme::theme()->paintOverhangShadows(context, scrollOffset(), horiz
ontalOverhangRect, verticalOverhangRect, dirtyRect); | |
| 4068 } | |
| 4069 | |
| 4070 void FrameView::calculateAndPaintOverhangAreas(GraphicsContext* context, const I
ntRect& dirtyRect) | |
| 4071 { | |
| 4072 IntRect horizontalOverhangRect; | |
| 4073 IntRect verticalOverhangRect; | |
| 4074 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); | |
| 4075 | |
| 4076 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) | |
| 4077 paintOverhangAreas(context, horizontalOverhangRect, verticalOverhangRect
, dirtyRect); | |
| 4078 } | |
| 4079 | |
| 4080 void FrameView::calculateAndPaintOverhangBackground(GraphicsContext* context, co
nst IntRect& dirtyRect) | |
| 4081 { | |
| 4082 IntRect horizontalOverhangRect; | |
| 4083 IntRect verticalOverhangRect; | |
| 4084 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe
ct); | |
| 4085 | |
| 4086 if (dirtyRect.intersects(horizontalOverhangRect) || dirtyRect.intersects(ver
ticalOverhangRect)) | |
| 4087 ScrollbarTheme::theme()->paintOverhangBackground(context, horizontalOver
hangRect, verticalOverhangRect, dirtyRect); | |
| 4088 } | |
| 4089 | |
| 4090 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) | 3881 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) |
| 4091 { | 3882 { |
| 4092 if (!scrollbarCornerPresent()) | 3883 if (!scrollbarCornerPresent()) |
| 4093 return false; | 3884 return false; |
| 4094 | 3885 |
| 4095 IntPoint viewPoint = convertFromContainingWindow(windowPoint); | 3886 IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 4096 | 3887 |
| 4097 if (m_horizontalScrollbar) { | 3888 if (m_horizontalScrollbar) { |
| 4098 int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y(); | 3889 int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y(); |
| 4099 int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m
_horizontalScrollbar->frameRect().height(); | 3890 int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m
_horizontalScrollbar->frameRect().height(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4189 } | 3980 } |
| 4190 | 3981 |
| 4191 Widget::hide(); | 3982 Widget::hide(); |
| 4192 } | 3983 } |
| 4193 | 3984 |
| 4194 void FrameView::addPanScrollIcon(const IntPoint& iconPosition) | 3985 void FrameView::addPanScrollIcon(const IntPoint& iconPosition) |
| 4195 { | 3986 { |
| 4196 HostWindow* window = hostWindow(); | 3987 HostWindow* window = hostWindow(); |
| 4197 if (!window) | 3988 if (!window) |
| 4198 return; | 3989 return; |
| 4199 m_drawPanScrollIcon = true; | 3990 m_shouldDrawPanScrollIcon = true; |
| 4200 m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , i
conPosition.y() - panIconSizeLength / 2); | 3991 m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , i
conPosition.y() - panIconSizeLength / 2); |
| 4201 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); | 3992 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); |
| 4202 } | 3993 } |
| 4203 | 3994 |
| 4204 void FrameView::removePanScrollIcon() | 3995 void FrameView::removePanScrollIcon() |
| 4205 { | 3996 { |
| 4206 HostWindow* window = hostWindow(); | 3997 HostWindow* window = hostWindow(); |
| 4207 if (!window) | 3998 if (!window) |
| 4208 return; | 3999 return; |
| 4209 m_drawPanScrollIcon = false; | 4000 m_shouldDrawPanScrollIcon = false; |
| 4210 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); | 4001 window->invalidateContentsAndRootView(IntRect(m_panScrollIconPoint, IntSize(
panIconSizeLength, panIconSizeLength))); |
| 4211 } | 4002 } |
| 4212 | 4003 |
| 4213 void FrameView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll
, bool updatePositionSynchronously) | 4004 void FrameView::setScrollOrigin(const IntPoint& origin, bool updatePositionAtAll
, bool updatePositionSynchronously) |
| 4214 { | 4005 { |
| 4215 if (scrollOrigin() == origin) | 4006 if (scrollOrigin() == origin) |
| 4216 return; | 4007 return; |
| 4217 | 4008 |
| 4218 ScrollableArea::setScrollOrigin(origin); | 4009 ScrollableArea::setScrollOrigin(origin); |
| 4219 | 4010 |
| 4220 // Update if the scroll origin changes, since our position will be different
if the content size did not change. | 4011 // Update if the scroll origin changes, since our position will be different
if the content size did not change. |
| 4221 if (updatePositionAtAll && updatePositionSynchronously) | 4012 if (updatePositionAtAll && updatePositionSynchronously) |
| 4222 updateScrollbars(scrollOffsetDouble()); | 4013 updateScrollbars(scrollOffsetDouble()); |
| 4223 } | 4014 } |
| 4224 | 4015 |
| 4225 } // namespace blink | 4016 } // namespace blink |
| OLD | NEW |