Source/WebKit/efl/ChangeLog

 12012-01-03 Gyuyoung Kim <gyuyoung.kim@samsung.com>
 2
 3 [EFL] Move viewport functions to new files.
 4 https://bugs.webkit.org/show_bug.cgi?id=75592
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Too many functions are implemented to ewk_view.cpp. So, independent features need to
 9 be moved to new files. This patch moves APIs and internal functions related to viewport meta tag
 10 to new files.
 11
 12 * CMakeListsEfl.txt: Add ewk_viewport_attributes.cpp
 13 * WebCoreSupport/ChromeClientEfl.cpp: Use ewk_viewport_attributes_changed function instead of ewk_view_viewport_attributes_set function.
 14 (WebCore::ChromeClientEfl::dispatchViewportPropertiesDidChange):
 15 * ewk/ewk_private.h:
 16 * ewk/ewk_view.cpp: Add viewport private data to Ewk_View_Private_Data.
 17 (_ewk_view_priv_new):
 18 (ewk_view_viewport_attributes_get):
 19 * ewk/ewk_view.h:
 20 * ewk/ewk_viewport_attributes.cpp: Added. This file has viewport attributes private data and functions related to viewport.
 21 (_ewk_view_viewport_attributes_compute):
 22 (ewk_viewport_attributes_changed):
 23 (ewk_viewport_attributes_new):
 24 * ewk/ewk_viewport_attributes.h: Added.
 25 * ewk/ewk_viewport_attributes_private.h: Added.
 26
1272012-01-02 Gyuyoung Kim <gyuyoung.kim@samsung.com>
228
329 [EFL] Remove whitespace/declaration style exception

Source/WebKit/efl/CMakeListsEfl.txt

@@LIST(APPEND WebKit_SOURCES
8888 efl/ewk/ewk_tiled_model.cpp
8989 efl/ewk/ewk_util.cpp
9090 efl/ewk/ewk_view.cpp
 91 efl/ewk/ewk_viewport_attributes.cpp
9192 efl/ewk/ewk_view_single.cpp
9293 efl/ewk/ewk_view_tiled.cpp
9394 efl/ewk/ewk_window_features.cpp

Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp

5151#include "ViewportArguments.h"
5252#include "WindowFeatures.h"
5353#include "ewk_private.h"
 54#include "ewk_viewport_attributes_private.h"
5455#include <Ecore_Evas.h>
5556#include <Evas.h>
5657#include <wtf/text/CString.h>

@@void ChromeClientEfl::loadIconForFiles(const Vector<String>&, FileIconLoader*)
531532
532533void ChromeClientEfl::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
533534{
534  ewk_view_viewport_attributes_set(m_view, arguments);
 535 ewk_viewport_attributes_changed(ewk_view_viewport_private_data_get(m_view));
535536}
536537
537538bool ChromeClientEfl::selectItemWritingDirectionIsNatural()

Source/WebKit/efl/ewk/ewk_private.h

@@WTF::PassRefPtr<WebCore::Frame> ewk_view_frame_create(Evas_Object* ewkView, Evas
139139WTF::PassRefPtr<WebCore::Widget> ewk_view_plugin_create(Evas_Object* ewkView, Evas_Object* frame, const WebCore::IntSize& pluginSize, WebCore::HTMLPlugInElement* element, const WebCore::KURL& url, const WTF::Vector<WTF::String>& paramNames, const WTF::Vector<WTF::String>& paramValues, const WTF::String& mimeType, bool loadManually);
140140
141141void ewk_view_popup_new(Evas_Object* ewkView, WebCore::PopupMenuClient* client, int selected, const WebCore::IntRect& rect);
142 void ewk_view_viewport_attributes_set(Evas_Object* ewkView, const WebCore::ViewportArguments& arguments);
143142
144143void ewk_view_download_request(Evas_Object* ewkView, Ewk_Download* download);
145144

Source/WebKit/efl/ewk/ewk_view.cpp

3030#include "DocumentLoader.h"
3131#include "DragClientEfl.h"
3232#include "EditorClientEfl.h"
33 #include "EflScreenUtilities.h"
3433#include "EventHandler.h"
3534#include "FocusController.h"
3635#include "FrameLoaderClientEfl.h"

5352#include "c_instance.h"
5453#include "ewk_logging.h"
5554#include "ewk_private.h"
 55#include "ewk_viewport_attributes_private.h"
5656#include <Ecore.h>
5757#include <Eina.h>
5858#include <Evas.h>

@@struct _Ewk_View_Private_Data {
129129 WebCore::Page* page;
130130 WebCore::Settings* pageSettings;
131131 WebCore::Frame* mainFrame;
132  WebCore::ViewportArguments viewportArguments;
133132 Ewk_History* history;
 133 Ewk_Viewport_Private_Data* viewportPrivateData;
134134 struct {
135135 Ewk_Menu menu;
136136 WebCore::PopupMenuClient* menuClient;

@@static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
626626 goto error_settings;
627627 }
628628
629  priv->viewportArguments.width = WebCore::ViewportArguments::ValueAuto;
630  priv->viewportArguments.height = WebCore::ViewportArguments::ValueAuto;
631  priv->viewportArguments.initialScale = WebCore::ViewportArguments::ValueAuto;
632  priv->viewportArguments.minimumScale = WebCore::ViewportArguments::ValueAuto;
633  priv->viewportArguments.maximumScale = WebCore::ViewportArguments::ValueAuto;
634  priv->viewportArguments.targetDensityDpi = WebCore::ViewportArguments::ValueAuto;
635  priv->viewportArguments.userScalable = true;
 629 priv->viewportPrivateData = ewk_viewport_attributes_new(smartData->self);
636630
637631 priv->pageSettings->setLoadsImagesAutomatically(true);
638632 priv->pageSettings->setDefaultTextEncodingName("iso-8859-1");

@@static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
758752
759753 ewk_history_free(priv->history);
760754
 755 delete priv->viewportPrivateData;
761756 delete priv->page;
762757 free(priv);
763758}

@@static void _ewk_view_zoom_animation_start(Ewk_View_Smart_Data* smartData)
10821077 (_ewk_view_zoom_animator_cb, smartData);
10831078}
10841079
1085 static WebCore::ViewportAttributes _ewk_view_viewport_attributes_compute(const Ewk_View_Private_Data* priv)
1086 {
1087  int desktopWidth = 980;
1088  int deviceDPI = WebCore::getDPI();
1089 
1090  WebCore::IntRect availableRect = enclosingIntRect(priv->page->chrome()->client()->pageRect());
1091  WebCore::IntRect deviceRect = enclosingIntRect(priv->page->chrome()->client()->windowRect());
1092 
1093  WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(priv->viewportArguments, desktopWidth, deviceRect.width(), deviceRect.height(), deviceDPI, availableRect.size());
1094  WebCore::restrictMinimumScaleFactorToViewportSize(attributes, availableRect.size());
1095  WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
1096 
1097  return attributes;
1098 }
1099 
11001080static Eina_Bool _ewk_view_smart_disable_render(Ewk_View_Smart_Data* smartData)
11011081{
11021082 WRN("not supported by engine. smartData=%p", smartData);

@@void ewk_view_js_window_object_clear(Evas_Object* ewkView, Evas_Object* frame)
35333513 evas_object_smart_callback_call(ewkView, "js,windowobject,clear", frame);
35343514}
35353515
3536 /**
3537  * @internal
3538  * Reports the viewport has changed.
3539  *
3540  * @param arguments viewport argument.
3541  *
3542  * Emits signal: "viewport,changed" with no parameters.
3543  */
3544 void ewk_view_viewport_attributes_set(Evas_Object* ewkView, const WebCore::ViewportArguments& arguments)
3545 {
3546  EWK_VIEW_SD_GET(ewkView, smartData);
3547  EWK_VIEW_PRIV_GET(smartData, priv);
3548 
3549  priv->viewportArguments = arguments;
3550  evas_object_smart_callback_call(ewkView, "viewport,changed", 0);
3551 }
3552 
3553 void ewk_view_viewport_attributes_get(const Evas_Object* ewkView, int* width, int* height, float* initScale, float* maxScale, float* minScale, float* devicePixelRatio, Eina_Bool* userScalable)
3554 {
3555  EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3556  EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3557  WebCore::ViewportAttributes attributes = _ewk_view_viewport_attributes_compute(priv);
3558 
3559  if (width)
3560  *width = attributes.layoutSize.width();
3561  if (height)
3562  *height = attributes.layoutSize.height();
3563  if (initScale)
3564  *initScale = attributes.initialScale;
3565  if (maxScale)
3566  *maxScale = attributes.maximumScale;
3567  if (minScale)
3568  *minScale = attributes.minimumScale;
3569  if (devicePixelRatio)
3570  *devicePixelRatio = attributes.devicePixelRatio;
3571  if (userScalable)
3572  *userScalable = static_cast<bool>(attributes.userScalable);
3573 }
35743516
35753517Eina_Bool ewk_view_zoom_range_set(Evas_Object* ewkView, float minScale, float maxScale)
35763518{

@@void ewk_view_mixed_content_run_set(Evas_Object* ewkView, bool hasRun)
38753817 evas_object_smart_callback_call(ewkView, "mixedcontent,run", 0);
38763818}
38773819
 3820/**
 3821 * @internal
 3822 * Gets viewport private data from ewkView's private data.
 3823 *
 3824 * @param ewkView view.
 3825 *
 3826 * @return viewport private data.
 3827 */
 3828Ewk_Viewport_Private_Data* ewk_view_viewport_private_data_get(Evas_Object* ewkView)
 3829{
 3830 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
 3831 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
 3832
 3833 return priv->viewportPrivateData;
 3834}
 3835
38783836Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
38793837{
38803838#if ENABLE(PAGE_VISIBILITY_API)

Source/WebKit/efl/ewk/ewk_view.h

8080 * - "tooltip,text,set", const char*: sets tooltip text and displays if it is currently hidden.
8181 * - "uri,changed", const char*: uri of the main frame was changed.
8282 * - "view,resized", void: view object's size was changed.
83  * - "viewport,changed", void: reports that viewport was changed.
8483 * - "zoom,animated,end", void: requested animated zoom is finished.
8584 */
8685

@@EAPI Eina_Bool ewk_view_paint(Ewk_View_Private_Data *priv, cairo_t *cr, const Ei
21212120 */
21222121EAPI Eina_Bool ewk_view_paint_contents(Ewk_View_Private_Data *priv, cairo_t *cr, const Eina_Rectangle *area);
21232122
2124 /**
2125  * Gets the attributes of the viewport meta tag.
2126  *
2127  * Properties are returned in the respective pointers. Passing @c 0 to any of
2128  * these pointers will make that property to not be returned.
2129  *
2130  * @param o view object to get the viewport attributes
2131  * @param w the pointer to store the width of the viewport
2132  * @param h the pointer to store the height of the viewport
2133  * @param init_scale the pointer to store the initial scale value
2134  * @param max_scale the pointer to store the maximum scale value
2135  * @param min_scale the pointer to store the minimum scale value
2136  * @param device_pixel_ratio the pointer to store the device pixel ratio value
2137  * @param user_scalable the pointer to store if user can scale viewport
2138  */
2139 EAPI void ewk_view_viewport_attributes_get(const Evas_Object *o, int *w, int *h, float *init_scale, float *max_scale, float *min_scale, float *device_pixel_ratio , Eina_Bool *user_scalable);
21402123
21412124/**
21422125 * Sets the zoom range.

Source/WebKit/efl/ewk/ewk_viewport_attributes.cpp

 1/*
 2 Copyright (C) 2012 Samsung Electronics.
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20#include "config.h"
 21#include "ewk_viewport_attributes.h"
 22
 23#include "Chrome.h"
 24#include "ChromeClientEfl.h"
 25#include "EflScreenUtilities.h"
 26#include "FloatRect.h"
 27#include "Frame.h"
 28#include "Page.h"
 29#include "ewk_logging.h"
 30#include "ewk_private.h"
 31#include "ewk_viewport_attributes_private.h"
 32#include <Evas.h>
 33
 34/**
 35 * \struct _Ewk_Viewport_Attributes
 36 * @brief Contains the viewport attributes data.
 37 */
 38struct _Ewk_Viewport_Attributes {
 39 float width;
 40 float height;
 41 float initialScale;
 42 float minimumScale;
 43 float maximumScale;
 44 float devicePixelRatio;
 45 float userScalable;
 46};
 47
 48/**
 49 * @brief Viewport private data that is used internally by EFL WebKit
 50 * and should never be modified from outside.
 51 *
 52 * @internal
 53 */
 54struct _Ewk_Viewport_Private_Data {
 55 Evas_Object* ewkView;
 56 WebCore::ViewportArguments arguments;
 57};
 58
 59static Ewk_Viewport_Attributes _ewk_view_viewport_attributes_compute(const Ewk_Viewport_Private_Data* priv)
 60{
 61 int desktopWidth = 980; // This value works well for most web pages designed for desktop browsers.
 62 int deviceDPI = WebCore::getDPI();
 63
 64 WebCore::Page* page = EWKPrivate::corePage(priv->ewkView);
 65
 66 WebCore::IntRect availableRect = WebCore::enclosingIntRect(page->chrome()->client()->pageRect());
 67 WebCore::IntRect deviceRect = WebCore::enclosingIntRect(page->chrome()->client()->windowRect());
 68
 69 WebCore::ViewportArguments arguments = page->mainFrame()->document()->viewportArguments();
 70 WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(arguments,
 71 desktopWidth,
 72 deviceRect.width(),
 73 deviceRect.height(),
 74 deviceDPI,
 75 availableRect.size());
 76
 77 WebCore::restrictMinimumScaleFactorToViewportSize(attributes, availableRect.size());
 78 WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
 79
 80 Ewk_Viewport_Attributes ewkAttributes;
 81 ewkAttributes.width = attributes.layoutSize.width();
 82 ewkAttributes.height = attributes.layoutSize.height();
 83 ewkAttributes.initialScale = attributes.initialScale;
 84 ewkAttributes.minimumScale = attributes.minimumScale;
 85 ewkAttributes.maximumScale = attributes.maximumScale;
 86 ewkAttributes.devicePixelRatio = attributes.devicePixelRatio;
 87 ewkAttributes.userScalable = attributes.userScalable;
 88
 89 return ewkAttributes;
 90}
 91
 92/**
 93 * @internal
 94 * Reports the viewport has changed.
 95 *
 96 * @param arguments viewport argument.
 97 *
 98 * Emits signal: "viewport,changed" with Ewk_Viewport_Attributes parameters.
 99 */
 100void ewk_viewport_attributes_changed(Ewk_Viewport_Private_Data* priv)
 101{
 102 Ewk_Viewport_Attributes attributes = _ewk_view_viewport_attributes_compute(priv);
 103 DBG("computed viewport attribute: width:%f, height:%f, initialScale:%f, minimumScale:%f,"
 104 "maximumScale:%f, devicePixelRatio:%f, userScalable:%d", attributes.width, attributes.height,
 105 attributes.initialScale, attributes.minimumScale, attributes.maximumScale, attributes.devicePixelRatio,
 106 static_cast<bool>(attributes.userScalable));
 107
 108 evas_object_smart_callback_call(priv->ewkView, "viewport,changed", &attributes);
 109}
 110
 111/**
 112 * @internal
 113 * Creates private data for viewport attributes.
 114 *
 115 * @param ewkView view object.
 116 *
 117 * @return private data for viewport attributes.
 118 */
 119Ewk_Viewport_Private_Data* ewk_viewport_attributes_new(Evas_Object* ewkView)
 120{
 121 ASSERT(ewkView);
 122
 123 Ewk_Viewport_Private_Data* priv = new Ewk_Viewport_Private_Data;
 124
 125 if (!priv) {
 126 CRITICAL("could not allocate Ewk_Viewport_Private_Data");
 127 return 0;
 128 }
 129
 130 priv->ewkView = ewkView;
 131 priv->arguments.width = WebCore::ViewportArguments::ValueAuto;
 132 priv->arguments.height = WebCore::ViewportArguments::ValueAuto;
 133 priv->arguments.initialScale = WebCore::ViewportArguments::ValueAuto;
 134 priv->arguments.minimumScale = WebCore::ViewportArguments::ValueAuto;
 135 priv->arguments.maximumScale = WebCore::ViewportArguments::ValueAuto;
 136 priv->arguments.targetDensityDpi = WebCore::ViewportArguments::ValueAuto;
 137 priv->arguments.userScalable = true;
 138
 139 return priv;
 140}

Source/WebKit/efl/ewk/ewk_viewport_attributes.h

 1/*
 2 Copyright (C) 2012 Samsung Electronics.
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20#ifndef ewk_viewport_attributes_h
 21#define ewk_viewport_attributes_h
 22
 23#include <Eina.h>
 24#include <Evas.h>
 25
 26#ifdef __cplusplus
 27extern "C" {
 28#endif
 29
 30/**
 31 * @file ewk_viewport_attributes.h
 32 * @brief Viewport Meta Tag information.
 33 *
 34 * The following signals (see evas_object_smart_callback_add()) are emitted:
 35 * - "viewport,changed", Ewk_Viewport_Attributes: reports that viewport was changed.
 36 */
 37
 38/// Creates a type name for @a _Ewk_Viewport_Attributes.
 39typedef struct _Ewk_Viewport_Attributes Ewk_Viewport_Attributes;
 40
 41#ifdef __cplusplus
 42}
 43#endif
 44#endif // ewk_viewport_arguments.h

Source/WebKit/efl/ewk/ewk_viewport_attributes_private.h

 1/*
 2 Copyright (C) 2012 Samsung Electronics.
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20#ifndef ewk_viewport_attributes_private_h
 21#define ewk_viewport_attributes_private_h
 22
 23#include <Evas.h>
 24
 25/// Creates a type name for @a _Ewk_View_Smart_Data.
 26typedef struct _Ewk_Viewport_Private_Data Ewk_Viewport_Private_Data;
 27
 28Ewk_Viewport_Private_Data* ewk_view_viewport_private_data_get(Evas_Object* ewkView);
 29
 30void ewk_viewport_attributes_changed(Ewk_Viewport_Private_Data* priv);
 31Ewk_Viewport_Private_Data* ewk_viewport_attributes_new(Evas_Object* ewkView);
 32
 33#endif // ewk_viewport_attributes_private_h