| Differences between
and this patch
- WebCore/ChangeLog +36 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2010-03-26  Daniel Bates  <dbates@rim.com>
2
3
        Reviewed by NOBODY (OOPS!).
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
1
2010-03-26  Yael Aharon  <yael.aharon@nokia.com>
37
2010-03-26  Yael Aharon  <yael.aharon@nokia.com>
2
38
3
        Reviewed by Antti Koivisto.
39
        Reviewed by Antti Koivisto.
- WebCore/Android.mk +1 lines
Lines 173-178 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ WebCore/Android.mk_sec1
173
	dom/TreeWalker.cpp \
173
	dom/TreeWalker.cpp \
174
	dom/UIEvent.cpp \
174
	dom/UIEvent.cpp \
175
	dom/UIEventWithKeyState.cpp \
175
	dom/UIEventWithKeyState.cpp \
176
	dom/ViewportArguments.cpp \
176
	dom/WebKitAnimationEvent.cpp \
177
	dom/WebKitAnimationEvent.cpp \
177
	dom/WebKitTransitionEvent.cpp \
178
	dom/WebKitTransitionEvent.cpp \
178
	dom/WheelEvent.cpp \
179
	dom/WheelEvent.cpp \
- WebCore/GNUmakefile.am +2 lines
Lines 865-870 webcore_sources += \ WebCore/GNUmakefile.am_sec1
865
	WebCore/dom/UIEvent.h \
865
	WebCore/dom/UIEvent.h \
866
	WebCore/dom/UIEventWithKeyState.cpp \
866
	WebCore/dom/UIEventWithKeyState.cpp \
867
	WebCore/dom/UIEventWithKeyState.h \
867
	WebCore/dom/UIEventWithKeyState.h \
868
	WebCore/dom/ViewportArguments.cpp \
869
	WebCore/dom/ViewportArguments.h \
868
	WebCore/dom/WebKitAnimationEvent.cpp \
870
	WebCore/dom/WebKitAnimationEvent.cpp \
869
	WebCore/dom/WebKitAnimationEvent.h \
871
	WebCore/dom/WebKitAnimationEvent.h \
870
	WebCore/dom/WebKitTransitionEvent.cpp \
872
	WebCore/dom/WebKitTransitionEvent.cpp \
- WebCore/WebCore.gypi +2 lines
Lines 1226-1231 WebCore/WebCore.gypi_sec1
1226
            'dom/UIEvent.h',
1226
            'dom/UIEvent.h',
1227
            'dom/UIEventWithKeyState.cpp',
1227
            'dom/UIEventWithKeyState.cpp',
1228
            'dom/UIEventWithKeyState.h',
1228
            'dom/UIEventWithKeyState.h',
1229
            'dom/ViewportArguments.cpp',
1230
            'dom/ViewportArguments.h',
1229
            'dom/WebKitAnimationEvent.cpp',
1231
            'dom/WebKitAnimationEvent.cpp',
1230
            'dom/WebKitAnimationEvent.h',
1232
            'dom/WebKitAnimationEvent.h',
1231
            'dom/WebKitTransitionEvent.cpp',
1233
            'dom/WebKitTransitionEvent.cpp',
- WebCore/WebCore.pro +2 lines
Lines 532-537 SOURCES += \ WebCore/WebCore.pro_sec1
532
    dom/TreeWalker.cpp \
532
    dom/TreeWalker.cpp \
533
    dom/UIEvent.cpp \
533
    dom/UIEvent.cpp \
534
    dom/UIEventWithKeyState.cpp \
534
    dom/UIEventWithKeyState.cpp \
535
    dom/ViewportArguments.cpp \
535
    dom/WebKitAnimationEvent.cpp \
536
    dom/WebKitAnimationEvent.cpp \
536
    dom/WebKitTransitionEvent.cpp \
537
    dom/WebKitTransitionEvent.cpp \
537
    dom/WheelEvent.cpp \
538
    dom/WheelEvent.cpp \
Lines 1243-1248 HEADERS += \ WebCore/WebCore.pro_sec2
1243
    dom/TreeWalker.h \
1244
    dom/TreeWalker.h \
1244
    dom/UIEvent.h \
1245
    dom/UIEvent.h \
1245
    dom/UIEventWithKeyState.h \
1246
    dom/UIEventWithKeyState.h \
1247
    dom/ViewportArguments.h \
1246
    dom/WebKitAnimationEvent.h \
1248
    dom/WebKitAnimationEvent.h \
1247
    dom/WebKitTransitionEvent.h \
1249
    dom/WebKitTransitionEvent.h \
1248
    dom/WheelEvent.h \
1250
    dom/WheelEvent.h \
- WebCore/WebCore.vcproj/WebCore.vcproj +8 lines
Lines 29473-29478 WebCore/WebCore.vcproj/WebCore.vcproj_sec1
29473
				>
29473
				>
29474
			</File>
29474
			</File>
29475
			<File
29475
			<File
29476
				RelativePath="..\dom\ViewportArguments.cpp"
29477
				>
29478
			</File>
29479
			<File
29480
				RelativePath="..\dom\ViewportArguments.h"
29481
				>
29482
			</File>
29483
			<File
29476
				RelativePath="..\dom\WebKitAnimationEvent.cpp"
29484
				RelativePath="..\dom\WebKitAnimationEvent.cpp"
29477
				>
29485
				>
29478
			</File>
29486
			</File>
- WebCore/WebCore.xcodeproj/project.pbxproj +8 lines
Lines 4698-4703 WebCore/WebCore.xcodeproj/project.pbxproj_sec1
4698
		CE4C00E410F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE4C00E310F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp */; };
4698
		CE4C00E410F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE4C00E310F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp */; };
4699
		CE4C00E610F6F7C100CA38F5 /* HTMLNoScriptElement.h in Headers */ = {isa = PBXBuildFile; fileRef = CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */; };
4699
		CE4C00E610F6F7C100CA38F5 /* HTMLNoScriptElement.h in Headers */ = {isa = PBXBuildFile; fileRef = CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */; };
4700
		CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
4700
		CE54FD381016D9A6008B44C8 /* ScriptSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
4701
		CE719954115C120300DAE789 /* ViewportArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = CE719952115C120300DAE789 /* ViewportArguments.h */; };
4702
		CE719955115C120300DAE789 /* ViewportArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE719953115C120300DAE789 /* ViewportArguments.cpp */; };
4701
		D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */; };
4703
		D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */; };
4702
		D01A27AE10C9BFD800026A42 /* SpaceSplitString.h in Headers */ = {isa = PBXBuildFile; fileRef = D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */; settings = {ATTRIBUTES = (Private, ); }; };
4704
		D01A27AE10C9BFD800026A42 /* SpaceSplitString.h in Headers */ = {isa = PBXBuildFile; fileRef = D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */; settings = {ATTRIBUTES = (Private, ); }; };
4703
		D05CED290A40BB2C00C5AF38 /* FormatBlockCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */; };
4705
		D05CED290A40BB2C00C5AF38 /* FormatBlockCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */; };
Lines 10045-10050 WebCore/WebCore.xcodeproj/project.pbxproj_sec2
10045
		CE4C00E310F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLNoScriptElement.cpp; sourceTree = "<group>"; };
10047
		CE4C00E310F6F7BA00CA38F5 /* HTMLNoScriptElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLNoScriptElement.cpp; sourceTree = "<group>"; };
10046
		CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLNoScriptElement.h; sourceTree = "<group>"; };
10048
		CE4C00E510F6F7C100CA38F5 /* HTMLNoScriptElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLNoScriptElement.h; sourceTree = "<group>"; };
10047
		CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceProvider.h; sourceTree = "<group>"; };
10049
		CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceProvider.h; sourceTree = "<group>"; };
10050
		CE719952115C120300DAE789 /* ViewportArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportArguments.h; sourceTree = "<group>"; };
10051
		CE719953115C120300DAE789 /* ViewportArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportArguments.cpp; sourceTree = "<group>"; };
10048
		D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpaceSplitString.cpp; sourceTree = "<group>"; };
10052
		D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpaceSplitString.cpp; sourceTree = "<group>"; };
10049
		D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpaceSplitString.h; sourceTree = "<group>"; };
10053
		D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpaceSplitString.h; sourceTree = "<group>"; };
10050
		D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormatBlockCommand.cpp; sourceTree = "<group>"; };
10054
		D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormatBlockCommand.cpp; sourceTree = "<group>"; };
Lines 16211-16216 WebCore/WebCore.xcodeproj/project.pbxproj_sec3
16211
				141B94EE09EC425A000E9413 /* UIEvent.idl */,
16215
				141B94EE09EC425A000E9413 /* UIEvent.idl */,
16212
				93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */,
16216
				93354A3B0B24F8C9003F6DEA /* UIEventWithKeyState.cpp */,
16213
				85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */,
16217
				85031B390A44EFC700F992E0 /* UIEventWithKeyState.h */,
16218
				CE719953115C120300DAE789 /* ViewportArguments.cpp */,
16219
				CE719952115C120300DAE789 /* ViewportArguments.h */,
16214
				31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */,
16220
				31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */,
16215
				31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */,
16221
				31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */,
16216
				31C0FF1D0E4CEB6E007D6FE5 /* WebKitAnimationEvent.idl */,
16222
				31C0FF1D0E4CEB6E007D6FE5 /* WebKitAnimationEvent.idl */,
Lines 18765-18770 WebCore/WebCore.xcodeproj/project.pbxproj_sec4
18765
				A513B3D7114B1666001C429B /* KeyEventCocoa.h in Headers */,
18771
				A513B3D7114B1666001C429B /* KeyEventCocoa.h in Headers */,
18766
				62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
18772
				62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
18767
				E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
18773
				E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
18774
				CE719954115C120300DAE789 /* ViewportArguments.h in Headers */,
18768
			);
18775
			);
18769
			runOnlyForDeploymentPostprocessing = 0;
18776
			runOnlyForDeploymentPostprocessing = 0;
18770
		};
18777
		};
Lines 20980-20985 WebCore/WebCore.xcodeproj/project.pbxproj_sec5
20980
				A513B3D8114B166A001C429B /* KeyEventCocoa.mm in Sources */,
20987
				A513B3D8114B166A001C429B /* KeyEventCocoa.mm in Sources */,
20981
				62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */,
20988
				62CD32591157E57C0063B0A7 /* CustomEvent.cpp in Sources */,
20982
				E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
20989
				E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
20990
				CE719955115C120300DAE789 /* ViewportArguments.cpp in Sources */,
20983
			);
20991
			);
20984
			runOnlyForDeploymentPostprocessing = 0;
20992
			runOnlyForDeploymentPostprocessing = 0;
20985
		};
20993
		};
- WebCore/dom/Document.cpp +73 lines
Lines 127-132 WebCore/dom/Document.cpp_sec1
127
#include "TreeWalker.h"
127
#include "TreeWalker.h"
128
#include "UIEvent.h"
128
#include "UIEvent.h"
129
#include "UserContentURLPattern.h"
129
#include "UserContentURLPattern.h"
130
#include "ViewportArguments.h"
130
#include "WebKitAnimationEvent.h"
131
#include "WebKitAnimationEvent.h"
131
#include "WebKitTransitionEvent.h"
132
#include "WebKitTransitionEvent.h"
132
#include "WheelEvent.h"
133
#include "WheelEvent.h"
Lines 2282-2287 void Document::processHttpEquiv(const St WebCore/dom/Document.cpp_sec2
2282
    }
2283
    }
2283
}
2284
}
2284
2285
2286
// Though isspace() considers \t and \v to be whitespace, Win IE doesn't.
2287
static bool isSeparator(UChar c)
2288
{
2289
    return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
2290
}
2291
2292
void Document::processArguments(const String& features, void* data, ArgumentsCallback callback)
2293
{
2294
    // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
2295
    int keyBegin, keyEnd;
2296
    int valueBegin, valueEnd;
2297
2298
    int i = 0;
2299
    int length = features.length();
2300
    String buffer = features.lower();
2301
    while (i < length) {
2302
        // skip to first non-separator, but don't skip past the end of the string
2303
        while (isSeparator(buffer[i])) {
2304
            if (i >= length)
2305
                break;
2306
            i++;
2307
        }
2308
        keyBegin = i;
2309
2310
        // skip to first separator
2311
        while (!isSeparator(buffer[i]))
2312
            i++;
2313
        keyEnd = i;
2314
2315
        // skip to first '=', but don't skip past a ',' or the end of the string
2316
        while (buffer[i] != '=') {
2317
            if (buffer[i] == ',' || i >= length)
2318
                break;
2319
            i++;
2320
        }
2321
2322
        // skip to first non-separator, but don't skip past a ',' or the end of the string
2323
        while (isSeparator(buffer[i])) {
2324
            if (buffer[i] == ',' || i >= length)
2325
                break;
2326
            i++;
2327
        }
2328
        valueBegin = i;
2329
2330
        // skip to first separator
2331
        while (!isSeparator(buffer[i]))
2332
            i++;
2333
        valueEnd = i;
2334
2335
        ASSERT(i <= length);
2336
2337
        String keyString = buffer.substring(keyBegin, keyEnd - keyBegin);
2338
        String valueString = buffer.substring(valueBegin, valueEnd - valueBegin);
2339
        callback(keyString, valueString, this, data);
2340
    }
2341
}
2342
2343
void Document::processViewport(const String& features)
2344
{
2345
    ASSERT(!features.isNull());
2346
2347
    Frame* frame = this->frame();
2348
    if (!frame)
2349
        return;
2350
2351
    ViewportArguments arguments;
2352
    processArguments(features, (void*)&arguments, &setViewportFeature);
2353
2354
    if (frame->page())
2355
        frame->page()->chrome()->client()->didReceiveViewportArguments(frame, arguments);
2356
}
2357
2285
MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& request, const IntPoint& documentPoint, const PlatformMouseEvent& event)
2358
MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& request, const IntPoint& documentPoint, const PlatformMouseEvent& event)
2286
{
2359
{
2287
    ASSERT(!renderer() || renderer()->isRenderView());
2360
    ASSERT(!renderer() || renderer()->isRenderView());
- WebCore/dom/Document.h -1 / +6 lines
Lines 698-704 public: WebCore/dom/Document.h_sec1
698
     * @param content The header value (value of the meta tag's "content" attribute)
698
     * @param content The header value (value of the meta tag's "content" attribute)
699
     */
699
     */
700
    void processHttpEquiv(const String& equiv, const String& content);
700
    void processHttpEquiv(const String& equiv, const String& content);
701
    
701
    void processViewport(const String& features);
702
702
    // Returns the owning element in the parent document.
703
    // Returns the owning element in the parent document.
703
    // Returns 0 if this is the top level document.
704
    // Returns 0 if this is the top level document.
704
    Element* ownerElement() const;
705
    Element* ownerElement() const;
Lines 972-977 protected: WebCore/dom/Document.h_sec2
972
    void clearXMLVersion() { m_xmlVersion = String(); }
973
    void clearXMLVersion() { m_xmlVersion = String(); }
973
974
974
private:
975
private:
976
977
    typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
978
    void processArguments(const String& features, void* data, ArgumentsCallback);
979
975
    virtual bool isDocument() const { return true; }
980
    virtual bool isDocument() const { return true; }
976
    virtual void removedLastRef();
981
    virtual void removedLastRef();
977
    virtual void determineParseMode() { }
982
    virtual void determineParseMode() { }
- WebCore/dom/ViewportArguments.cpp +120 lines
Line 0 WebCore/dom/ViewportArguments.cpp_sec1
1
/*
2
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7
 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Library General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Library General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Library General Public License
20
 * along with this library; see the file COPYING.LIB.  If not, write to
21
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
 * Boston, MA 02110-1301, USA.
23
 *
24
 */
25
26
#include "config.h"
27
#include "ViewportArguments.h"
28
29
#include "Chrome.h"
30
#include "Console.h"
31
#include "Document.h"
32
#include "DOMWindow.h"
33
#include "Frame.h"
34
#include "Page.h"
35
#include "PlatformString.h"
36
#include "Tokenizer.h"
37
38
namespace WebCore {
39
40
void setViewportFeature(const String& keyString, const String& valueString, Document* document, void* data)
41
{
42
    ViewportArguments* arguments = static_cast<ViewportArguments*>(data);
43
    float value = ViewportArguments::ValueUndefined;
44
    bool didUseConstants = false;
45
46
    if (equalIgnoringCase(valueString, "yes"))
47
        value = 1;
48
    else if (equalIgnoringCase(valueString, "device-width")) {
49
        didUseConstants = true;
50
        if (document->page())
51
            value = document->page()->chrome()->windowRect().width();
52
    } else if (equalIgnoringCase(valueString, "device-height")) {
53
        didUseConstants = true;
54
        if (document->page())
55
            value = document->page()->chrome()->windowRect().height();
56
    } else if (equalIgnoringCase(valueString, "default")) // This allows us to distinguish the omission of a key from asking for the default value.
57
        value = -2;
58
    else if (valueString.length()) // listing a key with no value is shorthand for key=default
59
        value = valueString.toFloat();
60
61
    if (keyString == "initial-scale")
62
        arguments->initialScale = value;
63
    else if (keyString == "minimum-scale")
64
        arguments->minimumScale = value;
65
    else if (keyString == "maximum-scale") {
66
        arguments->maximumScale = value;
67
        if (value > 10.0)
68
            reportViewportWarning(document, MaximumScaleTooLargeError, keyString);
69
    } else if (keyString == "user-scalable")
70
        arguments->userScalable = value;
71
    else if (keyString == "width") {
72
        if (document->page() && value == document->page()->chrome()->windowRect().width() && !didUseConstants)
73
            reportViewportWarning(document, DeviceWidthShouldBeUsedWarning, keyString);
74
        else if (document->page() && value == document->page()->chrome()->windowRect().height() && !didUseConstants)
75
            reportViewportWarning(document, DeviceHeightShouldBeUsedWarning, keyString);
76
77
        arguments->width = value;
78
    } else if (keyString == "height") {
79
        if (document->page() && value == document->page()->chrome()->windowRect().width() && !didUseConstants)
80
            reportViewportWarning(document, DeviceWidthShouldBeUsedWarning, keyString);
81
        else if (document->page() && value == document->page()->chrome()->windowRect().height() && !didUseConstants)
82
            reportViewportWarning(document, DeviceHeightShouldBeUsedWarning, keyString);
83
        
84
        arguments->height = value;
85
    } else
86
        reportViewportWarning(document, UnrecognizedViewportArgumentError, keyString);
87
}
88
89
static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
90
{
91
    static const char* const errors[] = { 
92
        "Viewport width or height set to physical device width, try using \"device-width\" constant instead for future compatibility.",
93
        "Viewport height or height set to physical device height, try using \"device-height\" constant instead for future compatibility.",
94
        "Viewport argument \"%replacement\" not recognized. Content ignored.",
95
        "Viewport maximum-scale cannot be larger than 10.0.  The maximum-scale will be set to 10.0."
96
    };
97
98
    return errors[errorCode];
99
}
100
101
static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode)
102
{
103
    return errorCode == UnrecognizedViewportArgumentError || errorCode == MaximumScaleTooLargeError ? ErrorMessageLevel : TipMessageLevel;
104
}
105
106
void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement)
107
{
108
    Tokenizer* tokenizer = document->tokenizer();
109
110
    Frame* frame = document->frame();
111
    if (!frame)
112
        return;
113
114
    String message = viewportErrorMessageTemplate(errorCode);
115
    message.replace("%replacement", replacement);
116
117
    frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, tokenizer ? tokenizer->lineNumber() + 1 : 0, document->url().string());
118
}
119
120
} // namespace WebCore
- WebCore/dom/ViewportArguments.h +74 lines
Line 0 WebCore/dom/ViewportArguments.h_sec1
1
/*
2
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
5
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6
 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7
 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Library General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Library General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Library General Public License
20
 * along with this library; see the file COPYING.LIB.  If not, write to
21
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
 * Boston, MA 02110-1301, USA.
23
 *
24
 */
25
26
#ifndef ViewportArguments_h
27
#define ViewportArguments_h
28
29
namespace WebCore {
30
31
class Document;
32
class String;
33
34
enum ViewportErrorCode {
35
    DeviceWidthShouldBeUsedWarning,
36
    DeviceHeightShouldBeUsedWarning,
37
    UnrecognizedViewportArgumentError,
38
    MaximumScaleTooLargeError
39
};
40
41
struct ViewportArguments {
42
43
    enum { ValueUndefined = -1 };
44
45
    ViewportArguments()
46
        : initialScale(ValueUndefined)
47
        , minimumScale(ValueUndefined)
48
        , maximumScale(ValueUndefined)
49
        , width(ValueUndefined)
50
        , height(ValueUndefined)
51
        , userScalable(ValueUndefined)
52
    {
53
    }
54
55
    float initialScale;
56
    float minimumScale;
57
    float maximumScale;
58
    float width;
59
    float height;
60
61
    float userScalable;
62
63
    bool hasCustomArgument() const
64
    {
65
        return initialScale != ValueUndefined || minimumScale != ValueUndefined || maximumScale != ValueUndefined || width != ValueUndefined || height != ValueUndefined || userScalable != ValueUndefined;
66
    }
67
};
68
69
void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
70
void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement);
71
72
} // namespace WebCore
73
74
#endif // ViewportArguments_h
- WebCore/html/HTMLMetaElement.cpp -1 / +7 lines
Lines 63-71 void HTMLMetaElement::insertedIntoDocume WebCore/html/HTMLMetaElement.cpp_sec1
63
63
64
void HTMLMetaElement::process()
64
void HTMLMetaElement::process()
65
{
65
{
66
    if (!inDocument() || m_content.isNull())
67
        return;
68
69
    if (equalIgnoringCase(name(), "viewport"))
70
        document()->processViewport(m_content);
71
66
    // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while
72
    // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while
67
    // it's not in the tree shouldn't have any effect on the document)
73
    // 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())
69
        document()->processHttpEquiv(m_equiv, m_content);
75
        document()->processHttpEquiv(m_equiv, m_content);
70
}
76
}
71
77
- WebCore/page/ChromeClient.h +3 lines
Lines 56-61 namespace WebCore { WebCore/page/ChromeClient.h_sec1
56
    class Widget;
56
    class Widget;
57
57
58
    struct FrameLoadRequest;
58
    struct FrameLoadRequest;
59
    struct ViewportArguments;
59
    struct WindowFeatures;
60
    struct WindowFeatures;
60
61
61
#if USE(ACCELERATED_COMPOSITING)
62
#if USE(ACCELERATED_COMPOSITING)
Lines 145-150 namespace WebCore { WebCore/page/ChromeClient.h_sec2
145
146
146
        virtual void setToolTip(const String&, TextDirection) = 0;
147
        virtual void setToolTip(const String&, TextDirection) = 0;
147
148
149
        virtual void didReceiveViewportArguments(Frame*, const ViewportArguments&) const { }
150
148
        virtual void print(Frame*) = 0;
151
        virtual void print(Frame*) = 0;
149
152
150
#if ENABLE(DATABASE)
153
#if ENABLE(DATABASE)

Return to Bug 36312