void Renderer::onContentSizeDirty() { _isPageSplitted = false; if (hasFlag(RenderFlag::PaginatedLayout)) { Size s = _owner->getContentSize(); if (shouldSplitPages(s)) { s.width /= 2.0f; _isPageSplitted = true; } s.width -= _pageMargin.horizontal(); s.height -= _pageMargin.vertical(); setSurfaceSize(s); } else { setSurfaceSize(_owner->getContentSize()); } }
void HTMLCanvasElement::reset() { if (m_ignoreReset) return; resetDirtyRect(); bool ok; bool hadImageBuffer = hasImageBuffer(); int w = getAttribute(widthAttr).toInt(&ok); if (!ok || w < 0) w = DefaultWidth; int h = getAttribute(heightAttr).toInt(&ok); if (!ok || h < 0) h = DefaultHeight; if (m_contextStateSaver) { // Reset to the initial graphics context state. m_contextStateSaver->restore(); m_contextStateSaver->save(); } if (m_context && m_context->is2d()) toCanvasRenderingContext2D(m_context.get())->reset(); IntSize oldSize = size(); IntSize newSize(w, h); // If the size of an existing buffer matches, we can just clear it instead of reallocating. // This optimization is only done for 2D canvases for now. if (hadImageBuffer && oldSize == newSize && m_context && m_context->is2d()) { if (!m_didClearImageBuffer) clearImageBuffer(); return; } setSurfaceSize(newSize); if (m_context && m_context->is3d() && oldSize != size()) toWebGLRenderingContext(m_context.get())->reshape(width(), height()); if (RenderObject* renderer = this->renderer()) { if (renderer->isCanvas()) { if (oldSize != size()) { toRenderHTMLCanvas(renderer)->canvasSizeChanged(); if (renderBox() && renderBox()->hasAcceleratedCompositing()) renderBox()->contentChanged(CanvasChanged); } if (hadImageBuffer) renderer->setShouldDoFullPaintInvalidation(true); } } WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator end = m_observers.end(); for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator it = m_observers.begin(); it != end; ++it) (*it)->canvasResized(this); }