Closed
Bug 119807
Opened 23 years ago
Closed 23 years ago
Computed color values should support getRGBColorValue
Categories
(Core :: DOM: CSS Object Model, defect, P1)
Core
DOM: CSS Object Model
Tracking
()
RESOLVED
FIXED
mozilla1.0
People
(Reporter: bzbarsky, Assigned: caillon)
Details
Attachments
(1 file, 3 obsolete files)
69.21 KB,
patch
|
bzbarsky
:
review+
caillon
:
superreview+
asa
:
approval+
|
Details | Diff | Splinter Review |
We need an nsIDOMRGBColor implementation (similar to nsIDOMRect). Then we need
to do the right thing for colors instead of setting them to strings.
![]() |
Reporter | |
Updated•23 years ago
|
Priority: -- → P1
Target Milestone: --- → mozilla1.0
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Target Milestone: mozilla1.2 → mozilla1.0
Assignee | ||
Comment 3•23 years ago
|
||
Implement this baby!
Thanks go to Peterv for the mac project changes :)
Also breakup nsComputedDOMStyle to have a header file, and add picas to our
convertible float units.
Assignee | ||
Updated•23 years ago
|
Keywords: review
Summary: Computed color values should support getColorValue → Computed color values should support getRGBColorValue
![]() |
Reporter | |
Comment 4•23 years ago
|
||
Looks pretty good, all told. A few comments:
1) Could you leave the static const nsCSSProperty queryableProperties in the
.cpp file?
2) Could you leave as many headers as possible in the .cpp file?
3) Could you add comments in nsIDOMClassInfo.h and nsDOMClassInfo.cpp right
before the lines you add saying what that stuff is? Yes, I know CSSRect does
not do it.... adding comments to that would be good too. :)
4) + NS_NAMED_LITERAL_STRING(comma, ",");
Shouldn't that have a space after the comma?
5) + nsDOMCSSRGBColor *rgbColor = new nsDOMCSSRGBColor(red, green, blue);
+
+ red->SetNumber(NS_GET_R(aColor));
+ green->SetNumber(NS_GET_G(aColor));
+ blue->SetNumber(NS_GET_B(aColor));
+
+ return rgbColor;
This leaks red/green/blue if the |new nsDOMCSSRGBColor| fails. And we _may_
want to throw out-of-memory exceptions when those |new| calls fail (further
upstream)
Assignee | ||
Comment 5•23 years ago
|
||
Comment on attachment 74620 [details] [diff] [review]
Proposed patch v1.0
Bah. It's just as well that my first patch sucked so badly.
Looking at it again made me realize that |foo { color: ActiveBorder; }| (and
other system colors) had not been accounted for.
New and highly improved patch coming up.
Attachment #74620 -
Attachment is obsolete: true
Attachment #74620 -
Flags: needs-work+
Assignee | ||
Comment 6•23 years ago
|
||
Okay, let's try this again :)
![]() |
Reporter | |
Comment 7•23 years ago
|
||
> .\$(OBJDIR)\nsDOMCSSRect.obj \
>+ .\$(OBJDIR)\nsDOMCSSRGBColor.obj \
Fix the spacing, please.
>- *
>- * This file is very much work in progress, there's a lot of code in this
>- * file that is #ifdef'd out placeholders.
Leave this in please. It's still true till we get CSS2Properties hooked up...
>+ val->SetString(NS_LITERAL_STRING(""));
>+ return NS_ERROR_OUT_OF_MEMORY;
This leaks |val|. You have this in a few places. It also returns an
uninitialized pointer from a getter, no? (even if you _are_ throwing an
exception)
>+ case CSS_IDENT :
>+ {
>+ tmpStr.Append(mValue.mString);
Isn't this identical to CSS_STRING so you can just make them share the code?
> + void SetIdentifier(const nsACString& aString)
I'd be happier if this were called SetIdent, I think
Assignee | ||
Comment 8•23 years ago
|
||
>> .\$(OBJDIR)\nsDOMCSSRect.obj \
>>+ .\$(OBJDIR)\nsDOMCSSRGBColor.obj \
>Fix the spacing, please.
Done. Though the spacing is kind of screwy in general for me in viewing that
file because of the tabs (I have my editor set to display tabs to 4 spaces and
it doesn't look aligned at all in my editor).
>>- *
>>- * This file is very much work in progress, there's a lot of code in this
>>- * file that is #ifdef'd out placeholders.
>Leave this in please. It's still true till we get CSS2Properties hooked up...
Ah, well I didn't remove it because I didn't it was true anymore. Rather I
removed it because I thought it was obvious that it was a work in progress and
didn't need to be explicitly said. Makes no difference either, so I put it
back in (with a grammar fix).
>>+ val->SetString(NS_LITERAL_STRING(""));
>>+ return NS_ERROR_OUT_OF_MEMORY;
>This leaks |val|. You have this in a few places.
Oops. Fixed.
>It also returns an uninitialized pointer from a getter, no?
Per conversation with bz (through email) we'll leave that alone for now since
we also do the same for the NS_ENSURE_TRUE call.
>>+ case CSS_IDENT :
>>+ {
>>+ tmpStr.Append(mValue.mString);
>Isn't this identical to CSS_STRING so you can just make them share the code?
Good catch. Done.
>> + void SetIdentifier(const nsACString& aString)
>I'd be happier if this were called SetIdent, I think
Heh, I actually had it called SetIdent until a few minutes before I diffed
attachment 74471 [details] [diff] [review]. I changed my mind at the last minute for some reason and
that's what got uploaded. Changed it back.
Attachment #74771 -
Attachment is obsolete: true
![]() |
Reporter | |
Comment 9•23 years ago
|
||
+ mValue.mColor = aColor;
+ NS_ADDREF(mValue.mRect);
Eeep. Please addref the right thing. :)
With that, r=bzbarsky
Comment 10•23 years ago
|
||
Comment on attachment 75026 [details] [diff] [review]
Proposed fix v1.2
- In nsComputedDOMStyle::GetDOMCSSRGBColor():
+ nsROCSSPrimitiveValue *red = nsnull;
+ nsROCSSPrimitiveValue *green = nsnull;
+ nsROCSSPrimitiveValue *blue = nsnull;
- PRUint32 len = PR_snprintf(buf, 32, "#%02x%02x%02x",
- NS_GET_R(aColor),
- NS_GET_G(aColor),
- NS_GET_B(aColor));
+ red = GetROCSSPrimitiveValue();
+ green = GetROCSSPrimitiveValue();
+ blue = GetROCSSPrimitiveValue();
Why not assign GetROCSSPrimitiveValue() directly into these variables when you
declare them in stead of the doing two assignments? Assigning null into these
variables here is pointless.
- In nsComputedDOMStyle::GetColor():
+ if (rgb)
+ val->SetColor(rgb);
+ else {
Please add braces around the if statement even if it's only a one line
statement. I found more of these in other places, fix all you can find.
- Eek:
- val->SetString(width); break;
+ val->SetIdent(width); break;
break really needs to be on its own line! I know you didn't write this, but
please change it.
- nsROCSSPrimitiveValue::SetIdent() and ::Reset(). SetIdent() will set
mValue.mString to nuill in an OOM situation, then reset will crash since you're
passing null to nsMemory::Free(). Ideally SetIdent() and all other similar
methods would deal with OOM and let the caller know about the error, and then
make the state of the object such that it's safe to call Reset() on it later
on. Or alternatively Reset() should be safe against OOM.
- In nsIDOMClassInfo.h, don't change the comment style of the comment in the
enum from a C++ style comment to a C style comment. All other comments in that
same enum are C++ style comments, so why should this be different?
sr=jst if you fix that.
Attachment #75026 -
Flags: superreview+
Assignee | ||
Comment 11•23 years ago
|
||
Includes bz's and jst's comments.
Attachment #75026 -
Attachment is obsolete: true
![]() |
Reporter | |
Comment 12•23 years ago
|
||
Comment on attachment 75462 [details] [diff] [review]
Fix v1.3
looks good
Attachment #75462 -
Flags: review+
![]() |
Reporter | |
Comment 13•23 years ago
|
||
Comment on attachment 75462 [details] [diff] [review]
Fix v1.3
looks good
Assignee | ||
Comment 14•23 years ago
|
||
Comment on attachment 75462 [details] [diff] [review]
Fix v1.3
transferring sr=jst
Attachment #75462 -
Flags: superreview+
Comment 15•23 years ago
|
||
Comment on attachment 75462 [details] [diff] [review]
Fix v1.3
a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #75462 -
Flags: approval+
Assignee | ||
Comment 16•23 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•