Unreviewed, rolling out r116715.
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2012 04:00:34 +0000 (04:00 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2012 04:00:34 +0000 (04:00 +0000)
http://trac.webkit.org/changeset/116715
https://bugs.webkit.org/show_bug.cgi?id=86172

Broke http/tests/security/cross-frame-access-selection.html
(Requested by tkent on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-05-10

* dom/Document.cpp:
(WebCore):
(WebCore::Document::getSelection):
* dom/Document.h:
(Document):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::selection):
* dom/TreeScope.cpp:
(WebCore::TreeScope::~TreeScope):
* dom/TreeScope.h:
(WebCore):
(TreeScope):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::DOMSelection):
* page/DOMSelection.h:
(WebCore):
(WebCore::DOMSelection::create):
(DOMSelection):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::~DOMWindow):
(WebCore::DOMWindow::clearDOMWindowProperties):
(WebCore::DOMWindow::getSelection):
* page/DOMWindow.h:
(DOMWindow):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116724 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/dom/TreeScope.h
Source/WebCore/page/DOMSelection.cpp
Source/WebCore/page/DOMSelection.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h

index d80b7eb..7269bca 100644 (file)
@@ -1,3 +1,37 @@
+2012-05-10  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r116715.
+        http://trac.webkit.org/changeset/116715
+        https://bugs.webkit.org/show_bug.cgi?id=86172
+
+        Broke http/tests/security/cross-frame-access-selection.html
+        (Requested by tkent on #webkit).
+
+        * dom/Document.cpp:
+        (WebCore):
+        (WebCore::Document::getSelection):
+        * dom/Document.h:
+        (Document):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::selection):
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::~TreeScope):
+        * dom/TreeScope.h:
+        (WebCore):
+        (TreeScope):
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::DOMSelection):
+        * 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-10  Hajime Morrita  <morrita@google.com>
 
         WebKit should support tab-size.
index 5a5043a..f467af3 100644 (file)
@@ -46,7 +46,6 @@
 #include "ContentSecurityPolicy.h"
 #include "CookieJar.h"
 #include "DOMImplementation.h"
-#include "DOMSelection.h"
 #include "DOMWindow.h"
 #include "DateComponents.h"
 #include "DeviceMotionController.h"
@@ -5093,6 +5092,12 @@ 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));
index 1ef6b4a..6c684e8 100644 (file)
@@ -969,6 +969,9 @@ 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);
index 6e4c3bd..aa034ba 100644 (file)
@@ -151,8 +151,8 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec)
 
 DOMSelection* ShadowRoot::selection()
 {
-    if (document())
-        return document()->getSelection();
+    if (document() && document()->domWindow())
+        return document()->domWindow()->getSelection();
     return 0;
 }
 
index 4d97896..9982645 100644 (file)
@@ -27,7 +27,6 @@
 #include "TreeScope.h"
 
 #include "ContainerNode.h"
-#include "DOMSelection.h"
 #include "Document.h"
 #include "Element.h"
 #include "FocusController.h"
@@ -37,7 +36,6 @@
 #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>
@@ -56,10 +54,6 @@ TreeScope::TreeScope(ContainerNode* rootNode)
 
 TreeScope::~TreeScope()
 {
-    if (m_selection) {
-        m_selection->clearTreeScope();
-        m_selection = 0;
-    }
 }
 
 void TreeScope::destroyTreeScopeData()
@@ -122,18 +116,6 @@ 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())
index 9920932..76c12e5 100644 (file)
@@ -33,7 +33,6 @@
 namespace WebCore {
 
 class ContainerNode;
-class DOMSelection;
 class Element;
 class HTMLMapElement;
 class Node;
@@ -63,8 +62,6 @@ 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
@@ -93,8 +90,6 @@ private:
     DocumentOrderedMap m_imageMapsByName;
 
     unsigned m_numNodeListCaches;
-
-    mutable RefPtr<DOMSelection> m_selection;
 };
 
 inline bool TreeScope::hasElementWithId(AtomicStringImpl* id) const
index e5844a0..fd84658 100644 (file)
@@ -58,18 +58,11 @@ static Node* selectionShadowAncestor(Frame* frame)
     return shadowAncestor;
 }
 
-DOMSelection::DOMSelection(const TreeScope* treeScope)
-    : m_treeScope(treeScope)
-    , m_frame(treeScope->rootNode()->document()->frame())
+DOMSelection::DOMSelection(Frame* frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-void DOMSelection::clearTreeScope()
-{
-    m_frame = 0;
-    m_treeScope = 0;
-}
-
 const VisibleSelection& DOMSelection::visibleSelection() const
 {
     ASSERT(m_frame);
index f446eaa..9803acc 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * 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
 namespace WebCore {
 
     class Frame;
-    class Node;
     class Range;
-    class TreeScope;
+    class Node;
     class VisibleSelection;
 
     typedef int ExceptionCode;
 
-    class DOMSelection : public RefCounted<DOMSelection> {
+    class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty {
     public:
-        static PassRefPtr<DOMSelection> create(const TreeScope* treeScope) { return adoptRef(new DOMSelection(treeScope)); }
-
-        void clearTreeScope();
+        static PassRefPtr<DOMSelection> create(Frame* frame) { return adoptRef(new DOMSelection(frame)); }
 
         // Safari Selection Object API
         // These methods return the valid equivalents of internal editing positions.
@@ -88,16 +84,11 @@ namespace WebCore {
 
         String toString();
 
-        Frame* frame() const { return m_frame; }
-
         // Microsoft Selection Object API
         void empty();
 
     private:
-        const TreeScope* m_treeScope;
-        Frame* m_frame;
-
-        explicit DOMSelection(const TreeScope*);
+        explicit DOMSelection(Frame*);
 
         // Convenience method for accessors, does not NULL check m_frame.
         const VisibleSelection& visibleSelection() const;
index 40e0b2a..1b8d44c 100644 (file)
@@ -399,6 +399,7 @@ DOMWindow::~DOMWindow()
 #ifndef NDEBUG
     if (!m_suspendedForPageCache) {
         ASSERT(!m_screen);
+        ASSERT(!m_selection);
         ASSERT(!m_history);
         ASSERT(!m_crypto);
         ASSERT(!m_locationbar);
@@ -571,6 +572,7 @@ void DOMWindow::clearDOMWindowProperties()
     m_properties.clear();
 
     m_screen = 0;
+    m_selection = 0;
     m_history = 0;
     m_crypto = 0;
     m_locationbar = 0;
@@ -884,10 +886,11 @@ void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
 
 DOMSelection* DOMWindow::getSelection()
 {
-    if (!isCurrentlyDisplayedInFrame() || !m_frame)
+    if (!isCurrentlyDisplayedInFrame())
         return 0;
-
-    return m_frame->document()->getSelection();
+    if (!m_selection)
+        m_selection = DOMSelection::create(m_frame);
+    return m_selection.get();
 }
 
 Element* DOMWindow::frameElement() const
index 4ac8162..bb6df85 100644 (file)
@@ -428,6 +428,7 @@ 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;