Changeset 141481 in webkit


Ignore:
Timestamp:
Jan 31, 2013 1:57:00 PM (11 years ago)
Author:
zhajiang@rim.com
Message:

[BlackBerry] Bing Images viewport causes layout "fun"
https://bugs.webkit.org/show_bug.cgi?id=108393

Patch by Jacky Jiang <zhajiang@rim.com>.
Reviewed by Yong Li.
Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.

Source/WebCore:

PR: 277855
On bing.com image search page, JS generated styles for the divs which
contained images based on the window.screen and window.innerWidth.
Unfortunately the styles for the divs weren't good enough on our device
which resulted in three images being overlapped in the same viewport.
On our port, we calculate the screen rect base on the physical screen
pixels. However, iOS and lastest Android Chrome port already changed it
to density-independent (logical) pixels. And also to my knowledge that
some websites would generate bad styles for us as well through
@media device-width/device-height.
To be consistent and fix such kinds of issues, we should use
density-independent pixels instead of physical screen pixels. Mainly
ported from Chrome port change r139356. The patch will affect
screen.width/height, window.outerWidth/outerHeight and
@media device-width/device-height.

  • platform/blackberry/PlatformScreenBlackBerry.cpp:

(WebCore):
(WebCore::toUserSpace):
(WebCore::screenAvailableRect):
(WebCore::screenRect):

Source/WebKit/blackberry:

PR: 277855
Set applyPageScaleFactorInCompositor settting to false by default.
Scale down chrome window rect to density-independent pixels.

  • Api/WebPage.cpp:

(BlackBerry::WebKit::WebPagePrivate::didChangeSettings):

  • Api/WebSettings.cpp:

(WebKit):
(BlackBerry::WebKit::WebSettings::standardSettings):
(BlackBerry::WebKit::WebSettings::applyDeviceScaleFactorInCompositor):
(BlackBerry::WebKit::WebSettings::setApplyPageScaleFactorInCompositor):

  • Api/WebSettings.h:
  • WebCoreSupport/ChromeClientBlackBerry.cpp:

(WebCore::ChromeClientBlackBerry::windowRect):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141480 r141481  
     12013-01-31  Jacky Jiang  <zhajiang@rim.com>
     2
     3        [BlackBerry] Bing Images viewport causes layout "fun"
     4        https://bugs.webkit.org/show_bug.cgi?id=108393
     5
     6        Reviewed by Yong Li.
     7        Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.
     8
     9        PR: 277855
     10        On bing.com image search page, JS generated styles for the divs which
     11        contained images based on the window.screen and window.innerWidth.
     12        Unfortunately the styles for the divs weren't good enough on our device
     13        which resulted in three images being overlapped in the same viewport.
     14        On our port, we calculate the screen rect base on the physical screen
     15        pixels. However, iOS and lastest Android Chrome port already changed it
     16        to density-independent (logical) pixels. And also to my knowledge that
     17        some websites would generate bad styles for us as well through
     18        @media device-width/device-height.
     19        To be consistent and fix such kinds of issues, we should use
     20        density-independent pixels instead of physical screen pixels. Mainly
     21        ported from Chrome port change r139356. The patch will affect
     22        screen.width/height, window.outerWidth/outerHeight and
     23        @media device-width/device-height.
     24
     25        * platform/blackberry/PlatformScreenBlackBerry.cpp:
     26        (WebCore):
     27        (WebCore::toUserSpace):
     28        (WebCore::screenAvailableRect):
     29        (WebCore::screenRect):
     30
    1312013-01-31  Max Vujovic  <mvujovic@adobe.com>
    232
  • trunk/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp

    r135165 r141481  
    11/*
    22 * Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
     3 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
    34 *
    45 * This library is free software; you can redistribute it and/or
     
    2122
    2223#include "FloatRect.h"
     24#include "Frame.h"
     25#include "FrameView.h"
    2326#include "NotImplemented.h"
     27#include "Page.h"
     28#include "Settings.h"
    2429#include "Widget.h"
    2530
     
    4348}
    4449
     50// Use logical (density-independent) pixels instead of physical screen pixels.
     51static FloatRect toUserSpace(FloatRect rect, Widget* widget)
     52{
     53    if (widget->isFrameView()) {
     54        Page* page = static_cast<FrameView*>(widget)->frame()->page();
     55        if (page && !page->settings()->applyDeviceScaleFactorInCompositor())
     56            rect.scale(1 / page->deviceScaleFactor());
     57    }
     58    return rect;
     59}
     60
    4561FloatRect screenAvailableRect(Widget* widget)
    4662{
    47     return FloatRect(FloatPoint(), FloatSize(IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())));
     63    if (!widget)
     64        return FloatRect();
     65    return toUserSpace(IntRect(IntPoint::zero(), IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())), widget);
    4866}
    4967
    5068FloatRect screenRect(Widget* widget)
    5169{
    52     return FloatRect(FloatPoint(), FloatSize(IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())));
     70    if (!widget)
     71        return FloatRect();
     72    return toUserSpace(IntRect(IntPoint::zero(), IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())), widget);
    5373}
    5474
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r141276 r141481  
    60046004    coreSettings->setShouldUseCrossOriginProtocolCheck(!webSettings->allowCrossSiteRequests());
    60056005    coreSettings->setWebSecurityEnabled(!webSettings->allowCrossSiteRequests());
     6006    coreSettings->setApplyPageScaleFactorInCompositor(webSettings->applyDeviceScaleFactorInCompositor());
    60066007
    60076008    cookieManager().setPrivateMode(webSettings->isPrivateBrowsingEnabled());
  • trunk/Source/WebKit/blackberry/Api/WebSettings.cpp

    r140849 r141481  
    3737
    3838DEFINE_STATIC_LOCAL(String, BlackBerryAllowCrossSiteRequests, (ASCIILiteral("BlackBerryAllowCrossSiteRequests")));
     39DEFINE_STATIC_LOCAL(String, BlackBerryApplyDeviceScaleFactorInCompositor, (ASCIILiteral("BlackBerryApplyDeviceScaleFactorInCompositor")));
    3940DEFINE_STATIC_LOCAL(String, BlackBerryAsynchronousSpellChecking, (ASCIILiteral("BlackBerryAsynchronousSpellChecking")));
    4041DEFINE_STATIC_LOCAL(String, BlackBerryBackgroundColor, (ASCIILiteral("BlackBerryBackgroundColor")));
     
    180181    settings->m_private->setBoolean(BlackBerryFormAutofillEnabled, false);
    181182    settings->m_private->setBoolean(BlackBerryAsynchronousSpellChecking, true);
     183    settings->m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, false);
    182184
    183185    if (BlackBerry::Platform::DeviceInfo::instance()->isMobile()) {
     
    843845}
    844846
     847bool WebSettings::applyDeviceScaleFactorInCompositor() const
     848{
     849    return m_private->getBoolean(BlackBerryApplyDeviceScaleFactorInCompositor);
     850}
     851
     852void WebSettings::setApplyPageScaleFactorInCompositor(bool applyDeviceScaleFactorInCompositor)
     853{
     854    m_private->setBoolean(BlackBerryApplyDeviceScaleFactorInCompositor, applyDeviceScaleFactorInCompositor);
     855}
     856
    845857} // namespace WebKit
    846858} // namespace BlackBerry
  • trunk/Source/WebKit/blackberry/Api/WebSettings.h

    r140849 r141481  
    245245    void setBackingStoreEnabled(bool);
    246246
     247    bool applyDeviceScaleFactorInCompositor() const;
     248    void setApplyPageScaleFactorInCompositor(bool);
     249
    247250private:
    248251    WebSettingsPrivate* m_private;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r141473 r141481  
     12013-01-31  Jacky Jiang  <zhajiang@rim.com>
     2
     3        [BlackBerry] Bing Images viewport causes layout "fun"
     4        https://bugs.webkit.org/show_bug.cgi?id=108393
     5
     6        Reviewed by Yong Li.
     7        Internally reviewed by Arvid Nilsson and partially reviewed by Konrad Piascik.
     8
     9        PR: 277855
     10        Set applyPageScaleFactorInCompositor settting to false by default.
     11        Scale down chrome window rect to density-independent pixels.
     12
     13        * Api/WebPage.cpp:
     14        (BlackBerry::WebKit::WebPagePrivate::didChangeSettings):
     15        * Api/WebSettings.cpp:
     16        (WebKit):
     17        (BlackBerry::WebKit::WebSettings::standardSettings):
     18        (BlackBerry::WebKit::WebSettings::applyDeviceScaleFactorInCompositor):
     19        (BlackBerry::WebKit::WebSettings::setApplyPageScaleFactorInCompositor):
     20        * Api/WebSettings.h:
     21        * WebCoreSupport/ChromeClientBlackBerry.cpp:
     22        (WebCore::ChromeClientBlackBerry::windowRect):
     23
    1242013-01-31  Enrica Casucci  <enrica@apple.com>
    225
  • trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp

    r139519 r141481  
    5555#include "SearchPopupMenuBlackBerry.h"
    5656#include "SecurityOrigin.h"
     57#include "Settings.h"
    5758#include "SharedPointer.h"
    5859#include "ViewportArguments.h"
     
    166167        windowSize = window->windowSize();
    167168
    168     return FloatRect(0, 0, windowSize.width(), windowSize.height());
     169    // Use logical (density-independent) pixels instead of physical screen pixels.
     170    FloatRect rect = FloatRect(0, 0, windowSize.width(), windowSize.height());
     171    if (!m_webPagePrivate->m_page->settings()->applyDeviceScaleFactorInCompositor())
     172        rect.scale(1 / m_webPagePrivate->m_page->deviceScaleFactor());
     173    return rect;
    169174}
    170175
Note: See TracChangeset for help on using the changeset viewer.