On Wed, Jun 8, 2016 at 1:05 AM, Tavmjong Bah <tavmjong@...8...> wrote:
- ID's should not be added to the class attribute. They need to be
added to the style sheet which is not easy to do at the moment. The SPStyle class is not very complete.
How should I proceed on this?
The SPStyle class probably needs to keep a parsed copy of the style sheet. It does not have to interpret the style sheet (that is the roll of libcroco). The data can be stored as a map. Something like:
std::map<std::string, std::vectorstd::string >
Where the first string is the selector: .red While the vector of strings keeps track of the properties: fill:red, stroke:blue, etc.
After any change to the map, the style sheet should be rewritten to the style XML node.
So the implementation I did with 'class' attribute, I should discard it? And rather add selector to style attribute of the object?
I should go like:
When '+' is clicked and object(s) is(are) selected, then the selector should be added to 'style' attribute in the form like:
"selector: .red;" or if it is id then "selector: #rect3542"
| V Is this how it should work?
And coming to parsed copy of stylesheet you mentioned, I should create a map first. And add the existing style values in it in the second string. Will this map exist, if no selector exists for the document?
On Wed, 2016-06-08 at 11:35 +0530, Kamalpreet Grewal wrote:
On Wed, Jun 8, 2016 at 1:05 AM, Tavmjong Bah <tavmjong@...8...> wrote:
- ID's should not be added to the class attribute. They need
to be added to the style sheet which is not easy to do at the moment. The SPStyle class is not very complete.
How should I proceed on this?
The SPStyle class probably needs to keep a parsed copy of the style sheet. It does not have to interpret the style sheet (that is the roll of libcroco). The data can be stored as a map. Something like:
std::map<std::string, std::vectorstd::string >
Where the first string is the selector: .red While the vector of strings keeps track of the properties: fill:red, stroke:blue, etc.
After any change to the map, the style sheet should be rewritten to the style XML node.
So the implementation I did with 'class' attribute, I should discard it? And rather add selector to style attribute of the object?
Yes
I should go like:
When '+' is clicked and object(s) is(are) selected, then the selector should be added to 'style' attribute in the form like:
"selector: .red;"
Just .red
or if it is id then "selector: #rect3542"
| V Is this how it should work?
And coming to parsed copy of stylesheet you mentioned, I should create a map first. And add the existing style values in it in the second string. Will this map exist, if no selector exists for the document?
Yes, but it will be empty.
participants (2)
-
Kamalpreet Grewal
-
Tavmjong Bah