Changeset 116746 in webkit
- Timestamp:
- May 11, 2012 3:36:31 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r116744 r116746 1 2012-05-11 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 * dom/TreeScope.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 * page/DOMWindow.cpp: 36 (WebCore::DOMWindow::~DOMWindow): 37 (WebCore::DOMWindow::clearDOMWindowProperties): 38 (WebCore::DOMWindow::getSelection): 39 * page/DOMWindow.h: 40 (DOMWindow): 41 1 42 2012-05-04 Yury Semikhatsky <yurys@chromium.org> 2 43 -
trunk/Source/WebCore/dom/Document.cpp
r116730 r116746 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
r116724 r116746 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
r116730 r116746 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
r116724 r116746 28 28 29 29 #include "ContainerNode.h" 30 #include "DOMSelection.h" 31 #include "DOMWindow.h" 30 32 #include "Document.h" 31 33 #include "Element.h" … … 37 39 #include "HTMLNames.h" 38 40 #include "Page.h" 41 #include "RuntimeEnabledFeatures.h" 39 42 #include "TreeScopeAdopter.h" 40 43 #include <wtf/text/AtomicString.h> … … 55 58 TreeScope::~TreeScope() 56 59 { 60 if (m_selection) { 61 m_selection->clearTreeScope(); 62 m_selection = 0; 63 } 57 64 } 58 65 … … 115 122 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this)); 116 123 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this)); 124 } 125 126 DOMSelection* TreeScope::getSelection() const 127 { 128 if (!rootNode()->document()->frame()) 129 return 0; 130 131 if (m_selection) 132 return m_selection.get(); 133 134 m_selection = DOMSelection::create(rootNode()->document()); 135 return m_selection.get(); 117 136 } 118 137 -
trunk/Source/WebCore/dom/TreeScope.h
r116724 r116746 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
r116724 r116746 59 59 } 60 60 61 DOMSelection::DOMSelection(Frame* frame) 62 : DOMWindowProperty(frame) 63 { 61 DOMSelection::DOMSelection(const TreeScope* treeScope) 62 : DOMWindowProperty(treeScope->rootNode()->document()->frame()) 63 , m_treeScope(treeScope) 64 { 65 } 66 67 void DOMSelection::clearTreeScope() 68 { 69 m_treeScope = 0; 64 70 } 65 71 -
trunk/Source/WebCore/page/DOMSelection.h
r116724 r116746 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 … … 47 49 class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty { 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 … … 89 93 90 94 private: 91 explicit DOMSelection(Frame*); 95 const TreeScope* m_treeScope; 96 97 explicit DOMSelection(const TreeScope*); 92 98 93 99 // Convenience method for accessors, does not NULL check m_frame. -
trunk/Source/WebCore/page/DOMWindow.cpp
r116724 r116746 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
r116724 r116746 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.