WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 37194
Prevent wrong use of PrintContext
https://bugs.webkit.org/show_bug.cgi?id=37194
Summary
Prevent wrong use of PrintContext
Shinichiro Hamaji
Reported
2010-04-07 01:49:53 PDT
We can misuse PrintContext in several ways. We can call PrintContext::begin() twice, we can call PrintContext::end() without PrintContext::begin(), and we can forget PrintContext::end() after PrintContext::begin().
Bug 36049
is an example of such mistakes. Let's add a boolean flag to prevent such misuses.
Attachments
Patch v1
(2.18 KB, patch)
2010-04-07 01:51 PDT
,
Shinichiro Hamaji
no flags
Details
Formatted Diff
Diff
Patch v2
(2.20 KB, patch)
2010-04-07 02:01 PDT
,
Shinichiro Hamaji
eric
: review+
eric
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Shinichiro Hamaji
Comment 1
2010-04-07 01:51:31 PDT
Created
attachment 52714
[details]
Patch v1
Shinichiro Hamaji
Comment 2
2010-04-07 01:59:45 PDT
Comment on
attachment 52714
[details]
Patch v1
> PrintContext::~PrintContext() > { > + if (m_isPrinting) > + end(); > m_pageRects.clear(); > }
Or, we may want to add ASSERT(!m_isPrinting) here. I personally like this kind of automatic release, but I'm not sure if this is suitable for this case. If a user of PrintContext relies on this, her/his code may have begin() without end(), which might look weird a bit. Hmm... I changed my mind while I'm writing this comment. I'll revise the patch.
Shinichiro Hamaji
Comment 3
2010-04-07 02:01:56 PDT
Created
attachment 52716
[details]
Patch v2
Eric Seidel (no email)
Comment 4
2010-04-09 14:03:13 PDT
Comment on
attachment 52716
[details]
Patch v2 if (m_isPrinting) 43 end(); isn't needed. the ASSERT is enough.
Eric Seidel (no email)
Comment 5
2010-04-09 14:04:01 PDT
Comment on
attachment 52716
[details]
Patch v2 You should consider documenting what m_isPrinting is for in teh header, otherwise this looks OK (- the release-only auto-end stuff). r=me with the two above comments addressed.
Yuzo Fujishima
Comment 6
2010-04-09 14:13:12 PDT
Why is m_isPrinting protected rather than private?
Shinichiro Hamaji
Comment 7
2010-04-09 16:41:04 PDT
Committed
r57384
: <
http://trac.webkit.org/changeset/57384
>
Shinichiro Hamaji
Comment 8
2010-04-09 16:43:00 PDT
Thanks for your suggestions! I addressed the three (2 from eric + 1 from yuzo) comments and landed the patch.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug