Changeset 57775 in webkit


Ignore:
Timestamp:
Apr 16, 2010 9:40:14 PM (14 years ago)
Author:
dbates@webkit.org
Message:

2010-04-16 Daniel Bates <dbates@rim.com>

Reviewed by Adam Treat.

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

Adds support for the viewport meta tag. The code is largely derived in whole
or in part from the WebCore-528.15 source published as part of the iPhone 3.1.3
source code <http://www.opensource.apple.com/source/WebCore/WebCore-528.15/>.

  • Android.mk: Added file ViewportArguments.cpp.
  • GNUmakefile.am: Added files ViewportArguments.cpp and ViewportArguments.h.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • dom/Document.cpp: (WebCore::isSeparator): Added. (WebCore::Document::processArguments): Added. (WebCore::Document::processViewport): Added.
  • dom/Document.h:
  • dom/ViewportArguments.cpp: Added. (WebCore::setViewportFeature): (WebCore::viewportErrorMessageTemplate): (WebCore::viewportErrorMessageLevel): (WebCore::reportViewportWarning):
  • dom/ViewportArguments.h: Added. (WebCore::): (WebCore::ViewportArguments::): (WebCore::ViewportArguments::ViewportArguments): (WebCore::ViewportArguments::hasCustomArgument):
  • html/HTMLMetaElement.cpp: (WebCore::HTMLMetaElement::process): Modified to call Document::processViewport.
  • page/ChromeClient.h: (WebCore::ChromeClient::didReceiveViewportArguments): Added.
Location:
trunk/WebCore
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/Android.mk

    r57469 r57775  
    175175        dom/UIEventWithKeyState.cpp \
    176176        dom/UserGestureIndicator.cpp \
     177        dom/ViewportArguments.cpp \
    177178        dom/WebKitAnimationEvent.cpp \
    178179        dom/WebKitTransitionEvent.cpp \
  • trunk/WebCore/ChangeLog

    r57770 r57775  
     12010-04-16  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Adam Treat.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=36312
     6
     7        Adds support for the viewport meta tag. The code is largely derived in whole
     8        or in part from the WebCore-528.15 source published as part of the iPhone 3.1.3
     9        source code <http://www.opensource.apple.com/source/WebCore/WebCore-528.15/>.
     10
     11        * Android.mk: Added file ViewportArguments.cpp.
     12        * GNUmakefile.am: Added files ViewportArguments.cpp and ViewportArguments.h.
     13        * WebCore.gypi: Ditto.
     14        * WebCore.pro: Ditto.
     15        * WebCore.vcproj/WebCore.vcproj: Ditto.
     16        * WebCore.xcodeproj/project.pbxproj: Ditto.
     17        * dom/Document.cpp:
     18        (WebCore::isSeparator): Added.
     19        (WebCore::Document::processArguments): Added.
     20        (WebCore::Document::processViewport): Added.
     21        * dom/Document.h:
     22        * dom/ViewportArguments.cpp: Added.
     23        (WebCore::setViewportFeature):
     24        (WebCore::viewportErrorMessageTemplate):
     25        (WebCore::viewportErrorMessageLevel):
     26        (WebCore::reportViewportWarning):
     27        * dom/ViewportArguments.h: Added.
     28        (WebCore::):
     29        (WebCore::ViewportArguments::):
     30        (WebCore::ViewportArguments::ViewportArguments):
     31        (WebCore::ViewportArguments::hasCustomArgument):
     32        * html/HTMLMetaElement.cpp:
     33        (WebCore::HTMLMetaElement::process): Modified to call Document::processViewport.
     34        * page/ChromeClient.h:
     35        (WebCore::ChromeClient::didReceiveViewportArguments): Added.
     36
    1372010-04-16  No'am Rosenthal  <noam.rosenthal@nokia.com>
    238
  • trunk/WebCore/GNUmakefile.am

    r57749 r57775  
    877877        WebCore/dom/UserGestureIndicator.cpp \
    878878        WebCore/dom/UserGestureIndicator.h \
     879        WebCore/dom/ViewportArguments.cpp \
     880        WebCore/dom/ViewportArguments.h \
    879881        WebCore/dom/WebKitAnimationEvent.cpp \
    880882        WebCore/dom/WebKitAnimationEvent.h \
  • trunk/WebCore/WebCore.gypi

    r57749 r57775  
    12361236            'dom/UserGestureIndicator.cpp',
    12371237            'dom/UserGestureIndicator.h',
     1238            'dom/ViewportArguments.cpp',
     1239            'dom/ViewportArguments.h',
    12381240            'dom/WebKitAnimationEvent.cpp',
    12391241            'dom/WebKitAnimationEvent.h',
  • trunk/WebCore/WebCore.pro

    r57749 r57775  
    538538    dom/UIEventWithKeyState.cpp \
    539539    dom/UserGestureIndicator.cpp \
     540    dom/ViewportArguments.cpp \
    540541    dom/WebKitAnimationEvent.cpp \
    541542    dom/WebKitTransitionEvent.cpp \
     
    12601261    dom/UIEventWithKeyState.h \
    12611262    dom/UserGestureIndicator.h \
     1263    dom/ViewportArguments.h \
    12621264    dom/WebKitAnimationEvent.h \
    12631265    dom/WebKitTransitionEvent.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r57749 r57775  
    2955029550                        </File>
    2955129551                        <File
     29552                                RelativePath="..\dom\ViewportArguments.cpp"
     29553                                >
     29554                        </File>
     29555                        <File
     29556                                RelativePath="..\dom\ViewportArguments.h"
     29557                                >
     29558                        </File>
     29559                        <File
    2955229560                                RelativePath="..\dom\WebKitAnimationEvent.cpp"
    2955329561                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r57749 r57775  
    47194719                CE4C00E610F6F7C100CA38F5 /* HTMLNoScriptElement.h in Headers */ = {isa = PBXBuildFile; fileRef = CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */; };
    47204720                CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
     4721                CEF418CE1179678C009D112C /* ViewportArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEF418CC1179678C009D112C /* ViewportArguments.cpp */; };
     4722                CEF418CF1179678C009D112C /* ViewportArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = CEF418CD1179678C009D112C /* ViewportArguments.h */; };
    47214723                D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */; };
    47224724                D01A27AE10C9BFD800026A42 /* SpaceSplitString.h in Headers */ = {isa = PBXBuildFile; fileRef = D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1009210094                CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLNoScriptElement.h; sourceTree = "<group>"; };
    1009310095                CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceProvider.h; sourceTree = "<group>"; };
     10096                CEF418CC1179678C009D112C /* ViewportArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportArguments.cpp; sourceTree = "<group>"; };
     10097                CEF418CD1179678C009D112C /* ViewportArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportArguments.h; sourceTree = "<group>"; };
    1009410098                D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpaceSplitString.cpp; sourceTree = "<group>"; };
    1009510099                D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpaceSplitString.h; sourceTree = "<group>"; };
     
    1628916293                                2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */,
    1629016294                                2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */,
     16295                                CEF418CC1179678C009D112C /* ViewportArguments.cpp */,
     16296                                CEF418CD1179678C009D112C /* ViewportArguments.h */,
    1629116297                                31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */,
    1629216298                                31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */,
     
    1885918865                                895253DD116C4EF500CABF00 /* FileStreamProxy.h in Headers */,
    1886018866                                895253DF116C4F0600CABF00 /* FileThreadTask.h in Headers */,
     18867                                CEF418CF1179678C009D112C /* ViewportArguments.h in Headers */,
    1886118868                        );
    1886218869                        runOnlyForDeploymentPostprocessing = 0;
     
    2109421101                                9FA37EFC1172FDA600C4CD55 /* JSScriptProfileNode.cpp in Sources */,
    2109521102                                895253DC116C4EF500CABF00 /* FileStreamProxy.cpp in Sources */,
     21103                                CEF418CE1179678C009D112C /* ViewportArguments.cpp in Sources */,
    2109621104                        );
    2109721105                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/dom/Document.cpp

    r57533 r57775  
    127127#include "UIEvent.h"
    128128#include "UserContentURLPattern.h"
     129#include "ViewportArguments.h"
    129130#include "WebKitAnimationEvent.h"
    130131#include "WebKitTransitionEvent.h"
     
    22962297        }
    22972298    }
     2299}
     2300
     2301// Though isspace() considers \t and \v to be whitespace, Win IE doesn't.
     2302static bool isSeparator(UChar c)
     2303{
     2304    return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
     2305}
     2306
     2307void Document::processArguments(const String& features, void* data, ArgumentsCallback callback)
     2308{
     2309    // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
     2310    int keyBegin, keyEnd;
     2311    int valueBegin, valueEnd;
     2312
     2313    int i = 0;
     2314    int length = features.length();
     2315    String buffer = features.lower();
     2316    while (i < length) {
     2317        // skip to first non-separator, but don't skip past the end of the string
     2318        while (isSeparator(buffer[i])) {
     2319            if (i >= length)
     2320                break;
     2321            i++;
     2322        }
     2323        keyBegin = i;
     2324
     2325        // skip to first separator
     2326        while (!isSeparator(buffer[i]))
     2327            i++;
     2328        keyEnd = i;
     2329
     2330        // skip to first '=', but don't skip past a ',' or the end of the string
     2331        while (buffer[i] != '=') {
     2332            if (buffer[i] == ',' || i >= length)
     2333                break;
     2334            i++;
     2335        }
     2336
     2337        // skip to first non-separator, but don't skip past a ',' or the end of the string
     2338        while (isSeparator(buffer[i])) {
     2339            if (buffer[i] == ',' || i >= length)
     2340                break;
     2341            i++;
     2342        }
     2343        valueBegin = i;
     2344
     2345        // skip to first separator
     2346        while (!isSeparator(buffer[i]))
     2347            i++;
     2348        valueEnd = i;
     2349
     2350        ASSERT(i <= length);
     2351
     2352        String keyString = buffer.substring(keyBegin, keyEnd - keyBegin);
     2353        String valueString = buffer.substring(valueBegin, valueEnd - valueBegin);
     2354        callback(keyString, valueString, this, data);
     2355    }
     2356}
     2357
     2358void Document::processViewport(const String& features)
     2359{
     2360    ASSERT(!features.isNull());
     2361
     2362    Frame* frame = this->frame();
     2363    if (!frame)
     2364        return;
     2365
     2366    ViewportArguments arguments;
     2367    processArguments(features, (void*)&arguments, &setViewportFeature);
     2368
     2369    if (frame->page())
     2370        frame->page()->chrome()->client()->didReceiveViewportArguments(frame, arguments);
    22982371}
    22992372
  • trunk/WebCore/dom/Document.h

    r57391 r57775  
    701701     */
    702702    void processHttpEquiv(const String& equiv, const String& content);
    703    
     703    void processViewport(const String& features);
     704
    704705    // Returns the owning element in the parent document.
    705706    // Returns 0 if this is the top level document.
     
    975976
    976977private:
     978
     979    typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
     980    void processArguments(const String& features, void* data, ArgumentsCallback);
     981
    977982    virtual bool isDocument() const { return true; }
    978983    virtual void removedLastRef();
  • trunk/WebCore/html/HTMLMetaElement.cpp

    r43187 r57775  
    6464void HTMLMetaElement::process()
    6565{
     66    if (!inDocument() || m_content.isNull())
     67        return;
     68
     69    if (equalIgnoringCase(name(), "viewport"))
     70        document()->processViewport(m_content);
     71
    6672    // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while
    6773    // it's not in the tree shouldn't have any effect on the document)
    68     if (inDocument() && !m_equiv.isNull() && !m_content.isNull())
     74    if (!m_equiv.isNull())
    6975        document()->processHttpEquiv(m_equiv, m_content);
    7076}
  • trunk/WebCore/page/ChromeClient.h

    r57631 r57775  
    5757
    5858    struct FrameLoadRequest;
     59    struct ViewportArguments;
    5960    struct WindowFeatures;
    6061
     
    146147        virtual void setToolTip(const String&, TextDirection) = 0;
    147148
     149        virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const { }
     150
    148151        virtual void print(Frame*) = 0;
    149152
Note: See TracChangeset for help on using the changeset viewer.