Changeset 83201 in webkit


Ignore:
Timestamp:
Apr 7, 2011 1:23:48 PM (13 years ago)
Author:
aestes@apple.com
Message:

2011-04-07 Andy Estes <aestes@apple.com>

Reviewed by Darin Adler.

REGRESSION (r64712): Microsoft Outlook 2011: original message contents
not included when replying to an email.
https://bugs.webkit.org/show_bug.cgi?id=57794

  • WebKit.xcodeproj/project.pbxproj:

2011-04-07 Andy Estes <aestes@apple.com>

Reviewed by Darin Adler.

REGRESSION (r64712): Microsoft Outlook 2011: original message contents
not included when replying to an email.
https://bugs.webkit.org/show_bug.cgi?id=57794


Outlook populates a reply message by creating an empty WebView and
using DOM API to populate the WebView's empty document with content
from the original message. It expects the initial empty document to
simply be "<html></html>", and it proceeds to dynamically create and
append a BODY node and add the original message content as a child of
that node. Outlook then takes the innerHTML of the frame's first body
element and copies it into a *new* document that is displayed and
edited in the reply message window.


Due to implementing the HTML5 tree building algorithm in r64712,
initial empty documents went from being "<html></html>" to being
"<html><head></head><body></body></html>". Outlook still dynamically
creates a BODY node to parent the original message content, but this
BODY node duplicates the one created by the tree builder. When Outlook
then takes the innerHTML of the first body element to populate the
reply message window it gets the empty body element created by the
parser, not the one it created with the original message content.


Fix this by injecting a user script into the initial empty document
that removes the HEAD and BODY nodes created by the parser. This
ensures that the BODY created by Outlook is the only BODY in the
document.

  • Misc/OutlookQuirksUserScript.js: Added.
  • WebView/WebView.mm: (leakMailQuirksUserScriptContents): (-[WebView _injectMailQuirksScript]): (needsOutlookQuirksScript): (leakOutlookQuirksUserScriptContents): (-[WebView _injectOutlookQuirksScript]): (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):

2011-04-07 Andy Estes <aestes@apple.com>

Reviewed by Darin Adler.

REGRESSION (r64712): Microsoft Outlook 2011: original message contents
not included when replying to an email.
https://bugs.webkit.org/show_bug.cgi?id=57794


  • WebCore.exp.in:
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::finishedParsing): Call Frame::injectUserScripts() before checking if the FrameLoader is parsing the initial empty document. This allows user scripts to be injected at the end of document parsing (if the setting is enabled).
  • page/Frame.cpp: (WebCore::Frame::injectUserScripts): Do not inject scripts if this feature is disabled on the initial empty document.
  • page/Settings.cpp: (WebCore::Settings::Settings):
  • page/Settings.h: Add a setting for injecting user scripts into the initial empty document (defaults to false). (WebCore::Settings::setInjectUserScriptsInInitialEmptyDocument): (WebCore::Settings::injectUserScriptsInInitialEmptyDocument):
  • platform/mac/RuntimeApplicationChecks.h:
  • platform/mac/RuntimeApplicationChecks.mm: (WebCore::applicationIsMicrosoftOutlook): Check if the embedding application is Microsoft Outlook.
Location:
trunk/Source
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83196 r83201  
     12011-04-07  Andy Estes  <aestes@apple.com>
     2
     3        Reviewed by Darin Adler.
     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        * WebCore.exp.in:
     10        * loader/FrameLoader.cpp:
     11        (WebCore::FrameLoader::finishedParsing): Call Frame::injectUserScripts()
     12        before checking if the FrameLoader is parsing the initial empty document.
     13        This allows user scripts to be injected at the end of document parsing
     14        (if the setting is enabled).
     15        * page/Frame.cpp:
     16        (WebCore::Frame::injectUserScripts): Do not inject scripts if this
     17        feature is disabled on the initial empty document.
     18        * page/Settings.cpp:
     19        (WebCore::Settings::Settings):
     20        * page/Settings.h: Add a setting for injecting user scripts into the
     21        initial empty document (defaults to false).
     22        (WebCore::Settings::setInjectUserScriptsInInitialEmptyDocument):
     23        (WebCore::Settings::injectUserScriptsInInitialEmptyDocument):
     24        * platform/mac/RuntimeApplicationChecks.h:
     25        * platform/mac/RuntimeApplicationChecks.mm:
     26        (WebCore::applicationIsMicrosoftOutlook): Check if the embedding
     27        application is Microsoft Outlook.
     28
    1292011-04-06  Jer Noble  <jer.noble@apple.com>
    230
  • trunk/Source/WebCore/WebCore.exp.in

    r83081 r83201  
    618618__ZN7WebCore28encodeWithURLEscapeSequencesERKN3WTF6StringE
    619619__ZN7WebCore28removeLanguageChangeObserverEPv
     620__ZN7WebCore29applicationIsMicrosoftOutlookEv
    620621__ZN7WebCore29contextMenuItemTagLeftToRightEv
    621622__ZN7WebCore29contextMenuItemTagRightToLeftEv
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r82843 r83201  
    791791void FrameLoader::finishedParsing()
    792792{
     793    m_frame->injectUserScripts(InjectAtDocumentEnd);
     794
    793795    if (m_stateMachine.creatingInitialEmptyDocument())
    794796        return;
    795 
    796     m_frame->injectUserScripts(InjectAtDocumentEnd);
    797797
    798798    // This can be called from the Frame's destructor, in which case we shouldn't protect ourselves
  • trunk/Source/WebCore/page/Frame.cpp

    r83081 r83201  
    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)
     
    519519        return;
    520520
    521     if (loader()->stateMachine()->creatingInitialEmptyDocument())
    522         return;
    523    
     521    if (loader()->stateMachine()->creatingInitialEmptyDocument() && !settings()->shouldInjectUserScriptsInInitialEmptyDocument())
     522        return;
     523
    524524    // Walk the hashtable. Inject by world.
    525525    const UserScriptMap* userScripts = m_page->group().userScripts();
  • trunk/Source/WebCore/page/Settings.cpp

    r82386 r83201  
    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
     
    173173    , m_useQuickLookResourceCachingQuirks(false)
    174174    , m_forceCompositingMode(false)
     175    , m_shouldInjectUserScriptsInInitialEmptyDocument(false)
    175176{
    176177    // A Frame may not have been created yet, so we initialize the AtomicString
  • trunk/Source/WebCore/page/Settings.h

    r82386 r83201  
    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 *
     
    386386        void setForceCompositingMode(bool flag) { m_forceCompositingMode = flag; }
    387387        bool forceCompositingMode() { return m_forceCompositingMode; }
     388       
     389        void setShouldInjectUserScriptsInInitialEmptyDocument(bool flag) { m_shouldInjectUserScriptsInInitialEmptyDocument = flag; }
     390        bool shouldInjectUserScriptsInInitialEmptyDocument() { return m_shouldInjectUserScriptsInInitialEmptyDocument; }
    388391
    389392    private:
     
    488491        bool m_useQuickLookResourceCachingQuirks : 1;
    489492        bool m_forceCompositingMode : 1;
     493        bool m_shouldInjectUserScriptsInInitialEmptyDocument : 1;
    490494
    491495#if USE(SAFARI_THEME)
  • trunk/Source/WebCore/platform/mac/RuntimeApplicationChecks.h

    r68175 r83201  
    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
     
    3535bool applicationIsAOLInstantMessenger();
    3636bool applicationIsMicrosoftMyDay();
     37bool applicationIsMicrosoftOutlook();
    3738
    3839} // namespace WebCore
  • trunk/Source/WebCore/platform/mac/RuntimeApplicationChecks.mm

    r68175 r83201  
    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
     
    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
  • trunk/Source/WebKit/ChangeLog

    r83000 r83201  
     12011-04-07  Andy Estes  <aestes@apple.com>
     2
     3        Reviewed by Darin Adler.
     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
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r83000 r83201  
    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 */; };
     
    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; };
     
    940943                        isa = PBXGroup;
    941944                        children = (
     945                                29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */,
    942946                                A864B3E5123ED83D00C2A612 /* MailQuirksUserScript.js */,
    943947                                1CCFFD120B1F81F2002EE926 /* OldWebAssertions.c */,
     
    17131717                        buildActionMask = 2147483647;
    17141718                        files = (
     1719                                29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */,
    17151720                                A864B3F6123ED9FA00C2A612 /* MailQuirksUserScript.js in Resources */,
    17161721                                939810BA0824BF01008DF038 /* IDNScriptWhiteList.txt in Resources */,
     
    20162021                                BC42D34D131ED3880075FA4B /* WebLocalizableStringsInternal.mm in Sources */,
    20172022                                B82958D4132707D0000D0E79 /* CorrectionPanel.mm in Sources */,
     2023                                29AEF95E134C755400FE5096 /* OutlookQuirksUserScript.js in Sources */,
    20182024                        );
    20192025                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebKit/mac/ChangeLog

    r83133 r83201  
     12011-04-07  Andy Estes  <aestes@apple.com>
     2
     3        Reviewed by Darin Adler.
     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  Dai Mikurube  <dmikurube@chromium.org>
    242
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r82386 r83201  
    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
     
    640640}
    641641
    642 static NSString *leakMailQuirksUserScriptPath()
     642static NSString *leakMailQuirksUserScriptContents()
    643643{
    644644    NSString *scriptPath = [[NSBundle bundleForClass:[WebView class]] pathForResource:@"MailQuirksUserScript" ofType:@"js"];
     
    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
     
    720740    _private->page->setCanStartMedia([self window]);
    721741    _private->page->settings()->setLocalStorageDatabasePath([[self preferences] _localStorageDatabasePath]);
     742
     743    if (needsOutlookQuirksScript()) {
     744        _private->page->settings()->setShouldInjectUserScriptsInInitialEmptyDocument(true);
     745        [self _injectOutlookQuirksScript];
     746    }
    722747
    723748    [WebFrame _createMainFrameWithPage:_private->page frameName:frameName frameView:frameView];
Note: See TracChangeset for help on using the changeset viewer.