Commit c43a7d1c authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}

https://bugs.webkit.org/show_bug.cgi?id=67250

Reviewed by Simon Fraser.

Source/WebCore:

No new tests because there's no change in functionality.

* WebCore.exp.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForDocument):
* dom/Element.cpp:
(WebCore::Element::getClientRects):
(WebCore::Element::getBoundingClientRect):
* dom/Range.cpp:
(WebCore::adjustFloatQuadsForScrollAndAbsoluteZoomAndPageScale):
* loader/HistoryController.cpp:
(WebCore::HistoryController::restoreScrollPositionAndViewState):
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::pageScaleFactor):
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::setPageScaleFactor):
* page/Page.h:
(WebCore::Page::pageScaleFactor):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame):
(WebCore::RenderLayerCompositor::pageScaleFactor):
* rendering/RenderView.cpp:
(WebCore::RenderView::paintBoxDecorations):

Source/WebKit/chromium:

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::pageScaleFactor):
(WebKit::WebViewImpl::scalePage):

Source/WebKit/gtk:

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::scalePageBy):

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _scaleWebView:atOrigin:]):
(-[WebView _viewScaleFactor]):

Source/WebKit/qt:

* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::scalePageBy):

Source/WebKit2:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scalePage):
(WebKit::WebPage::pageScaleFactor):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3dbf0bb6
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
No new tests because there's no change in functionality.
* WebCore.exp.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForDocument):
* dom/Element.cpp:
(WebCore::Element::getClientRects):
(WebCore::Element::getBoundingClientRect):
* dom/Range.cpp:
(WebCore::adjustFloatQuadsForScrollAndAbsoluteZoomAndPageScale):
* loader/HistoryController.cpp:
(WebCore::HistoryController::restoreScrollPositionAndViewState):
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::pageScaleFactor):
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::setPageScaleFactor):
* page/Page.h:
(WebCore::Page::pageScaleFactor):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame):
(WebCore::RenderLayerCompositor::pageScaleFactor):
* rendering/RenderView.cpp:
(WebCore::RenderView::paintBoxDecorations):
2011-09-09 Dominic Mazzoni <dmazzoni@google.com>
AX: Images within anchors causes crash
......@@ -720,6 +720,7 @@ __ZN7WebCore4Page27setJavaScriptURLsAreAllowedEb
__ZN7WebCore4Page31setCustomHTMLTokenizerChunkSizeEi
__ZN7WebCore4Page31setCustomHTMLTokenizerTimeDelayEd
__ZN7WebCore4Page32setMemoryCacheClientCallsEnabledEb
__ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointE
__ZN7WebCore4Page37setInLowQualityImageInterpolationModeEb
__ZN7WebCore4Page6goBackEv
__ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE
......@@ -744,13 +745,13 @@ __ZN7WebCore5Frame17setPageZoomFactorEf
__ZN7WebCore5Frame17setTextZoomFactorEf
__ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
__ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
__ZNK7WebCore5Frame15pageScaleFactorEv
__ZN7WebCore5Frame25setPageAndTextZoomFactorsEff
__ZN7WebCore5Frame27resizePageRectsKeepingRatioERKNS_9FloatSizeES3_
__ZN7WebCore5Frame28searchForLabelsBeforeElementEP7NSArrayPNS_7ElementEPmPb
__ZN7WebCore5Frame6createEPNS_4PageEPNS_21HTMLFrameOwnerElementEPNS_17FrameLoaderClientE
__ZN7WebCore5Frame7setViewEN3WTF10PassRefPtrINS_9FrameViewEEE
__ZN7WebCore5Frame9nodeImageEPNS_4NodeE
__ZN7WebCore5Frame9scalePageEfRKNS_8IntPointE
__ZN7WebCore5FrameD1Ev
__ZN7WebCore5Image9nullImageEv
__ZN7WebCore5Image12supportsTypeERKN3WTF6StringE
......
......@@ -1060,7 +1060,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
documentStyle->setDisplay(BLOCK);
documentStyle->setRTLOrdering(document->visuallyOrdered() ? VisualOrder : LogicalOrder);
documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
documentStyle->setPageScaleTransform(frame ? frame->pageScaleFactor() : 1);
documentStyle->setPageScaleTransform(document->page() ? document->page()->pageScaleFactor() : 1);
documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
Element* docElement = document->documentElement();
......
......@@ -514,10 +514,8 @@ PassRefPtr<ClientRectList> Element::getClientRects()
renderBoxModelObject->absoluteQuads(quads);
float pageScale = 1;
if (Page* page = document()->page()) {
if (Frame* frame = page->mainFrame())
pageScale = frame->pageScaleFactor();
}
if (Page* page = document()->page())
pageScale = page->pageScaleFactor();
if (FrameView* view = document()->view()) {
LayoutRect visibleContentRect = view->visibleContentRect();
......@@ -565,10 +563,8 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect()
}
adjustFloatRectForAbsoluteZoom(result, renderer());
if (Page* page = document()->page()) {
if (Frame* frame = page->mainFrame())
adjustFloatRectForPageScale(result, frame->pageScaleFactor());
}
if (Page* page = document()->page())
adjustFloatRectForPageScale(result, page->pageScaleFactor());
return ClientRect::create(result);
}
......
......@@ -2028,10 +2028,8 @@ static void adjustFloatQuadsForScrollAndAbsoluteZoomAndPageScale(Vector<FloatQua
return;
float pageScale = 1;
if (Page* page = document->page()) {
if (Frame* frame = page->mainFrame())
pageScale = frame->pageScaleFactor();
}
if (Page* page = document->page())
pageScale = page->pageScaleFactor();
LayoutRect visibleContentRect = view->visibleContentRect();
for (size_t i = 0; i < quads.size(); ++i) {
......
......@@ -125,7 +125,8 @@ void HistoryController::restoreScrollPositionAndViewState()
if (FrameView* view = m_frame->view()) {
if (!view->wasScrolledByUser()) {
view->setScrollPosition(m_currentItem->scrollPoint());
m_frame->scalePage(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint());
if (Page* page = m_frame->page())
page->setPageScaleFactor(m_currentItem->pageScaleFactor(), m_currentItem->scrollPoint());
}
}
}
......
......@@ -160,7 +160,6 @@ inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoader
, m_animationController(this)
, m_pageZoomFactor(parentPageZoomFactor(this))
, m_textZoomFactor(parentTextZoomFactor(this))
, m_pageScaleFactor(1)
#if ENABLE(ORIENTATION_EVENTS)
, m_orientation(0)
#endif
......@@ -1026,6 +1025,14 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
page->backForward()->markPagesForFullStyleRecalc();
}
float Frame::pageScaleFactor() const
{
Page* page = this->page();
if (!page)
return 1;
return page->pageScaleFactor();
}
#if USE(ACCELERATED_COMPOSITING)
void Frame::deviceOrPageScaleFactorChanged()
{
......@@ -1037,33 +1044,6 @@ void Frame::deviceOrPageScaleFactorChanged()
root->compositor()->deviceOrPageScaleFactorChanged();
}
#endif
void Frame::scalePage(float scale, const LayoutPoint& origin)
{
Document* document = this->document();
if (!document)
return;
if (scale != m_pageScaleFactor) {
m_pageScaleFactor = scale;
if (document->renderer())
document->renderer()->setNeedsLayout(true);
document->recalcStyle(Node::Force);
#if USE(ACCELERATED_COMPOSITING)
deviceOrPageScaleFactorChanged();
#endif
}
if (FrameView* view = this->view()) {
if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
view->layout();
view->setScrollPosition(origin);
}
}
void Frame::notifyChromeClientWheelEventHandlerCountChanged() const
{
// Ensure that this method is being called on the main frame of the page.
......
......@@ -161,9 +161,9 @@ namespace WebCore {
float textZoomFactor() const { return m_textZoomFactor; }
void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
// FIXME: These functions should move to Page.
void scalePage(float scale, const LayoutPoint& origin);
float pageScaleFactor() const { return m_pageScaleFactor; }
// Convenience helper method that grabs the pageScaleFactor from Page.
float pageScaleFactor() const;
#if USE(ACCELERATED_COMPOSITING)
void deviceOrPageScaleFactorChanged();
#endif
......@@ -241,8 +241,6 @@ namespace WebCore {
float m_pageZoomFactor;
float m_textZoomFactor;
float m_pageScaleFactor;
#if ENABLE(ORIENTATION_EVENTS)
int m_orientation;
#endif
......
......@@ -147,6 +147,7 @@ Page::Page(PageClients& pageClients)
, m_cookieEnabled(true)
, m_areMemoryCacheClientCallsEnabled(true)
, m_mediaVolume(1)
, m_pageScaleFactor(1)
, m_deviceScaleFactor(1)
, m_javaScriptURLsAreAllowed(true)
, m_didLoadUserStyleSheet(false)
......@@ -608,6 +609,34 @@ void Page::setMediaVolume(float volume)
}
}
void Page::setPageScaleFactor(float scale, const LayoutPoint& origin)
{
if (scale == m_pageScaleFactor)
return;
Document* document = mainFrame()->document();
m_pageScaleFactor = scale;
if (document->renderer())
document->renderer()->setNeedsLayout(true);
document->recalcStyle(Node::Force);
#if USE(ACCELERATED_COMPOSITING)
mainFrame()->deviceOrPageScaleFactorChanged();
#endif
if (FrameView* view = document->view()) {
if (view->scrollPosition() != origin) {
if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
view->layout();
view->setScrollPosition(origin);
}
}
}
void Page::setDeviceScaleFactor(float scaleFactor)
{
if (m_deviceScaleFactor == scaleFactor)
......
......@@ -23,6 +23,7 @@
#include "FrameLoaderTypes.h"
#include "FindOptions.h"
#include "LayoutTypes.h"
#include "PageVisibilityState.h"
#include "PlatformString.h"
#include "ViewportArguments.h"
......@@ -243,6 +244,9 @@ namespace WebCore {
float mediaVolume() const { return m_mediaVolume; }
void setMediaVolume(float volume);
void setPageScaleFactor(float scale, const LayoutPoint& origin);
float pageScaleFactor() const { return m_pageScaleFactor; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
void setDeviceScaleFactor(float);
......@@ -369,6 +373,7 @@ namespace WebCore {
bool m_areMemoryCacheClientCallsEnabled;
float m_mediaVolume;
float m_pageScaleFactor;
float m_deviceScaleFactor;
bool m_javaScriptURLsAreAllowed;
......
......@@ -1251,7 +1251,7 @@ bool RenderLayerCompositor::shouldPropagateCompositingToEnclosingFrame() const
// document, or the parent is already compositing, or the main frame is scaled.
Frame* frame = m_renderView->frameView()->frame();
Page* page = frame ? frame->page() : 0;
if (page->mainFrame()->pageScaleFactor() != 1)
if (page && page->pageScaleFactor() != 1)
return true;
RenderPart* frameRenderer = toRenderPart(renderer);
......@@ -1566,7 +1566,7 @@ float RenderLayerCompositor::pageScaleFactor() const
Page* page = frame->page();
if (!page)
return 1;
return page->mainFrame()->pageScaleFactor();
return page->pageScaleFactor();
}
void RenderLayerCompositor::didCommitChangesForLayer(const GraphicsLayer*) const
......
......@@ -29,6 +29,7 @@
#include "GraphicsContext.h"
#include "HTMLFrameOwnerElement.h"
#include "HitTestResult.h"
#include "Page.h"
#include "RenderFlowThread.h"
#include "RenderLayer.h"
#include "RenderSelectionInfo.h"
......@@ -226,10 +227,9 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
RenderBox* rootBox = rootRenderer->isBox() ? toRenderBox(rootRenderer) : 0;
rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox->width() >= width() && rootBox->height() >= height();
}
float pageScaleFactor = 1;
if (Frame* frame = m_frameView->frame())
pageScaleFactor = frame->pageScaleFactor();
Page* page = document()->page();
float pageScaleFactor = page ? page->pageScaleFactor() : 1;
// If painting will entirely fill the view, no need to fill the background.
if (rootFillsViewport && rendererObscuresBackground(firstChild()) && pageScaleFactor >= 1)
......
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::pageScaleFactor):
(WebKit::WebViewImpl::scalePage):
2011-09-09 Hao Zheng <zhenghao@chromium.org>
[chromium] Implement DRT support for Android.
......
......@@ -1881,11 +1881,7 @@ float WebViewImpl::pageScaleFactor() const
if (!page())
return 1.0;
Frame* frame = page()->mainFrame();
if (!frame)
return 1.0;
return frame->pageScaleFactor();
return page()->pageScaleFactor();
}
void WebViewImpl::scalePage(float scaleFactor, WebPoint origin)
......@@ -1893,11 +1889,7 @@ void WebViewImpl::scalePage(float scaleFactor, WebPoint origin)
if (!page())
return;
Frame* frame = page()->mainFrame();
if (!frame)
return;
frame->scalePage(scaleFactor, origin);
page()->setPageScaleFactor(scaleFactor, origin);
}
bool WebViewImpl::isFixedLayoutModeEnabled() const
......
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::scalePageBy):
2011-09-08 Daniel Bates <dbates@webkit.org>
Fix the GTK build after <http://trac.webkit.org/changeset/94810>
......
......@@ -803,9 +803,5 @@ bool DumpRenderTreeSupportGtk::shouldClose(WebKitWebFrame* frame)
void DumpRenderTreeSupportGtk::scalePageBy(WebKitWebView* webView, float scaleFactor, float x, float y)
{
Frame* coreFrame = core(webView)->mainFrame();
if (!coreFrame)
return;
coreFrame->scalePage(scaleFactor, IntPoint(x, y));
core(webView)->setPageScaleFactor(scaleFactor, IntPoint(x, y));
}
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
* WebView/WebView.mm:
(-[WebView _scaleWebView:atOrigin:]):
(-[WebView _viewScaleFactor]):
2011-09-09 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (5/7)
......
......@@ -2732,20 +2732,12 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
- (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin
{
Frame* coreFrame = [self _mainCoreFrame];
if (!coreFrame)
return;
coreFrame->scalePage(scale, IntPoint(origin));
_private->page->setPageScaleFactor(scale, IntPoint(origin));
}
- (float)_viewScaleFactor
{
Frame* coreFrame = [self _mainCoreFrame];
if (!coreFrame)
return 1;
return coreFrame->pageScaleFactor();
return _private->page->pageScaleFactor();
}
- (void)_setUseFixedLayout:(BOOL)fixed
......
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::scalePageBy):
2011-09-09 Zeno Albisser <zeno.albisser@nokia.com>
[Qt] QWebElement::encloseWith doesn't work at all
......
......@@ -785,7 +785,8 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, c
void DumpRenderTreeSupportQt::scalePageBy(QWebFrame* frame, float scalefactor, const QPoint& origin)
{
WebCore::Frame* coreFrame = QWebFramePrivate::core(frame);
coreFrame->scalePage(scalefactor, origin);
if (Page* page = coreFrame->page())
page->setPageScaleFactor(scalefactor, origin);
}
void DumpRenderTreeSupportQt::activeMockDeviceOrientationClient(bool b)
......
2011-09-09 Fady Samuel <fsamuel@chromium.org>
Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}
https://bugs.webkit.org/show_bug.cgi?id=67250
Reviewed by Simon Fraser.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scalePage):
(WebKit::WebPage::pageScaleFactor):
2011-09-09 Mark Hahnenberg <mhahnenberg@apple.com>
Unzip initialization lists and constructors in JSCell hierarchy (5/7)
......
......@@ -443,7 +443,8 @@ void WebFrameLoaderClient::dispatchDidCommitLoad()
// Only restore the scale factor for standard frame loads (of the main frame).
if (m_frame->isMainFrame() && m_frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) {
if (m_frame->coreFrame()->pageScaleFactor() != 1)
Page* page = m_frame->coreFrame()->page();
if (page && page->pageScaleFactor() != 1)
webPage->scalePage(1, IntPoint());
}
}
......
......@@ -777,20 +777,14 @@ void WebPage::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFa
void WebPage::scalePage(double scale, const IntPoint& origin)
{
Frame* frame = m_mainFrame->coreFrame();
if (!frame)
return;
frame->scalePage(scale, origin);
m_page->setPageScaleFactor(scale, origin);
send(Messages::WebPageProxy::PageScaleFactorDidChange(scale));
}
double WebPage::pageScaleFactor() const
{
Frame* frame = m_mainFrame->coreFrame();
if (!frame)
return 1;
return frame->pageScaleFactor();
return m_page->pageScaleFactor();
}
void WebPage::setDeviceScaleFactor(float scaleFactor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment