This source file includes following definitions.
- updateLayerPositionFlags
- m_disabled
- m_didScrollTimer
- create
- create
- reset
- removeFromAXObjectCache
- resetScrollbars
- init
- prepareForDetach
- detachCustomScrollbars
- recalculateScrollbarOverlayStyle
- clear
- didFirstLayout
- invalidateRect
- setFrameRect
- scheduleAnimation
- page
- renderView
- setCanHaveScrollbars
- shouldUseCustomScrollbars
- createScrollbar
- setContentsSize
- clampOffsetAtScale
- adjustViewSize
- applyOverflowToViewportAndSetRenderer
- calculateScrollbarModesForLayoutAndSetViewportRenderer
- updateCompositingLayersAfterStyleChange
- updateCompositingLayersAfterLayout
- usesCompositedScrolling
- layerForScrolling
- layerForHorizontalScrollbar
- layerForVerticalScrollbar
- layerForScrollCorner
- hasCompositedContent
- isEnclosedInCompositingLayer
- layoutRoot
- forceLayoutParentViewIfNeeded
- performPreLayoutTasks
- performLayout
- scheduleOrPerformPostLayoutTasks
- layout
- repaintTree
- lifecycle
- gatherDebugLayoutRects
- embeddedContentBox
- addWidget
- removeWidget
- updateWidgetPositions
- addWidgetToUpdate
- setMediaType
- mediaType
- adjustMediaTypeForPrinting
- useSlowRepaints
- useSlowRepaintsIfNotOverlapped
- shouldAttemptToScrollUsingFastPath
- contentsInCompositedLayer
- setCannotBlitToWindow
- addSlowRepaintObject
- removeSlowRepaintObject
- addViewportConstrainedObject
- removeViewportConstrainedObject
- viewportConstrainedVisibleContentRect
- viewportConstrainedVisibleContentSizeChanged
- shouldPlaceVerticalScrollbarOnLeft
- scrollOffsetForFixedPosition
- lastKnownMousePosition
- shouldSetCursor
- scrollContentsIfNeededRecursive
- scrollContentsIfNeeded
- scrollContentsFastPath
- scrollContentsSlowPath
- setIsOverlapped
- setContentIsOpaque
- restoreScrollbar
- scrollToFragment
- scrollToAnchor
- maintainScrollPositionAtAnchor
- scrollElementToRect
- setScrollPosition
- setScrollPositionNonProgrammatically
- layoutSize
- setLayoutSize
- scrollPositionChanged
- didScrollTimerFired
- updateLayersAndCompositingAfterScrollIfNeeded
- updateFixedElementRepaintRectsAfterScroll
- shouldRubberBandInDirection
- isRubberBandInProgress
- hostWindow
- repaintContentRectangle
- contentsResized
- scrollbarExistenceDidChange
- handleLoadCompleted
- scheduleRelayout
- isObjectAncestorContainerOf
- scheduleRelayoutOfSubtree
- layoutPending
- isInPerformLayout
- needsLayout
- setNeedsLayout
- isTransparent
- setTransparent
- hasOpaqueBackground
- baseBackgroundColor
- setBaseBackgroundColor
- updateBackgroundRecursively
- scrollToAnchor
- updateWidgets
- updateWidgetsTimerFired
- flushAnyPendingPostLayoutTasks
- scheduleUpdateWidgetsIfNecessary
- performPostLayoutTasks
- sendResizeEventIfNeeded
- postLayoutTimerFired
- updateCounters
- autoSizeIfEnabled
- updateOverflowStatus
- windowClipRect
- windowClipRectForFrameOwner
- isActive
- scrollTo
- invalidateScrollbarRect
- getTickmarks
- windowResizerRect
- setVisibleContentScaleFactor
- setInputEventsTransformForEmulation
- inputEventsOffsetForEmulation
- inputEventsScaleFactor
- scrollbarsCanBeActive
- scrollableAreaBoundingBox
- isScrollable
- updateScrollableAreaSet
- shouldSuspendScrollAnimations
- scrollbarStyleChanged
- notifyPageThatContentAreaWillPaint
- scrollAnimatorEnabled
- updateAnnotatedRegions
- updateScrollCorner
- paintScrollCorner
- paintScrollbar
- documentBackgroundColor
- hasCustomScrollbars
- parentFrameView
- updateControlTints
- wasScrolledByUser
- setWasScrolledByUser
- paintContents
- setPaintBehavior
- paintBehavior
- isPainting
- setNodeToDraw
- paintOverhangAreas
- updateLayoutAndStyleForPainting
- updateLayoutAndStyleIfNeededRecursive
- enableAutoSizeMode
- forceLayout
- forceLayoutForPagination
- convertFromRenderer
- convertToRenderer
- convertFromRenderer
- convertToRenderer
- convertToContainingView
- convertFromContainingView
- convertToContainingView
- convertFromContainingView
- setTracksRepaints
- resetTrackedRepaints
- trackedRepaintRectsAsText
- addResizerArea
- removeResizerArea
- addScrollableArea
- removeScrollableArea
- containsScrollableArea
- removeChild
- wheelEvent
- isVerticalDocument
- isFlippedDocument
- axObjectCache
- setCursor
- isMainFrame
- frameRectsChanged
- setLayoutSizeInternal
- didAddScrollbar
- willRemoveScrollbar
#include "config.h"
#include "core/frame/FrameView.h"
#include "HTMLNames.h"
#include "RuntimeEnabledFeatures.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/css/FontFaceSet.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/DocumentMarkerController.h"
#include "core/editing/FrameSelection.h"
#include "core/events/OverflowEvent.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/ResourceLoadPriorityOptimizer.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElement.h"
#include "core/html/HTMLPlugInElement.h"
#include "core/html/parser/TextResourceDecoder.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/EventHandler.h"
#include "core/page/FocusController.h"
#include "core/page/FrameTree.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
#include "core/rendering/FastTextAutosizer.h"
#include "core/rendering/RenderCounter.h"
#include "core/rendering/RenderEmbeddedObject.h"
#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderListBox.h"
#include "core/rendering/RenderPart.h"
#include "core/rendering/RenderScrollbar.h"
#include "core/rendering/RenderScrollbarPart.h"
#include "core/rendering/RenderTheme.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/RenderWidget.h"
#include "core/rendering/TextAutosizer.h"
#include "core/rendering/compositing/CompositedLayerMapping.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/svg/RenderSVGRoot.h"
#include "core/svg/SVGDocument.h"
#include "core/svg/SVGSVGElement.h"
#include "platform/TraceEvent.h"
#include "platform/fonts/FontCache.h"
#include "platform/geometry/FloatRect.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayerDebugInfo.h"
#include "platform/scroll/ScrollAnimator.h"
#include "platform/scroll/ScrollbarTheme.h"
#include "platform/text/TextStream.h"
#include "wtf/CurrentTime.h"
#include "wtf/TemporaryChange.h"
namespace WebCore {
using namespace HTMLNames;
double FrameView::s_currentFrameTimeStamp = 0.0;
bool FrameView::s_inPaintContents = false;
static const unsigned maxUpdateWidgetsIterations = 2;
static const double resourcePriorityUpdateDelayAfterScroll = 0.250;
static RenderLayer::UpdateLayerPositionsFlags updateLayerPositionFlags(RenderLayer* layer, bool isRelayoutingSubtree, bool didFullRepaint)
{
RenderLayer::UpdateLayerPositionsFlags flags = didFullRepaint ? RenderLayer::NeedsFullRepaintInBacking : RenderLayer::CheckForRepaint;
if (isRelayoutingSubtree && layer->isPaginated())
flags |= RenderLayer::UpdatePagination;
return flags;
}
class FrameViewLayoutStateMaintainer {
WTF_MAKE_NONCOPYABLE(FrameViewLayoutStateMaintainer);
public:
FrameViewLayoutStateMaintainer(RenderObject& root, bool inSubtreeLayout)
: m_view(*root.view())
, m_inSubtreeLayout(inSubtreeLayout)
, m_disabled(inSubtreeLayout && m_view.shouldDisableLayoutStateForSubtree(root))
{
if (m_inSubtreeLayout)
m_view.pushLayoutState(root);
if (m_disabled)
m_view.disableLayoutState();
}
~FrameViewLayoutStateMaintainer()
{
if (m_disabled)
m_view.enableLayoutState();
if (m_inSubtreeLayout)
m_view.popLayoutState();
}
private:
RenderView& m_view;
bool m_inSubtreeLayout;
bool m_disabled;
};
FrameView::FrameView(LocalFrame* frame)
: m_frame(frame)
, m_canHaveScrollbars(true)
, m_slowRepaintObjectCount(0)
, m_hasPendingLayout(false)
, m_layoutSubtreeRoot(0)
, m_inSynchronousPostLayout(false)
, m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
, m_updateWidgetsTimer(this, &FrameView::updateWidgetsTimerFired)
, m_isTransparent(false)
, m_baseBackgroundColor(Color::white)
, m_mediaType("screen")
, m_overflowStatusDirty(true)
, m_viewportRenderer(0)
, m_wasScrolledByUser(false)
, m_inProgrammaticScroll(false)
, m_safeToPropagateScrollToParent(true)
, m_isTrackingRepaints(false)
, m_scrollCorner(0)
, m_shouldAutoSize(false)
, m_inAutoSize(false)
, m_didRunAutosize(false)
, m_hasSoftwareFilters(false)
, m_visibleContentScaleFactor(1)
, m_inputEventsScaleFactorForEmulation(1)
, m_layoutSizeFixedToFrameSize(true)
, m_didScrollTimer(this, &FrameView::didScrollTimerFired)
{
ASSERT(m_frame);
init();
if (!isMainFrame())
return;
ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed);
ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
}
PassRefPtr<FrameView> FrameView::create(LocalFrame* frame)
{
RefPtr<FrameView> view = adoptRef(new FrameView(frame));
view->show();
return view.release();
}
PassRefPtr<FrameView> FrameView::create(LocalFrame* frame, const IntSize& initialSize)
{
RefPtr<FrameView> view = adoptRef(new FrameView(frame));
view->Widget::setFrameRect(IntRect(view->location(), initialSize));
view->setLayoutSizeInternal(initialSize);
view->show();
return view.release();
}
FrameView::~FrameView()
{
if (m_postLayoutTasksTimer.isActive())
m_postLayoutTasksTimer.stop();
if (m_didScrollTimer.isActive())
m_didScrollTimer.stop();
removeFromAXObjectCache();
resetScrollbars();
ASSERT(!horizontalScrollbar() || !horizontalScrollbar()->isCustomScrollbar());
ASSERT(!verticalScrollbar() || !verticalScrollbar()->isCustomScrollbar());
setHasHorizontalScrollbar(false);
setHasVerticalScrollbar(false);
ASSERT(!m_scrollCorner);
ASSERT(m_frame);
ASSERT(m_frame->view() != this || !m_frame->contentRenderer());
HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement();
if (ownerElement && ownerElement->ownedWidget() == this)
ownerElement->setWidget(nullptr);
}
void FrameView::reset()
{
m_cannotBlitToWindow = false;
m_isOverlapped = false;
m_contentIsOpaque = false;
m_hasPendingLayout = false;
m_layoutSubtreeRoot = 0;
m_doFullRepaint = false;
m_layoutSchedulingEnabled = true;
m_inPerformLayout = false;
m_canRepaintDuringPerformLayout = false;
m_doingPreLayoutStyleUpdate = false;
m_inSynchronousPostLayout = false;
m_layoutCount = 0;
m_nestedLayoutCount = 0;
m_postLayoutTasksTimer.stop();
m_updateWidgetsTimer.stop();
m_firstLayout = true;
m_firstLayoutCallbackPending = false;
m_wasScrolledByUser = false;
m_safeToPropagateScrollToParent = true;
m_lastViewportSize = IntSize();
m_lastZoomFactor = 1.0f;
m_isTrackingRepaints = false;
m_trackedRepaintRects.clear();
m_lastPaintTime = 0;
m_paintBehavior = PaintBehaviorNormal;
m_isPainting = false;
m_visuallyNonEmptyCharacterCount = 0;
m_visuallyNonEmptyPixelCount = 0;
m_isVisuallyNonEmpty = false;
m_firstVisuallyNonEmptyLayoutCallbackPending = true;
m_maintainScrollPositionAnchor = nullptr;
m_viewportConstrainedObjects.clear();
}
void FrameView::removeFromAXObjectCache()
{
if (AXObjectCache* cache = axObjectCache())
cache->remove(this);
}
void FrameView::resetScrollbars()
{
m_firstLayout = true;
setScrollbarsSuppressed(true);
if (m_canHaveScrollbars)
setScrollbarModes(ScrollbarAuto, ScrollbarAuto);
else
setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
setScrollbarsSuppressed(false);
}
void FrameView::init()
{
reset();
m_size = LayoutSize();
Element* ownerElement = m_frame->ownerElement();
if (ownerElement && (isHTMLFrameElement(*ownerElement) || isHTMLIFrameElement(*ownerElement))) {
HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement);
if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
setCanHaveScrollbars(false);
}
}
void FrameView::prepareForDetach()
{
RELEASE_ASSERT(!isInPerformLayout());
if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
scrollAnimator->cancelAnimations();
detachCustomScrollbars();
removeFromAXObjectCache();
if (m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scrollingCoordinator())
scrollingCoordinator->willDestroyScrollableArea(this);
}
}
void FrameView::detachCustomScrollbars()
{
Scrollbar* horizontalBar = horizontalScrollbar();
if (horizontalBar && horizontalBar->isCustomScrollbar())
setHasHorizontalScrollbar(false);
Scrollbar* verticalBar = verticalScrollbar();
if (verticalBar && verticalBar->isCustomScrollbar())
setHasVerticalScrollbar(false);
if (m_scrollCorner) {
m_scrollCorner->destroy();
m_scrollCorner = 0;
}
}
void FrameView::recalculateScrollbarOverlayStyle()
{
ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
Color backgroundColor = documentBackgroundColor();
double hue, saturation, lightness;
backgroundColor.getHSL(hue, saturation, lightness);
if (lightness <= .5)
overlayStyle = ScrollbarOverlayStyleLight;
if (oldOverlayStyle != overlayStyle)
setScrollbarOverlayStyle(overlayStyle);
}
void FrameView::clear()
{
reset();
setScrollbarsSuppressed(true);
}
bool FrameView::didFirstLayout() const
{
return !m_firstLayout;
}
void FrameView::invalidateRect(const IntRect& rect)
{
if (!parent()) {
if (HostWindow* window = hostWindow())
window->invalidateContentsAndRootView(rect);
return;
}
RenderPart* renderer = m_frame->ownerRenderer();
if (!renderer)
return;
IntRect repaintRect = rect;
repaintRect.move(renderer->borderLeft() + renderer->paddingLeft(),
renderer->borderTop() + renderer->paddingTop());
renderer->repaintRectangle(repaintRect);
}
void FrameView::setFrameRect(const IntRect& newRect)
{
IntRect oldRect = frameRect();
if (newRect == oldRect)
return;
bool autosizerNeedsUpdating = false;
if (newRect.width() != oldRect.width()) {
if (isMainFrame() && m_frame->settings()->textAutosizingEnabled()) {
autosizerNeedsUpdating = true;
for (LocalFrame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext()) {
if (TextAutosizer* textAutosizer = frame->document()->textAutosizer())
textAutosizer->recalculateMultipliers();
}
}
}
ScrollView::setFrameRect(newRect);
updateScrollableAreaSet();
if (autosizerNeedsUpdating) {
if (FastTextAutosizer* textAutosizer = m_frame->document()->fastTextAutosizer())
textAutosizer->updatePageInfoInAllFrames();
}
if (RenderView* renderView = this->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidChangeSize();
}
viewportConstrainedVisibleContentSizeChanged(newRect.width() != oldRect.width(), newRect.height() != oldRect.height());
}
bool FrameView::scheduleAnimation()
{
if (HostWindow* window = hostWindow()) {
window->scheduleAnimation();
return true;
}
return false;
}
Page* FrameView::page() const
{
return frame().page();
}
RenderView* FrameView::renderView() const
{
return frame().contentRenderer();
}
void FrameView::setCanHaveScrollbars(bool canHaveScrollbars)
{
m_canHaveScrollbars = canHaveScrollbars;
ScrollView::setCanHaveScrollbars(canHaveScrollbars);
}
bool FrameView::shouldUseCustomScrollbars(Element*& customScrollbarElement, LocalFrame*& customScrollbarFrame)
{
customScrollbarElement = 0;
customScrollbarFrame = 0;
if (Settings* settings = m_frame->settings()) {
if (!settings->allowCustomScrollbarInMainFrame() && isMainFrame())
return false;
}
Document* doc = m_frame->document();
Element* body = doc ? doc->body() : 0;
if (body && body->renderer() && body->renderer()->style()->hasPseudoStyle(SCROLLBAR)) {
customScrollbarElement = body;
return true;
}
Element* docElement = doc ? doc->documentElement() : 0;
if (docElement && docElement->renderer() && docElement->renderer()->style()->hasPseudoStyle(SCROLLBAR)) {
customScrollbarElement = docElement;
return true;
}
RenderPart* frameRenderer = m_frame->ownerRenderer();
if (frameRenderer && frameRenderer->style()->hasPseudoStyle(SCROLLBAR)) {
customScrollbarFrame = m_frame.get();
return true;
}
return false;
}
PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientation)
{
Element* customScrollbarElement = 0;
LocalFrame* customScrollbarFrame = 0;
if (shouldUseCustomScrollbars(customScrollbarElement, customScrollbarFrame))
return RenderScrollbar::createCustomScrollbar(this, orientation, customScrollbarElement, customScrollbarFrame);
return ScrollView::createScrollbar(orientation);
}
void FrameView::setContentsSize(const IntSize& size)
{
if (size == contentsSize())
return;
ScrollView::setContentsSize(size);
ScrollView::contentsResized();
Page* page = frame().page();
if (!page)
return;
updateScrollableAreaSet();
page->chrome().contentsSizeChanged(m_frame.get(), size);
}
IntPoint FrameView::clampOffsetAtScale(const IntPoint& offset, float scale) const
{
IntPoint maxScrollExtent(contentsSize().width() - scrollOrigin().x(), contentsSize().height() - scrollOrigin().y());
FloatSize scaledSize = unscaledVisibleContentSize();
if (scale)
scaledSize.scale(1 / scale);
IntPoint clampedOffset = offset;
clampedOffset = clampedOffset.shrunkTo(maxScrollExtent - expandedIntSize(scaledSize));
clampedOffset = clampedOffset.expandedTo(-scrollOrigin());
return clampedOffset;
}
void FrameView::adjustViewSize()
{
RenderView* renderView = this->renderView();
if (!renderView)
return;
ASSERT(m_frame->view() == this);
const IntRect rect = renderView->documentRect();
const IntSize& size = rect.size();
ScrollView::setScrollOrigin(IntPoint(-rect.x(), -rect.y()), !m_frame->document()->printing(), size == contentsSize());
setContentsSize(size);
}
void FrameView::applyOverflowToViewportAndSetRenderer(RenderObject* o, ScrollbarMode& hMode, ScrollbarMode& vMode)
{
EOverflow overflowX = o->style()->overflowX();
EOverflow overflowY = o->style()->overflowY();
if (o->isSVGRoot()) {
if (!toRenderSVGRoot(o)->isEmbeddedThroughFrameContainingSVGDocument())
return;
overflowX = OHIDDEN;
overflowY = OHIDDEN;
}
bool ignoreOverflowHidden = false;
if (m_frame->settings()->ignoreMainFrameOverflowHiddenQuirk() && m_frame->isMainFrame())
ignoreOverflowHidden = true;
switch (overflowX) {
case OHIDDEN:
if (!ignoreOverflowHidden)
hMode = ScrollbarAlwaysOff;
break;
case OSCROLL:
hMode = ScrollbarAlwaysOn;
break;
case OAUTO:
hMode = ScrollbarAuto;
break;
default:
;
}
switch (overflowY) {
case OHIDDEN:
if (!ignoreOverflowHidden)
vMode = ScrollbarAlwaysOff;
break;
case OSCROLL:
vMode = ScrollbarAlwaysOn;
break;
case OAUTO:
vMode = ScrollbarAuto;
break;
default:
;
}
m_viewportRenderer = o;
}
void FrameView::calculateScrollbarModesForLayoutAndSetViewportRenderer(ScrollbarMode& hMode, ScrollbarMode& vMode, ScrollbarModesCalculationStrategy strategy)
{
m_viewportRenderer = 0;
const HTMLFrameOwnerElement* owner = m_frame->ownerElement();
if (owner && (owner->scrollingMode() == ScrollbarAlwaysOff)) {
hMode = ScrollbarAlwaysOff;
vMode = ScrollbarAlwaysOff;
return;
}
if (m_canHaveScrollbars || strategy == RulesFromWebContentOnly) {
hMode = ScrollbarAuto;
vMode = ScrollbarAuto;
} else {
hMode = ScrollbarAlwaysOff;
vMode = ScrollbarAlwaysOff;
}
if (!isSubtreeLayout()) {
Document* document = m_frame->document();
Node* body = document->body();
if (isHTMLFrameSetElement(body) && body->renderer()) {
vMode = ScrollbarAlwaysOff;
hMode = ScrollbarAlwaysOff;
} else if (Element* viewportElement = document->viewportDefiningElement()) {
if (RenderObject* viewportRenderer = viewportElement->renderer()) {
if (viewportRenderer->style())
applyOverflowToViewportAndSetRenderer(viewportRenderer, hMode, vMode);
}
}
}
}
void FrameView::updateCompositingLayersAfterStyleChange()
{
TRACE_EVENT0("webkit", "FrameView::updateCompositingLayersAfterStyleChange");
RenderView* renderView = this->renderView();
if (!renderView)
return;
if (m_doingPreLayoutStyleUpdate || layoutPending() || renderView->needsLayout())
return;
DisableCompositingQueryAsserts disabler;
renderView->compositor()->cacheAcceleratedCompositingFlags();
if (!needsLayout())
renderView->compositor()->updateCompositingRequirementsState();
renderView->compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterStyleChange);
}
void FrameView::updateCompositingLayersAfterLayout()
{
TRACE_EVENT0("webkit", "FrameView::updateCompositingLayersAfterLayout");
RenderView* renderView = this->renderView();
if (!renderView)
return;
DisableCompositingQueryAsserts disabler;
renderView->compositor()->cacheAcceleratedCompositingFlags();
renderView->compositor()->updateCompositingRequirementsState();
renderView->compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterLayout);
}
bool FrameView::usesCompositedScrolling() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return false;
if (m_frame->settings() && m_frame->settings()->compositedScrollingForFramesEnabled())
return renderView->compositor()->inForcedCompositingMode();
return false;
}
GraphicsLayer* FrameView::layerForScrolling() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->scrollLayer();
}
GraphicsLayer* FrameView::layerForHorizontalScrollbar() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForHorizontalScrollbar();
}
GraphicsLayer* FrameView::layerForVerticalScrollbar() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForVerticalScrollbar();
}
GraphicsLayer* FrameView::layerForScrollCorner() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForScrollCorner();
}
bool FrameView::hasCompositedContent() const
{
if (RenderView* renderView = this->renderView())
return renderView->compositor()->inCompositingMode();
return false;
}
bool FrameView::isEnclosedInCompositingLayer() const
{
RenderObject* frameOwnerRenderer = m_frame->ownerRenderer();
if (frameOwnerRenderer && frameOwnerRenderer->containerForRepaint())
return true;
if (FrameView* parentView = parentFrameView())
return parentView->isEnclosedInCompositingLayer();
return false;
}
RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
{
return onlyDuringLayout && layoutPending() ? 0 : m_layoutSubtreeRoot;
}
inline void FrameView::forceLayoutParentViewIfNeeded()
{
RenderPart* ownerRenderer = m_frame->ownerRenderer();
if (!ownerRenderer || !ownerRenderer->frame())
return;
RenderBox* contentBox = embeddedContentBox();
if (!contentBox)
return;
RenderSVGRoot* svgRoot = toRenderSVGRoot(contentBox);
if (svgRoot->everHadLayout() && !svgRoot->needsLayout())
return;
RefPtr<FrameView> frameView = ownerRenderer->frame()->view();
ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc();
ASSERT(frameView);
frameView->layout();
}
void FrameView::performPreLayoutTasks()
{
TRACE_EVENT0("webkit", "FrameView::performPreLayoutTasks");
lifecycle().advanceTo(DocumentLifecycle::InPreLayout);
TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksTimer.isActive()) {
m_inSynchronousPostLayout = true;
performPostLayoutTasks();
m_inSynchronousPostLayout = false;
}
Document* document = m_frame->document();
document->notifyResizeForViewportUnits();
if (!document->styleResolver() || document->styleResolver()->mediaQueryAffectedByViewportChange()) {
document->styleResolverChanged(RecalcStyleDeferred);
document->mediaQueryAffectingValueChanged();
InspectorInstrumentation::mediaQueryResultChanged(document);
} else {
document->evaluateMediaQueryList();
}
TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleUpdate, true);
document->updateRenderTreeIfNeeded();
lifecycle().advanceTo(DocumentLifecycle::StyleClean);
}
void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout)
{
TRACE_EVENT0("webkit", "FrameView::performLayout");
ASSERT(!isInPerformLayout());
lifecycle().advanceTo(DocumentLifecycle::InPerformLayout);
TemporaryChange<bool> changeInPerformLayout(m_inPerformLayout, true);
FrameViewLayoutStateMaintainer statePusher(*rootForThisLayout, inSubtreeLayout);
forceLayoutParentViewIfNeeded();
rootForThisLayout->layout();
gatherDebugLayoutRects(rootForThisLayout);
ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllImageResourcePriorities();
TextAutosizer* textAutosizer = frame().document()->textAutosizer();
bool autosized = textAutosizer && textAutosizer->processSubtree(rootForThisLayout);
if (autosized && rootForThisLayout->needsLayout()) {
TRACE_EVENT0("webkit", "2nd layout due to Text Autosizing");
UseCounter::count(*frame().document(), UseCounter::TextAutosizingLayout);
rootForThisLayout->layout();
gatherDebugLayoutRects(rootForThisLayout);
}
lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout);
}
void FrameView::scheduleOrPerformPostLayoutTasks()
{
if (m_postLayoutTasksTimer.isActive())
return;
if (!m_inSynchronousPostLayout) {
m_inSynchronousPostLayout = true;
performPostLayoutTasks();
m_inSynchronousPostLayout = false;
}
if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inSynchronousPostLayout)) {
m_postLayoutTasksTimer.startOneShot(0, FROM_HERE);
if (needsLayout())
layout();
}
}
void FrameView::layout(bool allowSubtree)
{
ASSERT(m_frame);
ASSERT(m_frame->view() == this);
ASSERT(m_frame->page());
if (isInPerformLayout() || !m_frame->document()->isActive())
return;
TRACE_EVENT0("webkit", "FrameView::layout");
TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "Layout");
RefPtr<FrameView> protector(this);
TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
m_hasPendingLayout = false;
DocumentLifecycle::Scope lifecycleScope(lifecycle(), DocumentLifecycle::LayoutClean);
RELEASE_ASSERT(!isPainting());
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(m_frame.get());
if (!allowSubtree && isSubtreeLayout()) {
m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
m_layoutSubtreeRoot = 0;
}
performPreLayoutTasks();
if (protector->hasOneRef())
return;
Document* document = m_frame->document();
bool inSubtreeLayout = isSubtreeLayout();
RenderObject* rootForThisLayout = inSubtreeLayout ? m_layoutSubtreeRoot : document->renderer();
if (!rootForThisLayout) {
ASSERT_NOT_REACHED();
return;
}
FontCachePurgePreventer fontCachePurgePreventer;
RenderLayer* layer;
{
TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
m_nestedLayoutCount++;
if (!inSubtreeLayout) {
Document* document = m_frame->document();
Node* body = document->body();
if (body && body->renderer()) {
if (isHTMLFrameSetElement(*body)) {
body->renderer()->setChildNeedsLayout();
} else if (isHTMLBodyElement(*body)) {
if (!m_firstLayout && m_size.height() != layoutSize().height() && body->renderer()->enclosingBox()->stretchesToViewport())
body->renderer()->setChildNeedsLayout();
}
}
}
updateCounters();
autoSizeIfEnabled();
ScrollbarMode hMode;
ScrollbarMode vMode;
calculateScrollbarModesForLayoutAndSetViewportRenderer(hMode, vMode);
bool shouldDoFullRepaint = !inSubtreeLayout && (m_firstLayout || toRenderView(rootForThisLayout)->document().printing());
if (!inSubtreeLayout) {
ScrollbarMode currentHMode = horizontalScrollbarMode();
ScrollbarMode currentVMode = verticalScrollbarMode();
if (m_firstLayout) {
setScrollbarsSuppressed(true);
m_firstLayout = false;
m_firstLayoutCallbackPending = true;
m_lastViewportSize = layoutSize(IncludeScrollbars);
m_lastZoomFactor = rootForThisLayout->style()->zoom();
if (vMode == ScrollbarAuto)
setVerticalScrollbarMode(ScrollbarAlwaysOn);
if (hMode == ScrollbarAuto)
setHorizontalScrollbarMode(ScrollbarAlwaysOff);
setScrollbarModes(hMode, vMode);
setScrollbarsSuppressed(false, true);
} else if (hMode != currentHMode || vMode != currentVMode) {
setScrollbarModes(hMode, vMode);
}
LayoutSize oldSize = m_size;
m_size = LayoutSize(layoutSize().width(), layoutSize().height());
if (oldSize != m_size) {
if (!renderView()->style()->isHorizontalWritingMode() || oldSize.width() != m_size.width())
shouldDoFullRepaint = true;
if (!m_firstLayout) {
RenderBox* rootRenderer = document->documentElement() ? document->documentElement()->renderBox() : 0;
RenderBox* bodyRenderer = rootRenderer && document->body() ? document->body()->renderBox() : 0;
if (bodyRenderer && bodyRenderer->stretchesToViewport())
bodyRenderer->setChildNeedsLayout();
else if (rootRenderer && rootRenderer->stretchesToViewport())
rootRenderer->setChildNeedsLayout();
}
}
}
layer = rootForThisLayout->enclosingLayer();
m_doFullRepaint |= shouldDoFullRepaint;
performLayout(rootForThisLayout, inSubtreeLayout);
m_layoutSubtreeRoot = 0;
}
if (!inSubtreeLayout && !toRenderView(rootForThisLayout)->document().printing())
adjustViewSize();
layer->updateLayerPositionsAfterLayout(renderView()->layer(), updateLayerPositionFlags(layer, inSubtreeLayout, m_doFullRepaint));
updateCompositingLayersAfterLayout();
m_layoutCount++;
if (AXObjectCache* cache = rootForThisLayout->document().axObjectCache())
cache->handleLayoutComplete(rootForThisLayout);
updateAnnotatedRegions();
ASSERT(!rootForThisLayout->needsLayout());
if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
updateOverflowStatus(layoutSize().width() < contentsWidth(), layoutSize().height() < contentsHeight());
scheduleOrPerformPostLayoutTasks();
InspectorInstrumentation::didLayout(cookie, rootForThisLayout);
m_nestedLayoutCount--;
if (m_nestedLayoutCount)
return;
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
repaintTree(rootForThisLayout);
} else if (m_doFullRepaint) {
renderView()->repaint();
}
m_doFullRepaint = false;
#ifndef NDEBUG
document->renderer()->assertSubtreeIsLaidOut();
#endif
if (frame().page())
frame().page()->chrome().client().layoutUpdated(m_frame.get());
}
void FrameView::repaintTree(RenderObject* root)
{
ASSERT(RuntimeEnabledFeatures::repaintAfterLayoutEnabled());
ASSERT(!root->needsLayout());
ASSERT(!m_nestedLayoutCount);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "FrameView::repaintTree");
DisableCompositingQueryAsserts disabler;
if (m_doFullRepaint) {
RenderView* view = renderView();
view->repaintAfterLayoutIfNeeded(view->containerForRepaint(), true, view->oldRepaintRect(), &(view->newRepaintRect()));
for (RenderObject* renderer = root; renderer; renderer = renderer->nextInPreOrder()) {
renderer->clearRepaintState();
}
return;
}
ASSERT(!m_doFullRepaint);
for (RenderObject* renderer = root; renderer; renderer = renderer->nextInPreOrder()) {
if ((renderer->onlyNeededPositionedMovementLayout() && renderer->compositingState() != PaintsIntoOwnBacking)
|| (renderer->shouldDoFullRepaintIfSelfPaintingLayer()
&& renderer->hasLayer()
&& toRenderLayerModelObject(renderer)->layer()->isSelfPaintingLayer())) {
renderer->setShouldDoFullRepaintAfterLayout(true);
}
bool didFullRepaint = false;
if (!renderer->layoutDidGetCalled()) {
if (renderer->shouldDoFullRepaintAfterLayout()) {
renderer->repaint();
didFullRepaint = true;
}
} else {
didFullRepaint = renderer->repaintAfterLayoutIfNeeded(renderer->containerForRepaint(),
renderer->shouldDoFullRepaintAfterLayout(), renderer->oldRepaintRect(), &(renderer->newRepaintRect()));
}
if (!didFullRepaint)
renderer->repaintOverflowIfNeeded();
if (RenderLayerScrollableArea* area = renderer->enclosingLayer()->scrollableArea()) {
if (area->hasVerticalBarDamage())
renderer->repaintRectangle(area->verticalBarDamage());
if (area->hasHorizontalBarDamage())
renderer->repaintRectangle(area->horizontalBarDamage());
area->resetScrollbarDamage();
}
if (renderer->isListBox()) {
RenderListBox* listBox = static_cast<RenderListBox*>(renderer);
listBox->repaintScrollbarIfNeeded();
}
renderer->clearRepaintState();
}
if (hasVerticalBarDamage())
invalidateRect(verticalBarDamage());
if (hasHorizontalBarDamage())
invalidateRect(horizontalBarDamage());
resetScrollbarDamage();
}
DocumentLifecycle& FrameView::lifecycle() const
{
return m_frame->document()->lifecycle();
}
void FrameView::gatherDebugLayoutRects(RenderObject* layoutRoot)
{
bool isTracing;
TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.layout"), &isTracing);
if (!isTracing)
return;
if (!layoutRoot->enclosingLayer()->hasCompositedLayerMapping())
return;
GraphicsLayer* graphicsLayer = layoutRoot->enclosingLayer()->compositedLayerMapping()->mainGraphicsLayer();
if (!graphicsLayer)
return;
GraphicsLayerDebugInfo& debugInfo = graphicsLayer->debugInfo();
debugInfo.currentLayoutRects().clear();
for (RenderObject* renderer = layoutRoot; renderer; renderer = renderer->nextInPreOrder()) {
if (renderer->layoutDidGetCalled()) {
FloatQuad quad = renderer->localToAbsoluteQuad(FloatQuad(renderer->newRepaintRect()));
LayoutRect rect = quad.enclosingBoundingBox();
debugInfo.currentLayoutRects().append(rect);
renderer->setLayoutDidGetCalled(false);
}
}
}
RenderBox* FrameView::embeddedContentBox() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
RenderObject* firstChild = renderView->firstChild();
if (!firstChild || !firstChild->isBox())
return 0;
if (firstChild->isSVGRoot())
return toRenderBox(firstChild);
return 0;
}
void FrameView::addWidget(RenderWidget* object)
{
m_widgets.add(object);
}
void FrameView::removeWidget(RenderWidget* object)
{
m_widgets.remove(object);
}
void FrameView::updateWidgetPositions()
{
Vector<RefPtr<RenderWidget> > widgets;
copyToVector(m_widgets, widgets);
for (size_t i = 0; i < widgets.size() && renderView(); ++i)
widgets[i]->updateWidgetPosition();
for (size_t i = 0; i < widgets.size() && renderView(); ++i)
widgets[i]->widgetPositionsUpdated();
}
void FrameView::addWidgetToUpdate(RenderEmbeddedObject& object)
{
ASSERT(isInPerformLayout());
Node* node = object.node();
ASSERT(node);
if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node))
toHTMLPlugInElement(node)->setNeedsWidgetUpdate(true);
m_widgetUpdateSet.add(&object);
}
void FrameView::setMediaType(const AtomicString& mediaType)
{
ASSERT(m_frame->document());
m_frame->document()->mediaQueryAffectingValueChanged();
m_mediaType = mediaType;
}
AtomicString FrameView::mediaType() const
{
String overrideType;
InspectorInstrumentation::applyEmulatedMedia(m_frame.get(), &overrideType);
if (!overrideType.isNull())
return AtomicString(overrideType);
return m_mediaType;
}
void FrameView::adjustMediaTypeForPrinting(bool printing)
{
if (printing) {
if (m_mediaTypeWhenNotPrinting.isNull())
m_mediaTypeWhenNotPrinting = mediaType();
setMediaType("print");
} else {
if (!m_mediaTypeWhenNotPrinting.isNull())
setMediaType(m_mediaTypeWhenNotPrinting);
m_mediaTypeWhenNotPrinting = nullAtom;
}
}
bool FrameView::useSlowRepaints(bool considerOverlap) const
{
DisableCompositingQueryAsserts disabler;
if (m_slowRepaintObjectCount > 0)
return true;
if (contentsInCompositedLayer())
return false;
if (m_frame->ownerElement() && !hasCompositedContent() && m_frame->page() && m_frame->page()->mainFrame()->view()->hasCompositedContent())
return true;
if (m_isOverlapped && considerOverlap)
return true;
if (m_cannotBlitToWindow)
return true;
if (!m_contentIsOpaque)
return true;
if (FrameView* parentView = parentFrameView())
return parentView->useSlowRepaints(considerOverlap);
return false;
}
bool FrameView::useSlowRepaintsIfNotOverlapped() const
{
return useSlowRepaints(false);
}
bool FrameView::shouldAttemptToScrollUsingFastPath() const
{
return !useSlowRepaints();
}
bool FrameView::contentsInCompositedLayer() const
{
RenderView* renderView = this->renderView();
if (renderView && renderView->compositingState() == PaintsIntoOwnBacking) {
GraphicsLayer* layer = renderView->layer()->compositedLayerMapping()->mainGraphicsLayer();
if (layer && layer->drawsContent())
return true;
}
return false;
}
void FrameView::setCannotBlitToWindow()
{
m_cannotBlitToWindow = true;
}
void FrameView::addSlowRepaintObject()
{
if (!m_slowRepaintObjectCount++) {
if (Page* page = m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewHasSlowRepaintObjectsDidChange(this);
}
}
}
void FrameView::removeSlowRepaintObject()
{
ASSERT(m_slowRepaintObjectCount > 0);
m_slowRepaintObjectCount--;
if (!m_slowRepaintObjectCount) {
if (Page* page = m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewHasSlowRepaintObjectsDidChange(this);
}
}
}
void FrameView::addViewportConstrainedObject(RenderObject* object)
{
if (!m_viewportConstrainedObjects)
m_viewportConstrainedObjects = adoptPtr(new ViewportConstrainedObjectSet);
if (!m_viewportConstrainedObjects->contains(object)) {
m_viewportConstrainedObjects->add(object);
if (Page* page = m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewFixedObjectsDidChange(this);
}
}
}
void FrameView::removeViewportConstrainedObject(RenderObject* object)
{
if (m_viewportConstrainedObjects && m_viewportConstrainedObjects->contains(object)) {
m_viewportConstrainedObjects->remove(object);
if (Page* page = m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewFixedObjectsDidChange(this);
}
}
}
LayoutRect FrameView::viewportConstrainedVisibleContentRect() const
{
LayoutRect viewportRect = visibleContentRect();
viewportRect.setLocation(clampScrollPosition(scrollPosition()));
return viewportRect;
}
void FrameView::viewportConstrainedVisibleContentSizeChanged(bool widthChanged, bool heightChanged)
{
if ((m_frame->settings() && !m_frame->settings()->viewportEnabled()) || !hasViewportConstrainedObjects())
return;
ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
RenderObject* renderer = *it;
RenderStyle* style = renderer->style();
if (widthChanged) {
if (style->width().isFixed() && (style->left().isAuto() || style->right().isAuto()))
renderer->setNeedsPositionedMovementLayout();
else
renderer->setNeedsLayout();
}
if (heightChanged) {
if (style->height().isFixed() && (style->top().isAuto() || style->bottom().isAuto()))
renderer->setNeedsPositionedMovementLayout();
else
renderer->setNeedsLayout();
}
}
}
bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const
{
if (isMainFrame())
return false;
Document* document = m_frame->document();
if (!document)
return false;
if (!document->body() || !document->body()->renderer())
return false;
return document->body()->renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft();
}
IntSize FrameView::scrollOffsetForFixedPosition() const
{
return toIntSize(clampScrollPosition(scrollPosition()));
}
IntPoint FrameView::lastKnownMousePosition() const
{
return m_frame->eventHandler().lastKnownMousePosition();
}
bool FrameView::shouldSetCursor() const
{
Page* page = frame().page();
return page && page->visibilityState() != PageVisibilityStateHidden && page->focusController().isActive();
}
void FrameView::scrollContentsIfNeededRecursive()
{
scrollContentsIfNeeded();
for (LocalFrame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
if (FrameView* view = child->view())
view->scrollContentsIfNeededRecursive();
}
}
void FrameView::scrollContentsIfNeeded()
{
bool didScroll = !pendingScrollDelta().isZero();
ScrollView::scrollContentsIfNeeded();
if (didScroll)
updateFixedElementRepaintRectsAfterScroll();
}
bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
{
if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()) {
hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
return true;
}
const bool isCompositedContentLayer = contentsInCompositedLayer();
Region regionToUpdate;
ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
RenderObject* renderer = *it;
ASSERT(renderer->style()->hasViewportConstrainedPosition());
ASSERT(renderer->hasLayer());
RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
if (layer->compositingState() == PaintsIntoOwnBacking)
continue;
if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForBoundsOutOfView
|| layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForNoVisibleContent) {
continue;
}
if (layer->hasAncestorWithFilterOutsets()) {
return false;
}
IntRect updateRect = pixelSnappedIntRect(layer->repainter().repaintRectIncludingNonCompositingDescendants());
RenderLayer* enclosingCompositingLayer = layer->enclosingCompositingLayer(ExcludeSelf);
if (enclosingCompositingLayer && !enclosingCompositingLayer->renderer()->isRenderView()) {
updateRect.moveBy(scrollPosition());
IntRect previousRect = updateRect;
previousRect.move(scrollDelta);
updateRect.unite(previousRect);
enclosingCompositingLayer->repainter().setBackingNeedsRepaintInRect(updateRect);
} else {
updateRect = contentsToRootView(updateRect);
if (!isCompositedContentLayer && clipsRepaints())
updateRect.intersect(rectToScroll);
if (!updateRect.isEmpty())
regionToUpdate.unite(updateRect);
}
}
hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
IntRect updateRect = subRectsToUpdate[i];
IntRect scrolledRect = updateRect;
scrolledRect.move(-scrollDelta);
updateRect.unite(scrolledRect);
if (isCompositedContentLayer) {
updateRect = rootViewToContents(updateRect);
ASSERT(renderView());
renderView()->layer()->repainter().setBackingNeedsRepaintInRect(updateRect);
continue;
}
if (clipsRepaints())
updateRect.intersect(rectToScroll);
hostWindow()->invalidateContentsAndRootView(updateRect);
}
return true;
}
void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
{
if (contentsInCompositedLayer()) {
IntRect updateRect = visibleContentRect();
ASSERT(renderView());
renderView()->layer()->repainter().setBackingNeedsRepaintInRect(updateRect);
}
if (RenderPart* frameRenderer = m_frame->ownerRenderer()) {
if (isEnclosedInCompositingLayer()) {
LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->paddingLeft(),
frameRenderer->borderTop() + frameRenderer->paddingTop(),
visibleWidth(), visibleHeight());
frameRenderer->repaintRectangle(rect);
return;
}
}
ScrollView::scrollContentsSlowPath(updateRect);
}
void FrameView::setIsOverlapped(bool isOverlapped)
{
m_isOverlapped = isOverlapped;
}
void FrameView::setContentIsOpaque(bool contentIsOpaque)
{
m_contentIsOpaque = contentIsOpaque;
}
void FrameView::restoreScrollbar()
{
setScrollbarsSuppressed(false);
}
bool FrameView::scrollToFragment(const KURL& url)
{
if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget())
return false;
String fragmentIdentifier = url.fragmentIdentifier();
if (scrollToAnchor(fragmentIdentifier))
return true;
if (m_frame->document()->encoding().isValid())
return scrollToAnchor(decodeURLEscapeSequences(fragmentIdentifier, m_frame->document()->encoding()));
return false;
}
bool FrameView::scrollToAnchor(const String& name)
{
ASSERT(m_frame->document());
if (!m_frame->document()->haveStylesheetsLoaded()) {
m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
return false;
}
m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
Element* anchorNode = m_frame->document()->findAnchor(name);
m_frame->document()->setCSSTarget(anchorNode);
if (m_frame->document()->isSVGDocument()) {
if (SVGSVGElement* svg = toSVGDocument(m_frame->document())->rootElement()) {
svg->setupInitialView(name, anchorNode);
if (!anchorNode)
return true;
}
}
if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))
return false;
maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());
if (anchorNode && anchorNode->isFocusable())
m_frame->document()->setFocusedElement(anchorNode);
return true;
}
void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode)
{
m_maintainScrollPositionAnchor = anchorNode;
if (!m_maintainScrollPositionAnchor)
return;
m_frame->document()->updateRenderTreeIfNeeded();
RenderView* renderView = this->renderView();
if (renderView && renderView->needsLayout())
layout();
else
scrollToAnchor();
}
void FrameView::scrollElementToRect(Element* element, const IntRect& rect)
{
m_frame->document()->updateLayoutIgnorePendingStylesheets();
LayoutRect bounds = element->boundingBox();
int centeringOffsetX = (rect.width() - bounds.width()) / 2;
int centeringOffsetY = (rect.height() - bounds.height()) / 2;
setScrollPosition(IntPoint(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y()));
}
void FrameView::setScrollPosition(const IntPoint& scrollPoint)
{
TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, true);
m_maintainScrollPositionAnchor = nullptr;
IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
if (newScrollPosition == scrollPosition())
return;
ScrollView::setScrollPosition(newScrollPosition);
}
void FrameView::setScrollPositionNonProgrammatically(const IntPoint& scrollPoint)
{
IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
if (newScrollPosition == scrollPosition())
return;
TemporaryChange<bool> changeInProgrammaticScroll(m_inProgrammaticScroll, false);
notifyScrollPositionChanged(newScrollPosition);
}
IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const
{
return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutSize) : m_layoutSize;
}
void FrameView::setLayoutSize(const IntSize& size)
{
ASSERT(!layoutSizeFixedToFrameSize());
setLayoutSizeInternal(size);
}
void FrameView::scrollPositionChanged()
{
setWasScrolledByUser(true);
Document* document = m_frame->document();
document->enqueueScrollEventForNode(document);
m_frame->eventHandler().dispatchFakeMouseMoveEventSoon();
if (RenderView* renderView = document->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidScroll();
}
if (m_didScrollTimer.isActive())
m_didScrollTimer.stop();
m_didScrollTimer.startOneShot(resourcePriorityUpdateDelayAfterScroll, FROM_HERE);
if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
cache->handleScrollPositionChanged(this);
frame().loader().saveScrollState();
}
void FrameView::didScrollTimerFired(Timer<FrameView>*)
{
if (m_frame->document() && m_frame->document()->renderer()) {
ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAllImageResourcePriorities();
}
}
void FrameView::updateLayersAndCompositingAfterScrollIfNeeded()
{
if (!hasViewportConstrainedObjects())
return;
RefPtr<FrameView> protect(this);
if (!m_nestedLayoutCount) {
updateWidgetPositions();
if (RenderView* renderView = this->renderView())
renderView->layer()->updateLayerPositionsAfterDocumentScroll();
}
if (RenderView* renderView = this->renderView())
renderView->compositor()->setNeedsCompositingUpdate(CompositingUpdateOnScroll);
}
void FrameView::updateFixedElementRepaintRectsAfterScroll()
{
if (!hasViewportConstrainedObjects())
return;
ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
RenderObject* renderer = *it;
ASSERT(renderer->style()->hasViewportConstrainedPosition());
ASSERT(renderer->hasLayer());
RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
if (layer->compositingState() == PaintsIntoOwnBacking)
continue;
if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForBoundsOutOfView
|| layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotCompositedForNoVisibleContent)
continue;
layer->repainter().computeRepaintRectsIncludingDescendants();
}
}
bool FrameView::shouldRubberBandInDirection(ScrollDirection direction) const
{
Page* page = frame().page();
if (!page)
return ScrollView::shouldRubberBandInDirection(direction);
return page->chrome().client().shouldRubberBandInDirection(direction);
}
bool FrameView::isRubberBandInProgress() const
{
if (scrollbarsSuppressed())
return false;
if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
return scrollAnimator->isRubberBandInProgress();
return false;
}
HostWindow* FrameView::hostWindow() const
{
Page* page = frame().page();
if (!page)
return 0;
return &page->chrome();
}
void FrameView::repaintContentRectangle(const IntRect& r)
{
ASSERT(repaintAllowed());
ASSERT(!m_frame->ownerElement());
if (m_isTrackingRepaints) {
IntRect repaintRect = r;
repaintRect.move(-scrollOffset());
m_trackedRepaintRects.append(repaintRect);
}
ScrollView::repaintContentRectangle(r);
}
void FrameView::contentsResized()
{
if (isMainFrame() && m_frame->document()) {
if (FastTextAutosizer* textAutosizer = m_frame->document()->fastTextAutosizer())
textAutosizer->updatePageInfoInAllFrames();
}
ScrollView::contentsResized();
if (RenderView* renderView = this->renderView()) {
renderView->setNeedsLayout(MarkContainingBlockChain, 0, DontRepaintLayer);
}
}
void FrameView::scrollbarExistenceDidChange()
{
if (!frame().view())
return;
bool useOverlayScrollbars = ScrollbarTheme::theme()->usesOverlayScrollbars();
if (!useOverlayScrollbars && needsLayout())
layout();
if (renderView() && renderView()->usesCompositing()) {
renderView()->compositor()->frameViewScrollbarsExistenceDidChange();
if (!useOverlayScrollbars)
renderView()->compositor()->frameViewDidChangeSize();
}
}
void FrameView::handleLoadCompleted()
{
autoSizeIfEnabled();
}
void FrameView::scheduleRelayout()
{
ASSERT(m_frame->view() == this);
if (isSubtreeLayout()) {
m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
m_layoutSubtreeRoot = 0;
}
if (!m_layoutSchedulingEnabled)
return;
if (!needsLayout())
return;
if (!m_frame->document()->shouldScheduleLayout())
return;
InspectorInstrumentation::didInvalidateLayout(m_frame.get());
if (m_hasPendingLayout)
return;
m_hasPendingLayout = true;
page()->animator().scheduleVisualUpdate();
}
static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* descendant)
{
for (RenderObject* r = descendant; r; r = r->container()) {
if (r == ancestor)
return true;
}
return false;
}
void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
{
ASSERT(m_frame->view() == this);
RenderView* renderView = this->renderView();
if (renderView && renderView->needsLayout()) {
if (relayoutRoot)
relayoutRoot->markContainingBlocksForLayout(false);
return;
}
if (layoutPending() || !m_layoutSchedulingEnabled) {
if (m_layoutSubtreeRoot != relayoutRoot) {
if (isObjectAncestorContainerOf(m_layoutSubtreeRoot, relayoutRoot)) {
relayoutRoot->markContainingBlocksForLayout(false, m_layoutSubtreeRoot);
ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
} else if (isSubtreeLayout() && isObjectAncestorContainerOf(relayoutRoot, m_layoutSubtreeRoot)) {
m_layoutSubtreeRoot->markContainingBlocksForLayout(false, relayoutRoot);
m_layoutSubtreeRoot = relayoutRoot;
ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
InspectorInstrumentation::didInvalidateLayout(m_frame.get());
} else {
if (isSubtreeLayout())
m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
m_layoutSubtreeRoot = 0;
relayoutRoot->markContainingBlocksForLayout(false);
InspectorInstrumentation::didInvalidateLayout(m_frame.get());
}
}
} else if (m_layoutSchedulingEnabled) {
m_layoutSubtreeRoot = relayoutRoot;
ASSERT(!m_layoutSubtreeRoot->container() || !m_layoutSubtreeRoot->container()->needsLayout());
InspectorInstrumentation::didInvalidateLayout(m_frame.get());
m_hasPendingLayout = true;
page()->animator().scheduleVisualUpdate();
}
}
bool FrameView::layoutPending() const
{
return m_hasPendingLayout;
}
bool FrameView::isInPerformLayout() const
{
ASSERT(m_inPerformLayout == (lifecycle().state() == DocumentLifecycle::InPerformLayout));
return m_inPerformLayout;
}
bool FrameView::needsLayout() const
{
RenderView* renderView = this->renderView();
return layoutPending()
|| (renderView && renderView->needsLayout())
|| isSubtreeLayout();
}
void FrameView::setNeedsLayout()
{
if (RenderView* renderView = this->renderView())
renderView->setNeedsLayout();
}
bool FrameView::isTransparent() const
{
return m_isTransparent;
}
void FrameView::setTransparent(bool isTransparent)
{
m_isTransparent = isTransparent;
DisableCompositingQueryAsserts disabler;
if (renderView() && renderView()->layer()->hasCompositedLayerMapping())
renderView()->layer()->compositedLayerMapping()->updateContentsOpaque();
}
bool FrameView::hasOpaqueBackground() const
{
return !m_isTransparent && !m_baseBackgroundColor.hasAlpha();
}
Color FrameView::baseBackgroundColor() const
{
return m_baseBackgroundColor;
}
void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
{
m_baseBackgroundColor = backgroundColor;
if (renderView() && renderView()->layer()->hasCompositedLayerMapping()) {
CompositedLayerMappingPtr compositedLayerMapping = renderView()->layer()->compositedLayerMapping();
compositedLayerMapping->updateContentsOpaque();
if (compositedLayerMapping->mainGraphicsLayer())
compositedLayerMapping->mainGraphicsLayer()->setNeedsDisplay();
}
recalculateScrollbarOverlayStyle();
}
void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent)
{
for (LocalFrame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext(m_frame.get())) {
if (FrameView* view = frame->view()) {
view->setTransparent(transparent);
view->setBaseBackgroundColor(backgroundColor);
}
}
}
void FrameView::scrollToAnchor()
{
RefPtr<Node> anchorNode = m_maintainScrollPositionAnchor;
if (!anchorNode)
return;
if (!anchorNode->renderer())
return;
LayoutRect rect;
if (anchorNode != m_frame->document())
rect = anchorNode->boundingBox();
anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
cache->handleScrolledToAnchor(anchorNode.get());
m_maintainScrollPositionAnchor = anchorNode;
}
bool FrameView::updateWidgets()
{
ASSERT(!m_widgetUpdateSet.isEmpty());
if (m_nestedLayoutCount > 1 || m_widgetUpdateSet.isEmpty())
return true;
EmbeddedObjectSet objects;
objects.swap(m_widgetUpdateSet);
for (EmbeddedObjectSet::iterator it = objects.begin(); it != objects.end(); ++it) {
RenderEmbeddedObject& object = **it;
HTMLPlugInElement* element = toHTMLPlugInElement(object.node());
if (!element)
continue;
if (object.showsUnavailablePluginIndicator())
continue;
if (element->needsWidgetUpdate())
element->updateWidget();
object.updateWidgetPosition();
m_widgetUpdateSet.remove(&object);
}
return m_widgetUpdateSet.isEmpty();
}
void FrameView::updateWidgetsTimerFired(Timer<FrameView>*)
{
ASSERT(!isInPerformLayout());
RefPtr<FrameView> protect(this);
m_updateWidgetsTimer.stop();
for (unsigned i = 0; i < maxUpdateWidgetsIterations; ++i) {
if (updateWidgets())
return;
}
}
void FrameView::flushAnyPendingPostLayoutTasks()
{
ASSERT(!isInPerformLayout());
if (m_postLayoutTasksTimer.isActive())
performPostLayoutTasks();
if (m_updateWidgetsTimer.isActive())
updateWidgetsTimerFired(0);
}
void FrameView::scheduleUpdateWidgetsIfNecessary()
{
ASSERT(!isInPerformLayout());
if (m_updateWidgetsTimer.isActive() || m_widgetUpdateSet.isEmpty())
return;
m_updateWidgetsTimer.startOneShot(0, FROM_HERE);
}
void FrameView::performPostLayoutTasks()
{
ASSERT(!isInPerformLayout());
TRACE_EVENT0("webkit", "FrameView::performPostLayoutTasks");
RefPtr<FrameView> protect(this);
m_postLayoutTasksTimer.stop();
m_frame->selection().setCaretRectNeedsUpdate();
{
DisableCompositingQueryAsserts disabler;
m_frame->selection().updateAppearance();
}
ASSERT(m_frame->document());
if (m_nestedLayoutCount <= 1) {
if (m_firstLayoutCallbackPending)
m_firstLayoutCallbackPending = false;
if (!m_frame->document()->parsing() && m_frame->loader().stateMachine()->committedFirstRealDocumentLoad())
m_isVisuallyNonEmpty = true;
if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
m_firstVisuallyNonEmptyLayoutCallbackPending = false;
m_frame->loader().client()->dispatchDidFirstVisuallyNonEmptyLayout();
}
}
FontFaceSet::didLayout(*m_frame->document());
updateWidgetPositions();
if (!renderView())
return;
scheduleUpdateWidgetsIfNecessary();
if (Page* page = m_frame->page()) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->notifyLayoutUpdated();
}
scrollToAnchor();
sendResizeEventIfNeeded();
}
void FrameView::sendResizeEventIfNeeded()
{
ASSERT(m_frame);
RenderView* renderView = this->renderView();
if (!renderView || renderView->document().printing())
return;
IntSize currentSize = layoutSize(IncludeScrollbars);
float currentZoomFactor = renderView->style()->zoom();
bool shouldSendResizeEvent = currentSize != m_lastViewportSize || currentZoomFactor != m_lastZoomFactor;
m_lastViewportSize = currentSize;
m_lastZoomFactor = currentZoomFactor;
if (!shouldSendResizeEvent)
return;
m_frame->document()->enqueueResizeEvent();
if (isMainFrame())
InspectorInstrumentation::didResizeMainFrame(m_frame->page());
}
void FrameView::postLayoutTimerFired(Timer<FrameView>*)
{
performPostLayoutTasks();
}
void FrameView::updateCounters()
{
RenderView* view = renderView();
if (!view->hasRenderCounters())
return;
for (RenderObject* renderer = view; renderer; renderer = renderer->nextInPreOrder()) {
if (!renderer->isCounter())
continue;
toRenderCounter(renderer)->updateCounter();
}
}
void FrameView::autoSizeIfEnabled()
{
if (!m_shouldAutoSize)
return;
if (m_inAutoSize)
return;
TemporaryChange<bool> changeInAutoSize(m_inAutoSize, true);
Document* document = frame().document();
if (!document || !document->isActive())
return;
Element* documentElement = document->documentElement();
if (!documentElement)
return;
if (!m_didRunAutosize)
resize(frameRect().width(), m_minAutoSize.height());
IntSize size = frameRect().size();
for (int i = 0; i < 2; i++) {
document->updateLayoutIgnorePendingStylesheets();
RenderView* renderView = document->renderView();
if (!renderView)
return;
int width = renderView->minPreferredLogicalWidth();
RenderBox* documentRenderBox = documentElement->renderBox();
if (!documentRenderBox)
return;
int height = documentRenderBox->scrollHeight();
IntSize newSize(width, height);
if (newSize.width() > m_maxAutoSize.width()) {
RefPtr<Scrollbar> localHorizontalScrollbar = horizontalScrollbar();
if (!localHorizontalScrollbar)
localHorizontalScrollbar = createScrollbar(HorizontalScrollbar);
if (!localHorizontalScrollbar->isOverlayScrollbar())
newSize.setHeight(newSize.height() + localHorizontalScrollbar->height());
} else if (newSize.height() > m_maxAutoSize.height()) {
RefPtr<Scrollbar> localVerticalScrollbar = verticalScrollbar();
if (!localVerticalScrollbar)
localVerticalScrollbar = createScrollbar(VerticalScrollbar);
if (!localVerticalScrollbar->isOverlayScrollbar())
newSize.setWidth(newSize.width() + localVerticalScrollbar->width());
}
newSize = newSize.expandedTo(m_minAutoSize);
ScrollbarMode horizonalScrollbarMode = ScrollbarAlwaysOff;
if (newSize.width() > m_maxAutoSize.width()) {
newSize.setWidth(m_maxAutoSize.width());
horizonalScrollbarMode = ScrollbarAlwaysOn;
}
ScrollbarMode verticalScrollbarMode = ScrollbarAlwaysOff;
if (newSize.height() > m_maxAutoSize.height()) {
newSize.setHeight(m_maxAutoSize.height());
verticalScrollbarMode = ScrollbarAlwaysOn;
}
if (newSize == size)
continue;
if (m_didRunAutosize && size.height() <= m_maxAutoSize.height() && size.width() <= m_maxAutoSize.width()
&& !m_frame->document()->loadEventFinished() && (newSize.height() < size.height() || newSize.width() < size.width()))
break;
resize(newSize.width(), newSize.height());
setVerticalScrollbarLock(false);
setHorizontalScrollbarLock(false);
setScrollbarModes(horizonalScrollbarMode, verticalScrollbarMode, true, true);
}
m_didRunAutosize = true;
}
void FrameView::updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow)
{
if (!m_viewportRenderer)
return;
if (m_overflowStatusDirty) {
m_horizontalOverflow = horizontalOverflow;
m_verticalOverflow = verticalOverflow;
m_overflowStatusDirty = false;
return;
}
bool horizontalOverflowChanged = (m_horizontalOverflow != horizontalOverflow);
bool verticalOverflowChanged = (m_verticalOverflow != verticalOverflow);
if (horizontalOverflowChanged || verticalOverflowChanged) {
m_horizontalOverflow = horizontalOverflow;
m_verticalOverflow = verticalOverflow;
RefPtrWillBeRawPtr<OverflowEvent> event = OverflowEvent::create(horizontalOverflowChanged, horizontalOverflow, verticalOverflowChanged, verticalOverflow);
event->setTarget(m_viewportRenderer->node());
m_frame->document()->enqueueAnimationFrameEvent(event.release());
}
}
IntRect FrameView::windowClipRect(IncludeScrollbarsInRect scrollbarInclusion) const
{
ASSERT(m_frame->view() == this);
if (paintsEntireContents())
return IntRect(IntPoint(), contentsSize());
IntRect clipRect = contentsToWindow(visibleContentRect(scrollbarInclusion));
if (!m_frame->ownerElement())
return clipRect;
HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement();
FrameView* parentView = ownerElement->document().view();
if (parentView)
clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement));
return clipRect;
}
IntRect FrameView::windowClipRectForFrameOwner(const HTMLFrameOwnerElement* ownerElement) const
{
if (!ownerElement->renderer())
return windowClipRect();
const RenderLayer* enclosingLayer = ownerElement->renderer()->enclosingLayer();
if (!enclosingLayer)
return windowClipRect();
DisableCompositingQueryAsserts disabler;
IntRect clipRect = contentsToWindow(pixelSnappedIntRect(enclosingLayer->clipper().childrenClipRect()));
return intersection(clipRect, windowClipRect());
}
bool FrameView::isActive() const
{
Page* page = frame().page();
return page && page->focusController().isActive();
}
void FrameView::scrollTo(const IntSize& newOffset)
{
LayoutSize offset = scrollOffset();
ScrollView::scrollTo(newOffset);
if (offset != scrollOffset()) {
updateLayersAndCompositingAfterScrollIfNeeded();
scrollPositionChanged();
}
frame().loader().client()->didChangeScrollOffset();
}
void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
{
IntRect dirtyRect = rect;
dirtyRect.moveBy(scrollbar->location());
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && isInPerformLayout()) {
if (scrollbar == verticalScrollbar()) {
m_verticalBarDamage = dirtyRect;
m_hasVerticalBarDamage = true;
} else {
m_horizontalBarDamage = dirtyRect;
m_hasHorizontalBarDamage = true;
}
} else {
invalidateRect(dirtyRect);
}
}
void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const
{
if (!m_tickmarks.isEmpty())
tickmarks = m_tickmarks;
else
tickmarks = frame().document()->markers().renderedRectsForMarkers(DocumentMarker::TextMatch);
}
IntRect FrameView::windowResizerRect() const
{
Page* page = frame().page();
if (!page)
return IntRect();
return page->chrome().windowResizerRect();
}
void FrameView::setVisibleContentScaleFactor(float visibleContentScaleFactor)
{
if (m_visibleContentScaleFactor == visibleContentScaleFactor)
return;
m_visibleContentScaleFactor = visibleContentScaleFactor;
updateScrollbars(scrollOffset());
}
void FrameView::setInputEventsTransformForEmulation(const IntSize& offset, float contentScaleFactor)
{
m_inputEventsOffsetForEmulation = offset;
m_inputEventsScaleFactorForEmulation = contentScaleFactor;
}
IntSize FrameView::inputEventsOffsetForEmulation() const
{
return m_inputEventsOffsetForEmulation;
}
float FrameView::inputEventsScaleFactor() const
{
return visibleContentScaleFactor() * m_inputEventsScaleFactorForEmulation;
}
bool FrameView::scrollbarsCanBeActive() const
{
if (m_frame->view() != this)
return false;
return !!m_frame->document();
}
IntRect FrameView::scrollableAreaBoundingBox() const
{
RenderPart* ownerRenderer = frame().ownerRenderer();
if (!ownerRenderer)
return frameRect();
return ownerRenderer->absoluteContentQuad().enclosingBoundingBox();
}
bool FrameView::isScrollable()
{
IntSize contentsSize = this->contentsSize();
IntSize visibleContentSize = visibleContentRect().size();
if ((contentsSize.height() <= visibleContentSize.height() && contentsSize.width() <= visibleContentSize.width()))
return false;
HTMLFrameOwnerElement* owner = m_frame->ownerElement();
if (owner && (!owner->renderer() || !owner->renderer()->visibleToHitTesting()))
return false;
ScrollbarMode horizontalMode;
ScrollbarMode verticalMode;
calculateScrollbarModesForLayoutAndSetViewportRenderer(horizontalMode, verticalMode, RulesFromWebContentOnly);
if (horizontalMode == ScrollbarAlwaysOff && verticalMode == ScrollbarAlwaysOff)
return false;
return true;
}
void FrameView::updateScrollableAreaSet()
{
FrameView* parentFrameView = this->parentFrameView();
if (!parentFrameView)
return;
if (!isScrollable()) {
parentFrameView->removeScrollableArea(this);
return;
}
parentFrameView->addScrollableArea(this);
}
bool FrameView::shouldSuspendScrollAnimations() const
{
return m_frame->loader().state() != FrameStateComplete;
}
void FrameView::scrollbarStyleChanged(int newStyle, bool forceUpdate)
{
if (!isMainFrame())
return;
if (forceUpdate)
ScrollView::scrollbarStyleChanged(newStyle, forceUpdate);
}
void FrameView::notifyPageThatContentAreaWillPaint() const
{
Page* page = m_frame->page();
if (!page)
return;
contentAreaWillPaint();
if (!m_scrollableAreas)
return;
for (HashSet<ScrollableArea*>::const_iterator it = m_scrollableAreas->begin(), end = m_scrollableAreas->end(); it != end; ++it) {
ScrollableArea* scrollableArea = *it;
if (!scrollableArea->scrollbarsCanBeActive())
continue;
scrollableArea->contentAreaWillPaint();
}
}
bool FrameView::scrollAnimatorEnabled() const
{
return m_frame->settings() && m_frame->settings()->scrollAnimatorEnabled();
}
void FrameView::updateAnnotatedRegions()
{
Document* document = m_frame->document();
if (!document->hasAnnotatedRegions())
return;
Vector<AnnotatedRegionValue> newRegions;
document->renderBox()->collectAnnotatedRegions(newRegions);
if (newRegions == document->annotatedRegions())
return;
document->setAnnotatedRegions(newRegions);
if (Page* page = m_frame->page())
page->chrome().client().annotatedRegionsChanged();
}
void FrameView::updateScrollCorner()
{
RefPtr<RenderStyle> cornerStyle;
IntRect cornerRect = scrollCornerRect();
Document* doc = m_frame->document();
if (doc && !cornerRect.isEmpty()) {
if (Element* body = doc->body()) {
if (RenderObject* renderer = body->renderer())
cornerStyle = renderer->getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), renderer->style());
}
if (!cornerStyle) {
if (Element* docElement = doc->documentElement()) {
if (RenderObject* renderer = docElement->renderer())
cornerStyle = renderer->getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), renderer->style());
}
}
if (!cornerStyle) {
if (RenderPart* renderer = m_frame->ownerRenderer())
cornerStyle = renderer->getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), renderer->style());
}
}
if (cornerStyle) {
if (!m_scrollCorner)
m_scrollCorner = RenderScrollbarPart::createAnonymous(doc);
m_scrollCorner->setStyle(cornerStyle.release());
invalidateScrollCorner(cornerRect);
} else if (m_scrollCorner) {
m_scrollCorner->destroy();
m_scrollCorner = 0;
}
ScrollView::updateScrollCorner();
}
void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect)
{
if (context->updatingControlTints()) {
updateScrollCorner();
return;
}
if (m_scrollCorner) {
bool needsBackgorund = isMainFrame();
if (needsBackgorund)
context->fillRect(cornerRect, baseBackgroundColor());
m_scrollCorner->paintIntoRect(context, cornerRect.location(), cornerRect);
return;
}
ScrollView::paintScrollCorner(context, cornerRect);
}
void FrameView::paintScrollbar(GraphicsContext* context, Scrollbar* bar, const IntRect& rect)
{
bool needsBackgorund = bar->isCustomScrollbar() && isMainFrame();
if (needsBackgorund) {
IntRect toFill = bar->frameRect();
toFill.intersect(rect);
context->fillRect(toFill, baseBackgroundColor());
}
ScrollView::paintScrollbar(context, bar, rect);
}
Color FrameView::documentBackgroundColor() const
{
Color result = baseBackgroundColor();
if (!frame().document())
return result;
Element* htmlElement = frame().document()->documentElement();
Element* bodyElement = frame().document()->body();
if (htmlElement && htmlElement->renderer())
result = result.blend(htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor));
if (bodyElement && bodyElement->renderer())
result = result.blend(bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor));
return result;
}
bool FrameView::hasCustomScrollbars() const
{
const HashSet<RefPtr<Widget> >* viewChildren = children();
HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) {
Widget* widget = current->get();
if (widget->isFrameView()) {
if (toFrameView(widget)->hasCustomScrollbars())
return true;
} else if (widget->isScrollbar()) {
Scrollbar* scrollbar = static_cast<Scrollbar*>(widget);
if (scrollbar->isCustomScrollbar())
return true;
}
}
return false;
}
FrameView* FrameView::parentFrameView() const
{
if (!parent())
return 0;
if (LocalFrame* parentFrame = m_frame->tree().parent())
return parentFrame->view();
return 0;
}
void FrameView::updateControlTints()
{
if (m_frame->document()->url().isEmpty())
return;
if (!RenderTheme::theme().supportsControlTints() && !hasCustomScrollbars())
return;
RefPtr<FrameView> protector(this);
updateLayoutAndStyleForPainting();
GraphicsContext context(0);
context.setUpdatingControlTints(true);
paint(&context, frameRect());
}
bool FrameView::wasScrolledByUser() const
{
return m_wasScrolledByUser;
}
void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
{
if (m_inProgrammaticScroll)
return;
m_maintainScrollPositionAnchor = nullptr;
m_wasScrolledByUser = wasScrolledByUser;
}
void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
{
Document* document = m_frame->document();
#ifndef NDEBUG
bool fillWithRed;
if (document->printing())
fillWithRed = false;
else if (m_frame->ownerElement())
fillWithRed = false;
else if (isTransparent())
fillWithRed = false;
else if (m_paintBehavior & PaintBehaviorSelectionOnly)
fillWithRed = false;
else if (m_nodeToDraw)
fillWithRed = false;
else
fillWithRed = true;
if (fillWithRed)
p->fillRect(rect, Color(0xFF, 0, 0));
#endif
RenderView* renderView = this->renderView();
if (!renderView) {
WTF_LOG_ERROR("called FrameView::paint with nil renderer");
return;
}
ASSERT(!needsLayout());
if (needsLayout())
return;
InspectorInstrumentation::willPaint(renderView, 0);
bool isTopLevelPainter = !s_inPaintContents;
s_inPaintContents = true;
FontCachePurgePreventer fontCachePurgePreventer;
PaintBehavior oldPaintBehavior = m_paintBehavior;
if (FrameView* parentView = parentFrameView()) {
if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
}
if (m_paintBehavior == PaintBehaviorNormal)
document->markers().invalidateRenderedRectsForMarkersInRect(rect);
if (document->printing())
m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
ASSERT(!m_isPainting);
m_isPainting = true;
RenderObject* renderer = m_nodeToDraw ? m_nodeToDraw->renderer() : 0;
RenderLayer* rootLayer = renderView->layer();
#ifndef NDEBUG
renderView->assertSubtreeIsLaidOut();
RenderObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(rootLayer->renderer());
#endif
RenderObject* enclosingLayerRenderer = renderer ? renderer->enclosingLayer()->renderer() : 0;
rootLayer->paint(p, rect, m_paintBehavior, enclosingLayerRenderer);
if (rootLayer->containsDirtyOverlayScrollbars())
rootLayer->paintOverlayScrollbars(p, rect, m_paintBehavior, renderer);
m_isPainting = false;
m_paintBehavior = oldPaintBehavior;
m_lastPaintTime = currentTime();
if (document->annotatedRegionsDirty())
updateAnnotatedRegions();
if (isTopLevelPainter) {
s_currentFrameTimeStamp = currentTime();
s_inPaintContents = false;
}
InspectorInstrumentation::didPaint(renderView, 0, p, rect);
}
void FrameView::setPaintBehavior(PaintBehavior behavior)
{
m_paintBehavior = behavior;
}
PaintBehavior FrameView::paintBehavior() const
{
return m_paintBehavior;
}
bool FrameView::isPainting() const
{
return m_isPainting;
}
void FrameView::setNodeToDraw(Node* node)
{
m_nodeToDraw = node;
}
void FrameView::paintOverhangAreas(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect)
{
if (context->paintingDisabled())
return;
if (m_frame->document()->printing())
return;
if (isMainFrame()) {
if (m_frame->page()->chrome().client().paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect))
return;
}
ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect);
}
void FrameView::updateLayoutAndStyleForPainting()
{
RefPtr<FrameView> protector(this);
updateLayoutAndStyleIfNeededRecursive();
if (RenderView* view = renderView()) {
ASSERT(!view->needsLayout());
view->compositor()->updateCompositingLayers();
view->compositor()->scheduleAnimationIfNeeded();
}
scrollContentsIfNeededRecursive();
}
void FrameView::updateLayoutAndStyleIfNeededRecursive()
{
m_frame->document()->updateRenderTreeIfNeeded();
if (needsLayout())
layout();
Vector<RefPtr<FrameView> > frameViews;
for (LocalFrame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
if (FrameView* view = child->view())
frameViews.append(view);
}
const Vector<RefPtr<FrameView> >::iterator end = frameViews.end();
for (Vector<RefPtr<FrameView> >::iterator it = frameViews.begin(); it != end; ++it)
(*it)->updateLayoutAndStyleIfNeededRecursive();
ASSERT(!needsLayout());
}
void FrameView::enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize)
{
ASSERT(!enable || !minSize.isEmpty());
ASSERT(minSize.width() <= maxSize.width());
ASSERT(minSize.height() <= maxSize.height());
if (m_shouldAutoSize == enable && m_minAutoSize == minSize && m_maxAutoSize == maxSize)
return;
m_shouldAutoSize = enable;
m_minAutoSize = minSize;
m_maxAutoSize = maxSize;
m_didRunAutosize = false;
setLayoutSizeFixedToFrameSize(enable);
setNeedsLayout();
scheduleRelayout();
if (m_shouldAutoSize)
return;
setVerticalScrollbarLock(false);
setHorizontalScrollbarLock(false);
setScrollbarModes(ScrollbarAuto, ScrollbarAuto);
}
void FrameView::forceLayout(bool allowSubtree)
{
layout(allowSubtree);
}
void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor)
{
if (RenderView* renderView = this->renderView()) {
float pageLogicalWidth = renderView->style()->isHorizontalWritingMode() ? pageSize.width() : pageSize.height();
float pageLogicalHeight = renderView->style()->isHorizontalWritingMode() ? pageSize.height() : pageSize.width();
LayoutUnit flooredPageLogicalWidth = static_cast<LayoutUnit>(pageLogicalWidth);
LayoutUnit flooredPageLogicalHeight = static_cast<LayoutUnit>(pageLogicalHeight);
renderView->setLogicalWidth(flooredPageLogicalWidth);
renderView->setPageLogicalHeight(flooredPageLogicalHeight);
renderView->setNeedsLayoutAndPrefWidthsRecalc();
forceLayout();
bool horizontalWritingMode = renderView->style()->isHorizontalWritingMode();
const LayoutRect& documentRect = renderView->documentRect();
LayoutUnit docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
if (docLogicalWidth > pageLogicalWidth) {
FloatSize expectedPageSize(std::min<float>(documentRect.width().toFloat(), pageSize.width() * maximumShrinkFactor), std::min<float>(documentRect.height().toFloat(), pageSize.height() * maximumShrinkFactor));
FloatSize maxPageSize = m_frame->resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), expectedPageSize);
pageLogicalWidth = horizontalWritingMode ? maxPageSize.width() : maxPageSize.height();
pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
flooredPageLogicalWidth = static_cast<LayoutUnit>(pageLogicalWidth);
flooredPageLogicalHeight = static_cast<LayoutUnit>(pageLogicalHeight);
renderView->setLogicalWidth(flooredPageLogicalWidth);
renderView->setPageLogicalHeight(flooredPageLogicalHeight);
renderView->setNeedsLayoutAndPrefWidthsRecalc();
forceLayout();
const LayoutRect& updatedDocumentRect = renderView->documentRect();
LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumentRect.height() : updatedDocumentRect.width();
LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRect.y() : updatedDocumentRect.x();
LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocumentRect.maxX() : updatedDocumentRect.maxY();
LayoutUnit clippedLogicalLeft = 0;
if (!renderView->style()->isLeftToRightDirection())
clippedLogicalLeft = docLogicalRight - pageLogicalWidth;
LayoutRect overflow(clippedLogicalLeft, docLogicalTop, pageLogicalWidth, docLogicalHeight);
if (!horizontalWritingMode)
overflow = overflow.transposedRect();
renderView->clearLayoutOverflow();
renderView->addLayoutOverflow(overflow);
}
}
adjustViewSize();
}
IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRect& rendererRect) const
{
IntRect rect = pixelSnappedIntRect(enclosingLayoutRect(renderer->localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox()));
rect.moveBy(-scrollPosition());
return rect;
}
IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect& viewRect) const
{
IntRect rect = viewRect;
rect.moveBy(scrollPosition());
rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(), UseTransforms)));
return rect;
}
IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntPoint& rendererPoint) const
{
IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, UseTransforms));
point.moveBy(-scrollPosition());
return point;
}
IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoint& viewPoint) const
{
IntPoint point = viewPoint;
point += IntSize(scrollX(), scrollY());
return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms));
}
IntRect FrameView::convertToContainingView(const IntRect& localRect) const
{
if (const ScrollView* parentScrollView = toScrollView(parent())) {
if (parentScrollView->isFrameView()) {
const FrameView* parentView = toFrameView(parentScrollView);
RenderPart* renderer = m_frame->ownerRenderer();
if (!renderer)
return localRect;
IntRect rect(localRect);
rect.move(renderer->borderLeft() + renderer->paddingLeft(),
renderer->borderTop() + renderer->paddingTop());
return parentView->convertFromRenderer(renderer, rect);
}
return Widget::convertToContainingView(localRect);
}
return localRect;
}
IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const
{
if (const ScrollView* parentScrollView = toScrollView(parent())) {
if (parentScrollView->isFrameView()) {
const FrameView* parentView = toFrameView(parentScrollView);
RenderPart* renderer = m_frame->ownerRenderer();
if (!renderer)
return parentRect;
IntRect rect = parentView->convertToRenderer(renderer, parentRect);
rect.move(-renderer->borderLeft() - renderer->paddingLeft(),
-renderer->borderTop() - renderer->paddingTop());
return rect;
}
return Widget::convertFromContainingView(parentRect);
}
return parentRect;
}
IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const
{
if (const ScrollView* parentScrollView = toScrollView(parent())) {
if (parentScrollView->isFrameView()) {
const FrameView* parentView = toFrameView(parentScrollView);
RenderPart* renderer = m_frame->ownerRenderer();
if (!renderer)
return localPoint;
IntPoint point(localPoint);
point.move(renderer->borderLeft() + renderer->paddingLeft(),
renderer->borderTop() + renderer->paddingTop());
return parentView->convertFromRenderer(renderer, point);
}
return Widget::convertToContainingView(localPoint);
}
return localPoint;
}
IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
{
if (const ScrollView* parentScrollView = toScrollView(parent())) {
if (parentScrollView->isFrameView()) {
const FrameView* parentView = toFrameView(parentScrollView);
RenderPart* renderer = m_frame->ownerRenderer();
if (!renderer)
return parentPoint;
IntPoint point = parentView->convertToRenderer(renderer, parentPoint);
point.move(-renderer->borderLeft() - renderer->paddingLeft(),
-renderer->borderTop() - renderer->paddingTop());
return point;
}
return Widget::convertFromContainingView(parentPoint);
}
return parentPoint;
}
void FrameView::setTracksRepaints(bool trackRepaints)
{
if (trackRepaints == m_isTrackingRepaints)
return;
for (LocalFrame* frame = m_frame->tree().top(); frame; frame = frame->tree().traverseNext()) {
if (RenderView* renderView = frame->contentRenderer())
renderView->compositor()->setTracksRepaints(trackRepaints);
}
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"),
"FrameView::setTracksRepaints", "enabled", trackRepaints);
resetTrackedRepaints();
m_isTrackingRepaints = trackRepaints;
}
void FrameView::resetTrackedRepaints()
{
m_trackedRepaintRects.clear();
if (RenderView* renderView = this->renderView())
renderView->compositor()->resetTrackedRepaintRects();
}
String FrameView::trackedRepaintRectsAsText() const
{
TextStream ts;
if (!m_trackedRepaintRects.isEmpty()) {
ts << "(repaint rects\n";
for (size_t i = 0; i < m_trackedRepaintRects.size(); ++i)
ts << " (rect " << m_trackedRepaintRects[i].x() << " " << m_trackedRepaintRects[i].y() << " " << m_trackedRepaintRects[i].width() << " " << m_trackedRepaintRects[i].height() << ")\n";
ts << ")\n";
}
return ts.release();
}
void FrameView::addResizerArea(RenderBox* resizerBox)
{
if (!m_resizerAreas)
m_resizerAreas = adoptPtr(new ResizerAreaSet);
m_resizerAreas->add(resizerBox);
}
void FrameView::removeResizerArea(RenderBox* resizerBox)
{
if (!m_resizerAreas)
return;
ResizerAreaSet::iterator it = m_resizerAreas->find(resizerBox);
if (it != m_resizerAreas->end())
m_resizerAreas->remove(it);
}
bool FrameView::addScrollableArea(ScrollableArea* scrollableArea)
{
ASSERT(scrollableArea);
if (!m_scrollableAreas)
m_scrollableAreas = adoptPtr(new ScrollableAreaSet);
return m_scrollableAreas->add(scrollableArea).isNewEntry;
}
bool FrameView::removeScrollableArea(ScrollableArea* scrollableArea)
{
if (!m_scrollableAreas)
return false;
ScrollableAreaSet::iterator it = m_scrollableAreas->find(scrollableArea);
if (it == m_scrollableAreas->end())
return false;
m_scrollableAreas->remove(it);
return true;
}
bool FrameView::containsScrollableArea(const ScrollableArea* scrollableArea) const
{
ASSERT(scrollableArea);
if (!m_scrollableAreas || !scrollableArea)
return false;
return m_scrollableAreas->contains(const_cast<ScrollableArea*>(scrollableArea));
}
void FrameView::removeChild(Widget* widget)
{
if (widget->isFrameView())
removeScrollableArea(toFrameView(widget));
ScrollView::removeChild(widget);
}
bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent)
{
#if !USE(RUBBER_BANDING)
if (!isScrollable())
return false;
#endif
if (!canHaveScrollbars())
return false;
return ScrollableArea::handleWheelEvent(wheelEvent);
}
bool FrameView::isVerticalDocument() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return true;
return renderView->style()->isHorizontalWritingMode();
}
bool FrameView::isFlippedDocument() const
{
RenderView* renderView = this->renderView();
if (!renderView)
return false;
return renderView->style()->isFlippedBlocksWritingMode();
}
AXObjectCache* FrameView::axObjectCache() const
{
if (frame().document())
return frame().document()->existingAXObjectCache();
return 0;
}
void FrameView::setCursor(const Cursor& cursor)
{
Page* page = frame().page();
if (!page)
return;
page->chrome().setCursor(cursor);
}
bool FrameView::isMainFrame() const
{
return m_frame->isMainFrame();
}
void FrameView::frameRectsChanged()
{
if (layoutSizeFixedToFrameSize())
setLayoutSizeInternal(frameRect().size());
ScrollView::frameRectsChanged();
}
void FrameView::setLayoutSizeInternal(const IntSize& size)
{
if (m_layoutSize == size)
return;
m_layoutSize = size;
contentsResized();
}
void FrameView::didAddScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
{
ScrollableArea::didAddScrollbar(scrollbar, orientation);
if (AXObjectCache* cache = axObjectCache())
cache->handleScrollbarUpdate(this);
}
void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation orientation)
{
ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
if (AXObjectCache* cache = axObjectCache()) {
cache->remove(scrollbar);
cache->handleScrollbarUpdate(this);
}
}
}