Merge lp:~timo-jyrinki/ubuntu/raring/qtwebkit-source/raring_231 into lp:ubuntu/saucy/qtwebkit-source

Proposed by Timo Jyrinki
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~timo-jyrinki/ubuntu/raring/qtwebkit-source/raring_231
Merge into: lp:ubuntu/saucy/qtwebkit-source
Diff against target: 16806 lines (+1220/-14071)
85 files modified
.pc/05_sparc_unaligned_access.diff/Source/WTF/wtf/ListHashSet.h (+0/-872)
.pc/applied-patches (+0/-9)
.pc/devicePixelResolution.patch/Source/WebCore/page/Page.cpp (+0/-1346)
.pc/disable_geolocation_501.diff/Source/WebKit/qt/Api/qwebpage.cpp (+0/-4103)
.pc/hurd.diff/Source/WTF/wtf/FastMalloc.cpp (+0/-4734)
.pc/kubuntu_fix_for_powerpc.diff/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp (+0/-545)
.pc/kubuntu_fix_for_powerpc.diff/Source/JavaScriptCore/offlineasm/cloop.rb (+0/-1131)
.pc/no_gc_sections.diff/Source/WebCore/WebCore.pri (+0/-361)
.pc/save_memory.diff/Source/WebCore/WebCore.pri (+0/-361)
.pc/stabs_format_debug_info.diff/Source/WebKit/WebKit1.pri (+0/-60)
.pc/stabs_format_debug_info.diff/Source/WebKit2/WebKit2.pri (+0/-81)
.pc/webkit_qt_hide_symbols.diff/Source/QtWebKit.pro (+0/-38)
ChangeLog (+16/-0)
Source/JavaScriptCore/ChangeLog (+403/-0)
Source/JavaScriptCore/JSCTypedArrayStubs.h (+4/-1)
Source/JavaScriptCore/assembler/ARMv7Assembler.h (+42/-3)
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h (+6/-1)
Source/JavaScriptCore/bytecode/CodeBlock.cpp (+2/-2)
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (+30/-2)
Source/JavaScriptCore/bytecompiler/Label.h (+6/-0)
Source/JavaScriptCore/dfg/DFGArgumentsSimplificationPhase.cpp (+9/-8)
Source/JavaScriptCore/dfg/DFGCFGSimplificationPhase.cpp (+8/-3)
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (+11/-3)
Source/JavaScriptCore/dfg/DFGGraph.h (+19/-8)
Source/JavaScriptCore/dfg/DFGNodeFlags.h (+1/-1)
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (+29/-4)
Source/JavaScriptCore/dfg/DFGRepatch.cpp (+6/-6)
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (+3/-4)
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (+1/-1)
Source/JavaScriptCore/dfg/DFGStructureCheckHoistingPhase.cpp (+1/-1)
Source/JavaScriptCore/heap/MarkStack.cpp (+4/-8)
Source/JavaScriptCore/heap/MarkStack.h (+5/-11)
Source/JavaScriptCore/heap/MarkStackInlines.h (+5/-5)
Source/JavaScriptCore/heap/WeakSet.cpp (+1/-1)
Source/JavaScriptCore/interpreter/Interpreter.cpp (+6/-3)
Source/JavaScriptCore/jit/JIT.h (+1/-1)
Source/JavaScriptCore/jit/JITStubs.cpp (+18/-2)
Source/JavaScriptCore/llint/LLIntExceptions.cpp (+3/-3)
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (+3/-4)
Source/JavaScriptCore/offlineasm/ast.rb (+1/-1)
Source/JavaScriptCore/runtime/Executable.cpp (+2/-2)
Source/JavaScriptCore/runtime/JSArray.h (+4/-0)
Source/JavaScriptCore/runtime/JSTypeInfo.h (+2/-1)
Source/JavaScriptCore/runtime/Operations.h (+6/-3)
Source/JavaScriptCore/runtime/Options.h (+0/-1)
Source/JavaScriptCore/yarr/YarrJIT.cpp (+12/-0)
Source/QtWebKit.pro (+1/-6)
Source/WTF/ChangeLog (+75/-0)
Source/WTF/wtf/Compiler.h (+3/-0)
Source/WTF/wtf/FastMalloc.cpp (+0/-4)
Source/WTF/wtf/HashMap.h (+30/-24)
Source/WTF/wtf/ListHashSet.h (+6/-3)
Source/WTF/wtf/Platform.h (+2/-2)
Source/WebCore/ChangeLog (+193/-11)
Source/WebCore/Target.pri (+10/-7)
Source/WebCore/WebCore.pri (+1/-3)
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (+10/-3)
Source/WebCore/css/mediaControlsQt.css (+98/-197)
Source/WebCore/page/EventHandler.cpp (+1/-1)
Source/WebCore/page/Page.cpp (+2/-2)
Source/WebCore/platform/graphics/GraphicsContext.cpp (+1/-1)
Source/WebCore/platform/graphics/ShadowBlur.cpp (+2/-2)
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (+6/-3)
Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp (+31/-0)
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (+2/-0)
Source/WebCore/platform/text/TextEncodingRegistry.cpp (+9/-0)
Source/WebCore/rendering/RenderBox.cpp (+1/-0)
Source/WebCore/rendering/RenderFrameSet.cpp (+4/-4)
Source/WebCore/rendering/RenderLayer.cpp (+1/-2)
Source/WebCore/rendering/RenderLayer.h (+0/-4)
Source/WebCore/rendering/RenderTableSection.cpp (+6/-1)
Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp (+1/-1)
Source/WebKit/WebKit1.pri (+0/-6)
Source/WebKit/qt/Api/qwebkitglobal.h (+2/-2)
Source/WebKit/qt/Api/qwebpage.cpp (+10/-1)
Source/WebKit/qt/Api/qwebpage.h (+1/-0)
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp (+2/-1)
Source/WebKit2/WebKit2.pri (+0/-6)
Source/api.pri (+13/-0)
Tools/Scripts/webkitdirs.pm (+3/-0)
Tools/qmake/qt_webkit.pri (+2/-2)
debian/changelog (+18/-0)
debian/patches/kubuntu_fix_for_powerpc.diff (+0/-35)
debian/patches/series (+0/-1)
debian/rules (+3/-1)
To merge this branch: bzr merge lp:~timo-jyrinki/ubuntu/raring/qtwebkit-source/raring_231
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+165031@code.launchpad.net

This proposal supersedes a proposal from 2013-04-22.

Commit message

This new 2.3.1 release with the correct build parameter (http://blogs.kde.org/2013/03/15/qtwebkit-230-out) fixes qtwebkit on non-SSE2 computers (mentioned in bug #1131636), and has other fixes http://comments.gmane.org/gmane.os.opendarwin.webkit.qt/3665

It does not however fix the Skype issue NVIDIA users have (bug #1155327).

Description of the change

This new 2.3.1 release with the correct build parameter (http://blogs.kde.org/2013/03/15/qtwebkit-230-out) fixes qtwebkit on non-SSE2 computers (mentioned in bug #1131636), and has other fixes http://comments.gmane.org/gmane.os.opendarwin.webkit.qt/3665

It does not however fix the Skype issue NVIDIA users have (bug #1155327).

To post a comment you must log in.
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote : Posted in a previous version of this proposal
Revision history for this message
Dmitry Shachnev (mitya57) wrote : Posted in a previous version of this proposal

Thanks Timo for working on it, I have a couple of comments:

- I've unlinked bugs that are not fixed by your update;
- Now this should go to Saucy, the diff looks to big for a SRU.
- We may want to cherry-pick some fixes to Raring, but I would like to wait for fix for https://bugs.webkit.org/show_bug.cgi?id=114618 (marked as a blocker currently). We'll also need a SRU bug in that case.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote : Posted in a previous version of this proposal

Yeah certainly this is for saucy at this point.

Revision history for this message
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Timo, could you retarget that one for saucy?

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Resubmitted to saucy, thanks.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Note that it is not rebased on top of 2.3.0-0ubuntu3 in Saucy, so one will need to at least merge changelog entries before uploading.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Right, it does not show up in any bzr, so merging manually the changelog entry and checking if the patch still applies.

35. By Timo Jyrinki

Manual merge of 2.3.0-0ubuntu3 in saucy. Changelog only, patch is included in 2.3.1.

* debian/patches/108991-jsval-32bit-fix.patch:
  - Drop, merged upstream
* Add patch 108991-jsval-32bit-fix.patch fixes
  QtWebKit JS crash on 32-bit systems LP: #1180731

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, I'm sponsoring that one

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file '.dir-locals.el' => '.dir-locals.el'
2=== renamed directory '.pc' => '.pc'
3=== removed directory '.pc/05_sparc_unaligned_access.diff'
4=== removed directory '.pc/05_sparc_unaligned_access.diff/Source'
5=== removed directory '.pc/05_sparc_unaligned_access.diff/Source/WTF'
6=== removed directory '.pc/05_sparc_unaligned_access.diff/Source/WTF/wtf'
7=== removed file '.pc/05_sparc_unaligned_access.diff/Source/WTF/wtf/ListHashSet.h'
8--- .pc/05_sparc_unaligned_access.diff/Source/WTF/wtf/ListHashSet.h 2013-02-18 14:24:18 +0000
9+++ .pc/05_sparc_unaligned_access.diff/Source/WTF/wtf/ListHashSet.h 1970-01-01 00:00:00 +0000
10@@ -1,872 +0,0 @@
11-/*
12- * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
13- * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com>
14- *
15- * This library is free software; you can redistribute it and/or
16- * modify it under the terms of the GNU Library General Public
17- * License as published by the Free Software Foundation; either
18- * version 2 of the License, or (at your option) any later version.
19- *
20- * This library is distributed in the hope that it will be useful,
21- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23- * Library General Public License for more details.
24- *
25- * You should have received a copy of the GNU Library General Public License
26- * along with this library; see the file COPYING.LIB. If not, write to
27- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28- * Boston, MA 02110-1301, USA.
29- *
30- */
31-
32-#ifndef WTF_ListHashSet_h
33-#define WTF_ListHashSet_h
34-
35-#include <wtf/HashSet.h>
36-#include <wtf/OwnPtr.h>
37-#include <wtf/PassOwnPtr.h>
38-
39-namespace WTF {
40-
41- // ListHashSet: Just like HashSet, this class provides a Set
42- // interface - a collection of unique objects with O(1) insertion,
43- // removal and test for containership. However, it also has an
44- // order - iterating it will always give back values in the order
45- // in which they are added.
46-
47- // Unlike iteration of most WTF Hash data structures, iteration is
48- // guaranteed safe against mutation of the ListHashSet, except for
49- // removal of the item currently pointed to by a given iterator.
50-
51- // In theory it would be possible to add prepend, insertAfter
52- // and an append that moves the element to the end even if already present,
53- // but unclear yet if these are needed.
54-
55- template<typename Value, size_t inlineCapacity, typename HashFunctions> class ListHashSet;
56-
57- template<typename Value, size_t inlineCapacity, typename HashFunctions>
58- void deleteAllValues(const ListHashSet<Value, inlineCapacity, HashFunctions>&);
59-
60- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator;
61- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstIterator;
62- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetReverseIterator;
63- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstReverseIterator;
64-
65- template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode;
66- template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNodeAllocator;
67-
68- template<typename HashArg> struct ListHashSetNodeHashFunctions;
69- template<typename HashArg> struct ListHashSetTranslator;
70-
71- template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg = typename DefaultHash<ValueArg>::Hash> class ListHashSet {
72- WTF_MAKE_FAST_ALLOCATED;
73- private:
74- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
75- typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
76-
77- typedef HashTraits<Node*> NodeTraits;
78- typedef ListHashSetNodeHashFunctions<HashArg> NodeHash;
79- typedef ListHashSetTranslator<HashArg> BaseTranslator;
80-
81- typedef HashTable<Node*, Node*, IdentityExtractor, NodeHash, NodeTraits, NodeTraits> ImplType;
82- typedef HashTableIterator<Node*, Node*, IdentityExtractor, NodeHash, NodeTraits, NodeTraits> ImplTypeIterator;
83- typedef HashTableConstIterator<Node*, Node*, IdentityExtractor, NodeHash, NodeTraits, NodeTraits> ImplTypeConstIterator;
84-
85- typedef HashArg HashFunctions;
86-
87- public:
88- typedef ValueArg ValueType;
89-
90- typedef ListHashSetIterator<ValueType, inlineCapacity, HashArg> iterator;
91- typedef ListHashSetConstIterator<ValueType, inlineCapacity, HashArg> const_iterator;
92- friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg>;
93-
94- typedef ListHashSetReverseIterator<ValueType, inlineCapacity, HashArg> reverse_iterator;
95- typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg> const_reverse_iterator;
96- friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>;
97-
98- typedef HashTableAddResult<iterator> AddResult;
99-
100- ListHashSet();
101- ListHashSet(const ListHashSet&);
102- ListHashSet& operator=(const ListHashSet&);
103- ~ListHashSet();
104-
105- void swap(ListHashSet&);
106-
107- int size() const;
108- int capacity() const;
109- bool isEmpty() const;
110-
111- size_t sizeInBytes() const;
112-
113- iterator begin();
114- iterator end();
115- const_iterator begin() const;
116- const_iterator end() const;
117-
118- reverse_iterator rbegin();
119- reverse_iterator rend();
120- const_reverse_iterator rbegin() const;
121- const_reverse_iterator rend() const;
122-
123- ValueType& first();
124- const ValueType& first() const;
125-
126- ValueType& last();
127- const ValueType& last() const;
128- void removeLast();
129-
130- iterator find(const ValueType&);
131- const_iterator find(const ValueType&) const;
132- bool contains(const ValueType&) const;
133-
134- // An alternate version of find() that finds the object by hashing and comparing
135- // with some other type, to avoid the cost of type conversion.
136- // The HashTranslator interface is defined in HashSet.
137- // FIXME: We should reverse the order of the template arguments so that callers
138- // can just pass the translator let the compiler deduce T.
139- template<typename T, typename HashTranslator> iterator find(const T&);
140- template<typename T, typename HashTranslator> const_iterator find(const T&) const;
141- template<typename T, typename HashTranslator> bool contains(const T&) const;
142-
143- // The return value of add is a pair of an iterator to the new value's location,
144- // and a bool that is true if an new entry was added.
145- AddResult add(const ValueType&);
146-
147- AddResult insertBefore(const ValueType& beforeValue, const ValueType& newValue);
148- AddResult insertBefore(iterator, const ValueType&);
149-
150- void remove(const ValueType&);
151- void remove(iterator);
152- void clear();
153-
154- private:
155- void unlinkAndDelete(Node*);
156- void appendNode(Node*);
157- void insertNodeBefore(Node* beforeNode, Node* newNode);
158- void deleteAllNodes();
159-
160- iterator makeIterator(Node*);
161- const_iterator makeConstIterator(Node*) const;
162- reverse_iterator makeReverseIterator(Node*);
163- const_reverse_iterator makeConstReverseIterator(Node*) const;
164-
165- friend void deleteAllValues<>(const ListHashSet&);
166-
167- ImplType m_impl;
168- Node* m_head;
169- Node* m_tail;
170- OwnPtr<NodeAllocator> m_allocator;
171- };
172-
173- template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNodeAllocator {
174- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
175- typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
176-
177- ListHashSetNodeAllocator()
178- : m_freeList(pool())
179- , m_isDoneWithInitialFreeList(false)
180- {
181- memset(m_pool.pool, 0, sizeof(m_pool.pool));
182- }
183-
184- Node* allocate()
185- {
186- Node* result = m_freeList;
187-
188- if (!result)
189- return static_cast<Node*>(fastMalloc(sizeof(Node)));
190-
191- ASSERT(!result->m_isAllocated);
192-
193- Node* next = result->m_next;
194- ASSERT(!next || !next->m_isAllocated);
195- if (!next && !m_isDoneWithInitialFreeList) {
196- next = result + 1;
197- if (next == pastPool()) {
198- m_isDoneWithInitialFreeList = true;
199- next = 0;
200- } else {
201- ASSERT(inPool(next));
202- ASSERT(!next->m_isAllocated);
203- }
204- }
205- m_freeList = next;
206-
207- return result;
208- }
209-
210- void deallocate(Node* node)
211- {
212- if (inPool(node)) {
213-#ifndef NDEBUG
214- node->m_isAllocated = false;
215-#endif
216- node->m_next = m_freeList;
217- m_freeList = node;
218- return;
219- }
220-
221- fastFree(node);
222- }
223-
224- bool inPool(Node* node)
225- {
226- return node >= pool() && node < pastPool();
227- }
228-
229- private:
230- Node* pool() { return reinterpret_cast_ptr<Node*>(m_pool.pool); }
231- Node* pastPool() { return pool() + m_poolSize; }
232-
233- Node* m_freeList;
234- bool m_isDoneWithInitialFreeList;
235- static const size_t m_poolSize = inlineCapacity;
236- union {
237- char pool[sizeof(Node) * m_poolSize];
238- double forAlignment;
239- } m_pool;
240- };
241-
242- template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode {
243- typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
244-
245- ListHashSetNode(ValueArg value)
246- : m_value(value)
247- , m_prev(0)
248- , m_next(0)
249-#ifndef NDEBUG
250- , m_isAllocated(true)
251-#endif
252- {
253- }
254-
255- void* operator new(size_t, NodeAllocator* allocator)
256- {
257- return allocator->allocate();
258- }
259- void destroy(NodeAllocator* allocator)
260- {
261- this->~ListHashSetNode();
262- allocator->deallocate(this);
263- }
264-
265- ValueArg m_value;
266- ListHashSetNode* m_prev;
267- ListHashSetNode* m_next;
268-
269-#ifndef NDEBUG
270- bool m_isAllocated;
271-#endif
272- };
273-
274- template<typename HashArg> struct ListHashSetNodeHashFunctions {
275- template<typename T> static unsigned hash(const T& key) { return HashArg::hash(key->m_value); }
276- template<typename T> static bool equal(const T& a, const T& b) { return HashArg::equal(a->m_value, b->m_value); }
277- static const bool safeToCompareToEmptyOrDeleted = false;
278- };
279-
280- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator {
281- private:
282- typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
283- typedef ListHashSetIterator<ValueArg, inlineCapacity, HashArg> iterator;
284- typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_iterator;
285- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
286- typedef ValueArg ValueType;
287- typedef ValueType& ReferenceType;
288- typedef ValueType* PointerType;
289-
290- friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
291-
292- ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { }
293-
294- public:
295- ListHashSetIterator() { }
296-
297- // default copy, assignment and destructor are OK
298-
299- PointerType get() const { return const_cast<PointerType>(m_iterator.get()); }
300- ReferenceType operator*() const { return *get(); }
301- PointerType operator->() const { return get(); }
302-
303- iterator& operator++() { ++m_iterator; return *this; }
304-
305- // postfix ++ intentionally omitted
306-
307- iterator& operator--() { --m_iterator; return *this; }
308-
309- // postfix -- intentionally omitted
310-
311- // Comparison.
312- bool operator==(const iterator& other) const { return m_iterator == other.m_iterator; }
313- bool operator!=(const iterator& other) const { return m_iterator != other.m_iterator; }
314-
315- operator const_iterator() const { return m_iterator; }
316-
317- private:
318- Node* node() { return m_iterator.node(); }
319-
320- const_iterator m_iterator;
321- };
322-
323- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstIterator {
324- private:
325- typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
326- typedef ListHashSetIterator<ValueArg, inlineCapacity, HashArg> iterator;
327- typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_iterator;
328- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
329- typedef ValueArg ValueType;
330- typedef const ValueType& ReferenceType;
331- typedef const ValueType* PointerType;
332-
333- friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
334- friend class ListHashSetIterator<ValueArg, inlineCapacity, HashArg>;
335-
336- ListHashSetConstIterator(const ListHashSetType* set, Node* position)
337- : m_set(set)
338- , m_position(position)
339- {
340- }
341-
342- public:
343- ListHashSetConstIterator()
344- {
345- }
346-
347- PointerType get() const
348- {
349- return &m_position->m_value;
350- }
351- ReferenceType operator*() const { return *get(); }
352- PointerType operator->() const { return get(); }
353-
354- const_iterator& operator++()
355- {
356- ASSERT(m_position != 0);
357- m_position = m_position->m_next;
358- return *this;
359- }
360-
361- // postfix ++ intentionally omitted
362-
363- const_iterator& operator--()
364- {
365- ASSERT(m_position != m_set->m_head);
366- if (!m_position)
367- m_position = m_set->m_tail;
368- else
369- m_position = m_position->m_prev;
370- return *this;
371- }
372-
373- // postfix -- intentionally omitted
374-
375- // Comparison.
376- bool operator==(const const_iterator& other) const
377- {
378- return m_position == other.m_position;
379- }
380- bool operator!=(const const_iterator& other) const
381- {
382- return m_position != other.m_position;
383- }
384-
385- private:
386- Node* node() { return m_position; }
387-
388- const ListHashSetType* m_set;
389- Node* m_position;
390- };
391-
392- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetReverseIterator {
393- private:
394- typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
395- typedef ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg> reverse_iterator;
396- typedef ListHashSetConstReverseIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;
397- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
398- typedef ValueArg ValueType;
399- typedef ValueType& ReferenceType;
400- typedef ValueType* PointerType;
401-
402- friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
403-
404- ListHashSetReverseIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { }
405-
406- public:
407- ListHashSetReverseIterator() { }
408-
409- // default copy, assignment and destructor are OK
410-
411- PointerType get() const { return const_cast<PointerType>(m_iterator.get()); }
412- ReferenceType operator*() const { return *get(); }
413- PointerType operator->() const { return get(); }
414-
415- reverse_iterator& operator++() { ++m_iterator; return *this; }
416-
417- // postfix ++ intentionally omitted
418-
419- reverse_iterator& operator--() { --m_iterator; return *this; }
420-
421- // postfix -- intentionally omitted
422-
423- // Comparison.
424- bool operator==(const reverse_iterator& other) const { return m_iterator == other.m_iterator; }
425- bool operator!=(const reverse_iterator& other) const { return m_iterator != other.m_iterator; }
426-
427- operator const_reverse_iterator() const { return m_iterator; }
428-
429- private:
430- Node* node() { return m_iterator.node(); }
431-
432- const_reverse_iterator m_iterator;
433- };
434-
435- template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstReverseIterator {
436- private:
437- typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
438- typedef ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg> reverse_iterator;
439- typedef ListHashSetConstReverseIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;
440- typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
441- typedef ValueArg ValueType;
442- typedef const ValueType& ReferenceType;
443- typedef const ValueType* PointerType;
444-
445- friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
446- friend class ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg>;
447-
448- ListHashSetConstReverseIterator(const ListHashSetType* set, Node* position)
449- : m_set(set)
450- , m_position(position)
451- {
452- }
453-
454- public:
455- ListHashSetConstReverseIterator()
456- {
457- }
458-
459- PointerType get() const
460- {
461- return &m_position->m_value;
462- }
463- ReferenceType operator*() const { return *get(); }
464- PointerType operator->() const { return get(); }
465-
466- const_reverse_iterator& operator++()
467- {
468- ASSERT(m_position != 0);
469- m_position = m_position->m_prev;
470- return *this;
471- }
472-
473- // postfix ++ intentionally omitted
474-
475- const_reverse_iterator& operator--()
476- {
477- ASSERT(m_position != m_set->m_tail);
478- if (!m_position)
479- m_position = m_set->m_head;
480- else
481- m_position = m_position->m_next;
482- return *this;
483- }
484-
485- // postfix -- intentionally omitted
486-
487- // Comparison.
488- bool operator==(const const_reverse_iterator& other) const
489- {
490- return m_position == other.m_position;
491- }
492- bool operator!=(const const_reverse_iterator& other) const
493- {
494- return m_position != other.m_position;
495- }
496-
497- private:
498- Node* node() { return m_position; }
499-
500- const ListHashSetType* m_set;
501- Node* m_position;
502- };
503-
504- template<typename HashFunctions>
505- struct ListHashSetTranslator {
506- template<typename T> static unsigned hash(const T& key) { return HashFunctions::hash(key); }
507- template<typename T, typename U> static bool equal(const T& a, const U& b) { return HashFunctions::equal(a->m_value, b); }
508- template<typename T, typename U, typename V> static void translate(T*& location, const U& key, const V& allocator)
509- {
510- location = new (allocator) T(key);
511- }
512- };
513-
514- template<typename T, size_t inlineCapacity, typename U>
515- inline ListHashSet<T, inlineCapacity, U>::ListHashSet()
516- : m_head(0)
517- , m_tail(0)
518- , m_allocator(adoptPtr(new NodeAllocator))
519- {
520- }
521-
522- template<typename T, size_t inlineCapacity, typename U>
523- inline ListHashSet<T, inlineCapacity, U>::ListHashSet(const ListHashSet& other)
524- : m_head(0)
525- , m_tail(0)
526- , m_allocator(adoptPtr(new NodeAllocator))
527- {
528- const_iterator end = other.end();
529- for (const_iterator it = other.begin(); it != end; ++it)
530- add(*it);
531- }
532-
533- template<typename T, size_t inlineCapacity, typename U>
534- inline ListHashSet<T, inlineCapacity, U>& ListHashSet<T, inlineCapacity, U>::operator=(const ListHashSet& other)
535- {
536- ListHashSet tmp(other);
537- swap(tmp);
538- return *this;
539- }
540-
541- template<typename T, size_t inlineCapacity, typename U>
542- inline void ListHashSet<T, inlineCapacity, U>::swap(ListHashSet& other)
543- {
544- m_impl.swap(other.m_impl);
545- std::swap(m_head, other.m_head);
546- std::swap(m_tail, other.m_tail);
547- m_allocator.swap(other.m_allocator);
548- }
549-
550- template<typename T, size_t inlineCapacity, typename U>
551- inline ListHashSet<T, inlineCapacity, U>::~ListHashSet()
552- {
553- deleteAllNodes();
554- }
555-
556- template<typename T, size_t inlineCapacity, typename U>
557- inline int ListHashSet<T, inlineCapacity, U>::size() const
558- {
559- return m_impl.size();
560- }
561-
562- template<typename T, size_t inlineCapacity, typename U>
563- inline int ListHashSet<T, inlineCapacity, U>::capacity() const
564- {
565- return m_impl.capacity();
566- }
567-
568- template<typename T, size_t inlineCapacity, typename U>
569- inline bool ListHashSet<T, inlineCapacity, U>::isEmpty() const
570- {
571- return m_impl.isEmpty();
572- }
573-
574- template<typename T, size_t inlineCapacity, typename U>
575- size_t ListHashSet<T, inlineCapacity, U>::sizeInBytes() const
576- {
577- size_t result = sizeof(*this) + sizeof(*m_allocator);
578- result += sizeof(typename ImplType::ValueType) * m_impl.capacity();
579- for (Node* node = m_head; node; node = node->m_next) {
580- if (!m_allocator->inPool(node))
581- result += sizeof(Node);
582- }
583- return result;
584- }
585-
586- template<typename T, size_t inlineCapacity, typename U>
587- inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::begin()
588- {
589- return makeIterator(m_head);
590- }
591-
592- template<typename T, size_t inlineCapacity, typename U>
593- inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::end()
594- {
595- return makeIterator(0);
596- }
597-
598- template<typename T, size_t inlineCapacity, typename U>
599- inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::begin() const
600- {
601- return makeConstIterator(m_head);
602- }
603-
604- template<typename T, size_t inlineCapacity, typename U>
605- inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::end() const
606- {
607- return makeConstIterator(0);
608- }
609-
610- template<typename T, size_t inlineCapacity, typename U>
611- inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin()
612- {
613- return makeReverseIterator(m_tail);
614- }
615-
616- template<typename T, size_t inlineCapacity, typename U>
617- inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rend()
618- {
619- return makeReverseIterator(0);
620- }
621-
622- template<typename T, size_t inlineCapacity, typename U>
623- inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin() const
624- {
625- return makeConstReverseIterator(m_tail);
626- }
627-
628- template<typename T, size_t inlineCapacity, typename U>
629- inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rend() const
630- {
631- return makeConstReverseIterator(0);
632- }
633-
634- template<typename T, size_t inlineCapacity, typename U>
635- inline T& ListHashSet<T, inlineCapacity, U>::first()
636- {
637- ASSERT(!isEmpty());
638- return m_head->m_value;
639- }
640-
641- template<typename T, size_t inlineCapacity, typename U>
642- inline const T& ListHashSet<T, inlineCapacity, U>::first() const
643- {
644- ASSERT(!isEmpty());
645- return m_head->m_value;
646- }
647-
648- template<typename T, size_t inlineCapacity, typename U>
649- inline T& ListHashSet<T, inlineCapacity, U>::last()
650- {
651- ASSERT(!isEmpty());
652- return m_tail->m_value;
653- }
654-
655- template<typename T, size_t inlineCapacity, typename U>
656- inline const T& ListHashSet<T, inlineCapacity, U>::last() const
657- {
658- ASSERT(!isEmpty());
659- return m_tail->m_value;
660- }
661-
662- template<typename T, size_t inlineCapacity, typename U>
663- inline void ListHashSet<T, inlineCapacity, U>::removeLast()
664- {
665- ASSERT(!isEmpty());
666- m_impl.remove(m_tail);
667- unlinkAndDelete(m_tail);
668- }
669-
670- template<typename T, size_t inlineCapacity, typename U>
671- inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::find(const ValueType& value)
672- {
673- ImplTypeIterator it = m_impl.template find<BaseTranslator>(value);
674- if (it == m_impl.end())
675- return end();
676- return makeIterator(*it);
677- }
678-
679- template<typename T, size_t inlineCapacity, typename U>
680- inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::find(const ValueType& value) const
681- {
682- ImplTypeConstIterator it = m_impl.template find<BaseTranslator>(value);
683- if (it == m_impl.end())
684- return end();
685- return makeConstIterator(*it);
686- }
687-
688- template<typename Translator>
689- struct ListHashSetTranslatorAdapter {
690- template<typename T> static unsigned hash(const T& key) { return Translator::hash(key); }
691- template<typename T, typename U> static bool equal(const T& a, const U& b) { return Translator::equal(a->m_value, b); }
692- };
693-
694- template<typename ValueType, size_t inlineCapacity, typename U>
695- template<typename T, typename HashTranslator>
696- inline typename ListHashSet<ValueType, inlineCapacity, U>::iterator ListHashSet<ValueType, inlineCapacity, U>::find(const T& value)
697- {
698- ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAdapter<HashTranslator> >(value);
699- if (it == m_impl.end())
700- return end();
701- return makeIterator(*it);
702- }
703-
704- template<typename ValueType, size_t inlineCapacity, typename U>
705- template<typename T, typename HashTranslator>
706- inline typename ListHashSet<ValueType, inlineCapacity, U>::const_iterator ListHashSet<ValueType, inlineCapacity, U>::find(const T& value) const
707- {
708- ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAdapter<HashTranslator> >(value);
709- if (it == m_impl.end())
710- return end();
711- return makeConstIterator(*it);
712- }
713-
714- template<typename ValueType, size_t inlineCapacity, typename U>
715- template<typename T, typename HashTranslator>
716- inline bool ListHashSet<ValueType, inlineCapacity, U>::contains(const T& value) const
717- {
718- return m_impl.template contains<ListHashSetTranslatorAdapter<HashTranslator> >(value);
719- }
720-
721- template<typename T, size_t inlineCapacity, typename U>
722- inline bool ListHashSet<T, inlineCapacity, U>::contains(const ValueType& value) const
723- {
724- return m_impl.template contains<BaseTranslator>(value);
725- }
726-
727- template<typename T, size_t inlineCapacity, typename U>
728- typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::add(const ValueType &value)
729- {
730- typename ImplType::AddResult result = m_impl.template add<BaseTranslator>(value, m_allocator.get());
731- if (result.isNewEntry)
732- appendNode(*result.iterator);
733- return AddResult(makeIterator(*result.iterator), result.isNewEntry);
734- }
735-
736- template<typename T, size_t inlineCapacity, typename U>
737- typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::insertBefore(iterator it, const ValueType& newValue)
738- {
739- typename ImplType::AddResult result = m_impl.template add<BaseTranslator>(newValue, m_allocator.get());
740- if (result.isNewEntry)
741- insertNodeBefore(it.node(), *result.iterator);
742- return AddResult(makeIterator(*result.iterator), result.isNewEntry);
743- }
744-
745- template<typename T, size_t inlineCapacity, typename U>
746- typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue)
747- {
748- return insertBefore(find(beforeValue), newValue);
749- }
750-
751- template<typename T, size_t inlineCapacity, typename U>
752- inline void ListHashSet<T, inlineCapacity, U>::remove(iterator it)
753- {
754- if (it == end())
755- return;
756- m_impl.remove(it.node());
757- unlinkAndDelete(it.node());
758- }
759-
760- template<typename T, size_t inlineCapacity, typename U>
761- inline void ListHashSet<T, inlineCapacity, U>::remove(const ValueType& value)
762- {
763- remove(find(value));
764- }
765-
766- template<typename T, size_t inlineCapacity, typename U>
767- inline void ListHashSet<T, inlineCapacity, U>::clear()
768- {
769- deleteAllNodes();
770- m_impl.clear();
771- m_head = 0;
772- m_tail = 0;
773- }
774-
775- template<typename T, size_t inlineCapacity, typename U>
776- void ListHashSet<T, inlineCapacity, U>::unlinkAndDelete(Node* node)
777- {
778- if (!node->m_prev) {
779- ASSERT(node == m_head);
780- m_head = node->m_next;
781- } else {
782- ASSERT(node != m_head);
783- node->m_prev->m_next = node->m_next;
784- }
785-
786- if (!node->m_next) {
787- ASSERT(node == m_tail);
788- m_tail = node->m_prev;
789- } else {
790- ASSERT(node != m_tail);
791- node->m_next->m_prev = node->m_prev;
792- }
793-
794- node->destroy(m_allocator.get());
795- }
796-
797- template<typename T, size_t inlineCapacity, typename U>
798- void ListHashSet<T, inlineCapacity, U>::appendNode(Node* node)
799- {
800- node->m_prev = m_tail;
801- node->m_next = 0;
802-
803- if (m_tail) {
804- ASSERT(m_head);
805- m_tail->m_next = node;
806- } else {
807- ASSERT(!m_head);
808- m_head = node;
809- }
810-
811- m_tail = node;
812- }
813-
814- template<typename T, size_t inlineCapacity, typename U>
815- void ListHashSet<T, inlineCapacity, U>::insertNodeBefore(Node* beforeNode, Node* newNode)
816- {
817- if (!beforeNode)
818- return appendNode(newNode);
819-
820- newNode->m_next = beforeNode;
821- newNode->m_prev = beforeNode->m_prev;
822- if (beforeNode->m_prev)
823- beforeNode->m_prev->m_next = newNode;
824- beforeNode->m_prev = newNode;
825-
826- if (!newNode->m_prev)
827- m_head = newNode;
828- }
829-
830- template<typename T, size_t inlineCapacity, typename U>
831- void ListHashSet<T, inlineCapacity, U>::deleteAllNodes()
832- {
833- if (!m_head)
834- return;
835-
836- for (Node* node = m_head, *next = m_head->m_next; node; node = next, next = node ? node->m_next : 0)
837- node->destroy(m_allocator.get());
838- }
839-
840- template<typename T, size_t inlineCapacity, typename U>
841- inline ListHashSetReverseIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeReverseIterator(Node* position)
842- {
843- return ListHashSetReverseIterator<T, inlineCapacity, U>(this, position);
844- }
845-
846- template<typename T, size_t inlineCapacity, typename U>
847- inline ListHashSetConstReverseIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeConstReverseIterator(Node* position) const
848- {
849- return ListHashSetConstReverseIterator<T, inlineCapacity, U>(this, position);
850- }
851-
852- template<typename T, size_t inlineCapacity, typename U>
853- inline ListHashSetIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeIterator(Node* position)
854- {
855- return ListHashSetIterator<T, inlineCapacity, U>(this, position);
856- }
857-
858- template<typename T, size_t inlineCapacity, typename U>
859- inline ListHashSetConstIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeConstIterator(Node* position) const
860- {
861- return ListHashSetConstIterator<T, inlineCapacity, U>(this, position);
862- }
863- template<bool, typename ValueType, typename HashTableType>
864- void deleteAllValues(HashTableType& collection)
865- {
866- typedef typename HashTableType::const_iterator iterator;
867- iterator end = collection.end();
868- for (iterator it = collection.begin(); it != end; ++it)
869- delete (*it)->m_value;
870- }
871-
872- template<typename T, size_t inlineCapacity, typename U>
873- inline void deleteAllValues(const ListHashSet<T, inlineCapacity, U>& collection)
874- {
875- deleteAllValues<true, typename ListHashSet<T, inlineCapacity, U>::ValueType>(collection.m_impl);
876- }
877-
878-} // namespace WTF
879-
880-using WTF::ListHashSet;
881-
882-#endif /* WTF_ListHashSet_h */
883
884=== removed file '.pc/applied-patches'
885--- .pc/applied-patches 2013-03-28 15:37:15 +0000
886+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
887@@ -1,9 +0,0 @@
888-05_sparc_unaligned_access.diff
889-stabs_format_debug_info.diff
890-no_gc_sections.diff
891-hurd.diff
892-webkit_qt_hide_symbols.diff
893-save_memory.diff
894-devicePixelResolution.patch
895-disable_geolocation_501.diff
896-kubuntu_fix_for_powerpc.diff
897
898=== removed directory '.pc/devicePixelResolution.patch'
899=== removed directory '.pc/devicePixelResolution.patch/Source'
900=== removed directory '.pc/devicePixelResolution.patch/Source/WebCore'
901=== removed directory '.pc/devicePixelResolution.patch/Source/WebCore/page'
902=== removed file '.pc/devicePixelResolution.patch/Source/WebCore/page/Page.cpp'
903--- .pc/devicePixelResolution.patch/Source/WebCore/page/Page.cpp 2013-02-18 14:24:18 +0000
904+++ .pc/devicePixelResolution.patch/Source/WebCore/page/Page.cpp 1970-01-01 00:00:00 +0000
905@@ -1,1346 +0,0 @@
906-/*
907- * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All Rights Reserved.
908- * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
909- *
910- * This library is free software; you can redistribute it and/or
911- * modify it under the terms of the GNU Library General Public
912- * License as published by the Free Software Foundation; either
913- * version 2 of the License, or (at your option) any later version.
914- * This library is distributed in the hope that it will be useful,
915- * but WITHOUT ANY WARRANTY; without even the implied warranty of
916- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
917- * Library General Public License for more details.
918- *
919- * You should have received a copy of the GNU Library General Public License
920- * along with this library; see the file COPYING.LIB. If not, write to
921- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
922- * Boston, MA 02110-1301, USA.
923- */
924-
925-#include "config.h"
926-#include "Page.h"
927-
928-#include "AlternativeTextClient.h"
929-#include "BackForwardController.h"
930-#include "BackForwardList.h"
931-#include "Chrome.h"
932-#include "ChromeClient.h"
933-#include "ContextMenuClient.h"
934-#include "ContextMenuController.h"
935-#include "DOMWindow.h"
936-#include "DocumentMarkerController.h"
937-#include "DocumentStyleSheetCollection.h"
938-#include "DragController.h"
939-#include "EditorClient.h"
940-#include "Event.h"
941-#include "EventNames.h"
942-#include "ExceptionCode.h"
943-#include "FileSystem.h"
944-#include "FocusController.h"
945-#include "Frame.h"
946-#include "FrameLoader.h"
947-#include "FrameLoaderClient.h"
948-#include "FrameSelection.h"
949-#include "FrameTree.h"
950-#include "FrameView.h"
951-#include "HTMLElement.h"
952-#include "HistoryItem.h"
953-#include "InspectorController.h"
954-#include "InspectorInstrumentation.h"
955-#include "Logging.h"
956-#include "MediaCanStartListener.h"
957-#include "Navigator.h"
958-#include "NetworkStateNotifier.h"
959-#include "PageCache.h"
960-#include "PageGroup.h"
961-#include "PluginData.h"
962-#include "PluginView.h"
963-#include "PointerLockController.h"
964-#include "ProgressTracker.h"
965-#include "RenderArena.h"
966-#include "RenderTheme.h"
967-#include "RenderView.h"
968-#include "RenderWidget.h"
969-#include "RuntimeEnabledFeatures.h"
970-#include "SchemeRegistry.h"
971-#include "ScrollingCoordinator.h"
972-#include "Settings.h"
973-#include "SharedBuffer.h"
974-#include "StorageArea.h"
975-#include "StorageNamespace.h"
976-#include "StyleResolver.h"
977-#include "TextResourceDecoder.h"
978-#include "VoidCallback.h"
979-#include "WebCoreMemoryInstrumentation.h"
980-#include "Widget.h"
981-#include <wtf/HashMap.h>
982-#include <wtf/RefCountedLeakCounter.h>
983-#include <wtf/StdLibExtras.h>
984-#include <wtf/text/Base64.h>
985-#include <wtf/text/StringHash.h>
986-
987-namespace WebCore {
988-
989-static HashSet<Page*>* allPages;
990-static const double hiddenPageTimerAlignmentInterval = 1.0; // once a second
991-
992-DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
993-
994-static void networkStateChanged()
995-{
996- Vector<RefPtr<Frame> > frames;
997-
998- // Get all the frames of all the pages in all the page groups
999- HashSet<Page*>::iterator end = allPages->end();
1000- for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
1001- for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
1002- frames.append(frame);
1003- InspectorInstrumentation::networkStateChanged(*it);
1004- }
1005-
1006- AtomicString eventName = networkStateNotifier().onLine() ? eventNames().onlineEvent : eventNames().offlineEvent;
1007- for (unsigned i = 0; i < frames.size(); i++)
1008- frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false));
1009-}
1010-
1011-float deviceScaleFactor(Frame* frame)
1012-{
1013- if (!frame)
1014- return 1;
1015- Page* page = frame->page();
1016- if (!page)
1017- return 1;
1018- return page->deviceScaleFactor();
1019-}
1020-
1021-Page::Page(PageClients& pageClients)
1022- : m_chrome(Chrome::create(this, pageClients.chromeClient))
1023- , m_dragCaretController(DragCaretController::create())
1024-#if ENABLE(DRAG_SUPPORT)
1025- , m_dragController(DragController::create(this, pageClients.dragClient))
1026-#endif
1027- , m_focusController(FocusController::create(this))
1028-#if ENABLE(CONTEXT_MENUS)
1029- , m_contextMenuController(ContextMenuController::create(this, pageClients.contextMenuClient))
1030-#endif
1031-#if ENABLE(INSPECTOR)
1032- , m_inspectorController(InspectorController::create(this, pageClients.inspectorClient))
1033-#endif
1034-#if ENABLE(POINTER_LOCK)
1035- , m_pointerLockController(PointerLockController::create(this))
1036-#endif
1037- , m_settings(Settings::create(this))
1038- , m_progress(ProgressTracker::create())
1039- , m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
1040- , m_theme(RenderTheme::themeForPage(this))
1041- , m_editorClient(pageClients.editorClient)
1042- , m_validationMessageClient(pageClients.validationMessageClient)
1043- , m_subframeCount(0)
1044- , m_openedByDOM(false)
1045- , m_tabKeyCyclesThroughElements(true)
1046- , m_defersLoading(false)
1047- , m_defersLoadingCallCount(0)
1048- , m_inLowQualityInterpolationMode(false)
1049- , m_cookieEnabled(true)
1050- , m_areMemoryCacheClientCallsEnabled(true)
1051- , m_mediaVolume(1)
1052- , m_pageScaleFactor(1)
1053- , m_deviceScaleFactor(1)
1054- , m_suppressScrollbarAnimations(false)
1055- , m_didLoadUserStyleSheet(false)
1056- , m_userStyleSheetModificationTime(0)
1057- , m_group(0)
1058- , m_debugger(0)
1059- , m_customHTMLTokenizerTimeDelay(-1)
1060- , m_customHTMLTokenizerChunkSize(-1)
1061- , m_canStartMedia(true)
1062- , m_viewMode(ViewModeWindowed)
1063- , m_minimumTimerInterval(Settings::defaultMinDOMTimerInterval())
1064- , m_timerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval())
1065- , m_isEditable(false)
1066- , m_isOnscreen(true)
1067-#if ENABLE(PAGE_VISIBILITY_API)
1068- , m_visibilityState(PageVisibilityStateVisible)
1069-#endif
1070- , m_displayID(0)
1071- , m_layoutMilestones(0)
1072- , m_isCountingRelevantRepaintedObjects(false)
1073-#ifndef NDEBUG
1074- , m_isPainting(false)
1075-#endif
1076- , m_alternativeTextClient(pageClients.alternativeTextClient)
1077- , m_scriptedAnimationsSuspended(false)
1078-{
1079- ASSERT(m_editorClient);
1080-
1081- if (!allPages) {
1082- allPages = new HashSet<Page*>;
1083-
1084- networkStateNotifier().setNetworkStateChangedFunction(networkStateChanged);
1085- }
1086-
1087- ASSERT(!allPages->contains(this));
1088- allPages->add(this);
1089-
1090-#ifndef NDEBUG
1091- pageCounter.increment();
1092-#endif
1093-}
1094-
1095-Page::~Page()
1096-{
1097- m_mainFrame->setView(0);
1098- setGroupName(String());
1099- allPages->remove(this);
1100-
1101- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1102- frame->willDetachPage();
1103- frame->detachFromPage();
1104- }
1105-
1106- m_editorClient->pageDestroyed();
1107- if (m_alternativeTextClient)
1108- m_alternativeTextClient->pageDestroyed();
1109-
1110-#if ENABLE(INSPECTOR)
1111- m_inspectorController->inspectedPageDestroyed();
1112-#endif
1113-
1114- if (m_scrollingCoordinator)
1115- m_scrollingCoordinator->pageDestroyed();
1116-
1117- backForward()->close();
1118-
1119-#ifndef NDEBUG
1120- pageCounter.decrement();
1121-#endif
1122-
1123-}
1124-
1125-ArenaSize Page::renderTreeSize() const
1126-{
1127- ArenaSize total(0, 0);
1128- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1129- if (!frame->document())
1130- continue;
1131- if (RenderArena* arena = frame->document()->renderArena()) {
1132- total.treeSize += arena->totalRenderArenaSize();
1133- total.allocated += arena->totalRenderArenaAllocatedBytes();
1134- }
1135- }
1136- return total;
1137-}
1138-
1139-ViewportArguments Page::viewportArguments() const
1140-{
1141- return mainFrame() && mainFrame()->document() ? mainFrame()->document()->viewportArguments() : ViewportArguments();
1142-}
1143-
1144-ScrollingCoordinator* Page::scrollingCoordinator()
1145-{
1146- if (!m_scrollingCoordinator && m_settings->scrollingCoordinatorEnabled())
1147- m_scrollingCoordinator = ScrollingCoordinator::create(this);
1148-
1149- return m_scrollingCoordinator.get();
1150-}
1151-
1152-String Page::scrollingStateTreeAsText()
1153-{
1154- if (Document* document = m_mainFrame->document())
1155- document->updateLayout();
1156-
1157- if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
1158- return scrollingCoordinator->scrollingStateTreeAsText();
1159-
1160- return String();
1161-}
1162-
1163-struct ViewModeInfo {
1164- const char* name;
1165- Page::ViewMode type;
1166-};
1167-static const int viewModeMapSize = 5;
1168-static ViewModeInfo viewModeMap[viewModeMapSize] = {
1169- {"windowed", Page::ViewModeWindowed},
1170- {"floating", Page::ViewModeFloating},
1171- {"fullscreen", Page::ViewModeFullscreen},
1172- {"maximized", Page::ViewModeMaximized},
1173- {"minimized", Page::ViewModeMinimized}
1174-};
1175-
1176-Page::ViewMode Page::stringToViewMode(const String& text)
1177-{
1178- for (int i = 0; i < viewModeMapSize; ++i) {
1179- if (text == viewModeMap[i].name)
1180- return viewModeMap[i].type;
1181- }
1182- return Page::ViewModeInvalid;
1183-}
1184-
1185-void Page::setViewMode(ViewMode viewMode)
1186-{
1187- if (viewMode == m_viewMode || viewMode == ViewModeInvalid)
1188- return;
1189-
1190- m_viewMode = viewMode;
1191-
1192- if (!m_mainFrame)
1193- return;
1194-
1195- if (m_mainFrame->view())
1196- m_mainFrame->view()->forceLayout();
1197-
1198- if (m_mainFrame->document())
1199- m_mainFrame->document()->styleResolverChanged(RecalcStyleImmediately);
1200-}
1201-
1202-void Page::setMainFrame(PassRefPtr<Frame> mainFrame)
1203-{
1204- ASSERT(!m_mainFrame); // Should only be called during initialization
1205- m_mainFrame = mainFrame;
1206-}
1207-
1208-bool Page::openedByDOM() const
1209-{
1210- return m_openedByDOM;
1211-}
1212-
1213-void Page::setOpenedByDOM()
1214-{
1215- m_openedByDOM = true;
1216-}
1217-
1218-BackForwardList* Page::backForwardList() const
1219-{
1220- return m_backForwardController->client();
1221-}
1222-
1223-bool Page::goBack()
1224-{
1225- HistoryItem* item = backForward()->backItem();
1226-
1227- if (item) {
1228- goToItem(item, FrameLoadTypeBack);
1229- return true;
1230- }
1231- return false;
1232-}
1233-
1234-bool Page::goForward()
1235-{
1236- HistoryItem* item = backForward()->forwardItem();
1237-
1238- if (item) {
1239- goToItem(item, FrameLoadTypeForward);
1240- return true;
1241- }
1242- return false;
1243-}
1244-
1245-bool Page::canGoBackOrForward(int distance) const
1246-{
1247- if (distance == 0)
1248- return true;
1249- if (distance > 0 && distance <= backForward()->forwardCount())
1250- return true;
1251- if (distance < 0 && -distance <= backForward()->backCount())
1252- return true;
1253- return false;
1254-}
1255-
1256-void Page::goBackOrForward(int distance)
1257-{
1258- if (distance == 0)
1259- return;
1260-
1261- HistoryItem* item = backForward()->itemAtIndex(distance);
1262- if (!item) {
1263- if (distance > 0) {
1264- if (int forwardCount = backForward()->forwardCount())
1265- item = backForward()->itemAtIndex(forwardCount);
1266- } else {
1267- if (int backCount = backForward()->backCount())
1268- item = backForward()->itemAtIndex(-backCount);
1269- }
1270- }
1271-
1272- if (!item)
1273- return;
1274-
1275- goToItem(item, FrameLoadTypeIndexedBackForward);
1276-}
1277-
1278-void Page::goToItem(HistoryItem* item, FrameLoadType type)
1279-{
1280- // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem
1281- // being deref()-ed. Make sure we can still use it with HistoryController::goToItem later.
1282- RefPtr<HistoryItem> protector(item);
1283-
1284- if (m_mainFrame->loader()->history()->shouldStopLoadingForHistoryItem(item))
1285- m_mainFrame->loader()->stopAllLoaders();
1286-
1287- m_mainFrame->loader()->history()->goToItem(item, type);
1288-}
1289-
1290-int Page::getHistoryLength()
1291-{
1292- return backForward()->backCount() + 1 + backForward()->forwardCount();
1293-}
1294-
1295-void Page::setGroupName(const String& name)
1296-{
1297- if (m_group && !m_group->name().isEmpty()) {
1298- ASSERT(m_group != m_singlePageGroup.get());
1299- ASSERT(!m_singlePageGroup);
1300- m_group->removePage(this);
1301- }
1302-
1303- if (name.isEmpty())
1304- m_group = m_singlePageGroup.get();
1305- else {
1306- m_singlePageGroup.clear();
1307- m_group = PageGroup::pageGroup(name);
1308- m_group->addPage(this);
1309- }
1310-}
1311-
1312-const String& Page::groupName() const
1313-{
1314- DEFINE_STATIC_LOCAL(String, nullString, ());
1315- // FIXME: Why not just return String()?
1316- return m_group ? m_group->name() : nullString;
1317-}
1318-
1319-void Page::initGroup()
1320-{
1321- ASSERT(!m_singlePageGroup);
1322- ASSERT(!m_group);
1323- m_singlePageGroup = PageGroup::create(this);
1324- m_group = m_singlePageGroup.get();
1325-}
1326-
1327-void Page::scheduleForcedStyleRecalcForAllPages()
1328-{
1329- if (!allPages)
1330- return;
1331- HashSet<Page*>::iterator end = allPages->end();
1332- for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
1333- for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
1334- frame->document()->scheduleForcedStyleRecalc();
1335-}
1336-
1337-void Page::setNeedsRecalcStyleInAllFrames()
1338-{
1339- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1340- frame->document()->styleResolverChanged(DeferRecalcStyle);
1341-}
1342-
1343-void Page::refreshPlugins(bool reload)
1344-{
1345- if (!allPages)
1346- return;
1347-
1348- PluginData::refresh();
1349-
1350- Vector<RefPtr<Frame> > framesNeedingReload;
1351-
1352- HashSet<Page*>::iterator end = allPages->end();
1353- for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
1354- Page* page = *it;
1355-
1356- // Clear out the page's plug-in data.
1357- if (page->m_pluginData)
1358- page->m_pluginData = 0;
1359-
1360- if (!reload)
1361- continue;
1362-
1363- for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1364- if (frame->loader()->subframeLoader()->containsPlugins())
1365- framesNeedingReload.append(frame);
1366- }
1367- }
1368-
1369- for (size_t i = 0; i < framesNeedingReload.size(); ++i)
1370- framesNeedingReload[i]->loader()->reload();
1371-}
1372-
1373-PluginData* Page::pluginData() const
1374-{
1375- if (!mainFrame()->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
1376- return 0;
1377- if (!m_pluginData)
1378- m_pluginData = PluginData::create(this);
1379- return m_pluginData.get();
1380-}
1381-
1382-inline MediaCanStartListener* Page::takeAnyMediaCanStartListener()
1383-{
1384- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1385- if (MediaCanStartListener* listener = frame->document()->takeAnyMediaCanStartListener())
1386- return listener;
1387- }
1388- return 0;
1389-}
1390-
1391-void Page::setCanStartMedia(bool canStartMedia)
1392-{
1393- if (m_canStartMedia == canStartMedia)
1394- return;
1395-
1396- m_canStartMedia = canStartMedia;
1397-
1398- while (m_canStartMedia) {
1399- MediaCanStartListener* listener = takeAnyMediaCanStartListener();
1400- if (!listener)
1401- break;
1402- listener->mediaCanStart();
1403- }
1404-}
1405-
1406-static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
1407-{
1408- return forward
1409- ? curr->tree()->traverseNextWithWrap(wrapFlag)
1410- : curr->tree()->traversePreviousWithWrap(wrapFlag);
1411-}
1412-
1413-bool Page::findString(const String& target, TextCaseSensitivity caseSensitivity, FindDirection direction, bool shouldWrap)
1414-{
1415- return findString(target, (caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0) | (direction == FindDirectionBackward ? Backwards : 0) | (shouldWrap ? WrapAround : 0));
1416-}
1417-
1418-bool Page::findString(const String& target, FindOptions options)
1419-{
1420- if (target.isEmpty() || !mainFrame())
1421- return false;
1422-
1423- bool shouldWrap = options & WrapAround;
1424- Frame* frame = focusController()->focusedOrMainFrame();
1425- Frame* startFrame = frame;
1426- do {
1427- if (frame->editor()->findString(target, (options & ~WrapAround) | StartInSelection)) {
1428- if (frame != startFrame)
1429- startFrame->selection()->clear();
1430- focusController()->setFocusedFrame(frame);
1431- return true;
1432- }
1433- frame = incrementFrame(frame, !(options & Backwards), shouldWrap);
1434- } while (frame && frame != startFrame);
1435-
1436- // Search contents of startFrame, on the other side of the selection that we did earlier.
1437- // We cheat a bit and just research with wrap on
1438- if (shouldWrap && !startFrame->selection()->isNone()) {
1439- bool found = startFrame->editor()->findString(target, options | WrapAround | StartInSelection);
1440- focusController()->setFocusedFrame(frame);
1441- return found;
1442- }
1443-
1444- return false;
1445-}
1446-
1447-PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options)
1448-{
1449- if (target.isEmpty() || !mainFrame())
1450- return 0;
1451-
1452- if (referenceRange && referenceRange->ownerDocument()->page() != this)
1453- return 0;
1454-
1455- bool shouldWrap = options & WrapAround;
1456- Frame* frame = referenceRange ? referenceRange->ownerDocument()->frame() : mainFrame();
1457- Frame* startFrame = frame;
1458- do {
1459- if (RefPtr<Range> resultRange = frame->editor()->rangeOfString(target, frame == startFrame ? referenceRange : 0, options & ~WrapAround))
1460- return resultRange.release();
1461-
1462- frame = incrementFrame(frame, !(options & Backwards), shouldWrap);
1463- } while (frame && frame != startFrame);
1464-
1465- // Search contents of startFrame, on the other side of the reference range that we did earlier.
1466- // We cheat a bit and just search again with wrap on.
1467- if (shouldWrap && referenceRange) {
1468- if (RefPtr<Range> resultRange = startFrame->editor()->rangeOfString(target, referenceRange, options | WrapAround | StartInSelection))
1469- return resultRange.release();
1470- }
1471-
1472- return 0;
1473-}
1474-
1475-unsigned int Page::markAllMatchesForText(const String& target, TextCaseSensitivity caseSensitivity, bool shouldHighlight, unsigned limit)
1476-{
1477- return markAllMatchesForText(target, caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0, shouldHighlight, limit);
1478-}
1479-
1480-unsigned int Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned limit)
1481-{
1482- if (target.isEmpty() || !mainFrame())
1483- return 0;
1484-
1485- unsigned matches = 0;
1486-
1487- Frame* frame = mainFrame();
1488- do {
1489- frame->editor()->setMarkedTextMatchesAreHighlighted(shouldHighlight);
1490- matches += frame->editor()->countMatchesForText(target, options, limit ? (limit - matches) : 0, true);
1491- frame = incrementFrame(frame, true, false);
1492- } while (frame);
1493-
1494- return matches;
1495-}
1496-
1497-void Page::unmarkAllTextMatches()
1498-{
1499- if (!mainFrame())
1500- return;
1501-
1502- Frame* frame = mainFrame();
1503- do {
1504- frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch);
1505- frame = incrementFrame(frame, true, false);
1506- } while (frame);
1507-}
1508-
1509-const VisibleSelection& Page::selection() const
1510-{
1511- return focusController()->focusedOrMainFrame()->selection()->selection();
1512-}
1513-
1514-void Page::setDefersLoading(bool defers)
1515-{
1516- if (!m_settings->loadDeferringEnabled())
1517- return;
1518-
1519- if (m_settings->wantsBalancedSetDefersLoadingBehavior()) {
1520- ASSERT(defers || m_defersLoadingCallCount);
1521- if (defers && ++m_defersLoadingCallCount > 1)
1522- return;
1523- if (!defers && --m_defersLoadingCallCount)
1524- return;
1525- } else {
1526- ASSERT(!m_defersLoadingCallCount);
1527- if (defers == m_defersLoading)
1528- return;
1529- }
1530-
1531- m_defersLoading = defers;
1532- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1533- frame->loader()->setDefersLoading(defers);
1534-}
1535-
1536-void Page::clearUndoRedoOperations()
1537-{
1538- m_editorClient->clearUndoRedoOperations();
1539-}
1540-
1541-bool Page::inLowQualityImageInterpolationMode() const
1542-{
1543- return m_inLowQualityInterpolationMode;
1544-}
1545-
1546-void Page::setInLowQualityImageInterpolationMode(bool mode)
1547-{
1548- m_inLowQualityInterpolationMode = mode;
1549-}
1550-
1551-void Page::setMediaVolume(float volume)
1552-{
1553- if (volume < 0 || volume > 1)
1554- return;
1555-
1556- if (m_mediaVolume == volume)
1557- return;
1558-
1559- m_mediaVolume = volume;
1560- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1561- frame->document()->mediaVolumeDidChange();
1562- }
1563-}
1564-
1565-void Page::setPageScaleFactor(float scale, const IntPoint& origin)
1566-{
1567- Document* document = mainFrame()->document();
1568- FrameView* view = document->view();
1569-
1570- if (scale == m_pageScaleFactor) {
1571- if (view && (view->scrollPosition() != origin || view->delegatesScrolling())) {
1572- document->updateLayoutIgnorePendingStylesheets();
1573- view->setScrollPosition(origin);
1574- }
1575- return;
1576- }
1577-
1578- m_pageScaleFactor = scale;
1579-
1580- if (document->renderer())
1581- document->renderer()->setNeedsLayout(true);
1582-
1583- document->recalcStyle(Node::Force);
1584-
1585- // Transform change on RenderView doesn't trigger repaint on non-composited contents.
1586- mainFrame()->view()->invalidateRect(IntRect(LayoutRect::infiniteRect()));
1587-
1588-#if USE(ACCELERATED_COMPOSITING)
1589- mainFrame()->deviceOrPageScaleFactorChanged();
1590-#endif
1591-
1592- if (view && view->scrollPosition() != origin) {
1593- if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
1594- view->layout();
1595- view->setScrollPosition(origin);
1596- }
1597-}
1598-
1599-
1600-void Page::setDeviceScaleFactor(float scaleFactor)
1601-{
1602- if (m_deviceScaleFactor == scaleFactor)
1603- return;
1604-
1605- m_deviceScaleFactor = scaleFactor;
1606- setNeedsRecalcStyleInAllFrames();
1607-
1608-#if USE(ACCELERATED_COMPOSITING)
1609- if (mainFrame())
1610- mainFrame()->deviceOrPageScaleFactorChanged();
1611-#endif
1612-
1613- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1614- frame->editor()->deviceScaleFactorChanged();
1615-
1616- pageCache()->markPagesForFullStyleRecalc(this);
1617-}
1618-
1619-void Page::setShouldSuppressScrollbarAnimations(bool suppressAnimations)
1620-{
1621- if (suppressAnimations == m_suppressScrollbarAnimations)
1622- return;
1623-
1624- if (!suppressAnimations) {
1625- // If animations are not going to be suppressed anymore, then there is nothing to do here but
1626- // change the cached value.
1627- m_suppressScrollbarAnimations = suppressAnimations;
1628- return;
1629- }
1630-
1631- // On the other hand, if we are going to start suppressing animations, then we need to make sure we
1632- // finish any current scroll animations first.
1633- FrameView* view = mainFrame()->view();
1634- if (!view)
1635- return;
1636-
1637- view->finishCurrentScrollAnimations();
1638-
1639- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1640- FrameView* frameView = frame->view();
1641- if (!frameView)
1642- continue;
1643-
1644- const HashSet<ScrollableArea*>* scrollableAreas = frameView->scrollableAreas();
1645- if (!scrollableAreas)
1646- continue;
1647-
1648- for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
1649- ScrollableArea* scrollableArea = *it;
1650- ASSERT(scrollableArea->scrollbarsCanBeActive());
1651-
1652- scrollableArea->finishCurrentScrollAnimations();
1653- }
1654- }
1655-
1656- m_suppressScrollbarAnimations = suppressAnimations;
1657-}
1658-
1659-void Page::setPagination(const Pagination& pagination)
1660-{
1661- if (m_pagination == pagination)
1662- return;
1663-
1664- m_pagination = pagination;
1665-
1666- setNeedsRecalcStyleInAllFrames();
1667- pageCache()->markPagesForFullStyleRecalc(this);
1668-}
1669-
1670-unsigned Page::pageCount() const
1671-{
1672- if (m_pagination.mode == Pagination::Unpaginated)
1673- return 0;
1674-
1675- FrameView* frameView = mainFrame()->view();
1676- if (frameView->needsLayout())
1677- frameView->layout();
1678-
1679- RenderView* contentRenderer = mainFrame()->contentRenderer();
1680- return contentRenderer ? contentRenderer->columnCount(contentRenderer->columnInfo()) : 0;
1681-}
1682-
1683-void Page::didMoveOnscreen()
1684-{
1685- m_isOnscreen = true;
1686-
1687- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1688- if (FrameView* frameView = frame->view())
1689- frameView->didMoveOnscreen();
1690- }
1691-
1692- resumeScriptedAnimations();
1693-}
1694-
1695-void Page::willMoveOffscreen()
1696-{
1697- m_isOnscreen = false;
1698-
1699- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1700- if (FrameView* frameView = frame->view())
1701- frameView->willMoveOffscreen();
1702- }
1703-
1704- suspendScriptedAnimations();
1705-}
1706-
1707-void Page::windowScreenDidChange(PlatformDisplayID displayID)
1708-{
1709- m_displayID = displayID;
1710-
1711- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1712- if (frame->document())
1713- frame->document()->windowScreenDidChange(displayID);
1714- }
1715-}
1716-
1717-void Page::suspendScriptedAnimations()
1718-{
1719- m_scriptedAnimationsSuspended = true;
1720- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1721- if (frame->document())
1722- frame->document()->suspendScriptedAnimationControllerCallbacks();
1723- }
1724-}
1725-
1726-void Page::resumeScriptedAnimations()
1727-{
1728- m_scriptedAnimationsSuspended = false;
1729- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1730- if (frame->document())
1731- frame->document()->resumeScriptedAnimationControllerCallbacks();
1732- }
1733-}
1734-
1735-void Page::userStyleSheetLocationChanged()
1736-{
1737- // FIXME: Eventually we will move to a model of just being handed the sheet
1738- // text instead of loading the URL ourselves.
1739- KURL url = m_settings->userStyleSheetLocation();
1740-
1741- // Allow any local file URL scheme to be loaded.
1742- if (SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
1743- m_userStyleSheetPath = url.fileSystemPath();
1744- else
1745- m_userStyleSheetPath = String();
1746-
1747- m_didLoadUserStyleSheet = false;
1748- m_userStyleSheet = String();
1749- m_userStyleSheetModificationTime = 0;
1750-
1751- // Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
1752- // synchronously and avoid using a loader.
1753- if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
1754- m_didLoadUserStyleSheet = true;
1755-
1756- Vector<char> styleSheetAsUTF8;
1757- if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), styleSheetAsUTF8, Base64IgnoreWhitespace))
1758- m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSheetAsUTF8.size());
1759- }
1760-
1761- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1762- if (frame->document())
1763- frame->document()->styleSheetCollection()->updatePageUserStyleSheet();
1764- }
1765-}
1766-
1767-const String& Page::userStyleSheet() const
1768-{
1769- if (m_userStyleSheetPath.isEmpty())
1770- return m_userStyleSheet;
1771-
1772- time_t modTime;
1773- if (!getFileModificationTime(m_userStyleSheetPath, modTime)) {
1774- // The stylesheet either doesn't exist, was just deleted, or is
1775- // otherwise unreadable. If we've read the stylesheet before, we should
1776- // throw away that data now as it no longer represents what's on disk.
1777- m_userStyleSheet = String();
1778- return m_userStyleSheet;
1779- }
1780-
1781- // If the stylesheet hasn't changed since the last time we read it, we can
1782- // just return the old data.
1783- if (m_didLoadUserStyleSheet && modTime <= m_userStyleSheetModificationTime)
1784- return m_userStyleSheet;
1785-
1786- m_didLoadUserStyleSheet = true;
1787- m_userStyleSheet = String();
1788- m_userStyleSheetModificationTime = modTime;
1789-
1790- // FIXME: It would be better to load this asynchronously to avoid blocking
1791- // the process, but we will first need to create an asynchronous loading
1792- // mechanism that is not tied to a particular Frame. We will also have to
1793- // determine what our behavior should be before the stylesheet is loaded
1794- // and what should happen when it finishes loading, especially with respect
1795- // to when the load event fires, when Document::close is called, and when
1796- // layout/paint are allowed to happen.
1797- RefPtr<SharedBuffer> data = SharedBuffer::createWithContentsOfFile(m_userStyleSheetPath);
1798- if (!data)
1799- return m_userStyleSheet;
1800-
1801- RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/css");
1802- m_userStyleSheet = decoder->decode(data->data(), data->size());
1803- m_userStyleSheet.append(decoder->flush());
1804-
1805- return m_userStyleSheet;
1806-}
1807-
1808-void Page::removeAllVisitedLinks()
1809-{
1810- if (!allPages)
1811- return;
1812- HashSet<PageGroup*> groups;
1813- HashSet<Page*>::iterator pagesEnd = allPages->end();
1814- for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1815- if (PageGroup* group = (*it)->groupPtr())
1816- groups.add(group);
1817- }
1818- HashSet<PageGroup*>::iterator groupsEnd = groups.end();
1819- for (HashSet<PageGroup*>::iterator it = groups.begin(); it != groupsEnd; ++it)
1820- (*it)->removeVisitedLinks();
1821-}
1822-
1823-void Page::allVisitedStateChanged(PageGroup* group)
1824-{
1825- ASSERT(group);
1826- if (!allPages)
1827- return;
1828-
1829- HashSet<Page*>::iterator pagesEnd = allPages->end();
1830- for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1831- Page* page = *it;
1832- if (page->m_group != group)
1833- continue;
1834- for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree()->traverseNext()) {
1835- if (StyleResolver* styleResolver = frame->document()->styleResolver())
1836- styleResolver->allVisitedStateChanged();
1837- }
1838- }
1839-}
1840-
1841-void Page::visitedStateChanged(PageGroup* group, LinkHash visitedLinkHash)
1842-{
1843- ASSERT(group);
1844- if (!allPages)
1845- return;
1846-
1847- HashSet<Page*>::iterator pagesEnd = allPages->end();
1848- for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1849- Page* page = *it;
1850- if (page->m_group != group)
1851- continue;
1852- for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree()->traverseNext()) {
1853- if (StyleResolver* styleResolver = frame->document()->styleResolver())
1854- styleResolver->visitedStateChanged(visitedLinkHash);
1855- }
1856- }
1857-}
1858-
1859-void Page::setDebuggerForAllPages(JSC::Debugger* debugger)
1860-{
1861- ASSERT(allPages);
1862-
1863- HashSet<Page*>::iterator end = allPages->end();
1864- for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
1865- (*it)->setDebugger(debugger);
1866-}
1867-
1868-void Page::setDebugger(JSC::Debugger* debugger)
1869-{
1870- if (m_debugger == debugger)
1871- return;
1872-
1873- m_debugger = debugger;
1874-
1875- for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree()->traverseNext())
1876- frame->script()->attachDebugger(m_debugger);
1877-}
1878-
1879-StorageNamespace* Page::sessionStorage(bool optionalCreate)
1880-{
1881- if (!m_sessionStorage && optionalCreate)
1882- m_sessionStorage = StorageNamespace::sessionStorageNamespace(this, m_settings->sessionStorageQuota());
1883-
1884- return m_sessionStorage.get();
1885-}
1886-
1887-void Page::setSessionStorage(PassRefPtr<StorageNamespace> newStorage)
1888-{
1889- m_sessionStorage = newStorage;
1890-}
1891-
1892-void Page::setCustomHTMLTokenizerTimeDelay(double customHTMLTokenizerTimeDelay)
1893-{
1894- if (customHTMLTokenizerTimeDelay < 0) {
1895- m_customHTMLTokenizerTimeDelay = -1;
1896- return;
1897- }
1898- m_customHTMLTokenizerTimeDelay = customHTMLTokenizerTimeDelay;
1899-}
1900-
1901-void Page::setCustomHTMLTokenizerChunkSize(int customHTMLTokenizerChunkSize)
1902-{
1903- if (customHTMLTokenizerChunkSize < 0) {
1904- m_customHTMLTokenizerChunkSize = -1;
1905- return;
1906- }
1907- m_customHTMLTokenizerChunkSize = customHTMLTokenizerChunkSize;
1908-}
1909-
1910-void Page::setMemoryCacheClientCallsEnabled(bool enabled)
1911-{
1912- if (m_areMemoryCacheClientCallsEnabled == enabled)
1913- return;
1914-
1915- m_areMemoryCacheClientCallsEnabled = enabled;
1916- if (!enabled)
1917- return;
1918-
1919- for (RefPtr<Frame> frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1920- frame->loader()->tellClientAboutPastMemoryCacheLoads();
1921-}
1922-
1923-void Page::setMinimumTimerInterval(double minimumTimerInterval)
1924-{
1925- double oldTimerInterval = m_minimumTimerInterval;
1926- m_minimumTimerInterval = minimumTimerInterval;
1927- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNextWithWrap(false)) {
1928- if (frame->document())
1929- frame->document()->adjustMinimumTimerInterval(oldTimerInterval);
1930- }
1931-}
1932-
1933-double Page::minimumTimerInterval() const
1934-{
1935- return m_minimumTimerInterval;
1936-}
1937-
1938-void Page::setTimerAlignmentInterval(double interval)
1939-{
1940- if (interval == m_timerAlignmentInterval)
1941- return;
1942-
1943- m_timerAlignmentInterval = interval;
1944- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNextWithWrap(false)) {
1945- if (frame->document())
1946- frame->document()->didChangeTimerAlignmentInterval();
1947- }
1948-}
1949-
1950-double Page::timerAlignmentInterval() const
1951-{
1952- return m_timerAlignmentInterval;
1953-}
1954-
1955-void Page::dnsPrefetchingStateChanged()
1956-{
1957- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1958- frame->document()->initDNSPrefetch();
1959-}
1960-
1961-void Page::collectPluginViews(Vector<RefPtr<PluginViewBase>, 32>& pluginViewBases)
1962-{
1963- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1964- FrameView* view = frame->view();
1965- if (!view)
1966- return;
1967-
1968- const HashSet<RefPtr<Widget> >* children = view->children();
1969- ASSERT(children);
1970-
1971- HashSet<RefPtr<Widget> >::const_iterator end = children->end();
1972- for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
1973- Widget* widget = (*it).get();
1974- if (widget->isPluginViewBase())
1975- pluginViewBases.append(static_cast<PluginViewBase*>(widget));
1976- }
1977- }
1978-}
1979-
1980-void Page::storageBlockingStateChanged()
1981-{
1982- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1983- frame->document()->storageBlockingStateDidChange();
1984-
1985- // Collect the PluginViews in to a vector to ensure that action the plug-in takes
1986- // from below storageBlockingStateChanged does not affect their lifetime.
1987- Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
1988- collectPluginViews(pluginViewBases);
1989-
1990- for (size_t i = 0; i < pluginViewBases.size(); ++i)
1991- pluginViewBases[i]->storageBlockingStateChanged();
1992-}
1993-
1994-void Page::privateBrowsingStateChanged()
1995-{
1996- bool privateBrowsingEnabled = m_settings->privateBrowsingEnabled();
1997-
1998- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
1999- frame->document()->privateBrowsingStateDidChange();
2000-
2001- // Collect the PluginViews in to a vector to ensure that action the plug-in takes
2002- // from below privateBrowsingStateChanged does not affect their lifetime.
2003- Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
2004- collectPluginViews(pluginViewBases);
2005-
2006- for (size_t i = 0; i < pluginViewBases.size(); ++i)
2007- pluginViewBases[i]->privateBrowsingStateChanged(privateBrowsingEnabled);
2008-}
2009-
2010-#if !ASSERT_DISABLED
2011-void Page::checkSubframeCountConsistency() const
2012-{
2013- ASSERT(m_subframeCount >= 0);
2014-
2015- int subframeCount = 0;
2016- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
2017- ++subframeCount;
2018-
2019- ASSERT(m_subframeCount + 1 == subframeCount);
2020-}
2021-#endif
2022-
2023-#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
2024-void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
2025-{
2026-#if ENABLE(PAGE_VISIBILITY_API)
2027- if (m_visibilityState == visibilityState)
2028- return;
2029- m_visibilityState = visibilityState;
2030-
2031- if (!isInitialState && m_mainFrame)
2032- m_mainFrame->dispatchVisibilityStateChangeEvent();
2033-#endif
2034-
2035-#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
2036- if (visibilityState == WebCore::PageVisibilityStateHidden)
2037- setTimerAlignmentInterval(hiddenPageTimerAlignmentInterval);
2038- else
2039- setTimerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval());
2040-#if !ENABLE(PAGE_VISIBILITY_API)
2041- UNUSED_PARAM(isInitialState);
2042-#endif
2043-#endif
2044-}
2045-#endif // ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
2046-
2047-#if ENABLE(PAGE_VISIBILITY_API)
2048-PageVisibilityState Page::visibilityState() const
2049-{
2050- return m_visibilityState;
2051-}
2052-#endif
2053-
2054-void Page::addLayoutMilestones(LayoutMilestones milestones)
2055-{
2056- // In the future, we may want a function that replaces m_layoutMilestones instead of just adding to it.
2057- m_layoutMilestones |= milestones;
2058-}
2059-
2060-// These are magical constants that might be tweaked over time.
2061-static double gMinimumPaintedAreaRatio = 0.1;
2062-static double gMaximumUnpaintedAreaRatio = 0.04;
2063-
2064-bool Page::isCountingRelevantRepaintedObjects() const
2065-{
2066- return m_isCountingRelevantRepaintedObjects && (m_layoutMilestones & DidHitRelevantRepaintedObjectsAreaThreshold);
2067-}
2068-
2069-void Page::startCountingRelevantRepaintedObjects()
2070-{
2071- // Reset everything in case we didn't hit the threshold last time.
2072- resetRelevantPaintedObjectCounter();
2073-
2074- m_isCountingRelevantRepaintedObjects = true;
2075-}
2076-
2077-void Page::resetRelevantPaintedObjectCounter()
2078-{
2079- m_isCountingRelevantRepaintedObjects = false;
2080- m_relevantUnpaintedRenderObjects.clear();
2081- m_relevantPaintedRegion = Region();
2082- m_relevantUnpaintedRegion = Region();
2083-}
2084-
2085-void Page::addRelevantRepaintedObject(RenderObject* object, const LayoutRect& objectPaintRect)
2086-{
2087- if (!isCountingRelevantRepaintedObjects())
2088- return;
2089-
2090- // The objects are only relevant if they are being painted within the viewRect().
2091- if (RenderView* view = object->view()) {
2092- if (!objectPaintRect.intersects(pixelSnappedIntRect(view->viewRect())))
2093- return;
2094- }
2095-
2096- IntRect snappedPaintRect = pixelSnappedIntRect(objectPaintRect);
2097-
2098- // If this object was previously counted as an unpainted object, remove it from that HashSet
2099- // and corresponding Region. FIXME: This doesn't do the right thing if the objects overlap.
2100- HashSet<RenderObject*>::iterator it = m_relevantUnpaintedRenderObjects.find(object);
2101- if (it != m_relevantUnpaintedRenderObjects.end()) {
2102- m_relevantUnpaintedRenderObjects.remove(it);
2103- m_relevantUnpaintedRegion.subtract(snappedPaintRect);
2104- }
2105-
2106- m_relevantPaintedRegion.unite(snappedPaintRect);
2107-
2108- RenderView* view = object->view();
2109- if (!view)
2110- return;
2111-
2112- float viewArea = view->viewRect().width() * view->viewRect().height();
2113- float ratioOfViewThatIsPainted = m_relevantPaintedRegion.totalArea() / viewArea;
2114- float ratioOfViewThatIsUnpainted = m_relevantUnpaintedRegion.totalArea() / viewArea;
2115-
2116- if (ratioOfViewThatIsPainted > gMinimumPaintedAreaRatio && ratioOfViewThatIsUnpainted < gMaximumUnpaintedAreaRatio) {
2117- m_isCountingRelevantRepaintedObjects = false;
2118- resetRelevantPaintedObjectCounter();
2119- if (Frame* frame = mainFrame())
2120- frame->loader()->didLayout(DidHitRelevantRepaintedObjectsAreaThreshold);
2121- }
2122-}
2123-
2124-void Page::addRelevantUnpaintedObject(RenderObject* object, const LayoutRect& objectPaintRect)
2125-{
2126- if (!isCountingRelevantRepaintedObjects())
2127- return;
2128-
2129- // The objects are only relevant if they are being painted within the viewRect().
2130- if (RenderView* view = object->view()) {
2131- if (!objectPaintRect.intersects(pixelSnappedIntRect(view->viewRect())))
2132- return;
2133- }
2134-
2135- m_relevantUnpaintedRenderObjects.add(object);
2136- m_relevantUnpaintedRegion.unite(pixelSnappedIntRect(objectPaintRect));
2137-}
2138-
2139-void Page::suspendActiveDOMObjectsAndAnimations()
2140-{
2141- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
2142- frame->suspendActiveDOMObjectsAndAnimations();
2143-}
2144-
2145-void Page::resumeActiveDOMObjectsAndAnimations()
2146-{
2147- for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext())
2148- frame->resumeActiveDOMObjectsAndAnimations();
2149-}
2150-
2151-bool Page::hasSeenAnyPlugin() const
2152-{
2153- return !m_seenPlugins.isEmpty();
2154-}
2155-
2156-bool Page::hasSeenPlugin(const String& serviceType) const
2157-{
2158- return m_seenPlugins.contains(serviceType);
2159-}
2160-
2161-void Page::sawPlugin(const String& serviceType)
2162-{
2163- m_seenPlugins.add(serviceType);
2164-}
2165-
2166-void Page::resetSeenPlugins()
2167-{
2168- m_seenPlugins.clear();
2169-}
2170-
2171-bool Page::hasSeenAnyMediaEngine() const
2172-{
2173- return !m_seenMediaEngines.isEmpty();
2174-}
2175-
2176-bool Page::hasSeenMediaEngine(const String& engineDescription) const
2177-{
2178- return m_seenMediaEngines.contains(engineDescription);
2179-}
2180-
2181-void Page::sawMediaEngine(const String& engineDescription)
2182-{
2183- m_seenMediaEngines.add(engineDescription);
2184-}
2185-
2186-void Page::resetSeenMediaEngines()
2187-{
2188- m_seenMediaEngines.clear();
2189-}
2190-
2191-void Page::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
2192-{
2193- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Page);
2194- info.addMember(m_chrome);
2195- info.addMember(m_dragCaretController);
2196-
2197-#if ENABLE(DRAG_SUPPORT)
2198- info.addMember(m_dragController);
2199-#endif
2200- info.addMember(m_focusController);
2201-#if ENABLE(CONTEXT_MENUS)
2202- info.addMember(m_contextMenuController);
2203-#endif
2204-#if ENABLE(INSPECTOR)
2205- info.addMember(m_inspectorController);
2206-#endif
2207-#if ENABLE(POINTER_LOCK)
2208- info.addMember(m_pointerLockController);
2209-#endif
2210- info.addMember(m_scrollingCoordinator);
2211- info.addMember(m_settings);
2212- info.addMember(m_progress);
2213- info.addMember(m_backForwardController);
2214- info.addMember(m_mainFrame);
2215- info.addMember(m_pluginData);
2216- info.addMember(m_theme);
2217- info.addWeakPointer(m_editorClient);
2218- info.addMember(m_featureObserver);
2219- info.addMember(m_groupName);
2220- info.addMember(m_pagination);
2221- info.addMember(m_userStyleSheetPath);
2222- info.addMember(m_userStyleSheet);
2223- info.addMember(m_singlePageGroup);
2224- info.addMember(m_group);
2225- info.addWeakPointer(m_debugger);
2226- info.addMember(m_sessionStorage);
2227- info.addMember(m_relevantUnpaintedRenderObjects);
2228- info.addMember(m_relevantPaintedRegion);
2229- info.addMember(m_relevantUnpaintedRegion);
2230- info.addWeakPointer(m_alternativeTextClient);
2231- info.addMember(m_seenPlugins);
2232-}
2233-
2234-Page::PageClients::PageClients()
2235- : alternativeTextClient(0)
2236- , chromeClient(0)
2237-#if ENABLE(CONTEXT_MENUS)
2238- , contextMenuClient(0)
2239-#endif
2240- , editorClient(0)
2241- , dragClient(0)
2242- , inspectorClient(0)
2243- , validationMessageClient(0)
2244-{
2245-}
2246-
2247-Page::PageClients::~PageClients()
2248-{
2249-}
2250-
2251-} // namespace WebCore
2252
2253=== removed directory '.pc/disable_geolocation_501.diff'
2254=== removed directory '.pc/disable_geolocation_501.diff/Source'
2255=== removed directory '.pc/disable_geolocation_501.diff/Source/WebKit'
2256=== removed directory '.pc/disable_geolocation_501.diff/Source/WebKit/qt'
2257=== removed directory '.pc/disable_geolocation_501.diff/Source/WebKit/qt/Api'
2258=== removed file '.pc/disable_geolocation_501.diff/Source/WebKit/qt/Api/qwebpage.cpp'
2259--- .pc/disable_geolocation_501.diff/Source/WebKit/qt/Api/qwebpage.cpp 2013-02-18 14:24:18 +0000
2260+++ .pc/disable_geolocation_501.diff/Source/WebKit/qt/Api/qwebpage.cpp 1970-01-01 00:00:00 +0000
2261@@ -1,4103 +0,0 @@
2262-/*
2263- Copyright (C) 2008, 2009, 2012 Nokia Corporation and/or its subsidiary(-ies)
2264- Copyright (C) 2007 Staikos Computing Services Inc.
2265- Copyright (C) 2007 Apple Inc.
2266-
2267- This library is free software; you can redistribute it and/or
2268- modify it under the terms of the GNU Library General Public
2269- License as published by the Free Software Foundation; either
2270- version 2 of the License, or (at your option) any later version.
2271-
2272- This library is distributed in the hope that it will be useful,
2273- but WITHOUT ANY WARRANTY; without even the implied warranty of
2274- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2275- Library General Public License for more details.
2276-
2277- You should have received a copy of the GNU Library General Public License
2278- along with this library; see the file COPYING.LIB. If not, write to
2279- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2280- Boston, MA 02110-1301, USA.
2281-*/
2282-
2283-#include "config.h"
2284-#include "qwebpage.h"
2285-
2286-#include "qwebview.h"
2287-#include "qwebframe.h"
2288-#include "qwebpage_p.h"
2289-#include "qwebframe_p.h"
2290-#include "qwebhistory.h"
2291-#include "qwebhistory_p.h"
2292-#include "qwebinspector.h"
2293-#include "qwebinspector_p.h"
2294-#include "qwebsettings.h"
2295-#include "qwebkitplatformplugin.h"
2296-#include "qwebkitversion.h"
2297-
2298-#include "CSSComputedStyleDeclaration.h"
2299-#include "CSSParser.h"
2300-#include "ApplicationCacheStorage.h"
2301-#include "BackForwardListImpl.h"
2302-#include "MemoryCache.h"
2303-#include "Chrome.h"
2304-#include "ChromeClientQt.h"
2305-#include "ClientRect.h"
2306-#include "ContextMenu.h"
2307-#include "ContextMenuClientQt.h"
2308-#include "ContextMenuController.h"
2309-#if ENABLE(DEVICE_ORIENTATION)
2310-#include "DeviceMotionClientQt.h"
2311-#include "DeviceOrientationClientMock.h"
2312-#include "DeviceOrientationClientQt.h"
2313-#endif
2314-#include "DocumentLoader.h"
2315-#include "DragClientQt.h"
2316-#include "DragController.h"
2317-#include "DragData.h"
2318-#include "DragSession.h"
2319-#include "Editor.h"
2320-#include "EditorClientQt.h"
2321-#include "FocusController.h"
2322-#include "FormState.h"
2323-#include "Frame.h"
2324-#include "FrameLoadRequest.h"
2325-#include "FrameLoader.h"
2326-#include "FrameLoader.h"
2327-#include "FrameLoaderClientQt.h"
2328-#include "FrameTree.h"
2329-#include "FrameView.h"
2330-#if ENABLE(GEOLOCATION)
2331-#include "GeolocationClientMock.h"
2332-#include "GeolocationClientQt.h"
2333-#include "GeolocationController.h"
2334-#endif
2335-#include "GeolocationPermissionClientQt.h"
2336-#include "HTMLFormElement.h"
2337-#include "HTMLFrameOwnerElement.h"
2338-#include "HTMLInputElement.h"
2339-#include "HTMLNames.h"
2340-#include "HitTestResult.h"
2341-#include "Image.h"
2342-#include "InitWebCoreQt.h"
2343-#include "InspectorClientQt.h"
2344-#include "InspectorController.h"
2345-#include "InspectorServerQt.h"
2346-#include "KURL.h"
2347-#include "LocalizedStrings.h"
2348-#include "MIMETypeRegistry.h"
2349-#include "NavigationAction.h"
2350-#include "NetworkingContext.h"
2351-#include "NodeList.h"
2352-#include "NotificationPresenterClientQt.h"
2353-#include "NotImplemented.h"
2354-#include "Page.h"
2355-#include "PageClientQt.h"
2356-#include "PageGroup.h"
2357-#include "Pasteboard.h"
2358-#include "PlatformGestureEvent.h"
2359-#include "PlatformKeyboardEvent.h"
2360-#include "PlatformTouchEvent.h"
2361-#include "PlatformWheelEvent.h"
2362-#include "PluginDatabase.h"
2363-#include "PluginDatabase.h"
2364-#include "PluginPackage.h"
2365-#include "ProgressTracker.h"
2366-#include "QtPlatformPlugin.h"
2367-#include "RenderTextControl.h"
2368-#include "RenderThemeQt.h"
2369-#include "SchemeRegistry.h"
2370-#include "Scrollbar.h"
2371-#include "ScrollbarTheme.h"
2372-#include "SecurityOrigin.h"
2373-#include "Settings.h"
2374-#if defined Q_OS_WIN32
2375-#include "SystemInfo.h"
2376-#endif // Q_OS_WIN32
2377-#include "TextIterator.h"
2378-#include "UtilsQt.h"
2379-#include "UserAgentQt.h"
2380-#include "WebEventConversion.h"
2381-#include "WebKitVersion.h"
2382-#include "WindowFeatures.h"
2383-#include "WorkerThread.h"
2384-
2385-#include <QAction>
2386-#include <QApplication>
2387-#include <QBasicTimer>
2388-#include <QBitArray>
2389-#include <QColorDialog>
2390-#include <QDebug>
2391-#include <QDesktopWidget>
2392-#include <QDragEnterEvent>
2393-#include <QDragLeaveEvent>
2394-#include <QDragMoveEvent>
2395-#include <QDropEvent>
2396-#include <QFileDialog>
2397-#include <QGestureEvent>
2398-#include <QInputDialog>
2399-#include <QLabel>
2400-#include <QMenu>
2401-#include <QMessageBox>
2402-#include <QNetworkProxy>
2403-#include <QUndoStack>
2404-#include <QUrl>
2405-#include <QPainter>
2406-#include <QClipboard>
2407-#include <QSslSocket>
2408-#include <QStyle>
2409-#include <QSysInfo>
2410-#include <QTextCharFormat>
2411-#include <QTouchEvent>
2412-#include <QNetworkAccessManager>
2413-#include <QNetworkRequest>
2414-#if defined(Q_WS_X11)
2415-#include <QX11Info>
2416-#endif
2417-#if USE(QT_MOBILITY_SYSTEMINFO)
2418-#include <qsysteminfo.h>
2419-#endif
2420-
2421-using namespace WebCore;
2422-
2423-// from text/qfont.cpp
2424-QT_BEGIN_NAMESPACE
2425-extern Q_GUI_EXPORT int qt_defaultDpi();
2426-QT_END_NAMESPACE
2427-
2428-bool QWebPagePrivate::drtRun = false;
2429-
2430-// Lookup table mapping QWebPage::WebActions to the associated Editor commands
2431-static const char* editorCommandWebActions[] =
2432-{
2433- 0, // OpenLink,
2434-
2435- 0, // OpenLinkInNewWindow,
2436- 0, // OpenFrameInNewWindow,
2437-
2438- 0, // DownloadLinkToDisk,
2439- 0, // CopyLinkToClipboard,
2440-
2441- 0, // OpenImageInNewWindow,
2442- 0, // DownloadImageToDisk,
2443- 0, // CopyImageToClipboard,
2444-
2445- 0, // Back,
2446- 0, // Forward,
2447- 0, // Stop,
2448- 0, // Reload,
2449-
2450- "Cut", // Cut,
2451- "Copy", // Copy,
2452- "Paste", // Paste,
2453-
2454- "Undo", // Undo,
2455- "Redo", // Redo,
2456- "MoveForward", // MoveToNextChar,
2457- "MoveBackward", // MoveToPreviousChar,
2458- "MoveWordForward", // MoveToNextWord,
2459- "MoveWordBackward", // MoveToPreviousWord,
2460- "MoveDown", // MoveToNextLine,
2461- "MoveUp", // MoveToPreviousLine,
2462- "MoveToBeginningOfLine", // MoveToStartOfLine,
2463- "MoveToEndOfLine", // MoveToEndOfLine,
2464- "MoveToBeginningOfParagraph", // MoveToStartOfBlock,
2465- "MoveToEndOfParagraph", // MoveToEndOfBlock,
2466- "MoveToBeginningOfDocument", // MoveToStartOfDocument,
2467- "MoveToEndOfDocument", // MoveToEndOfDocument,
2468- "MoveForwardAndModifySelection", // SelectNextChar,
2469- "MoveBackwardAndModifySelection", // SelectPreviousChar,
2470- "MoveWordForwardAndModifySelection", // SelectNextWord,
2471- "MoveWordBackwardAndModifySelection", // SelectPreviousWord,
2472- "MoveDownAndModifySelection", // SelectNextLine,
2473- "MoveUpAndModifySelection", // SelectPreviousLine,
2474- "MoveToBeginningOfLineAndModifySelection", // SelectStartOfLine,
2475- "MoveToEndOfLineAndModifySelection", // SelectEndOfLine,
2476- "MoveToBeginningOfParagraphAndModifySelection", // SelectStartOfBlock,
2477- "MoveToEndOfParagraphAndModifySelection", // SelectEndOfBlock,
2478- "MoveToBeginningOfDocumentAndModifySelection", //SelectStartOfDocument,
2479- "MoveToEndOfDocumentAndModifySelection", // SelectEndOfDocument,
2480- "DeleteWordBackward", // DeleteStartOfWord,
2481- "DeleteWordForward", // DeleteEndOfWord,
2482-
2483- 0, // SetTextDirectionDefault,
2484- 0, // SetTextDirectionLeftToRight,
2485- 0, // SetTextDirectionRightToLeft,
2486-
2487- "ToggleBold", // ToggleBold,
2488- "ToggleItalic", // ToggleItalic,
2489- "ToggleUnderline", // ToggleUnderline,
2490-
2491- 0, // InspectElement,
2492-
2493- "InsertNewline", // InsertParagraphSeparator
2494- "InsertLineBreak", // InsertLineSeparator
2495-
2496- "SelectAll", // SelectAll
2497- 0, // ReloadAndBypassCache,
2498-
2499- "PasteAndMatchStyle", // PasteAndMatchStyle
2500- "RemoveFormat", // RemoveFormat
2501- "Strikethrough", // ToggleStrikethrough,
2502- "Subscript", // ToggleSubscript
2503- "Superscript", // ToggleSuperscript
2504- "InsertUnorderedList", // InsertUnorderedList
2505- "InsertOrderedList", // InsertOrderedList
2506- "Indent", // Indent
2507- "Outdent", // Outdent,
2508-
2509- "AlignCenter", // AlignCenter,
2510- "AlignJustified", // AlignJustified,
2511- "AlignLeft", // AlignLeft,
2512- "AlignRight", // AlignRight,
2513-
2514- 0, // StopScheduledPageRefresh,
2515-
2516- 0, // CopyImageUrlToClipboard,
2517-
2518- 0, // OpenLinkInThisWindow,
2519-
2520- 0 // WebActionCount
2521-};
2522-
2523-// Lookup the appropriate editor command to use for WebAction \a action
2524-const char* QWebPagePrivate::editorCommandForWebActions(QWebPage::WebAction action)
2525-{
2526- if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*))))
2527- return editorCommandWebActions[action];
2528- return 0;
2529-}
2530-
2531-static inline DragOperation dropActionToDragOp(Qt::DropActions actions)
2532-{
2533- unsigned result = 0;
2534- if (actions & Qt::CopyAction)
2535- result |= DragOperationCopy;
2536- // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
2537- // hence it should be considered as "move"
2538- if (actions & Qt::MoveAction)
2539- result |= (DragOperationMove | DragOperationGeneric);
2540- if (actions & Qt::LinkAction)
2541- result |= DragOperationLink;
2542- if (result == (DragOperationCopy | DragOperationMove | DragOperationGeneric | DragOperationLink))
2543- result = DragOperationEvery;
2544- return (DragOperation)result;
2545-}
2546-
2547-static inline Qt::DropAction dragOpToDropAction(unsigned actions)
2548-{
2549- Qt::DropAction result = Qt::IgnoreAction;
2550- if (actions & DragOperationCopy)
2551- result = Qt::CopyAction;
2552- else if (actions & DragOperationMove)
2553- result = Qt::MoveAction;
2554- // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
2555- // hence it should be considered as "move"
2556- else if (actions & DragOperationGeneric)
2557- result = Qt::MoveAction;
2558- else if (actions & DragOperationLink)
2559- result = Qt::LinkAction;
2560- return result;
2561-}
2562-
2563-QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
2564- : q(qq)
2565- , page(0)
2566-#ifndef QT_NO_UNDOSTACK
2567- , undoStack(0)
2568-#endif
2569- , insideOpenCall(false)
2570- , m_totalBytes(0)
2571- , m_bytesReceived()
2572- , clickCausedFocus(false)
2573- , networkManager(0)
2574- , forwardUnsupportedContent(false)
2575- , smartInsertDeleteEnabled(true)
2576- , selectTrailingWhitespaceEnabled(false)
2577- , linkPolicy(QWebPage::DontDelegateLinks)
2578- , viewportSize(QSize(0, 0))
2579- , settings(0)
2580- , useFixedLayout(false)
2581- , pluginFactory(0)
2582- , inspectorFrontend(0)
2583- , inspector(0)
2584- , inspectorIsInternalOnly(false)
2585- , m_lastDropAction(Qt::IgnoreAction)
2586-{
2587-#if ENABLE(GEOLOCATION) || ENABLE(DEVICE_ORIENTATION)
2588- bool useMock = QWebPagePrivate::drtRun;
2589-#endif
2590-
2591- WebCore::initializeWebCoreQt();
2592-
2593- Page::PageClients pageClients;
2594- pageClients.chromeClient = new ChromeClientQt(q);
2595- pageClients.contextMenuClient = new ContextMenuClientQt();
2596- pageClients.editorClient = new EditorClientQt(q);
2597- pageClients.dragClient = new DragClientQt(q);
2598- pageClients.inspectorClient = new InspectorClientQt(q);
2599- page = new Page(pageClients);
2600-#if ENABLE(GEOLOCATION)
2601- if (useMock) {
2602- // In case running in DumpRenderTree mode set the controller to mock provider.
2603- GeolocationClientMock* mock = new GeolocationClientMock;
2604- WebCore::provideGeolocationTo(page, mock);
2605- mock->setController(WebCore::GeolocationController::from(page));
2606- } else
2607- WebCore::provideGeolocationTo(page, new GeolocationClientQt(q));
2608-#endif
2609-#if ENABLE(DEVICE_ORIENTATION)
2610- if (useMock)
2611- WebCore::provideDeviceOrientationTo(page, new DeviceOrientationClientMock);
2612- else
2613- WebCore::provideDeviceOrientationTo(page, new DeviceOrientationClientQt);
2614- WebCore::provideDeviceMotionTo(page, new DeviceMotionClientQt);
2615-#endif
2616-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
2617- WebCore::provideNotification(page, NotificationPresenterClientQt::notificationPresenter());
2618-#endif
2619-
2620- // By default each page is put into their own unique page group, which affects popup windows
2621- // and visited links. Page groups (per process only) is a feature making it possible to use
2622- // separate settings for each group, so that for instance an integrated browser/email reader
2623- // can use different settings for displaying HTML pages and HTML email. To make QtWebKit work
2624- // as expected out of the box, we use a default group similar to what other ports are doing.
2625- page->setGroupName("Default Group");
2626-
2627- page->addLayoutMilestones(DidFirstVisuallyNonEmptyLayout);
2628-
2629- settings = new QWebSettings(page->settings());
2630-
2631- history.d = new QWebHistoryPrivate(static_cast<WebCore::BackForwardListImpl*>(page->backForwardList()));
2632- memset(actions, 0, sizeof(actions));
2633-
2634- PageGroup::setShouldTrackVisitedLinks(true);
2635-
2636-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
2637- NotificationPresenterClientQt::notificationPresenter()->addClient();
2638-#endif
2639-}
2640-
2641-QWebPagePrivate::~QWebPagePrivate()
2642-{
2643-#ifndef QT_NO_CONTEXTMENU
2644- delete currentContextMenu.data();
2645-#endif
2646-#ifndef QT_NO_UNDOSTACK
2647- delete undoStack;
2648-#endif
2649- delete settings;
2650- delete page;
2651-
2652- if (inspector) {
2653- // If the inspector is ours, delete it, otherwise just detach from it.
2654- if (inspectorIsInternalOnly)
2655- delete inspector;
2656- else
2657- inspector->setPage(0);
2658- }
2659-
2660-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
2661- NotificationPresenterClientQt::notificationPresenter()->removeClient();
2662-#endif
2663-}
2664-
2665-WebCore::ViewportArguments QWebPagePrivate::viewportArguments()
2666-{
2667- return page ? page->viewportArguments() : WebCore::ViewportArguments();
2668-}
2669-
2670-WebCore::Page* QWebPagePrivate::core(const QWebPage* page)
2671-{
2672- return page->d->page;
2673-}
2674-
2675-QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page)
2676-{
2677- return page->d;
2678-}
2679-
2680-bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
2681-{
2682- if (insideOpenCall
2683- && frame == mainFrame.data())
2684- return true;
2685- return q->acceptNavigationRequest(frame, request, type);
2686-}
2687-
2688-void QWebPagePrivate::createMainFrame()
2689-{
2690- if (!mainFrame) {
2691- QWebFrameData frameData(page);
2692- mainFrame = new QWebFrame(q, &frameData);
2693-
2694- emit q->frameCreated(mainFrame.data());
2695- }
2696-}
2697-
2698-static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action)
2699-{
2700- switch (action) {
2701- case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink;
2702- case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow;
2703- case WebCore::ContextMenuItemTagOpenLinkInThisWindow: return QWebPage::OpenLinkInThisWindow;
2704- case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk;
2705- case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard;
2706- case WebCore::ContextMenuItemTagOpenImageInNewWindow: return QWebPage::OpenImageInNewWindow;
2707- case WebCore::ContextMenuItemTagDownloadImageToDisk: return QWebPage::DownloadImageToDisk;
2708- case WebCore::ContextMenuItemTagCopyImageToClipboard: return QWebPage::CopyImageToClipboard;
2709- case WebCore::ContextMenuItemTagCopyImageUrlToClipboard: return QWebPage::CopyImageUrlToClipboard;
2710- case WebCore::ContextMenuItemTagOpenFrameInNewWindow: return QWebPage::OpenFrameInNewWindow;
2711- case WebCore::ContextMenuItemTagCopy: return QWebPage::Copy;
2712- case WebCore::ContextMenuItemTagGoBack: return QWebPage::Back;
2713- case WebCore::ContextMenuItemTagGoForward: return QWebPage::Forward;
2714- case WebCore::ContextMenuItemTagStop: return QWebPage::Stop;
2715- case WebCore::ContextMenuItemTagReload: return QWebPage::Reload;
2716- case WebCore::ContextMenuItemTagCut: return QWebPage::Cut;
2717- case WebCore::ContextMenuItemTagPaste: return QWebPage::Paste;
2718- case WebCore::ContextMenuItemTagDefaultDirection: return QWebPage::SetTextDirectionDefault;
2719- case WebCore::ContextMenuItemTagLeftToRight: return QWebPage::SetTextDirectionLeftToRight;
2720- case WebCore::ContextMenuItemTagRightToLeft: return QWebPage::SetTextDirectionRightToLeft;
2721- case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold;
2722- case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic;
2723- case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline;
2724- case WebCore::ContextMenuItemTagSelectAll: return QWebPage::SelectAll;
2725-#if ENABLE(INSPECTOR)
2726- case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement;
2727-#endif
2728- default: break;
2729- }
2730- return QWebPage::NoWebAction;
2731-}
2732-
2733-#ifndef QT_NO_CONTEXTMENU
2734-QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu,
2735- const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions)
2736-{
2737- if (!client || !webcoreMenu)
2738- return 0;
2739-
2740- QMenu* menu = new QMenu(client->ownerWidget());
2741- for (int i = 0; i < items->count(); ++i) {
2742- const ContextMenuItem &item = items->at(i);
2743- switch (item.type()) {
2744- case WebCore::CheckableActionType: /* fall through */
2745- case WebCore::ActionType: {
2746- QWebPage::WebAction action = webActionForContextMenuAction(item.action());
2747- QAction *a = q->action(action);
2748- if (a) {
2749- ContextMenuItem it(item);
2750- page->contextMenuController()->checkOrEnableIfNeeded(it);
2751- PlatformMenuItemDescription desc = it.releasePlatformDescription();
2752- a->setEnabled(desc.enabled);
2753- a->setChecked(desc.checked);
2754- a->setCheckable(item.type() == WebCore::CheckableActionType);
2755-
2756- menu->addAction(a);
2757- visitedWebActions->setBit(action);
2758- }
2759- break;
2760- }
2761- case WebCore::SeparatorType:
2762- menu->addSeparator();
2763- break;
2764- case WebCore::SubmenuType: {
2765- QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions);
2766-
2767- bool anyEnabledAction = false;
2768-
2769- QList<QAction *> actions = subMenu->actions();
2770- for (int i = 0; i < actions.count(); ++i) {
2771- if (actions.at(i)->isVisible())
2772- anyEnabledAction |= actions.at(i)->isEnabled();
2773- }
2774-
2775- // don't show sub-menus with just disabled actions
2776- if (anyEnabledAction) {
2777- subMenu->setTitle(item.title());
2778- menu->addAction(subMenu->menuAction());
2779- } else
2780- delete subMenu;
2781- break;
2782- }
2783- }
2784- }
2785- return menu;
2786-}
2787-#endif // QT_NO_CONTEXTMENU
2788-
2789-#ifndef QT_NO_ACTION
2790-void QWebPagePrivate::_q_webActionTriggered(bool checked)
2791-{
2792- QAction *a = qobject_cast<QAction *>(q->sender());
2793- if (!a)
2794- return;
2795- QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt());
2796- q->triggerAction(action, checked);
2797-}
2798-#endif // QT_NO_ACTION
2799-
2800-void QWebPagePrivate::_q_cleanupLeakMessages()
2801-{
2802-#ifndef NDEBUG
2803- // Need this to make leak messages accurate.
2804- memoryCache()->setCapacities(0, 0, 0);
2805-#endif
2806-}
2807-
2808-void QWebPagePrivate::updateAction(QWebPage::WebAction action)
2809-{
2810-#ifdef QT_NO_ACTION
2811- Q_UNUSED(action)
2812-#else
2813- QAction *a = actions[action];
2814- if (!a || !mainFrame)
2815- return;
2816-
2817- WebCore::FrameLoader *loader = mainFrame.data()->d->frame->loader();
2818- WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
2819-
2820- bool enabled = a->isEnabled();
2821- bool checked = a->isChecked();
2822-
2823- switch (action) {
2824- case QWebPage::Back:
2825- enabled = page->canGoBackOrForward(-1);
2826- break;
2827- case QWebPage::Forward:
2828- enabled = page->canGoBackOrForward(1);
2829- break;
2830- case QWebPage::Stop:
2831- enabled = loader->isLoading();
2832- break;
2833- case QWebPage::Reload:
2834- case QWebPage::ReloadAndBypassCache:
2835- enabled = !loader->isLoading();
2836- break;
2837-#ifndef QT_NO_UNDOSTACK
2838- case QWebPage::Undo:
2839- case QWebPage::Redo:
2840- // those two are handled by QUndoStack
2841- break;
2842-#endif // QT_NO_UNDOSTACK
2843- case QWebPage::SelectAll: // editor command is always enabled
2844- break;
2845- case QWebPage::SetTextDirectionDefault:
2846- case QWebPage::SetTextDirectionLeftToRight:
2847- case QWebPage::SetTextDirectionRightToLeft:
2848- enabled = editor->canEdit();
2849- checked = false;
2850- break;
2851- default: {
2852- // see if it's an editor command
2853- const char* commandName = editorCommandForWebActions(action);
2854-
2855- // if it's an editor command, let it's logic determine state
2856- if (commandName) {
2857- Editor::Command command = editor->command(commandName);
2858- enabled = command.isEnabled();
2859- if (enabled)
2860- checked = command.state() != FalseTriState;
2861- else
2862- checked = false;
2863- }
2864- break;
2865- }
2866- }
2867-
2868- a->setEnabled(enabled);
2869-
2870- if (a->isCheckable())
2871- a->setChecked(checked);
2872-#endif // QT_NO_ACTION
2873-}
2874-
2875-void QWebPagePrivate::updateNavigationActions()
2876-{
2877- updateAction(QWebPage::Back);
2878- updateAction(QWebPage::Forward);
2879- updateAction(QWebPage::Stop);
2880- updateAction(QWebPage::Reload);
2881- updateAction(QWebPage::ReloadAndBypassCache);
2882-}
2883-
2884-void QWebPagePrivate::updateEditorActions()
2885-{
2886- updateAction(QWebPage::Cut);
2887- updateAction(QWebPage::Copy);
2888- updateAction(QWebPage::Paste);
2889- updateAction(QWebPage::MoveToNextChar);
2890- updateAction(QWebPage::MoveToPreviousChar);
2891- updateAction(QWebPage::MoveToNextWord);
2892- updateAction(QWebPage::MoveToPreviousWord);
2893- updateAction(QWebPage::MoveToNextLine);
2894- updateAction(QWebPage::MoveToPreviousLine);
2895- updateAction(QWebPage::MoveToStartOfLine);
2896- updateAction(QWebPage::MoveToEndOfLine);
2897- updateAction(QWebPage::MoveToStartOfBlock);
2898- updateAction(QWebPage::MoveToEndOfBlock);
2899- updateAction(QWebPage::MoveToStartOfDocument);
2900- updateAction(QWebPage::MoveToEndOfDocument);
2901- updateAction(QWebPage::SelectNextChar);
2902- updateAction(QWebPage::SelectPreviousChar);
2903- updateAction(QWebPage::SelectNextWord);
2904- updateAction(QWebPage::SelectPreviousWord);
2905- updateAction(QWebPage::SelectNextLine);
2906- updateAction(QWebPage::SelectPreviousLine);
2907- updateAction(QWebPage::SelectStartOfLine);
2908- updateAction(QWebPage::SelectEndOfLine);
2909- updateAction(QWebPage::SelectStartOfBlock);
2910- updateAction(QWebPage::SelectEndOfBlock);
2911- updateAction(QWebPage::SelectStartOfDocument);
2912- updateAction(QWebPage::SelectEndOfDocument);
2913- updateAction(QWebPage::DeleteStartOfWord);
2914- updateAction(QWebPage::DeleteEndOfWord);
2915- updateAction(QWebPage::SetTextDirectionDefault);
2916- updateAction(QWebPage::SetTextDirectionLeftToRight);
2917- updateAction(QWebPage::SetTextDirectionRightToLeft);
2918- updateAction(QWebPage::ToggleBold);
2919- updateAction(QWebPage::ToggleItalic);
2920- updateAction(QWebPage::ToggleUnderline);
2921- updateAction(QWebPage::InsertParagraphSeparator);
2922- updateAction(QWebPage::InsertLineSeparator);
2923- updateAction(QWebPage::PasteAndMatchStyle);
2924- updateAction(QWebPage::RemoveFormat);
2925- updateAction(QWebPage::ToggleStrikethrough);
2926- updateAction(QWebPage::ToggleSubscript);
2927- updateAction(QWebPage::ToggleSuperscript);
2928- updateAction(QWebPage::InsertUnorderedList);
2929- updateAction(QWebPage::InsertOrderedList);
2930- updateAction(QWebPage::Indent);
2931- updateAction(QWebPage::Outdent);
2932- updateAction(QWebPage::AlignCenter);
2933- updateAction(QWebPage::AlignJustified);
2934- updateAction(QWebPage::AlignLeft);
2935- updateAction(QWebPage::AlignRight);
2936-}
2937-
2938-void QWebPagePrivate::timerEvent(QTimerEvent *ev)
2939-{
2940- int timerId = ev->timerId();
2941- if (timerId == tripleClickTimer.timerId())
2942- tripleClickTimer.stop();
2943- else
2944- q->timerEvent(ev);
2945-}
2946-
2947-template<class T>
2948-void QWebPagePrivate::mouseMoveEvent(T* ev)
2949-{
2950- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
2951- if (!frame->view())
2952- return;
2953-
2954- bool accepted = frame->eventHandler()->mouseMoved(convertMouseEvent(ev, 0));
2955- ev->setAccepted(accepted);
2956-}
2957-
2958-template<class T>
2959-void QWebPagePrivate::mousePressEvent(T* ev)
2960-{
2961- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
2962- if (!frame->view())
2963- return;
2964-
2965- RefPtr<WebCore::Node> oldNode;
2966- Frame* focusedFrame = page->focusController()->focusedFrame();
2967- if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
2968- oldNode = focusedDocument->focusedNode();
2969-
2970- if (tripleClickTimer.isActive()
2971- && (ev->pos() - tripleClick).manhattanLength()
2972- < QApplication::startDragDistance()) {
2973- mouseTripleClickEvent(ev);
2974- return;
2975- }
2976-
2977- bool accepted = false;
2978- adjustPointForClicking(ev);
2979- PlatformMouseEvent mev = convertMouseEvent(ev, 1);
2980- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
2981- if (mev.button() != NoButton)
2982- accepted = frame->eventHandler()->handleMousePressEvent(mev);
2983- ev->setAccepted(accepted);
2984-
2985- RefPtr<WebCore::Node> newNode;
2986- focusedFrame = page->focusController()->focusedFrame();
2987- if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
2988- newNode = focusedDocument->focusedNode();
2989-
2990- if (newNode && oldNode != newNode)
2991- clickCausedFocus = true;
2992-}
2993-
2994-template<class T>
2995-void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
2996-{
2997- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
2998- if (!frame->view())
2999- return;
3000-
3001- bool accepted = false;
3002- PlatformMouseEvent mev = convertMouseEvent(ev, 2);
3003- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
3004- if (mev.button() != NoButton)
3005- accepted = frame->eventHandler()->handleMousePressEvent(mev);
3006- ev->setAccepted(accepted);
3007-
3008- tripleClickTimer.start(QApplication::doubleClickInterval(), q);
3009- tripleClick = QPointF(ev->pos()).toPoint();
3010-}
3011-
3012-template<class T>
3013-void QWebPagePrivate::mouseTripleClickEvent(T *ev)
3014-{
3015- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
3016- if (!frame->view())
3017- return;
3018-
3019- bool accepted = false;
3020- PlatformMouseEvent mev = convertMouseEvent(ev, 3);
3021- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
3022- if (mev.button() != NoButton)
3023- accepted = frame->eventHandler()->handleMousePressEvent(mev);
3024- ev->setAccepted(accepted);
3025-}
3026-
3027-template<class T>
3028-void QWebPagePrivate::mouseReleaseEvent(T *ev)
3029-{
3030- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
3031- if (!frame->view())
3032- return;
3033-
3034- bool accepted = false;
3035- adjustPointForClicking(ev);
3036- PlatformMouseEvent mev = convertMouseEvent(ev, 0);
3037- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
3038- if (mev.button() != NoButton)
3039- accepted = frame->eventHandler()->handleMouseReleaseEvent(mev);
3040- ev->setAccepted(accepted);
3041-
3042- handleSoftwareInputPanel(ev->button(), QPointF(ev->pos()).toPoint());
3043-}
3044-
3045-void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button, const QPoint& pos)
3046-{
3047- Frame* frame = page->focusController()->focusedFrame();
3048- if (!frame)
3049- return;
3050-
3051- if (client && client->inputMethodEnabled()
3052- && frame->document()->focusedNode()
3053- && button == Qt::LeftButton && qApp->autoSipEnabled()) {
3054- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
3055- client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
3056- if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
3057- HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(pos), false);
3058- if (result.isContentEditable()) {
3059- QEvent event(QEvent::RequestSoftwareInputPanel);
3060- QApplication::sendEvent(client->ownerWidget(), &event);
3061- }
3062- }
3063- }
3064-
3065- clickCausedFocus = false;
3066-}
3067-
3068-#ifndef QT_NO_CONTEXTMENU
3069-void QWebPagePrivate::contextMenuEvent(const QPoint& globalPos)
3070-{
3071- QMenu *menu = q->createStandardContextMenu();
3072- if (menu) {
3073- menu->exec(globalPos);
3074- delete menu;
3075- }
3076-}
3077-#endif // QT_NO_CONTEXTMENU
3078-
3079-/*!
3080- \since 4.5
3081- This function creates the standard context menu which is shown when
3082- the user clicks on the web page with the right mouse button. It is
3083- called from the default contextMenuEvent() handler. The popup menu's
3084- ownership is transferred to the caller.
3085- */
3086-QMenu *QWebPage::createStandardContextMenu()
3087-{
3088-#ifndef QT_NO_CONTEXTMENU
3089- QMenu* menu = d->currentContextMenu.data();
3090- d->currentContextMenu = 0;
3091- return menu;
3092-#else
3093- return 0;
3094-#endif
3095-}
3096-
3097-#ifndef QT_NO_WHEELEVENT
3098-template<class T>
3099-void QWebPagePrivate::wheelEvent(T *ev)
3100-{
3101- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
3102- if (!frame->view())
3103- return;
3104-
3105- PlatformWheelEvent pev = convertWheelEvent(ev);
3106- bool accepted = frame->eventHandler()->handleWheelEvent(pev);
3107- ev->setAccepted(accepted);
3108-}
3109-#endif // QT_NO_WHEELEVENT
3110-
3111-#ifndef QT_NO_SHORTCUT
3112-QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event)
3113-{
3114- static struct {
3115- QKeySequence::StandardKey standardKey;
3116- QWebPage::WebAction action;
3117- } editorActions[] = {
3118- { QKeySequence::Cut, QWebPage::Cut },
3119- { QKeySequence::Copy, QWebPage::Copy },
3120- { QKeySequence::Paste, QWebPage::Paste },
3121- { QKeySequence::Undo, QWebPage::Undo },
3122- { QKeySequence::Redo, QWebPage::Redo },
3123- { QKeySequence::MoveToNextChar, QWebPage::MoveToNextChar },
3124- { QKeySequence::MoveToPreviousChar, QWebPage::MoveToPreviousChar },
3125- { QKeySequence::MoveToNextWord, QWebPage::MoveToNextWord },
3126- { QKeySequence::MoveToPreviousWord, QWebPage::MoveToPreviousWord },
3127- { QKeySequence::MoveToNextLine, QWebPage::MoveToNextLine },
3128- { QKeySequence::MoveToPreviousLine, QWebPage::MoveToPreviousLine },
3129- { QKeySequence::MoveToStartOfLine, QWebPage::MoveToStartOfLine },
3130- { QKeySequence::MoveToEndOfLine, QWebPage::MoveToEndOfLine },
3131- { QKeySequence::MoveToStartOfBlock, QWebPage::MoveToStartOfBlock },
3132- { QKeySequence::MoveToEndOfBlock, QWebPage::MoveToEndOfBlock },
3133- { QKeySequence::MoveToStartOfDocument, QWebPage::MoveToStartOfDocument },
3134- { QKeySequence::MoveToEndOfDocument, QWebPage::MoveToEndOfDocument },
3135- { QKeySequence::SelectNextChar, QWebPage::SelectNextChar },
3136- { QKeySequence::SelectPreviousChar, QWebPage::SelectPreviousChar },
3137- { QKeySequence::SelectNextWord, QWebPage::SelectNextWord },
3138- { QKeySequence::SelectPreviousWord, QWebPage::SelectPreviousWord },
3139- { QKeySequence::SelectNextLine, QWebPage::SelectNextLine },
3140- { QKeySequence::SelectPreviousLine, QWebPage::SelectPreviousLine },
3141- { QKeySequence::SelectStartOfLine, QWebPage::SelectStartOfLine },
3142- { QKeySequence::SelectEndOfLine, QWebPage::SelectEndOfLine },
3143- { QKeySequence::SelectStartOfBlock, QWebPage::SelectStartOfBlock },
3144- { QKeySequence::SelectEndOfBlock, QWebPage::SelectEndOfBlock },
3145- { QKeySequence::SelectStartOfDocument, QWebPage::SelectStartOfDocument },
3146- { QKeySequence::SelectEndOfDocument, QWebPage::SelectEndOfDocument },
3147- { QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord },
3148- { QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord },
3149- { QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator },
3150- { QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator },
3151- { QKeySequence::SelectAll, QWebPage::SelectAll },
3152- { QKeySequence::UnknownKey, QWebPage::NoWebAction }
3153- };
3154-
3155- for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i)
3156- if (event == editorActions[i].standardKey)
3157- return editorActions[i].action;
3158-
3159- return QWebPage::NoWebAction;
3160-}
3161-#endif // QT_NO_SHORTCUT
3162-
3163-void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
3164-{
3165- bool handled = false;
3166- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
3167- // we forward the key event to WebCore first to handle potential DOM
3168- // defined event handlers and later on end up in EditorClientQt::handleKeyboardEvent
3169- // to trigger editor commands via triggerAction().
3170- if (!handled)
3171- handled = frame->eventHandler()->keyEvent(ev);
3172- if (!handled) {
3173- handled = true;
3174- if (!handleScrolling(ev, frame)) {
3175- switch (ev->key()) {
3176- case Qt::Key_Back:
3177- q->triggerAction(QWebPage::Back);
3178- break;
3179- case Qt::Key_Forward:
3180- q->triggerAction(QWebPage::Forward);
3181- break;
3182- case Qt::Key_Stop:
3183- q->triggerAction(QWebPage::Stop);
3184- break;
3185- case Qt::Key_Refresh:
3186- q->triggerAction(QWebPage::Reload);
3187- break;
3188- case Qt::Key_Backspace:
3189- if (ev->modifiers() == Qt::ShiftModifier)
3190- q->triggerAction(QWebPage::Forward);
3191- else
3192- q->triggerAction(QWebPage::Back);
3193- break;
3194- default:
3195- handled = false;
3196- break;
3197- }
3198- }
3199- }
3200-
3201- ev->setAccepted(handled);
3202-}
3203-
3204-void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev)
3205-{
3206- if (ev->isAutoRepeat()) {
3207- ev->setAccepted(true);
3208- return;
3209- }
3210-
3211- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
3212- bool handled = frame->eventHandler()->keyEvent(ev);
3213- ev->setAccepted(handled);
3214-}
3215-
3216-void QWebPagePrivate::focusInEvent(QFocusEvent*)
3217-{
3218- FocusController *focusController = page->focusController();
3219- focusController->setActive(true);
3220- focusController->setFocused(true);
3221- if (!focusController->focusedFrame())
3222- focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame.data()));
3223-}
3224-
3225-void QWebPagePrivate::focusOutEvent(QFocusEvent*)
3226-{
3227- // only set the focused frame inactive so that we stop painting the caret
3228- // and the focus frame. But don't tell the focus controller so that upon
3229- // focusInEvent() we can re-activate the frame.
3230- FocusController *focusController = page->focusController();
3231- // Call setFocused first so that window.onblur doesn't get called twice
3232- focusController->setFocused(false);
3233- focusController->setActive(false);
3234-}
3235-
3236-template<class T>
3237-void QWebPagePrivate::dragEnterEvent(T* ev)
3238-{
3239-#ifndef QT_NO_DRAGANDDROP
3240- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
3241- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
3242- Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData).operation);
3243- ev->setDropAction(action);
3244- ev->acceptProposedAction();
3245-#endif
3246-}
3247-
3248-template<class T>
3249-void QWebPagePrivate::dragLeaveEvent(T *ev)
3250-{
3251-#ifndef QT_NO_DRAGANDDROP
3252- DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone);
3253- page->dragController()->dragExited(&dragData);
3254- ev->accept();
3255-#endif
3256-}
3257-
3258-template<class T>
3259-void QWebPagePrivate::dragMoveEvent(T *ev)
3260-{
3261-#ifndef QT_NO_DRAGANDDROP
3262- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
3263- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
3264- m_lastDropAction = dragOpToDropAction(page->dragController()->dragUpdated(&dragData).operation);
3265- ev->setDropAction(m_lastDropAction);
3266- if (m_lastDropAction != Qt::IgnoreAction)
3267- ev->accept();
3268-#endif
3269-}
3270-
3271-template<class T>
3272-void QWebPagePrivate::dropEvent(T *ev)
3273-{
3274-#ifndef QT_NO_DRAGANDDROP
3275- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
3276- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
3277- if (page->dragController()->performDrag(&dragData)) {
3278- ev->setDropAction(m_lastDropAction);
3279- ev->accept();
3280- }
3281-#endif
3282-}
3283-
3284-void QWebPagePrivate::leaveEvent(QEvent*)
3285-{
3286- // Fake a mouse move event just outside of the widget, since all
3287- // the interesting mouse-out behavior like invalidating scrollbars
3288- // is handled by the WebKit event handler's mouseMoved function.
3289- QMouseEvent fakeEvent(QEvent::MouseMove, QCursor::pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
3290- mouseMoveEvent(&fakeEvent);
3291-}
3292-
3293-/*!
3294- \property QWebPage::palette
3295- \brief the page's palette
3296-
3297- The base brush of the palette is used to draw the background of the main frame.
3298-
3299- By default, this property contains the application's default palette.
3300-*/
3301-void QWebPage::setPalette(const QPalette &pal)
3302-{
3303- d->palette = pal;
3304- if (!d->mainFrame || !d->mainFrame.data()->d->frame->view())
3305- return;
3306-
3307- QBrush brush = pal.brush(QPalette::Base);
3308- QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor();
3309- QWebFramePrivate::core(d->mainFrame.data())->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha());
3310-}
3311-
3312-QPalette QWebPage::palette() const
3313-{
3314- return d->palette;
3315-}
3316-
3317-void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
3318-{
3319- WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
3320- WebCore::Editor *editor = frame->editor();
3321-
3322- if (!editor->canEdit()) {
3323- ev->ignore();
3324- return;
3325- }
3326-
3327- Node* node = 0;
3328- if (frame->selection()->rootEditableElement())
3329- node = frame->selection()->rootEditableElement()->shadowAncestorNode();
3330-
3331- Vector<CompositionUnderline> underlines;
3332- bool hasSelection = false;
3333-
3334- for (int i = 0; i < ev->attributes().size(); ++i) {
3335- const QInputMethodEvent::Attribute& a = ev->attributes().at(i);
3336- switch (a.type) {
3337- case QInputMethodEvent::TextFormat: {
3338- QTextCharFormat textCharFormat = a.value.value<QTextFormat>().toCharFormat();
3339- QColor qcolor = textCharFormat.underlineColor();
3340- underlines.append(CompositionUnderline(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)), Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())), false));
3341- break;
3342- }
3343- case QInputMethodEvent::Cursor: {
3344- frame->selection()->setCaretVisible(a.length); //if length is 0 cursor is invisible
3345- if (a.length > 0) {
3346- RenderObject* caretRenderer = frame->selection()->caretRenderer();
3347- if (caretRenderer) {
3348- QColor qcolor = a.value.value<QColor>();
3349- caretRenderer->style()->setColor(Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())));
3350- }
3351- }
3352- break;
3353- }
3354- case QInputMethodEvent::Selection: {
3355- hasSelection = true;
3356- // A selection in the inputMethodEvent is always reflected in the visible text
3357- if (node) {
3358- if (HTMLTextFormControlElement* textControl = toTextFormControl(node))
3359- textControl->setSelectionRange(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
3360- }
3361-
3362- if (!ev->preeditString().isEmpty())
3363- editor->setComposition(ev->preeditString(), underlines, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
3364- else {
3365- // If we are in the middle of a composition, an empty pre-edit string and a selection of zero
3366- // cancels the current composition
3367- if (editor->hasComposition() && (a.start + a.length == 0))
3368- editor->setComposition(QString(), underlines, 0, 0);
3369- }
3370- break;
3371- }
3372- default:
3373- break;
3374- }
3375- }
3376-
3377- if (node && ev->replacementLength() > 0) {
3378- int cursorPos = frame->selection()->extent().offsetInContainerNode();
3379- int start = cursorPos + ev->replacementStart();
3380- if (HTMLTextFormControlElement* textControl = toTextFormControl(node))
3381- textControl->setSelectionRange(start, start + ev->replacementLength());
3382- // Commit regardless of whether commitString is empty, to get rid of selection.
3383- editor->confirmComposition(ev->commitString());
3384- } else if (!ev->commitString().isEmpty()) {
3385- if (editor->hasComposition())
3386- editor->confirmComposition(ev->commitString());
3387- else
3388- editor->insertText(ev->commitString(), 0);
3389- } else if (!hasSelection && !ev->preeditString().isEmpty())
3390- editor->setComposition(ev->preeditString(), underlines, 0, 0);
3391- else if (ev->preeditString().isEmpty() && editor->hasComposition())
3392- editor->confirmComposition(String());
3393-
3394- ev->accept();
3395-}
3396-
3397-#ifndef QT_NO_PROPERTIES
3398-typedef struct {
3399- const char* name;
3400- double deferredRepaintDelay;
3401- double initialDeferredRepaintDelayDuringLoading;
3402- double maxDeferredRepaintDelayDuringLoading;
3403- double deferredRepaintDelayIncrementDuringLoading;
3404-} QRepaintThrottlingPreset;
3405-
3406-void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* event)
3407-{
3408- if (event->propertyName() == "_q_viewMode") {
3409- page->setViewMode(Page::stringToViewMode(q->property("_q_viewMode").toString()));
3410- } else if (event->propertyName() == "_q_HTMLTokenizerChunkSize") {
3411- int chunkSize = q->property("_q_HTMLTokenizerChunkSize").toInt();
3412- q->handle()->page->setCustomHTMLTokenizerChunkSize(chunkSize);
3413- } else if (event->propertyName() == "_q_HTMLTokenizerTimeDelay") {
3414- double timeDelay = q->property("_q_HTMLTokenizerTimeDelay").toDouble();
3415- q->handle()->page->setCustomHTMLTokenizerTimeDelay(timeDelay);
3416- } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelay") {
3417- double p = q->property("_q_RepaintThrottlingDeferredRepaintDelay").toDouble();
3418- FrameView::setRepaintThrottlingDeferredRepaintDelay(p);
3419- } else if (event->propertyName() == "_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading") {
3420- double p = q->property("_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading").toDouble();
3421- FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(p);
3422- } else if (event->propertyName() == "_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading") {
3423- double p = q->property("_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading").toDouble();
3424- FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(p);
3425- } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading") {
3426- double p = q->property("_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading").toDouble();
3427- FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(p);
3428- } else if (event->propertyName() == "_q_RepaintThrottlingPreset") {
3429- static const QRepaintThrottlingPreset presets[] = {
3430- { "NoThrottling", 0, 0, 0, 0 },
3431- { "Legacy", 0.025, 0, 2.5, 0.5 },
3432- { "Minimal", 0.01, 0, 1, 0.2 },
3433- { "Medium", 0.025, 1, 5, 0.5 },
3434- { "Heavy", 0.1, 2, 10, 1 }
3435- };
3436-
3437- QString p = q->property("_q_RepaintThrottlingPreset").toString();
3438- for (size_t i = 0; i < sizeof(presets) / sizeof(presets[0]); i++) {
3439- if (p == QLatin1String(presets[i].name)) {
3440- FrameView::setRepaintThrottlingDeferredRepaintDelay(
3441- presets[i].deferredRepaintDelay);
3442- FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(
3443- presets[i].initialDeferredRepaintDelayDuringLoading);
3444- FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(
3445- presets[i].maxDeferredRepaintDelayDuringLoading);
3446- FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(
3447- presets[i].deferredRepaintDelayIncrementDuringLoading);
3448- break;
3449- }
3450- }
3451- }
3452- else if (event->propertyName() == "_q_webInspectorServerPort") {
3453- InspectorServerQt* inspectorServer = InspectorServerQt::server();
3454- inspectorServer->listen(inspectorServerPort());
3455- } else if (event->propertyName() == "_q_deadDecodedDataDeletionInterval") {
3456- double interval = q->property("_q_deadDecodedDataDeletionInterval").toDouble();
3457- memoryCache()->setDeadDecodedDataDeletionInterval(interval);
3458- }
3459-}
3460-#endif
3461-
3462-void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event)
3463-{
3464- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
3465- WebCore::Editor* editor = frame->editor();
3466- if (editor->canEdit()) {
3467- if (event->modifiers() == Qt::NoModifier
3468- || event->modifiers() == Qt::ShiftModifier
3469- || event->modifiers() == Qt::KeypadModifier) {
3470- if (event->key() < Qt::Key_Escape) {
3471- event->accept();
3472- } else {
3473- switch (event->key()) {
3474- case Qt::Key_Return:
3475- case Qt::Key_Enter:
3476- case Qt::Key_Delete:
3477- case Qt::Key_Home:
3478- case Qt::Key_End:
3479- case Qt::Key_Backspace:
3480- case Qt::Key_Left:
3481- case Qt::Key_Right:
3482- case Qt::Key_Up:
3483- case Qt::Key_Down:
3484- case Qt::Key_Tab:
3485- event->accept();
3486- default:
3487- break;
3488- }
3489- }
3490- }
3491-#ifndef QT_NO_SHORTCUT
3492- else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction)
3493- event->accept();
3494-#endif
3495- }
3496-}
3497-
3498-bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
3499-{
3500- ScrollDirection direction;
3501- ScrollGranularity granularity;
3502-
3503-#ifndef QT_NO_SHORTCUT
3504- if (ev == QKeySequence::MoveToNextPage
3505- || (ev->key() == Qt::Key_Space && !(ev->modifiers() & Qt::ShiftModifier))) {
3506- granularity = ScrollByPage;
3507- direction = ScrollDown;
3508- } else if (ev == QKeySequence::MoveToPreviousPage
3509- || ((ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier))) {
3510- granularity = ScrollByPage;
3511- direction = ScrollUp;
3512- } else
3513-#endif // QT_NO_SHORTCUT
3514- if ((ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier)
3515- || ev->key() == Qt::Key_Home) {
3516- granularity = ScrollByDocument;
3517- direction = ScrollUp;
3518- } else if ((ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier)
3519- || ev->key() == Qt::Key_End) {
3520- granularity = ScrollByDocument;
3521- direction = ScrollDown;
3522- } else {
3523- switch (ev->key()) {
3524- case Qt::Key_Up:
3525- granularity = ScrollByLine;
3526- direction = ScrollUp;
3527- break;
3528- case Qt::Key_Down:
3529- granularity = ScrollByLine;
3530- direction = ScrollDown;
3531- break;
3532- case Qt::Key_Left:
3533- granularity = ScrollByLine;
3534- direction = ScrollLeft;
3535- break;
3536- case Qt::Key_Right:
3537- granularity = ScrollByLine;
3538- direction = ScrollRight;
3539- break;
3540- default:
3541- return false;
3542- }
3543- }
3544-
3545- return frame->eventHandler()->scrollRecursively(direction, granularity);
3546-}
3547-
3548-void QWebPagePrivate::adjustPointForClicking(QMouseEvent*)
3549-{
3550- notImplemented();
3551-}
3552-
3553-#if !defined(QT_NO_GRAPHICSVIEW)
3554-void QWebPagePrivate::adjustPointForClicking(QGraphicsSceneMouseEvent* ev)
3555-{
3556- QtPlatformPlugin platformPlugin;
3557- OwnPtr<QWebTouchModifier> touchModifier = platformPlugin.createTouchModifier();
3558- if (!touchModifier)
3559- return;
3560-
3561- unsigned topPadding = touchModifier->hitTestPaddingForTouch(QWebTouchModifier::Up);
3562- unsigned rightPadding = touchModifier->hitTestPaddingForTouch(QWebTouchModifier::Right);
3563- unsigned bottomPadding = touchModifier->hitTestPaddingForTouch(QWebTouchModifier::Down);
3564- unsigned leftPadding = touchModifier->hitTestPaddingForTouch(QWebTouchModifier::Left);
3565-
3566- touchModifier = nullptr;
3567-
3568- if (!topPadding && !rightPadding && !bottomPadding && !leftPadding)
3569- return;
3570-
3571- Document* startingDocument = page->mainFrame()->document();
3572- if (!startingDocument)
3573- return;
3574-
3575- IntPoint originalPoint(QPointF(ev->pos()).toPoint());
3576- TouchAdjuster touchAdjuster(topPadding, rightPadding, bottomPadding, leftPadding);
3577- IntPoint adjustedPoint = touchAdjuster.findCandidatePointForTouch(originalPoint, startingDocument);
3578- if (adjustedPoint == IntPoint::zero())
3579- return;
3580-
3581- ev->setPos(QPointF(adjustedPoint));
3582-}
3583-#endif
3584-
3585-bool QWebPagePrivate::touchEvent(QTouchEvent* event)
3586-{
3587-#if ENABLE(TOUCH_EVENTS)
3588- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
3589- if (!frame->view())
3590- return false;
3591-
3592- // Always accept the QTouchEvent so that we'll receive also TouchUpdate and TouchEnd events
3593- event->setAccepted(true);
3594-
3595- // Return whether the default action was cancelled in the JS event handler
3596- return frame->eventHandler()->handleTouchEvent(convertTouchEvent(event));
3597-#else
3598- event->ignore();
3599- return false;
3600-#endif
3601-}
3602-
3603-bool QWebPagePrivate::gestureEvent(QGestureEvent* event)
3604-{
3605-#if ENABLE(GESTURE_EVENTS)
3606- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame.data());
3607- if (!frame->view())
3608- return false;
3609-
3610- // QGestureEvents can contain updates for multiple gestures.
3611- bool handled = false;
3612- QGesture* gesture = event->gesture(Qt::TapGesture);
3613- // Beware that gestures send by DumpRenderTree will have state Qt::NoGesture,
3614- // due to not originating from a GestureRecognizer.
3615- if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) {
3616- frame->eventHandler()->handleGestureEvent(convertGesture(event, gesture));
3617- event->setAccepted(true);
3618- handled = true;
3619- }
3620- gesture = event->gesture(Qt::TapAndHoldGesture);
3621- if (gesture && (gesture->state() == Qt::GestureStarted || gesture->state() == Qt::NoGesture)) {
3622- frame->eventHandler()->sendContextMenuEventForGesture(convertGesture(event, gesture));
3623- event->setAccepted(true);
3624- handled = true;
3625- }
3626-
3627- return handled;
3628-#else
3629- event->ignore();
3630- return false;
3631-#endif
3632-}
3633-
3634-/*!
3635- This method is used by the input method to query a set of properties of the page
3636- to be able to support complex input method operations as support for surrounding
3637- text and reconversions.
3638-
3639- \a property specifies which property is queried.
3640-
3641- \sa QWidget::inputMethodEvent(), QInputMethodEvent, QInputContext
3642-*/
3643-QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
3644-{
3645- Frame* frame = d->page->focusController()->focusedFrame();
3646- if (!frame)
3647- return QVariant();
3648-
3649- WebCore::Editor* editor = frame->editor();
3650-
3651- RenderObject* renderer = 0;
3652- RenderTextControl* renderTextControl = 0;
3653-
3654- if (frame->selection()->rootEditableElement())
3655- renderer = frame->selection()->rootEditableElement()->shadowAncestorNode()->renderer();
3656-
3657- if (renderer && renderer->isTextControl())
3658- renderTextControl = toRenderTextControl(renderer);
3659-
3660- switch (property) {
3661- case Qt::ImMicroFocus: {
3662- WebCore::FrameView* view = frame->view();
3663- if (view && view->needsLayout()) {
3664- // We can't access absoluteCaretBounds() while the view needs to layout.
3665- return QVariant();
3666- }
3667- return QVariant(view->contentsToWindow(frame->selection()->absoluteCaretBounds()));
3668- }
3669- case Qt::ImFont: {
3670- if (renderTextControl) {
3671- RenderStyle* renderStyle = renderTextControl->style();
3672- return QVariant(QFont(renderStyle->font().syntheticFont()));
3673- }
3674- return QVariant(QFont());
3675- }
3676- case Qt::ImCursorPosition: {
3677- if (editor->hasComposition())
3678- return QVariant(frame->selection()->end().offsetInContainerNode());
3679- return QVariant(frame->selection()->extent().offsetInContainerNode());
3680- }
3681- case Qt::ImSurroundingText: {
3682- if (renderTextControl && renderTextControl->textFormControlElement()) {
3683- QString text = renderTextControl->textFormControlElement()->value();
3684- RefPtr<Range> range = editor->compositionRange();
3685- if (range)
3686- text.remove(range->startPosition().offsetInContainerNode(), TextIterator::rangeLength(range.get()));
3687- return QVariant(text);
3688- }
3689- return QVariant();
3690- }
3691- case Qt::ImCurrentSelection: {
3692- if (!editor->hasComposition() && renderTextControl && renderTextControl->textFormControlElement()) {
3693- int start = frame->selection()->start().offsetInContainerNode();
3694- int end = frame->selection()->end().offsetInContainerNode();
3695- if (end > start)
3696- return QVariant(QString(renderTextControl->textFormControlElement()->value()).mid(start, end - start));
3697- }
3698- return QVariant();
3699-
3700- }
3701- case Qt::ImAnchorPosition: {
3702- if (editor->hasComposition())
3703- return QVariant(frame->selection()->start().offsetInContainerNode());
3704- return QVariant(frame->selection()->base().offsetInContainerNode());
3705- }
3706- case Qt::ImMaximumTextLength: {
3707- if (frame->selection()->isContentEditable()) {
3708- if (frame->document() && frame->document()->focusedNode()) {
3709- if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) {
3710- HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
3711- return QVariant(inputElement->maxLength());
3712- }
3713- }
3714- return QVariant(HTMLInputElement::maximumLength);
3715- }
3716- return QVariant(0);
3717- }
3718- default:
3719- return QVariant();
3720- }
3721-}
3722-
3723-/*!
3724- \internal
3725-*/
3726-void QWebPagePrivate::setInspector(QWebInspector* insp)
3727-{
3728- if (inspector)
3729- inspector->d->setFrontend(0);
3730-
3731- inspector = insp;
3732-
3733- // Give inspector frontend web view if previously created
3734- if (inspector && inspectorFrontend)
3735- inspector->d->setFrontend(inspectorFrontend);
3736-}
3737-
3738-/*!
3739- \internal
3740- Returns the inspector and creates it if it wasn't created yet.
3741- The instance created here will not be available through QWebPage's API.
3742-*/
3743-QWebInspector* QWebPagePrivate::getOrCreateInspector()
3744-{
3745-#if ENABLE(INSPECTOR)
3746- if (!inspector) {
3747- QWebInspector* insp = new QWebInspector;
3748- insp->setPage(q);
3749- inspectorIsInternalOnly = true;
3750-
3751- Q_ASSERT(inspector); // Associated through QWebInspector::setPage(q)
3752- }
3753-#endif
3754- return inspector;
3755-}
3756-
3757-/*! \internal */
3758-InspectorController* QWebPagePrivate::inspectorController()
3759-{
3760-#if ENABLE(INSPECTOR)
3761- return page->inspectorController();
3762-#else
3763- return 0;
3764-#endif
3765-}
3766-
3767-quint16 QWebPagePrivate::inspectorServerPort()
3768-{
3769-#if ENABLE(INSPECTOR) && !defined(QT_NO_PROPERTIES)
3770- if (q && q->property("_q_webInspectorServerPort").isValid())
3771- return q->property("_q_webInspectorServerPort").toInt();
3772-#endif
3773- return 0;
3774-}
3775-
3776-static bool hasMouseListener(Element* element)
3777-{
3778- ASSERT(element);
3779- return element->hasEventListeners(eventNames().clickEvent)
3780- || element->hasEventListeners(eventNames().mousedownEvent)
3781- || element->hasEventListeners(eventNames().mouseupEvent);
3782-}
3783-
3784-static bool isClickableElement(Element* element, RefPtr<NodeList> list)
3785-{
3786- ASSERT(element);
3787- bool isClickable = hasMouseListener(element);
3788- if (!isClickable && list) {
3789- Element* parent = element->parentElement();
3790- unsigned count = list->length();
3791- for (unsigned i = 0; i < count && parent; i++) {
3792- if (list->item(i) != parent)
3793- continue;
3794-
3795- isClickable = hasMouseListener(parent);
3796- if (isClickable)
3797- break;
3798-
3799- parent = parent->parentElement();
3800- }
3801- }
3802-
3803- ExceptionCode ec = 0;
3804- return isClickable
3805- || element->webkitMatchesSelector("a,*:link,*:visited,*[role=button],button,input,select,label", ec)
3806- || CSSComputedStyleDeclaration::create(element)->getPropertyValue(cssPropertyID("cursor")) == "pointer";
3807-}
3808-
3809-static bool isValidFrameOwner(Element* element)
3810-{
3811- ASSERT(element);
3812- return element->isFrameOwnerElement() && static_cast<HTMLFrameOwnerElement*>(element)->contentFrame();
3813-}
3814-
3815-static Element* nodeToElement(Node* node)
3816-{
3817- if (node && node->isElementNode())
3818- return static_cast<Element*>(node);
3819- return 0;
3820-}
3821-
3822-QWebPagePrivate::TouchAdjuster::TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
3823- : m_topPadding(topPadding)
3824- , m_rightPadding(rightPadding)
3825- , m_bottomPadding(bottomPadding)
3826- , m_leftPadding(leftPadding)
3827-{
3828-}
3829-
3830-IntPoint QWebPagePrivate::TouchAdjuster::findCandidatePointForTouch(const IntPoint& touchPoint, Document* document) const
3831-{
3832- if (!document)
3833- return IntPoint();
3834-
3835- int x = touchPoint.x();
3836- int y = touchPoint.y();
3837-
3838- RefPtr<NodeList> intersectedNodes = document->nodesFromRect(x, y, m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding, false /*ignoreClipping*/, false /*allowShadowContent*/);
3839- if (!intersectedNodes)
3840- return IntPoint();
3841-
3842- Element* closestClickableElement = 0;
3843- IntRect largestIntersectionRect;
3844- FrameView* view = document->frame()->view();
3845-
3846- // Touch rect in contents coordinates.
3847- IntRect touchRect(HitTestLocation::rectForPoint(view->windowToContents(IntPoint(x, y)), m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding));
3848-
3849- // Iterate over the list of nodes hit looking for the one whose bounding area
3850- // has largest intersection with the touch area (point + padding).
3851- for (unsigned i = 0; i < intersectedNodes->length(); i++) {
3852- Node* currentNode = intersectedNodes->item(i);
3853-
3854- Element* currentElement = nodeToElement(currentNode);
3855- if (!currentElement || (!isClickableElement(currentElement, 0) && !isValidFrameOwner(currentElement)))
3856- continue;
3857-
3858- IntRect currentElementBoundingRect = currentElement->pixelSnappedBoundingBox();
3859- currentElementBoundingRect.intersect(touchRect);
3860-
3861- if (currentElementBoundingRect.isEmpty())
3862- continue;
3863-
3864- int currentIntersectionRectArea = currentElementBoundingRect.width() * currentElementBoundingRect.height();
3865- int largestIntersectionRectArea = largestIntersectionRect.width() * largestIntersectionRect.height();
3866- if (currentIntersectionRectArea > largestIntersectionRectArea) {
3867- closestClickableElement = currentElement;
3868- largestIntersectionRect = currentElementBoundingRect;
3869- }
3870- }
3871-
3872- if (largestIntersectionRect.isEmpty())
3873- return IntPoint();
3874-
3875- // Handle the case when user taps a inner frame. It is done in three steps:
3876- // 1) Transform the original touch point to the inner document coordinates;
3877- // 1) Call nodesFromRect for the inner document in case;
3878- // 3) Re-add the inner frame offset (location) before passing the new clicking
3879- // position to WebCore.
3880- if (closestClickableElement->isFrameOwnerElement()) {
3881- // Adjust client coordinates' origin to be top left of inner frame viewport.
3882- PassRefPtr<ClientRect> rect = closestClickableElement->getBoundingClientRect();
3883- IntPoint newTouchPoint = touchPoint;
3884- IntSize offset = IntSize(rect->left(), rect->top());
3885- newTouchPoint -= offset;
3886-
3887- HTMLFrameOwnerElement* owner = static_cast<HTMLFrameOwnerElement*>(closestClickableElement);
3888- Document* childDocument = owner->contentFrame()->document();
3889- return findCandidatePointForTouch(newTouchPoint, childDocument);
3890- }
3891- return view->contentsToWindow(largestIntersectionRect).center();
3892-}
3893-
3894-/*!
3895- \enum QWebPage::FindFlag
3896-
3897- This enum describes the options available to the findText() function. The options
3898- can be OR-ed together from the following list:
3899-
3900- \value FindBackward Searches backwards instead of forwards.
3901- \value FindCaseSensitively By default findText() works case insensitive. Specifying this option
3902- changes the behaviour to a case sensitive find operation.
3903- \value FindWrapsAroundDocument Makes findText() restart from the beginning of the document if the end
3904- was reached and the text was not found.
3905- \value HighlightAllOccurrences Highlights all existing occurrences of a specific string.
3906- (This value was introduced in 4.6.)
3907-*/
3908-
3909-/*!
3910- \enum QWebPage::LinkDelegationPolicy
3911-
3912- This enum defines the delegation policies a webpage can have when activating links and emitting
3913- the linkClicked() signal.
3914-
3915- \value DontDelegateLinks No links are delegated. Instead, QWebPage tries to handle them all.
3916- \value DelegateExternalLinks When activating links that point to documents not stored on the
3917- local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted.
3918- \value DelegateAllLinks Whenever a link is activated the linkClicked() signal is emitted.
3919-
3920- \sa QWebPage::linkDelegationPolicy
3921-*/
3922-
3923-/*!
3924- \enum QWebPage::NavigationType
3925-
3926- This enum describes the types of navigation available when browsing through hyperlinked
3927- documents.
3928-
3929- \value NavigationTypeLinkClicked The user clicked on a link or pressed return on a focused link.
3930- \value NavigationTypeFormSubmitted The user activated a submit button for an HTML form.
3931- \value NavigationTypeBackOrForward Navigation to a previously shown document in the back or forward history is requested.
3932- \value NavigationTypeReload The user activated the reload action.
3933- \value NavigationTypeFormResubmitted An HTML form was submitted a second time.
3934- \value NavigationTypeOther A navigation to another document using a method not listed above.
3935-
3936- \sa acceptNavigationRequest()
3937-*/
3938-
3939-/*!
3940- \enum QWebPage::WebAction
3941-
3942- This enum describes the types of action which can be performed on the web page.
3943-
3944- Actions only have an effect when they are applicable. The availability of
3945- actions can be be determined by checking \l{QAction::}{isEnabled()} on the
3946- action returned by action().
3947-
3948- One method of enabling the text editing, cursor movement, and text selection actions
3949- is by setting \l contentEditable to true.
3950-
3951- \value NoWebAction No action is triggered.
3952- \value OpenLink Open the current link.
3953- \value OpenLinkInNewWindow Open the current link in a new window.
3954- \value OpenLinkInThisWindow Open the current link without opening a new window. Used on links that would default to opening in another frame or a new window. (Added in Qt 5.0)
3955- \value OpenFrameInNewWindow Replicate the current frame in a new window.
3956- \value DownloadLinkToDisk Download the current link to the disk.
3957- \value CopyLinkToClipboard Copy the current link to the clipboard.
3958- \value OpenImageInNewWindow Open the highlighted image in a new window.
3959- \value DownloadImageToDisk Download the highlighted image to the disk.
3960- \value CopyImageToClipboard Copy the highlighted image to the clipboard. (Added in Qt 4.8)
3961- \value CopyImageUrlToClipboard Copy the highlighted image's URL to the clipboard.
3962- \value Back Navigate back in the history of navigated links.
3963- \value Forward Navigate forward in the history of navigated links.
3964- \value Stop Stop loading the current page.
3965- \value StopScheduledPageRefresh Stop all pending page refresh/redirect requests. (Added in Qt 4.7)
3966- \value Reload Reload the current page.
3967- \value ReloadAndBypassCache Reload the current page, but do not use any local cache. (Added in Qt 4.6)
3968- \value Cut Cut the content currently selected into the clipboard.
3969- \value Copy Copy the content currently selected into the clipboard.
3970- \value Paste Paste content from the clipboard.
3971- \value Undo Undo the last editing action.
3972- \value Redo Redo the last editing action.
3973- \value MoveToNextChar Move the cursor to the next character.
3974- \value MoveToPreviousChar Move the cursor to the previous character.
3975- \value MoveToNextWord Move the cursor to the next word.
3976- \value MoveToPreviousWord Move the cursor to the previous word.
3977- \value MoveToNextLine Move the cursor to the next line.
3978- \value MoveToPreviousLine Move the cursor to the previous line.
3979- \value MoveToStartOfLine Move the cursor to the start of the line.
3980- \value MoveToEndOfLine Move the cursor to the end of the line.
3981- \value MoveToStartOfBlock Move the cursor to the start of the block.
3982- \value MoveToEndOfBlock Move the cursor to the end of the block.
3983- \value MoveToStartOfDocument Move the cursor to the start of the document.
3984- \value MoveToEndOfDocument Move the cursor to the end of the document.
3985- \value SelectNextChar Select to the next character.
3986- \value SelectPreviousChar Select to the previous character.
3987- \value SelectNextWord Select to the next word.
3988- \value SelectPreviousWord Select to the previous word.
3989- \value SelectNextLine Select to the next line.
3990- \value SelectPreviousLine Select to the previous line.
3991- \value SelectStartOfLine Select to the start of the line.
3992- \value SelectEndOfLine Select to the end of the line.
3993- \value SelectStartOfBlock Select to the start of the block.
3994- \value SelectEndOfBlock Select to the end of the block.
3995- \value SelectStartOfDocument Select to the start of the document.
3996- \value SelectEndOfDocument Select to the end of the document.
3997- \value DeleteStartOfWord Delete to the start of the word.
3998- \value DeleteEndOfWord Delete to the end of the word.
3999- \value SetTextDirectionDefault Set the text direction to the default direction.
4000- \value SetTextDirectionLeftToRight Set the text direction to left-to-right.
4001- \value SetTextDirectionRightToLeft Set the text direction to right-to-left.
4002- \value ToggleBold Toggle the formatting between bold and normal weight.
4003- \value ToggleItalic Toggle the formatting between italic and normal style.
4004- \value ToggleUnderline Toggle underlining.
4005- \value InspectElement Show the Web Inspector with the currently highlighted HTML element.
4006- \value InsertParagraphSeparator Insert a new paragraph.
4007- \value InsertLineSeparator Insert a new line.
4008- \value SelectAll Selects all content.
4009- \value PasteAndMatchStyle Paste content from the clipboard with current style. (Added in Qt 4.6)
4010- \value RemoveFormat Removes formatting and style. (Added in Qt 4.6)
4011- \value ToggleStrikethrough Toggle the formatting between strikethrough and normal style. (Added in Qt 4.6)
4012- \value ToggleSubscript Toggle the formatting between subscript and baseline. (Added in Qt 4.6)
4013- \value ToggleSuperscript Toggle the formatting between supercript and baseline. (Added in Qt 4.6)
4014- \value InsertUnorderedList Toggles the selection between an ordered list and a normal block. (Added in Qt 4.6)
4015- \value InsertOrderedList Toggles the selection between an ordered list and a normal block. (Added in Qt 4.6)
4016- \value Indent Increases the indentation of the currently selected format block by one increment. (Added in Qt 4.6)
4017- \value Outdent Decreases the indentation of the currently selected format block by one increment. (Added in Qt 4.6)
4018- \value AlignCenter Applies center alignment to content. (Added in Qt 4.6)
4019- \value AlignJustified Applies full justification to content. (Added in Qt 4.6)
4020- \value AlignLeft Applies left justification to content. (Added in Qt 4.6)
4021- \value AlignRight Applies right justification to content. (Added in Qt 4.6)
4022-
4023-
4024- \omitvalue WebActionCount
4025-
4026-*/
4027-
4028-/*!
4029- \enum QWebPage::WebWindowType
4030-
4031- This enum describes the types of window that can be created by the createWindow() function.
4032-
4033- \value WebBrowserWindow The window is a regular web browser window.
4034- \value WebModalDialog The window acts as modal dialog.
4035-*/
4036-
4037-
4038-/*!
4039- \class QWebPage::ViewportAttributes
4040- \since 4.7
4041- \brief The QWebPage::ViewportAttributes class describes hints that can be applied to a viewport.
4042-
4043- QWebPage::ViewportAttributes provides a description of a viewport, such as viewport geometry,
4044- initial scale factor with limits, plus information about whether a user should be able
4045- to scale the contents in the viewport or not, ie. by zooming.
4046-
4047- ViewportAttributes can be set by a web author using the viewport meta tag extension, documented
4048- at \l{http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html}{Safari Reference Library: Using the Viewport Meta Tag}.
4049-
4050- All values might not be set, as such when dealing with the hints, the developer needs to
4051- check whether the values are valid. Negative values denote an invalid qreal value.
4052-
4053- \inmodule QtWebKit
4054-*/
4055-
4056-/*!
4057- Constructs an empty QWebPage::ViewportAttributes.
4058-*/
4059-QWebPage::ViewportAttributes::ViewportAttributes()
4060- : d(0)
4061- , m_initialScaleFactor(-1.0)
4062- , m_minimumScaleFactor(-1.0)
4063- , m_maximumScaleFactor(-1.0)
4064- , m_devicePixelRatio(-1.0)
4065- , m_isUserScalable(true)
4066- , m_isValid(false)
4067-{
4068-
4069-}
4070-
4071-/*!
4072- Constructs a QWebPage::ViewportAttributes which is a copy from \a other .
4073-*/
4074-QWebPage::ViewportAttributes::ViewportAttributes(const QWebPage::ViewportAttributes& other)
4075- : d(other.d)
4076- , m_initialScaleFactor(other.m_initialScaleFactor)
4077- , m_minimumScaleFactor(other.m_minimumScaleFactor)
4078- , m_maximumScaleFactor(other.m_maximumScaleFactor)
4079- , m_devicePixelRatio(other.m_devicePixelRatio)
4080- , m_isUserScalable(other.m_isUserScalable)
4081- , m_isValid(other.m_isValid)
4082- , m_size(other.m_size)
4083-{
4084-
4085-}
4086-
4087-/*!
4088- Destroys the QWebPage::ViewportAttributes.
4089-*/
4090-QWebPage::ViewportAttributes::~ViewportAttributes()
4091-{
4092-
4093-}
4094-
4095-/*!
4096- Assigns the given QWebPage::ViewportAttributes to this viewport hints and returns a
4097- reference to this.
4098-*/
4099-QWebPage::ViewportAttributes& QWebPage::ViewportAttributes::operator=(const QWebPage::ViewportAttributes& other)
4100-{
4101- if (this != &other) {
4102- d = other.d;
4103- m_initialScaleFactor = other.m_initialScaleFactor;
4104- m_minimumScaleFactor = other.m_minimumScaleFactor;
4105- m_maximumScaleFactor = other.m_maximumScaleFactor;
4106- m_isUserScalable = other.m_isUserScalable;
4107- m_isValid = other.m_isValid;
4108- m_size = other.m_size;
4109- }
4110-
4111- return *this;
4112-}
4113-
4114-/*! \fn inline bool QWebPage::ViewportAttributes::isValid() const
4115- Returns whether this is a valid ViewportAttributes or not.
4116-
4117- An invalid ViewportAttributes will have an empty QSize, negative values for scale factors and
4118- true for the boolean isUserScalable.
4119-*/
4120-
4121-/*! \fn inline QSize QWebPage::ViewportAttributes::size() const
4122- Returns the size of the viewport.
4123-*/
4124-
4125-/*! \fn inline qreal QWebPage::ViewportAttributes::initialScaleFactor() const
4126- Returns the initial scale of the viewport as a multiplier.
4127-*/
4128-
4129-/*! \fn inline qreal QWebPage::ViewportAttributes::minimumScaleFactor() const
4130- Returns the minimum scale value of the viewport as a multiplier.
4131-*/
4132-
4133-/*! \fn inline qreal QWebPage::ViewportAttributes::maximumScaleFactor() const
4134- Returns the maximum scale value of the viewport as a multiplier.
4135-*/
4136-
4137-/*! \fn inline bool QWebPage::ViewportAttributes::isUserScalable() const
4138- Determines whether or not the scale can be modified by the user.
4139-*/
4140-
4141-
4142-/*!
4143- \class QWebPage
4144- \since 4.4
4145- \brief The QWebPage class provides an object to view and edit web documents.
4146-
4147- \inmodule QtWebKit
4148-
4149- QWebPage holds a main frame responsible for web content, settings, the history
4150- of navigated links and actions. This class can be used, together with QWebFrame,
4151- to provide functionality like QWebView in a widget-less environment.
4152-
4153- QWebPage's API is very similar to QWebView, as you are still provided with
4154- common functions like action() (known as
4155- \l{QWebView::pageAction()}{pageAction}() in QWebView), triggerAction(),
4156- findText() and settings(). More QWebView-like functions can be found in the
4157- main frame of QWebPage, obtained via the mainFrame() function. For example,
4158- the \l{QWebFrame::load()}{load}(), \l{QWebFrame::setUrl()}{setUrl}() and
4159- \l{QWebFrame::setHtml()}{setHtml}() functions for QWebPage can be accessed
4160- using QWebFrame.
4161-
4162- The loadStarted() signal is emitted when the page begins to load.The
4163- loadProgress() signal, on the other hand, is emitted whenever an element
4164- of the web page completes loading, such as an embedded image, a script,
4165- etc. Finally, the loadFinished() signal is emitted when the page contents
4166- are loaded completely, independent of script execution or page rendering.
4167- Its argument, either true or false, indicates whether or not the load
4168- operation succeeded.
4169-
4170- \section1 Using QWebPage in a Widget-less Environment
4171-
4172- Before you begin painting a QWebPage object, you need to set the size of
4173- the viewport by calling setViewportSize(). Then, you invoke the main
4174- frame's render function (QWebFrame::render()). An example of this
4175- is shown in the code snippet below.
4176-
4177- Suppose we have a \c Thumbnail class as follows:
4178-
4179- \snippet webkitsnippets/webpage/main.cpp 0
4180-
4181- The \c Thumbnail's constructor takes in a \a url. We connect our QWebPage
4182- object's \l{QWebPage::}{loadFinished()} signal to our private slot,
4183- \c render().
4184-
4185- \snippet webkitsnippets/webpage/main.cpp 1
4186-
4187- The \c render() function shows how we can paint a thumbnail using a
4188- QWebPage object.
4189-
4190- \snippet webkitsnippets/webpage/main.cpp 2
4191-
4192- We begin by setting the \l{QWebPage::viewportSize()}{viewportSize} and
4193- then we instantiate a QImage object, \c image, with the same size as our
4194- \l{QWebPage::viewportSize()}{viewportSize}. This image is then sent
4195- as a parameter to \c painter. Next, we render the contents of the main
4196- frame and its subframes into \c painter. Finally, we save the scaled image.
4197-
4198- \sa QWebFrame
4199-*/
4200-
4201-/*!
4202- Constructs an empty QWebPage with parent \a parent.
4203-*/
4204-QWebPage::QWebPage(QObject *parent)
4205- : QObject(parent)
4206- , d(new QWebPagePrivate(this))
4207-{
4208- setView(qobject_cast<QWidget*>(parent));
4209-
4210- connect(this, SIGNAL(loadProgress(int)), this, SLOT(_q_onLoadProgressChanged(int)));
4211-#ifndef NDEBUG
4212- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(_q_cleanupLeakMessages()));
4213-#endif
4214-}
4215-
4216-/*!
4217- Destroys the web page.
4218-*/
4219-QWebPage::~QWebPage()
4220-{
4221- d->createMainFrame();
4222- FrameLoader* loader = d->mainFrame.data()->d->frame->loader();
4223- if (loader)
4224- loader->detachFromParent();
4225- delete d;
4226-}
4227-
4228-/*!
4229- Returns the main frame of the page.
4230-
4231- The main frame provides access to the hierarchy of sub-frames and is also needed if you
4232- want to explicitly render a web page into a given painter.
4233-
4234- \sa currentFrame()
4235-*/
4236-QWebFrame *QWebPage::mainFrame() const
4237-{
4238- d->createMainFrame();
4239- return d->mainFrame.data();
4240-}
4241-
4242-/*!
4243- Returns the frame currently active.
4244-
4245- \sa mainFrame(), frameCreated()
4246-*/
4247-QWebFrame *QWebPage::currentFrame() const
4248-{
4249- d->createMainFrame();
4250- WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame();
4251- return qobject_cast<QWebFrame*>(frame->loader()->networkingContext()->originatingObject());
4252-}
4253-
4254-
4255-/*!
4256- \since 4.6
4257-
4258- Returns the frame at the given point \a pos, or 0 if there is no frame at
4259- that position.
4260-
4261- \sa mainFrame(), currentFrame()
4262-*/
4263-QWebFrame* QWebPage::frameAt(const QPoint& pos) const
4264-{
4265- QWebFrame* webFrame = mainFrame();
4266- if (!webFrame->geometry().contains(pos))
4267- return 0;
4268- QWebHitTestResult hitTestResult = webFrame->hitTestContent(pos);
4269- return hitTestResult.frame();
4270-}
4271-
4272-/*!
4273- Returns a pointer to the view's history of navigated web pages.
4274-*/
4275-QWebHistory *QWebPage::history() const
4276-{
4277- d->createMainFrame();
4278- return &d->history;
4279-}
4280-
4281-/*!
4282- Sets the \a view that is associated with the web page.
4283-
4284- \sa view()
4285-*/
4286-void QWebPage::setView(QWidget* view)
4287-{
4288- if (this->view() == view)
4289- return;
4290-
4291- d->view = view;
4292- setViewportSize(view ? view->size() : QSize(0, 0));
4293-
4294- // If we have no client, we install a special client delegating
4295- // the responsibility to the QWidget. This is the code path
4296- // handling a.o. the "legacy" QWebView.
4297- //
4298- // If such a special delegate already exist, we substitute the view.
4299-
4300- if (d->client) {
4301- if (d->client->isQWidgetClient())
4302- static_cast<PageClientQWidget*>(d->client.get())->view = view;
4303- return;
4304- }
4305-
4306- if (view)
4307- d->client = adoptPtr(new PageClientQWidget(view, this));
4308-}
4309-
4310-/*!
4311- Returns the view widget that is associated with the web page.
4312-
4313- \sa setView()
4314-*/
4315-QWidget *QWebPage::view() const
4316-{
4317- return d->view.data();
4318-}
4319-
4320-/*!
4321- This function is called whenever a JavaScript program tries to print a \a message to the web browser's console.
4322-
4323- For example in case of evaluation errors the source URL may be provided in \a sourceID as well as the \a lineNumber.
4324-
4325- The default implementation prints nothing.
4326-*/
4327-void QWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
4328-{
4329- Q_UNUSED(sourceID)
4330-
4331- // Catch plugin logDestroy message for LayoutTests/plugins/open-and-close-window-with-plugin.html
4332- // At this point DRT's WebPage has already been destroyed
4333- if (QWebPagePrivate::drtRun) {
4334- if (message == QLatin1String("PLUGIN: NPP_Destroy")) {
4335- fprintf(stdout, "CONSOLE MESSAGE: ");
4336- if (lineNumber)
4337- fprintf(stdout, "line %d: ", lineNumber);
4338- fprintf(stdout, "%s\n", message.toUtf8().constData());
4339- }
4340- }
4341-}
4342-
4343-/*!
4344- This function is called whenever a JavaScript program running inside \a frame calls the alert() function with
4345- the message \a msg.
4346-
4347- The default implementation shows the message, \a msg, with QMessageBox::information.
4348-*/
4349-void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg)
4350-{
4351- Q_UNUSED(frame)
4352-#ifndef QT_NO_MESSAGEBOX
4353- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
4354- QMessageBox box(parent);
4355- box.setWindowTitle(tr("JavaScript Alert - %1").arg(mainFrame()->url().host()));
4356- box.setTextFormat(Qt::PlainText);
4357- box.setText(msg);
4358- box.setStandardButtons(QMessageBox::Ok);
4359- box.exec();
4360-#endif
4361-}
4362-
4363-/*!
4364- This function is called whenever a JavaScript program running inside \a frame calls the confirm() function
4365- with the message, \a msg. Returns true if the user confirms the message; otherwise returns false.
4366-
4367- The default implementation executes the query using QMessageBox::information with QMessageBox::Ok and QMessageBox::Cancel buttons.
4368-*/
4369-bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
4370-{
4371- Q_UNUSED(frame)
4372-#ifdef QT_NO_MESSAGEBOX
4373- return true;
4374-#else
4375- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
4376- QMessageBox box(parent);
4377- box.setWindowTitle(tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()));
4378- box.setTextFormat(Qt::PlainText);
4379- box.setText(msg);
4380- box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
4381- return QMessageBox::Ok == box.exec();
4382-#endif
4383-}
4384-
4385-/*!
4386- This function is called whenever a JavaScript program running inside \a frame tries to prompt the user for input.
4387- The program may provide an optional message, \a msg, as well as a default value for the input in \a defaultValue.
4388-
4389- If the prompt was cancelled by the user the implementation should return false; otherwise the
4390- result should be written to \a result and true should be returned. If the prompt was not cancelled by the
4391- user, the implementation should return true and the result string must not be null.
4392-
4393- The default implementation uses QInputDialog::getText().
4394-*/
4395-bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result)
4396-{
4397- Q_UNUSED(frame)
4398- bool ok = false;
4399-#ifndef QT_NO_INPUTDIALOG
4400-
4401- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
4402- QInputDialog dlg(parent);
4403- dlg.setWindowTitle(tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()));
4404-
4405- // Hack to force the dialog's QLabel into plain text mode
4406- // prevents https://bugs.webkit.org/show_bug.cgi?id=34429
4407- QLabel* label = dlg.findChild<QLabel*>();
4408- if (label)
4409- label->setTextFormat(Qt::PlainText);
4410-
4411- // double the &'s because single & will underline the following character
4412- // (Accelerator mnemonics)
4413- QString escMsg(msg);
4414- escMsg.replace(QChar::fromLatin1('&'), QLatin1String("&&"));
4415- dlg.setLabelText(escMsg);
4416-
4417- dlg.setTextEchoMode(QLineEdit::Normal);
4418- dlg.setTextValue(defaultValue);
4419-
4420- ok = !!dlg.exec();
4421-
4422- if (ok && result)
4423- *result = dlg.textValue();
4424-#endif
4425- return ok;
4426-}
4427-
4428-/*!
4429- \fn bool QWebPage::shouldInterruptJavaScript()
4430- \since 4.6
4431- This function is called when a JavaScript program is running for a long period of time.
4432-
4433- If the user wanted to stop the JavaScript the implementation should return true; otherwise false.
4434-
4435- The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
4436-
4437- \warning Because of binary compatibility constraints, this function is not virtual. If you want to
4438- provide your own implementation in a QWebPage subclass, reimplement the shouldInterruptJavaScript()
4439- slot in your subclass instead. QtWebKit will dynamically detect the slot and call it.
4440-*/
4441-bool QWebPage::shouldInterruptJavaScript()
4442-{
4443-#ifdef QT_NO_MESSAGEBOX
4444- return false;
4445-#else
4446- QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
4447- return QMessageBox::Yes == QMessageBox::information(parent, tr("JavaScript Problem - %1").arg(mainFrame()->url().host()), tr("The script on this page appears to have a problem. Do you want to stop the script?"), QMessageBox::Yes, QMessageBox::No);
4448-#endif
4449-}
4450-
4451-void QWebPage::setFeaturePermission(QWebFrame* frame, Feature feature, PermissionPolicy policy)
4452-{
4453-#if !ENABLE(NOTIFICATIONS) && !ENABLE(LEGACY_NOTIFICATIONS) && !ENABLE(GEOLOCATION)
4454- Q_UNUSED(frame);
4455- Q_UNUSED(policy);
4456-#endif
4457- switch (feature) {
4458- case Notifications:
4459-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
4460- if (policy != PermissionUnknown)
4461- NotificationPresenterClientQt::notificationPresenter()->setNotificationsAllowedForFrame(frame->d->frame, (policy == PermissionGrantedByUser));
4462-#endif
4463- break;
4464- case Geolocation:
4465-#if ENABLE(GEOLOCATION)
4466- GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy);
4467-#endif
4468- break;
4469-
4470- default:
4471- break;
4472- }
4473-}
4474-
4475-/*!
4476- This function is called whenever WebKit wants to create a new window of the given \a type, for
4477- example when a JavaScript program requests to open a document in a new window.
4478-
4479- If the new window can be created, the new window's QWebPage is returned; otherwise a null pointer is returned.
4480-
4481- If the view associated with the web page is a QWebView object, then the default implementation forwards
4482- the request to QWebView's createWindow() function; otherwise it returns a null pointer.
4483-
4484- If \a type is WebModalDialog, the application must call setWindowModality(Qt::ApplicationModal) on the new window.
4485-
4486- \note In the cases when the window creation is being triggered by JavaScript, apart from
4487- reimplementing this method application must also set the JavaScriptCanOpenWindows attribute
4488- of QWebSettings to true in order for it to get called.
4489-
4490- \sa acceptNavigationRequest(), QWebView::createWindow()
4491-*/
4492-QWebPage *QWebPage::createWindow(WebWindowType type)
4493-{
4494- QWebView *webView = qobject_cast<QWebView*>(view());
4495- if (webView) {
4496- QWebView *newView = webView->createWindow(type);
4497- if (newView)
4498- return newView->page();
4499- }
4500- return 0;
4501-}
4502-
4503-/*!
4504- This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin". It is
4505- called regardless of the value of QWebSettings::PluginsEnabled. The \a classid, \a url, \a paramNames and \a paramValues
4506- correspond to the HTML object element attributes and child elements to configure the embeddable object.
4507-*/
4508-QObject *QWebPage::createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
4509-{
4510- Q_UNUSED(classid)
4511- Q_UNUSED(url)
4512- Q_UNUSED(paramNames)
4513- Q_UNUSED(paramValues)
4514- return 0;
4515-}
4516-
4517-static void extractContentTypeFromHash(const HashSet<String>& types, QStringList* list)
4518-{
4519- if (!list)
4520- return;
4521-
4522- HashSet<String>::const_iterator endIt = types.end();
4523- for (HashSet<String>::const_iterator it = types.begin(); it != endIt; ++it)
4524- *list << *it;
4525-}
4526-
4527-static void extractContentTypeFromPluginVector(const Vector<PluginPackage*>& plugins, QStringList* list)
4528-{
4529- if (!list)
4530- return;
4531-
4532- for (unsigned int i = 0; i < plugins.size(); ++i) {
4533- MIMEToDescriptionsMap::const_iterator map_it = plugins[i]->mimeToDescriptions().begin();
4534- MIMEToDescriptionsMap::const_iterator map_end = plugins[i]->mimeToDescriptions().end();
4535- for (; map_it != map_end; ++map_it)
4536- *list << map_it->key;
4537- }
4538-}
4539-
4540-/*!
4541- * Returns the list of all content types supported by QWebPage.
4542- */
4543-QStringList QWebPage::supportedContentTypes() const
4544-{
4545- QStringList mimeTypes;
4546-
4547- extractContentTypeFromHash(MIMETypeRegistry::getSupportedImageMIMETypes(), &mimeTypes);
4548- extractContentTypeFromHash(MIMETypeRegistry::getSupportedNonImageMIMETypes(), &mimeTypes);
4549- if (d->page->settings() && d->page->settings()->arePluginsEnabled())
4550- extractContentTypeFromPluginVector(PluginDatabase::installedPlugins()->plugins(), &mimeTypes);
4551-
4552- return mimeTypes;
4553-}
4554-
4555-/*!
4556- * Returns true if QWebPage can handle the given \a mimeType; otherwise, returns false.
4557- */
4558-bool QWebPage::supportsContentType(const QString& mimeType) const
4559-{
4560- const String type = mimeType.toLower();
4561- if (MIMETypeRegistry::isSupportedImageMIMEType(type))
4562- return true;
4563-
4564- if (MIMETypeRegistry::isSupportedNonImageMIMEType(type))
4565- return true;
4566-
4567- if (d->page->settings() && d->page->settings()->arePluginsEnabled()
4568- && PluginDatabase::installedPlugins()->isMIMETypeRegistered(type))
4569- return true;
4570-
4571- return false;
4572-}
4573-
4574-static WebCore::FrameLoadRequest frameLoadRequest(const QUrl &url, WebCore::Frame *frame)
4575-{
4576- return WebCore::FrameLoadRequest(frame->document()->securityOrigin(),
4577- WebCore::ResourceRequest(url, frame->loader()->outgoingReferrer()));
4578-}
4579-
4580-static void openNewWindow(const QUrl& url, WebCore::Frame* frame)
4581-{
4582- if (Page* oldPage = frame->page()) {
4583- WindowFeatures features;
4584- NavigationAction action;
4585- FrameLoadRequest request = frameLoadRequest(url, frame);
4586- if (Page* newPage = oldPage->chrome()->createWindow(frame, request, features, action)) {
4587- newPage->mainFrame()->loader()->loadFrameRequest(request, false, false, 0, 0, MaybeSendReferrer);
4588- newPage->chrome()->show();
4589- }
4590- }
4591-}
4592-
4593-static void collectChildFrames(QWebFrame* frame, QList<QWebFrame*>& list)
4594-{
4595- list << frame->childFrames();
4596- QListIterator<QWebFrame*> it(frame->childFrames());
4597- while (it.hasNext()) {
4598- collectChildFrames(it.next(), list);
4599- }
4600-}
4601-
4602-/*!
4603- This function can be called to trigger the specified \a action.
4604- It is also called by QtWebKit if the user triggers the action, for example
4605- through a context menu item.
4606-
4607- If \a action is a checkable action then \a checked specified whether the action
4608- is toggled or not.
4609-
4610- \sa action()
4611-*/
4612-void QWebPage::triggerAction(WebAction action, bool)
4613-{
4614- WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame();
4615- if (!frame)
4616- return;
4617- WebCore::Editor *editor = frame->editor();
4618- const char *command = 0;
4619-
4620- switch (action) {
4621- case OpenLink:
4622- if (QWebFrame *targetFrame = d->hitTestResult.linkTargetFrame()) {
4623- WTF::RefPtr<WebCore::Frame> wcFrame = targetFrame->d->frame;
4624- targetFrame->d->frame->loader()->loadFrameRequest(frameLoadRequest(d->hitTestResult.linkUrl(), wcFrame.get()),
4625- /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0,
4626- /*FormState*/ 0, MaybeSendReferrer);
4627- break;
4628- }
4629- // fall through
4630- case OpenLinkInNewWindow:
4631- openNewWindow(d->hitTestResult.linkUrl(), frame);
4632- break;
4633- case OpenLinkInThisWindow:
4634- frame->loader()->loadFrameRequest(frameLoadRequest(d->hitTestResult.linkUrl(), frame),
4635- /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, /*FormState*/ 0, MaybeSendReferrer);
4636- break;
4637- case OpenFrameInNewWindow: {
4638- KURL url = frame->loader()->documentLoader()->unreachableURL();
4639- if (url.isEmpty())
4640- url = frame->loader()->documentLoader()->url();
4641- openNewWindow(url, frame);
4642- break;
4643- }
4644- case CopyLinkToClipboard: {
4645-#if defined(Q_WS_X11)
4646- bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
4647- Pasteboard::generalPasteboard()->setSelectionMode(true);
4648- editor->copyURL(d->hitTestResult.linkUrl(), d->hitTestResult.linkText());
4649- Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
4650-#endif
4651- editor->copyURL(d->hitTestResult.linkUrl(), d->hitTestResult.linkText());
4652- break;
4653- }
4654- case OpenImageInNewWindow:
4655- openNewWindow(d->hitTestResult.imageUrl(), frame);
4656- break;
4657- case DownloadImageToDisk:
4658- frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.imageUrl(), frame->loader()->outgoingReferrer()));
4659- break;
4660- case DownloadLinkToDisk:
4661- frame->loader()->client()->startDownload(WebCore::ResourceRequest(d->hitTestResult.linkUrl(), frame->loader()->outgoingReferrer()));
4662- break;
4663-#ifndef QT_NO_CLIPBOARD
4664- case CopyImageToClipboard:
4665- QApplication::clipboard()->setPixmap(d->hitTestResult.pixmap());
4666- break;
4667- case CopyImageUrlToClipboard:
4668- QApplication::clipboard()->setText(d->hitTestResult.imageUrl().toString());
4669- break;
4670-#endif
4671- case Back:
4672- d->page->goBack();
4673- break;
4674- case Forward:
4675- d->page->goForward();
4676- break;
4677- case Stop:
4678- mainFrame()->d->frame->loader()->stopForUserCancel();
4679- d->updateNavigationActions();
4680- break;
4681- case Reload:
4682- mainFrame()->d->frame->loader()->reload(/*endtoendreload*/false);
4683- break;
4684- case ReloadAndBypassCache:
4685- mainFrame()->d->frame->loader()->reload(/*endtoendreload*/true);
4686- break;
4687- case SetTextDirectionDefault:
4688- editor->setBaseWritingDirection(NaturalWritingDirection);
4689- break;
4690- case SetTextDirectionLeftToRight:
4691- editor->setBaseWritingDirection(LeftToRightWritingDirection);
4692- break;
4693- case SetTextDirectionRightToLeft:
4694- editor->setBaseWritingDirection(RightToLeftWritingDirection);
4695- break;
4696- case InspectElement: {
4697-#if ENABLE(INSPECTOR)
4698- if (!d->hitTestResult.isNull()) {
4699- d->getOrCreateInspector(); // Make sure the inspector is created
4700- d->inspector->show(); // The inspector is expected to be shown on inspection
4701- d->page->inspectorController()->inspect(d->hitTestResult.d->innerNonSharedNode.get());
4702- }
4703-#endif
4704- break;
4705- }
4706- case StopScheduledPageRefresh: {
4707- QWebFrame* topFrame = mainFrame();
4708- topFrame->d->frame->navigationScheduler()->cancel();
4709- QList<QWebFrame*> childFrames;
4710- collectChildFrames(topFrame, childFrames);
4711- QListIterator<QWebFrame*> it(childFrames);
4712- while (it.hasNext())
4713- it.next()->d->frame->navigationScheduler()->cancel();
4714- break;
4715- }
4716- default:
4717- command = QWebPagePrivate::editorCommandForWebActions(action);
4718- break;
4719- }
4720-
4721- if (command)
4722- editor->command(command).execute();
4723-}
4724-
4725-
4726-QColor QWebPagePrivate::colorSelectionRequested(const QColor &selectedColor)
4727-{
4728- QColor ret = selectedColor;
4729-#ifndef QT_NO_COLORDIALOG
4730- QWidget* parent = (client) ? client->ownerWidget() : 0;
4731- ret = QColorDialog::getColor(selectedColor, parent);
4732- if (!ret.isValid())
4733- ret = selectedColor;
4734-#endif
4735- return ret;
4736-}
4737-
4738-QSize QWebPage::viewportSize() const
4739-{
4740- if (d->mainFrame && d->mainFrame.data()->d->frame->view())
4741- return d->mainFrame.data()->d->frame->view()->frameRect().size();
4742-
4743- return d->viewportSize;
4744-}
4745-
4746-/*!
4747- \property QWebPage::viewportSize
4748- \brief the size of the viewport
4749-
4750- The size affects for example the visibility of scrollbars
4751- if the document is larger than the viewport.
4752-
4753- By default, for a newly-created Web page, this property contains a size with
4754- zero width and height.
4755-
4756- \sa QWebFrame::render(), preferredContentsSize
4757-*/
4758-void QWebPage::setViewportSize(const QSize &size) const
4759-{
4760- d->viewportSize = size;
4761-
4762- QWebFrame *frame = mainFrame();
4763- if (frame->d->frame && frame->d->frame->view()) {
4764- WebCore::FrameView* view = frame->d->frame->view();
4765- view->resize(size);
4766- view->adjustViewSize();
4767- }
4768-}
4769-
4770-static int getintenv(const char* variable)
4771-{
4772- bool ok;
4773- int value = qgetenv(variable).toInt(&ok);
4774- return (ok) ? value : -1;
4775-}
4776-
4777-static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget)
4778-{
4779- QDesktopWidget* desktop = QApplication::desktop();
4780- if (!desktop)
4781- return QSize();
4782-
4783- QSize size;
4784-
4785- if (widget) {
4786- // Returns the available geometry of the screen which contains widget.
4787- // NOTE: this must be the the full screen size including any fixed status areas etc.
4788- size = desktop->availableGeometry(widget).size();
4789- } else
4790- size = desktop->availableGeometry().size();
4791-
4792- // This must be in portrait mode, adjust if not.
4793- if (size.width() > size.height()) {
4794- int width = size.width();
4795- size.setWidth(size.height());
4796- size.setHeight(width);
4797- }
4798-
4799- return size;
4800-}
4801-
4802-/*!
4803- Computes the optimal viewport configuration given the \a availableSize, when
4804- user interface components are disregarded.
4805-
4806- The configuration is also dependent on the device screen size which is obtained
4807- automatically. For testing purposes the size can be overridden by setting two
4808- environment variables QTWEBKIT_DEVICE_WIDTH and QTWEBKIT_DEVICE_HEIGHT, which
4809- both needs to be set.
4810-
4811- The ViewportAttributes includes a pixel density ratio, which will also be exposed to
4812- the web author though the -webkit-pixel-ratio media feature. This is the ratio
4813- between 1 density-independent pixel (DPI) and physical pixels.
4814-
4815- A density-independent pixel is equivalent to one physical pixel on a 160 DPI screen,
4816- so on our platform assumes that as the baseline density.
4817-
4818- The conversion of DIP units to screen pixels is quite simple:
4819-
4820- pixels = DIPs * (density / 160).
4821-
4822- Thus, on a 240 DPI screen, 1 DIPs would equal 1.5 physical pixels.
4823-
4824- An invalid instance will be returned in the case an empty size is passed to the
4825- method.
4826-
4827- \note The density is automatically obtained from the DPI of the screen where the page
4828- is being shown, but as many X11 servers are reporting wrong DPI, it is possible to
4829- override it using QX11Info::setAppDpiY().
4830-*/
4831-
4832-QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& availableSize) const
4833-{
4834- static int desktopWidth = 980;
4835-
4836- ViewportAttributes result;
4837-
4838- if (availableSize.isEmpty())
4839- return result; // Returns an invalid instance.
4840-
4841- int deviceWidth = getintenv("QTWEBKIT_DEVICE_WIDTH");
4842- int deviceHeight = getintenv("QTWEBKIT_DEVICE_HEIGHT");
4843-
4844- // Both environment variables need to be set - or they will be ignored.
4845- if (deviceWidth < 0 && deviceHeight < 0) {
4846- QSize size = queryDeviceSizeForScreenContainingWidget((d->client) ? d->client->ownerWidget() : 0);
4847- deviceWidth = size.width();
4848- deviceHeight = size.height();
4849- }
4850-
4851- float devicePixelRatio = qt_defaultDpi() / WebCore::ViewportArguments::deprecatedTargetDPI;
4852-
4853- WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, devicePixelRatio, availableSize);
4854- WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize, devicePixelRatio);
4855- WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf);
4856-
4857- result.m_isValid = true;
4858- result.m_size = QSize(conf.layoutSize.width(), conf.layoutSize.height());
4859- result.m_initialScaleFactor = conf.initialScale;
4860- result.m_minimumScaleFactor = conf.minimumScale;
4861- result.m_maximumScaleFactor = conf.maximumScale;
4862- result.m_devicePixelRatio = devicePixelRatio;
4863- result.m_isUserScalable = static_cast<bool>(conf.userScalable);
4864-
4865- d->page->setDeviceScaleFactor(devicePixelRatio);
4866-
4867- return result;
4868-}
4869-
4870-QSize QWebPage::preferredContentsSize() const
4871-{
4872- QWebFrame* frame = d->mainFrame.data();
4873- if (frame) {
4874- WebCore::FrameView* view = frame->d->frame->view();
4875- if (view && view->useFixedLayout())
4876- return d->mainFrame.data()->d->frame->view()->fixedLayoutSize();
4877- }
4878-
4879- return d->fixedLayoutSize;
4880-}
4881-
4882-/*!
4883- \property QWebPage::preferredContentsSize
4884- \since 4.6
4885- \brief a custom size used for laying out the page contents.
4886-
4887- By default all pages are laid out using the viewport of the page as the base.
4888-
4889- As pages mostly are designed for desktop usage, they often do not layout properly
4890- on small devices as the contents require a certain view width. For this reason
4891- it is common to use a different layout size and then scale the contents to fit
4892- within the actual view.
4893-
4894- If this property is set to a valid size, this size is used for all layout needs
4895- instead of the size of the viewport.
4896-
4897- Setting an invalid size, makes the page fall back to using the viewport size for layout.
4898-
4899- \sa viewportSize
4900-*/
4901-void QWebPage::setPreferredContentsSize(const QSize& size) const
4902-{
4903- // FIXME: Rename this method to setCustomLayoutSize
4904-
4905- d->fixedLayoutSize = size;
4906-
4907- QWebFrame* frame = mainFrame();
4908- if (!frame->d->frame || !frame->d->frame->view())
4909- return;
4910-
4911- WebCore::FrameView* view = frame->d->frame->view();
4912-
4913- if (size.isValid()) {
4914- view->setUseFixedLayout(true);
4915- view->setFixedLayoutSize(size);
4916- } else if (view->useFixedLayout())
4917- view->setUseFixedLayout(false);
4918-
4919- view->layout();
4920-}
4921-
4922-/*
4923- This function is to be called after any (animated) scroll/pan has ended, in the case the application handles the
4924- scrolling/panning of the web contents. This is commonly used in combination with tiling where is it common for
4925- the application to pan the actual view, which then resizes itself to the size of the contents.
4926-
4927- \note Calling this function makes WebKit stop trying to calculate the visibleContentRect. To turn that on
4928- again, call this method with an empty rect.
4929-
4930- \sa QGraphicsWebView::resizesToContents, QWebSettings::TiledBackingStoreEnabled
4931-*/
4932-void QWebPage::setActualVisibleContentRect(const QRect& rect) const
4933-{
4934- QWebFrame* frame = mainFrame();
4935- if (!frame->d->frame || !frame->d->frame->view())
4936- return;
4937-
4938- WebCore::FrameView* view = frame->d->frame->view();
4939- view->setFixedVisibleContentRect(rect);
4940-}
4941-
4942-/*!
4943- \fn bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
4944-
4945- This function is called whenever WebKit requests to navigate \a frame to the resource specified by \a request by means of
4946- the specified navigation type \a type.
4947-
4948- If \a frame is a null pointer then navigation to a new window is requested. If the request is
4949- accepted createWindow() will be called.
4950-
4951- The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true
4952- to let QWebPage handle the navigation itself.
4953-
4954- \sa createWindow()
4955-*/
4956-bool QWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
4957-{
4958- Q_UNUSED(frame)
4959- if (type == NavigationTypeLinkClicked) {
4960- switch (d->linkPolicy) {
4961- case DontDelegateLinks:
4962- return true;
4963-
4964- case DelegateExternalLinks:
4965- if (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal(request.url().scheme()))
4966- return true;
4967- emit linkClicked(request.url());
4968- return false;
4969-
4970- case DelegateAllLinks:
4971- emit linkClicked(request.url());
4972- return false;
4973- }
4974- }
4975- return true;
4976-}
4977-
4978-/*!
4979- \property QWebPage::hasSelection
4980- \brief whether this page contains selected content or not.
4981-
4982- \sa selectionChanged()
4983-*/
4984-bool QWebPage::hasSelection() const
4985-{
4986- d->createMainFrame();
4987- WebCore::Frame* frame = d->page->focusController()->focusedOrMainFrame();
4988- if (frame)
4989- return (frame->selection()->selection().selectionType() != VisibleSelection::NoSelection);
4990- return false;
4991-}
4992-
4993-/*!
4994- \property QWebPage::selectedText
4995- \brief the text currently selected
4996-
4997- By default, this property contains an empty string.
4998-
4999- \sa selectionChanged(), selectedHtml()
5000-*/
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches