Changeset 116715 in webkit
- Timestamp:
- May 10, 2012 6:45:47 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r116714 r116715 1 2012-05-10 Shinya Kawanaka <shinyak@chromium.org> 2 3 [Refactoring] Move Selection from DOMWindow to TreeScope. 4 https://bugs.webkit.org/show_bug.cgi?id=82699 5 6 Reviewed by Ryosuke Niwa. 7 8 Since ShadowRoot will also manage its own version of DOMSelection, we would like to 9 share the code among Document and DOMSelection. This patch moves DOMSelection from DOMWindow to TreeScope 10 so that ShadowRoot can also use it. 11 12 No new tests, should covered by existing tests. 13 14 * dom/Document.cpp: 15 (WebCore::Document::updateFocusAppearanceTimerFired): 16 * dom/Document.h: 17 (Document): 18 * dom/ShadowRoot.cpp: 19 (WebCore::ShadowRoot::selection): 20 * do/mTreeScope.cpp: 21 (WebCore::TreeScope::~TreeScope): 22 (WebCore::TreeScope::getSelection): 23 (WebCore): 24 * dom/TreeScope.h: 25 (WebCore): 26 (TreeScope): 27 * page/DOMSelection.cpp: 28 (WebCore::DOMSelection::DOMSelection): 29 (WebCore::DOMSelection::clearTreeScope): 30 (WebCore): 31 * page/DOMSelection.h: 32 (WebCore): 33 (WebCore::DOMSelection::create): 34 (DOMSelection): 35 (WebCore::DOMSelection::frame): 36 * page/DOMWindow.cpp: 37 (WebCore::DOMWindow::~DOMWindow): 38 (WebCore::DOMWindow::clearDOMWindowProperties): 39 (WebCore::DOMWindow::getSelection): 40 * page/DOMWindow.h: 41 (DOMWindow): 42 1 43 2012-05-10 Kent Tamura <tkent@chromium.org> 2 44 -
trunk/Source/WebCore/dom/Document.cpp
r116694 r116715 47 47 #include "CookieJar.h" 48 48 #include "DOMImplementation.h" 49 #include "DOMSelection.h" 49 50 #include "DOMWindow.h" 50 51 #include "DateComponents.h" … … 5093 5094 } 5094 5095 5095 // FF method for accessing the selection added for compatibility.5096 DOMSelection* Document::getSelection() const5097 {5098 return frame() ? frame()->domWindow()->getSelection() : 0;5099 }5100 5101 5096 void Document::attachRange(Range* range) 5102 5097 { -
trunk/Source/WebCore/dom/Document.h
r116595 r116715 970 970 void cancelFocusAppearanceUpdate(); 971 971 972 // FF method for accessing the selection added for compatibility.973 DOMSelection* getSelection() const;974 975 972 // Extension for manipulating canvas drawing contexts for use in CSS 976 973 CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height); -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r116521 r116715 152 152 DOMSelection* ShadowRoot::selection() 153 153 { 154 if (document() && document()->domWindow())155 return document()-> domWindow()->getSelection();154 if (document()) 155 return document()->getSelection(); 156 156 return 0; 157 157 } -
trunk/Source/WebCore/dom/TreeScope.cpp
r116521 r116715 28 28 29 29 #include "ContainerNode.h" 30 #include "DOMSelection.h" 30 31 #include "Document.h" 31 32 #include "Element.h" … … 37 38 #include "HTMLNames.h" 38 39 #include "Page.h" 40 #include "RuntimeEnabledFeatures.h" 39 41 #include "TreeScopeAdopter.h" 40 42 #include <wtf/text/AtomicString.h> … … 55 57 TreeScope::~TreeScope() 56 58 { 59 if (m_selection) { 60 m_selection->clearTreeScope(); 61 m_selection = 0; 62 } 57 63 } 58 64 … … 115 121 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this)); 116 122 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this)); 123 } 124 125 DOMSelection* TreeScope::getSelection() const 126 { 127 if (!rootNode()->document()->frame()) 128 return 0; 129 130 if (m_selection) 131 return m_selection.get(); 132 133 m_selection = DOMSelection::create(rootNode()->document()); 134 return m_selection.get(); 117 135 } 118 136 -
trunk/Source/WebCore/dom/TreeScope.h
r116521 r116715 34 34 35 35 class ContainerNode; 36 class DOMSelection; 36 37 class Element; 37 38 class HTMLMapElement; … … 63 64 bool hasNodeListCaches() const { return m_numNodeListCaches; } 64 65 66 DOMSelection* getSelection() const; 67 65 68 // Find first anchor with the given name. 66 69 // First searches for an element with the given ID, but if that fails, then looks … … 91 94 92 95 unsigned m_numNodeListCaches; 96 97 mutable RefPtr<DOMSelection> m_selection; 93 98 }; 94 99 -
trunk/Source/WebCore/page/DOMSelection.cpp
r113276 r116715 59 59 } 60 60 61 DOMSelection::DOMSelection(Frame* frame) 62 : DOMWindowProperty(frame) 63 { 61 DOMSelection::DOMSelection(const TreeScope* treeScope) 62 : m_treeScope(treeScope) 63 , m_frame(treeScope->rootNode()->document()->frame()) 64 { 65 } 66 67 void DOMSelection::clearTreeScope() 68 { 69 m_frame = 0; 70 m_treeScope = 0; 64 71 } 65 72 -
trunk/Source/WebCore/page/DOMSelection.h
r104380 r116715 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 39 40 40 41 class Frame; 42 class Node; 41 43 class Range; 42 class Node;44 class TreeScope; 43 45 class VisibleSelection; 44 46 45 47 typedef int ExceptionCode; 46 48 47 class DOMSelection : public RefCounted<DOMSelection> , public DOMWindowProperty{49 class DOMSelection : public RefCounted<DOMSelection> { 48 50 public: 49 static PassRefPtr<DOMSelection> create(Frame* frame) { return adoptRef(new DOMSelection(frame)); } 51 static PassRefPtr<DOMSelection> create(const TreeScope* treeScope) { return adoptRef(new DOMSelection(treeScope)); } 52 53 void clearTreeScope(); 50 54 51 55 // Safari Selection Object API … … 85 89 String toString(); 86 90 91 Frame* frame() const { return m_frame; } 92 87 93 // Microsoft Selection Object API 88 94 void empty(); 89 95 90 96 private: 91 explicit DOMSelection(Frame*); 97 const TreeScope* m_treeScope; 98 Frame* m_frame; 99 100 explicit DOMSelection(const TreeScope*); 92 101 93 102 // Convenience method for accessors, does not NULL check m_frame. -
trunk/Source/WebCore/page/DOMWindow.cpp
r116608 r116715 400 400 if (!m_suspendedForPageCache) { 401 401 ASSERT(!m_screen); 402 ASSERT(!m_selection);403 402 ASSERT(!m_history); 404 403 ASSERT(!m_crypto); … … 573 572 574 573 m_screen = 0; 575 m_selection = 0;576 574 m_history = 0; 577 575 m_crypto = 0; … … 887 885 DOMSelection* DOMWindow::getSelection() 888 886 { 889 if (!isCurrentlyDisplayedInFrame()) 890 return 0; 891 if (!m_selection) 892 m_selection = DOMSelection::create(m_frame); 893 return m_selection.get(); 887 if (!isCurrentlyDisplayedInFrame() || !m_frame) 888 return 0; 889 890 return m_frame->document()->getSelection(); 894 891 } 895 892 -
trunk/Source/WebCore/page/DOMWindow.h
r116608 r116715 429 429 430 430 mutable RefPtr<Screen> m_screen; 431 mutable RefPtr<DOMSelection> m_selection;432 431 mutable RefPtr<History> m_history; 433 432 mutable RefPtr<Crypto> m_crypto;
Note: See TracChangeset
for help on using the changeset viewer.