WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-82699-20120510154036.patch (text/plain), 10.50 KB, created by
Shinya Kawanaka
on 2012-05-09 23:40:38 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Shinya Kawanaka
Created:
2012-05-09 23:40:38 PDT
Size:
10.50 KB
patch
obsolete
>Subversion Revision: 116605 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 218549d884d28e4e81ec8e6258cf72325a22f95a..0f777ea9187b25c5bc4cc15e57e520eb6244d647 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,44 @@ >+2012-05-09 Shinya Kawanaka <shinyak@chromium.org> >+ >+ [Refactoring] Move Selection from DOMWindow to TreeScope. >+ https://bugs.webkit.org/show_bug.cgi?id=82699 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Since ShadowRoot will also manage its own version of DOMSelection, we would like to >+ share the code to return DOMSelection among Document and DOMSelection. This patch moves >+ DOMSelection related code from DOMWindow to TreeScope. >+ >+ No new tests, should coverered by existing tests. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::updateFocusAppearanceTimerFired): >+ * dom/Document.h: >+ (Document): >+ * dom/ShadowRoot.cpp: >+ (WebCore::ShadowRoot::selection): >+ * dom/TreeScope.cpp: >+ (WebCore::TreeScope::~TreeScope): >+ (WebCore::TreeScope::getSelection): >+ (WebCore): >+ * dom/TreeScope.h: >+ (WebCore): >+ (TreeScope): >+ * page/DOMSelection.cpp: >+ (WebCore::DOMSelection::DOMSelection): >+ (WebCore::DOMSelection::disconnectTreeScope): >+ (WebCore): >+ * page/DOMSelection.h: >+ (WebCore): >+ (WebCore::DOMSelection::create): >+ (DOMSelection): >+ * page/DOMWindow.cpp: >+ (WebCore::DOMWindow::~DOMWindow): >+ (WebCore::DOMWindow::clearDOMWindowProperties): >+ (WebCore::DOMWindow::getSelection): >+ * page/DOMWindow.h: >+ (DOMWindow): >+ > 2012-05-09 Jason Liu <jason.liu@torchmobile.com.cn> > > [BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead. >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 00a7dcce4e98e1f408c0f5b3cd48217f2e89a0d2..9632c5a6cdc41d480cb5899de2577f95b13ecba7 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -46,6 +46,7 @@ > #include "ContentSecurityPolicy.h" > #include "CookieJar.h" > #include "DOMImplementation.h" >+#include "DOMSelection.h" > #include "DOMWindow.h" > #include "DateComponents.h" > #include "DeviceMotionController.h" >@@ -5084,12 +5085,6 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>*) > element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection); > } > >-// FF method for accessing the selection added for compatibility. >-DOMSelection* Document::getSelection() const >-{ >- return frame() ? frame()->domWindow()->getSelection() : 0; >-} >- > void Document::attachRange(Range* range) > { > ASSERT(!m_ranges.contains(range)); >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 6c684e8228b381f0e91435b0ac1ed44c167052df..1ef6b4a9babdac378cffc8de8e037f201210279f 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -969,9 +969,6 @@ public: > void updateFocusAppearanceSoon(bool restorePreviousSelection); > void cancelFocusAppearanceUpdate(); > >- // FF method for accessing the selection added for compatibility. >- DOMSelection* getSelection() const; >- > // Extension for manipulating canvas drawing contexts for use in CSS > CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height); > HTMLCanvasElement* getCSSCanvasElement(const String& name); >diff --git a/Source/WebCore/dom/ShadowRoot.cpp b/Source/WebCore/dom/ShadowRoot.cpp >index aa034ba300e275617e5b7f95acb757a7366956d5..6e4c3bd6228c24ff6a5bf3c4939697cd9f950434 100644 >--- a/Source/WebCore/dom/ShadowRoot.cpp >+++ b/Source/WebCore/dom/ShadowRoot.cpp >@@ -151,8 +151,8 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec) > > DOMSelection* ShadowRoot::selection() > { >- if (document() && document()->domWindow()) >- return document()->domWindow()->getSelection(); >+ if (document()) >+ return document()->getSelection(); > return 0; > } > >diff --git a/Source/WebCore/dom/TreeScope.cpp b/Source/WebCore/dom/TreeScope.cpp >index 998264532087650693c448fc5a76b930c1c40f91..47fb79070933aecf84e6d95573d50f4776004ebe 100644 >--- a/Source/WebCore/dom/TreeScope.cpp >+++ b/Source/WebCore/dom/TreeScope.cpp >@@ -27,6 +27,7 @@ > #include "TreeScope.h" > > #include "ContainerNode.h" >+#include "DOMSelection.h" > #include "Document.h" > #include "Element.h" > #include "FocusController.h" >@@ -36,6 +37,7 @@ > #include "HTMLMapElement.h" > #include "HTMLNames.h" > #include "Page.h" >+#include "RuntimeEnabledFeatures.h" > #include "TreeScopeAdopter.h" > #include <wtf/text/AtomicString.h> > #include <wtf/text/CString.h> >@@ -54,6 +56,9 @@ TreeScope::TreeScope(ContainerNode* rootNode) > > TreeScope::~TreeScope() > { >+ if (m_selection) >+ m_selection->disconnectTreeScope(); >+ m_selection = 0; > } > > void TreeScope::destroyTreeScopeData() >@@ -116,6 +121,18 @@ HTMLMapElement* TreeScope::getImageMap(const String& url) const > return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this)); > } > >+DOMSelection* TreeScope::getSelection() const >+{ >+ if (!rootNode()->document()->frame()) >+ return 0; >+ >+ if (m_selection) >+ return m_selection.get(); >+ >+ m_selection = DOMSelection::create(rootNode()->document()); >+ return m_selection.get(); >+} >+ > Element* TreeScope::findAnchor(const String& name) > { > if (name.isEmpty()) >diff --git a/Source/WebCore/dom/TreeScope.h b/Source/WebCore/dom/TreeScope.h >index 76c12e5c90f71e24ce98c87d1bf1718f31826f96..9920932696d22c148aea87293a004654b94aaa11 100644 >--- a/Source/WebCore/dom/TreeScope.h >+++ b/Source/WebCore/dom/TreeScope.h >@@ -33,6 +33,7 @@ > namespace WebCore { > > class ContainerNode; >+class DOMSelection; > class Element; > class HTMLMapElement; > class Node; >@@ -62,6 +63,8 @@ public: > void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; } > bool hasNodeListCaches() const { return m_numNodeListCaches; } > >+ DOMSelection* getSelection() const; >+ > // Find first anchor with the given name. > // First searches for an element with the given ID, but if that fails, then looks > // for an anchor with the given name. ID matching is always case sensitive, but >@@ -90,6 +93,8 @@ private: > DocumentOrderedMap m_imageMapsByName; > > unsigned m_numNodeListCaches; >+ >+ mutable RefPtr<DOMSelection> m_selection; > }; > > inline bool TreeScope::hasElementWithId(AtomicStringImpl* id) const >diff --git a/Source/WebCore/page/DOMSelection.cpp b/Source/WebCore/page/DOMSelection.cpp >index fd846583ffb5e6c868f8bdfca86ed5a478c41824..defc209ee23f5c6619b8547641ed6bedb1bf0660 100644 >--- a/Source/WebCore/page/DOMSelection.cpp >+++ b/Source/WebCore/page/DOMSelection.cpp >@@ -58,11 +58,18 @@ static Node* selectionShadowAncestor(Frame* frame) > return shadowAncestor; > } > >-DOMSelection::DOMSelection(Frame* frame) >- : DOMWindowProperty(frame) >+DOMSelection::DOMSelection(const TreeScope* treeScope) >+ : m_treeScope(treeScope) >+ , m_frame(treeScope->rootNode()->document()->frame()) > { > } > >+void DOMSelection::disconnectTreeScope() >+{ >+ m_frame = 0; >+ m_treeScope = 0; >+} >+ > const VisibleSelection& DOMSelection::visibleSelection() const > { > ASSERT(m_frame); >diff --git a/Source/WebCore/page/DOMSelection.h b/Source/WebCore/page/DOMSelection.h >index 9803acca22ba43c52767856a2395c768c8a7d7f4..7058b50b9f663c9bd58e215c0931faae73b87dc7 100644 >--- a/Source/WebCore/page/DOMSelection.h >+++ b/Source/WebCore/page/DOMSelection.h >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2007 Apple Inc. All rights reserved. >+ * Copyright (C) 2012 Google Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -38,15 +39,18 @@ > namespace WebCore { > > class Frame; >- class Range; > class Node; >+ class Range; >+ class TreeScope; > class VisibleSelection; > > typedef int ExceptionCode; > >- class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty { >+ class DOMSelection : public RefCounted<DOMSelection> { > public: >- static PassRefPtr<DOMSelection> create(Frame* frame) { return adoptRef(new DOMSelection(frame)); } >+ static PassRefPtr<DOMSelection> create(const TreeScope* treeScope) { return adoptRef(new DOMSelection(treeScope)); } >+ >+ void disconnectTreeScope(); > > // Safari Selection Object API > // These methods return the valid equivalents of internal editing positions. >@@ -88,7 +92,10 @@ namespace WebCore { > void empty(); > > private: >- explicit DOMSelection(Frame*); >+ const TreeScope* m_treeScope; >+ Frame* m_frame; >+ >+ explicit DOMSelection(const TreeScope*); > > // Convenience method for accessors, does not NULL check m_frame. > const VisibleSelection& visibleSelection() const; >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index def0e626c4be3a186b870b350f4f2e83d275b63e..57dd911eed6ffae72113cd7f40dfefddf8acedd1 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -399,7 +399,6 @@ DOMWindow::~DOMWindow() > #ifndef NDEBUG > if (!m_suspendedForPageCache) { > ASSERT(!m_screen); >- ASSERT(!m_selection); > ASSERT(!m_history); > ASSERT(!m_crypto); > ASSERT(!m_locationbar); >@@ -572,7 +571,6 @@ void DOMWindow::clearDOMWindowProperties() > m_properties.clear(); > > m_screen = 0; >- m_selection = 0; > m_history = 0; > m_crypto = 0; > m_locationbar = 0; >@@ -883,9 +881,8 @@ DOMSelection* DOMWindow::getSelection() > { > if (!isCurrentlyDisplayedInFrame()) > return 0; >- if (!m_selection) >- m_selection = DOMSelection::create(m_frame); >- return m_selection.get(); >+ >+ return m_frame->document()->getSelection(); > } > > Element* DOMWindow::frameElement() const >diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h >index 78fb6f6e3b16d5af8f1197f517789edd98c98c4b..5f99f09f1617c89d080c91508c9c7312c6d36c79 100644 >--- a/Source/WebCore/page/DOMWindow.h >+++ b/Source/WebCore/page/DOMWindow.h >@@ -425,7 +425,6 @@ namespace WebCore { > HashSet<DOMWindowProperty*> m_properties; > > mutable RefPtr<Screen> m_screen; >- mutable RefPtr<DOMSelection> m_selection; > mutable RefPtr<History> m_history; > mutable RefPtr<Crypto> m_crypto; > mutable RefPtr<BarInfo> m_locationbar;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 82699
:
141088
|
141092
|
141102
|
141110
|
141309
|
141344