From df921942eabaf558a1e86f3d536875865e0aee98 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 25 Oct 2011 16:36:38 +0000 Subject: [PATCH] - Restore original file permissions after patching a file (issue #387). - Add the ability to selectively apply patches based on the presence of an environment variable (issue #388). - Add a patch to disable scrollbar bounce and scrollbar overlay on Lion based on the presence of the CEF_SPI_BUILD environment variable (issue #364). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@339 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- patch/patch.cfg | 42 ++++++++++++++++++++--------- patch/patches/spi_webcore_364.patch | 35 ++++++++++++++++++++++++ tools/patch_util.py | 9 +++++++ tools/patcher.py | 31 +++++++++++++-------- 4 files changed, 94 insertions(+), 23 deletions(-) create mode 100644 patch/patches/spi_webcore_364.patch diff --git a/patch/patch.cfg b/patch/patch.cfg index 1ab927280..f4122f7ec 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -1,12 +1,30 @@ -# An element of this array associates a patch file with a target directory. -# All paths in the patch file must be relative to that directory. Each patch -# file entry for source code changes should be proceeded by the code review -# or bug report link that it relates to. -patches = { - # http://codereview.chromium.org/8086022/ - 'build' : '../build/', - # http://codereview.chromium.org/6730028/ - 'base' : '../base/', - # http://code.google.com/p/gyp/issues/detail?id=223 - 'tools_gyp' : '../tools/gyp/', -} +# Each map in the list associates a patch file name with a target path and +# optional condition. All paths in the patch file must be relative to the +# target path. Each map should include a comment linking to the code review +# or bug report that the patch relates to. If a condition is provided the +# patch will only be applied if an environment variable with the specified +# name exists. + +patches = [ + { + # http://codereview.chromium.org/8086022/ + 'name': 'build', + 'path': '../build/', + }, + { + # http://codereview.chromium.org/6730028/ + 'name': 'base', + 'path': '../base/', + }, + { + # http://code.google.com/p/gyp/issues/detail?id=223 + 'name': 'tools_gyp', + 'path': '../tools/gyp/', + }, + { + # http://code.google.com/p/chromiumembedded/issues/detail?id=364 + 'name': 'spi_webcore_364', + 'path': '../third_party/WebKit/Source/WebCore/', + 'condition': 'CEF_SPI_BUILD', + }, +] diff --git a/patch/patches/spi_webcore_364.patch b/patch/patches/spi_webcore_364.patch new file mode 100644 index 000000000..a83633c22 --- /dev/null +++ b/patch/patches/spi_webcore_364.patch @@ -0,0 +1,35 @@ +Index: page/FrameView.cpp +=================================================================== +--- page/FrameView.cpp (revision 97950) ++++ page/FrameView.cpp (working copy) +@@ -152,10 +152,12 @@ + m_page = page; + m_page->addScrollableArea(this); + ++#if 0 + if (m_frame == m_page->mainFrame()) { + ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); + ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); + } ++#endif + } + } + } +Index: platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm +=================================================================== +--- platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm (revision 97950) ++++ platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm (working copy) +@@ -356,9 +356,13 @@ + + bool isScrollbarOverlayAPIAvailable() + { ++#if 0 + static bool apiAvailable = [lookUpNSScrollerImpClass() respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] && + [lookUpNSScrollerImpPairClass() instancesRespondToSelector:@selector(scrollerStyle)]; + return apiAvailable; ++#else ++ return false; ++#endif + } + + #endif // USE(WK_SCROLLBAR_PAINTER) diff --git a/tools/patch_util.py b/tools/patch_util.py index dde6ce69e..990b81f32 100644 --- a/tools/patch_util.py +++ b/tools/patch_util.py @@ -20,7 +20,9 @@ __version__ = "8.12-1" import copy import logging +import os import re +from stat import * # cStringIO doesn't support unicode in 2.5 from StringIO import StringIO from logging import debug, info, warning @@ -500,6 +502,9 @@ def patch_stream(instream, hunks): def patch_hunks(srcname, tgtname, hunks): + # get the current file mode + mode = os.stat(srcname)[ST_MODE] + src = open(srcname, "rb") tgt = open(tgtname, "wb") @@ -509,6 +514,10 @@ def patch_hunks(srcname, tgtname, hunks): tgt.close() src.close() + + # restore the file mode + os.chmod(tgtname, mode) + return True diff --git a/tools/patcher.py b/tools/patcher.py index 2aa720e19..ed5ff723e 100644 --- a/tools/patcher.py +++ b/tools/patcher.py @@ -4,7 +4,7 @@ import pickle from optparse import OptionParser -import os.path +import os import sys from file_util import * from patch_util import * @@ -51,16 +51,25 @@ else: execfile(options.patchconfig, scope) patches = scope["patches"] - for name in patches.keys(): - file = patchdir+'patches/'+name+'.patch' - if not os.path.isfile(file): - sys.stderr.write('Patch file '+file+' does not exist.\n') - else: - sys.stderr.write('Reading patch file '+file+'\n') - dir = patches[name] - patchObj = from_file(file) - patchObj.apply(dir) - + for patch in patches: + file = patchdir+'patches/'+patch['name']+'.patch' + dopatch = True + + if 'condition' in patch: + # Check that the environment variable is set. + if patch['condition'] not in os.environ: + sys.stderr.write('Skipping patch file '+file+'\n') + dopatch = False + + if dopatch: + if not os.path.isfile(file): + sys.stderr.write('Patch file '+file+' does not exist.\n') + else: + sys.stderr.write('Reading patch file '+file+'\n') + dir = patch['path'] + patchObj = from_file(file) + patchObj.apply(dir) + # read the current include file, if any incfile = patchdir + 'patch_state.h' if nopatch: