Commit 0f442a78 authored by darin@apple.com's avatar darin@apple.com

2010-09-17 Darin Adler <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * src/FrameLoaderClientImpl.cpp:
        (WebKit::FrameLoaderClientImpl::createPlugin):
        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::setZoomLevel):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * Api/qwebframe.cpp:
        (QWebFrame::setTextSizeMultiplier):
        (QWebFrame::textSizeMultiplier):
        (QWebFrame::setZoomFactor):
        (QWebFrame::zoomFactor):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * webkit/webkitwebview.cpp:
        (webkit_web_view_get_zoom_level):
        (webkit_web_view_apply_zoom_level):
        (webkit_web_view_set_full_content_zoom):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * WebView.cpp:
        (WebView::setZoomMultiplier):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * WebFrame.cpp:
        (wxWebFrame::IncreaseTextSize):
        (wxWebFrame::DecreaseTextSize):
        (wxWebFrame::ResetTextSize):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * WebView/WebView.mm:
        (-[WebView _setZoomMultiplier:isTextOnly:]):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * ewk/ewk_frame.cpp:
        (ewk_frame_zoom_get):
        (ewk_frame_zoom_set):
        (ewk_frame_zoom_text_only_set):
        Call functions on Frame instead of FrameView.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        Moved zoom level back from FrameView to Frame.
        I had forgotten that FrameView's lifetime is much shorter than
        Frame's, and until that is fixed it's best to leave this on Frame.

        * WebCore.exp.in: Updated.

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::styleForDocument):
        (WebCore::CSSStyleSelector::applyProperty):
        (WebCore::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
        * dom/Document.cpp:
        (WebCore::Document::nodesFromRect):
        (WebCore::Document::elementFromPoint):
        (WebCore::Document::caretRangeFromPoint):
        * dom/MouseRelatedEvent.cpp:
        (WebCore::contentsX):
        (WebCore::contentsY):
        (WebCore::pageZoomFactor):
        * dom/Node.cpp:
        (WebCore::Node::dispatchMouseEvent):
        (WebCore::Node::dispatchWheelEvent):
        * html/HTMLBodyElement.cpp:
        (WebCore::adjustForZoom):
        (WebCore::HTMLBodyElement::scrollLeft):
        (WebCore::HTMLBodyElement::setScrollLeft):
        (WebCore::HTMLBodyElement::scrollTop):
        (WebCore::HTMLBodyElement::setScrollTop):
        (WebCore::HTMLBodyElement::scrollHeight):
        (WebCore::HTMLBodyElement::scrollWidth):
        * html/ImageDocument.cpp:
        (WebCore::pageZoomFactor):
        (WebCore::ImageDocument::scale):
        (WebCore::ImageDocument::imageFitsInWindow):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::innerHeight):
        (WebCore::DOMWindow::innerWidth):
        (WebCore::DOMWindow::scrollX):
        (WebCore::DOMWindow::scrollY):
        (WebCore::DOMWindow::scrollTo):
        * page/DragController.cpp:
        (WebCore::elementUnderMouse):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::zoomFactor):
        * svg/SVGSVGElement.cpp:
        (WebCore::SVGSVGElement::currentScale):
        (WebCore::SVGSVGElement::setCurrentScale):
        Get zoom factor from Frame rather than FrameView.

        * page/Frame.cpp:
        (WebCore::parentPageZoomFactor): Moved back here from FrameView.
        (WebCore::parentTextZoomFactor): Ditto.
        (WebCore::Frame::Frame): Ditto.
        (WebCore::Frame::setPageZoomFactor): Ditto.
        (WebCore::Frame::setTextZoomFactor): Ditto.
        (WebCore::Frame::setPageAndTextZoomFactors): Ditto.

        * page/Frame.h: Moved functions and data for zooming back here
        from FrameView.

        * page/FrameView.cpp:
        (WebCore::FrameView::FrameView):
        * page/FrameView.h:
        Removed code from here.
2010-09-17  Daniel Bates  <dbates@rim.com>

        Reviewed by Darin Adler.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * fast/css/preserve-user-specified-zoom-level-on-reload.html: Added.
        * platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.checksum: Added.
        * platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.png: Added.
        * platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.txt: Added.
2010-09-17  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
        https://bugs.webkit.org/show_bug.cgi?id=42863

        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::textZoomFactor):
        (WebKit::WebPage::setTextZoomFactor):
        (WebKit::WebPage::pageZoomFactor):
        (WebKit::WebPage::setPageZoomFactor):
        (WebKit::WebPage::setPageAndTextZoomFactors):
        Call functions on Frame instead of FrameView.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c9fecd1f
2010-09-17 Daniel Bates <dbates@rim.com>
Reviewed by Darin Adler.
REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
https://bugs.webkit.org/show_bug.cgi?id=42863
* fast/css/preserve-user-specified-zoom-level-on-reload.html: Added.
* platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.checksum: Added.
* platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.png: Added.
* platform/mac/fast/css/preserve-user-specified-zoom-level-on-reload-expected.txt: Added.
2010-09-17 Tony Chang <tony@chromium.org>
Reviewed by Kent Tamura.
<html>
<head>
<script>
function runTest()
{
if (!window.layoutTestController)
return;
if (!window.eventSender)
return;
if (!window.sessionStorage)
return
layoutTestController.waitUntilDone();
if (sessionStorage.testCompleted)
layoutTestController.notifyDone();
else {
// Note, it is sufficient to zoom-in only once, but so as to make it easier
// for a human to compare the pixel test results we zoom-in up to Safari's
// maximum zoom level, which at the time of writing (09/17) is 6.
const MaxZoomIn = 6;
for (var i = 0; i < MaxZoomIn; ++i)
eventSender.zoomPageIn();
sessionStorage.testCompleted = true;
document.location.reload(true);
}
}
window.onload = runTest;
</script>
</head>
<body>
<p>This test ensures that we preserve the user-specified zoom level of the page on reload.</p>
</body>
</html>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (23,23) size 754x530
RenderBlock {P} at (0,0) size 754x165
RenderText {#text} at (0,0) size 714x165
text run at (0,0) width 714: "This test ensures that we preserve the"
text run at (0,55) width 714: "user-specified zoom level of the page"
text run at (0,110) width 191: "on reload."
2010-09-17 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
REGRESSION (r60104): Zoom level is unexpectedly reset on page reload
https://bugs.webkit.org/show_bug.cgi?id=42863
Moved zoom level back from FrameView to Frame.
I had forgotten that FrameView's lifetime is much shorter than
Frame's, and until that is fixed it's best to leave this on Frame.
* WebCore.exp.in: Updated.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForDocument):
(WebCore::CSSStyleSelector::applyProperty):
(WebCore::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
(WebCore::Document::elementFromPoint):
(WebCore::Document::caretRangeFromPoint):
* dom/MouseRelatedEvent.cpp:
(WebCore::contentsX):
(WebCore::contentsY):
(WebCore::pageZoomFactor):
* dom/Node.cpp:
(WebCore::Node::dispatchMouseEvent):
(WebCore::Node::dispatchWheelEvent):
* html/HTMLBodyElement.cpp:
(WebCore::adjustForZoom):
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
(WebCore::HTMLBodyElement::setScrollTop):
(WebCore::HTMLBodyElement::scrollHeight):
(WebCore::HTMLBodyElement::scrollWidth):
* html/ImageDocument.cpp:
(WebCore::pageZoomFactor):
(WebCore::ImageDocument::scale):
(WebCore::ImageDocument::imageFitsInWindow):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::innerHeight):
(WebCore::DOMWindow::innerWidth):
(WebCore::DOMWindow::scrollX):
(WebCore::DOMWindow::scrollY):
(WebCore::DOMWindow::scrollTo):
* page/DragController.cpp:
(WebCore::elementUnderMouse):
* rendering/RenderView.cpp:
(WebCore::RenderView::zoomFactor):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::currentScale):
(WebCore::SVGSVGElement::setCurrentScale):
Get zoom factor from Frame rather than FrameView.
* page/Frame.cpp:
(WebCore::parentPageZoomFactor): Moved back here from FrameView.
(WebCore::parentTextZoomFactor): Ditto.
(WebCore::Frame::Frame): Ditto.
(WebCore::Frame::setPageZoomFactor): Ditto.
(WebCore::Frame::setTextZoomFactor): Ditto.
(WebCore::Frame::setPageAndTextZoomFactors): Ditto.
* page/Frame.h: Moved functions and data for zooming back here
from FrameView.
* page/FrameView.cpp:
(WebCore::FrameView::FrameView):
* page/FrameView.h:
Removed code from here.
2010-09-17 Matthew Delaney <mdelaney@apple.com>
Reviewed by Simon Fraser.
......@@ -580,8 +580,11 @@ __ZN7WebCore5Cache13getStatisticsEv
__ZN7WebCore5Cache13setCapacitiesEjjj
__ZN7WebCore5Frame10createViewERKNS_7IntSizeERKNS_5ColorEbS3_bNS_13ScrollbarModeEbS7_b
__ZN7WebCore5Frame14frameForWidgetEPKNS_6WidgetE
__ZN7WebCore5Frame17setPageZoomFactorEf
__ZN7WebCore5Frame17setTextZoomFactorEf
__ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
__ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
__ZN7WebCore5Frame25setPageAndTextZoomFactorsEff
__ZN7WebCore5Frame28searchForLabelsBeforeElementEP7NSArrayPNS_7ElementEPmPb
__ZN7WebCore5Frame6createEPNS_4PageEPNS_21HTMLFrameOwnerElementEPNS_17FrameLoaderClientE
__ZN7WebCore5Frame7setViewEN3WTF10PassRefPtrINS_9FrameViewEEE
......@@ -767,15 +770,12 @@ __ZN7WebCore9FrameView14setTransparentEb
__ZN7WebCore9FrameView15setMarginHeightEi
__ZN7WebCore9FrameView16adjustPageHeightEPffff
__ZN7WebCore9FrameView16setPaintBehaviorEj
__ZN7WebCore9FrameView17setPageZoomFactorEf
__ZN7WebCore9FrameView17setTextZoomFactorEf
__ZN7WebCore9FrameView18updateControlTintsEv
__ZN7WebCore9FrameView20enterCompositingModeEv
__ZN7WebCore9FrameView21flushDeferredRepaintsEv
__ZN7WebCore9FrameView22setBaseBackgroundColorENS_5ColorE
__ZN7WebCore9FrameView23updateCanHaveScrollbarsEv
__ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_5Frame19AdjustViewSizeOrNotE
__ZN7WebCore9FrameView25setPageAndTextZoomFactorsEff
__ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
__ZN7WebCore9FrameView29syncCompositingStateRecursiveEv
__ZN7WebCore9FrameView37updateLayoutAndStyleIfNeededRecursiveEv
......@@ -846,7 +846,6 @@ __ZN7WebCore9toElementEN3JSC7JSValueE
__ZN7WebCoreeqERKNS_19ResourceRequestBaseES2_
__ZNK3JSC8Bindings10RootObject12globalObjectEv
__ZNK3WTF6String14createCFStringEv
__ZNK7WebCore6Editor34selectionStartHasSpellingMarkerForEii
__ZNK7WebCore10FloatPointcv8_NSPointEv
__ZNK7WebCore10PluginData16supportsMimeTypeERKN3WTF6StringE
__ZNK7WebCore10RenderText16linesBoundingBoxEv
......@@ -1022,6 +1021,7 @@ __ZNK7WebCore6Editor22selectionStartHasStyleEPNS_19CSSStyleDeclarationE
__ZNK7WebCore6Editor23getCompositionSelectionERjS1_
__ZNK7WebCore6Editor30applyEditingStyleToBodyElementEv
__ZNK7WebCore6Editor31fontAttributesForSelectionStartEv
__ZNK7WebCore6Editor34selectionStartHasSpellingMarkerForEii
__ZNK7WebCore6Editor37baseWritingDirectionForSelectionStartEv
__ZNK7WebCore6Editor6canCutEv
__ZNK7WebCore6Editor7Command11isSupportedEv
......
......@@ -1099,12 +1099,12 @@ void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
{
FrameView* view = document->view();
Frame* frame = document->frame();
RefPtr<RenderStyle> documentStyle = RenderStyle::create();
documentStyle->setDisplay(BLOCK);
documentStyle->setVisuallyOrdered(document->visuallyOrdered());
documentStyle->setZoom(view ? view->pageZoomFactor() : 1);
documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
FontDescription fontDescription;
fontDescription.setUsePrinterFont(document->printing());
......@@ -4149,8 +4149,8 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
else if (CSSPrimitiveValue::isUnitTypeLength(type)) {
double multiplier = zoomFactor;
if (m_style->textSizeAdjust()) {
if (FrameView* view = m_checker.m_document->view())
multiplier *= view->textZoomFactor();
if (Frame* frame = m_checker.m_document->frame())
multiplier *= frame->textZoomFactor();
}
lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, multiplier), Fixed);
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
......@@ -6274,8 +6274,8 @@ float CSSStyleSelector::getComputedSizeFromSpecifiedSize(Document* document, Ren
float zoomFactor = 1.0f;
if (!useSVGZoomRules) {
zoomFactor = style->effectiveZoom();
if (document->view())
zoomFactor *= document->view()->textZoomFactor();
if (Frame* frame = document->frame())
zoomFactor *= frame->textZoomFactor();
}
// We support two types of minimum font size. The first is a hard override that applies to
......
......@@ -1060,7 +1060,7 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned
if (!frameView)
return 0;
float zoomFactor = frameView->pageZoomFactor();
float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(centerX * zoomFactor + view()->scrollX(), centerY * zoomFactor + view()->scrollY()));
IntSize padding(hPadding, vPadding);
......@@ -1113,7 +1113,7 @@ Element* Document::elementFromPoint(int x, int y) const
if (!frameView)
return 0;
float zoomFactor = frameView->pageZoomFactor();
float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY()));
if (!frameView->visibleContentRect().contains(point))
......@@ -1143,7 +1143,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
if (!frameView)
return 0;
float zoomFactor = frameView->pageZoomFactor();
float zoomFactor = frame->pageZoomFactor();
IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY()));
if (!frameView->visibleContentRect().contains(point))
......
......@@ -57,7 +57,7 @@ static int contentsX(AbstractView* abstractView)
FrameView* frameView = frame->view();
if (!frameView)
return 0;
return frameView->scrollX() / frameView->pageZoomFactor();
return frameView->scrollX() / frame->pageZoomFactor();
}
static int contentsY(AbstractView* abstractView)
......@@ -70,7 +70,7 @@ static int contentsY(AbstractView* abstractView)
FrameView* frameView = frame->view();
if (!frameView)
return 0;
return frameView->scrollY() / frameView->pageZoomFactor();
return frameView->scrollY() / frame->pageZoomFactor();
}
MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, PassRefPtr<AbstractView> viewArg,
......@@ -126,10 +126,7 @@ static float pageZoomFactor(UIEvent* event)
Frame* frame = window->frame();
if (!frame)
return 1;
FrameView* view = frame->view();
if (!view)
return 1;
return view->pageZoomFactor();
return frame->pageZoomFactor();
}
void MouseRelatedEvent::computePageLocation()
......
......@@ -2845,8 +2845,8 @@ bool Node::dispatchMouseEvent(const AtomicString& eventType, int button, int det
int adjustedPageX = pageX;
int adjustedPageY = pageY;
if (FrameView* view = document()->view()) {
float pageZoom = view->pageZoomFactor();
if (Frame* frame = document()->frame()) {
float pageZoom = frame->pageZoomFactor();
if (pageZoom != 1.0f) {
// Adjust our pageX and pageY to account for the page zoom.
adjustedPageX = lroundf(pageX / pageZoom);
......@@ -2902,8 +2902,8 @@ void Node::dispatchWheelEvent(PlatformWheelEvent& e)
int adjustedPageX = pos.x();
int adjustedPageY = pos.y();
if (FrameView* view = document()->view()) {
float pageZoom = view->pageZoomFactor();
if (Frame* frame = document()->frame()) {
float pageZoom = frame->pageZoomFactor();
if (pageZoom != 1.0f) {
// Adjust our pageX and pageY to account for the page zoom.
adjustedPageX = lroundf(pos.x() / pageZoom);
......
......@@ -252,9 +252,9 @@ void HTMLBodyElement::setVLink(const String& value)
setAttribute(vlinkAttr, value);
}
static int adjustForZoom(int value, FrameView* frameView)
static int adjustForZoom(int value, Document* document)
{
float zoomFactor = frameView->pageZoomFactor();
float zoomFactor = document->frame()->pageZoomFactor();
if (zoomFactor == 1)
return value;
// Needed because of truncation (rather than rounding) when scaling up.
......@@ -266,57 +266,63 @@ static int adjustForZoom(int value, FrameView* frameView)
int HTMLBodyElement::scrollLeft() const
{
// Update the document's layout.
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? adjustForZoom(view->scrollX(), view) : 0;
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
return view ? adjustForZoom(view->scrollX(), document) : 0;
}
void HTMLBodyElement::setScrollLeft(int scrollLeft)
{
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
Frame* frame = document->frame();
if (!frame)
return;
FrameView* view = frame->view();
if (!view)
return;
view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * view->pageZoomFactor()), view->scrollY()));
view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor()), view->scrollY()));
}
int HTMLBodyElement::scrollTop() const
{
// Update the document's layout.
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? adjustForZoom(view->scrollY(), view) : 0;
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
return view ? adjustForZoom(view->scrollY(), document) : 0;
}
void HTMLBodyElement::setScrollTop(int scrollTop)
{
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
Frame* frame = document->frame();
if (!frame)
return;
FrameView* view = frame->view();
if (!view)
return;
view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * view->pageZoomFactor())));
view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor())));
}
int HTMLBodyElement::scrollHeight() const
{
// Update the document's layout.
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? adjustForZoom(view->contentsHeight(), view) : 0;
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
return view ? adjustForZoom(view->contentsHeight(), document) : 0;
}
int HTMLBodyElement::scrollWidth() const
{
// Update the document's layout.
Document* doc = document();
doc->updateLayoutIgnorePendingStylesheets();
FrameView* view = doc->view();
return view ? adjustForZoom(view->contentsWidth(), view) : 0;
Document* document = this->document();
document->updateLayoutIgnorePendingStylesheets();
FrameView* view = document->view();
return view ? adjustForZoom(view->contentsWidth(), document) : 0;
}
void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
......
......@@ -117,10 +117,10 @@ inline PassRefPtr<ImageDocumentElement> ImageDocumentElement::create(ImageDocume
// --------
static float pageZoomFactor(Document* document)
static float pageZoomFactor(const Document* document)
{
FrameView* view = document->view();
return view ? view->pageZoomFactor() : 1;
Frame* frame = document->frame();
return frame ? frame->pageZoomFactor() : 1;
}
void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, int, bool)
......@@ -231,7 +231,7 @@ float ImageDocument::scale() const
if (!view)
return 1;
IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
IntSize windowSize = IntSize(view->width(), view->height());
float widthScale = (float)windowSize.width() / imageSize.width();
......@@ -319,8 +319,10 @@ bool ImageDocument::imageFitsInWindow() const
return true;
FrameView* view = frame()->view();
if (!view)
return true;
IntSize imageSize = m_imageElement->cachedImage()->imageSize(view->pageZoomFactor());
IntSize imageSize = m_imageElement->cachedImage()->imageSize(pageZoomFactor(this));
IntSize windowSize = IntSize(view->width(), view->height());
return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
......
......@@ -1053,7 +1053,7 @@ int DOMWindow::innerHeight() const
if (!view)
return 0;
return static_cast<int>(view->height() / view->pageZoomFactor());
return static_cast<int>(view->height() / m_frame->pageZoomFactor());
}
int DOMWindow::innerWidth() const
......@@ -1065,7 +1065,7 @@ int DOMWindow::innerWidth() const
if (!view)
return 0;
return static_cast<int>(view->width() / view->pageZoomFactor());
return static_cast<int>(view->width() / m_frame->pageZoomFactor());
}
int DOMWindow::screenX() const
......@@ -1103,7 +1103,7 @@ int DOMWindow::scrollX() const
m_frame->document()->updateLayoutIgnorePendingStylesheets();
return static_cast<int>(view->scrollX() / view->pageZoomFactor());
return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
}
int DOMWindow::scrollY() const
......@@ -1117,7 +1117,7 @@ int DOMWindow::scrollY() const
m_frame->document()->updateLayoutIgnorePendingStylesheets();
return static_cast<int>(view->scrollY() / view->pageZoomFactor());
return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
}
bool DOMWindow::closed() const
......@@ -1337,8 +1337,8 @@ void DOMWindow::scrollTo(int x, int y) const
if (!view)
return;
int zoomedX = static_cast<int>(x * view->pageZoomFactor());
int zoomedY = static_cast<int>(y * view->pageZoomFactor());
int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
view->setScrollPosition(IntPoint(zoomedX, zoomedY));
}
......
......@@ -270,8 +270,8 @@ static HTMLInputElement* asFileInput(Node* node)
static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p)
{
FrameView* view = documentUnderMouse->view();
float zoomFactor = view ? view->pageZoomFactor() : 1;
Frame* frame = documentUnderMouse->frame();
float zoomFactor = frame ? frame->pageZoomFactor() : 1;
IntPoint point = roundedIntPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
......
......@@ -129,6 +129,22 @@ static inline Frame* parentFromOwnerElement(HTMLFrameOwnerElement* ownerElement)
return ownerElement->document()->frame();
}
static inline float parentPageZoomFactor(Frame* frame)
{
Frame* parent = frame->tree()->parent();
if (!parent)
return 1;
return frame->pageZoomFactor();
}
static inline float parentTextZoomFactor(Frame* frame)
{
Frame* parent = frame->tree()->parent();
if (!parent)
return 1;
return frame->textZoomFactor();
}
inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* frameLoaderClient)
: m_page(page)
, m_treeNode(this, parentFromOwnerElement(ownerElement))
......@@ -141,6 +157,8 @@ inline Frame::Frame(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoader
, m_eventHandler(this)
, m_animationController(this)
, m_lifeSupportTimer(this, &Frame::lifeSupportTimerFired)
, m_pageZoomFactor(parentPageZoomFactor(this))
, m_textZoomFactor(parentTextZoomFactor(this))
#if ENABLE(ORIENTATION_EVENTS)
, m_orientation(0)
#endif
......@@ -882,4 +900,61 @@ String Frame::layerTreeAsText() const
#endif
}
void Frame::setPageZoomFactor(float factor)
{
setPageAndTextZoomFactors(factor, m_textZoomFactor);
}
void Frame::setTextZoomFactor(float factor)
{
setPageAndTextZoomFactors(m_pageZoomFactor, factor);
}
void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor)
{
if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
return;
Page* page = this->page();
if (!page)
return;
Document* document = this->document();
if (!document)
return;
#if ENABLE(SVG)
// Respect SVGs zoomAndPan="disabled" property in standalone SVG documents.
// FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification.
if (document->isSVGDocument()) {
if (!static_cast<SVGDocument*>(document)->zoomAndPanEnabled())
return;
if (document->renderer())
document->renderer()->setNeedsLayout(true);
}
#endif
if (m_pageZoomFactor != pageZoomFactor) {
if (FrameView* view = this->view()) {
// Update the scroll position when doing a full page zoom, so the content stays in relatively the same position.
IntPoint scrollPosition = view->scrollPosition();
float percentDifference = (pageZoomFactor / m_pageZoomFactor);
view->setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference));
}
}
m_pageZoomFactor = pageZoomFactor;
m_textZoomFactor = textZoomFactor;
document->recalcStyle(Node::Force);
for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
child->setPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor);
if (FrameView* view = this->view()) {
if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
view->layout();
}
}
} // namespace WebCore
......@@ -138,6 +138,12 @@ namespace WebCore {
void setDocument(PassRefPtr<Document>);
void setPageZoomFactor(float factor);
float pageZoomFactor() const { return m_pageZoomFactor; }
void setTextZoomFactor(float factor);
float textZoomFactor() const { return m_textZoomFactor; }
void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
#if ENABLE(ORIENTATION_EVENTS)
// Orientation is the interface orientation in degrees. Some examples are:
// 0 is straight up; -90 is when the device is rotated 90 clockwise;
......@@ -206,6 +212,9 @@ namespace WebCore {
Timer<Frame> m_lifeSupportTimer;
float m_pageZoomFactor;
float m_textZoomFactor;
#if ENABLE(ORIENTATION_EVENTS)
int m_orientation;
#endif
......
......@@ -111,28 +111,6 @@ struct ScheduledEvent : Noncopyable {
RefPtr<Node> m_eventTarget;
};
static inline float parentPageZoomFactor(Frame* frame)
{
Frame* parent = frame->tree()->parent();
if (!parent)
return 1;
FrameView* parentView = parent->view();
if (!parentView)
return 1;
return parentView->pageZoomFactor();
}
static inline float parentTextZoomFactor(Frame* frame)
{
Frame* parent = frame->tree()->parent();
if (!parent)
return 1;
FrameView* parentView = parent->view();
if (!parentView)
return 1;
return parentView->textZoomFactor();
}
FrameView::FrameView(Frame* frame)
: m_frame(frame)
, m_canHaveScrollbars(true)
......@@ -156,9 +134,6 @@ FrameView::FrameView(Frame* frame)
, m_deferSetNeedsLayouts(0)
, m_setNeedsLayoutWasDeferred(false)
, m_scrollCorner(0)
, m_pageZoomFactor(parentPageZoomFactor(frame))
, m_textZoomFactor(parentTextZoomFactor(frame))
{
init();
}
......@@ -2295,64 +2270,6 @@ IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
return parentPoint;
}
void FrameView::setPageZoomFactor(float factor)
{
setPageAndTextZoomFactors(factor, m_textZoomFactor);
}