2010-07-08 Aaron Boodman <aa@chromium.org>
authoraa@chromium.org <aa@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jul 2010 01:15:07 +0000 (01:15 +0000)
committeraa@chromium.org <aa@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jul 2010 01:15:07 +0000 (01:15 +0000)
        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        * platform/win/Skipped: Skipped test because WebKit API needs updating.
        * userscripts/mixed-case-stylesheet.html: Added new allFrames param.
        * userscripts/resources/frame1.html: Added.
        * userscripts/resources/frame2.html: Added.
        * userscripts/script-not-run-for-fragments.html: Added new allFrames param.
        * userscripts/script-run-at-end.html: Ditto.
        * userscripts/script-run-at-start.html: Ditto.
        * userscripts/simple-stylesheet.html: Ditto.
        * userscripts/user-script-all-frames-expected.txt: Added.
        * userscripts/user-script-all-frames.html: Added.
        * userscripts/user-script-top-frame-only-expected.txt: Added.
        * userscripts/user-script-top-frame-only.html: Added.
        * userscripts/user-style-all-frames-expected.txt: Added.
        * userscripts/user-style-all-frames.html: Added.
        * userscripts/user-style-top-frame-only-expected.txt: Added.
        * userscripts/user-style-top-frame-only.html: Added.
2010-07-08  Aaron Boodman  <aa@chromium.org>

        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        Tests: userscripts/user-script-all-frames.html
               userscripts/user-script-top-frame-only.html
               userscripts/user-style-all-frames.html
               userscripts/user-style-top-frame-only.html

        * WebCore.base.exp: Update PageGroup method signatures.
        * dom/Document.cpp:
        (WebCore::Document::pageGroupUserSheets): Check allFrames before injecting.
        * page/Frame.cpp:
        (WebCore::Frame::injectUserScriptsForWorld): Ditto.
        * page/PageGroup.cpp:
        (WebCore::PageGroup::addUserScriptToWorld):
        (WebCore::PageGroup::addUserStyleSheetToWorld):
        * page/PageGroup.h:
        * page/UserScript.h:
        (WebCore::UserScript::UserScript):
        (WebCore::UserScript::injectedFrames):
        * page/UserScriptTypes.h:
        (WebCore::):
        * page/UserStyleSheet.h:
        (WebCore::UserStyleSheet::UserStyleSheet):
        (WebCore::UserStyleSheet::injectedFrames):
2010-07-08  Aaron Boodman  <aa@chromium.org>

        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        * public/WebView.h:
        (WebKit::WebView::):
        (WebKit::WebView::addUserScript):
        (WebKit::WebView::addUserStyleSheet):
        * src/AssertMatchingEnums.cpp:
        * src/WebViewImpl.cpp:
        (WebKit::WebView::addUserScript):
        (WebKit::WebView::addUserStyleSheet):
2010-07-08  Aaron Boodman  <aa@chromium.org>

        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        * WebView/WebView.mm:
        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:injectedFrames:]):
        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:injectedFrames:]):
        * WebView/WebViewPrivate.h:
2010-07-08  Aaron Boodman  <aa@chromium.org>

        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        * WebView.cpp:
        (WebView::addUserScriptToGroup):
        (WebView::addUserStyleSheetToGroup):
2010-07-08  Aaron Boodman  <aa@chromium.org>

        Reviewed by Timothy Hatcher.

        Add the ability for user scripts and user styles to affect just the top frame.

        https://bugs.webkit.org/show_bug.cgi?id=41529

        * DumpRenderTree/LayoutTestController.h: Added new allFrames param.
        * DumpRenderTree/LayoutTestController.cpp: Ditto.
        (addUserScriptCallback):
        (addUserStyleSheetCallback):
        * DumpRenderTree/chromium/LayoutTestController.cpp: Ditto.
        (LayoutTestController::addUserScript):
        (LayoutTestController::addUserStyleSheet):
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: Ditto.
        (LayoutTestController::addUserScript):
        (LayoutTestController::addUserStyleSheet):
        * DumpRenderTree/mac/LayoutTestControllerMac.mm: Ditto.
        (LayoutTestController::addUserScript):
        (LayoutTestController::addUserStyleSheet):
        * DumpRenderTree/win/LayoutTestControllerWin.cpp: Ditto.
        (LayoutTestController::addUserScript):
        (LayoutTestController::addUserStyleSheet):
        * DumpRenderTree/wx/LayoutTestControllerWx.cpp: Ditto.
        (LayoutTestController::addUserScript):
        (LayoutTestController::addUserStyleSheet):

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

46 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/win/Skipped
LayoutTests/userscripts/mixed-case-stylesheet.html
LayoutTests/userscripts/resources/frame1.html [new file with mode: 0644]
LayoutTests/userscripts/resources/frame2.html [new file with mode: 0644]
LayoutTests/userscripts/script-not-run-for-fragments.html
LayoutTests/userscripts/script-run-at-end.html
LayoutTests/userscripts/script-run-at-start.html
LayoutTests/userscripts/simple-stylesheet.html
LayoutTests/userscripts/user-script-all-frames-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/user-script-all-frames.html [new file with mode: 0644]
LayoutTests/userscripts/user-script-top-frame-only-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/user-script-top-frame-only.html [new file with mode: 0644]
LayoutTests/userscripts/user-style-all-frames-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/user-style-all-frames.html [new file with mode: 0644]
LayoutTests/userscripts/user-style-top-frame-only-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/user-style-top-frame-only.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.exp.in
WebCore/WebCore.gypi
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Document.cpp
WebCore/page/Frame.cpp
WebCore/page/PageGroup.cpp
WebCore/page/PageGroup.h
WebCore/page/UserContentTypes.h [new file with mode: 0644]
WebCore/page/UserScript.h
WebCore/page/UserStyleSheet.h
WebKit/chromium/ChangeLog
WebKit/chromium/public/WebView.h
WebKit/chromium/src/AssertMatchingEnums.cpp
WebKit/chromium/src/WebViewImpl.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebView.mm
WebKit/mac/WebView/WebViewPrivate.h
WebKit/win/ChangeLog
WebKit/win/WebView.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

index 85fd0f2..e06d0e5 100644 (file)
@@ -1,3 +1,28 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        * platform/win/Skipped: Skipped test because WebKit API needs updating.
+        * userscripts/mixed-case-stylesheet.html: Added new allFrames param.
+        * userscripts/resources/frame1.html: Added.
+        * userscripts/resources/frame2.html: Added.
+        * userscripts/script-not-run-for-fragments.html: Added new allFrames param.
+        * userscripts/script-run-at-end.html: Ditto.
+        * userscripts/script-run-at-start.html: Ditto.
+        * userscripts/simple-stylesheet.html: Ditto.
+        * userscripts/user-script-all-frames-expected.txt: Added.
+        * userscripts/user-script-all-frames.html: Added.
+        * userscripts/user-script-top-frame-only-expected.txt: Added.
+        * userscripts/user-script-top-frame-only.html: Added.
+        * userscripts/user-style-all-frames-expected.txt: Added.
+        * userscripts/user-style-all-frames.html: Added.
+        * userscripts/user-style-top-frame-only-expected.txt: Added.
+        * userscripts/user-style-top-frame-only.html: Added.
+
 2010-07-08  Adele Peterson  <adele@apple.com>
 
         Reviewed by Jon Honeycutt, Adam Roben, and Darin Adler.
index 13cd4da..2866a5a 100644 (file)
@@ -944,3 +944,11 @@ fast/forms/input-appearance-speechbutton.html
 # Needs to be fixed at image decoder layer for Safari.
 fast/images/large-size-image-crash.html
 
+# Disable until the windows WebKit API supports injecting in the top frame only.
+# https://bugs.webkit.org/show_bug.cgi?id=41800
+userscripts/user-script-all-frames.html
+userscripts/user-script-top-frame-only.html
+userscripts/user-style-all-frames.html
+userscripts/user-style-top-frame-only.html
+userscripts/frameset-all-frames.html
+userscripts/frameset-top-frame-only.html
index 7937d6f..d41cbac 100644 (file)
@@ -3,7 +3,7 @@
 <script>
 if (window.layoutTestController) {
     window.layoutTestController.dumpAsText();
-    window.layoutTestController.addUserStyleSheet("#mixedCase { display: none }");
+    window.layoutTestController.addUserStyleSheet("#mixedCase { display: none }", true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/resources/frame1.html b/LayoutTests/userscripts/resources/frame1.html
new file mode 100644 (file)
index 0000000..3918f7c
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<body>
+<div id="thinger">thinger</div>
+<iframe src="frame2.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/userscripts/resources/frame2.html b/LayoutTests/userscripts/resources/frame2.html
new file mode 100644 (file)
index 0000000..9cd15b3
--- /dev/null
@@ -0,0 +1,11 @@
+<html>
+<body>
+<script>
+window.onload = function() {
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+</script>
+<div id="thinger">thinger</div>
+</body>
+</html>
index 8d69172..c73efc3 100644 (file)
@@ -5,7 +5,7 @@
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
     layoutTestController.waitUntilDone();
-    layoutTestController.addUserScript("console.log('injected'); var div = document.createElement('div'); div.innerHTML = '<p>hi</p>';", true);
+    layoutTestController.addUserScript("console.log('injected'); var div = document.createElement('div'); div.innerHTML = '<p>hi</p>';", true, true);
 }
 </script>
 </head>
index 821b1c8..462da88 100644 (file)
@@ -4,7 +4,7 @@
 <script>
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
-    layoutTestController.addUserScript("document.getElementById('target').innerHTML = 'PASS'", false);
+    layoutTestController.addUserScript("document.getElementById('target').innerHTML = 'PASS'", false, true);
 }
 </script>
 </head>
index a91b61c..4aa2f35 100644 (file)
@@ -4,7 +4,7 @@
 <script>
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
-    layoutTestController.addUserScript("if (window.location == 'about:blank') console.log('SUCCESS');", true);
+    layoutTestController.addUserScript("if (window.location == 'about:blank') console.log('SUCCESS');", true, true);
 }
 </script>
 </head>
index 3914c72..da004d0 100644 (file)
@@ -4,7 +4,7 @@
 <script>
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
-    layoutTestController.addUserStyleSheet("div { width:0; }");
+    layoutTestController.addUserStyleSheet("div { width:0; }", true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/user-script-all-frames-expected.txt b/LayoutTests/userscripts/user-script-all-frames-expected.txt
new file mode 100644 (file)
index 0000000..fd16428
--- /dev/null
@@ -0,0 +1,11 @@
+If any thingers appear on this page, the test has failed. 
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->/<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/userscripts/user-script-all-frames.html b/LayoutTests/userscripts/user-script-all-frames.html
new file mode 100644 (file)
index 0000000..d850e58
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    window.layoutTestController.dumpChildFramesAsText();
+    layoutTestController.waitUntilDone();
+    window.layoutTestController.addUserScript("document.getElementById('thinger').style.display = 'none';",
+                                              false, true);
+}
+</script>
+</head>
+<body>
+If any thingers appear on this page, the test has failed.
+<Div id="thinger">thinger</div>
+<iframe src="resources/frame1.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/userscripts/user-script-top-frame-only-expected.txt b/LayoutTests/userscripts/user-script-top-frame-only-expected.txt
new file mode 100644 (file)
index 0000000..f31fccb
--- /dev/null
@@ -0,0 +1,12 @@
+Two thingers should appear on this page. Otherwise the test has failed. 
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+thinger
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->/<!--frame0-->-->'
+--------
+thinger
diff --git a/LayoutTests/userscripts/user-script-top-frame-only.html b/LayoutTests/userscripts/user-script-top-frame-only.html
new file mode 100644 (file)
index 0000000..29d4f66
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    window.layoutTestController.dumpChildFramesAsText();
+    layoutTestController.waitUntilDone();
+    window.layoutTestController.addUserScript("document.getElementById('thinger').style.display = 'none';",
+                                              false, false);
+}
+</script>
+</head>
+<body>
+Two thingers should appear on this page. Otherwise the test has failed.
+<Div id="thinger">thinger</div>
+<iframe src="resources/frame1.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/userscripts/user-style-all-frames-expected.txt b/LayoutTests/userscripts/user-style-all-frames-expected.txt
new file mode 100644 (file)
index 0000000..091e199
--- /dev/null
@@ -0,0 +1,11 @@
+If any thingers appear on this page, the test has failed.  
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->/<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/userscripts/user-style-all-frames.html b/LayoutTests/userscripts/user-style-all-frames.html
new file mode 100644 (file)
index 0000000..e361ff5
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    window.layoutTestController.dumpChildFramesAsText();
+    layoutTestController.waitUntilDone();
+    window.layoutTestController.addUserStyleSheet("#thinger { display:none; }", true);
+}
+</script>
+</head>
+<body>
+If any thingers appear on this page, the test has failed.
+<Div id="thinger">thinger</div>
+<iframe src="resources/frame1.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/userscripts/user-style-top-frame-only-expected.txt b/LayoutTests/userscripts/user-style-top-frame-only-expected.txt
new file mode 100644 (file)
index 0000000..58c7f5a
--- /dev/null
@@ -0,0 +1,12 @@
+2 thingers should appear on this page. Otherwise the test has failed.  
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+thinger
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->/<!--frame0-->-->'
+--------
+thinger
diff --git a/LayoutTests/userscripts/user-style-top-frame-only.html b/LayoutTests/userscripts/user-style-top-frame-only.html
new file mode 100644 (file)
index 0000000..f7c751c
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    window.layoutTestController.dumpChildFramesAsText();
+    layoutTestController.waitUntilDone();
+    window.layoutTestController.addUserStyleSheet("#thinger { display:none; }", false);
+}
+</script>
+</head>
+<body>
+2 thingers should appear on this page. Otherwise the test has failed.
+<Div id="thinger">thinger</div>
+<iframe src="resources/frame1.html"></iframe>
+</body>
+</html>
index 0cbe299..811138c 100644 (file)
@@ -1,3 +1,34 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        Tests: userscripts/user-script-all-frames.html
+               userscripts/user-script-top-frame-only.html
+               userscripts/user-style-all-frames.html
+               userscripts/user-style-top-frame-only.html
+
+        * WebCore.base.exp: Update PageGroup method signatures.
+        * dom/Document.cpp:
+        (WebCore::Document::pageGroupUserSheets): Check allFrames before injecting.
+        * page/Frame.cpp:
+        (WebCore::Frame::injectUserScriptsForWorld): Ditto.
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::addUserScriptToWorld):
+        (WebCore::PageGroup::addUserStyleSheetToWorld):
+        * page/PageGroup.h:
+        * page/UserScript.h:
+        (WebCore::UserScript::UserScript):
+        (WebCore::UserScript::injectedFrames):
+        * page/UserScriptTypes.h:
+        (WebCore::):
+        * page/UserStyleSheet.h:
+        (WebCore::UserStyleSheet::UserStyleSheet):
+        (WebCore::UserStyleSheet::injectedFrames):
+
 2010-07-08  Adele Peterson  <adele@apple.com>
 
         Reviewed by Jon Honeycutt, Adam Roben, and Darin Adler.
index 7fa3752..42b2599 100644 (file)
@@ -1600,6 +1600,7 @@ webcore_sources += \
        WebCore/page/Timing.h \
        WebCore/page/UserContentURLPattern.cpp \
        WebCore/page/UserContentURLPattern.h \
+       WebCore/page/UserContentTypes.h \
        WebCore/page/UserScript.h \
        WebCore/page/UserScriptTypes.h \
        WebCore/page/UserStyleSheet.h \
index a607274..a161e26 100644 (file)
@@ -750,10 +750,10 @@ __ZN7WebCore9PageCache11setCapacityEi
 __ZN7WebCore9PageCache27releaseAutoreleasedPagesNowEv
 __ZN7WebCore9PageGroup14addVisitedLinkEPKtm
 __ZN7WebCore9PageGroup17closeLocalStorageEv
-__ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_23UserScriptInjectionTimeE
+__ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_23UserScriptInjectionTimeENS_25UserContentInjectedFramesE
 __ZN7WebCore9PageGroup20removeAllUserContentEv
 __ZN7WebCore9PageGroup21removeAllVisitedLinksEv
-__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_
+__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_25UserContentInjectedFramesE
 __ZN7WebCore9PageGroup25removeUserScriptFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
 __ZN7WebCore9PageGroup26removeUserScriptsFromWorldEPNS_15DOMWrapperWorldE
 __ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
index dc3c1fc..7dab8d2 100644 (file)
             'page/Timing.h',
             'page/UserContentURLPattern.cpp',
             'page/UserContentURLPattern.h',
+            'page/UserContentTypes.h',
             'page/UserScript.h',
             'page/UserScriptTypes.h',
             'page/UserStyleSheet.h',
index 95a6660..0032d03 100644 (file)
@@ -35,6 +35,7 @@
 /* Begin PBXBuildFile section */
                0014628A103CD1DE000B20DB /* OriginAccessEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00146288103CD1DE000B20DB /* OriginAccessEntry.cpp */; };
                0014628B103CD1DE000B20DB /* OriginAccessEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 00146289103CD1DE000B20DB /* OriginAccessEntry.h */; };
+               003F1FEA11E6AB43008258D9 /* UserContentTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 003F1FE911E6AB43008258D9 /* UserContentTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                06027CAD0B1CBFC000884B2D /* ContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */; };
                062287840B4DB322000C34DF /* FocusDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 062287830B4DB322000C34DF /* FocusDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* Begin PBXFileReference section */
                00146288103CD1DE000B20DB /* OriginAccessEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OriginAccessEntry.cpp; sourceTree = "<group>"; };
                00146289103CD1DE000B20DB /* OriginAccessEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OriginAccessEntry.h; sourceTree = "<group>"; };
+               003F1FE911E6AB43008258D9 /* UserContentTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentTypes.h; sourceTree = "<group>"; };
                06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenuItem.h; sourceTree = "<group>"; };
                06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuItemMac.mm; sourceTree = "<group>"; };
                062287830B4DB322000C34DF /* FocusDirection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FocusDirection.h; sourceTree = "<group>"; };
                                8AF4E55811DC5A63000ED3DE /* Timing.cpp */,
                                8AF4E55911DC5A63000ED3DE /* Timing.h */,
                                8AF4E55A11DC5A63000ED3DE /* Timing.idl */,
+                               003F1FE911E6AB43008258D9 /* UserContentTypes.h */,
                                BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */,
                                BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */,
                                BCA2B0601050475F0043BD1C /* UserScript.h */,
                                BCA8C81E11E3D36900812FB7 /* BackForwardController.h in Headers */,
                                BCA8C83111E3D53200812FB7 /* BackForwardControllerClient.h in Headers */,
                                BCA8CA6011E4E6D100812FB7 /* BackForwardListImpl.h in Headers */,
+                               003F1FEA11E6AB43008258D9 /* UserContentTypes.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 1590a59..35dbc6c 100644 (file)
@@ -2154,6 +2154,8 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
         const UserStyleSheetVector* sheets = it->second;
         for (unsigned i = 0; i < sheets->size(); ++i) {
             const UserStyleSheet* sheet = sheets->at(i).get();
+            if (sheet->injectedFrames() == InjectInTopFrameOnly && ownerElement())
+                continue;
             if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
                 continue;
             RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
index f2edd93..6c79c76 100644 (file)
@@ -691,6 +691,9 @@ void Frame::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVe
     unsigned count = userScripts.size();
     for (unsigned i = 0; i < count; ++i) {
         UserScript* script = userScripts[i].get();
+        if (script->injectedFrames() == InjectInTopFrameOnly && ownerElement())
+            continue;
+
         if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->whitelist(), script->blacklist()))
             m_script.evaluateInWorld(ScriptSourceCode(script->source(), script->url()), world);
     }
index f6c746d..b45b9ea 100644 (file)
@@ -213,12 +213,13 @@ IndexedDatabase* PageGroup::indexedDatabase()
 }
 #endif
 
-void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,  PassOwnPtr<Vector<String> > whitelist,
-                                     PassOwnPtr<Vector<String> > blacklist, UserScriptInjectionTime injectionTime)
+void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,
+                                     PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                                     UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
 {
     ASSERT_ARG(world, world);
 
-    OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, injectionTime));
+    OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames));
     if (!m_userScripts)
         m_userScripts.set(new UserScriptMap);
     UserScriptVector*& scriptsInWorld = m_userScripts->add(world, 0).first->second;
@@ -227,19 +228,20 @@ void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& sourc
     scriptsInWorld->append(userScript.release());
 }
 
-void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
-                                         PassOwnPtr<Vector<String> > blacklist)
+void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,
+                                         PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                                         UserContentInjectedFrames injectedFrames)
 {
     ASSERT_ARG(world, world);
 
-    OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist));
+    OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist, injectedFrames));
     if (!m_userStyleSheets)
         m_userStyleSheets.set(new UserStyleSheetMap);
     UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(world, 0).first->second;
     if (!styleSheetsInWorld)
         styleSheetsInWorld = new UserStyleSheetVector;
     styleSheetsInWorld->append(userStyleSheet.release());
-    
+
     // Clear our cached sheets and have them just reparse.
     HashSet<Page*>::const_iterator end = m_pages.end();
     for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {
index a409494..545df78 100644 (file)
@@ -74,20 +74,21 @@ namespace WebCore {
         IndexedDatabase* indexedDatabase();
 #endif
 
-        void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&, 
+        void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
                                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
-                                  UserScriptInjectionTime);
+                                  UserScriptInjectionTime, UserContentInjectedFrames);
         void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
-                               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist);
-        
+                                      PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                                      UserContentInjectedFrames);
+
         void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&);
         void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&);
-        
+
         void removeUserScriptsFromWorld(DOMWrapperWorld*);
         void removeUserStyleSheetsFromWorld(DOMWrapperWorld*);
-    
+
         void removeAllUserContent();
-        
+
         const UserScriptMap* userScripts() const { return m_userScripts.get(); }
         const UserStyleSheetMap* userStyleSheets() const { return m_userStyleSheets.get(); }
 
diff --git a/WebCore/page/UserContentTypes.h b/WebCore/page/UserContentTypes.h
new file mode 100644 (file)
index 0000000..d012b8c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef UserContentTypes_h
+#define UserContentTypes_h
+
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+enum UserContentInjectedFrames { InjectInAllFrames, InjectInTopFrameOnly };
+
+} // namespace WebCore
+#endif // UserContentTypes_h
index 8b3703f..0652439 100644 (file)
@@ -27,6 +27,7 @@
 #define UserScript_h
 
 #include "KURL.h"
+#include "UserContentTypes.h"
 #include "UserScriptTypes.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -38,12 +39,13 @@ class UserScript : public Noncopyable {
 public:
     UserScript(const String& source, const KURL& url,
                PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
-               UserScriptInjectionTime injectionTime)
+               UserScriptInjectionTime injectionTime, UserContentInjectedFrames injectedFrames)
         : m_source(source)
         , m_url(url)
         , m_whitelist(whitelist)
         , m_blacklist(blacklist)
         , m_injectionTime(injectionTime)
+        , m_injectedFrames(injectedFrames)
     {
     }
 
@@ -52,15 +54,17 @@ public:
     const Vector<String>* whitelist() const { return m_whitelist.get(); }
     const Vector<String>* blacklist() const { return m_blacklist.get(); }
     UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
-    
+    UserContentInjectedFrames injectedFrames() const { return m_injectedFrames; }
+
 private:
     String m_source;
     KURL m_url;
     OwnPtr<Vector<String> > m_whitelist;
     OwnPtr<Vector<String> > m_blacklist;
     UserScriptInjectionTime m_injectionTime;
+    UserContentInjectedFrames m_injectedFrames;
 };
 
 } // namespace WebCore
+
 #endif // UserScript_h
index 610778f..4c6d708 100644 (file)
@@ -27,6 +27,7 @@
 #define UserStyleSheet_h
 
 #include "KURL.h"
+#include "UserContentTypes.h"
 #include "UserStyleSheetTypes.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
@@ -37,11 +38,13 @@ namespace WebCore {
 class UserStyleSheet : public Noncopyable {
 public:
     UserStyleSheet(const String& source, const KURL& url,
-                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist)
+                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                   UserContentInjectedFrames injectedFrames)
         : m_source(source)
         , m_url(url)
         , m_whitelist(whitelist)
         , m_blacklist(blacklist)
+        , m_injectedFrames(injectedFrames)
     {
     }
 
@@ -49,12 +52,14 @@ public:
     const KURL& url() const { return m_url; }
     const Vector<String>* whitelist() const { return m_whitelist.get(); }
     const Vector<String>* blacklist() const { return m_blacklist.get(); }
+    UserContentInjectedFrames injectedFrames() const { return m_injectedFrames; }
 
 private:
     String m_source;
     KURL m_url;
     OwnPtr<Vector<String> > m_whitelist;
     OwnPtr<Vector<String> > m_blacklist;
+    UserContentInjectedFrames m_injectedFrames;
 };
 
 } // namespace WebCore
index a4460cb..d1c47df 100644 (file)
@@ -1,3 +1,20 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        * public/WebView.h:
+        (WebKit::WebView::):
+        (WebKit::WebView::addUserScript):
+        (WebKit::WebView::addUserStyleSheet):
+        * src/AssertMatchingEnums.cpp:
+        * src/WebViewImpl.cpp:
+        (WebKit::WebView::addUserScript):
+        (WebKit::WebView::addUserStyleSheet):
+
 2010-07-08  James Robinson  <jamesr@google.com>
 
         Reviewed by Darin Fisher.
index 1efd752..a8f5387 100644 (file)
@@ -54,6 +54,18 @@ struct WebPoint;
 
 class WebView : public WebWidget {
 public:
+    // Controls the time that user scripts injected into the document run.
+    enum UserScriptInjectAt {
+        UserScriptInjectAtDocumentStart,
+        UserScriptInjectAtDocumentEnd
+    };
+
+    // Controls which frames user content is injected into.
+    enum UserContentInjectIn {
+        UserContentInjectInAllFrames,
+        UserContentInjectInTopFrameOnly
+    };
+
     // Initialization ------------------------------------------------------
 
     // Creates a WebView that is NOT yet initialized.  You will need to
@@ -286,18 +298,22 @@ public:
     // FIXME: These two methods are DEPRECATED. Remove once Chromium has been rolled.
     virtual void addUserScript(const WebString& sourceCode, bool runAtStart)
     {
-        addUserScript(sourceCode, WebVector<WebString>(), runAtStart);
+        addUserScript(sourceCode, WebVector<WebString>(),
+                      runAtStart ? UserScriptInjectAtDocumentStart : UserScriptInjectAtDocumentEnd,
+                      UserContentInjectInAllFrames);
     }
     virtual void addUserStyleSheet(const WebString& sourceCode)
     {
-        addUserStyleSheet(sourceCode, WebVector<WebString>());
+        addUserStyleSheet(sourceCode, WebVector<WebString>(), UserContentInjectInAllFrames);
     }
 
     WEBKIT_API static void addUserScript(const WebString& sourceCode,
                                          const WebVector<WebString>& patterns,
-                                         bool runAtStart);
+                                         UserScriptInjectAt injectAt,
+                                         UserContentInjectIn injectIn);
     WEBKIT_API static void addUserStyleSheet(const WebString& sourceCode,
-                                             const WebVector<WebString>& patterns);
+                                             const WebVector<WebString>& patterns,
+                                             UserContentInjectIn injectIn);
     WEBKIT_API static void removeAllUserContent();
 
     // Modal dialog support ------------------------------------------------
index 5736ca0..43aa910 100644 (file)
@@ -44,6 +44,8 @@
 #include "Settings.h"
 #include "StringImpl.h"
 #include "TextAffinity.h"
+#include "UserContentTypes.h"
+#include "UserScriptTypes.h"
 #include "WebAccessibilityObject.h"
 #include "WebApplicationCacheHost.h"
 #include "WebClipboard.h"
@@ -56,6 +58,7 @@
 #include "WebSettings.h"
 #include "WebTextAffinity.h"
 #include "WebTextCaseSensitivity.h"
+#include "WebView.h"
 #include <wtf/Assertions.h>
 
 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \
@@ -312,3 +315,8 @@ COMPILE_ASSERT_MATCHING_ENUM(WebTextAffinityDownstream, DOWNSTREAM);
 
 COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseSensitive, TextCaseSensitive);
 COMPILE_ASSERT_MATCHING_ENUM(WebTextCaseInsensitive, TextCaseInsensitive);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserScriptInjectAtDocumentStart, InjectAtDocumentStart);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserScriptInjectAtDocumentEnd, InjectAtDocumentEnd);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInAllFrames, InjectInAllFrames);
+COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInTopFrameOnly, InjectInTopFrameOnly);
index 3584763..5897def 100644 (file)
@@ -1870,7 +1870,10 @@ void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor,
 #endif
 }
 
-void WebView::addUserScript(const WebString& sourceCode, const WebVector<WebString>& patternsIn, bool runAtStart)
+void WebView::addUserScript(const WebString& sourceCode,
+                            const WebVector<WebString>& patternsIn,
+                            WebView::UserScriptInjectAt injectAt,
+                            WebView::UserContentInjectIn injectIn)
 {
     OwnPtr<Vector<String> > patterns(new Vector<String>);
     for (size_t i = 0; i < patternsIn.size(); ++i)
@@ -1879,10 +1882,13 @@ void WebView::addUserScript(const WebString& sourceCode, const WebVector<WebStri
     PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
     RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::create());
     pageGroup->addUserScriptToWorld(world.get(), sourceCode, WebURL(), patterns.release(), 0,
-                                    runAtStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
+                                    static_cast<UserScriptInjectionTime>(injectAt),
+                                    static_cast<UserContentInjectedFrames>(injectIn));
 }
 
-void WebView::addUserStyleSheet(const WebString& sourceCode, const WebVector<WebString>& patternsIn)
+void WebView::addUserStyleSheet(const WebString& sourceCode,
+                                const WebVector<WebString>& patternsIn,
+                                WebView::UserContentInjectIn injectIn)
 {
     OwnPtr<Vector<String> > patterns(new Vector<String>);
     for (size_t i = 0; i < patternsIn.size(); ++i)
@@ -1890,7 +1896,8 @@ void WebView::addUserStyleSheet(const WebString& sourceCode, const WebVector<Web
 
     PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName);
     RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::create());
-    pageGroup->addUserStyleSheetToWorld(world.get(), sourceCode, WebURL(), patterns.release(), 0);
+    pageGroup->addUserStyleSheetToWorld(world.get(), sourceCode, WebURL(), patterns.release(), 0,
+                                        static_cast<UserContentInjectedFrames>(injectIn));
 }
 
 void WebView::removeAllUserContent()
index 93c2272..a4ef157 100644 (file)
@@ -1,3 +1,18 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        * WebView/WebView.mm:
+        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
+        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:injectedFrames:]):
+        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
+        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:injectedFrames:]):
+        * WebView/WebViewPrivate.h:
+
 2010-07-08  Adele Peterson  <adele@apple.com>
 
         Reviewed by Jon Honeycutt, Adam Roben, and Darin Adler.
index 23d3bb3..6d61453 100644 (file)
@@ -2362,7 +2362,16 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
 }
 
 + (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
-                    whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime
+                    whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
+                injectionTime:(WebUserScriptInjectionTime)injectionTime
+{
+    [WebView _addUserScriptToGroup:groupName world:world source:source url:url whitelist:whitelist blacklist:blacklist injectionTime:injectionTime injectedFrames:WebInjectInAllFrames];
+}
+
++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
+                    whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
+                injectionTime:(WebUserScriptInjectionTime)injectionTime
+               injectedFrames:(WebUserContentInjectedFrames)injectedFrames
 {
     String group(groupName);
     if (group.isEmpty())
@@ -2373,11 +2382,19 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
         return;
     
     pageGroup->addUserScriptToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist), 
-                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
+                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd,
+                                    injectedFrames == WebInjectInAllFrames ? InjectInAllFrames : InjectInTopFrameOnly);
+}
+
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
+                        whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
+{
+    [WebView _addUserStyleSheetToGroup:groupName world:world source:source url:url whitelist:whitelist blacklist:blacklist injectedFrames:WebInjectInAllFrames];
 }
 
 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
                         whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
+                   injectedFrames:(WebUserContentInjectedFrames)injectedFrames
 {
     String group(groupName);
     if (group.isEmpty())
@@ -2387,7 +2404,7 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
     if (!pageGroup)
         return;
 
-    pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist));
+    pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist), injectedFrames == WebInjectInAllFrames ? InjectInAllFrames : InjectInTopFrameOnly);
 }
 
 + (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url
index cedc62c..9d47a4d 100644 (file)
@@ -88,6 +88,11 @@ typedef enum {
     WebInjectAtDocumentEnd,
 } WebUserScriptInjectionTime;
 
+typedef enum {
+    WebInjectInAllFrames,
+    WebInjectInTopFrameOnly
+} WebUserContentInjectedFrames;
+
 @interface WebController : NSTreeController {
     IBOutlet WebView *webView;
 }
@@ -504,8 +509,12 @@ Could be worth adding to the API.
 // Removes all white list entries created with _addOriginAccessWhitelistEntryWithSourceOrigin.
 + (void)_resetOriginAccessWhitelists;
 
+// FIXME: The following two methods are deprecated in favor of the overloads below that take the WebUserContentInjectedFrames argument. https://bugs.webkit.org/show_bug.cgi?id=41800.
 + (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
 + (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
+
++ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime injectedFrames:(WebUserContentInjectedFrames)injectedFrames;
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectedFrames:(WebUserContentInjectedFrames)injectedFrames;
 + (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
 + (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
index 5a844f9..65eff34 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        * WebView.cpp:
+        (WebView::addUserScriptToGroup):
+        (WebView::addUserStyleSheetToGroup):
+
 2010-07-08  Adele Peterson  <adele@apple.com>
 
         Reviewed by Jon Honeycutt, Adam Roben, and Darin Adler.
index 5ea4ec3..b5c4fa8 100644 (file)
@@ -5970,7 +5970,8 @@ HRESULT WebView::addUserScriptToGroup(BSTR groupName, IWebScriptWorld* iWorld, B
 
     pageGroup->addUserScriptToWorld(world->world(), toString(source), toKURL(url),
                                     toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist),
-                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
+                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd,
+                                    InjectInAllFrames);
 
     return S_OK;
 }
@@ -5993,7 +5994,8 @@ HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld* iWorl
         return E_FAIL;
 
     pageGroup->addUserStyleSheetToWorld(world->world(), toString(source), toKURL(url),
-                                        toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist));
+                                        toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist),
+                                        InjectInAllFrames);
 
     return S_OK;
 }
index d36dc7c..6c41aeb 100644 (file)
@@ -1,3 +1,31 @@
+2010-07-08  Aaron Boodman  <aa@chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Add the ability for user scripts and user styles to affect just the top frame.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41529
+
+        * DumpRenderTree/LayoutTestController.h: Added new allFrames param.
+        * DumpRenderTree/LayoutTestController.cpp: Ditto.
+        (addUserScriptCallback):
+        (addUserStyleSheetCallback):
+        * DumpRenderTree/chromium/LayoutTestController.cpp: Ditto.
+        (LayoutTestController::addUserScript):
+        (LayoutTestController::addUserStyleSheet):
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: Ditto.
+        (LayoutTestController::addUserScript):
+        (LayoutTestController::addUserStyleSheet):
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm: Ditto.
+        (LayoutTestController::addUserScript):
+        (LayoutTestController::addUserStyleSheet):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp: Ditto.
+        (LayoutTestController::addUserScript):
+        (LayoutTestController::addUserStyleSheet):
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp: Ditto.
+        (LayoutTestController::addUserScript):
+        (LayoutTestController::addUserStyleSheet):
+
 2010-07-08  Adele Peterson  <adele@apple.com>
 
         Reviewed by Jon Honeycutt, Adam Roben, and Darin Adler.
index edab29e..cd294bc 100644 (file)
@@ -1499,28 +1499,30 @@ static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef,
 
 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (argumentCount != 2)
+    if (argumentCount != 3)
         return JSValueMakeUndefined(context);
     
     JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
     bool runAtStart = JSValueToBoolean(context, arguments[1]);
+    bool allFrames = JSValueToBoolean(context, arguments[2]);
     
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    controller->addUserScript(source.get(), runAtStart);
+    controller->addUserScript(source.get(), runAtStart, allFrames);
     return JSValueMakeUndefined(context);
 }
  
 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (argumentCount != 1)
+    if (argumentCount != 2)
         return JSValueMakeUndefined(context);
     
     JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     ASSERT(!*exception);
+    bool allFrames = JSValueToBoolean(context, arguments[1]);
    
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    controller->addUserStyleSheet(source.get());
+    controller->addUserStyleSheet(source.get(), allFrames);
     return JSValueMakeUndefined(context);
 }
 
index be79473..16eda2c 100644 (file)
@@ -241,8 +241,8 @@ public:
     void addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
     void removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
 
-    void addUserScript(JSStringRef source, bool runAtStart);
-    void addUserStyleSheet(JSStringRef source);
+    void addUserScript(JSStringRef source, bool runAtStart, bool allFrames);
+    void addUserStyleSheet(JSStringRef source, bool allFrames);
 
     void setGeolocationPermission(bool allow);
     bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
index cb8693d..0f37d7e 100644 (file)
@@ -1273,17 +1273,22 @@ void LayoutTestController::forceRedSelectionColors(const CppArgumentList& argume
 void LayoutTestController::addUserScript(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
-    if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool())
+    if (arguments.size() < 3 || !arguments[0].isString() || !arguments[1].isBool() || !arguments[2].isBool())
         return;
-    m_shell->webView()->addUserScript(cppVariantToWebString(arguments[0]), arguments[1].toBoolean());
+    WebView::addUserScript(
+        cppVariantToWebString(arguments[0]), WebVector<WebString>(),
+        arguments[1].toBoolean() ? WebView::UserScriptInjectAtDocumentStart : WebView::UserScriptInjectAtDocumentEnd,
+        arguments[2].toBoolean() ? WebView::UserContentInjectInAllFrames : WebView::UserContentInjectInTopFrameOnly);
 }
 
 void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
-    if (arguments.size() < 1 || !arguments[0].isString())
+    if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool())
         return;
-    m_shell->webView()->addUserStyleSheet(cppVariantToWebString(arguments[0]));
+    WebView::addUserStyleSheet(
+        cppVariantToWebString(arguments[0]), WebVector<WebString>(),
+        arguments[2].toBoolean() ? WebView::UserContentInjectInAllFrames : WebView::UserContentInjectInTopFrameOnly);
 }
 
 void LayoutTestController::setEditingBehavior(const CppArgumentList& arguments, CppVariant* results)
index 1814933..5c942d3 100644 (file)
@@ -624,12 +624,12 @@ void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value
     g_free(strValue);
 }
 
-void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
+void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     printf("LayoutTestController::addUserScript not implemented.\n");
 }
 
-void LayoutTestController::addUserStyleSheet(JSStringRef source)
+void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
 {
     printf("LayoutTestController::addUserStyleSheet not implemented.\n");
 }
index 9b044c3..aec4c19 100644 (file)
@@ -627,18 +627,18 @@ void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringR
     // FIXME: implement
 }
 
-void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
+void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
     NSString *sourceNS = (NSString *)sourceCF.get();
-    [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
+    [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd) injectedFrames:(allFrames ? WebInjectInAllFrames : WebInjectInTopFrameOnly)];
 }
 
-void LayoutTestController::addUserStyleSheet(JSStringRef source)
+void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
 {
     RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
     NSString *sourceNS = (NSString *)sourceCF.get();
-    [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil];
+    [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectedFrames:(allFrames ? WebInjectInAllFrames : WebInjectInTopFrameOnly)];
 }
 
 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled)
index df96328..b79bb2a 100644 (file)
@@ -1040,7 +1040,7 @@ void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringR
     // FIXME: implement
 }
 
-void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
+void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     COMPtr<IWebViewPrivate> webView;
     if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView))))
@@ -1054,7 +1054,7 @@ void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
 }
 
 
-void LayoutTestController::addUserStyleSheet(JSStringRef source)
+void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
 {
     COMPtr<IWebViewPrivate> webView;
     if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView))))
index 05a315b..905463a 100644 (file)
@@ -327,12 +327,12 @@ void LayoutTestController::overridePreference(JSStringRef /* key */, JSStringRef
     // FIXME: implement
 }
 
-void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
+void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 {
     printf("LayoutTestController::addUserScript not implemented.\n");
 }
 
-void LayoutTestController::addUserStyleSheet(JSStringRef source)
+void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
 {
     printf("LayoutTestController::addUserStyleSheet not implemented.\n");
 }