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

Proposed by Timo Jyrinki
Status: Superseded
Proposed branch: lp:~timo-jyrinki/ubuntu/raring/qtwebkit-source/raring_231
Merge into: lp:ubuntu/raring/qtwebkit-source
Diff against target: 16776 lines (+1211/-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 (+9/-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+160068@code.launchpad.net

This proposal has been superseded by a proposal from 2013-05-22.

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 :
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

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 :

Yeah certainly this is for saucy at this point.

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

Timo, could you retarget that one for saucy?

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

Unmerged revisions

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

34. By Timo Jyrinki

* debian/patches/kubuntu_fix_for_powerpc.diff:
  - Drop, merged upstream

33. By Timo Jyrinki

Use --no-force-sse2 for now.

32. By Timo Jyrinki

New upstream release.

Preview Diff

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

Subscribers

People subscribed via source and target branches