Source/WebCore/ChangeLog

 12011-04-06 Andy Estes <aestes@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 REGRESSION (r64712): Microsoft Outlook 2011: original message contents
 6 not included when replying to an email.
 7 https://bugs.webkit.org/show_bug.cgi?id=57794
 8
 9 Add a function to check if the embedding application is Microsoft
 10 Outlook. Also, add a setting to control whether user scripts should be
 11 injected into the initial empty document. This setting defaults to
 12 false.
 13
 14 * WebCore.exp.in:
 15 * loader/FrameLoader.cpp:
 16 (WebCore::FrameLoader::finishedParsing):
 17 * page/Frame.cpp:
 18 (WebCore::Frame::injectUserScripts):
 19 * page/Settings.cpp:
 20 (WebCore::Settings::Settings):
 21 * page/Settings.h:
 22 (WebCore::Settings::setInjectUserScriptsInInitialEmptyDocument):
 23 (WebCore::Settings::injectUserScriptsInInitialEmptyDocument):
 24 * platform/mac/RuntimeApplicationChecks.h:
 25 * platform/mac/RuntimeApplicationChecks.mm:
 26 (WebCore::applicationIsMicrosoftOutlook):
 27
1282011-04-06 Stephanie Lewis <slewis@apple.com>
229
330 Reviewed by Darin Adler.
83131

Source/WebCore/WebCore.exp.in

@@__ZN7WebCore28contextMenuItemTagSmartLin
616616__ZN7WebCore28contextMenuItemTagSpeechMenuEv
617617__ZN7WebCore28encodeWithURLEscapeSequencesERKN3WTF6StringE
618618__ZN7WebCore28removeLanguageChangeObserverEPv
 619__ZN7WebCore29applicationIsMicrosoftOutlookEv
619620__ZN7WebCore29contextMenuItemTagLeftToRightEv
620621__ZN7WebCore29contextMenuItemTagRightToLeftEv
621622__ZN7WebCore29contextMenuItemTagSmartDashesEv
83032

Source/WebCore/loader/FrameLoader.cpp

@@void FrameLoader::commitIconURLToIconDat
790790
791791void FrameLoader::finishedParsing()
792792{
 793 m_frame->injectUserScripts(InjectAtDocumentEnd);
 794
793795 if (m_stateMachine.creatingInitialEmptyDocument())
794796 return;
795797
796  m_frame->injectUserScripts(InjectAtDocumentEnd);
797 
798798 // This can be called from the Frame's destructor, in which case we shouldn't protect ourselves
799799 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
800800 // Null-checking the FrameView indicates whether or not we're in the destructor.
83032

Source/WebCore/page/Frame.cpp

55 * 2000 Simon Hausmann <hausmann@kde.org>
66 * 2000 Stefan Schimanski <1Stein@gmx.de>
77 * 2001 George Staikos <staikos@kde.org>
8  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
99 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
1010 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
1111 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>

@@void Frame::injectUserScripts(UserScript
518518 if (!m_page)
519519 return;
520520
521  if (loader()->stateMachine()->creatingInitialEmptyDocument())
 521 if (loader()->stateMachine()->creatingInitialEmptyDocument()
 522 && !settings()->injectUserScriptsInInitialEmptyDocument())
522523 return;
523 
 524
524525 // Walk the hashtable. Inject by world.
525526 const UserScriptMap* userScripts = m_page->group().userScripts();
526527 if (!userScripts)
83032

Source/WebCore/page/Settings.cpp

11/*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
 2 * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@Settings::Settings(Page* page)
172172 , m_crossOriginCheckInGetMatchedCSSRulesDisabled(false)
173173 , m_useQuickLookResourceCachingQuirks(false)
174174 , m_forceCompositingMode(false)
 175 , m_injectUserScriptsInInitialEmptyDocument(false)
175176{
176177 // A Frame may not have been created yet, so we initialize the AtomicString
177178 // hash before trying to use it.
83032

Source/WebCore/page/Settings.h

11/*
2  * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
33 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
44 *
55 * Redistribution and use in source and binary forms, with or without

@@namespace WebCore {
385385
386386 void setForceCompositingMode(bool flag) { m_forceCompositingMode = flag; }
387387 bool forceCompositingMode() { return m_forceCompositingMode; }
 388
 389 void setInjectUserScriptsInInitialEmptyDocument(bool flag) { m_injectUserScriptsInInitialEmptyDocument = flag; }
 390 bool injectUserScriptsInInitialEmptyDocument() { return m_injectUserScriptsInInitialEmptyDocument; }
388391
389392 private:
390393 Page* m_page;

@@namespace WebCore {
487490 bool m_crossOriginCheckInGetMatchedCSSRulesDisabled : 1;
488491 bool m_useQuickLookResourceCachingQuirks : 1;
489492 bool m_forceCompositingMode : 1;
 493 bool m_injectUserScriptsInInitialEmptyDocument : 1;
490494
491495#if USE(SAFARI_THEME)
492496 static bool gShouldPaintNativeControls;
83032

Source/WebCore/platform/mac/RuntimeApplicationChecks.h

11/*
2  * Copyright (C) 2009 Apple Inc. All rights reserved.
 2 * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@bool applicationIsMicrosoftMessenger();
3434bool applicationIsAdobeInstaller();
3535bool applicationIsAOLInstantMessenger();
3636bool applicationIsMicrosoftMyDay();
 37bool applicationIsMicrosoftOutlook();
3738
3839} // namespace WebCore
3940
83032

Source/WebCore/platform/mac/RuntimeApplicationChecks.mm

11/*
2  * Copyright (C) 2009 Apple Inc. All rights reserved.
 2 * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@bool applicationIsMicrosoftMyDay()
6464 static bool isMicrosoftMyDay = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.microsoft.myday"];
6565 return isMicrosoftMyDay;
6666}
 67
 68bool applicationIsMicrosoftOutlook()
 69{
 70 static bool isMicrosoftOutlook = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.microsoft.Outlook"];
 71 return isMicrosoftOutlook;
 72}
6773
6874} // namespace WebCore
83032

Source/WebKit/ChangeLog

 12011-04-06 Andy Estes <aestes@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 REGRESSION (r64712): Microsoft Outlook 2011: original message contents
 6 not included when replying to an email.
 7 https://bugs.webkit.org/show_bug.cgi?id=57794
 8
 9 * WebKit.xcodeproj/project.pbxproj:
 10
1112011-04-05 Alexey Proskuryakov <ap@apple.com>
212
313 Reviewed by Darin Adler.
83131

Source/WebKit/WebKit.xcodeproj/project.pbxproj

8181 226E9E6A09D0AA8200F3A2BC /* WebNetscapeDeprecatedFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 226E9E6809D0AA8200F3A2BC /* WebNetscapeDeprecatedFunctions.h */; };
8282 226E9E6B09D0AA8200F3A2BC /* WebNetscapeDeprecatedFunctions.c in Sources */ = {isa = PBXBuildFile; fileRef = 226E9E6909D0AA8200F3A2BC /* WebNetscapeDeprecatedFunctions.c */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
8383 22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 84 29AEF95E134C755400FE5096 /* OutlookQuirksUserScript.js in Sources */ = {isa = PBXBuildFile; fileRef = 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */; };
 85 29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */; };
8486 37B6FB4E1063530C000FDB3B /* WebPDFDocumentExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 37B6FB4C1063530C000FDB3B /* WebPDFDocumentExtras.h */; };
8587 37B6FB4F1063530C000FDB3B /* WebPDFDocumentExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37B6FB4D1063530C000FDB3B /* WebPDFDocumentExtras.mm */; };
8688 37D1DCA81065928C0068F7EF /* WebJSPDFDoc.h in Headers */ = {isa = PBXBuildFile; fileRef = 37D1DCA61065928C0068F7EF /* WebJSPDFDoc.h */; };

464466 226E9E6909D0AA8200F3A2BC /* WebNetscapeDeprecatedFunctions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = WebNetscapeDeprecatedFunctions.c; sourceTree = "<group>"; };
465467 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
466468 2568C72C0174912D0ECA149E /* WebKit.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKit.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 469 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = OutlookQuirksUserScript.js; sourceTree = "<group>"; };
467470 2D36FD5E03F78F9E00A80166 /* WebFormDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegatePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
468471 2D81DAB203EB0B2D00A80166 /* WebFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFormDelegate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
469472 2D81DAB303EB0B2D00A80166 /* WebFormDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebFormDelegate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };

939942 254DC334016E1D3F0ECA149E /* Misc */ = {
940943 isa = PBXGroup;
941944 children = (
 945 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */,
942946 A864B3E5123ED83D00C2A612 /* MailQuirksUserScript.js */,
943947 1CCFFD120B1F81F2002EE926 /* OldWebAssertions.c */,
944948 5DE92FEE0BD7017E0059A5FD /* WebAssertions.h */,

17121716 isa = PBXResourcesBuildPhase;
17131717 buildActionMask = 2147483647;
17141718 files = (
 1719 29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */,
17151720 A864B3F6123ED9FA00C2A612 /* MailQuirksUserScript.js in Resources */,
17161721 939810BA0824BF01008DF038 /* IDNScriptWhiteList.txt in Resources */,
17171722 939810B70824BF01008DF038 /* url_icon.tiff in Resources */,

20152020 3ABB3C7B1309C3B500E93D94 /* WebStorageTrackerClient.mm in Sources */,
20162021 BC42D34D131ED3880075FA4B /* WebLocalizableStringsInternal.mm in Sources */,
20172022 B82958D4132707D0000D0E79 /* CorrectionPanel.mm in Sources */,
 2023 29AEF95E134C755400FE5096 /* OutlookQuirksUserScript.js in Sources */,
20182024 );
20192025 runOnlyForDeploymentPostprocessing = 0;
20202026 };
83032

Source/WebKit/mac/ChangeLog

 12011-04-06 Andy Estes <aestes@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 REGRESSION (r64712): Microsoft Outlook 2011: original message contents
 6 not included when replying to an email.
 7 https://bugs.webkit.org/show_bug.cgi?id=57794
 8
 9 Outlook populates a reply message by creating an empty WebView and
 10 using DOM API to populate the WebView's empty document with content
 11 from the original message. It expects the initial empty document to
 12 simply be "<html></html>", and it proceeds to dynamically create and
 13 append a BODY node and add the original message content as a child of
 14 that node. Outlook then takes the innerHTML of the frame's first body
 15 element and copies it into a *new* document that is displayed and
 16 edited in the reply message window.
 17
 18 Due to implementing the HTML5 tree building algorithm in r64712,
 19 initial empty documents went from being "<html></html>" to being
 20 "<html><head></head><body></body></html>". Outlook still dynamically
 21 creates a BODY node to parent the original message content, but this
 22 BODY node duplicates the one created by the tree builder. When Outlook
 23 then takes the innerHTML of the first body element to populate the
 24 reply message window it gets the empty body element created by the
 25 parser, not the one it created with the original message content.
 26
 27 Fix this by injecting a user script into the initial empty document
 28 that removes the HEAD and BODY nodes created by the parser. This
 29 ensures that the BODY created by Outlook is the only BODY in the
 30 document.
 31
 32 * Misc/OutlookQuirksUserScript.js: Added.
 33 * WebView/WebView.mm:
 34 (leakMailQuirksUserScriptContents):
 35 (-[WebView _injectMailQuirksScript]):
 36 (needsOutlookQuirksScript):
 37 (leakOutlookQuirksUserScriptContents):
 38 (-[WebView _injectOutlookQuirksScript]):
 39 (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):
 40
1412011-04-06 Robert Sesek <rsesek@chromium.org>
242
343 Reviewed by Alexey Proskuryakov.
83131

Source/WebKit/mac/Misc/OutlookQuirksUserScript.js

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25(function() {
 26 // This should only apply to the initial empty document, which should look like:
 27 // <html><head></head><body></body></html>
 28 if (document.documentElement.outerHTML != "<html><head></head><body></body></html>")
 29 return;
 30
 31 // Outlook expects the initial empty document to only contain the document
 32 // element. It will explicitly insert a BODY node.
 33 document.documentElement.removeChild(document.head);
 34 document.documentElement.removeChild(document.body);
 35})();
 36
 37
0

Source/WebKit/mac/WebView/WebView.mm

11/*
2  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
33 * Copyright (C) 2006 David Smith (catfish.man@gmail.com)
44 * Copyright (C) 2010 Igalia S.L
55 *

@@- (BOOL)_usesDocumentViews
639639 return _private->usesDocumentViews;
640640}
641641
642 static NSString *leakMailQuirksUserScriptPath()
 642static NSString *leakMailQuirksUserScriptContents()
643643{
644644 NSString *scriptPath = [[NSBundle bundleForClass:[WebView class]] pathForResource:@"MailQuirksUserScript" ofType:@"js"];
645645 return [[NSString alloc] initWithContentsOfFile:scriptPath];

@@static NSString *leakMailQuirksUserScrip
647647
648648- (void)_injectMailQuirksScript
649649{
650  static NSString *mailQuirksScriptPath = leakMailQuirksUserScriptPath();
 650 static NSString *mailQuirksScriptContents = leakMailQuirksUserScriptContents();
651651 core(self)->group().addUserScriptToWorld(core([WebScriptWorld world]),
652  mailQuirksScriptPath, KURL(), 0, 0, InjectAtDocumentEnd, InjectInAllFrames);
 652 mailQuirksScriptContents, KURL(), 0, 0, InjectAtDocumentEnd, InjectInAllFrames);
 653}
 654
 655static bool needsOutlookQuirksScript()
 656{
 657 static bool isOutlookNeedingQuirksScript = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_HTML5_PARSER)
 658 && applicationIsMicrosoftOutlook();
 659 return isOutlookNeedingQuirksScript;
 660}
 661
 662static NSString *leakOutlookQuirksUserScriptContents()
 663{
 664 NSString *scriptPath = [[NSBundle bundleForClass:[WebView class]] pathForResource:@"OutlookQuirksUserScript" ofType:@"js"];
 665 return [[NSString alloc] initWithContentsOfFile:scriptPath];
 666}
 667
 668-(void)_injectOutlookQuirksScript
 669{
 670 static NSString *outlookQuirksScriptContents = leakOutlookQuirksUserScriptContents();
 671 core(self)->group().addUserScriptToWorld(core([WebScriptWorld world]),
 672 outlookQuirksScriptContents, KURL(), 0, 0, InjectAtDocumentEnd, InjectInAllFrames);
653673}
654674
655675- (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName usesDocumentViews:(BOOL)usesDocumentViews

@@- (void)_commonInitializationWithFrameNa
720740 _private->page->setCanStartMedia([self window]);
721741 _private->page->settings()->setLocalStorageDatabasePath([[self preferences] _localStorageDatabasePath]);
722742
 743 if (needsOutlookQuirksScript()) {
 744 _private->page->settings()->setInjectUserScriptsInInitialEmptyDocument(true);
 745 [self _injectOutlookQuirksScript];
 746 }
 747
723748 [WebFrame _createMainFrameWithPage:_private->page frameName:frameName frameView:frameView];
724749
725750#ifndef BUILDING_ON_TIGER
83032